From 6ff638c972475dce2829e098491ed37156f99ebb Mon Sep 17 00:00:00 2001 From: Joyce Huang Date: Thu, 24 Oct 2019 13:37:02 -0500 Subject: [PATCH 1/9] init commit --- dist/appid.min.js | 385 ++++++++++++++++++++++++++++++++++------ dist/appid.umd.min.js | 395 ++++++++++++++++++++++++++++++++++++------ src/RequestHandler.js | 4 + src/constants.js | 2 + src/index.js | 31 +++- src/utils.js | 10 +- 6 files changed, 721 insertions(+), 106 deletions(-) diff --git a/dist/appid.min.js b/dist/appid.min.js index f4536bb..c15f773 100644 --- a/dist/appid.min.js +++ b/dist/appid.min.js @@ -1,50 +1,335 @@ -var AppID=function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=4)}([function(t,e,i){(function(t){var i={userAgent:!1},n={}; -/*! -Copyright (c) 2011, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.9.0 -*/ -if(void 0===r)var r={};r.lang={extend:function(t,e,n){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),n){var s;for(s in n)t.prototype[s]=n[s];var o=function(){},a=["toString","valueOf"];try{/MSIE/.test(i.userAgent)&&(o=function(t,e){for(s=0;s>>2]>>>24-s%4*8&255;e[n+s>>>2]|=o<<24-(n+s)%4*8}else for(s=0;s>>2]=i[s>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=s.ceil(e/4)},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i>>2]>>>24-r%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new u.init(i,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,i=t.sigBytes,n=[],r=0;r>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new u.init(i,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},g=a.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,n=e.sigBytes,r=this.blockSize,o=n/(4*r),a=(o=t?s.ceil(o):s.max((0|o)-this._minBufferSize,0))*r,h=s.min(4*a,n);if(a){for(var c=0;c>>2]}},e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:h,padding:c}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(h=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?n.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=n.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:i})}},e.SerializableCipher=i.extend({cfg:i.extend({format:h}),encrypt:function(t,e,i,n){n=this.cfg.extend(n);var r=t.createEncryptor(i,n);return e=r.finalize(e),r=r.cfg,l.create({ciphertext:e,key:i,iv:r.iv,algorithm:t,mode:r.mode,padding:r.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(i,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,i,r){return r||(r=n.random(8)),t=o.create({keySize:e+i}).compute(t,r),i=n.create(t.words.slice(e),4*i),t.sigBytes=4*e,l.create({key:t,iv:i,salt:r})}},g=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:d}),encrypt:function(t,e,i,n){return i=(n=this.cfg.extend(n)).kdf.execute(i,t.keySize,t.ivSize),n.iv=i.iv,(t=f.encrypt.call(this,t,e,i.key,n)).mixIn(i),t},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),i=n.kdf.execute(i,t.keySize,t.ivSize,e.salt),n.iv=i.iv,f.decrypt.call(this,t,e,i.key,n)}})}(),function(){for(var t=y,e=t.lib.BlockCipher,i=t.algo,n=[],r=[],s=[],o=[],a=[],h=[],u=[],c=[],l=[],f=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var p=0,v=0;for(g=0;256>g;g++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;n[p]=m,r[m]=p;var S=d[p],F=d[S],w=d[F],E=257*d[m]^16843008*m;s[p]=E<<24|E>>>8,o[p]=E<<16|E>>>16,a[p]=E<<8|E>>>24,h[p]=E,E=16843009*w^65537*F^257*S^16843008*p,u[m]=E<<24|E>>>8,c[m]=E<<16|E>>>16,l[m]=E<<8|E>>>24,f[m]=E,p?(p=S^d[d[d[w^S]]],v^=d[d[v]]):p=v=1}var x=[0,1,2,4,8,16,32,64,128,27,54];i=i.AES=e.extend({_doReset:function(){for(var t=(i=this._key).words,e=i.sigBytes/4,i=4*((this._nRounds=e+6)+1),r=this._keySchedule=[],s=0;s>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o]):(o=n[(o=o<<8|o>>>24)>>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o],o^=x[s/e|0]<<24),r[s]=r[s-e]^o}for(t=this._invKeySchedule=[],e=0;ee||4>=s?o:u[n[o>>>24]]^c[n[o>>>16&255]]^l[n[o>>>8&255]]^f[n[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,o,a,h,n)},decryptBlock:function(t,e){var i=t[e+1];t[e+1]=t[e+3],t[e+3]=i,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,r),i=t[e+1],t[e+1]=t[e+3],t[e+3]=i},_doCryptBlock:function(t,e,i,n,r,s,o,a){for(var h=this._nRounds,u=t[e]^i[0],c=t[e+1]^i[1],l=t[e+2]^i[2],f=t[e+3]^i[3],d=4,g=1;g>>24]^r[c>>>16&255]^s[l>>>8&255]^o[255&f]^i[d++],y=n[c>>>24]^r[l>>>16&255]^s[f>>>8&255]^o[255&u]^i[d++],v=n[l>>>24]^r[f>>>16&255]^s[u>>>8&255]^o[255&c]^i[d++];f=n[f>>>24]^r[u>>>16&255]^s[c>>>8&255]^o[255&l]^i[d++],u=p,c=y,l=v}p=(a[u>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&f])^i[d++],y=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[f>>>8&255]<<8|a[255&u])^i[d++],v=(a[l>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[255&c])^i[d++],f=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^i[d++],t[e]=p,t[e+1]=y,t[e+2]=v,t[e+3]=f},keySize:8});t.AES=e._createHelper(i)}(),function(){function t(t,e){var i=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=i,this._lBlock^=i<>>t^this._lBlock)&e;this._lBlock^=i,this._rBlock^=i<i;i++){var n=o[i]-1;e[i]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;16>n;n++){var r=t[n]=[],s=h[n];for(i=0;24>i;i++)r[i/6|0]|=e[(a[i]-1+s)%28]<<31-i%6,r[4+(i/6|0)]|=e[28+(a[i+24]-1+s)%28]<<31-i%6;for(r[0]=r[0]<<1|r[0]>>>31,i=1;7>i;i++)r[i]>>>=4*(i-1)+3;r[7]=r[7]<<5|r[7]>>>27}for(e=this._invSubKeys=[],i=0;16>i;i++)e[i]=t[15-i]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(i,n,r){this._lBlock=i[n],this._rBlock=i[n+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var o=r[s],a=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^o[f])&c[f])>>>0];this._lBlock=h,this._rBlock=a^l}r=this._lBlock,this._lBlock=this._rBlock,this._rBlock=r,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),i[n]=this._lBlock,i[n+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});i.DES=r._createHelper(l),s=s.TripleDES=r.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(n.create(t.slice(0,2))),this._des2=l.createEncryptor(n.create(t.slice(2,4))),this._des3=l.createEncryptor(n.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),i.TripleDES=r._createHelper(s)}(),function(){var t=y,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,i=t.sigBytes,n=this._map;t.clamp(),t=[];for(var r=0;r>>2]>>>24-r%4*8&255)<<16|(e[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|e[r+2>>>2]>>>24-(r+2)%4*8&255,o=0;4>o&&r+.75*o>>6*(3-o)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var i=t.length,n=this._map;(r=n.charAt(64))&&(-1!=(r=t.indexOf(r))&&(i=r));for(var r=[],s=0,o=0;o>>6-o%4*2;r[s>>>2]|=(a|h)<<24-s%4*8,s++}return e.create(r,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,i,n,r,s,o){return((t=t+(e&i|~e&n)+r+o)<>>32-s)+e}function i(t,e,i,n,r,s,o){return((t=t+(e&n|i&~n)+r+o)<>>32-s)+e}function n(t,e,i,n,r,s,o){return((t=t+(e^i^n)+r+o)<>>32-s)+e}function r(t,e,i,n,r,s,o){return((t=t+(i^(e|~n))+r+o)<>>32-s)+e}for(var s=y,o=(h=s.lib).WordArray,a=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var o=0;16>o;o++){var a=t[h=s+o];t[h]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var h=t[s+0],c=(a=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],d=t[s+5],g=t[s+6],p=t[s+7],y=t[s+8],v=t[s+9],m=t[s+10],S=t[s+11],F=t[s+12],w=t[s+13],E=t[s+14],x=t[s+15],A=e(A=o[0],C=o[1],I=o[2],b=o[3],h,7,u[0]),b=e(b,A,C,I,a,12,u[1]),I=e(I,b,A,C,c,17,u[2]),C=e(C,I,b,A,l,22,u[3]);A=e(A,C,I,b,f,7,u[4]),b=e(b,A,C,I,d,12,u[5]),I=e(I,b,A,C,g,17,u[6]),C=e(C,I,b,A,p,22,u[7]),A=e(A,C,I,b,y,7,u[8]),b=e(b,A,C,I,v,12,u[9]),I=e(I,b,A,C,m,17,u[10]),C=e(C,I,b,A,S,22,u[11]),A=e(A,C,I,b,F,7,u[12]),b=e(b,A,C,I,w,12,u[13]),I=e(I,b,A,C,E,17,u[14]),A=i(A,C=e(C,I,b,A,x,22,u[15]),I,b,a,5,u[16]),b=i(b,A,C,I,g,9,u[17]),I=i(I,b,A,C,S,14,u[18]),C=i(C,I,b,A,h,20,u[19]),A=i(A,C,I,b,d,5,u[20]),b=i(b,A,C,I,m,9,u[21]),I=i(I,b,A,C,x,14,u[22]),C=i(C,I,b,A,f,20,u[23]),A=i(A,C,I,b,v,5,u[24]),b=i(b,A,C,I,E,9,u[25]),I=i(I,b,A,C,l,14,u[26]),C=i(C,I,b,A,y,20,u[27]),A=i(A,C,I,b,w,5,u[28]),b=i(b,A,C,I,c,9,u[29]),I=i(I,b,A,C,p,14,u[30]),A=n(A,C=i(C,I,b,A,F,20,u[31]),I,b,d,4,u[32]),b=n(b,A,C,I,y,11,u[33]),I=n(I,b,A,C,S,16,u[34]),C=n(C,I,b,A,E,23,u[35]),A=n(A,C,I,b,a,4,u[36]),b=n(b,A,C,I,f,11,u[37]),I=n(I,b,A,C,p,16,u[38]),C=n(C,I,b,A,m,23,u[39]),A=n(A,C,I,b,w,4,u[40]),b=n(b,A,C,I,h,11,u[41]),I=n(I,b,A,C,l,16,u[42]),C=n(C,I,b,A,g,23,u[43]),A=n(A,C,I,b,v,4,u[44]),b=n(b,A,C,I,F,11,u[45]),I=n(I,b,A,C,x,16,u[46]),A=r(A,C=n(C,I,b,A,c,23,u[47]),I,b,h,6,u[48]),b=r(b,A,C,I,p,10,u[49]),I=r(I,b,A,C,E,15,u[50]),C=r(C,I,b,A,d,21,u[51]),A=r(A,C,I,b,F,6,u[52]),b=r(b,A,C,I,l,10,u[53]),I=r(I,b,A,C,m,15,u[54]),C=r(C,I,b,A,a,21,u[55]),A=r(A,C,I,b,y,6,u[56]),b=r(b,A,C,I,x,10,u[57]),I=r(I,b,A,C,g,15,u[58]),C=r(C,I,b,A,w,21,u[59]),A=r(A,C,I,b,f,6,u[60]),b=r(b,A,C,I,S,10,u[61]),I=r(I,b,A,C,c,15,u[62]),C=r(C,I,b,A,v,21,u[63]);o[0]=o[0]+A|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+b|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;i[r>>>5]|=128<<24-r%32;var s=t.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(i.length+1),this._process(),i=(e=this._hash).words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=a._createHelper(h),s.HmacMD5=a._createHmacHelper(h)}(Math),function(){var t=y,e=(r=t.lib).WordArray,i=r.Hasher,n=[],r=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=this._hash.words,r=i[0],s=i[1],o=i[2],a=i[3],h=i[4],u=0;80>u;u++){if(16>u)n[u]=0|t[e+u];else{var c=n[u-3]^n[u-8]^n[u-14]^n[u-16];n[u]=c<<1|c>>>31}c=(r<<5|r>>>27)+h+n[u],c=20>u?c+(1518500249+(s&o|~s&a)):40>u?c+(1859775393+(s^o^a)):60>u?c+((s&o|s&a|o&a)-1894007588):c+((s^o^a)-899497514),h=a,a=o,o=s<<30|s>>>2,s=r,r=c}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+o|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(i/4294967296),e[15+(n+64>>>9<<4)]=i,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=i._createHelper(r),t.HmacSHA1=i._createHmacHelper(r)}(),function(t){for(var e=y,i=(r=e.lib).WordArray,n=r.Hasher,r=e.algo,s=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=a(t.pow(h,.5))),o[u]=a(t.pow(h,1/3)),u++),h++}var d=[];r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(t,e){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],a=i[3],h=i[4],u=i[5],c=i[6],l=i[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var g=d[f-15],p=d[f-2];d[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[f-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[f-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+o[f]+d[f],p=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&r^n&s^r&s),l=c,c=u,u=h,h=a+g|0,a=s,s=r,r=n,n=g+p|0}i[0]=i[0]+n|0,i[1]=i[1]+r|0,i[2]=i[2]+s|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0,i[5]=i[5]+u|0,i[6]=i[6]+c|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return i[r>>>5]|=128<<24-r%32,i[14+(r+64>>>9<<4)]=t.floor(n/4294967296),i[15+(r+64>>>9<<4)]=n,e.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(r),e.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var t=y,e=t.lib.WordArray,i=(n=t.algo).SHA256,n=n.SHA224=i.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=i._createHelper(n),t.HmacSHA224=i._createHmacHelper(n)}(),function(){function t(){return n.create.apply(n,arguments)}for(var e=y,i=e.lib.Hasher,n=(s=e.x64).Word,r=s.WordArray,s=e.algo,o=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],a=[],h=0;80>h;h++)a[h]=t();s=s.SHA512=i.extend({_doReset:function(){this._hash=new r.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var i=(l=this._hash.words)[0],n=l[1],r=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=i.high,d=i.low,g=n.high,p=n.low,y=r.high,v=r.low,m=s.high,S=s.low,F=h.high,w=h.low,E=u.high,x=u.low,A=c.high,b=c.low,I=l.high,C=l.low,D=f,T=d,P=g,R=p,H=y,B=v,N=m,O=S,j=F,V=w,L=E,_=x,K=A,k=b,M=I,U=C,q=0;80>q;q++){var z=a[q];if(16>q)var Y=z.high=0|t[e+2*q],G=z.low=0|t[e+2*q+1];else{Y=((G=(Y=a[q-15]).high)>>>1|(J=Y.low)<<31)^(G>>>8|J<<24)^G>>>7;var J=(J>>>1|G<<31)^(J>>>8|G<<24)^(J>>>7|G<<25),W=((G=(W=a[q-2]).high)>>>19|(X=W.low)<<13)^(G<<3|X>>>29)^G>>>6,X=(X>>>19|G<<13)^(X<<3|G>>>29)^(X>>>6|G<<26),Z=(G=a[q-7]).high,$=(Q=a[q-16]).high,Q=Q.low;Y=(Y=(Y=Y+Z+((G=J+G.low)>>>0>>0?1:0))+W+((G=G+X)>>>0>>0?1:0))+$+((G=G+Q)>>>0>>0?1:0);z.high=Y,z.low=G}Z=j&L^~j&K,Q=V&_^~V&k,z=D&P^D&H^P&H;var tt=T&R^T&B^R&B,et=(J=(D>>>28|T<<4)^(D<<30|T>>>2)^(D<<25|T>>>7),W=(T>>>28|D<<4)^(T<<30|D>>>2)^(T<<25|D>>>7),(X=o[q]).high),it=X.low;$=M+((j>>>14|V<<18)^(j>>>18|V<<14)^(j<<23|V>>>9))+((X=U+((V>>>14|j<<18)^(V>>>18|j<<14)^(V<<23|j>>>9)))>>>0>>0?1:0),M=K,U=k,K=L,k=_,L=j,_=V,j=N+($=($=($=$+Z+((X=X+Q)>>>0>>0?1:0))+et+((X=X+it)>>>0>>0?1:0))+Y+((X=X+G)>>>0>>0?1:0))+((V=O+X|0)>>>0>>0?1:0)|0,N=H,O=B,H=P,B=R,P=D,R=T,D=$+(z=J+z+((G=W+tt)>>>0>>0?1:0))+((T=X+G|0)>>>0>>0?1:0)|0}d=i.low=d+T,i.high=f+D+(d>>>0>>0?1:0),p=n.low=p+R,n.high=g+P+(p>>>0>>0?1:0),v=r.low=v+B,r.high=y+H+(v>>>0>>0?1:0),S=s.low=S+O,s.high=m+N+(S>>>0>>0?1:0),w=h.low=w+V,h.high=F+j+(w>>>0>>0?1:0),x=u.low=x+_,u.high=E+L+(x>>>0<_>>>0?1:0),b=c.low=b+k,c.high=A+K+(b>>>0>>0?1:0),C=l.low=C+U,l.high=I+M+(C>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(i/4294967296),e[31+(n+128>>>10<<5)]=i,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=i._createHelper(s),e.HmacSHA512=i._createHmacHelper(s)}(),function(){var t=y,e=(r=t.x64).Word,i=r.WordArray,n=(r=t.algo).SHA512,r=r.SHA384=n.extend({_doReset:function(){this._hash=new i.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(r),t.HmacSHA384=n._createHmacHelper(r)}(),function(){var t=y,e=(n=t.lib).WordArray,i=n.Hasher,n=t.algo,r=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),o=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);n=n.RIPEMD160=i.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=0;16>i;i++){var n=t[F=e+i];t[F]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var c,l,f,d,g,p,y,v,m,S,F=this._hash.words,w=(n=h.words,u.words),E=r.words,x=s.words,A=o.words,b=a.words;p=c=F[0],y=l=F[1],v=f=F[2],m=d=F[3],S=g=F[4];var I;for(i=0;80>i;i+=1)I=c+t[e+E[i]]|0,I=16>i?I+((l^f^d)+n[0]):32>i?I+((l&f|~l&d)+n[1]):48>i?I+(((l|~f)^d)+n[2]):64>i?I+((l&d|f&~d)+n[3]):I+((l^(f|~d))+n[4]),I=(I=(I|=0)<>>32-A[i])+g|0,c=g,g=d,d=f<<10|f>>>22,f=l,l=I,I=p+t[e+x[i]]|0,I=16>i?I+((y^(v|~m))+w[0]):32>i?I+((y&m|v&~m)+w[1]):48>i?I+(((y|~v)^m)+w[2]):64>i?I+((y&v|~y&m)+w[3]):I+((y^v^m)+w[4]),I=(I=(I|=0)<>>32-b[i])+S|0,p=S,S=m,m=v<<10|v>>>22,v=y,y=I;I=F[1]+f+m|0,F[1]=F[2]+d+S|0,F[2]=F[3]+g+p|0,F[3]=F[4]+c+y|0,F[4]=F[0]+l+v|0,F[0]=I},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,i=0;5>i;i++)n=e[i],e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(n),t.HmacRIPEMD160=i._createHmacHelper(n)}(Math),function(){var t=y,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,i){t=this._hasher=new t.init,"string"==typeof i&&(i=e.parse(i));var n=t.blockSize,r=4*n;i.sigBytes>r&&(i=t.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),o=this._iKey=i.clone(),a=s.words,h=o.words,u=0;u>6)+m.charAt(63&i);if(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),n+=m.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),n+=m.charAt(i>>2)+m.charAt((3&i)<<4)),S)for(;(3&n.length)>0;)n+=S;return n}function w(t){var e,i,n,r="",s=0;for(e=0;e>2),i=3&n,s=1):1==s?(r+=T(i<<2|n>>4),i=15&n,s=2):2==s?(r+=T(i),r+=T(n>>2),i=3&n,s=3):(r+=T(i<<2|n>>4),r+=T(15&n),s=0));return 1==s&&(r+=T(i<<2)),r}function E(t){var e,i=w(t),n=new Array;for(e=0;2*e>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;r=((h=o*h+((32767&c)<<15)+i[n]+(1073741823&r))>>>30)+(c>>>15)+a*u+(r>>>30),i[n++]=1073741823&h}return r},v=30):"Netscape"!=i.appName?(x.prototype.am=function(t,e,i,n,r,s){for(;--s>=0;){var o=e*this[t++]+i[n]+r;r=Math.floor(o/67108864),i[n++]=67108863&o}return r},v=26):(x.prototype.am=function(t,e,i,n,r,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;r=((h=o*h+((16383&c)<<14)+i[n]+r)>>28)+(c>>14)+a*u,i[n++]=268435455&h}return r},v=28),x.prototype.DB=v,x.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function B(t){this.m=t}function N(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function K(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function k(){}function M(t){return t}function U(t){this.r2=A(),this.q3=A(),x.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}B.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},B.prototype.revert=function(t){return t},B.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},B.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},B.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},N.prototype.convert=function(t){var e=A();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(x.ZERO)>0&&this.m.subTo(e,e),e},N.prototype.revert=function(t){var e=A();return t.copyTo(e),this.reduce(e),e},N.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},N.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},N.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},x.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},x.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},x.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,r=!1,s=0;--n>=0;){var o=8==i?255&t[n]:P(t,n);o<0?"-"==t.charAt(n)&&(r=!0):(r=!1,0==s?this[this.t++]=o:s+i>this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},x.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},x.prototype.drShiftTo=function(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>r|a,a=(this[i]&s)<=0;--i)e[i]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},x.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,r=this.DB-n,s=(1<>n;for(var o=i+1;o>n;n>0&&(e[this.t-i-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},x.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),r=i.t;for(e.t=r+n.t;--r>=0;)e[r]=0;for(r=0;r=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},x.prototype.divRemTo=function(t,e,i){var n=t.abs();if(!(n.t<=0)){var r=this.abs();if(r.t0?(n.lShiftTo(h,s),r.lShiftTo(h,i)):(n.copyTo(s),r.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<1?s[u-2]>>this.F2:0),f=this.FV/l,d=(1<=0&&(i[i.t++]=1,i.subTo(v,i)),x.ONE.dlShiftTo(u,v),v.subTo(s,s);s.t=0;){var m=i[--p]==c?this.DM:Math.floor(i[p]*f+(i[p-1]+g)*d);if((i[p]+=s.am(0,m,i,y,0,u))0&&i.rShiftTo(h,i),o<0&&x.ZERO.subTo(i,i)}}},x.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},x.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},x.prototype.exp=function(t,e){if(t>4294967295||t<1)return x.ONE;var i=A(),n=A(),r=e.convert(this),s=H(t)-1;for(r.copyTo(i);--s>=0;)if(e.sqrTo(i,n),(t&1<0)e.mulTo(n,r,i);else{var o=i;i=n,n=o}return e.revert(i)},x.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<0)for(a>a)>0&&(r=!0,s=T(i));o>=0;)a>(a+=this.DB-e)):(i=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),i>0&&(r=!0),r&&(s+=T(i));return r?s:"0"},x.prototype.negate=function(){var t=A();return x.ZERO.subTo(this,t),t},x.prototype.abs=function(){return this.s<0?this.negate():this},x.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},x.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+H(this[this.t-1]^this.s&this.DM)},x.prototype.mod=function(t){var e=A();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(x.ZERO)>0&&t.subTo(e,e),e},x.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new B(e):new N(e),this.exp(t,i)},x.ZERO=R(0),x.ONE=R(1),k.prototype.convert=M,k.prototype.revert=M,k.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},k.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=A();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var q=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],z=(1<<26)/q[q.length-1]; -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function Y(){this.i=0,this.j=0,this.S=new Array}x.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},x.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),n=R(i),r=A(),s=A(),o="";for(this.divRemTo(n,r,s);r.signum()>0;)o=(i+s.intValue()).toString(t).substr(1)+o,r.divRemTo(n,r,s);return s.intValue().toString(t)+o},x.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),r=!1,s=0,o=0,a=0;a=i&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),r&&x.ZERO.subTo(this,this)},x.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(x.ONE.shiftLeft(t-1),j,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(x.ONE.shiftLeft(t-1),this);else{var n=new Array,r=7&t;n.length=1+(t>>3),e.nextBytes(n),r>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},x.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},x.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},x.prototype.multiplyLowerTo=function(t,e,i){var n,r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r=0;)i[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},x.prototype.millerRabin=function(t){var e=this.subtract(x.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var n=e.shiftRight(i);(t=t+1>>1)>q.length&&(t=q.length);for(var r=A(),s=0;s>24},x.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},x.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},x.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,r=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[r++]=i|this.s<=0;)n<8?(i=(this[t]&(1<>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(e[r++]=i);return e},x.prototype.equals=function(t){return 0==this.compareTo(t)},x.prototype.min=function(t){return this.compareTo(t)<0?this:t},x.prototype.max=function(t){return this.compareTo(t)>0?this:t},x.prototype.and=function(t){var e=A();return this.bitwiseTo(t,O,e),e},x.prototype.or=function(t){var e=A();return this.bitwiseTo(t,j,e),e},x.prototype.xor=function(t){var e=A();return this.bitwiseTo(t,V,e),e},x.prototype.andNot=function(t){var e=A();return this.bitwiseTo(t,L,e),e},x.prototype.not=function(){for(var t=A(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var c=A();for(n.sqrTo(o[1],c);a<=u;)o[a]=A(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,d=t.t-1,g=!0,p=A();for(r=H(t[d])-1;d>=0;){for(r>=h?l=t[d]>>r-h&u:(l=(t[d]&(1<0&&(l|=t[d-1]>>this.DB+r-h)),a=i;0==(1&l);)l>>=1,--a;if((r-=a)<0&&(r+=this.DB,--d),g)o[l].copyTo(s),g=!1;else{for(;a>1;)n.sqrTo(s,p),n.sqrTo(p,s),a-=2;a>0?n.sqrTo(s,p):(f=s,s=p,p=f),n.mulTo(p,o[l],s)}for(;d>=0&&0==(t[d]&1<=0?(i.subTo(n,i),e&&r.subTo(o,r),s.subTo(a,s)):(n.subTo(i,n),e&&o.subTo(r,o),a.subTo(s,a))}return 0!=n.compareTo(x.ONE)?x.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},x.prototype.pow=function(t){return this.exp(t,new k)},x.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var r=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(r0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(r=e.getLowestSetBit())>0&&e.rShiftTo(r,e),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},x.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=q[q.length-1]){for(e=0;e>8&255,J[W++]^=t>>16&255,J[W++]^=t>>24&255,W>=X&&(W-=X)}((new Date).getTime())}if(null==J){var $;if(J=new Array,W=0,void 0!==n&&(void 0!==n.crypto||void 0!==n.msCrypto)){var Q=n.crypto||n.msCrypto;if(Q.getRandomValues){var tt=new Uint8Array(32);for(Q.getRandomValues(tt),$=0;$<32;++$)J[W++]=tt[$]}else if("Netscape"==i.appName&&i.appVersion<"5"){var et=n.crypto.random(32);for($=0;$>>8,J[W++]=255&$;W=0,Z()}function it(){if(null==G){for(Z(),(G=new Y).init(J),W=0;W>24,(16711680&r)>>16,(65280&r)>>8,255&r]))),r+=1;return n}function ot(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function at(t,e,i){for(var n="",r=0;n.length>24,(16711680&r)>>16,(65280&r)>>8,255&r])),r+=1;return n} -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function ht(t,e){this.x=e,this.q=t}function ut(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?x.ONE:n,this.zinv=null}function ct(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new ut(this,null,null)}nt.prototype.nextBytes=function(t){var e;for(e=0;e0&&e.length>0))throw"Invalid RSA public key";this.n=rt(t,16),this.e=parseInt(e,16)}},ot.prototype.encrypt=function(t){var e=function(t,e){if(e=0&&e>0;){var r=t.charCodeAt(n--);r<128?i[--e]=r:r>127&&r<2048?(i[--e]=63&r|128,i[--e]=r>>6|192):(i[--e]=63&r|128,i[--e]=r>>6&63|128,i[--e]=r>>12|224)}i[--e]=0;for(var s=new nt,o=new Array;e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new x(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var n=i.toString(16);return 0==(1&n.length)?n:"0"+n},ot.prototype.encryptOAEP=function(t,e,i){var n=function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;if(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t.length+2*n+2>e)throw"Message too long for RSA";var a,h="";for(a=0;a>3,e,i);if(null==n)return null;var r=this.doPublic(n);if(null==r)return null;var s=r.toString(16);return 0==(1&s.length)?s:"0"+s},ot.prototype.type="RSA",ot.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},ot.prototype.setPrivate=function(t,e,i){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=i;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16)}},ot.prototype.setPrivateEx=function(t,e,i,n,r,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16),this.p=rt(n,16),this.q=rt(r,16),this.dmp1=rt(s,16),this.dmq1=rt(o,16),this.coeff=rt(a,16)},ot.prototype.generate=function(t,e){var i=new nt,n=t>>1;this.e=parseInt(e,16);for(var r=new x(e,16);;){for(;this.p=new x(t-n,1,i),0!=this.p.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.p.isProbablePrime(10););for(;this.q=new x(n,1,i),0!=this.q.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(x.ONE),a=this.q.subtract(x.ONE),h=o.multiply(a);if(0==h.gcd(r).compareTo(x.ONE)){this.n=this.p.multiply(this.q),this.d=r.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},ot.prototype.decrypt=function(t){var e=rt(t,16),i=this.doPrivate(e);return null==i?null: -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function(t,e){for(var i=t.toByteArray(),n=0;n=i.length)return null;for(var r="";++n191&&s<224?(r+=String.fromCharCode((31&s)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&s)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},ot.prototype.decryptOAEP=function(t,e,i){var n=rt(t,16),r=this.doPrivate(n);return null==r?null:function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;for(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t=t.toByteArray(),a=0;a>3,e,i)},ht.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ht.prototype.toBigInteger=function(){return this.x},ht.prototype.negate=function(){return new ht(this.q,this.x.negate().mod(this.q))},ht.prototype.add=function(t){return new ht(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ht.prototype.subtract=function(t){return new ht(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ht.prototype.multiply=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ht.prototype.square=function(){return new ht(this.q,this.x.square().mod(this.q))},ht.prototype.divide=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ut.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO))},ut.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(x.ZERO)&&!this.y.toBigInteger().equals(x.ZERO)},ut.prototype.negate=function(){return new ut(this.curve,this.x,this.y.negate(),this.z)},ut.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),i=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(x.ZERO.equals(i))return x.ZERO.equals(e)?this.twice():this.curve.getInfinity();var n=new x("3"),r=this.x.toBigInteger(),s=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),i.square()),a=o.multiply(i),h=r.multiply(o),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(a).multiply(i).mod(this.curve.q),l=h.multiply(n).multiply(e).subtract(s.multiply(a)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),f=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},ut.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new x("3"),e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=i.multiply(this.z),r=n.multiply(i).mod(this.curve.q),s=this.curve.a.toBigInteger(),o=e.square().multiply(t);x.ZERO.equals(s)||(o=o.add(this.z.square().multiply(s)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(r)).shiftLeft(1).multiply(n).mod(this.curve.q),h=o.multiply(t).multiply(e).subtract(r.shiftLeft(1)).shiftLeft(2).multiply(r).subtract(o.square().multiply(o)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),u)},ut.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add(o?this:r))}return s},ut.prototype.multiplyTwo=function(t,e,i){var n;n=t.bitLength()>i.bitLength()?t.bitLength()-1:i.bitLength()-1;for(var r=this.curve.getInfinity(),s=this.add(e);n>=0;)r=r.twice(),t.testBit(n)?r=i.testBit(n)?r.add(s):r.add(this):i.testBit(n)&&(r=r.add(e)),--n;return r},ct.prototype.getQ=function(){return this.q},ct.prototype.getA=function(){return this.a},ct.prototype.getB=function(){return this.b},ct.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ct.prototype.getInfinity=function(){return this.infinity},ct.prototype.fromBigInteger=function(t){return new ht(this.q,t)},ct.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,i=t.substr(2,e),n=t.substr(e+2,e);return new ut(this,this.fromBigInteger(new x(i,16)),this.fromBigInteger(new x(n,16)));default:return null}}, -/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib - */ -ht.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ut.prototype.getEncoded=function(t){var e=function(t,e){var i=t.toByteArrayUnsigned();if(ei.length;)i.unshift(0);return i},i=this.getX().toBigInteger(),n=this.getY().toBigInteger(),r=e(i,32);return t?n.isEven()?r.unshift(2):r.unshift(3):(r.unshift(4),r=r.concat(e(n,32))),r},ut.decodeFrom=function(t,e){e[0];var i=e.length-1,n=e.slice(1,1+i/2),r=e.slice(1+i/2,1+i);n.unshift(0),r.unshift(0);var s=new x(n),o=new x(r);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.decodeFromHex=function(t,e){e.substr(0,2);var i=e.length-2,n=e.substr(2,i/2),r=e.substr(2+i/2,i/2),s=new x(n,16),o=new x(r,16);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),i=t.y.subtract(this.y).divide(e),n=i.square().subtract(this.x).subtract(t.x),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(x.valueOf(2)),e=this.curve.fromBigInteger(x.valueOf(3)),i=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=i.square().subtract(this.x.multiply(t)),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add2D(o?this:r))}return s},ut.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),i=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),r=this.curve.getQ(),s=e.multiply(e).mod(r),o=t.multiply(t).multiply(t).add(i.multiply(t)).add(n).mod(r);return s.equals(o)},ut.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ut.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),i=this.getY().toBigInteger();if(e.compareTo(x.ONE)<0||e.compareTo(t.subtract(x.ONE))>0)throw new Error("x coordinate out of bounds");if(i.compareTo(x.ONE)<0||i.compareTo(t.subtract(x.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0}; -/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval - */ -var lt=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),i={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,n){return e?i[e]:String.fromCharCode(parseInt(n,16))}var r=new String(""),s=(Object,Array,Object.hasOwnProperty);return function(i,o){var a,h,u=i.match(t),c=u[0],l=!1;"{"===c?a={}:"["===c?a=[]:(a=[],l=!0);for(var f=[a],d=1-l,g=u.length;d=0;)delete i[n[h]]}return o.call(t,e,i)};a=y({"":a},"")}return a}}();void 0!==ft&&ft||(ft={}),void 0!==ft.asn1&&ft.asn1||(ft.asn1={}),ft.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},ft.asn1.DERAbstractString=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=At(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},r.lang.extend(ft.asn1.DERAbstractString,ft.asn1.ASN1Object),ft.asn1.DERAbstractTime=function(t){ft.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var n=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var h=n(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=St(t)},this.setByDateValue=function(t,e,i,n,r,s){var o=new Date(Date.UTC(t,e-1,i,n,r,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},r.lang.extend(ft.asn1.DERAbstractTime,ft.asn1.ASN1Object),ft.asn1.DERAbstractStructured=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},r.lang.extend(ft.asn1.DERAbstractStructured,ft.asn1.ASN1Object),ft.asn1.DERBoolean=function(){ft.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},r.lang.extend(ft.asn1.DERBoolean,ft.asn1.ASN1Object),ft.asn1.DERInteger=function(t){ft.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ft.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},r.lang.extend(ft.asn1.DERInteger,ft.asn1.ASN1Object),ft.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ft.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}ft.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7r.length&&(r=n[i]);return(t=t.replace(r,"::")).slice(1,-1)}function _t(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?Lt(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function Kt(t){for(var e=encodeURIComponent(t),i="",n=0;n"7"?"00"+t:t}function Mt(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,i){var n=parseInt(t);if(n<0||255=2*s)break;if(a>=200)break;n.push(h),o=h,a++}return n},pt.getNthChildIdx=function(t,e,i){return pt.getChildIdx(t,e)[i]},pt.getIdxbyList=function(t,e,i,n){var r,s,o=pt;if(0==i.length){if(void 0!==n&&t.substr(e,2)!==n)throw"checking tag doesn't match: "+t.substr(e,2)+"!="+n;return e}return r=i.shift(),s=o.getChildIdx(t,e),o.getIdxbyList(t,s[r],i,n)},pt.getTLVbyList=function(t,e,i,n){var r=pt,s=r.getIdxbyList(t,e,i);if(void 0===s)throw"can't find nthList object";if(void 0!==n&&t.substr(s,2)!=n)throw"checking tag doesn't match: "+t.substr(s,2)+"!="+n;return r.getTLV(t,s)},pt.getVbyList=function(t,e,i,n,r){var s,o,a=pt;if(void 0===(s=a.getIdxbyList(t,e,i,n)))throw"can't find nthList object";return o=a.getV(t,s),!0===r&&(o=o.substr(2)),o},pt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},i=[],n=t.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var s=t.substr(2),o=[],a=0;a0&&(c=c+"."+h.join(".")),c},pt.dump=function(t,e,i,n){var r=pt,s=r.getV,o=r.dump,a=r.getChildIdx,h=t;t instanceof ft.asn1.ASN1Object&&(h=t.getEncodedHex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var c=e.ommit_long_octet;if("01"==h.substr(i,2))return"00"==(l=s(h,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==h.substr(i,2))return n+"INTEGER "+u(l=s(h,i),c)+"\n";if("03"==h.substr(i,2))return n+"BITSTRING "+u(l=s(h,i),c)+"\n";if("04"==h.substr(i,2)){var l=s(h,i);if(r.isASN1HEX(l)){var f=n+"OCTETSTRING, encapsulates\n";return f+=o(l,e,0,n+" ")}return n+"OCTETSTRING "+u(l,c)+"\n"}if("05"==h.substr(i,2))return n+"NULL\n";if("06"==h.substr(i,2)){var d=s(h,i),g=ft.asn1.ASN1Util.oidHexToInt(d),p=ft.asn1.x509.OID.oid2name(g),y=g.replace(/\./g," ");return""!=p?n+"ObjectIdentifier "+p+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0c"==h.substr(i,2))return n+"UTF8String '"+bt(s(h,i))+"'\n";if("13"==h.substr(i,2))return n+"PrintableString '"+bt(s(h,i))+"'\n";if("14"==h.substr(i,2))return n+"TeletexString '"+bt(s(h,i))+"'\n";if("16"==h.substr(i,2))return n+"IA5String '"+bt(s(h,i))+"'\n";if("17"==h.substr(i,2))return n+"UTCTime "+bt(s(h,i))+"\n";if("18"==h.substr(i,2))return n+"GeneralizedTime "+bt(s(h,i))+"\n";if("30"==h.substr(i,2)){if("3000"==h.substr(i,4))return n+"SEQUENCE {}\n";f=n+"SEQUENCE\n";var v=e;if((2==(F=a(h,i)).length||3==F.length)&&"06"==h.substr(F[0],2)&&"04"==h.substr(F[F.length-1],2)){p=r.oidname(s(h,F[0]));var m=JSON.parse(JSON.stringify(e));m.x509ExtName=p,v=m}for(var S=0;S0){var e=new i({array:this.extensionsArray}),n=new r({explicit:!0,tag:"a3",obj:e});this.asn1Array.push(n)}var s=new i({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertificate,ft.asn1.ASN1Object),ft.asn1.x509.Extension=function(t){ft.asn1.x509.Extension.superclass.constructor.call(this);var e=ft.asn1,i=e.DERObjectIdentifier,n=e.DEROctetString,r=(e.DERBitString,e.DERBoolean),s=e.DERSequence;this.getEncodedHex=function(){var t=new i({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new r),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},r.lang.extend(ft.asn1.x509.Extension,ft.asn1.ASN1Object),ft.asn1.x509.Extension.appendByNameToArray=function(t,e,i){var n=t.toLowerCase(),r=ft.asn1.x509;if("basicconstraints"==n){var s=new r.BasicConstraints(e);i.push(s)}else if("keyusage"==n){s=new r.KeyUsage(e);i.push(s)}else if("crldistributionpoints"==n){s=new r.CRLDistributionPoints(e);i.push(s)}else if("extkeyusage"==n){s=new r.ExtKeyUsage(e);i.push(s)}else if("authoritykeyidentifier"==n){s=new r.AuthorityKeyIdentifier(e);i.push(s)}else if("authorityinfoaccess"==n){s=new r.AuthorityInfoAccess(e);i.push(s)}else if("subjectaltname"==n){s=new r.SubjectAltName(e);i.push(s)}else{if("issueraltname"!=n)throw"unsupported extension name: "+t;s=new r.IssuerAltName(e);i.push(s)}},ft.asn1.x509.KeyUsage=function(t){ft.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Jt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new ft.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var i=t.names,n="000000000",r=0;r-1&&t.push(new ft.asn1.DERInteger({int:this.pathLen}));var e=new ft.asn1.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},r.lang.extend(ft.asn1.x509.BasicConstraints,ft.asn1.x509.Extension),ft.asn1.x509.CRLDistributionPoints=function(t){ft.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ft.asn1,i=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){this.asn1ExtnValue=new e.DERSequence({array:t})},this.setByOneURI=function(t){var e=new i.GeneralNames([{uri:t}]),n=new i.DistributionPointName(e),r=new i.DistributionPoint({dpobj:n});this.setByDPArray([r])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},r.lang.extend(ft.asn1.x509.CRLDistributionPoints,ft.asn1.x509.Extension),ft.asn1.x509.ExtKeyUsage=function(t){ft.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=ft.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var i=0;i0){var t=new i({array:this.aRevokedCert});this.asn1Array.push(t)}var e=new i({array:this.asn1Array});return this.hTLV=e.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize=function(){this.asn1Version=null,this.asn1SignatureAlg=null,this.asn1Issuer=null,this.asn1ThisUpdate=null,this.asn1NextUpdate=null,this.aRevokedCert=new Array},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertList,ft.asn1.ASN1Object),ft.asn1.x509.CRLEntry=function(t){ft.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=ft.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},r.lang.extend(ft.asn1.x509.CRLEntry,ft.asn1.ASN1Object),ft.asn1.x509.X500Name=function(t){ft.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=new Array;var e=ft.asn1,i=e.x509,n=Ht;if(this.setByString=function(t){var e=t.split("/");e.shift();for(var n=[],r=0;r0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},ft.asn1.x509.RDN=function(t){ft.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=new Array,this.addByString=function(t){this.asn1Array.push(new ft.asn1.x509.AttributeTypeAndValue({str:t}))},this.addByMultiValuedString=function(t){for(var e=ft.asn1.x509.RDN.parseString(t),i=0;i0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var a=!1,h=[];for(r=0;n.length>0;r++){s=n.shift();if(!0===a){var u=h.pop();if(s.match(/"$/)){o=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(o),a=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(a=!0)}return h},ft.asn1.x509.AttributeTypeAndValue=function(t){ft.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var e=ft.asn1;this.setByString=function(t){var e=t.match(/^([^=]+)=(.+)$/);if(!e)throw"malformed attrTypeAndValueStr: "+t;this.setByAttrTypeAndValueStr(e[1],e[2])},this.setByAttrTypeAndValueStr=function(t,e){this.typeObj=ft.asn1.x509.OID.atype2obj(t);var i="utf8";"C"==t&&(i="prn"),this.valueObj=this.getValueObj(i,e)},this.getValueObj=function(t,i){if("utf8"==t)return new e.DERUTF8String({str:i});if("prn"==t)return new e.DERPrintableString({str:i});if("tel"==t)return new e.DERTeletexString({str:i});if("ia5"==t)return new e.DERIA5String({str:i});throw"unsupported directory string type: type="+t+" value="+i},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.typeObj,this.valueObj]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&void 0!==t.str&&this.setByString(t.str)},r.lang.extend(ft.asn1.x509.AttributeTypeAndValue,ft.asn1.ASN1Object),ft.asn1.x509.SubjectPublicKeyInfo=function(t){ft.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ft,i=e.asn1,n=i.DERInteger,r=i.DERBitString,s=i.DERObjectIdentifier,o=i.DERSequence,a=i.ASN1Util.newObject,h=i.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof ot){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+e})}}catch(t){}try{if(t instanceof ft.crypto.ECDSA){var i=new s({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ft.crypto.DSA){i=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new h({name:"dsa",asn1params:i});var o=new n({bigint:t.y});this.asn1SubjPKey=new r({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},r.lang.extend(ft.asn1.x509.SubjectPublicKeyInfo,ft.asn1.ASN1Object),ft.asn1.x509.Time=function(t){ft.asn1.x509.Time.superclass.constructor.call(this);var e=ft.asn1,i=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},r.lang.extend(ft.asn1.x509.Time,ft.asn1.ASN1Object),ft.asn1.x509.AlgorithmIdentifier=function(t){ft.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ft.asn1;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw"algorithm not specified";null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var t=[this.asn1Alg];null!==this.asn1Params&&t.push(this.asn1Params);var i=new e.DERSequence({array:t});return this.hTLV=i.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},r.lang.extend(ft.asn1.x509.AlgorithmIdentifier,ft.asn1.ASN1Object),ft.asn1.x509.GeneralName=function(t){ft.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=ft.asn1,n=(i.DERSequence,i.DEROctetString),r=i.DERIA5String,s=i.DERTaggedObject,o=i.ASN1Object,a=i.x509.X500Name,h=Ht;this.explicit=!1,this.setByParam=function(t){var i=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",i=new r({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",i=new r({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",i=new r({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,i=new a({str:t.dn})),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var u=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certissuer param not cert";(f=new Jt).hex=u;var c=f.getIssuerHex();(i=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;u=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certsubj param not cert";(f=new Jt).hex=u;c=f.getSubjectHex();(i=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,g=t.ip,p="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(d=Mt("["+g.split(".").join(",")+"]")).length)throw p}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=Vt(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw p;d=g}i=new n({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},r.lang.extend(ft.asn1.x509.GeneralName,ft.asn1.ASN1Object),ft.asn1.x509.GeneralNames=function(t){ft.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ft.asn1;this.setByParamArray=function(t){for(var i=0;i0&&(e=new n({obj:this.dUnsignedAttrs,tag:"a1",explicit:!1}));var r=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,t,this.dSigAlg,this.dSig];null!=e&&r.push(e);var o=new i.DERSequence({array:r});return this.hTLV=o.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.SignerInfo,ft.asn1.ASN1Object),ft.asn1.cms.EncapsulatedContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.dEContentType=new r({name:"data"}),this.dEContent=null,this.isDetached=!1,this.eContentValueHex=null,this.setContentType=function(t){t.match(/^[0-2][.][0-9.]+$/)?this.dEContentType=new r({oid:t}):this.dEContentType=new r({name:t})},this.setContentValue=function(t){void 0!==t&&("string"==typeof t.hex?this.eContentValueHex=t.hex:"string"==typeof t.str&&(this.eContentValueHex=At(t.str)))},this.setContentValueHex=function(t){this.eContentValueHex=t},this.setContentValueStr=function(t){this.eContentValueHex=At(t)},this.getEncodedHex=function(){if("string"!=typeof this.eContentValueHex)throw"eContentValue not yet set";var t=new s({hex:this.eContentValueHex});this.dEContent=new i({obj:t,tag:"a0",explicit:!0});var e=[this.dEContentType];this.isDetached||e.push(this.dEContent);var r=new n({array:e});return this.hTLV=r.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.EncapsulatedContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.ContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.x509;ft.asn1.cms.ContentInfo.superclass.constructor.call(this),this.dContentType=null,this.dContent=null,this.setContentType=function(t){"string"==typeof t&&(this.dContentType=r.OID.name2obj(t))},this.getEncodedHex=function(){var t=new i({obj:this.dContent,tag:"a0",explicit:!0}),e=new n({array:[this.dContentType,t]});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t&&(t.type&&this.setContentType(t.type),t.obj&&t.obj instanceof e.ASN1Object&&(this.dContent=t.obj))},r.lang.extend(ft.asn1.cms.ContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.SignedData=function(t){var e=ft.asn1,i=e.ASN1Object,n=e.DERInteger,r=e.DERSet,s=e.DERSequence,o=e.DERTaggedObject,a=e.cms,h=a.EncapsulatedContentInfo,u=a.SignerInfo,c=a.ContentInfo,l=e.x509.AlgorithmIdentifier;ft.asn1.cms.SignedData.superclass.constructor.call(this),this.dCMSVersion=new n({int:1}),this.dDigestAlgs=null,this.digestAlgNameList=[],this.dEncapContentInfo=new h,this.dCerts=null,this.certificateList=[],this.crlList=[],this.signerInfoList=[new u],this.addCertificatesByPEM=function(t){var e=Ht(t),n=new i;n.hTLV=e,this.certificateList.push(n)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(null==this.dDigestAlgs){for(var t=[],e=0;e0){var h=new r({array:this.certificateList});this.dCerts=new o({obj:h,tag:"a0",explicit:!1})}null!=this.dCerts&&a.push(this.dCerts);var u=new r({array:this.signerInfoList});a.push(u);var c=new s({array:a});return this.hTLV=c.getEncodedHex(),this.hTLV},this.getContentInfo=function(){return this.getEncodedHex(),new c({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},this.getPEM=function(){return Rt(this.getContentInfoEncodedHex(),"CMS")}},r.lang.extend(ft.asn1.cms.SignedData,ft.asn1.ASN1Object),ft.asn1.cms.CMSUtil=new function(){},ft.asn1.cms.CMSUtil.newSignedData=function(t){var e=ft.asn1,i=e.cms,n=i.SignerInfo,r=i.SignedData,s=i.SigningTime,o=i.SigningCertificate,a=i.SigningCertificateV2,h=e.cades.SignaturePolicyIdentifier,u=new r;if(u.dEncapContentInfo.setContentValue(t.content),"object"==typeof t.certs)for(var c=0;c0){var t=new n({array:this.extensionsArray}),e=new r({array:[t]}),i=new n({array:[new a({oid:"1.2.840.113549.1.9.14"}),e]}),h=new o({explicit:!0,tag:"a0",obj:i});this.asn1Array.push(h)}else{h=new o({explicit:!1,tag:"a0",obj:new s});this.asn1Array.push(h)}var u=new n({array:this.asn1Array});return this.hTLV=u.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.csr.CertificationRequestInfo,ft.asn1.ASN1Object),ft.asn1.csr.CSRUtil=new function(){},ft.asn1.csr.CSRUtil.newCSRPEM=function(t){var e=Ut,i=ft.asn1.csr;if(void 0===t.subject)throw"parameter subject undefined";if(void 0===t.sbjpubkey)throw"parameter sbjpubkey undefined";if(void 0===t.sigalg)throw"parameter sigalg undefined";if(void 0===t.sbjprvkey)throw"parameter sbjpubkey undefined";var n=new i.CertificationRequestInfo;if(n.setSubjectByParam(t.subject),n.setSubjectPublicKeyByGetKey(t.sbjpubkey),void 0!==t.ext&&void 0!==t.ext.length)for(var r=0;rr)throw"key is too short for SigAlg: keylen="+i+","+e;for(var s="0001",o="00"+n,a="",h=r-s.length-o.length,u=0;u=0)return!1;if(i.compareTo(x.ONE)<0||i.compareTo(r)>=0)return!1;var o=i.modInverse(r),a=t.multiply(o).mod(r),h=e.multiply(o).mod(r);return s.multiply(a).add(n.multiply(h)).getX().toBigInteger().mod(r).equals(e)},this.serializeSig=function(t,e){var i=t.toByteArraySigned(),n=e.toByteArraySigned(),r=[];return r.push(2),r.push(i.length),(r=r.concat(i)).push(2),r.push(n.length),(r=r.concat(n)).unshift(r.length),r.unshift(48),r},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:x.fromByteArrayUnsigned(i),s:x.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:x.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:x.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[2,0],"06"),i=o(t,0,[1],"04");try{n=o(t,0,[3,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#1/5 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{o(t,0,[1,0],"06"),e=o(t,0,[1,1],"06"),i=o(t,0,[2,0,1],"04");try{n=o(t,0,[2,0,2,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#8 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){var e,i,n=pt,r=ft.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{s(t,0,[0,0],"06"),e=s(t,0,[0,1],"06"),i=s(t,0,[1],"03").substr(2)}catch(t){throw"malformed PKCS#8 ECC public key"}if(this.curveName=r(e),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,e){5!==e&&(e=6);var i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{i=o(t,0,[0,e,0,1],"06"),n=o(t,0,[0,e,1],"03").substr(2)}catch(t){throw"malformed X.509 certificate ECC public key"}if(this.curveName=s(i),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ft.crypto.ECDSA.parseSigHex=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new x(e.r,16),s:new x(e.s,16)}},ft.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=pt,i=e.getChildIdx,n=e.getV;if("30"!=t.substr(0,2))throw"signature is not a ASN.1 sequence";var r=i(t,0);if(2!=r.length)throw"number of signature ASN.1 sequence elements seem wrong";var s=r[0],o=r[1];if("02"!=t.substr(s,2))throw"1st item of sequene of signature is not ASN.1 integer";if("02"!=t.substr(o,2))throw"2nd item of sequene of signature is not ASN.1 integer";return{r:n(t,s),s:n(t,o)}},ft.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t),i=e.r,n=e.s;if("00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),i.length%32==30&&(i="00"+i),n.length%32==30&&(n="00"+n),i.length%32!=0)throw"unknown ECDSA sig r length error";if(n.length%32!=0)throw"unknown ECDSA sig s length error";return i+n},ft.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var e=t.substr(0,t.length/2),i=t.substr(t.length/2);return ft.crypto.ECDSA.hexRSSigToASN1Sig(e,i)},ft.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var i=new x(t,16),n=new x(e,16);return ft.crypto.ECDSA.biRSSigToASN1Sig(i,n)},ft.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var i=ft.asn1,n=new i.DERInteger({bigint:t}),r=new i.DERInteger({bigint:e});return new i.DERSequence({array:[n,r]}).getEncodedHex()},ft.crypto.ECDSA.getName=function(t){return"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040022"===t?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":null},void 0!==ft&&ft||(ft={}),void 0!==ft.crypto&&ft.crypto||(ft.crypto={}),ft.crypto.ECParameterDB=new function(){var t={},e={};function i(t){return new x(t,16)}this.getByName=function(i){var n=i;if(void 0!==e[n]&&(n=e[i]),void 0!==t[n])return t[n];throw"unregistered EC curve name: "+n},this.regist=function(n,r,s,o,a,h,u,c,l,f,d,g){t[n]={};var p=i(s),y=i(o),v=i(a),m=i(h),S=i(u),F=new ct(p,y,v),w=F.decodePointHex("04"+c+l);t[n].name=n,t[n].keylen=r,t[n].curve=F,t[n].G=w,t[n].n=m,t[n].h=S,t[n].oid=d,t[n].info=g;for(var E=0;E1?new x(n,16):null,u=new x(r,16),this.setPrivate(s,o,a,h,u)},this.setPublic=function(t,e,i,n){this.isPublic=!0,this.p=t,this.q=e,this.g=i,this.y=n,this.x=null},this.setPublicHex=function(t,e,i,n){var r,s,o,a;r=new x(t,16),s=new x(e,16),o=new x(i,16),a=new x(n,16),this.setPublic(r,s,o,a)},this.signWithMessageHash=function(t){var e=this.p,i=this.q,n=this.g,r=(this.y,this.x),s=ft.crypto.Util.getRandomBigIntegerMinToMax(x.ONE.add(x.ONE),i.subtract(x.ONE)),o=new x(t.substr(0,i.bitLength()/4),16),a=n.modPow(s,e).mod(i),h=s.modInverse(i).multiply(o.add(r.multiply(a))).mod(i);return ft.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:a}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var i=this.p,n=this.q,r=this.g,s=this.y,o=this.parseASN1Signature(e),a=o[0],h=o[1],u=new x(t.substr(0,n.bitLength()/4),16);if(x.ZERO.compareTo(a)>0||a.compareTo(n)>0)throw"invalid DSA signature";if(x.ZERO.compareTo(h)>=0||h.compareTo(n)>0)throw"invalid DSA signature";var c=h.modInverse(n),l=u.multiply(c).mod(n),f=a.multiply(c).mod(n);return 0==r.modPow(l,i).multiply(s.modPow(f,i)).mod(i).mod(n).compareTo(a)},this.parseASN1Signature=function(t){try{return[new x(pt.getVbyList(t,0,[0],"02"),16),new x(pt.getVbyList(t,0,[1],"02"),16)]}catch(t){throw"malformed ASN.1 DSA signature"}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r,s,o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{e=a(t,0,[1],"02"),i=a(t,0,[2],"02"),n=a(t,0,[3],"02"),r=a(t,0,[4],"02"),s=a(t,0,[5],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#1/5 plain DSA private key"}this.setPrivateHex(e,i,n,r,s)},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[1,1,0],"02"),i=o(t,0,[1,1,1],"02"),n=o(t,0,[1,1,2],"02"),r=o(t,0,[2,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 plain DSA private key"}this.setPrivateHex(e,i,n,null,r)},this.readPKCS8PubKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[0,1,0],"02"),i=o(t,0,[0,1,1],"02"),n=o(t,0,[0,1,2],"02"),r=o(t,0,[1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 DSA public key"}this.setPublicHex(e,i,n,r)},this.readCertPubKeyHex=function(t,e){var i,n,r,s;5!==e&&(e=6);var o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{i=a(t,0,[0,e,0,1,0],"02"),n=a(t,0,[0,e,0,1,1],"02"),r=a(t,0,[0,e,0,1,2],"02"),s=a(t,0,[0,e,1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed X.509 certificate DSA public key"}this.setPublicHex(i,n,r,s)}};var Ut=function(){var t=function(t,i,n){return e(y.AES,t,i,n)},e=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=r;var h=t.decrypt(a,s,{iv:o});return y.enc.Hex.stringify(h)},i=function(t,e,i){return n(y.AES,t,e,i)},n=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a=t.encrypt(r,s,{iv:o}),h=y.enc.Hex.parse(a.toString());return y.enc.Base64.stringify(h)},r={"AES-256-CBC":{proc:t,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,i,n){return e(y.TripleDES,t,i,n)},eproc:function(t,e,i){return n(y.TripleDES,t,e,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,i,n){return e(y.DES,t,i,n)},eproc:function(t,e,i){return n(y.DES,t,e,i)},keylen:8,ivlen:8}},s=function(t){var e={},i=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(e.cipher=i[1],e.ivsalt=i[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var r=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(r=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(r=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=r&&-1!=o){var a=t.substring(r+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,i){for(var n=i.substring(0,16),s=y.enc.Hex.parse(n),o=y.enc.Utf8.parse(e),a=r[t].keylen+r[t].ivlen,h="",u=null;;){var c=y.algo.MD5.create();if(null!=u&&c.update(u),c.update(o),c.update(s),u=c.finalize(),(h+=y.enc.Hex.stringify(u)).length>=2*a)break}var l={};return l.keyhex=h.substr(0,2*r[t].keylen),l.ivhex=h.substr(2*r[t].keylen,2*r[t].ivlen),l},a=function(t,e,i,n){var s=y.enc.Base64.parse(t),o=y.enc.Hex.stringify(s);return(0,r[e].proc)(o,i,n)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,i){return o(t,e,i)},decryptKeyB64:function(t,e,i,n){return a(t,e,i,n)},getDecryptedKeyHex:function(t,e){var i=s(t),n=(i.type,i.cipher),r=i.ivsalt,h=i.data,u=o(n,e,r).keyhex;return a(h,n,u,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,i,n,s){var a="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===r[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==s&&null!=s||(s=function(t){var e=y.lib.WordArray.random(t);return y.enc.Hex.stringify(e)}(r[n].ivlen).toUpperCase());var h=function(t,e,i,n){return(0,r[e].eproc)(t,i,n)}(e,n,o(n,i,s).keyhex,s);a="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+n+","+s+"\r\n",a+="\r\n",a+=h.replace(/(.{64})/g,"$1\r\n"),a+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={},s=i(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;r.ciphertext=n(t,s[1]);var o=i(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=i(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var h=i(t,a[1]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length;if("2a864886f70d0307"!=n(t,h[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(t,h[1]);var u=i(t,a[0]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length;if("2a864886f70d01050c"!=n(t,u[0]))throw"this only supports pkcs5PBKDF2";var c=i(t,u[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;r.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{r.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return r},getPBKDF2KeyHexFromParam:function(t,e){var i=y.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,r=y.PBKDF2(e,i,{keySize:6,iterations:n});return y.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var i=Ht(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=Ut.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=y.enc.Hex.parse(n.ciphertext);var o=y.enc.Hex.parse(r),a=y.enc.Hex.parse(n.encryptionSchemeIV),h=y.TripleDES.decrypt(s,o,{iv:a});return y.enc.Hex.stringify(h)},getKeyFromEncryptedPKCS8PEM:function(t,e){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var s=i(t,0);if(3!=s.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(s[1],2))throw"malformed PKCS8 private key(code:003)";var o=i(t,s[1]);if(2!=o.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(o[0],2))throw"malformed PKCS8 private key(code:005)";if(r.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(r.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw"malformed PKCS8 private key(code:006)";return r.keyidx=e.getVidx(t,s[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Ht(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,i=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==i.algoid)e=new ot;else if("2a8648ce380401"==i.algoid)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";e=new ft.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,i=pt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===i)e=new ot;else if("2a8648ce380401"===i)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";e=new ft.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=i(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(r.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return r.e=n(t,s[1]),r},parsePublicPKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null},s=i(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=i(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?r.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(r.algparam={},r.algparam.p=e.getVbyList(t,a[1],[0],"02"),r.algparam.q=e.getVbyList(t,a[1],[1],"02"),r.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(t,s[1]).substr(2),r}}}();Ut.getKey=function(t,e,i){var n=(y=pt).getChildIdx,r=(y.getV,y.getVbyList),s=ft.crypto,o=s.ECDSA,a=s.DSA,h=ot,u=Ht,c=Ut;if(void 0!==h&&t instanceof h)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(t.n,t.e),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(D=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(D=new h).setPrivate(t.n,t.e,t.d),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(D=new a).setPublic(t.p,t.q,t.g,t.y),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(D=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(xt(t.n),xt(t.e)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(D=new h).setPrivateEx(xt(t.n),xt(t.e),xt(t.d),xt(t.p),xt(t.q),xt(t.dp),xt(t.dq),xt(t.qi)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(D=new h).setPrivate(xt(t.n),xt(t.e),xt(t.d)),D;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);return C.setPublicKeyHex(f),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);var d=("0000000000"+xt(t.d)).slice(-l);return C.setPublicKeyHex(f),C.setPrivateKeyHex(d),C}if("pkcs5prv"===i){var g,p=t,y=pt;if(9===(g=n(p,0)).length)(D=new h).readPKCS5PrvKeyHex(p);else if(6===g.length)(D=new a).readPKCS5PrvKeyHex(p);else{if(!(g.length>2&&"04"===p.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(D=new o).readPKCS5PrvKeyHex(p)}return D}if("pkcs8prv"===i)return D=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===i)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===i)return Jt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Jt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=Ht(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=u(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=r(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),F=r(R,0,[2],"02"),w=r(R,0,[3],"02"),E=r(R,0,[4],"02"),A=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(w,16),new x(E,16),new x(A,16)),D}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var b=c.getDecryptedKeyHex(t,e),I=new ot;return I.readPKCS5PrvKeyHex(b),I}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var C,D=r(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),T=r(R,0,[2,0],"06"),P=r(R,0,[3,0],"03").substr(2);if(void 0===ft.crypto.OID.oidhex2name[T])throw"undefined OID(hex) in KJUR.crypto.OID: "+T;return(C=new o({curve:ft.crypto.OID.oidhex2name[T]})).setPublicKeyHex(P),C.setPrivateKeyHex(D),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;S=r(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),F=r(R,0,[2],"02"),w=r(R,0,[3],"02"),E=r(R,0,[4],"02"),A=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(w,16),new x(E,16),new x(A,16)),D}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw"not supported argument"},Ut.generateKeypair=function(t,e){if("RSA"==t){var i=e;(o=new ot).generate(i,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new ot,r=o.n.toString(16),s=o.e.toString(16);return n.setPublic(r,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,h=e,u=new ft.crypto.ECDSA({curve:h}).generateKeyPairHex();return(o=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),o.setPrivateKeyHex(u.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Ut.getPEM=function(t,e,i,n,r,s){var o=ft,a=o.asn1,h=a.DERObjectIdentifier,u=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,f=o.crypto,d=f.DSA,g=f.ECDSA,p=ot;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function S(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==p&&t instanceof p||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Rt(x=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=v(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===i||null==i)&&1==t.isPrivate){var F=new h({name:t.curveName}).getEncodedHex(),w=m(t).getEncodedHex(),E="";return E+=Rt(F,"EC PARAMETERS"),E+=Rt(w,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=S(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==i&&null!=i&&1==t.isPrivate){var x=v(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==i&&null!=i&&1==t.isPrivate){x=m(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==i&&null!=i&&1==t.isPrivate){x=S(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",x,i,n,s)}var A=function(t,e){var i=b(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},b=function(t,e){var i=y.lib.WordArray.random(8),n=y.lib.WordArray.random(8),r=y.PBKDF2(e,i,{keySize:6,iterations:100}),s=y.enc.Hex.parse(t),o=y.TripleDES.encrypt(s,r,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=y.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=y.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=p&&t instanceof p&&1==t.isPrivate){var I=v(t).getEncodedHex();x=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=A(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){I=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=A(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){I=new u({bigint:t.x}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=A(x,i),"ENCRYPTED PRIVATE KEY")}throw"unsupported object nor format"},Ut.getKeyFromCSRPEM=function(t){var e=Ht(t,"CERTIFICATE REQUEST");return Ut.getKeyFromCSRHex(e)},Ut.getKeyFromCSRHex=function(t){var e=Ut.parseCSRHex(t);return Ut.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Ut.parseCSRHex=function(t){var e=pt,i=e.getChildIdx,n=e.getTLV,r={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=i(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=i(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(s,a[2]),r},Ut.getJWKFromKey=function(t){var e={};if(t instanceof ot&&t.isPrivate)return e.kty="RSA",e.n=Et(t.n.toString(16)),e.e=Et(t.e.toString(16)),e.d=Et(t.d.toString(16)),e.p=Et(t.p.toString(16)),e.q=Et(t.q.toString(16)),e.dp=Et(t.dmp1.toString(16)),e.dq=Et(t.dmq1.toString(16)),e.qi=Et(t.coeff.toString(16)),e;if(t instanceof ot&&t.isPublic)return e.kty="RSA",e.n=Et(t.n.toString(16)),e.e=Et(t.e.toString(16)),e;if(t instanceof ft.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=Et(i.x),e.y=Et(i.y),e.d=Et(t.prvKeyHex),e}if(t instanceof ft.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=Et(i.x),e.y=Et(i.y),e}throw"not supported key object"},ot.getPosArrayOfChildrenFromHex=function(t){return pt.getChildIdx(t,0)},ot.getHexValueArrayOfChildrenFromHex=function(t){var e,i=pt.getV,n=i(t,(e=ot.getPosArrayOfChildrenFromHex(t))[0]),r=i(t,e[1]),s=i(t,e[2]),o=i(t,e[3]),a=i(t,e[4]),h=i(t,e[5]),u=i(t,e[6]),c=i(t,e[7]),l=i(t,e[8]);return(e=new Array).push(n,r,s,o,a,h,u,c,l),e},ot.prototype.readPrivateKeyFromPEMString=function(t){var e=Ht(t),i=ot.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},ot.prototype.readPKCS5PrvKeyHex=function(t){var e=ot.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},ot.prototype.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s,o,a,h,u=pt,c=u.getVbyList;if(!1===u.isASN1HEX(t))throw"not ASN.1 hex string";try{e=c(t,0,[2,0,1],"02"),i=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),r=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw"malformed PKCS#8 plain RSA private key"}this.setPrivateEx(e,i,n,r,s,o,a,h)},ot.prototype.readPKCS5PubKeyHex=function(t){var e=pt,i=e.getV;if(!1===e.isASN1HEX(t))throw"keyHex is not ASN.1 hex string";var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw"wrong hex for PKCS#5 public key";var r=i(t,n[0]),s=i(t,n[1]);this.setPublic(r,s)},ot.prototype.readPKCS8PubKeyHex=function(t){var e=pt;if(!1===e.isASN1HEX(t))throw"not ASN.1 hex string";if("06092a864886f70d010101"!==e.getTLVbyList(t,0,[0,0]))throw"not PKCS8 RSA public key";var i=e.getTLVbyList(t,0,[1,0]);this.readPKCS5PubKeyHex(i)},ot.prototype.readCertPubKeyHex=function(t,e){var i,n;(i=new Jt).readCertHex(t),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var qt=new RegExp("");function zt(t,e){for(var i="",n=e/4-t.length,r=0;r>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function Gt(t){for(var e in ft.crypto.Util.DIGESTINFOHEAD){var i=ft.crypto.Util.DIGESTINFOHEAD[e],n=i.length;if(t.substring(0,n)==i)return[e,t.substring(n)]}return[]}function Jt(){var t=pt,e=t.getChildIdx,i=t.getV,n=t.getTLV,r=t.getVbyList,s=t.getTLVbyList,o=t.getIdxbyList,a=t.getVidx,h=t.oidname,u=Jt,c=Ht;this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){return null===this.hex||0!==this.version?this.version:"a003020102"!==s(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return r(this.hex,0,[0,1+this.foffset],"02")},this.getSignatureAlgorithmField=function(){return h(r(this.hex,0,[0,2+this.foffset,0],"06"))},this.getIssuerHex=function(){return s(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return u.hex2dn(this.getIssuerHex())},this.getSubjectHex=function(){return s(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return u.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=r(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=r(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return t.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return o(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return o(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Ut.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){return h(r(this.hex,0,[1,0],"06"))},this.getSignatureValueHex=function(){return r(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmName(),i=this.getSignatureValueHex(),n=s(this.hex,0,[0],"30"),r=new ft.crypto.Signature({alg:e});return r.init(t),r.updateHex(n),r.verify(i)},this.parseExt=function(){if(3!==this.version)return-1;var i=o(this.hex,0,[0,7,0],"30"),n=e(this.hex,i);this.aExtInfo=new Array;for(var s=0;s0&&(u=new Array(i),(new nt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=It(h(Ct("\0\0\0\0\0\0\0\0"+r+u))),l=[];for(n=0;n>8*a-o&255;for(g[0]&=~p,n=0;nthis.n.bitLength())return 0;var n=Gt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;var r=n[0];return n[1]==function(t){return ft.crypto.Util.hashString(t,r)}(t)},ot.prototype.verifyWithMessageHash=function(t,e){var i=rt(e=(e=e.replace(qt,"")).replace(/[ \n]+/g,""),16);if(i.bitLength()>this.n.bitLength())return 0;var n=Gt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;n[0];return n[1]==t},ot.prototype.verifyPSS=function(t,e,i,n){var r,s=(r=Ct(t),ft.crypto.Util.hashHex(r,i));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(s,e,i,n)},ot.prototype.verifyWithMessageHashPSS=function(t,e,i,n){var r=new x(e,16);if(r.bitLength()>this.n.bitLength())return!1;var s,o=function(t){return ft.crypto.Util.hashHex(t,i)},a=It(t),h=a.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===n||void 0===n)n=h;else if(-2===n)n=c-h-2;else if(n<-2)throw"invalid salt length";if(c>8*c-u&255;if(0!=(f.charCodeAt(0)&g))throw"bits beyond keysize not zero";var p=Yt(d,f.length,o),y=[];for(s=0;s0)&&-1==(":"+i.join(":")+":").indexOf(":"+p+":"))throw"algorithm '"+p+"' not accepted in the list";if("none"!=p&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Ut.getKey(e)),!("RS"!=y&&"PS"!=y||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==y&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===s.jwsalg2sigalg[g.alg])throw"unsupported alg name: "+p;if("none"==(v=s.jwsalg2sigalg[p]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var S,F=null;try{F=h.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(F)}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(d)},ft.jws.JWS.parse=function(t){var e,i,n,r=t.split("."),s={};if(2!=r.length&&3!=r.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=r[0],i=r[1],3==r.length&&(n=r[2]),s.headerObj=ft.jws.JWS.readSafeJSONString(gt(e)),s.payloadObj=ft.jws.JWS.readSafeJSONString(gt(i)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=gt(i):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==n&&(s.sigHex=xt(n)),s},ft.jws.JWS.verifyJWT=function(t,e,i){var n=ft.jws,r=n.JWS,s=r.readSafeJSONString,o=r.inArray,a=r.includedArray,h=t.split("."),u=h[0],c=h[1],l=(xt(h[2]),s(gt(u))),f=s(gt(c));if(void 0===l.alg)return!1;if(void 0===i.alg)throw"acceptField.alg shall be specified";if(!o(l.alg,i.alg))return!1;if(void 0!==f.iss&&"object"==typeof i.iss&&!o(f.iss,i.iss))return!1;if(void 0!==f.sub&&"object"==typeof i.sub&&!o(f.sub,i.sub))return!1;if(void 0!==f.aud&&"object"==typeof i.aud)if("string"==typeof f.aud){if(!o(f.aud,i.aud))return!1}else if("object"==typeof f.aud&&!a(f.aud,i.aud))return!1;var d=n.IntDate.getNow();return void 0!==i.verifyAt&&"number"==typeof i.verifyAt&&(d=i.verifyAt),void 0!==i.gracePeriod&&"number"==typeof i.gracePeriod||(i.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+i.gracePeriodr&&this.aHeader.pop(),this.aSignature.length>r&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignatures=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},e.SecureRandom=nt,e.rng_seed_time=Z,e.BigInteger=x,e.RSAKey=ot,e.ECDSA=ft.crypto.ECDSA,e.DSA=ft.crypto.DSA,e.Signature=ft.crypto.Signature,e.MessageDigest=ft.crypto.MessageDigest,e.Mac=ft.crypto.Mac,e.Cipher=ft.crypto.Cipher,e.KEYUTIL=Ut,e.ASN1HEX=pt,e.X509=Jt,e.CryptoJS=y,e.b64tohex=w,e.b64toBA=E,e.stoBA=yt,e.BAtos=vt,e.BAtohex=mt,e.stohex=St,e.stob64=function(t){return F(St(t))},e.stob64u=function(t){return Ft(F(St(t)))},e.b64utos=function(t){return vt(E(wt(t)))},e.b64tob64u=Ft,e.b64utob64=wt,e.hex2b64=F,e.hextob64u=Et,e.b64utohex=xt,e.utf8tob64u=dt,e.b64utoutf8=gt,e.utf8tob64=function(t){return F(Ot(Kt(t)))},e.b64toutf8=function(t){return decodeURIComponent(jt(w(t)))},e.utf8tohex=At,e.hextoutf8=bt,e.hextorstr=It,e.rstrtohex=Ct,e.hextob64=Dt,e.hextob64nl=Tt,e.b64nltohex=Pt,e.hextopem=Rt,e.pemtohex=Ht,e.hextoArrayBuffer=function(t){if(t.length%2!=0)throw"input is not even length";if(null==t.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var e=new ArrayBuffer(t.length/2),i=new DataView(e),n=0;ne.length&&(i=e.length);for(var n=0;n300)throw new r(`Failed to fetch ${t}. Response=${s}`,i.status);try{return JSON.parse(s)}catch(e){throw new r(`Invalid response while trying to fetch ${t}. Response=${s}`,i.status,e)}}}},function(t,e,i){const n=i(5),r=i(3),s=i(16),o=i(18),a=i(20),h=i(1),u=i(2),c=i(0);t.exports=class{constructor({popup:t=new s,iframe:e=new o,openIdConfigResource:i=new a,utils:h,requestHandler:u=new r,w:l=window,url:f=URL}={}){this.popup=t,this.iframe=e,this.openIdConfigResource=i,this.URL=f,this.utils=h,h||(this.utils=new n({openIdConfigResource:this.openIdConfigResource,url:this.URL,popup:this.popup,jsrsasign:c})),this.request=u.request,this.window=l,this.initialized=!1}async init({clientId:t,discoveryEndpoint:e,popup:i={height:.8*window.screen.height,width:400}}){if(!t)throw new u(h.MISSING_CLIENT_ID);try{new this.URL(e)}catch(t){throw new u(h.INVALID_DISCOVERY_ENDPOINT)}await this.openIdConfigResource.init({discoveryEndpoint:e,requestHandler:this.request}),this.popup.init(i),this.clientId=t,this.initialized=!0}async signin(){this._validateInitalize();const t=this.openIdConfigResource.getAuthorizationEndpoint();return this.utils.performOAuthFlowAndGetTokens({origin:this.window.origin,clientId:this.clientId,endpoint:t})}async silentSignin(){this._validateInitalize();const t=this.openIdConfigResource.getAuthorizationEndpoint(),{codeVerifier:e,nonce:i,state:n,url:r}=this.utils.getAuthParamsAndUrl({clientId:this.clientId,origin:this.window.origin,prompt:h.PROMPT,endpoint:t});let s;this.iframe.open(r);try{s=await this.iframe.waitForMessage({messageType:"authorization_response"})}finally{this.iframe.remove()}this.utils.verifyMessage({message:s,state:n});let o=s.data.code;return await this.utils.retrieveTokens({clientId:this.clientId,authCode:o,codeVerifier:e,nonce:i,openId:this.openIdConfigResource,windowOrigin:this.window.origin})}async getUserInfo(t){if(this._validateInitalize(),"string"!=typeof t)throw new u(h.INVALID_ACCESS_TOKEN);return await this.request(this.openIdConfigResource.getUserInfoEndpoint(),{headers:{Authorization:"Bearer "+t}})}async changePassword(t){let e;if(this._validateInitalize(),!t)throw new u(h.MISSING_ID_TOKEN_PAYLOAD);if("string"==typeof t)throw new u(h.INVALID_ID_TOKEN_PAYLOAD);if(!(t.identities&&t.identities[0]&&t.identities[0].id))throw new u(h.INVALID_ID_TOKEN_PAYLOAD);if("cloud_directory"!==t.identities[0].provider)throw new u(h.NOT_CD_USER);e=t.identities[0].id;const i=this.openIdConfigResource.getIssuer()+h.CHANGE_PASSWORD;return this.utils.performOAuthFlowAndGetTokens({userId:e,origin:this.window.origin,clientId:this.clientId,endpoint:i})}_validateInitalize(){if(!this.initialized)throw new u(h.FAIL_TO_INITIALIZE)}}},function(t,e,i){i(0);const n=i(2),r=i(11),s=i(3),o=i(14),a=i(1);t.exports=class{constructor({requestHandler:t=new s,tokenValidator:e=new o,url:i=URL,openIdConfigResource:n,popup:r,jsrsasign:a=a}={}){this.URL=i,this.request=t.request,this.tokenValidator=e,this.openIdConfigResource=n,this.popup=r,this.rs=a}buildParams(t){return Object.keys(t).map((function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])})).join("&")}getRandomString(t){return this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(t/2)}sha256(t){return this.rs.KJUR.crypto.Util.sha256(t)}getPKCEFields(){const t=this.getRandomString(a.CODE_VERIFIER_LENGTH);return{codeVerifier:t,codeChallenge:this.sha256(t),state:this.getRandomString(a.STATE_LENGTH),nonce:this.getRandomString(a.NONCE_LENGTH)}}getAuthParamsAndUrl({clientId:t,origin:e,prompt:i,endpoint:n,userId:r}){const{codeVerifier:s,codeChallenge:o,state:h,nonce:u}=this.getPKCEFields();let c={client_id:t,response_type:a.RESPONSE_TYPE,state:this.rs.stob64(h),code_challenge:this.rs.stob64(o),code_challenge_method:a.CHALLENGE_METHOD,redirect_uri:e,response_mode:a.RESPONSE_MODE,nonce:u,scope:a.SCOPE};return i&&(c.prompt=i),r&&(c.user_id=r),{codeVerifier:s,nonce:u,state:h,url:n+"?"+this.buildParams(c)}}async performOAuthFlowAndGetTokens({userId:t,origin:e,clientId:i,endpoint:n}){const{codeVerifier:r,state:s,nonce:o,url:a}=this.getAuthParamsAndUrl({userId:t,origin:e,clientId:i,endpoint:n});this.popup.open(),this.popup.navigate(a);const h=await this.popup.waitForMessage({messageType:"authorization_response"});this.popup.close(),this.verifyMessage({message:h,state:s});let u=h.data.code;return await this.retrieveTokens({clientId:i,authCode:u,codeVerifier:r,nonce:o,windowOrigin:e})}verifyMessage({message:t,state:e}){if(t.data.error||t.data.error_description)throw new r({description:t.data.error_description,error:t.data.error});if(this.rs.b64utos(t.data.state)!==e)throw new n(a.INVALID_STATE);if(t.origin!==new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin)throw new n(a.INVALID_ORIGIN)}async retrieveTokens({clientId:t,authCode:e,nonce:i,codeVerifier:n,windowOrigin:r}){let s=this.openIdConfigResource.getIssuer(),o={grant_type:"authorization_code",redirect_uri:r,code:e,code_verifier:n};const a=this.buildParams(o),h=this.openIdConfigResource.getTokenEndpoint(),u=await this.request(h,{method:"POST",headers:{Authorization:"Basic "+this.rs.stob64(`${t}:${n}`),"Content-Type":"application/x-www-form-urlencoded"},body:a}),c=await this.openIdConfigResource.getPublicKeys(),l=this.tokenValidator.decodeAndValidate({token:u.access_token,publicKeys:c,issuer:s,clientId:t,nonce:i}),f=this.tokenValidator.decodeAndValidate({token:u.id_token,publicKeys:c,issuer:s,clientId:t,nonce:i});return{accessToken:u.access_token,accessTokenPayload:l,idToken:u.id_token,idTokenPayload:f}}}},function(t,e,i){"use strict";(function(t){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -var n=i(8),r=i(9),s=i(10);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return b(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function b(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return w(this,t,e,i);case"latin1":case"binary":return E(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function N(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||B(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);B(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);B(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(7))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e,i){const n=i(1),r=i(15);t.exports=class{constructor({jwt:t=i(0)}={}){this.jwt=t}decodeAndValidate({token:t,publicKeys:e,issuer:i,clientId:s,nonce:o}){const a=Math.floor(Date.now()/1e3),h=t.split(".");if(3!==h.length)throw new r(`Invalid JWT token. Got only ${h.length} parts.`);const u=this.jwt.KJUR.jws.JWS.parse(t);if(!u.headerObj)throw new r(n.INVALID_TOKEN);const c=u.headerObj.kid,l=this.getPublicKey(e.keys,c),f=this.jwt.KEYUTIL.getKey(l);if(!this.jwt.KJUR.jws.JWS.verify(t,f,{alg:[n.TOKEN_ALG]}))throw new r(n.INVALID_SIGNATURE);if(u.payloadObj.exp{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e){t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t),this.publicKeys=e(this.getJwksEndpoint())}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}}]); \ No newline at end of file +var AppID = +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./node_modules/base64-js/index.js": +/*!*****************************************!*\ + !*** ./node_modules/base64-js/index.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/base64-js/index.js?"); + +/***/ }), + +/***/ "./node_modules/buffer/index.js": +/*!**************************************!*\ + !*** ./node_modules/buffer/index.js ***! + \**************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("/* WEBPACK VAR INJECTION */(function(global) {/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n\n\nvar base64 = __webpack_require__(/*! base64-js */ \"./node_modules/base64-js/index.js\")\nvar ieee754 = __webpack_require__(/*! ieee754 */ \"./node_modules/ieee754/index.js\")\nvar isArray = __webpack_require__(/*! isarray */ \"./node_modules/isarray/index.js\")\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://AppID/./node_modules/buffer/index.js?"); + +/***/ }), + +/***/ "./node_modules/ieee754/index.js": +/*!***************************************!*\ + !*** ./node_modules/ieee754/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/ieee754/index.js?"); + +/***/ }), + +/***/ "./node_modules/isarray/index.js": +/*!***************************************!*\ + !*** ./node_modules/isarray/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n\n\n//# sourceURL=webpack://AppID/./node_modules/isarray/index.js?"); + +/***/ }), + +/***/ "./node_modules/jsrsasign/lib/jsrsasign.js": +/*!*************************************************!*\ + !*** ./node_modules/jsrsasign/lib/jsrsasign.js ***! + \*************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\nvar navigator = {};\nnavigator.userAgent = false;\n\nvar window = {};\n/*\n * jsrsasign(all) 8.0.12 (2018-04-22) (c) 2010-2018 Kenji Urushima | kjur.github.com/jsrsasign/license\n */\n\n/*!\nCopyright (c) 2011, Yahoo! Inc. All rights reserved.\nCode licensed under the BSD License:\nhttp://developer.yahoo.com/yui/license.html\nversion: 2.9.0\n*/\nif(YAHOO===undefined){var YAHOO={}}YAHOO.lang={extend:function(g,h,f){if(!h||!g){throw new Error(\"YAHOO.lang.extend failed, please check that all dependencies are included.\")}var d=function(){};d.prototype=h.prototype;g.prototype=new d();g.prototype.constructor=g;g.superclass=h.prototype;if(h.prototype.constructor==Object.prototype.constructor){h.prototype.constructor=h}if(f){var b;for(b in f){g.prototype[b]=f[b]}var e=function(){},c=[\"toString\",\"valueOf\"];try{if(/MSIE/.test(navigator.userAgent)){e=function(j,i){for(b=0;b>>2]>>>(24-(r%4)*8))&255;q[(n+r)>>>2]|=o<<(24-((n+r)%4)*8)}}else{for(var r=0;r>>2]=p[r>>>2]}}this.sigBytes+=s;return this},clamp:function(){var o=this.words;var n=this.sigBytes;o[n>>>2]&=4294967295<<(32-(n%4)*8);o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);n.words=this.words.slice(0);return n},random:function(p){var o=[];for(var n=0;n>>2]>>>(24-(n%4)*8))&255;q.push((s>>>4).toString(16));q.push((s&15).toString(16))}return q.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>3]|=parseInt(p.substr(o,2),16)<<(24-(o%8)*4)}return new l.init(q,n/2)}};var d=m.Latin1={stringify:function(q){var r=q.words;var p=q.sigBytes;var n=[];for(var o=0;o>>2]>>>(24-(o%4)*8))&255;n.push(String.fromCharCode(s))}return n.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>2]|=(p.charCodeAt(o)&255)<<(24-(o%4)*8)}return new l.init(q,n)}};var c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error(\"Malformed UTF-8 data\")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}};var i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init();this._nDataBytes=0},_append:function(n){if(typeof n==\"string\"){n=c.parse(n)}this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data;var x=q.words;var n=q.sigBytes;var t=this.blockSize;var v=t*4;var u=n/v;if(w){u=e.ceil(u)}else{u=e.max((u|0)-this._minBufferSize,0)}var s=u*t;var r=e.min(s*4,n);if(s){for(var p=0;p>>2]&255}};f.BlockCipher=n.extend({cfg:n.cfg.extend({mode:m,padding:h}),reset:function(){n.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;\nthis._mode=c.call(a,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var p=f.CipherParams=k.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(g.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;\nreturn(a?l.create([1398893684,1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=l.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return p.create({ciphertext:a,salt:c})}},j=f.SerializableCipher=k.extend({cfg:k.extend({format:m}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return p.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,\nblockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return\"string\"==typeof a?b.parse(a,this):a}}),g=(g.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=l.random(8));a=v.create({keySize:b+c}).compute(a,d);c=l.create(a.words.slice(b),4*c);a.sigBytes=4*b;return p.create({key:a,iv:c,salt:d})}},s=f.PasswordBasedCipher=j.extend({cfg:j.cfg.extend({kdf:g}),encrypt:function(a,\nb,c,d){d=this.cfg.extend(d);c=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=c.iv;a=j.encrypt.call(this,a,b,c.key,d);a.mixIn(c);return a},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=c.iv;return j.decrypt.call(this,a,b,c.key,d)}})}();\n\n/*\nCryptoJS v3.1.2 aes.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){for(var q=CryptoJS,x=q.lib.BlockCipher,r=q.algo,j=[],y=[],z=[],A=[],B=[],C=[],s=[],u=[],v=[],w=[],g=[],k=0;256>k;k++)g[k]=128>k?k<<1:k<<1^283;for(var n=0,l=0,k=0;256>k;k++){var f=l^l<<1^l<<2^l<<3^l<<4,f=f>>>8^f&255^99;j[n]=f;y[f]=n;var t=g[n],D=g[t],E=g[D],b=257*g[f]^16843008*f;z[n]=b<<24|b>>>8;A[n]=b<<16|b>>>16;B[n]=b<<8|b>>>24;C[n]=b;b=16843009*E^65537*D^257*t^16843008*n;s[f]=b<<24|b>>>8;u[f]=b<<16|b>>>16;v[f]=b<<8|b>>>24;w[f]=b;n?(n=t^g[g[g[E^t]]],l^=g[g[l]]):n=l=1}var F=[0,1,2,4,8,\n16,32,64,128,27,54],r=r.AES=x.extend({_doReset:function(){for(var c=this._key,e=c.words,a=c.sigBytes/4,c=4*((this._nRounds=a+6)+1),b=this._keySchedule=[],h=0;h>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255]):(d=d<<8|d>>>24,d=j[d>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255],d^=F[h/a|0]<<24);b[h]=b[h-a]^d}e=this._invKeySchedule=[];for(a=0;aa||4>=h?d:s[j[d>>>24]]^u[j[d>>>16&255]]^v[j[d>>>\n8&255]]^w[j[d&255]]},encryptBlock:function(c,e){this._doCryptBlock(c,e,this._keySchedule,z,A,B,C,j)},decryptBlock:function(c,e){var a=c[e+1];c[e+1]=c[e+3];c[e+3]=a;this._doCryptBlock(c,e,this._invKeySchedule,s,u,v,w,y);a=c[e+1];c[e+1]=c[e+3];c[e+3]=a},_doCryptBlock:function(c,e,a,b,h,d,j,m){for(var n=this._nRounds,f=c[e]^a[0],g=c[e+1]^a[1],k=c[e+2]^a[2],p=c[e+3]^a[3],l=4,t=1;t>>24]^h[g>>>16&255]^d[k>>>8&255]^j[p&255]^a[l++],r=b[g>>>24]^h[k>>>16&255]^d[p>>>8&255]^j[f&255]^a[l++],s=\nb[k>>>24]^h[p>>>16&255]^d[f>>>8&255]^j[g&255]^a[l++],p=b[p>>>24]^h[f>>>16&255]^d[g>>>8&255]^j[k&255]^a[l++],f=q,g=r,k=s;q=(m[f>>>24]<<24|m[g>>>16&255]<<16|m[k>>>8&255]<<8|m[p&255])^a[l++];r=(m[g>>>24]<<24|m[k>>>16&255]<<16|m[p>>>8&255]<<8|m[f&255])^a[l++];s=(m[k>>>24]<<24|m[p>>>16&255]<<16|m[f>>>8&255]<<8|m[g&255])^a[l++];p=(m[p>>>24]<<24|m[f>>>16&255]<<16|m[g>>>8&255]<<8|m[k&255])^a[l++];c[e]=q;c[e+1]=r;c[e+2]=s;c[e+3]=p},keySize:8});q.AES=x._createHelper(r)})();\n\n/*\nCryptoJS v3.1.2 tripledes-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function j(b,c){var a=(this._lBlock>>>b^this._rBlock)&c;this._rBlock^=a;this._lBlock^=a<>>b^this._lBlock)&c;this._lBlock^=a;this._rBlock^=a<a;a++){var f=q[a]-1;c[a]=b[f>>>5]>>>31-f%32&1}b=this._subKeys=[];for(f=0;16>f;f++){for(var d=b[f]=[],e=r[f],a=0;24>a;a++)d[a/6|0]|=c[(p[a]-1+e)%28]<<31-a%6,d[4+(a/6|0)]|=c[28+(p[a+24]-1+e)%28]<<31-a%6;d[0]=d[0]<<1|d[0]>>>31;for(a=1;7>a;a++)d[a]>>>=\n4*(a-1)+3;d[7]=d[7]<<5|d[7]>>>27}c=this._invSubKeys=[];for(a=0;16>a;a++)c[a]=b[15-a]},encryptBlock:function(b,c){this._doCryptBlock(b,c,this._subKeys)},decryptBlock:function(b,c){this._doCryptBlock(b,c,this._invSubKeys)},_doCryptBlock:function(b,c,a){this._lBlock=b[c];this._rBlock=b[c+1];j.call(this,4,252645135);j.call(this,16,65535);l.call(this,2,858993459);l.call(this,8,16711935);j.call(this,1,1431655765);for(var f=0;16>f;f++){for(var d=a[f],e=this._lBlock,h=this._rBlock,g=0,k=0;8>k;k++)g|=s[k][((h^\nd[k])&t[k])>>>0];this._lBlock=h;this._rBlock=e^g}a=this._lBlock;this._lBlock=this._rBlock;this._rBlock=a;j.call(this,1,1431655765);l.call(this,8,16711935);l.call(this,2,858993459);j.call(this,16,65535);j.call(this,4,252645135);b[c]=this._lBlock;b[c+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});h.DES=e._createHelper(m);g=g.TripleDES=e.extend({_doReset:function(){var b=this._key.words;this._des1=m.createEncryptor(n.create(b.slice(0,2)));this._des2=m.createEncryptor(n.create(b.slice(2,4)));this._des3=\nm.createEncryptor(n.create(b.slice(4,6)))},encryptBlock:function(b,c){this._des1.encryptBlock(b,c);this._des2.decryptBlock(b,c);this._des3.encryptBlock(b,c)},decryptBlock:function(b,c){this._des3.decryptBlock(b,c);this._des2.encryptBlock(b,c);this._des1.decryptBlock(b,c)},keySize:6,ivSize:2,blockSize:2});h.TripleDES=e._createHelper(g)})();\n\n/*\nCryptoJS v3.1.2 enc-base64.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join(\"\")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d<\ne;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\"}})();\n\n/*\nCryptoJS v3.1.2 md5.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(E){function h(a,f,g,j,p,h,k){a=a+(f&g|~f&j)+p+k;return(a<>>32-h)+f}function k(a,f,g,j,p,h,k){a=a+(f&j|g&~j)+p+k;return(a<>>32-h)+f}function l(a,f,g,j,h,k,l){a=a+(f^g^j)+h+l;return(a<>>32-k)+f}function n(a,f,g,j,h,k,l){a=a+(g^(f|~j))+h+l;return(a<>>32-k)+f}for(var r=CryptoJS,q=r.lib,F=q.WordArray,s=q.Hasher,q=r.algo,a=[],t=0;64>t;t++)a[t]=4294967296*E.abs(E.sin(t+1))|0;q=q.MD5=s.extend({_doReset:function(){this._hash=new F.init([1732584193,4023233417,2562383102,271733878])},\n_doProcessBlock:function(m,f){for(var g=0;16>g;g++){var j=f+g,p=m[j];m[j]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360}var g=this._hash.words,j=m[f+0],p=m[f+1],q=m[f+2],r=m[f+3],s=m[f+4],t=m[f+5],u=m[f+6],v=m[f+7],w=m[f+8],x=m[f+9],y=m[f+10],z=m[f+11],A=m[f+12],B=m[f+13],C=m[f+14],D=m[f+15],b=g[0],c=g[1],d=g[2],e=g[3],b=h(b,c,d,e,j,7,a[0]),e=h(e,b,c,d,p,12,a[1]),d=h(d,e,b,c,q,17,a[2]),c=h(c,d,e,b,r,22,a[3]),b=h(b,c,d,e,s,7,a[4]),e=h(e,b,c,d,t,12,a[5]),d=h(d,e,b,c,u,17,a[6]),c=h(c,d,e,b,v,22,a[7]),\nb=h(b,c,d,e,w,7,a[8]),e=h(e,b,c,d,x,12,a[9]),d=h(d,e,b,c,y,17,a[10]),c=h(c,d,e,b,z,22,a[11]),b=h(b,c,d,e,A,7,a[12]),e=h(e,b,c,d,B,12,a[13]),d=h(d,e,b,c,C,17,a[14]),c=h(c,d,e,b,D,22,a[15]),b=k(b,c,d,e,p,5,a[16]),e=k(e,b,c,d,u,9,a[17]),d=k(d,e,b,c,z,14,a[18]),c=k(c,d,e,b,j,20,a[19]),b=k(b,c,d,e,t,5,a[20]),e=k(e,b,c,d,y,9,a[21]),d=k(d,e,b,c,D,14,a[22]),c=k(c,d,e,b,s,20,a[23]),b=k(b,c,d,e,x,5,a[24]),e=k(e,b,c,d,C,9,a[25]),d=k(d,e,b,c,r,14,a[26]),c=k(c,d,e,b,w,20,a[27]),b=k(b,c,d,e,B,5,a[28]),e=k(e,b,\nc,d,q,9,a[29]),d=k(d,e,b,c,v,14,a[30]),c=k(c,d,e,b,A,20,a[31]),b=l(b,c,d,e,t,4,a[32]),e=l(e,b,c,d,w,11,a[33]),d=l(d,e,b,c,z,16,a[34]),c=l(c,d,e,b,C,23,a[35]),b=l(b,c,d,e,p,4,a[36]),e=l(e,b,c,d,s,11,a[37]),d=l(d,e,b,c,v,16,a[38]),c=l(c,d,e,b,y,23,a[39]),b=l(b,c,d,e,B,4,a[40]),e=l(e,b,c,d,j,11,a[41]),d=l(d,e,b,c,r,16,a[42]),c=l(c,d,e,b,u,23,a[43]),b=l(b,c,d,e,x,4,a[44]),e=l(e,b,c,d,A,11,a[45]),d=l(d,e,b,c,D,16,a[46]),c=l(c,d,e,b,q,23,a[47]),b=n(b,c,d,e,j,6,a[48]),e=n(e,b,c,d,v,10,a[49]),d=n(d,e,b,c,\nC,15,a[50]),c=n(c,d,e,b,t,21,a[51]),b=n(b,c,d,e,A,6,a[52]),e=n(e,b,c,d,r,10,a[53]),d=n(d,e,b,c,y,15,a[54]),c=n(c,d,e,b,p,21,a[55]),b=n(b,c,d,e,w,6,a[56]),e=n(e,b,c,d,D,10,a[57]),d=n(d,e,b,c,u,15,a[58]),c=n(c,d,e,b,B,21,a[59]),b=n(b,c,d,e,s,6,a[60]),e=n(e,b,c,d,z,10,a[61]),d=n(d,e,b,c,q,15,a[62]),c=n(c,d,e,b,x,21,a[63]);g[0]=g[0]+b|0;g[1]=g[1]+c|0;g[2]=g[2]+d|0;g[3]=g[3]+e|0},_doFinalize:function(){var a=this._data,f=a.words,g=8*this._nDataBytes,j=8*a.sigBytes;f[j>>>5]|=128<<24-j%32;var h=E.floor(g/\n4294967296);f[(j+64>>>9<<4)+15]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;f[(j+64>>>9<<4)+14]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360;a.sigBytes=4*(f.length+1);this._process();a=this._hash;f=a.words;for(g=0;4>g;g++)j=f[g],f[g]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=s.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=s._createHelper(q);r.HmacMD5=s._createHmacHelper(q)})(Math);\n\n/*\nCryptoJS v3.1.2 sha1-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var k=CryptoJS,b=k.lib,m=b.WordArray,l=b.Hasher,d=[],b=k.algo.SHA1=l.extend({_doReset:function(){this._hash=new m.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(n,p){for(var a=this._hash.words,e=a[0],f=a[1],h=a[2],j=a[3],b=a[4],c=0;80>c;c++){if(16>c)d[c]=n[p+c]|0;else{var g=d[c-3]^d[c-8]^d[c-14]^d[c-16];d[c]=g<<1|g>>>31}g=(e<<5|e>>>27)+b+d[c];g=20>c?g+((f&h|~f&j)+1518500249):40>c?g+((f^h^j)+1859775393):60>c?g+((f&h|f&j|h&j)-1894007588):g+((f^h^\nj)-899497514);b=j;j=h;h=f<<30|f>>>2;f=e;e=g}a[0]=a[0]+e|0;a[1]=a[1]+f|0;a[2]=a[2]+h|0;a[3]=a[3]+j|0;a[4]=a[4]+b|0},_doFinalize:function(){var b=this._data,d=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=Math.floor(a/4294967296);d[(e+64>>>9<<4)+15]=a;b.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var b=l.clone.call(this);b._hash=this._hash.clone();return b}});k.SHA1=l._createHelper(b);k.HmacSHA1=l._createHmacHelper(b)})();\n\n/*\nCryptoJS v3.1.2 sha256-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(k){for(var g=CryptoJS,h=g.lib,v=h.WordArray,j=h.Hasher,h=g.algo,s=[],t=[],u=function(q){return 4294967296*(q-(q|0))|0},l=2,b=0;64>b;){var d;a:{d=l;for(var w=k.sqrt(d),r=2;r<=w;r++)if(!(d%r)){d=!1;break a}d=!0}d&&(8>b&&(s[b]=u(k.pow(l,0.5))),t[b]=u(k.pow(l,1/3)),b++);l++}var n=[],h=h.SHA256=j.extend({_doReset:function(){this._hash=new v.init(s.slice(0))},_doProcessBlock:function(q,h){for(var a=this._hash.words,c=a[0],d=a[1],b=a[2],k=a[3],f=a[4],g=a[5],j=a[6],l=a[7],e=0;64>e;e++){if(16>e)n[e]=\nq[h+e]|0;else{var m=n[e-15],p=n[e-2];n[e]=((m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3)+n[e-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[e-16]}m=l+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&g^~f&j)+t[e]+n[e];p=((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&d^c&b^d&b);l=j;j=g;g=f;f=k+m|0;k=b;b=d;d=c;c=m+p|0}a[0]=a[0]+c|0;a[1]=a[1]+d|0;a[2]=a[2]+b|0;a[3]=a[3]+k|0;a[4]=a[4]+f|0;a[5]=a[5]+g|0;a[6]=a[6]+j|0;a[7]=a[7]+l|0},_doFinalize:function(){var d=this._data,b=d.words,a=8*this._nDataBytes,c=8*d.sigBytes;\nb[c>>>5]|=128<<24-c%32;b[(c+64>>>9<<4)+14]=k.floor(a/4294967296);b[(c+64>>>9<<4)+15]=a;d.sigBytes=4*b.length;this._process();return this._hash},clone:function(){var b=j.clone.call(this);b._hash=this._hash.clone();return b}});g.SHA256=j._createHelper(h);g.HmacSHA256=j._createHmacHelper(h)})(Math);\n\n/*\nCryptoJS v3.1.2 sha224-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var b=CryptoJS,d=b.lib.WordArray,a=b.algo,c=a.SHA256,a=a.SHA224=c.extend({_doReset:function(){this._hash=new d.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var a=c._doFinalize.call(this);a.sigBytes-=4;return a}});b.SHA224=c._createHelper(a);b.HmacSHA224=c._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 sha512-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function a(){return d.create.apply(d,arguments)}for(var n=CryptoJS,r=n.lib.Hasher,e=n.x64,d=e.Word,T=e.WordArray,e=n.algo,ea=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),\na(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,\n2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),\na(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,\n3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],w=0;80>w;w++)v[w]=a();e=e.SHA512=r.extend({_doReset:function(){this._hash=new T.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(a,d){for(var f=this._hash.words,\nF=f[0],e=f[1],n=f[2],r=f[3],G=f[4],H=f[5],I=f[6],f=f[7],w=F.high,J=F.low,X=e.high,K=e.low,Y=n.high,L=n.low,Z=r.high,M=r.low,$=G.high,N=G.low,aa=H.high,O=H.low,ba=I.high,P=I.low,ca=f.high,Q=f.low,k=w,g=J,z=X,x=K,A=Y,y=L,U=Z,B=M,l=$,h=N,R=aa,C=O,S=ba,D=P,V=ca,E=Q,m=0;80>m;m++){var s=v[m];if(16>m)var j=s.high=a[d+2*m]|0,b=s.low=a[d+2*m+1]|0;else{var j=v[m-15],b=j.high,p=j.low,j=(b>>>1|p<<31)^(b>>>8|p<<24)^b>>>7,p=(p>>>1|b<<31)^(p>>>8|b<<24)^(p>>>7|b<<25),u=v[m-2],b=u.high,c=u.low,u=(b>>>19|c<<13)^(b<<\n3|c>>>29)^b>>>6,c=(c>>>19|b<<13)^(c<<3|b>>>29)^(c>>>6|b<<26),b=v[m-7],W=b.high,t=v[m-16],q=t.high,t=t.low,b=p+b.low,j=j+W+(b>>>0

>>0?1:0),b=b+c,j=j+u+(b>>>0>>0?1:0),b=b+t,j=j+q+(b>>>0>>0?1:0);s.high=j;s.low=b}var W=l&R^~l&S,t=h&C^~h&D,s=k&z^k&A^z&A,T=g&x^g&y^x&y,p=(k>>>28|g<<4)^(k<<30|g>>>2)^(k<<25|g>>>7),u=(g>>>28|k<<4)^(g<<30|k>>>2)^(g<<25|k>>>7),c=ea[m],fa=c.high,da=c.low,c=E+((h>>>14|l<<18)^(h>>>18|l<<14)^(h<<23|l>>>9)),q=V+((l>>>14|h<<18)^(l>>>18|h<<14)^(l<<23|h>>>9))+(c>>>0>>0?1:\n0),c=c+t,q=q+W+(c>>>0>>0?1:0),c=c+da,q=q+fa+(c>>>0>>0?1:0),c=c+b,q=q+j+(c>>>0>>0?1:0),b=u+T,s=p+s+(b>>>0>>0?1:0),V=S,E=D,S=R,D=C,R=l,C=h,h=B+c|0,l=U+q+(h>>>0>>0?1:0)|0,U=A,B=y,A=z,y=x,z=k,x=g,g=c+b|0,k=q+s+(g>>>0>>0?1:0)|0}J=F.low=J+g;F.high=w+k+(J>>>0>>0?1:0);K=e.low=K+x;e.high=X+z+(K>>>0>>0?1:0);L=n.low=L+y;n.high=Y+A+(L>>>0>>0?1:0);M=r.low=M+B;r.high=Z+U+(M>>>0>>0?1:0);N=G.low=N+h;G.high=$+l+(N>>>0>>0?1:0);O=H.low=O+C;H.high=aa+R+(O>>>0>>0?1:0);P=I.low=P+D;\nI.high=ba+S+(P>>>0>>0?1:0);Q=f.low=Q+E;f.high=ca+V+(Q>>>0>>0?1:0)},_doFinalize:function(){var a=this._data,d=a.words,f=8*this._nDataBytes,e=8*a.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+128>>>10<<5)+30]=Math.floor(f/4294967296);d[(e+128>>>10<<5)+31]=f;a.sigBytes=4*d.length;this._process();return this._hash.toX32()},clone:function(){var a=r.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});n.SHA512=r._createHelper(e);n.HmacSHA512=r._createHmacHelper(e)})();\n\n/*\nCryptoJS v3.1.2 sha384-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,a=c.x64,b=a.Word,e=a.WordArray,a=c.algo,d=a.SHA512,a=a.SHA384=d.extend({_doReset:function(){this._hash=new e.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var a=d._doFinalize.call(this);a.sigBytes-=16;return a}});c.SHA384=\nd._createHelper(a);c.HmacSHA384=d._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 ripemd160-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n/*\n\n(c) 2012 by Cedric Mesnil. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n(function(){var q=CryptoJS,d=q.lib,n=d.WordArray,p=d.Hasher,d=q.algo,x=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),y=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),z=n.create([11,14,15,12,\n5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),A=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),B=n.create([0,1518500249,1859775393,2400959708,2840853838]),C=n.create([1352829926,1548603684,1836072691,\n2053994217,0]),d=d.RIPEMD160=p.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,v){for(var b=0;16>b;b++){var c=v+b,f=e[c];e[c]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360}var c=this._hash.words,f=B.words,d=C.words,n=x.words,q=y.words,p=z.words,w=A.words,t,g,h,j,r,u,k,l,m,s;u=t=c[0];k=g=c[1];l=h=c[2];m=j=c[3];s=r=c[4];for(var a,b=0;80>b;b+=1)a=t+e[v+n[b]]|0,a=16>b?a+((g^h^j)+f[0]):32>b?a+((g&h|~g&j)+f[1]):48>b?\na+(((g|~h)^j)+f[2]):64>b?a+((g&j|h&~j)+f[3]):a+((g^(h|~j))+f[4]),a|=0,a=a<>>32-p[b],a=a+r|0,t=r,r=j,j=h<<10|h>>>22,h=g,g=a,a=u+e[v+q[b]]|0,a=16>b?a+((k^(l|~m))+d[0]):32>b?a+((k&m|l&~m)+d[1]):48>b?a+(((k|~l)^m)+d[2]):64>b?a+((k&l|~k&m)+d[3]):a+((k^l^m)+d[4]),a|=0,a=a<>>32-w[b],a=a+s|0,u=s,s=m,m=l<<10|l>>>22,l=k,k=a;a=c[1]+h+m|0;c[1]=c[2]+j+s|0;c[2]=c[3]+r+u|0;c[3]=c[4]+t+k|0;c[4]=c[0]+g+l|0;c[0]=a},_doFinalize:function(){var e=this._data,d=e.words,b=8*this._nDataBytes,c=8*e.sigBytes;\nd[c>>>5]|=128<<24-c%32;d[(c+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;e.sigBytes=4*(d.length+1);this._process();e=this._hash;d=e.words;for(b=0;5>b;b++)c=d[b],d[b]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return e},clone:function(){var d=p.clone.call(this);d._hash=this._hash.clone();return d}});q.RIPEMD160=p._createHelper(d);q.HmacRIPEMD160=p._createHmacHelper(d)})(Math);\n\n/*\nCryptoJS v3.1.2 hmac.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,k=c.enc.Utf8;c.algo.HMAC=c.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;\"string\"==typeof b&&(b=k.parse(b));var c=a.blockSize,e=4*c;b.sigBytes>e&&(b=a.finalize(b));b.clamp();for(var f=this._oKey=b.clone(),g=this._iKey=b.clone(),h=f.words,j=g.words,d=0;d>6)+b64map.charAt(e&63)}if(b+1==d.length){e=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(e<<2)}else{if(b+2==d.length){e=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(e>>2)+b64map.charAt((e&3)<<4)}}if(b64pad){while((a.length&3)>0){a+=b64pad}}return a}function b64tohex(f){var d=\"\";var e;var b=0;var c;var a;for(e=0;e>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(e){var d=b64tohex(e);var c;var b=new Array();for(c=0;2*c=0){var d=a*this[f++]+b[e]+h;h=Math.floor(d/67108864);b[e++]=d&67108863}return h}function am2(f,q,r,e,o,a){var k=q&32767,p=q>>15;while(--a>=0){var d=this[f]&32767;var g=this[f++]>>15;var b=p*d+g*k;d=k*d+((b&32767)<<15)+r[e]+(o&1073741823);o=(d>>>30)+(b>>>15)+p*g+(o>>>30);r[e++]=d&1073741823}return o}function am3(f,q,r,e,o,a){var k=q&16383,p=q>>14;while(--a>=0){var d=this[f]&16383;var g=this[f++]>>14;var b=p*d+g*k;d=k*d+((b&16383)<<14)+r[e]+o;o=(d>>28)+(b>>14)+p*g;r[e++]=d&268435455}return o}if(j_lm&&(navigator.appName==\"Microsoft Internet Explorer\")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator.appName!=\"Netscape\")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=((1<=0;--a){b[a]=this[a]}b.t=this.t;b.s=this.s}function bnpFromInt(a){this.t=1;this.s=(a<0)?-1:0;if(a>0){this[0]=a}else{if(a<-1){this[0]=a+this.DV}else{this.t=0}}}function nbv(a){var b=nbi();b.fromInt(a);return b}function bnpFromString(h,c){var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==256){e=8}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{this.fromRadix(h,c);return}}}}}}this.t=0;this.s=0;var g=h.length,d=false,f=0;while(--g>=0){var a=(e==8)?h[g]&255:intAt(h,g);if(a<0){if(h.charAt(g)==\"-\"){d=true}continue}d=false;if(f==0){this[this.t++]=a}else{if(f+e>this.DB){this[this.t-1]|=(a&((1<<(this.DB-f))-1))<>(this.DB-f))}else{this[this.t-1]|=a<=this.DB){f-=this.DB}}if(e==8&&(h[0]&128)!=0){this.s=-1;if(f>0){this[this.t-1]|=((1<<(this.DB-f))-1)<0&&this[this.t-1]==a){--this.t}}function bnToString(c){if(this.s<0){return\"-\"+this.negate().toString(c)}var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{return this.toRadix(c)}}}}}var g=(1<0){if(j>j)>0){a=true;h=int2char(l)}while(f>=0){if(j>(j+=this.DB-e)}else{l=(this[f]>>(j-=e))&g;if(j<=0){j+=this.DB;--f}}if(l>0){a=true}if(a){h+=int2char(l)}}}return a?h:\"0\"}function bnNegate(){var a=nbi();BigInteger.ZERO.subTo(this,a);return a}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(b){var d=this.s-b.s;if(d!=0){return d}var c=this.t;d=c-b.t;if(d!=0){return(this.s<0)?-d:d}while(--c>=0){if((d=this[c]-b[c])!=0){return d}}return 0}function nbits(a){var c=1,b;if((b=a>>>16)!=0){a=b;c+=16}if((b=a>>8)!=0){a=b;c+=8}if((b=a>>4)!=0){a=b;c+=4}if((b=a>>2)!=0){a=b;c+=2}if((b=a>>1)!=0){a=b;c+=1}return c}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(c,b){var a;for(a=this.t-1;a>=0;--a){b[a+c]=this[a]}for(a=c-1;a>=0;--a){b[a]=0}b.t=this.t+c;b.s=this.s}function bnpDRShiftTo(c,b){for(var a=c;a=0;--d){e[d+f+1]=(this[d]>>a)|h;h=(this[d]&g)<=0;--d){e[d]=0}e[f]=h;e.t=this.t+f+1;e.s=this.s;e.clamp()}function bnpRShiftTo(g,d){d.s=this.s;var e=Math.floor(g/this.DB);if(e>=this.t){d.t=0;return}var b=g%this.DB;var a=this.DB-b;var f=(1<>b;for(var c=e+1;c>b}if(b>0){d[this.t-e-1]|=(this.s&f)<>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g-=d.s}f.s=(g<0)?-1:0;if(g<-1){f[e++]=this.DV+g}else{if(g>0){f[e++]=g}}f.t=e;f.clamp()}function bnpMultiplyTo(c,e){var b=this.abs(),f=c.abs();var d=b.t;e.t=d+f.t;while(--d>=0){e[d]=0}for(d=0;d=0){d[b]=0}for(b=0;b=a.DV){d[b+a.t]-=a.DV;d[b+a.t+1]=1}}if(d.t>0){d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)}d.s=0;d.clamp()}function bnpDivRemTo(n,h,g){var w=n.abs();if(w.t<=0){return}var k=this.abs();if(k.t0){w.lShiftTo(v,d);k.lShiftTo(v,g)}else{w.copyTo(d);k.copyTo(g)}var p=d.t;var b=d[p-1];if(b==0){return}var o=b*(1<1)?d[p-2]>>this.F2:0);var A=this.FV/o,z=(1<=0){g[g.t++]=1;g.subTo(f,g)}BigInteger.ONE.dlShiftTo(p,f);f.subTo(d,d);while(d.t=0){var c=(g[--u]==b)?this.DM:Math.floor(g[u]*A+(g[u-1]+x)*z);if((g[u]+=d.am(0,c,g,s,0,p))0){g.rShiftTo(v,g)}if(a<0){BigInteger.ZERO.subTo(g,g)}}function bnMod(b){var c=nbi();this.abs().divRemTo(b,null,c);if(this.s<0&&c.compareTo(BigInteger.ZERO)>0){b.subTo(c,c)}return c}function Classic(a){this.m=a}function cConvert(a){if(a.s<0||a.compareTo(this.m)>=0){return a.mod(this.m)}else{return a}}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var a=this[0];if((a&1)==0){return 0}var b=a&3;b=(b*(2-(a&15)*b))&15;b=(b*(2-(a&255)*b))&255;b=(b*(2-(((a&65535)*b)&65535)))&65535;b=(b*(2-a*b%this.DV))%this.DV;return(b>0)?this.DV-b:-b}function Montgomery(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(a.DB-15))-1;this.mt2=2*a.t}function montConvert(a){var b=nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);if(a.s<0&&b.compareTo(BigInteger.ZERO)>0){this.m.subTo(b,b)}return b}function montRevert(a){var b=nbi();a.copyTo(b);this.reduce(b);return b}function montReduce(a){while(a.t<=this.mt2){a[a.t++]=0}for(var c=0;c>15)*this.mpl)&this.um)<<15))&a.DM;b=c+this.m.t;a[b]+=this.m.am(0,d,a,c,0,this.m.t);while(a[b]>=a.DV){a[b]-=a.DV;a[++b]++}}a.clamp();a.drShiftTo(this.m.t,a);if(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(h,j){if(h>4294967295||h<1){return BigInteger.ONE}var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;d.copyTo(f);while(--c>=0){j.sqrTo(f,a);if((h&(1<0){j.mulTo(a,d,f)}else{var b=f;f=a;a=b}}return j.revert(f)}function bnModPowInt(b,a){var c;if(b<256||a.isEven()){c=new Classic(a)}else{c=new Montgomery(a)}return this.exp(b,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction bnClone(){var a=nbi();this.copyTo(a);return a}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this[0]}else{if(this.t==0){return 0}}}return((this[1]&((1<<(32-this.DB))-1))<>24}function bnShortValue(){return(this.t==0)?this.s:(this[0]<<16)>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this[0]<=0)){return 0}else{return 1}}}function bnpToRadix(c){if(c==null){c=10}if(this.signum()==0||c<2||c>36){return\"0\"}var f=this.chunkSize(c);var e=Math.pow(c,f);var i=nbv(e),j=nbi(),h=nbi(),g=\"\";this.divRemTo(i,j,h);while(j.signum()>0){g=(e+h.intValue()).toString(c).substr(1)+g;j.divRemTo(i,j,h)}return h.intValue().toString(c)+g}function bnpFromRadix(m,h){this.fromInt(0);if(h==null){h=10}var f=this.chunkSize(h);var g=Math.pow(h,f),e=false,a=0,l=0;for(var c=0;c=f){this.dMultiply(g);this.dAddOffset(l,0);a=0;l=0}}if(a>0){this.dMultiply(Math.pow(h,a));this.dAddOffset(l,0)}if(e){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(f,e,h){if(\"number\"==typeof e){if(f<2){this.fromInt(1)}else{this.fromNumber(f,h);if(!this.testBit(f-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(f-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(e)){this.dAddOffset(2,0);if(this.bitLength()>f){this.subTo(BigInteger.ONE.shiftLeft(f-1),this)}}}}else{var d=new Array(),g=f&7;d.length=(f>>3)+1;e.nextBytes(d);if(g>0){d[0]&=((1<0){if(e>e)!=(this.s&this.DM)>>e){c[a++]=f|(this.s<<(this.DB-e))}while(b>=0){if(e<8){f=(this[b]&((1<>(e+=this.DB-8)}else{f=(this[b]>>(e-=8))&255;if(e<=0){e+=this.DB;--b}}if((f&128)!=0){f|=-256}if(a==0&&(this.s&128)!=(f&128)){++a}if(a>0||f!=this.s){c[a++]=f}}}return c}function bnEquals(b){return(this.compareTo(b)==0)}function bnMin(b){return(this.compareTo(b)<0)?this:b}function bnMax(b){return(this.compareTo(b)>0)?this:b}function bnpBitwiseTo(c,h,e){var d,g,b=Math.min(c.t,this.t);for(d=0;d>=16;b+=16}if((a&255)==0){a>>=8;b+=8}if((a&15)==0){a>>=4;b+=4}if((a&3)==0){a>>=2;b+=2}if((a&1)==0){++b}return b}function bnGetLowestSetBit(){for(var a=0;a=this.t){return(this.s!=0)}return((this[a]&(1<<(b%this.DB)))!=0)}function bnpChangeBit(c,b){var a=BigInteger.ONE.shiftLeft(c);this.bitwiseTo(a,b,a);return a}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(d,f){var e=0,g=0,b=Math.min(d.t,this.t);while(e>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g+=d.s}f.s=(g<0)?-1:0;if(g>0){f[e++]=g}else{if(g<-1){f[e++]=this.DV+g}}f.t=e;f.clamp()}function bnAdd(b){var c=nbi();this.addTo(b,c);return c}function bnSubtract(b){var c=nbi();this.subTo(b,c);return c}function bnMultiply(b){var c=nbi();this.multiplyTo(b,c);return c}function bnSquare(){var a=nbi();this.squareTo(a);return a}function bnDivide(b){var c=nbi();this.divRemTo(b,c,null);return c}function bnRemainder(b){var c=nbi();this.divRemTo(b,null,c);return c}function bnDivideAndRemainder(b){var d=nbi(),c=nbi();this.divRemTo(b,d,c);return new Array(d,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(b,a){if(b==0){return}while(this.t<=a){this[this.t++]=0}this[a]+=b;while(this[a]>=this.DV){this[a]-=this.DV;if(++a>=this.t){this[this.t++]=0}++this[a]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,c,b){a.multiplyTo(c,b)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp())}function bnpMultiplyLowerTo(b,f,e){var d=Math.min(this.t+b.t,f);e.s=0;e.t=d;while(d>0){e[--d]=0}var c;for(c=e.t-this.t;d=0){d[c]=0}for(c=Math.max(e-this.t,0);c2*this.m.t){return a.mod(this.m)}else{if(a.compareTo(this.m)<0){return a}else{var b=nbi();a.copyTo(b);this.reduce(b);return b}}}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1){a.t=this.m.t+1;a.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0){a.dAddOffset(1,this.m.t+1)}a.subTo(this.r2,a);while(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(q,f){var o=q.bitLength(),h,b=nbv(1),v;if(o<=0){return b}else{if(o<18){h=1}else{if(o<48){h=3}else{if(o<144){h=4}else{if(o<768){h=5}else{h=6}}}}}if(o<8){v=new Classic(f)}else{if(f.isEven()){v=new Barrett(f)}else{v=new Montgomery(f)}}var p=new Array(),d=3,s=h-1,a=(1<1){var A=nbi();v.sqrTo(p[1],A);while(d<=a){p[d]=nbi();v.mulTo(A,p[d-2],p[d]);d+=2}}var l=q.t-1,x,u=true,c=nbi(),y;o=nbits(q[l])-1;while(l>=0){if(o>=s){x=(q[l]>>(o-s))&a}else{x=(q[l]&((1<<(o+1))-1))<<(s-o);if(l>0){x|=q[l-1]>>(this.DB+o-s)}}d=h;while((x&1)==0){x>>=1;--d}if((o-=d)<0){o+=this.DB;--l}if(u){p[x].copyTo(b);u=false}else{while(d>1){v.sqrTo(b,c);v.sqrTo(c,b);d-=2}if(d>0){v.sqrTo(b,c)}else{y=b;b=c;c=y}v.mulTo(c,p[x],b)}while(l>=0&&(q[l]&(1<0){b.rShiftTo(f,b);h.rShiftTo(f,h)}while(b.signum()>0){if((d=b.getLowestSetBit())>0){b.rShiftTo(d,b)}if((d=h.getLowestSetBit())>0){h.rShiftTo(d,h)}if(b.compareTo(h)>=0){b.subTo(h,b);b.rShiftTo(1,b)}else{h.subTo(b,h);h.rShiftTo(1,h)}}if(f>0){h.lShiftTo(f,h)}return h}function bnpModInt(e){if(e<=0){return 0}var c=this.DV%e,b=(this.s<0)?e-1:0;if(this.t>0){if(c==0){b=this[0]%e}else{for(var a=this.t-1;a>=0;--a){b=(c*b+this[a])%e}}}return b}function bnModInverse(f){var j=f.isEven();if((this.isEven()&&j)||f.signum()==0){return BigInteger.ZERO}var i=f.clone(),h=this.clone();var g=nbv(1),e=nbv(0),l=nbv(0),k=nbv(1);while(i.signum()!=0){while(i.isEven()){i.rShiftTo(1,i);if(j){if(!g.isEven()||!e.isEven()){g.addTo(this,g);e.subTo(f,e)}g.rShiftTo(1,g)}else{if(!e.isEven()){e.subTo(f,e)}}e.rShiftTo(1,e)}while(h.isEven()){h.rShiftTo(1,h);if(j){if(!l.isEven()||!k.isEven()){l.addTo(this,l);k.subTo(f,k)}l.rShiftTo(1,l)}else{if(!k.isEven()){k.subTo(f,k)}}k.rShiftTo(1,k)}if(i.compareTo(h)>=0){i.subTo(h,i);if(j){g.subTo(l,g)}e.subTo(k,e)}else{h.subTo(i,h);if(j){l.subTo(g,l)}k.subTo(e,k)}}if(h.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(k.compareTo(f)>=0){return k.subtract(f)}if(k.signum()<0){k.addTo(f,k)}else{return k}if(k.signum()<0){return k.add(f)}else{return k}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(e){var d,b=this.abs();if(b.t==1&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d>1;if(f>lowprimes.length){f=lowprimes.length}var b=nbi();for(var e=0;e>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(window!==undefined&&(window.crypto!==undefined||window.msCrypto!==undefined)){var crypto=window.crypto||window.msCrypto;if(crypto.getRandomValues){var ua=new Uint8Array(32);crypto.getRandomValues(ua);for(t=0;t<32;++t){rng_pool[rng_pptr++]=ua[t]}}else{if(navigator.appName==\"Netscape\"&&navigator.appVersion<\"5\"){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr=0&&h>0){var f=e.charCodeAt(d--);if(f<128){g[--h]=f}else{if((f>127)&&(f<2048)){g[--h]=(f&63)|128;g[--h]=(f>>6)|192}else{g[--h]=(f&63)|128;g[--h]=((f>>6)&63)|128;g[--h]=(f>>12)|224}}}g[--h]=0;var b=new SecureRandom();var a=new Array();while(h>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}g[--h]=a[0]}g[--h]=2;g[--h]=0;return new BigInteger(g)}function oaep_mgf1_arr(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255])));d+=1}return b}function oaep_pad(q,a,f,l){var c=KJUR.crypto.MessageDigest;var o=KJUR.crypto.Util;var b=null;if(!f){f=\"sha1\"}if(typeof f===\"string\"){b=c.getCanonicalAlgName(f);l=c.getHashLength(b);f=function(i){return hextorstr(o.hashHex(rstrtohex(i),b))}}if(q.length+2*l+2>a){throw\"Message too long for RSA\"}var k=\"\",e;for(e=0;e0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{throw\"Invalid RSA public key\"}}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var e=this.doPublic(a);if(e==null){return null}var b=e.toString(16);if((b.length&1)==0){return b}else{return\"0\"+b}}function RSAEncryptOAEP(f,e,b){var a=oaep_pad(f,(this.n.bitLength()+7)>>3,e,b);if(a==null){return null}var g=this.doPublic(a);if(g==null){return null}var d=g.toString(16);if((d.length&1)==0){return d}else{return\"0\"+d}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;RSAKey.prototype.encryptOAEP=RSAEncryptOAEP;RSAKey.prototype.type=\"RSA\";\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction pkcs1unpad2(g,j){var a=g.toByteArray();var f=0;while(f=a.length){return null}}var e=\"\";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}function oaep_unpad(o,b,g,p){var e=KJUR.crypto.MessageDigest;var r=KJUR.crypto.Util;var c=null;if(!g){g=\"sha1\"}if(typeof g===\"string\"){c=e.getCanonicalAlgName(g);p=e.getHashLength(c);g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}}o=o.toByteArray();var h;for(h=0;h0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{throw\"Invalid RSA private key\"}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;this.isPublic=false;if(g==null){throw\"RSASetPrivateEx N == null\"}if(d==null){throw\"RSASetPrivateEx E == null\"}if(g.length==0){throw\"RSASetPrivateEx N.length == 0\"}if(d.length==0){throw\"RSASetPrivateEx E.length == 0\"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{throw\"Invalid RSA private key in RSASetPrivateEx\"}}function RSAGenerate(b,i){var a=new SecureRandom();var f=b>>1;this.e=parseInt(i,16);var c=new BigInteger(i,16);for(;;){for(;;){this.p=new BigInteger(b-f,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(f,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var h=this.p;this.p=this.q;this.q=h}var g=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var e=g.multiply(d);if(e.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(e);this.dmp1=this.d.mod(g);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=true}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}function RSADecryptOAEP(e,d,b){var f=parseBigInt(e,16);var a=this.doPrivate(f);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,d,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP;\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction ECFieldElementFp(b,a){this.x=a;this.q=b}function feFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.x.equals(a.x))}function feFpToBigInteger(){return this.x}function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))}function feFpAdd(a){return new ECFieldElementFp(this.q,this.x.add(a.toBigInteger()).mod(this.q))}function feFpSubtract(a){return new ECFieldElementFp(this.q,this.x.subtract(a.toBigInteger()).mod(this.q))}function feFpMultiply(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger()).mod(this.q))}function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))}function feFpDivide(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger().modInverse(this.q)).mod(this.q))}ECFieldElementFp.prototype.equals=feFpEquals;ECFieldElementFp.prototype.toBigInteger=feFpToBigInteger;ECFieldElementFp.prototype.negate=feFpNegate;ECFieldElementFp.prototype.add=feFpAdd;ECFieldElementFp.prototype.subtract=feFpSubtract;ECFieldElementFp.prototype.multiply=feFpMultiply;ECFieldElementFp.prototype.square=feFpSquare;ECFieldElementFp.prototype.divide=feFpDivide;function ECPointFp(c,a,d,b){this.curve=c;this.x=a;this.y=d;if(b==null){this.z=BigInteger.ONE}else{this.z=b}this.zinv=null}function pointFpGetX(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpGetY(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpEquals(a){if(a==this){return true}if(this.isInfinity()){return a.isInfinity()}if(a.isInfinity()){return this.isInfinity()}var c,b;c=a.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(a.z)).mod(this.curve.q);if(!c.equals(BigInteger.ZERO)){return false}b=a.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(a.z)).mod(this.curve.q);return b.equals(BigInteger.ZERO)}function pointFpIsInfinity(){if((this.x==null)&&(this.y==null)){return true}return this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)}function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)}function pointFpAdd(l){if(this.isInfinity()){return l}if(l.isInfinity()){return this}var p=l.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(l.z)).mod(this.curve.q);var o=l.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(l.z)).mod(this.curve.q);if(BigInteger.ZERO.equals(o)){if(BigInteger.ZERO.equals(p)){return this.twice()}return this.curve.getInfinity()}var j=new BigInteger(\"3\");var e=this.x.toBigInteger();var n=this.y.toBigInteger();var c=l.x.toBigInteger();var k=l.y.toBigInteger();var m=o.square();var i=m.multiply(o);var d=e.multiply(m);var g=p.square().multiply(this.z);var a=g.subtract(d.shiftLeft(1)).multiply(l.z).subtract(i).multiply(o).mod(this.curve.q);var h=d.multiply(j).multiply(p).subtract(n.multiply(i)).subtract(g.multiply(p)).multiply(l.z).add(p.multiply(i)).mod(this.curve.q);var f=i.multiply(this.z).multiply(l.z).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),f)}function pointFpTwice(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var g=new BigInteger(\"3\");var c=this.x.toBigInteger();var h=this.y.toBigInteger();var e=h.multiply(this.z);var j=e.multiply(h).mod(this.curve.q);var i=this.curve.a.toBigInteger();var k=c.square().multiply(g);if(!BigInteger.ZERO.equals(i)){k=k.add(this.z.square().multiply(i))}k=k.mod(this.curve.q);var b=k.square().subtract(c.shiftLeft(3).multiply(j)).shiftLeft(1).multiply(e).mod(this.curve.q);var f=k.multiply(g).multiply(c).subtract(j.shiftLeft(1)).shiftLeft(2).multiply(j).subtract(k.square().multiply(k)).mod(this.curve.q);var d=e.square().multiply(e).shiftLeft(3).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(b),this.curve.fromBigInteger(f),d)}function pointFpMultiply(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add(a?this:l)}}return d}function pointFpMultiplyTwo(c,a,b){var d;if(c.bitLength()>b.bitLength()){d=c.bitLength()-1}else{d=b.bitLength()-1}var f=this.curve.getInfinity();var e=this.add(a);while(d>=0){f=f.twice();if(c.testBit(d)){if(b.testBit(d)){f=f.add(e)}else{f=f.add(this)}}else{if(b.testBit(d)){f=f.add(a)}}--d}return f}ECPointFp.prototype.getX=pointFpGetX;ECPointFp.prototype.getY=pointFpGetY;ECPointFp.prototype.equals=pointFpEquals;ECPointFp.prototype.isInfinity=pointFpIsInfinity;ECPointFp.prototype.negate=pointFpNegate;ECPointFp.prototype.add=pointFpAdd;ECPointFp.prototype.twice=pointFpTwice;ECPointFp.prototype.multiply=pointFpMultiply;ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo;function ECCurveFp(e,d,c){this.q=e;this.a=this.fromBigInteger(d);this.b=this.fromBigInteger(c);this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b))}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)}function curveFpDecodePointHex(d){switch(parseInt(d.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var a=(d.length-2)/2;var c=d.substr(2,a);var b=d.substr(a+2,a);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(b,16)));default:return null}}ECCurveFp.prototype.getQ=curveFpGetQ;ECCurveFp.prototype.getA=curveFpGetA;ECCurveFp.prototype.getB=curveFpGetB;ECCurveFp.prototype.equals=curveFpEquals;ECCurveFp.prototype.getInfinity=curveFpGetInfinity;ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger;ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex;\n/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib\n */\nECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};ECPointFp.prototype.getEncoded=function(c){var d=function(h,f){var g=h.toByteArrayUnsigned();if(fg.length){g.unshift(0)}}return g};var a=this.getX().toBigInteger();var e=this.getY().toBigInteger();var b=d(a,32);if(c){if(e.isEven()){b.unshift(2)}else{b.unshift(3)}}else{b.unshift(4);b=b.concat(d(e,32))}return b};ECPointFp.decodeFrom=function(g,c){var f=c[0];var e=c.length-1;var d=c.slice(1,1+e/2);var b=c.slice(1+e/2,1+e);d.unshift(0);b.unshift(0);var a=new BigInteger(d);var h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.decodeFromHex=function(g,c){var f=c.substr(0,2);var e=c.length-2;var d=c.substr(2,e/2);var b=c.substr(2+e/2,e/2);var a=new BigInteger(d,16);var h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.prototype.add2D=function(c){if(this.isInfinity()){return c}if(c.isInfinity()){return this}if(this.x.equals(c.x)){if(this.y.equals(c.y)){return this.twice()}return this.curve.getInfinity()}var g=c.x.subtract(this.x);var e=c.y.subtract(this.y);var a=e.divide(g);var d=a.square().subtract(this.x).subtract(c.x);var f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var b=this.curve.fromBigInteger(BigInteger.valueOf(2));var e=this.curve.fromBigInteger(BigInteger.valueOf(3));var a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b));var c=a.square().subtract(this.x.multiply(b));var d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)};ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add2D(a?this:l)}}return d};ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger();var i=this.getY().toBigInteger();var f=this.curve.getA().toBigInteger();var c=this.curve.getB().toBigInteger();var h=this.curve.getQ();var e=i.multiply(i).mod(h);var g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)};ECPointFp.prototype.toString=function(){return\"(\"+this.getX().toBigInteger().toString()+\",\"+this.getY().toBigInteger().toString()+\")\"};ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity()){throw new Error(\"Point is at infinity.\")}var a=this.getX().toBigInteger();var b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"x coordinate out of bounds\")}if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"y coordinate out of bounds\")}if(!this.isOnCurve()){throw new Error(\"Point is not on the curve.\")}if(this.multiply(c).isInfinity()){throw new Error(\"Point is not a scalar multiple of G.\")}return true};\n/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval\n */\nvar jsonParse=(function(){var e=\"(?:-?\\\\b(?:0|[1-9][0-9]*)(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\\\b)\";var j='(?:[^\\\\0-\\\\x08\\\\x0a-\\\\x1f\"\\\\\\\\]|\\\\\\\\(?:[\"/\\\\\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:\"'+j+'*\")';var d=new RegExp(\"(?:false|true|null|[\\\\{\\\\}\\\\[\\\\]]|\"+e+\"|\"+i+\")\",\"g\");var k=new RegExp(\"\\\\\\\\(?:([^u])|u(.{4}))\",\"g\");var g={'\"':'\"',\"/\":\"/\",\"\\\\\":\"\\\\\",b:\"\\b\",f:\"\\f\",n:\"\\n\",r:\"\\r\",t:\"\\t\"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String(\"\");var a=\"\\\\\";var f={\"{\":Object,\"[\":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if(\"{\"===v){x={}}else{if(\"[\"===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({\"\":x},\"\")}return x}})();\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.asn1==\"undefined\"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b=\"0\"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!=\"-\"){if(f.length%2==1){f=\"0\"+f}else{if(!f.match(/^[0-7]/)){f=\"00\"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g=\"\";for(var d=0;d15){throw\"ASN.1 length too long to represent by 8x: n = \"+i.toString(16)}var f=128+g;return f.toString(16)+h}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return\"\"}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!=\"undefined\"){if(typeof c==\"string\"){this.setString(c)}else{if(typeof c.str!=\"undefined\"){this.setString(c.str)}else{if(typeof c.hex!=\"undefined\"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(f){utc=f.getTime()+(f.getTimezoneOffset()*60000);var e=new Date(utc);return e};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o==\"utc\"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,\"\");r=r+\".\"+k}}return r+\"Z\"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join(\"0\")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!=\"undefined\"){if(typeof b.array!=\"undefined\"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT=\"01\";this.hTLV=\"0101ff\"};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT=\"02\";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!=\"undefined\"){if(typeof a.bigint!=\"undefined\"){this.setByBigInteger(a.bigint)}else{if(typeof a[\"int\"]!=\"undefined\"){this.setByInteger(a[\"int\"])}else{if(typeof a==\"number\"){this.setByInteger(a)}else{if(typeof a.hex!=\"undefined\"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!==\"undefined\"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex=\"00\"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT=\"03\";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=(l*2))){break}if(d>=200){break}g.push(b);c=b;d++}return g};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){throw\"checking tag doesn't match: \"+e.substr(d,2)+\"!=\"+i}}return d}f=c.shift();b=g.getChildIdx(e,d);return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getTLVbyList=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyList(d,c,b);if(a===undefined){throw\"can't find nthList object\"}if(f!==undefined){if(d.substr(a,2)!=f){throw\"checking tag doesn't match: \"+d.substr(a,2)+\"!=\"+f}}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a===undefined){throw\"can't find nthList object\"}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join(\"0\")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+\".\"+j.join(\".\")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+\"..(total \"+A.length/2+\"bytes)..\"+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=\"\"}var x=c.ommit_long_octet;if(e.substr(l,2)==\"01\"){var h=j(e,l);if(h==\"00\"){return g+\"BOOLEAN FALSE\\n\"}else{return g+\"BOOLEAN TRUE\\n\"}}if(e.substr(l,2)==\"02\"){var h=j(e,l);return g+\"INTEGER \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"03\"){var h=j(e,l);return g+\"BITSTRING \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"04\"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+\"OCTETSTRING, encapsulates\\n\";k=k+y(h,c,0,g+\" \");return k}else{return g+\"OCTETSTRING \"+q(h,x)+\"\\n\"}}if(e.substr(l,2)==\"05\"){return g+\"NULL\\n\"}if(e.substr(l,2)==\"06\"){var m=j(e,l);var a=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(a);var b=a.replace(/\\./g,\" \");if(o!=\"\"){return g+\"ObjectIdentifier \"+o+\" (\"+b+\")\\n\"}else{return g+\"ObjectIdentifier (\"+b+\")\\n\"}}if(e.substr(l,2)==\"0c\"){return g+\"UTF8String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"13\"){return g+\"PrintableString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"14\"){return g+\"TeletexString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"16\"){return g+\"IA5String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"17\"){return g+\"UTCTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"18\"){return g+\"GeneralizedTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"30\"){if(e.substr(l,4)==\"3000\"){return g+\"SEQUENCE {}\\n\"}var k=g+\"SEQUENCE\\n\";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)==\"06\"&&e.substr(d[d.length-1],2)==\"04\"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u0){var m=new f({array:this.extensionsArray});var k=new c({explicit:true,tag:\"a3\",obj:m});this.asn1Array.push(k)}var n=new f({array:this.asn1Array});this.hTLV=n.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension=function(d){KJUR.asn1.x509.Extension.superclass.constructor.call(this);var f=null,a=KJUR,e=a.asn1,h=e.DERObjectIdentifier,i=e.DEROctetString,b=e.DERBitString,g=e.DERBoolean,c=e.DERSequence;this.getEncodedHex=function(){var m=new h({oid:this.oid});var l=new i({hex:this.getExtnValueHex()});var k=new Array();k.push(m);if(this.critical){k.push(new g())}k.push(l);var j=new c({array:k});return j.getEncodedHex()};this.critical=false;if(d!==undefined){if(d.critical!==undefined){this.critical=d.critical}}};YAHOO.lang.extend(KJUR.asn1.x509.Extension,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension.appendByNameToArray=function(e,c,b){var g=e.toLowerCase(),f=KJUR.asn1.x509;if(g==\"basicconstraints\"){var d=new f.BasicConstraints(c);b.push(d)}else{if(g==\"keyusage\"){var d=new f.KeyUsage(c);b.push(d)}else{if(g==\"crldistributionpoints\"){var d=new f.CRLDistributionPoints(c);b.push(d)}else{if(g==\"extkeyusage\"){var d=new f.ExtKeyUsage(c);b.push(d)}else{if(g==\"authoritykeyidentifier\"){var d=new f.AuthorityKeyIdentifier(c);b.push(d)}else{if(g==\"authorityinfoaccess\"){var d=new f.AuthorityInfoAccess(c);b.push(d)}else{if(g==\"subjectaltname\"){var d=new f.SubjectAltName(c);b.push(d)}else{if(g==\"issueraltname\"){var d=new f.IssuerAltName(c);b.push(d)}else{throw\"unsupported extension name: \"+e}}}}}}}}};KJUR.asn1.x509.KeyUsage=function(f){KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this,f);var a=X509.KEYUSAGE_NAME;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.15\";if(f!==undefined){if(f.bin!==undefined){this.asn1ExtnValue=new KJUR.asn1.DERBitString(f)}if(f.names!==undefined&&f.names.length!==undefined){var e=f.names;var d=\"000000000\";for(var c=0;c-1){e.push(new KJUR.asn1.DERInteger({\"int\":this.pathLen}))}var d=new KJUR.asn1.DERSequence({array:e});this.asn1ExtnValue=d;return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.19\";this.cA=false;this.pathLen=-1;if(c!==undefined){if(c.cA!==undefined){this.cA=c.cA}if(c.pathLen!==undefined){this.pathLen=c.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){this.asn1ExtnValue=new a.DERSequence({array:e})};this.setByOneURI=function(h){var e=new c.GeneralNames([{uri:h}]);var g=new c.DistributionPointName(e);var f=new c.DistributionPoint({dpobj:g});this.setByDPArray([f])};this.oid=\"2.5.29.31\";if(d!==undefined){if(d.array!==undefined){this.setByDPArray(d.array)}else{if(d.uri!==undefined){this.setByOneURI(d.uri)}}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLDistributionPoints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.ExtKeyUsage=function(c){KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,c);var b=KJUR,a=b.asn1;this.setPurposeArray=function(d){this.asn1ExtnValue=new a.DERSequence();for(var e=0;e0){var h=new b({array:this.aRevokedCert});this.asn1Array.push(h)}var i=new b({array:this.asn1Array});this.hTLV=i.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize=function(){this.asn1Version=null;this.asn1SignatureAlg=null;this.asn1Issuer=null;this.asn1ThisUpdate=null;this.asn1NextUpdate=null;this.aRevokedCert=new Array()};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertList,KJUR.asn1.ASN1Object);KJUR.asn1.x509.CRLEntry=function(e){KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);var d=null,c=null,b=KJUR,a=b.asn1;this.setCertSerial=function(f){this.sn=new a.DERInteger(f)};this.setRevocationDate=function(f){this.time=new a.x509.Time(f)};this.getEncodedHex=function(){var f=new a.DERSequence({array:[this.sn,this.time]});this.TLV=f.getEncodedHex();return this.TLV};if(e!==undefined){if(e.time!==undefined){this.setRevocationDate(e.time)}if(e.sn!==undefined){this.setCertSerial(e.sn)}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLEntry,KJUR.asn1.ASN1Object);KJUR.asn1.x509.X500Name=function(f){KJUR.asn1.x509.X500Name.superclass.constructor.call(this);this.asn1Array=new Array();var d=KJUR,c=d.asn1,e=c.x509,b=pemtohex;this.setByString=function(g){var k=g.split(\"/\");k.shift();var j=[];for(var l=0;l0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+\",\"+h).replace(/\\\\,/g,\",\");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)===\"\\\\\"){e=true}}b=b.map(function(a){return a.replace(\"/\",\"\\\\/\")});b.reverse();return\"/\"+b.join(\"/\")};KJUR.asn1.x509.RDN=function(a){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=new Array();this.addByString=function(b){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:b}))};this.addByMultiValuedString=function(d){var b=KJUR.asn1.x509.RDN.parseString(d);for(var c=0;c0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+\"+\"+k).replace(/\\\\\\+/g,\"+\");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)===\"\\\\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/\"$/)){var d=(e+\"+\"+k).replace(/^([^=]+)=\"(.*)\"$/,\"$1=$2\");b.push(d);l=false}else{b.push(e+\"+\"+k)}}else{b.push(k)}if(k.match(/^[^=]+=\"/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(d){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var f=null,e=null,a=\"utf8\",c=KJUR,b=c.asn1;this.setByString=function(h){var g=h.match(/^([^=]+)=(.+)$/);if(g){this.setByAttrTypeAndValueStr(g[1],g[2])}else{throw\"malformed attrTypeAndValueStr: \"+h}};this.setByAttrTypeAndValueStr=function(i,h){this.typeObj=KJUR.asn1.x509.OID.atype2obj(i);var g=a;if(i==\"C\"){g=\"prn\"}this.valueObj=this.getValueObj(g,h)};this.getValueObj=function(h,g){if(h==\"utf8\"){return new b.DERUTF8String({str:g})}if(h==\"prn\"){return new b.DERPrintableString({str:g})}if(h==\"tel\"){return new b.DERTeletexString({str:g})}if(h==\"ia5\"){return new b.DERIA5String({str:g})}throw\"unsupported directory string type: type=\"+h+\" value=\"+g};this.getEncodedHex=function(){var g=new b.DERSequence({array:[this.typeObj,this.valueObj]});this.TLV=g.getEncodedHex();return this.TLV};if(d!==undefined){if(d.str!==undefined){this.setByString(d.str)}}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw\"algId and/or subjPubKey not set\"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{\"int\":{bigint:q.n}},{\"int\":{\"int\":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:\"rsaEncryption\"});this.asn1SubjPKey=new b({hex:\"00\"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:\"ecPublicKey\",asn1params:r});this.asn1SubjPKey=new b({hex:\"00\"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{\"int\":{bigint:q.p}},{\"int\":{bigint:q.q}},{\"int\":{bigint:q.g}}]});this.asn1AlgId=new o({name:\"dsa\",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:\"00\"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type==\"utc\"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type==\"utc\"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type=\"utc\";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type=\"utc\"}if(f.str.match(/^[0-9]{14}Z$/)){this.type=\"gen\"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(d){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw\"algorithm not specified\"}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var e=[this.asn1Alg];if(this.asn1Params!==null){e.push(this.asn1Params)}var f=new a.DERSequence({array:e});this.hTLV=f.getEncodedHex();return this.hTLV};if(d!==undefined){if(d.name!==undefined){this.nameAlg=d.name}if(d.asn1params!==undefined){this.asn1Params=d.asn1params}if(d.paramempty!==undefined){this.paramEmpty=d.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){var c=this.nameAlg.toLowerCase();if(c.substr(-7,7)!==\"withdsa\"&&c.substr(-9,9)!==\"withecdsa\"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:\"81\",dns:\"82\",dn:\"a4\",uri:\"86\",ip:\"87\"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type=\"rfc822\";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type=\"dns\";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type=\"uri\";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({str:p.dn})}if(p.ldapdn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certissuer param not cert\"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certsubj param not cert\"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type=\"ip\";this.explicit=false;var q=p.ip;var s;var n=\"malformed IP address\";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex(\"[\"+q.split(\".\").join(\",\")+\"]\");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw\"unsupported type in params=\"+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){r=new b({obj:this.dUnsignedAttrs,tag:\"a1\",explicit:false})}var q=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,o,this.dSigAlg,this.dSig,];if(r!=null){q.push(r)}var p=new h.DERSequence({array:q});this.hTLV=p.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.SignerInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.EncapsulatedContentInfo=function(g){var c=KJUR,b=c.asn1,e=b.DERTaggedObject,a=b.DERSequence,h=b.DERObjectIdentifier,d=b.DEROctetString,f=b.cms;f.EncapsulatedContentInfo.superclass.constructor.call(this);this.dEContentType=new h({name:\"data\"});this.dEContent=null;this.isDetached=false;this.eContentValueHex=null;this.setContentType=function(i){if(i.match(/^[0-2][.][0-9.]+$/)){this.dEContentType=new h({oid:i})}else{this.dEContentType=new h({name:i})}};this.setContentValue=function(i){if(i!==undefined){if(typeof i.hex==\"string\"){this.eContentValueHex=i.hex}else{if(typeof i.str==\"string\"){this.eContentValueHex=utf8tohex(i.str)}}}};this.setContentValueHex=function(i){this.eContentValueHex=i};this.setContentValueStr=function(i){this.eContentValueHex=utf8tohex(i)};this.getEncodedHex=function(){if(typeof this.eContentValueHex!=\"string\"){throw\"eContentValue not yet set\"}var k=new d({hex:this.eContentValueHex});this.dEContent=new e({obj:k,tag:\"a0\",explicit:true});var i=[this.dEContentType];if(!this.isDetached){i.push(this.dEContent)}var j=new a({array:i});this.hTLV=j.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.EncapsulatedContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.ContentInfo=function(f){var c=KJUR,b=c.asn1,d=b.DERTaggedObject,a=b.DERSequence,e=b.x509;KJUR.asn1.cms.ContentInfo.superclass.constructor.call(this);this.dContentType=null;this.dContent=null;this.setContentType=function(g){if(typeof g==\"string\"){this.dContentType=e.OID.name2obj(g)}};this.getEncodedHex=function(){var h=new d({obj:this.dContent,tag:\"a0\",explicit:true});var g=new a({array:[this.dContentType,h]});this.hTLV=g.getEncodedHex();return this.hTLV};if(f!==undefined){if(f.type){this.setContentType(f.type)}if(f.obj&&f.obj instanceof b.ASN1Object){this.dContent=f.obj}}};YAHOO.lang.extend(KJUR.asn1.cms.ContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.SignedData=function(e){var a=KJUR,h=a.asn1,j=h.ASN1Object,g=h.DERInteger,m=h.DERSet,f=h.DERSequence,b=h.DERTaggedObject,l=h.cms,i=l.EncapsulatedContentInfo,d=l.SignerInfo,n=l.ContentInfo,c=h.x509,k=c.AlgorithmIdentifier;KJUR.asn1.cms.SignedData.superclass.constructor.call(this);this.dCMSVersion=new g({\"int\":1});this.dDigestAlgs=null;this.digestAlgNameList=[];this.dEncapContentInfo=new i();this.dCerts=null;this.certificateList=[];this.crlList=[];this.signerInfoList=[new d()];this.addCertificatesByPEM=function(p){var q=pemtohex(p);var r=new j();r.hTLV=q;this.certificateList.push(r)};this.getEncodedHex=function(){if(typeof this.hTLV==\"string\"){return this.hTLV}if(this.dDigestAlgs==null){var u=[];for(var t=0;t0){var v=new m({array:this.certificateList});this.dCerts=new b({obj:v,tag:\"a0\",explicit:false})}}if(this.dCerts!=null){p.push(this.dCerts)}var r=new m({array:this.signerInfoList});p.push(r);var q=new f({array:p});this.hTLV=q.getEncodedHex();return this.hTLV};this.getContentInfo=function(){this.getEncodedHex();var o=new n({type:\"signed-data\",obj:this});return o};this.getContentInfoEncodedHex=function(){var o=this.getContentInfo();var p=o.getEncodedHex();return p};this.getPEM=function(){return hextopem(this.getContentInfoEncodedHex(),\"CMS\")}};YAHOO.lang.extend(KJUR.asn1.cms.SignedData,KJUR.asn1.ASN1Object);KJUR.asn1.cms.CMSUtil=new function(){};KJUR.asn1.cms.CMSUtil.newSignedData=function(d){var b=KJUR,j=b.asn1,q=j.cms,f=q.SignerInfo,n=q.SignedData,o=q.SigningTime,a=q.SigningCertificate,p=q.SigningCertificateV2,c=j.cades,e=c.SignaturePolicyIdentifier;var m=new n();m.dEncapContentInfo.setContentValue(d.content);if(typeof d.certs==\"object\"){for(var h=0;h0){var s=new f({array:this.extensionsArray});var r=new m({array:[s]});var q=new f({array:[new k({oid:\"1.2.840.113549.1.9.14\"}),r]});var p=new c({explicit:true,tag:\"a0\",obj:q});this.asn1Array.push(p)}else{var p=new c({explicit:false,tag:\"a0\",obj:new j()});this.asn1Array.push(p)}var t=new f({array:this.asn1Array});this.hTLV=t.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CSRUtil=new function(){};KJUR.asn1.csr.CSRUtil.newCSRPEM=function(h){var c=KEYUTIL,b=KJUR.asn1.csr;if(h.subject===undefined){throw\"parameter subject undefined\"}if(h.sbjpubkey===undefined){throw\"parameter sbjpubkey undefined\"}if(h.sigalg===undefined){throw\"parameter sigalg undefined\"}if(h.sbjprvkey===undefined){throw\"parameter sbjpubkey undefined\"}var d=new b.CertificationRequestInfo();d.setSubjectByParam(h.subject);d.setSubjectPublicKeyByGetKey(h.sbjpubkey);if(h.ext!==undefined&&h.ext.length!==undefined){for(var e=0;ef.length){f=c[d]}}e=e.replace(f,\"::\");return e.slice(1,-1)}function hextoip(b){var d=\"malformed hex value\";if(!b.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){throw d}if(b.length==8){var c;try{c=parseInt(b.substr(0,2),16)+\".\"+parseInt(b.substr(2,2),16)+\".\"+parseInt(b.substr(4,2),16)+\".\"+parseInt(b.substr(6,2),16);return c}catch(a){throw d}}else{if(b.length==32){return hextoipv6(b)}else{return b}}}function iptohex(f){var j=\"malformed IP address\";f=f.toLowerCase(f);if(f.match(/^[0-9.]+$/)){var b=f.split(\".\");if(b.length!==4){throw j}var g=\"\";try{for(var e=0;e<4;e++){var h=parseInt(b[e]);g+=(\"0\"+h.toString(16)).slice(-2)}return g}catch(c){throw j}}else{if(f.match(/^[0-9a-f:]+$/)&&f.indexOf(\":\")!==-1){return ipv6tohex(f)}else{throw j}}}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b=\"\";for(var c=0;c\"7\"){return\"00\"+a}return a}function intarystrtohex(b){b=b.replace(/^\\s*\\[\\s*/,\"\");b=b.replace(/\\s*\\]\\s*$/,\"\");b=b.replace(/\\s*/g,\"\");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;bd){throw\"key is too short for SigAlg: keylen=\"+j+\",\"+a}var b=\"0001\";var k=\"00\"+c;var g=\"\";var l=d-b.length-k.length;for(var f=0;f=0;--p){q=q.twice2D();q.z=BigInteger.ONE;if(o.testBit(p)){if(n.testBit(p)){q=q.add2D(t)}else{q=q.add2D(s)}}else{if(n.testBit(p)){q=q.add2D(r)}}}return q}this.getBigRandom=function(i){return new BigInteger(i.bitLength(),a).mod(i.subtract(BigInteger.ONE)).add(BigInteger.ONE)};this.setNamedCurve=function(i){this.ecparams=KJUR.crypto.ECParameterDB.getByName(i);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=i};this.setPrivateKeyHex=function(i){this.isPrivate=true;this.prvKeyHex=i};this.setPublicKeyHex=function(i){this.isPublic=true;this.pubKeyHex=i};this.getPublicKeyXYHex=function(){var k=this.pubKeyHex;if(k.substr(0,2)!==\"04\"){throw\"this method supports uncompressed format(04) only\"}var j=this.ecparams.keylen/4;if(k.length!==2+j*2){throw\"malformed public key hex length\"}var i={};i.x=k.substr(2,j);i.y=k.substr(2+j);return i};this.getShortNISTPCurveName=function(){var i=this.curveName;if(i===\"secp256r1\"||i===\"NIST P-256\"||i===\"P-256\"||i===\"prime256v1\"){return\"P-256\"}if(i===\"secp384r1\"||i===\"NIST P-384\"||i===\"P-384\"){return\"P-384\"}return null};this.generateKeyPairHex=function(){var k=this.ecparams.n;var n=this.getBigRandom(k);var l=this.ecparams.G.multiply(n);var q=l.getX().toBigInteger();var o=l.getY().toBigInteger();var i=this.ecparams.keylen/4;var m=(\"0000000000\"+n.toString(16)).slice(-i);var r=(\"0000000000\"+q.toString(16)).slice(-i);var p=(\"0000000000\"+o.toString(16)).slice(-i);var j=\"04\"+r+p;this.setPrivateKeyHex(m);this.setPublicKeyHex(j);return{ecprvhex:m,ecpubhex:j}};this.signWithMessageHash=function(i){return this.signHex(i,this.prvKeyHex)};this.signHex=function(o,j){var t=new BigInteger(j,16);var l=this.ecparams.n;var q=new BigInteger(o,16);do{var m=this.getBigRandom(l);var u=this.ecparams.G;var p=u.multiply(m);var i=p.getX().toBigInteger().mod(l)}while(i.compareTo(BigInteger.ZERO)<=0);var v=m.modInverse(l).multiply(q.add(t.multiply(i))).mod(l);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(i,v)};this.sign=function(m,u){var q=u;var j=this.ecparams.n;var p=BigInteger.fromByteArrayUnsigned(m);do{var l=this.getBigRandom(j);var t=this.ecparams.G;var o=t.multiply(l);var i=o.getX().toBigInteger().mod(j)}while(i.compareTo(BigInteger.ZERO)<=0);var v=l.modInverse(j).multiply(p.add(q.multiply(i))).mod(j);return this.serializeSig(i,v)};this.verifyWithMessageHash=function(j,i){return this.verifyHex(j,i,this.pubKeyHex)};this.verifyHex=function(m,i,p){var l,j;var o=KJUR.crypto.ECDSA.parseSigHex(i);l=o.r;j=o.s;var k;k=ECPointFp.decodeFromHex(this.ecparams.curve,p);var n=new BigInteger(m,16);return this.verifyRaw(n,l,j,k)};this.verify=function(o,p,j){var l,i;if(Bitcoin.Util.isArray(p)){var n=this.parseSig(p);l=n.r;i=n.s}else{if(\"object\"===typeof p&&p.r&&p.s){l=p.r;i=p.s}else{throw\"Invalid value for signature\"}}var k;if(j instanceof ECPointFp){k=j}else{if(Bitcoin.Util.isArray(j)){k=ECPointFp.decodeFrom(this.ecparams.curve,j)}else{throw\"Invalid format for pubkey value, must be byte array or ECPointFp\"}}var m=BigInteger.fromByteArrayUnsigned(o);return this.verifyRaw(m,l,i,k)};this.verifyRaw=function(o,i,w,m){var l=this.ecparams.n;var u=this.ecparams.G;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(l)>=0){return false}if(w.compareTo(BigInteger.ONE)<0||w.compareTo(l)>=0){return false}var p=w.modInverse(l);var k=o.multiply(p).mod(l);var j=i.multiply(p).mod(l);var q=u.multiply(k).add(m.multiply(j));var t=q.getX().toBigInteger().mod(l);return t.equals(i)};this.serializeSig=function(k,j){var l=k.toByteArraySigned();var i=j.toByteArraySigned();var m=[];m.push(2);m.push(l.length);m=m.concat(l);m.push(2);m.push(i.length);m=m.concat(i);m.unshift(m.length);m.unshift(48);return m};this.parseSig=function(n){var m;if(n[0]!=48){throw new Error(\"Signature not a valid DERSequence\")}m=2;if(n[m]!=2){throw new Error(\"First element in signature must be a DERInteger\")}var l=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];if(n[m]!=2){throw new Error(\"Second element in signature must be a DERInteger\")}var i=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];var k=BigInteger.fromByteArrayUnsigned(l);var j=BigInteger.fromByteArrayUnsigned(i);return{r:k,s:j}};this.parseSigCompact=function(m){if(m.length!==65){throw\"Signature has the wrong length\"}var j=m[0]-27;if(j<0||j>7){throw\"Invalid signature type\"}var o=this.ecparams.n;var l=BigInteger.fromByteArrayUnsigned(m.slice(1,33)).mod(o);var k=BigInteger.fromByteArrayUnsigned(m.slice(33,65)).mod(o);return{r:l,s:k,i:j}};this.readPKCS5PrvKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var i,k,o;try{i=p(l,0,[2,0],\"06\");k=p(l,0,[1],\"04\");try{o=p(l,0,[3,0],\"03\").substr(2)}catch(j){}}catch(j){throw\"malformed PKCS#1/5 plain ECC private key\"}this.curveName=m(i);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o);this.setPrivateKeyHex(k);this.isPublic=false};this.readPKCS8PrvKeyHex=function(l){var q=ASN1HEX;var i=KJUR.crypto.ECDSA.getName;var n=q.getVbyList;if(q.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var j,p,m,k;try{j=n(l,0,[1,0],\"06\");p=n(l,0,[1,1],\"06\");m=n(l,0,[2,0,1],\"04\");try{k=n(l,0,[2,0,2,0],\"03\").substr(2)}catch(o){}}catch(o){throw\"malformed PKCS#8 plain ECC private key\"}this.curveName=i(p);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(k);this.setPrivateKeyHex(m);this.isPublic=false};this.readPKCS8PubKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var k,i,o;try{k=p(l,0,[0,0],\"06\");i=p(l,0,[0,1],\"06\");o=p(l,0,[1],\"03\").substr(2)}catch(j){throw\"malformed PKCS#8 ECC public key\"}this.curveName=m(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o)};this.readCertPubKeyHex=function(k,p){if(p!==5){p=6}var m=ASN1HEX;var l=KJUR.crypto.ECDSA.getName;var o=m.getVbyList;if(m.isASN1HEX(k)===false){throw\"not ASN.1 hex string\"}var i,n;try{i=o(k,0,[0,p,0,1],\"06\");n=o(k,0,[0,p,1],\"03\").substr(2)}catch(j){throw\"malformed X.509 certificate ECC public key\"}this.curveName=l(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(n)};if(h!==undefined){if(h.curve!==undefined){this.curveName=h.curve}}if(this.curveName===undefined){this.curveName=e}this.setNamedCurve(this.curveName);if(h!==undefined){if(h.prv!==undefined){this.setPrivateKeyHex(h.prv)}if(h.pub!==undefined){this.setPublicKeyHex(h.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX;var i=j.getChildIdx;var g=j.getV;if(f.substr(0,2)!=\"30\"){throw\"signature is not a ASN.1 sequence\"}var h=i(f,0);if(h.length!=2){throw\"number of signature ASN.1 sequence elements seem wrong\"}var e=h[0];var d=h[1];if(f.substr(e,2)!=\"02\"){throw\"1st item of sequene of signature is not ASN.1 integer\"}if(f.substr(d,2)!=\"02\"){throw\"2nd item of sequene of signature is not ASN.1 integer\"}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(c){var d=KJUR.crypto.ECDSA.parseSigHexInHexRS(c);var b=d.r;var a=d.s;if(b.substr(0,2)==\"00\"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)==\"00\"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b=\"00\"+b}if((a.length%32)==30){a=\"00\"+a}if(b.length%32!=0){throw\"unknown ECDSA sig r length error\"}if(a.length%32!=0){throw\"unknown ECDSA sig s length error\"}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if((((a.length/2)*8)%(16*8))!=0){throw\"unknown ECDSA concatinated r-s sig length error\"}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.getEncodedHex()};KJUR.crypto.ECDSA.getName=function(a){if(a===\"2a8648ce3d030107\"){return\"secp256r1\"}if(a===\"2b8104000a\"){return\"secp256k1\"}if(a===\"2b81040022\"){return\"secp384r1\"}if(\"|secp256r1|NIST P-256|P-256|prime256v1|\".indexOf(a)!==-1){return\"secp256r1\"}if(\"|secp256k1|\".indexOf(a)!==-1){return\"secp256k1\"}if(\"|secp384r1|NIST P-384|P-384|\".indexOf(a)!==-1){return\"secp384r1\"}return null};\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.crypto==\"undefined\"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!=\"undefined\"){d=c[e]}if(typeof b[d]!=\"undefined\"){return b[d]}throw\"unregistered EC curve name: \"+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex(\"04\"+f+k);b[A][\"name\"]=A;b[A][\"keylen\"]=l;b[A][\"curve\"]=r;b[A][\"G\"]=q;b[A][\"n\"]=t;b[A][\"h\"]=w;b[A][\"oid\"]=d;b[A][\"info\"]=x;for(var v=0;v1){g=new BigInteger(i,16)}else{g=null}h=new BigInteger(j,16);this.setPrivate(c,a,e,g,h)};this.setPublic=function(c,b,a,d){this.isPublic=true;this.p=c;this.q=b;this.g=a;this.y=d;this.x=null};this.setPublicHex=function(f,e,d,g){var b,a,h,c;b=new BigInteger(f,16);a=new BigInteger(e,16);h=new BigInteger(d,16);c=new BigInteger(g,16);this.setPublic(b,a,h,c)};this.signWithMessageHash=function(d){var c=this.p;var b=this.q;var f=this.g;var i=this.y;var j=this.x;var e=KJUR.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),b.subtract(BigInteger.ONE));var l=d.substr(0,b.bitLength()/4);var h=new BigInteger(l,16);var a=(f.modPow(e,c)).mod(b);var n=(e.modInverse(b).multiply(h.add(j.multiply(a)))).mod(b);var m=KJUR.asn1.ASN1Util.jsonToASN1HEX({seq:[{\"int\":{bigint:a}},{\"int\":{bigint:n}}]});return m};this.verifyWithMessageHash=function(h,f){var d=this.p;var b=this.q;var j=this.g;var l=this.y;var i=this.parseASN1Signature(f);var a=i[0];var t=i[1];var o=h.substr(0,b.bitLength()/4);var k=new BigInteger(o,16);if(BigInteger.ZERO.compareTo(a)>0||a.compareTo(b)>0){throw\"invalid DSA signature\"}if(BigInteger.ZERO.compareTo(t)>=0||t.compareTo(b)>0){throw\"invalid DSA signature\"}var m=t.modInverse(b);var e=k.multiply(m).mod(b);var c=a.multiply(m).mod(b);var n=j.modPow(e,d).multiply(l.modPow(c,d)).mod(d).mod(b);return n.compareTo(a)==0};this.parseASN1Signature=function(a){try{var d=new BigInteger(ASN1HEX.getVbyList(a,0,[0],\"02\"),16);var c=new BigInteger(ASN1HEX.getVbyList(a,0,[1],\"02\"),16);return[d,c]}catch(b){throw\"malformed ASN.1 DSA signature\"}};this.readPKCS5PrvKeyHex=function(c){var b,a,f,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[1],\"02\");a=d(c,0,[2],\"02\");f=d(c,0,[3],\"02\");g=d(c,0,[4],\"02\");i=d(c,0,[5],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed PKCS#1/5 plain DSA private key\"}this.setPrivateHex(b,a,f,g,i)};this.readPKCS8PrvKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[1,1,0],\"02\");c=i(d,0,[1,1,1],\"02\");b=i(d,0,[1,1,2],\"02\");g=i(d,0,[2,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 plain DSA private key\"}this.setPrivateHex(f,c,b,null,g)};this.readPKCS8PubKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[0,1,0],\"02\");c=i(d,0,[0,1,1],\"02\");b=i(d,0,[0,1,2],\"02\");g=i(d,0,[1,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 DSA public key\"}this.setPublicHex(f,c,b,g)};this.readCertPubKeyHex=function(c,f){if(f!==5){f=6}var b,a,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[0,f,0,1,0],\"02\");a=d(c,0,[0,f,0,1,1],\"02\");g=d(c,0,[0,f,0,1,2],\"02\");i=d(c,0,[0,f,1,0],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed X.509 certificate DSA public key\"}this.setPublicHex(b,a,g,i)}};\nvar KEYUTIL=function(){var d=function(p,r,q){return k(CryptoJS.AES,p,r,q)};var e=function(p,r,q){return k(CryptoJS.TripleDES,p,r,q)};var a=function(p,r,q){return k(CryptoJS.DES,p,r,q)};var k=function(s,x,u,q){var r=CryptoJS.enc.Hex.parse(x);var w=CryptoJS.enc.Hex.parse(u);var p=CryptoJS.enc.Hex.parse(q);var t={};t.key=w;t.iv=p;t.ciphertext=r;var v=s.decrypt(t,w,{iv:p});return CryptoJS.enc.Hex.stringify(v)};var l=function(p,r,q){return g(CryptoJS.AES,p,r,q)};var o=function(p,r,q){return g(CryptoJS.TripleDES,p,r,q)};var f=function(p,r,q){return g(CryptoJS.DES,p,r,q)};var g=function(t,y,v,q){var s=CryptoJS.enc.Hex.parse(y);var x=CryptoJS.enc.Hex.parse(v);var p=CryptoJS.enc.Hex.parse(q);var w=t.encrypt(s,x,{iv:p});var r=CryptoJS.enc.Hex.parse(w.toString());var u=CryptoJS.enc.Base64.stringify(r);return u};var i={\"AES-256-CBC\":{proc:d,eproc:l,keylen:32,ivlen:16},\"AES-192-CBC\":{proc:d,eproc:l,keylen:24,ivlen:16},\"AES-128-CBC\":{proc:d,eproc:l,keylen:16,ivlen:16},\"DES-EDE3-CBC\":{proc:e,eproc:o,keylen:24,ivlen:8},\"DES-CBC\":{proc:a,eproc:f,keylen:8,ivlen:8}};var c=function(p){return i[p][\"proc\"]};var m=function(p){var r=CryptoJS.lib.WordArray.random(p);var q=CryptoJS.enc.Hex.stringify(r);return q};var n=function(v){var w={};var q=v.match(new RegExp(\"DEK-Info: ([^,]+),([0-9A-Fa-f]+)\",\"m\"));if(q){w.cipher=q[1];w.ivsalt=q[2]}var p=v.match(new RegExp(\"-----BEGIN ([A-Z]+) PRIVATE KEY-----\"));if(p){w.type=p[1]}var u=-1;var x=0;if(v.indexOf(\"\\r\\n\\r\\n\")!=-1){u=v.indexOf(\"\\r\\n\\r\\n\");x=2}if(v.indexOf(\"\\n\\n\")!=-1){u=v.indexOf(\"\\n\\n\");x=1}var t=v.indexOf(\"-----END\");if(u!=-1&&t!=-1){var r=v.substring(u+x*2,t-x);r=r.replace(/\\s+/g,\"\");w.data=r}return w};var j=function(q,y,p){var v=p.substring(0,16);var t=CryptoJS.enc.Hex.parse(v);var r=CryptoJS.enc.Utf8.parse(y);var u=i[q][\"keylen\"]+i[q][\"ivlen\"];var x=\"\";var w=null;for(;;){var s=CryptoJS.algo.MD5.create();if(w!=null){s.update(w)}s.update(r);s.update(t);w=s.finalize();x=x+CryptoJS.enc.Hex.stringify(w);if(x.length>=u*2){break}}var z={};z.keyhex=x.substr(0,i[q][\"keylen\"]*2);z.ivhex=x.substr(i[q][\"keylen\"]*2,i[q][\"ivlen\"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v][\"proc\"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s][\"eproc\"];var t=r(p,q,u);return t};return{version:\"1.0.0\",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p=\"\";if(typeof t==\"undefined\"||t==null){t=\"AES-256-CBC\"}if(typeof i[t]==\"undefined\"){throw\"KEYUTIL unsupported algorithm: \"+t}if(typeof r==\"undefined\"||r==null){var v=i[t][\"ivlen\"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,\"$1\\r\\n\");var p=\"-----BEGIN \"+x+\" PRIVATE KEY-----\\r\\n\";p+=\"Proc-Type: 4,ENCRYPTED\\r\\n\";p+=\"DEK-Info: \"+t+\",\"+r+\"\\r\\n\";p+=\"\\r\\n\";p+=q;p+=\"\\r\\n-----END \"+x+\" PRIVATE KEY-----\\r\\n\";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw\"malformed format: SEQUENCE(0).items != 2: \"+r.length}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0).items != 2: \"+A.length}if(w(y,A[0])!=\"2a864886f70d01050d\"){throw\"this only supports pkcs5PBES2\"}var p=z(y,A[1]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0.1).items != 2: \"+p.length}var q=z(y,p[1]);if(q.length!=2){throw\"malformed format: SEQUENCE(0.0.1.1).items != 2: \"+q.length}if(w(y,q[0])!=\"2a864886f70d0307\"){throw\"this only supports TripleDES\"}t.encryptionSchemeAlg=\"TripleDES\";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw\"malformed format: SEQUENCE(0.0.1.0).items != 2: \"+s.length}if(w(y,s[0])!=\"2a864886f70d01050c\"){throw\"this only supports pkcs5PBKDF2\"}var x=z(y,s[1]);if(x.length<2){throw\"malformed format: SEQUENCE(0.0.1.0.1).items < 2: \"+x.length}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw\"malformed format pbkdf2Iter: \"+u}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,\"ENCRYPTED PRIVATE KEY\");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!=\"30\"){throw\"malformed plain PKCS8 private key(code:001)\"}var r=u(s,0);if(r.length!=3){throw\"malformed plain PKCS8 private key(code:002)\"}if(s.substr(r[1],2)!=\"30\"){throw\"malformed PKCS8 private key(code:003)\"}var p=u(s,r[1]);if(p.length!=2){throw\"malformed PKCS8 private key(code:004)\"}if(s.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 private key(code:005)\"}q.algoid=t(s,p[0]);if(s.substr(p[1],2)==\"06\"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!=\"04\"){throw\"malformed PKCS8 private key(code:006)\"}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,\"PRIVATE KEY\");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid==\"2a864886f70d010101\"){r=new RSAKey()}else{if(q.algoid==\"2a8648ce380401\"){r=new KJUR.crypto.DSA()}else{if(q.algoid==\"2a8648ce3d0201\"){r=new KJUR.crypto.ECDSA()}else{throw\"unsupported private key algorithm\"}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],\"06\");if(r===\"2a864886f70d010101\"){p=new RSAKey()}else{if(r===\"2a8648ce380401\"){p=new KJUR.crypto.DSA()}else{if(r===\"2a8648ce3d0201\"){p=new KJUR.crypto.ECDSA()}else{throw\"unsupported PKCS#8 public key hex\"}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!=\"30\"){throw\"malformed RSA key(code:001)\"}var q=t(r,0);if(q.length!=2){throw\"malformed RSA key(code:002)\"}if(r.substr(q[0],2)!=\"02\"){throw\"malformed RSA key(code:003)\"}p.n=s(r,q[0]);if(r.substr(q[1],2)!=\"02\"){throw\"malformed RSA key(code:004)\"}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw\"outer DERSequence shall have 2 elements: \"+r.length}var w=r[0];if(t.substr(w,2)!=\"30\"){throw\"malformed PKCS8 public key(code:001)\"}var p=u(t,w);if(p.length!=2){throw\"malformed PKCS8 public key(code:002)\"}if(t.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 public key(code:003)\"}q.algoid=s(t,p[0]);if(t.substr(p[1],2)==\"06\"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)==\"30\"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],\"02\");q.algparam.q=v.getVbyList(t,p[1],[1],\"02\");q.algparam.g=v.getVbyList(t,p[1],[2],\"02\")}}if(t.substr(r[1],2)!=\"03\"){throw\"malformed PKCS8 public key(code:004)\"}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!=\"undefined\"&&l instanceof w){return l}if(typeof i!=\"undefined\"&&l instanceof i){return l}if(typeof C!=\"undefined\"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;j.setPublicKeyHex(u);return j}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;var b=(\"0000000000\"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n===\"pkcs5prv\"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)===\"04\"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw\"unsupported PKCS#1/5 hexadecimal key\"}}}return P}if(n===\"pkcs8prv\"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n===\"pkcs8pub\"){return F._getKeyFromPublicPKCS8Hex(l)}if(n===\"x509pub\"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf(\"-END CERTIFICATE-\",0)!=-1||l.indexOf(\"-END X509 CERTIFICATE-\",0)!=-1||l.indexOf(\"-END TRUSTED CERTIFICATE-\",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf(\"-END PUBLIC KEY-\")!=-1){var O=pemtohex(l,\"PUBLIC KEY\");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var m=M(l,\"RSA PRIVATE KEY\");return F.getKey(m,null,\"pkcs5prv\")}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var I=M(l,\"DSA PRIVATE KEY\");var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END PRIVATE KEY-\")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf(\"-END EC PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],\"04\");var f=d(I,0,[2,0],\"06\");var A=d(I,0,[3,0],\"03\").substr(2);var e=\"\";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw\"undefined OID(hex) in KJUR.crypto.OID: \"+f}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END ENCRYPTED PRIVATE KEY-\")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw\"not supported argument\"};KEYUTIL.generateKeypair=function(a,c){if(a==\"RSA\"){var b=c;var h=new RSAKey();h.generate(b,\"10001\");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a==\"EC\"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw\"unknown algorithm: \"+a}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.n}},{\"int\":s.e},{\"int\":{bigint:s.d}},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.dmp1}},{\"int\":{bigint:s.dmq1}},{\"int\":{bigint:s.coeff}}]});return G}function B(G){var s=l({seq:[{\"int\":1},{octstr:{hex:G.prvKeyHex}},{tag:[\"a0\",true,{oid:{name:G.curveName}}]},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+G.pubKeyHex}}]}]});return s}function x(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.g}},{\"int\":{bigint:s.y}},{\"int\":{bigint:s.x}}]});return G}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D==\"PKCS8PUB\")){var E=new C(b);var w=E.getEncodedHex();return hextopem(w,\"PUBLIC KEY\")}if(D==\"PKCS1PRV\"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();return hextopem(w,\"RSA PRIVATE KEY\")}if(D==\"PKCS1PRV\"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.getEncodedHex();var h=B(b);var t=h.getEncodedHex();var p=\"\";p+=hextopem(v,\"EC PARAMETERS\");p+=hextopem(t,\"EC PRIVATE KEY\");return p}if(D==\"PKCS1PRV\"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();return hextopem(w,\"DSA PRIVATE KEY\")}if(D==\"PKCS5PRV\"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"RSA\",w,y,m,j)}if(D==\"PKCS5PRV\"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"EC\",w,y,m,j)}if(D==\"PKCS5PRV\"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"DSA\",w,y,m,j)}var o=function(G,s){var I=c(G,s);var H=new l({seq:[{seq:[{oid:{name:\"pkcs5PBES2\"}},{seq:[{seq:[{oid:{name:\"pkcs5PBKDF2\"}},{seq:[{octstr:{hex:I.pbkdf2Salt}},{\"int\":I.pbkdf2Iter}]}]},{seq:[{oid:{name:\"des-EDE3-CBC\"}},{octstr:{hex:I.encryptionSchemeIV}}]}]}]},{octstr:{hex:I.ciphertext}}]});return H.getEncodedHex()};var c=function(N,O){var H=100;var M=CryptoJS.lib.WordArray.random(8);var L=\"DES-EDE3-CBC\";var s=CryptoJS.lib.WordArray.random(8);var I=CryptoJS.PBKDF2(O,M,{keySize:192/32,iterations:H});var J=CryptoJS.enc.Hex.parse(N);var K=CryptoJS.TripleDES.encrypt(J,I,{iv:s})+\"\";var G={};G.ciphertext=K;G.pbkdf2Salt=CryptoJS.enc.Hex.stringify(M);G.pbkdf2Iter=H;G.encryptionSchemeAlg=L;G.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return G};if(D==\"PKCS8PRV\"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"rsaEncryption\"}},{\"null\":true}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var g=new l({seq:[{\"int\":1},{octstr:{hex:b.prvKeyHex}},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+b.pubKeyHex}}]}]});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"ecPublicKey\"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"dsa\"}},{seq:[{\"int\":{bigint:b.p}},{\"int\":{bigint:b.q}},{\"int\":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}throw\"unsupported object nor format\"};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,\"CERTIFICATE REQUEST\");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,\"pkcs8pub\");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!=\"30\"){throw\"malformed CSR(code:001)\"}var e=f(g,0);if(e.length<1){throw\"malformed CSR(code:002)\"}if(g.substr(e[0],2)!=\"30\"){throw\"malformed CSR(code:003)\"}var a=f(g,e[0]);if(a.length<3){throw\"malformed CSR(code:004)\"}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getJWKFromKey=function(d){var b={};if(d instanceof RSAKey&&d.isPrivate){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));b.d=hextob64u(d.d.toString(16));b.p=hextob64u(d.p.toString(16));b.q=hextob64u(d.q.toString(16));b.dp=hextob64u(d.dmp1.toString(16));b.dq=hextob64u(d.dmq1.toString(16));b.qi=hextob64u(d.coeff.toString(16));return b}else{if(d instanceof RSAKey&&d.isPublic){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPrivate){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);b.d=hextob64u(d.prvKeyHex);return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPublic){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);return b}}}}throw\"not supported key object\"};\nRSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,j,l,b,a,f,d,k;var m=ASN1HEX;var g=m.getVbyList;if(m.isASN1HEX(e)===false){throw\"not ASN.1 hex string\"}try{c=g(e,0,[2,0,1],\"02\");j=g(e,0,[2,0,2],\"02\");l=g(e,0,[2,0,3],\"02\");b=g(e,0,[2,0,4],\"02\");a=g(e,0,[2,0,5],\"02\");f=g(e,0,[2,0,6],\"02\");d=g(e,0,[2,0,7],\"02\");k=g(e,0,[2,0,8],\"02\")}catch(i){throw\"malformed PKCS#8 plain RSA private key\"}this.setPrivateEx(c,j,l,b,a,f,d,k)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw\"keyHex is not ASN.1 hex string\"}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!==\"02\"||c.substr(a[1],2)!==\"02\"){throw\"wrong hex for PKCS#5 public key\"}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw\"not ASN.1 hex string\"}if(c.getTLVbyList(b,0,[0,0])!==\"06092a864886f70d010101\"){throw\"not PKCS8 RSA public key\"}var a=c.getTLVbyList(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)};\nvar _RE_HEXDECONLY=new RegExp(\"\");_RE_HEXDECONLY.compile(\"[^0-9a-f]\",\"gi\");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c=\"\";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw\"invalid salt length\"}}}if(c<(g+k+2)){throw\"data too long\"}var f=\"\";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dthis.n.bitLength()){return 0}var i=this.doPublic(b);var e=i.toString(16).replace(/^1f+00/,\"\");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(k){return KJUR.crypto.Util.hashString(k,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){a=a.replace(_RE_HEXDECONLY,\"\");a=a.replace(/[ \\n]+/g,\"\");var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,\"\");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){var k=new BigInteger(s,16);if(k.bitLength()>this.n.bitLength()){return false}var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw\"invalid salt length\"}}}if(m<(h+c+2)){throw\"data too long\"}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw\"bits beyond keysize not zero\"}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q0){var b=\":\"+n.join(\":\")+\":\";if(b.indexOf(\":\"+k+\":\")==-1){throw\"algorithm '\"+k+\"' not accepted in the list\"}}if(k!=\"none\"&&B===null){throw\"key shall be specified to verify.\"}if(typeof B==\"string\"&&B.indexOf(\"-----BEGIN \")!=-1){B=KEYUTIL.getKey(B)}if(z==\"RS\"||z==\"PS\"){if(!(B instanceof m)){throw\"key shall be a RSAKey obj for RS* and PS* algs\"}}if(z==\"ES\"){if(!(B instanceof p)){throw\"key shall be a ECDSA obj for ES* algs\"}}if(k==\"none\"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw\"unsupported alg name: \"+k}else{u=t.jwsalg2sigalg[k]}if(u==\"none\"){throw\"not supported\"}else{if(u.substr(0,4)==\"Hmac\"){var o=null;if(B===undefined){throw\"hexadecimal key shall be specified for HMAC\"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf(\"withECDSA\")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(\".\");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw\"malformed sJWS: wrong number of '.' splitted elements\"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null,\" \");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null,\" \")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;var k=e.split(\".\");var c=k[0];var i=k[1];var q=c+\".\"+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw\"acceptField.alg shall be specified\"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss===\"object\"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub===\"object\"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud===\"object\"){if(typeof g.aud==\"string\"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud==\"object\"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt===\"number\"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!==\"number\"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp==\"number\"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw\"addSignature failed: \"+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw\"malformed header\"}if(typeof g.payload===\"string\"){this.sPayload=g.payload}else{throw\"malformed signatures\"}if(g.signatures.length>0){this.aSignatures=g.signatures}else{throw\"malformed signatures\"}}catch(e){throw\"malformed JWS-JS JSON object: \"+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}};\nexports.SecureRandom = SecureRandom;\nexports.rng_seed_time = rng_seed_time;\n\nexports.BigInteger = BigInteger;\nexports.RSAKey = RSAKey;\nexports.ECDSA = KJUR.crypto.ECDSA;\nexports.DSA = KJUR.crypto.DSA;\nexports.Signature = KJUR.crypto.Signature;\nexports.MessageDigest = KJUR.crypto.MessageDigest;\nexports.Mac = KJUR.crypto.Mac;\nexports.Cipher = KJUR.crypto.Cipher;\nexports.KEYUTIL = KEYUTIL;\nexports.ASN1HEX = ASN1HEX;\nexports.X509 = X509;\nexports.CryptoJS = CryptoJS;\n\n// ext/base64.js\nexports.b64tohex = b64tohex;\nexports.b64toBA = b64toBA;\n\n// base64x.js\nexports.stoBA = stoBA;\nexports.BAtos = BAtos;\nexports.BAtohex = BAtohex;\nexports.stohex = stohex;\nexports.stob64 = stob64;\nexports.stob64u = stob64u;\nexports.b64utos = b64utos;\nexports.b64tob64u = b64tob64u;\nexports.b64utob64 = b64utob64;\nexports.hex2b64 = hex2b64;\nexports.hextob64u = hextob64u;\nexports.b64utohex = b64utohex;\nexports.utf8tob64u = utf8tob64u;\nexports.b64utoutf8 = b64utoutf8;\nexports.utf8tob64 = utf8tob64;\nexports.b64toutf8 = b64toutf8;\nexports.utf8tohex = utf8tohex;\nexports.hextoutf8 = hextoutf8;\nexports.hextorstr = hextorstr;\nexports.rstrtohex = rstrtohex;\nexports.hextob64 = hextob64;\nexports.hextob64nl = hextob64nl;\nexports.b64nltohex = b64nltohex;\nexports.hextopem = hextopem;\nexports.pemtohex = pemtohex;\nexports.hextoArrayBuffer = hextoArrayBuffer;\nexports.ArrayBuffertohex = ArrayBuffertohex;\nexports.zulutomsec = zulutomsec;\nexports.zulutosec = zulutosec;\nexports.zulutodate = zulutodate;\nexports.datetozulu = datetozulu;\nexports.uricmptohex = uricmptohex;\nexports.hextouricmp = hextouricmp;\nexports.ipv6tohex = ipv6tohex;\nexports.hextoipv6 = hextoipv6;\nexports.hextoip = hextoip;\nexports.iptohex = iptohex;\nexports.encodeURIComponentAll = encodeURIComponentAll;\nexports.newline_toUnix = newline_toUnix;\nexports.newline_toDos = newline_toDos;\nexports.hextoposhex = hextoposhex;\nexports.intarystrtohex = intarystrtohex;\nexports.strdiffidx = strdiffidx;\n\n// name spaces\nexports.KJUR = KJUR;\nexports.crypto = KJUR.crypto;\nexports.asn1 = KJUR.asn1;\nexports.jws = KJUR.jws;\nexports.lang = KJUR.lang;\n\n\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://AppID/./node_modules/jsrsasign/lib/jsrsasign.js?"); + +/***/ }), + +/***/ "./node_modules/node-fetch/browser.js": +/*!********************************************!*\ + !*** ./node_modules/node-fetch/browser.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n// ref: https://github.com/tc39/proposal-global\nvar getGlobal = function () {\n\t// the only reliable means to get the global object is\n\t// `Function('return this')()`\n\t// However, this causes CSP violations in Chrome apps.\n\tif (typeof self !== 'undefined') { return self; }\n\tif (typeof window !== 'undefined') { return window; }\n\tif (typeof global !== 'undefined') { return global; }\n\tthrow new Error('unable to locate global object');\n}\n\nvar global = getGlobal();\n\nmodule.exports = exports = global.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = global.fetch.bind(global);\n\nexports.Headers = global.Headers;\nexports.Request = global.Request;\nexports.Response = global.Response;\n\n//# sourceURL=webpack://AppID/./node_modules/node-fetch/browser.js?"); + +/***/ }), + +/***/ "./node_modules/webpack/buildin/global.js": +/*!***********************************!*\ + !*** (webpack)/buildin/global.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://AppID/(webpack)/buildin/global.js?"); + +/***/ }), + +/***/ "./package.json": +/*!**********************!*\ + !*** ./package.json ***! + \**********************/ +/*! exports provided: name, version, description, scripts, repository, main, nyc, dependencies, devDependencies, default */ +/***/ (function(module) { + +eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"ibmcloud-appid-js\\\",\\\"version\\\":\\\"0.0.2\\\",\\\"description\\\":\\\"IBM Cloud App ID SDK for Single Page Applications\\\",\\\"scripts\\\":{\\\"build\\\":\\\"webpack --mode=development\\\",\\\"test\\\":\\\"mocha\\\",\\\"coverage\\\":\\\"nyc --reporter=lcov mocha\\\",\\\"docs\\\":\\\"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json\\\"},\\\"repository\\\":{\\\"type\\\":\\\"git\\\",\\\"url\\\":\\\"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git\\\"},\\\"main\\\":\\\"dist/appid.umd.min.js\\\",\\\"nyc\\\":{\\\"all\\\":true,\\\"include\\\":[\\\"src/*.js\\\"],\\\"exclude\\\":[\\\"**/PopupController.js\\\",\\\"**/IFrameController.js\\\",\\\"**/OpenIDConfigurationResource.js\\\",\\\"**/constants.js\\\"]},\\\"dependencies\\\":{\\\"jsrsasign\\\":\\\"^8.0.12\\\"},\\\"devDependencies\\\":{\\\"node-fetch\\\":\\\"^2.6.0\\\",\\\"@babel/cli\\\":\\\"^7.0.0\\\",\\\"@babel/core\\\":\\\"^7.5.5\\\",\\\"@babel/plugin-transform-runtime\\\":\\\"^7.5.5\\\",\\\"@babel/preset-env\\\":\\\"^7.5.5\\\",\\\"babel-cli\\\":\\\"^7.0.0-beta.3\\\",\\\"chai\\\":\\\"^4.2.0\\\",\\\"coveralls\\\":\\\"^3.0.6\\\",\\\"gulp-babel\\\":\\\"^8.0.0\\\",\\\"mocha\\\":\\\"^6.2.0\\\",\\\"nyc\\\":\\\"^14.1.1\\\",\\\"webpack\\\":\\\"^4.39.1\\\",\\\"webpack-cli\\\":\\\"^3.3.6\\\",\\\"docdash\\\":\\\"^1.1.1\\\",\\\"jsdoc\\\":\\\"^3.6.3\\\"}}\");\n\n//# sourceURL=webpack://AppID/./package.json?"); + +/***/ }), + +/***/ "./src/IFrameController.js": +/*!*********************************!*\ + !*** ./src/IFrameController.js ***! + \*********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const IFrameError = __webpack_require__(/*! ./errors/IFrameError */ \"./src/errors/IFrameError.js\");\n\nclass IFrameController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t}\n\n\topen(url) {\n\t\tthis.iFrame = this.window.document.createElement('iframe');\n\t\tthis.iFrame.src = url;\n\t\tthis.iFrame.width = 0;\n\t\tthis.iFrame.height = 0;\n\t\tthis.window.document.body.appendChild(this.iFrame);\n\t}\n\n\tremove() {\n\t\twindow.document.body.removeChild(this.iFrame);\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\treject(new IFrameError('Silent sign-in timed out'));\n\t\t\t}, 5 * 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tclearInterval(timer);\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = IFrameController;\n\n\n//# sourceURL=webpack://AppID/./src/IFrameController.js?"); + +/***/ }), + +/***/ "./src/OpenIDConfigurationResource.js": +/*!********************************************!*\ + !*** ./src/OpenIDConfigurationResource.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const packagejson = __webpack_require__(/*! ../package.json */ \"./package.json\");\n\nclass OpenIdConfigurationResource {\n\tasync init({discoveryEndpoint, requestHandler}){\n\t\tthis.openIdConfig = await requestHandler(discoveryEndpoint);\n\t\tconst headers = { 'x-filter-type': `spa:v${packagejson.version}` };\n\t\tthis.publicKeys = requestHandler(this.getJwksEndpoint(), { headers: headers });\n\t}\n\n\tgetAuthorizationEndpoint() {\n\t\treturn this.openIdConfig.authorization_endpoint;\n\t}\n\n\tgetUserInfoEndpoint() {\n\t\treturn this.openIdConfig.userinfo_endpoint;\n\t}\n\n\tgetJwksEndpoint() {\n\t\treturn this.openIdConfig.jwks_uri;\n\t}\n\n\tgetTokenEndpoint() {\n\t\treturn this.openIdConfig.token_endpoint;\n\t}\n\n\tgetIssuer() {\n\t\treturn this.openIdConfig.issuer;\n\t}\n\n\tasync getPublicKeys() {\n\t\treturn await this.publicKeys;\n\t}\n}\nmodule.exports = OpenIdConfigurationResource;\n\n\n\n//# sourceURL=webpack://AppID/./src/OpenIDConfigurationResource.js?"); + +/***/ }), + +/***/ "./src/PopupController.js": +/*!********************************!*\ + !*** ./src/PopupController.js ***! + \********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const PopupError = __webpack_require__(/*! ./errors/PopupError */ \"./src/errors/PopupError.js\");\n\nclass PopupController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t};\n\n\tinit(popupConfig){\n\t\tthis.popupConfig = popupConfig;\n\t}\n\n\topen() {\n\t\tconst h = this.popupConfig.height;\n\t\tconst w = this.popupConfig.width;\n\t\tconst left = (window.screen.width - w) / 2;\n\t\tconst top = (window.screen.height - h) / 2;\n\t\tthis.popup = this.window.open('', 'popup', `left=${left},top=${top},width=${w},height=${h},resizable,scrollbars=yes,status=1`);\n\t\tif (!this.popup) {\n\t\t\tthrow new PopupError('Unable to open popup')\n\t\t}\n\t};\n\n\tnavigate(url) {\n\t\tthis.popup.location.href = url;\n\t};\n\n\tclose() {\n\t\tthis.popup.close();\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\tif(this.popup.closed) {\n\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\treject(new PopupError('Popup closed'));\n\t\t\t\t}\n\t\t\t}, 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = PopupController;\n\n\n//# sourceURL=webpack://AppID/./src/PopupController.js?"); + +/***/ }), + +/***/ "./src/RequestHandler.js": +/*!*******************************!*\ + !*** ./src/RequestHandler.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t}\n\t\t\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tif (text !== '') {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); + +/***/ }), + +/***/ "./src/TokenValidator.js": +/*!*******************************!*\ + !*** ./src/TokenValidator.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg:[constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif (decoded.payloadObj.nonce && decoded.payloadObj.nonce !== nonce) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor(let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); + +/***/ }), + +/***/ "./src/constants.js": +/*!**************************!*\ + !*** ./src/constants.js ***! + \**************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN_PAYLOAD: 'Expect id token payload object to have identities field',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN_PAYLOAD: 'Missing id token payload',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tGENERATE_CODE: '/cloud_directory/generate_code',\n\tCHANGE_DETAILS: '/cloud_directory/change_details',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); + +/***/ }), + +/***/ "./src/errors/AppIDError.js": +/*!**********************************!*\ + !*** ./src/errors/AppIDError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class AppIDError extends Error {}\nmodule.exports = AppIDError;\n\n//# sourceURL=webpack://AppID/./src/errors/AppIDError.js?"); + +/***/ }), + +/***/ "./src/errors/IFrameError.js": +/*!***********************************!*\ + !*** ./src/errors/IFrameError.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class IFrameError extends Error {}\nmodule.exports = IFrameError;\n\n//# sourceURL=webpack://AppID/./src/errors/IFrameError.js?"); + +/***/ }), + +/***/ "./src/errors/OAuthError.js": +/*!**********************************!*\ + !*** ./src/errors/OAuthError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class OAuthError extends Error {\n\t// See https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for the possible error messages\n\tconstructor({error, description}) {\n\t\tsuper(description || error);\n\t\tthis.error = error;\n\t\tthis.description = description;\n\t}\n}\nmodule.exports = OAuthError;\n\n//# sourceURL=webpack://AppID/./src/errors/OAuthError.js?"); + +/***/ }), + +/***/ "./src/errors/PopupError.js": +/*!**********************************!*\ + !*** ./src/errors/PopupError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class PopupError extends Error {}\nmodule.exports = PopupError;\n\n//# sourceURL=webpack://AppID/./src/errors/PopupError.js?"); + +/***/ }), + +/***/ "./src/errors/RequestError.js": +/*!************************************!*\ + !*** ./src/errors/RequestError.js ***! + \************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class RequestError extends Error {\n\tconstructor(description, status, originError) {\n\t\tsuper(description);\n\t\tthis.status = status;\n\t\tthis.originError = originError;\n\t}\n}\nmodule.exports = RequestError;\n\n//# sourceURL=webpack://AppID/./src/errors/RequestError.js?"); + +/***/ }), + +/***/ "./src/errors/TokenError.js": +/*!**********************************!*\ + !*** ./src/errors/TokenError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class TokenError extends Error {}\nmodule.exports = TokenError;\n\n//# sourceURL=webpack://AppID/./src/errors/TokenError.js?"); + +/***/ }), + +/***/ "./src/index.js": +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in will attempt to authenticate the user in a hidden iframe.\n\t * You will need to enable Cloud Directory SSO.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * @param {string} idTokenPayload The id token payload.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token payload\"\n\t * @example\n\t * let tokens = await appID.changePassword(idTokenPayload);\n\t */\n\tasync changePassword(idTokenPayload) {\n\t\tthis._validateInitalize();\n\t\tlet userId;\n\n\t\tif (!idTokenPayload) {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN_PAYLOAD);\n\t\t}\n\t\tif (typeof idTokenPayload === 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN_PAYLOAD);\n\t\t}\n\t\tif (idTokenPayload.identities && idTokenPayload.identities[0] && idTokenPayload.identities[0].id) {\n\t\t\tif (idTokenPayload.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = idTokenPayload.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN_PAYLOAD);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\tasync changeDetails(tokens) {\n\t\t// get code\n\t\tconst generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE;\n\t\tconsole.log(generateCodeUrl);\n\t\tconst changeDetailsCode = await this.request(generateCodeUrl, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + tokens.accessToken + ' ' + tokens.idToken\n\t\t\t}\n\t\t});\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS;\n\n\t\t// send code with url\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint,\n\t\t\tchangeDetailsCode\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); + +/***/ }), + +/***/ "./src/utils.js": +/*!**********************!*\ + !*** ./src/utils.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId, changeDetailsCode}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tif (changeDetailsCode) {\n\t\t\tauthParams.code = changeDetailsCode;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint, changeDetailsCode}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint, changeDetailsCode});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); + +/***/ }) + +/******/ }); \ No newline at end of file diff --git a/dist/appid.umd.min.js b/dist/appid.umd.min.js index 4206c23..7090f1a 100644 --- a/dist/appid.umd.min.js +++ b/dist/appid.umd.min.js @@ -1,50 +1,345 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.AppID=e():t.AppID=e()}(window,(function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=4)}([function(t,e,i){(function(t){var i={userAgent:!1},n={}; -/*! -Copyright (c) 2011, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.9.0 -*/ -if(void 0===r)var r={};r.lang={extend:function(t,e,n){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),n){var s;for(s in n)t.prototype[s]=n[s];var o=function(){},a=["toString","valueOf"];try{/MSIE/.test(i.userAgent)&&(o=function(t,e){for(s=0;s>>2]>>>24-s%4*8&255;e[n+s>>>2]|=o<<24-(n+s)%4*8}else for(s=0;s>>2]=i[s>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=s.ceil(e/4)},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i>>2]>>>24-r%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new u.init(i,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,i=t.sigBytes,n=[],r=0;r>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new u.init(i,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},g=a.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,n=e.sigBytes,r=this.blockSize,o=n/(4*r),a=(o=t?s.ceil(o):s.max((0|o)-this._minBufferSize,0))*r,h=s.min(4*a,n);if(a){for(var c=0;c>>2]}},e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:h,padding:c}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(h=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?n.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=n.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:i})}},e.SerializableCipher=i.extend({cfg:i.extend({format:h}),encrypt:function(t,e,i,n){n=this.cfg.extend(n);var r=t.createEncryptor(i,n);return e=r.finalize(e),r=r.cfg,l.create({ciphertext:e,key:i,iv:r.iv,algorithm:t,mode:r.mode,padding:r.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(i,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,i,r){return r||(r=n.random(8)),t=o.create({keySize:e+i}).compute(t,r),i=n.create(t.words.slice(e),4*i),t.sigBytes=4*e,l.create({key:t,iv:i,salt:r})}},g=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:d}),encrypt:function(t,e,i,n){return i=(n=this.cfg.extend(n)).kdf.execute(i,t.keySize,t.ivSize),n.iv=i.iv,(t=f.encrypt.call(this,t,e,i.key,n)).mixIn(i),t},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),i=n.kdf.execute(i,t.keySize,t.ivSize,e.salt),n.iv=i.iv,f.decrypt.call(this,t,e,i.key,n)}})}(),function(){for(var t=y,e=t.lib.BlockCipher,i=t.algo,n=[],r=[],s=[],o=[],a=[],h=[],u=[],c=[],l=[],f=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var p=0,v=0;for(g=0;256>g;g++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;n[p]=m,r[m]=p;var S=d[p],F=d[S],w=d[F],E=257*d[m]^16843008*m;s[p]=E<<24|E>>>8,o[p]=E<<16|E>>>16,a[p]=E<<8|E>>>24,h[p]=E,E=16843009*w^65537*F^257*S^16843008*p,u[m]=E<<24|E>>>8,c[m]=E<<16|E>>>16,l[m]=E<<8|E>>>24,f[m]=E,p?(p=S^d[d[d[w^S]]],v^=d[d[v]]):p=v=1}var x=[0,1,2,4,8,16,32,64,128,27,54];i=i.AES=e.extend({_doReset:function(){for(var t=(i=this._key).words,e=i.sigBytes/4,i=4*((this._nRounds=e+6)+1),r=this._keySchedule=[],s=0;s>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o]):(o=n[(o=o<<8|o>>>24)>>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o],o^=x[s/e|0]<<24),r[s]=r[s-e]^o}for(t=this._invKeySchedule=[],e=0;ee||4>=s?o:u[n[o>>>24]]^c[n[o>>>16&255]]^l[n[o>>>8&255]]^f[n[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,o,a,h,n)},decryptBlock:function(t,e){var i=t[e+1];t[e+1]=t[e+3],t[e+3]=i,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,r),i=t[e+1],t[e+1]=t[e+3],t[e+3]=i},_doCryptBlock:function(t,e,i,n,r,s,o,a){for(var h=this._nRounds,u=t[e]^i[0],c=t[e+1]^i[1],l=t[e+2]^i[2],f=t[e+3]^i[3],d=4,g=1;g>>24]^r[c>>>16&255]^s[l>>>8&255]^o[255&f]^i[d++],y=n[c>>>24]^r[l>>>16&255]^s[f>>>8&255]^o[255&u]^i[d++],v=n[l>>>24]^r[f>>>16&255]^s[u>>>8&255]^o[255&c]^i[d++];f=n[f>>>24]^r[u>>>16&255]^s[c>>>8&255]^o[255&l]^i[d++],u=p,c=y,l=v}p=(a[u>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&f])^i[d++],y=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[f>>>8&255]<<8|a[255&u])^i[d++],v=(a[l>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[255&c])^i[d++],f=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^i[d++],t[e]=p,t[e+1]=y,t[e+2]=v,t[e+3]=f},keySize:8});t.AES=e._createHelper(i)}(),function(){function t(t,e){var i=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=i,this._lBlock^=i<>>t^this._lBlock)&e;this._lBlock^=i,this._rBlock^=i<i;i++){var n=o[i]-1;e[i]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;16>n;n++){var r=t[n]=[],s=h[n];for(i=0;24>i;i++)r[i/6|0]|=e[(a[i]-1+s)%28]<<31-i%6,r[4+(i/6|0)]|=e[28+(a[i+24]-1+s)%28]<<31-i%6;for(r[0]=r[0]<<1|r[0]>>>31,i=1;7>i;i++)r[i]>>>=4*(i-1)+3;r[7]=r[7]<<5|r[7]>>>27}for(e=this._invSubKeys=[],i=0;16>i;i++)e[i]=t[15-i]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(i,n,r){this._lBlock=i[n],this._rBlock=i[n+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var o=r[s],a=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^o[f])&c[f])>>>0];this._lBlock=h,this._rBlock=a^l}r=this._lBlock,this._lBlock=this._rBlock,this._rBlock=r,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),i[n]=this._lBlock,i[n+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});i.DES=r._createHelper(l),s=s.TripleDES=r.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(n.create(t.slice(0,2))),this._des2=l.createEncryptor(n.create(t.slice(2,4))),this._des3=l.createEncryptor(n.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),i.TripleDES=r._createHelper(s)}(),function(){var t=y,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,i=t.sigBytes,n=this._map;t.clamp(),t=[];for(var r=0;r>>2]>>>24-r%4*8&255)<<16|(e[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|e[r+2>>>2]>>>24-(r+2)%4*8&255,o=0;4>o&&r+.75*o>>6*(3-o)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var i=t.length,n=this._map;(r=n.charAt(64))&&(-1!=(r=t.indexOf(r))&&(i=r));for(var r=[],s=0,o=0;o>>6-o%4*2;r[s>>>2]|=(a|h)<<24-s%4*8,s++}return e.create(r,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,i,n,r,s,o){return((t=t+(e&i|~e&n)+r+o)<>>32-s)+e}function i(t,e,i,n,r,s,o){return((t=t+(e&n|i&~n)+r+o)<>>32-s)+e}function n(t,e,i,n,r,s,o){return((t=t+(e^i^n)+r+o)<>>32-s)+e}function r(t,e,i,n,r,s,o){return((t=t+(i^(e|~n))+r+o)<>>32-s)+e}for(var s=y,o=(h=s.lib).WordArray,a=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var o=0;16>o;o++){var a=t[h=s+o];t[h]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var h=t[s+0],c=(a=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],d=t[s+5],g=t[s+6],p=t[s+7],y=t[s+8],v=t[s+9],m=t[s+10],S=t[s+11],F=t[s+12],w=t[s+13],E=t[s+14],x=t[s+15],A=e(A=o[0],C=o[1],I=o[2],b=o[3],h,7,u[0]),b=e(b,A,C,I,a,12,u[1]),I=e(I,b,A,C,c,17,u[2]),C=e(C,I,b,A,l,22,u[3]);A=e(A,C,I,b,f,7,u[4]),b=e(b,A,C,I,d,12,u[5]),I=e(I,b,A,C,g,17,u[6]),C=e(C,I,b,A,p,22,u[7]),A=e(A,C,I,b,y,7,u[8]),b=e(b,A,C,I,v,12,u[9]),I=e(I,b,A,C,m,17,u[10]),C=e(C,I,b,A,S,22,u[11]),A=e(A,C,I,b,F,7,u[12]),b=e(b,A,C,I,w,12,u[13]),I=e(I,b,A,C,E,17,u[14]),A=i(A,C=e(C,I,b,A,x,22,u[15]),I,b,a,5,u[16]),b=i(b,A,C,I,g,9,u[17]),I=i(I,b,A,C,S,14,u[18]),C=i(C,I,b,A,h,20,u[19]),A=i(A,C,I,b,d,5,u[20]),b=i(b,A,C,I,m,9,u[21]),I=i(I,b,A,C,x,14,u[22]),C=i(C,I,b,A,f,20,u[23]),A=i(A,C,I,b,v,5,u[24]),b=i(b,A,C,I,E,9,u[25]),I=i(I,b,A,C,l,14,u[26]),C=i(C,I,b,A,y,20,u[27]),A=i(A,C,I,b,w,5,u[28]),b=i(b,A,C,I,c,9,u[29]),I=i(I,b,A,C,p,14,u[30]),A=n(A,C=i(C,I,b,A,F,20,u[31]),I,b,d,4,u[32]),b=n(b,A,C,I,y,11,u[33]),I=n(I,b,A,C,S,16,u[34]),C=n(C,I,b,A,E,23,u[35]),A=n(A,C,I,b,a,4,u[36]),b=n(b,A,C,I,f,11,u[37]),I=n(I,b,A,C,p,16,u[38]),C=n(C,I,b,A,m,23,u[39]),A=n(A,C,I,b,w,4,u[40]),b=n(b,A,C,I,h,11,u[41]),I=n(I,b,A,C,l,16,u[42]),C=n(C,I,b,A,g,23,u[43]),A=n(A,C,I,b,v,4,u[44]),b=n(b,A,C,I,F,11,u[45]),I=n(I,b,A,C,x,16,u[46]),A=r(A,C=n(C,I,b,A,c,23,u[47]),I,b,h,6,u[48]),b=r(b,A,C,I,p,10,u[49]),I=r(I,b,A,C,E,15,u[50]),C=r(C,I,b,A,d,21,u[51]),A=r(A,C,I,b,F,6,u[52]),b=r(b,A,C,I,l,10,u[53]),I=r(I,b,A,C,m,15,u[54]),C=r(C,I,b,A,a,21,u[55]),A=r(A,C,I,b,y,6,u[56]),b=r(b,A,C,I,x,10,u[57]),I=r(I,b,A,C,g,15,u[58]),C=r(C,I,b,A,w,21,u[59]),A=r(A,C,I,b,f,6,u[60]),b=r(b,A,C,I,S,10,u[61]),I=r(I,b,A,C,c,15,u[62]),C=r(C,I,b,A,v,21,u[63]);o[0]=o[0]+A|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+b|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;i[r>>>5]|=128<<24-r%32;var s=t.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(i.length+1),this._process(),i=(e=this._hash).words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=a._createHelper(h),s.HmacMD5=a._createHmacHelper(h)}(Math),function(){var t=y,e=(r=t.lib).WordArray,i=r.Hasher,n=[],r=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=this._hash.words,r=i[0],s=i[1],o=i[2],a=i[3],h=i[4],u=0;80>u;u++){if(16>u)n[u]=0|t[e+u];else{var c=n[u-3]^n[u-8]^n[u-14]^n[u-16];n[u]=c<<1|c>>>31}c=(r<<5|r>>>27)+h+n[u],c=20>u?c+(1518500249+(s&o|~s&a)):40>u?c+(1859775393+(s^o^a)):60>u?c+((s&o|s&a|o&a)-1894007588):c+((s^o^a)-899497514),h=a,a=o,o=s<<30|s>>>2,s=r,r=c}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+o|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(i/4294967296),e[15+(n+64>>>9<<4)]=i,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=i._createHelper(r),t.HmacSHA1=i._createHmacHelper(r)}(),function(t){for(var e=y,i=(r=e.lib).WordArray,n=r.Hasher,r=e.algo,s=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=a(t.pow(h,.5))),o[u]=a(t.pow(h,1/3)),u++),h++}var d=[];r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(t,e){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],a=i[3],h=i[4],u=i[5],c=i[6],l=i[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var g=d[f-15],p=d[f-2];d[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[f-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[f-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+o[f]+d[f],p=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&r^n&s^r&s),l=c,c=u,u=h,h=a+g|0,a=s,s=r,r=n,n=g+p|0}i[0]=i[0]+n|0,i[1]=i[1]+r|0,i[2]=i[2]+s|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0,i[5]=i[5]+u|0,i[6]=i[6]+c|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return i[r>>>5]|=128<<24-r%32,i[14+(r+64>>>9<<4)]=t.floor(n/4294967296),i[15+(r+64>>>9<<4)]=n,e.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(r),e.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var t=y,e=t.lib.WordArray,i=(n=t.algo).SHA256,n=n.SHA224=i.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=i._createHelper(n),t.HmacSHA224=i._createHmacHelper(n)}(),function(){function t(){return n.create.apply(n,arguments)}for(var e=y,i=e.lib.Hasher,n=(s=e.x64).Word,r=s.WordArray,s=e.algo,o=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],a=[],h=0;80>h;h++)a[h]=t();s=s.SHA512=i.extend({_doReset:function(){this._hash=new r.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var i=(l=this._hash.words)[0],n=l[1],r=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=i.high,d=i.low,g=n.high,p=n.low,y=r.high,v=r.low,m=s.high,S=s.low,F=h.high,w=h.low,E=u.high,x=u.low,A=c.high,b=c.low,I=l.high,C=l.low,D=f,T=d,P=g,R=p,H=y,B=v,N=m,O=S,j=F,V=w,L=E,_=x,K=A,k=b,M=I,U=C,q=0;80>q;q++){var z=a[q];if(16>q)var Y=z.high=0|t[e+2*q],G=z.low=0|t[e+2*q+1];else{Y=((G=(Y=a[q-15]).high)>>>1|(J=Y.low)<<31)^(G>>>8|J<<24)^G>>>7;var J=(J>>>1|G<<31)^(J>>>8|G<<24)^(J>>>7|G<<25),W=((G=(W=a[q-2]).high)>>>19|(X=W.low)<<13)^(G<<3|X>>>29)^G>>>6,X=(X>>>19|G<<13)^(X<<3|G>>>29)^(X>>>6|G<<26),Z=(G=a[q-7]).high,$=(Q=a[q-16]).high,Q=Q.low;Y=(Y=(Y=Y+Z+((G=J+G.low)>>>0>>0?1:0))+W+((G=G+X)>>>0>>0?1:0))+$+((G=G+Q)>>>0>>0?1:0);z.high=Y,z.low=G}Z=j&L^~j&K,Q=V&_^~V&k,z=D&P^D&H^P&H;var tt=T&R^T&B^R&B,et=(J=(D>>>28|T<<4)^(D<<30|T>>>2)^(D<<25|T>>>7),W=(T>>>28|D<<4)^(T<<30|D>>>2)^(T<<25|D>>>7),(X=o[q]).high),it=X.low;$=M+((j>>>14|V<<18)^(j>>>18|V<<14)^(j<<23|V>>>9))+((X=U+((V>>>14|j<<18)^(V>>>18|j<<14)^(V<<23|j>>>9)))>>>0>>0?1:0),M=K,U=k,K=L,k=_,L=j,_=V,j=N+($=($=($=$+Z+((X=X+Q)>>>0>>0?1:0))+et+((X=X+it)>>>0>>0?1:0))+Y+((X=X+G)>>>0>>0?1:0))+((V=O+X|0)>>>0>>0?1:0)|0,N=H,O=B,H=P,B=R,P=D,R=T,D=$+(z=J+z+((G=W+tt)>>>0>>0?1:0))+((T=X+G|0)>>>0>>0?1:0)|0}d=i.low=d+T,i.high=f+D+(d>>>0>>0?1:0),p=n.low=p+R,n.high=g+P+(p>>>0>>0?1:0),v=r.low=v+B,r.high=y+H+(v>>>0>>0?1:0),S=s.low=S+O,s.high=m+N+(S>>>0>>0?1:0),w=h.low=w+V,h.high=F+j+(w>>>0>>0?1:0),x=u.low=x+_,u.high=E+L+(x>>>0<_>>>0?1:0),b=c.low=b+k,c.high=A+K+(b>>>0>>0?1:0),C=l.low=C+U,l.high=I+M+(C>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(i/4294967296),e[31+(n+128>>>10<<5)]=i,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=i._createHelper(s),e.HmacSHA512=i._createHmacHelper(s)}(),function(){var t=y,e=(r=t.x64).Word,i=r.WordArray,n=(r=t.algo).SHA512,r=r.SHA384=n.extend({_doReset:function(){this._hash=new i.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(r),t.HmacSHA384=n._createHmacHelper(r)}(),function(){var t=y,e=(n=t.lib).WordArray,i=n.Hasher,n=t.algo,r=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),o=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);n=n.RIPEMD160=i.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=0;16>i;i++){var n=t[F=e+i];t[F]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var c,l,f,d,g,p,y,v,m,S,F=this._hash.words,w=(n=h.words,u.words),E=r.words,x=s.words,A=o.words,b=a.words;p=c=F[0],y=l=F[1],v=f=F[2],m=d=F[3],S=g=F[4];var I;for(i=0;80>i;i+=1)I=c+t[e+E[i]]|0,I=16>i?I+((l^f^d)+n[0]):32>i?I+((l&f|~l&d)+n[1]):48>i?I+(((l|~f)^d)+n[2]):64>i?I+((l&d|f&~d)+n[3]):I+((l^(f|~d))+n[4]),I=(I=(I|=0)<>>32-A[i])+g|0,c=g,g=d,d=f<<10|f>>>22,f=l,l=I,I=p+t[e+x[i]]|0,I=16>i?I+((y^(v|~m))+w[0]):32>i?I+((y&m|v&~m)+w[1]):48>i?I+(((y|~v)^m)+w[2]):64>i?I+((y&v|~y&m)+w[3]):I+((y^v^m)+w[4]),I=(I=(I|=0)<>>32-b[i])+S|0,p=S,S=m,m=v<<10|v>>>22,v=y,y=I;I=F[1]+f+m|0,F[1]=F[2]+d+S|0,F[2]=F[3]+g+p|0,F[3]=F[4]+c+y|0,F[4]=F[0]+l+v|0,F[0]=I},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,i=0;5>i;i++)n=e[i],e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(n),t.HmacRIPEMD160=i._createHmacHelper(n)}(Math),function(){var t=y,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,i){t=this._hasher=new t.init,"string"==typeof i&&(i=e.parse(i));var n=t.blockSize,r=4*n;i.sigBytes>r&&(i=t.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),o=this._iKey=i.clone(),a=s.words,h=o.words,u=0;u>6)+m.charAt(63&i);if(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),n+=m.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),n+=m.charAt(i>>2)+m.charAt((3&i)<<4)),S)for(;(3&n.length)>0;)n+=S;return n}function w(t){var e,i,n,r="",s=0;for(e=0;e>2),i=3&n,s=1):1==s?(r+=T(i<<2|n>>4),i=15&n,s=2):2==s?(r+=T(i),r+=T(n>>2),i=3&n,s=3):(r+=T(i<<2|n>>4),r+=T(15&n),s=0));return 1==s&&(r+=T(i<<2)),r}function E(t){var e,i=w(t),n=new Array;for(e=0;2*e>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;r=((h=o*h+((32767&c)<<15)+i[n]+(1073741823&r))>>>30)+(c>>>15)+a*u+(r>>>30),i[n++]=1073741823&h}return r},v=30):"Netscape"!=i.appName?(x.prototype.am=function(t,e,i,n,r,s){for(;--s>=0;){var o=e*this[t++]+i[n]+r;r=Math.floor(o/67108864),i[n++]=67108863&o}return r},v=26):(x.prototype.am=function(t,e,i,n,r,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;r=((h=o*h+((16383&c)<<14)+i[n]+r)>>28)+(c>>14)+a*u,i[n++]=268435455&h}return r},v=28),x.prototype.DB=v,x.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function B(t){this.m=t}function N(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function K(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function k(){}function M(t){return t}function U(t){this.r2=A(),this.q3=A(),x.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}B.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},B.prototype.revert=function(t){return t},B.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},B.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},B.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},N.prototype.convert=function(t){var e=A();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(x.ZERO)>0&&this.m.subTo(e,e),e},N.prototype.revert=function(t){var e=A();return t.copyTo(e),this.reduce(e),e},N.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},N.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},N.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},x.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},x.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},x.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,r=!1,s=0;--n>=0;){var o=8==i?255&t[n]:P(t,n);o<0?"-"==t.charAt(n)&&(r=!0):(r=!1,0==s?this[this.t++]=o:s+i>this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},x.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},x.prototype.drShiftTo=function(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>r|a,a=(this[i]&s)<=0;--i)e[i]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},x.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,r=this.DB-n,s=(1<>n;for(var o=i+1;o>n;n>0&&(e[this.t-i-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},x.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),r=i.t;for(e.t=r+n.t;--r>=0;)e[r]=0;for(r=0;r=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},x.prototype.divRemTo=function(t,e,i){var n=t.abs();if(!(n.t<=0)){var r=this.abs();if(r.t0?(n.lShiftTo(h,s),r.lShiftTo(h,i)):(n.copyTo(s),r.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<1?s[u-2]>>this.F2:0),f=this.FV/l,d=(1<=0&&(i[i.t++]=1,i.subTo(v,i)),x.ONE.dlShiftTo(u,v),v.subTo(s,s);s.t=0;){var m=i[--p]==c?this.DM:Math.floor(i[p]*f+(i[p-1]+g)*d);if((i[p]+=s.am(0,m,i,y,0,u))0&&i.rShiftTo(h,i),o<0&&x.ZERO.subTo(i,i)}}},x.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},x.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},x.prototype.exp=function(t,e){if(t>4294967295||t<1)return x.ONE;var i=A(),n=A(),r=e.convert(this),s=H(t)-1;for(r.copyTo(i);--s>=0;)if(e.sqrTo(i,n),(t&1<0)e.mulTo(n,r,i);else{var o=i;i=n,n=o}return e.revert(i)},x.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<0)for(a>a)>0&&(r=!0,s=T(i));o>=0;)a>(a+=this.DB-e)):(i=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),i>0&&(r=!0),r&&(s+=T(i));return r?s:"0"},x.prototype.negate=function(){var t=A();return x.ZERO.subTo(this,t),t},x.prototype.abs=function(){return this.s<0?this.negate():this},x.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},x.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+H(this[this.t-1]^this.s&this.DM)},x.prototype.mod=function(t){var e=A();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(x.ZERO)>0&&t.subTo(e,e),e},x.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new B(e):new N(e),this.exp(t,i)},x.ZERO=R(0),x.ONE=R(1),k.prototype.convert=M,k.prototype.revert=M,k.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},k.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=A();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var q=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],z=(1<<26)/q[q.length-1]; -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function Y(){this.i=0,this.j=0,this.S=new Array}x.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},x.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),n=R(i),r=A(),s=A(),o="";for(this.divRemTo(n,r,s);r.signum()>0;)o=(i+s.intValue()).toString(t).substr(1)+o,r.divRemTo(n,r,s);return s.intValue().toString(t)+o},x.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),r=!1,s=0,o=0,a=0;a=i&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),r&&x.ZERO.subTo(this,this)},x.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(x.ONE.shiftLeft(t-1),j,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(x.ONE.shiftLeft(t-1),this);else{var n=new Array,r=7&t;n.length=1+(t>>3),e.nextBytes(n),r>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},x.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},x.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},x.prototype.multiplyLowerTo=function(t,e,i){var n,r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r=0;)i[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},x.prototype.millerRabin=function(t){var e=this.subtract(x.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var n=e.shiftRight(i);(t=t+1>>1)>q.length&&(t=q.length);for(var r=A(),s=0;s>24},x.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},x.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},x.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,r=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[r++]=i|this.s<=0;)n<8?(i=(this[t]&(1<>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(e[r++]=i);return e},x.prototype.equals=function(t){return 0==this.compareTo(t)},x.prototype.min=function(t){return this.compareTo(t)<0?this:t},x.prototype.max=function(t){return this.compareTo(t)>0?this:t},x.prototype.and=function(t){var e=A();return this.bitwiseTo(t,O,e),e},x.prototype.or=function(t){var e=A();return this.bitwiseTo(t,j,e),e},x.prototype.xor=function(t){var e=A();return this.bitwiseTo(t,V,e),e},x.prototype.andNot=function(t){var e=A();return this.bitwiseTo(t,L,e),e},x.prototype.not=function(){for(var t=A(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var c=A();for(n.sqrTo(o[1],c);a<=u;)o[a]=A(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,d=t.t-1,g=!0,p=A();for(r=H(t[d])-1;d>=0;){for(r>=h?l=t[d]>>r-h&u:(l=(t[d]&(1<0&&(l|=t[d-1]>>this.DB+r-h)),a=i;0==(1&l);)l>>=1,--a;if((r-=a)<0&&(r+=this.DB,--d),g)o[l].copyTo(s),g=!1;else{for(;a>1;)n.sqrTo(s,p),n.sqrTo(p,s),a-=2;a>0?n.sqrTo(s,p):(f=s,s=p,p=f),n.mulTo(p,o[l],s)}for(;d>=0&&0==(t[d]&1<=0?(i.subTo(n,i),e&&r.subTo(o,r),s.subTo(a,s)):(n.subTo(i,n),e&&o.subTo(r,o),a.subTo(s,a))}return 0!=n.compareTo(x.ONE)?x.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},x.prototype.pow=function(t){return this.exp(t,new k)},x.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var r=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(r0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(r=e.getLowestSetBit())>0&&e.rShiftTo(r,e),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},x.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=q[q.length-1]){for(e=0;e>8&255,J[W++]^=t>>16&255,J[W++]^=t>>24&255,W>=X&&(W-=X)}((new Date).getTime())}if(null==J){var $;if(J=new Array,W=0,void 0!==n&&(void 0!==n.crypto||void 0!==n.msCrypto)){var Q=n.crypto||n.msCrypto;if(Q.getRandomValues){var tt=new Uint8Array(32);for(Q.getRandomValues(tt),$=0;$<32;++$)J[W++]=tt[$]}else if("Netscape"==i.appName&&i.appVersion<"5"){var et=n.crypto.random(32);for($=0;$>>8,J[W++]=255&$;W=0,Z()}function it(){if(null==G){for(Z(),(G=new Y).init(J),W=0;W>24,(16711680&r)>>16,(65280&r)>>8,255&r]))),r+=1;return n}function ot(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function at(t,e,i){for(var n="",r=0;n.length>24,(16711680&r)>>16,(65280&r)>>8,255&r])),r+=1;return n} -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function ht(t,e){this.x=e,this.q=t}function ut(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?x.ONE:n,this.zinv=null}function ct(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new ut(this,null,null)}nt.prototype.nextBytes=function(t){var e;for(e=0;e0&&e.length>0))throw"Invalid RSA public key";this.n=rt(t,16),this.e=parseInt(e,16)}},ot.prototype.encrypt=function(t){var e=function(t,e){if(e=0&&e>0;){var r=t.charCodeAt(n--);r<128?i[--e]=r:r>127&&r<2048?(i[--e]=63&r|128,i[--e]=r>>6|192):(i[--e]=63&r|128,i[--e]=r>>6&63|128,i[--e]=r>>12|224)}i[--e]=0;for(var s=new nt,o=new Array;e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new x(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var n=i.toString(16);return 0==(1&n.length)?n:"0"+n},ot.prototype.encryptOAEP=function(t,e,i){var n=function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;if(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t.length+2*n+2>e)throw"Message too long for RSA";var a,h="";for(a=0;a>3,e,i);if(null==n)return null;var r=this.doPublic(n);if(null==r)return null;var s=r.toString(16);return 0==(1&s.length)?s:"0"+s},ot.prototype.type="RSA",ot.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},ot.prototype.setPrivate=function(t,e,i){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=i;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16)}},ot.prototype.setPrivateEx=function(t,e,i,n,r,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16),this.p=rt(n,16),this.q=rt(r,16),this.dmp1=rt(s,16),this.dmq1=rt(o,16),this.coeff=rt(a,16)},ot.prototype.generate=function(t,e){var i=new nt,n=t>>1;this.e=parseInt(e,16);for(var r=new x(e,16);;){for(;this.p=new x(t-n,1,i),0!=this.p.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.p.isProbablePrime(10););for(;this.q=new x(n,1,i),0!=this.q.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(x.ONE),a=this.q.subtract(x.ONE),h=o.multiply(a);if(0==h.gcd(r).compareTo(x.ONE)){this.n=this.p.multiply(this.q),this.d=r.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},ot.prototype.decrypt=function(t){var e=rt(t,16),i=this.doPrivate(e);return null==i?null: -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function(t,e){for(var i=t.toByteArray(),n=0;n=i.length)return null;for(var r="";++n191&&s<224?(r+=String.fromCharCode((31&s)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&s)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},ot.prototype.decryptOAEP=function(t,e,i){var n=rt(t,16),r=this.doPrivate(n);return null==r?null:function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;for(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t=t.toByteArray(),a=0;a>3,e,i)},ht.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ht.prototype.toBigInteger=function(){return this.x},ht.prototype.negate=function(){return new ht(this.q,this.x.negate().mod(this.q))},ht.prototype.add=function(t){return new ht(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ht.prototype.subtract=function(t){return new ht(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ht.prototype.multiply=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ht.prototype.square=function(){return new ht(this.q,this.x.square().mod(this.q))},ht.prototype.divide=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ut.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO))},ut.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(x.ZERO)&&!this.y.toBigInteger().equals(x.ZERO)},ut.prototype.negate=function(){return new ut(this.curve,this.x,this.y.negate(),this.z)},ut.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),i=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(x.ZERO.equals(i))return x.ZERO.equals(e)?this.twice():this.curve.getInfinity();var n=new x("3"),r=this.x.toBigInteger(),s=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),i.square()),a=o.multiply(i),h=r.multiply(o),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(a).multiply(i).mod(this.curve.q),l=h.multiply(n).multiply(e).subtract(s.multiply(a)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),f=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},ut.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new x("3"),e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=i.multiply(this.z),r=n.multiply(i).mod(this.curve.q),s=this.curve.a.toBigInteger(),o=e.square().multiply(t);x.ZERO.equals(s)||(o=o.add(this.z.square().multiply(s)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(r)).shiftLeft(1).multiply(n).mod(this.curve.q),h=o.multiply(t).multiply(e).subtract(r.shiftLeft(1)).shiftLeft(2).multiply(r).subtract(o.square().multiply(o)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),u)},ut.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add(o?this:r))}return s},ut.prototype.multiplyTwo=function(t,e,i){var n;n=t.bitLength()>i.bitLength()?t.bitLength()-1:i.bitLength()-1;for(var r=this.curve.getInfinity(),s=this.add(e);n>=0;)r=r.twice(),t.testBit(n)?r=i.testBit(n)?r.add(s):r.add(this):i.testBit(n)&&(r=r.add(e)),--n;return r},ct.prototype.getQ=function(){return this.q},ct.prototype.getA=function(){return this.a},ct.prototype.getB=function(){return this.b},ct.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ct.prototype.getInfinity=function(){return this.infinity},ct.prototype.fromBigInteger=function(t){return new ht(this.q,t)},ct.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,i=t.substr(2,e),n=t.substr(e+2,e);return new ut(this,this.fromBigInteger(new x(i,16)),this.fromBigInteger(new x(n,16)));default:return null}}, -/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib - */ -ht.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ut.prototype.getEncoded=function(t){var e=function(t,e){var i=t.toByteArrayUnsigned();if(ei.length;)i.unshift(0);return i},i=this.getX().toBigInteger(),n=this.getY().toBigInteger(),r=e(i,32);return t?n.isEven()?r.unshift(2):r.unshift(3):(r.unshift(4),r=r.concat(e(n,32))),r},ut.decodeFrom=function(t,e){e[0];var i=e.length-1,n=e.slice(1,1+i/2),r=e.slice(1+i/2,1+i);n.unshift(0),r.unshift(0);var s=new x(n),o=new x(r);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.decodeFromHex=function(t,e){e.substr(0,2);var i=e.length-2,n=e.substr(2,i/2),r=e.substr(2+i/2,i/2),s=new x(n,16),o=new x(r,16);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),i=t.y.subtract(this.y).divide(e),n=i.square().subtract(this.x).subtract(t.x),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(x.valueOf(2)),e=this.curve.fromBigInteger(x.valueOf(3)),i=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=i.square().subtract(this.x.multiply(t)),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add2D(o?this:r))}return s},ut.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),i=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),r=this.curve.getQ(),s=e.multiply(e).mod(r),o=t.multiply(t).multiply(t).add(i.multiply(t)).add(n).mod(r);return s.equals(o)},ut.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ut.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),i=this.getY().toBigInteger();if(e.compareTo(x.ONE)<0||e.compareTo(t.subtract(x.ONE))>0)throw new Error("x coordinate out of bounds");if(i.compareTo(x.ONE)<0||i.compareTo(t.subtract(x.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0}; -/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval - */ -var lt=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),i={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,n){return e?i[e]:String.fromCharCode(parseInt(n,16))}var r=new String(""),s=(Object,Array,Object.hasOwnProperty);return function(i,o){var a,h,u=i.match(t),c=u[0],l=!1;"{"===c?a={}:"["===c?a=[]:(a=[],l=!0);for(var f=[a],d=1-l,g=u.length;d=0;)delete i[n[h]]}return o.call(t,e,i)};a=y({"":a},"")}return a}}();void 0!==ft&&ft||(ft={}),void 0!==ft.asn1&&ft.asn1||(ft.asn1={}),ft.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},ft.asn1.DERAbstractString=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=At(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},r.lang.extend(ft.asn1.DERAbstractString,ft.asn1.ASN1Object),ft.asn1.DERAbstractTime=function(t){ft.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var n=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var h=n(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=St(t)},this.setByDateValue=function(t,e,i,n,r,s){var o=new Date(Date.UTC(t,e-1,i,n,r,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},r.lang.extend(ft.asn1.DERAbstractTime,ft.asn1.ASN1Object),ft.asn1.DERAbstractStructured=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},r.lang.extend(ft.asn1.DERAbstractStructured,ft.asn1.ASN1Object),ft.asn1.DERBoolean=function(){ft.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},r.lang.extend(ft.asn1.DERBoolean,ft.asn1.ASN1Object),ft.asn1.DERInteger=function(t){ft.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ft.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},r.lang.extend(ft.asn1.DERInteger,ft.asn1.ASN1Object),ft.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ft.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}ft.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7r.length&&(r=n[i]);return(t=t.replace(r,"::")).slice(1,-1)}function _t(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?Lt(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function Kt(t){for(var e=encodeURIComponent(t),i="",n=0;n"7"?"00"+t:t}function Mt(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,i){var n=parseInt(t);if(n<0||255=2*s)break;if(a>=200)break;n.push(h),o=h,a++}return n},pt.getNthChildIdx=function(t,e,i){return pt.getChildIdx(t,e)[i]},pt.getIdxbyList=function(t,e,i,n){var r,s,o=pt;if(0==i.length){if(void 0!==n&&t.substr(e,2)!==n)throw"checking tag doesn't match: "+t.substr(e,2)+"!="+n;return e}return r=i.shift(),s=o.getChildIdx(t,e),o.getIdxbyList(t,s[r],i,n)},pt.getTLVbyList=function(t,e,i,n){var r=pt,s=r.getIdxbyList(t,e,i);if(void 0===s)throw"can't find nthList object";if(void 0!==n&&t.substr(s,2)!=n)throw"checking tag doesn't match: "+t.substr(s,2)+"!="+n;return r.getTLV(t,s)},pt.getVbyList=function(t,e,i,n,r){var s,o,a=pt;if(void 0===(s=a.getIdxbyList(t,e,i,n)))throw"can't find nthList object";return o=a.getV(t,s),!0===r&&(o=o.substr(2)),o},pt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},i=[],n=t.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var s=t.substr(2),o=[],a=0;a0&&(c=c+"."+h.join(".")),c},pt.dump=function(t,e,i,n){var r=pt,s=r.getV,o=r.dump,a=r.getChildIdx,h=t;t instanceof ft.asn1.ASN1Object&&(h=t.getEncodedHex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var c=e.ommit_long_octet;if("01"==h.substr(i,2))return"00"==(l=s(h,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==h.substr(i,2))return n+"INTEGER "+u(l=s(h,i),c)+"\n";if("03"==h.substr(i,2))return n+"BITSTRING "+u(l=s(h,i),c)+"\n";if("04"==h.substr(i,2)){var l=s(h,i);if(r.isASN1HEX(l)){var f=n+"OCTETSTRING, encapsulates\n";return f+=o(l,e,0,n+" ")}return n+"OCTETSTRING "+u(l,c)+"\n"}if("05"==h.substr(i,2))return n+"NULL\n";if("06"==h.substr(i,2)){var d=s(h,i),g=ft.asn1.ASN1Util.oidHexToInt(d),p=ft.asn1.x509.OID.oid2name(g),y=g.replace(/\./g," ");return""!=p?n+"ObjectIdentifier "+p+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0c"==h.substr(i,2))return n+"UTF8String '"+bt(s(h,i))+"'\n";if("13"==h.substr(i,2))return n+"PrintableString '"+bt(s(h,i))+"'\n";if("14"==h.substr(i,2))return n+"TeletexString '"+bt(s(h,i))+"'\n";if("16"==h.substr(i,2))return n+"IA5String '"+bt(s(h,i))+"'\n";if("17"==h.substr(i,2))return n+"UTCTime "+bt(s(h,i))+"\n";if("18"==h.substr(i,2))return n+"GeneralizedTime "+bt(s(h,i))+"\n";if("30"==h.substr(i,2)){if("3000"==h.substr(i,4))return n+"SEQUENCE {}\n";f=n+"SEQUENCE\n";var v=e;if((2==(F=a(h,i)).length||3==F.length)&&"06"==h.substr(F[0],2)&&"04"==h.substr(F[F.length-1],2)){p=r.oidname(s(h,F[0]));var m=JSON.parse(JSON.stringify(e));m.x509ExtName=p,v=m}for(var S=0;S0){var e=new i({array:this.extensionsArray}),n=new r({explicit:!0,tag:"a3",obj:e});this.asn1Array.push(n)}var s=new i({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertificate,ft.asn1.ASN1Object),ft.asn1.x509.Extension=function(t){ft.asn1.x509.Extension.superclass.constructor.call(this);var e=ft.asn1,i=e.DERObjectIdentifier,n=e.DEROctetString,r=(e.DERBitString,e.DERBoolean),s=e.DERSequence;this.getEncodedHex=function(){var t=new i({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new r),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},r.lang.extend(ft.asn1.x509.Extension,ft.asn1.ASN1Object),ft.asn1.x509.Extension.appendByNameToArray=function(t,e,i){var n=t.toLowerCase(),r=ft.asn1.x509;if("basicconstraints"==n){var s=new r.BasicConstraints(e);i.push(s)}else if("keyusage"==n){s=new r.KeyUsage(e);i.push(s)}else if("crldistributionpoints"==n){s=new r.CRLDistributionPoints(e);i.push(s)}else if("extkeyusage"==n){s=new r.ExtKeyUsage(e);i.push(s)}else if("authoritykeyidentifier"==n){s=new r.AuthorityKeyIdentifier(e);i.push(s)}else if("authorityinfoaccess"==n){s=new r.AuthorityInfoAccess(e);i.push(s)}else if("subjectaltname"==n){s=new r.SubjectAltName(e);i.push(s)}else{if("issueraltname"!=n)throw"unsupported extension name: "+t;s=new r.IssuerAltName(e);i.push(s)}},ft.asn1.x509.KeyUsage=function(t){ft.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Jt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new ft.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var i=t.names,n="000000000",r=0;r-1&&t.push(new ft.asn1.DERInteger({int:this.pathLen}));var e=new ft.asn1.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},r.lang.extend(ft.asn1.x509.BasicConstraints,ft.asn1.x509.Extension),ft.asn1.x509.CRLDistributionPoints=function(t){ft.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ft.asn1,i=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){this.asn1ExtnValue=new e.DERSequence({array:t})},this.setByOneURI=function(t){var e=new i.GeneralNames([{uri:t}]),n=new i.DistributionPointName(e),r=new i.DistributionPoint({dpobj:n});this.setByDPArray([r])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},r.lang.extend(ft.asn1.x509.CRLDistributionPoints,ft.asn1.x509.Extension),ft.asn1.x509.ExtKeyUsage=function(t){ft.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=ft.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var i=0;i0){var t=new i({array:this.aRevokedCert});this.asn1Array.push(t)}var e=new i({array:this.asn1Array});return this.hTLV=e.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize=function(){this.asn1Version=null,this.asn1SignatureAlg=null,this.asn1Issuer=null,this.asn1ThisUpdate=null,this.asn1NextUpdate=null,this.aRevokedCert=new Array},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertList,ft.asn1.ASN1Object),ft.asn1.x509.CRLEntry=function(t){ft.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=ft.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},r.lang.extend(ft.asn1.x509.CRLEntry,ft.asn1.ASN1Object),ft.asn1.x509.X500Name=function(t){ft.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=new Array;var e=ft.asn1,i=e.x509,n=Ht;if(this.setByString=function(t){var e=t.split("/");e.shift();for(var n=[],r=0;r0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},ft.asn1.x509.RDN=function(t){ft.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=new Array,this.addByString=function(t){this.asn1Array.push(new ft.asn1.x509.AttributeTypeAndValue({str:t}))},this.addByMultiValuedString=function(t){for(var e=ft.asn1.x509.RDN.parseString(t),i=0;i0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var a=!1,h=[];for(r=0;n.length>0;r++){s=n.shift();if(!0===a){var u=h.pop();if(s.match(/"$/)){o=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(o),a=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(a=!0)}return h},ft.asn1.x509.AttributeTypeAndValue=function(t){ft.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var e=ft.asn1;this.setByString=function(t){var e=t.match(/^([^=]+)=(.+)$/);if(!e)throw"malformed attrTypeAndValueStr: "+t;this.setByAttrTypeAndValueStr(e[1],e[2])},this.setByAttrTypeAndValueStr=function(t,e){this.typeObj=ft.asn1.x509.OID.atype2obj(t);var i="utf8";"C"==t&&(i="prn"),this.valueObj=this.getValueObj(i,e)},this.getValueObj=function(t,i){if("utf8"==t)return new e.DERUTF8String({str:i});if("prn"==t)return new e.DERPrintableString({str:i});if("tel"==t)return new e.DERTeletexString({str:i});if("ia5"==t)return new e.DERIA5String({str:i});throw"unsupported directory string type: type="+t+" value="+i},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.typeObj,this.valueObj]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&void 0!==t.str&&this.setByString(t.str)},r.lang.extend(ft.asn1.x509.AttributeTypeAndValue,ft.asn1.ASN1Object),ft.asn1.x509.SubjectPublicKeyInfo=function(t){ft.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ft,i=e.asn1,n=i.DERInteger,r=i.DERBitString,s=i.DERObjectIdentifier,o=i.DERSequence,a=i.ASN1Util.newObject,h=i.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof ot){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+e})}}catch(t){}try{if(t instanceof ft.crypto.ECDSA){var i=new s({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ft.crypto.DSA){i=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new h({name:"dsa",asn1params:i});var o=new n({bigint:t.y});this.asn1SubjPKey=new r({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},r.lang.extend(ft.asn1.x509.SubjectPublicKeyInfo,ft.asn1.ASN1Object),ft.asn1.x509.Time=function(t){ft.asn1.x509.Time.superclass.constructor.call(this);var e=ft.asn1,i=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},r.lang.extend(ft.asn1.x509.Time,ft.asn1.ASN1Object),ft.asn1.x509.AlgorithmIdentifier=function(t){ft.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ft.asn1;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw"algorithm not specified";null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var t=[this.asn1Alg];null!==this.asn1Params&&t.push(this.asn1Params);var i=new e.DERSequence({array:t});return this.hTLV=i.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},r.lang.extend(ft.asn1.x509.AlgorithmIdentifier,ft.asn1.ASN1Object),ft.asn1.x509.GeneralName=function(t){ft.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=ft.asn1,n=(i.DERSequence,i.DEROctetString),r=i.DERIA5String,s=i.DERTaggedObject,o=i.ASN1Object,a=i.x509.X500Name,h=Ht;this.explicit=!1,this.setByParam=function(t){var i=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",i=new r({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",i=new r({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",i=new r({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,i=new a({str:t.dn})),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var u=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certissuer param not cert";(f=new Jt).hex=u;var c=f.getIssuerHex();(i=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;u=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certsubj param not cert";(f=new Jt).hex=u;c=f.getSubjectHex();(i=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,g=t.ip,p="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(d=Mt("["+g.split(".").join(",")+"]")).length)throw p}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=Vt(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw p;d=g}i=new n({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},r.lang.extend(ft.asn1.x509.GeneralName,ft.asn1.ASN1Object),ft.asn1.x509.GeneralNames=function(t){ft.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ft.asn1;this.setByParamArray=function(t){for(var i=0;i0&&(e=new n({obj:this.dUnsignedAttrs,tag:"a1",explicit:!1}));var r=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,t,this.dSigAlg,this.dSig];null!=e&&r.push(e);var o=new i.DERSequence({array:r});return this.hTLV=o.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.SignerInfo,ft.asn1.ASN1Object),ft.asn1.cms.EncapsulatedContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.dEContentType=new r({name:"data"}),this.dEContent=null,this.isDetached=!1,this.eContentValueHex=null,this.setContentType=function(t){t.match(/^[0-2][.][0-9.]+$/)?this.dEContentType=new r({oid:t}):this.dEContentType=new r({name:t})},this.setContentValue=function(t){void 0!==t&&("string"==typeof t.hex?this.eContentValueHex=t.hex:"string"==typeof t.str&&(this.eContentValueHex=At(t.str)))},this.setContentValueHex=function(t){this.eContentValueHex=t},this.setContentValueStr=function(t){this.eContentValueHex=At(t)},this.getEncodedHex=function(){if("string"!=typeof this.eContentValueHex)throw"eContentValue not yet set";var t=new s({hex:this.eContentValueHex});this.dEContent=new i({obj:t,tag:"a0",explicit:!0});var e=[this.dEContentType];this.isDetached||e.push(this.dEContent);var r=new n({array:e});return this.hTLV=r.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.EncapsulatedContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.ContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.x509;ft.asn1.cms.ContentInfo.superclass.constructor.call(this),this.dContentType=null,this.dContent=null,this.setContentType=function(t){"string"==typeof t&&(this.dContentType=r.OID.name2obj(t))},this.getEncodedHex=function(){var t=new i({obj:this.dContent,tag:"a0",explicit:!0}),e=new n({array:[this.dContentType,t]});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t&&(t.type&&this.setContentType(t.type),t.obj&&t.obj instanceof e.ASN1Object&&(this.dContent=t.obj))},r.lang.extend(ft.asn1.cms.ContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.SignedData=function(t){var e=ft.asn1,i=e.ASN1Object,n=e.DERInteger,r=e.DERSet,s=e.DERSequence,o=e.DERTaggedObject,a=e.cms,h=a.EncapsulatedContentInfo,u=a.SignerInfo,c=a.ContentInfo,l=e.x509.AlgorithmIdentifier;ft.asn1.cms.SignedData.superclass.constructor.call(this),this.dCMSVersion=new n({int:1}),this.dDigestAlgs=null,this.digestAlgNameList=[],this.dEncapContentInfo=new h,this.dCerts=null,this.certificateList=[],this.crlList=[],this.signerInfoList=[new u],this.addCertificatesByPEM=function(t){var e=Ht(t),n=new i;n.hTLV=e,this.certificateList.push(n)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(null==this.dDigestAlgs){for(var t=[],e=0;e0){var h=new r({array:this.certificateList});this.dCerts=new o({obj:h,tag:"a0",explicit:!1})}null!=this.dCerts&&a.push(this.dCerts);var u=new r({array:this.signerInfoList});a.push(u);var c=new s({array:a});return this.hTLV=c.getEncodedHex(),this.hTLV},this.getContentInfo=function(){return this.getEncodedHex(),new c({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},this.getPEM=function(){return Rt(this.getContentInfoEncodedHex(),"CMS")}},r.lang.extend(ft.asn1.cms.SignedData,ft.asn1.ASN1Object),ft.asn1.cms.CMSUtil=new function(){},ft.asn1.cms.CMSUtil.newSignedData=function(t){var e=ft.asn1,i=e.cms,n=i.SignerInfo,r=i.SignedData,s=i.SigningTime,o=i.SigningCertificate,a=i.SigningCertificateV2,h=e.cades.SignaturePolicyIdentifier,u=new r;if(u.dEncapContentInfo.setContentValue(t.content),"object"==typeof t.certs)for(var c=0;c0){var t=new n({array:this.extensionsArray}),e=new r({array:[t]}),i=new n({array:[new a({oid:"1.2.840.113549.1.9.14"}),e]}),h=new o({explicit:!0,tag:"a0",obj:i});this.asn1Array.push(h)}else{h=new o({explicit:!1,tag:"a0",obj:new s});this.asn1Array.push(h)}var u=new n({array:this.asn1Array});return this.hTLV=u.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.csr.CertificationRequestInfo,ft.asn1.ASN1Object),ft.asn1.csr.CSRUtil=new function(){},ft.asn1.csr.CSRUtil.newCSRPEM=function(t){var e=Ut,i=ft.asn1.csr;if(void 0===t.subject)throw"parameter subject undefined";if(void 0===t.sbjpubkey)throw"parameter sbjpubkey undefined";if(void 0===t.sigalg)throw"parameter sigalg undefined";if(void 0===t.sbjprvkey)throw"parameter sbjpubkey undefined";var n=new i.CertificationRequestInfo;if(n.setSubjectByParam(t.subject),n.setSubjectPublicKeyByGetKey(t.sbjpubkey),void 0!==t.ext&&void 0!==t.ext.length)for(var r=0;rr)throw"key is too short for SigAlg: keylen="+i+","+e;for(var s="0001",o="00"+n,a="",h=r-s.length-o.length,u=0;u=0)return!1;if(i.compareTo(x.ONE)<0||i.compareTo(r)>=0)return!1;var o=i.modInverse(r),a=t.multiply(o).mod(r),h=e.multiply(o).mod(r);return s.multiply(a).add(n.multiply(h)).getX().toBigInteger().mod(r).equals(e)},this.serializeSig=function(t,e){var i=t.toByteArraySigned(),n=e.toByteArraySigned(),r=[];return r.push(2),r.push(i.length),(r=r.concat(i)).push(2),r.push(n.length),(r=r.concat(n)).unshift(r.length),r.unshift(48),r},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:x.fromByteArrayUnsigned(i),s:x.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:x.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:x.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[2,0],"06"),i=o(t,0,[1],"04");try{n=o(t,0,[3,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#1/5 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{o(t,0,[1,0],"06"),e=o(t,0,[1,1],"06"),i=o(t,0,[2,0,1],"04");try{n=o(t,0,[2,0,2,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#8 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){var e,i,n=pt,r=ft.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{s(t,0,[0,0],"06"),e=s(t,0,[0,1],"06"),i=s(t,0,[1],"03").substr(2)}catch(t){throw"malformed PKCS#8 ECC public key"}if(this.curveName=r(e),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,e){5!==e&&(e=6);var i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{i=o(t,0,[0,e,0,1],"06"),n=o(t,0,[0,e,1],"03").substr(2)}catch(t){throw"malformed X.509 certificate ECC public key"}if(this.curveName=s(i),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ft.crypto.ECDSA.parseSigHex=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new x(e.r,16),s:new x(e.s,16)}},ft.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=pt,i=e.getChildIdx,n=e.getV;if("30"!=t.substr(0,2))throw"signature is not a ASN.1 sequence";var r=i(t,0);if(2!=r.length)throw"number of signature ASN.1 sequence elements seem wrong";var s=r[0],o=r[1];if("02"!=t.substr(s,2))throw"1st item of sequene of signature is not ASN.1 integer";if("02"!=t.substr(o,2))throw"2nd item of sequene of signature is not ASN.1 integer";return{r:n(t,s),s:n(t,o)}},ft.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t),i=e.r,n=e.s;if("00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),i.length%32==30&&(i="00"+i),n.length%32==30&&(n="00"+n),i.length%32!=0)throw"unknown ECDSA sig r length error";if(n.length%32!=0)throw"unknown ECDSA sig s length error";return i+n},ft.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var e=t.substr(0,t.length/2),i=t.substr(t.length/2);return ft.crypto.ECDSA.hexRSSigToASN1Sig(e,i)},ft.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var i=new x(t,16),n=new x(e,16);return ft.crypto.ECDSA.biRSSigToASN1Sig(i,n)},ft.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var i=ft.asn1,n=new i.DERInteger({bigint:t}),r=new i.DERInteger({bigint:e});return new i.DERSequence({array:[n,r]}).getEncodedHex()},ft.crypto.ECDSA.getName=function(t){return"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040022"===t?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":null},void 0!==ft&&ft||(ft={}),void 0!==ft.crypto&&ft.crypto||(ft.crypto={}),ft.crypto.ECParameterDB=new function(){var t={},e={};function i(t){return new x(t,16)}this.getByName=function(i){var n=i;if(void 0!==e[n]&&(n=e[i]),void 0!==t[n])return t[n];throw"unregistered EC curve name: "+n},this.regist=function(n,r,s,o,a,h,u,c,l,f,d,g){t[n]={};var p=i(s),y=i(o),v=i(a),m=i(h),S=i(u),F=new ct(p,y,v),w=F.decodePointHex("04"+c+l);t[n].name=n,t[n].keylen=r,t[n].curve=F,t[n].G=w,t[n].n=m,t[n].h=S,t[n].oid=d,t[n].info=g;for(var E=0;E1?new x(n,16):null,u=new x(r,16),this.setPrivate(s,o,a,h,u)},this.setPublic=function(t,e,i,n){this.isPublic=!0,this.p=t,this.q=e,this.g=i,this.y=n,this.x=null},this.setPublicHex=function(t,e,i,n){var r,s,o,a;r=new x(t,16),s=new x(e,16),o=new x(i,16),a=new x(n,16),this.setPublic(r,s,o,a)},this.signWithMessageHash=function(t){var e=this.p,i=this.q,n=this.g,r=(this.y,this.x),s=ft.crypto.Util.getRandomBigIntegerMinToMax(x.ONE.add(x.ONE),i.subtract(x.ONE)),o=new x(t.substr(0,i.bitLength()/4),16),a=n.modPow(s,e).mod(i),h=s.modInverse(i).multiply(o.add(r.multiply(a))).mod(i);return ft.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:a}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var i=this.p,n=this.q,r=this.g,s=this.y,o=this.parseASN1Signature(e),a=o[0],h=o[1],u=new x(t.substr(0,n.bitLength()/4),16);if(x.ZERO.compareTo(a)>0||a.compareTo(n)>0)throw"invalid DSA signature";if(x.ZERO.compareTo(h)>=0||h.compareTo(n)>0)throw"invalid DSA signature";var c=h.modInverse(n),l=u.multiply(c).mod(n),f=a.multiply(c).mod(n);return 0==r.modPow(l,i).multiply(s.modPow(f,i)).mod(i).mod(n).compareTo(a)},this.parseASN1Signature=function(t){try{return[new x(pt.getVbyList(t,0,[0],"02"),16),new x(pt.getVbyList(t,0,[1],"02"),16)]}catch(t){throw"malformed ASN.1 DSA signature"}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r,s,o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{e=a(t,0,[1],"02"),i=a(t,0,[2],"02"),n=a(t,0,[3],"02"),r=a(t,0,[4],"02"),s=a(t,0,[5],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#1/5 plain DSA private key"}this.setPrivateHex(e,i,n,r,s)},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[1,1,0],"02"),i=o(t,0,[1,1,1],"02"),n=o(t,0,[1,1,2],"02"),r=o(t,0,[2,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 plain DSA private key"}this.setPrivateHex(e,i,n,null,r)},this.readPKCS8PubKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[0,1,0],"02"),i=o(t,0,[0,1,1],"02"),n=o(t,0,[0,1,2],"02"),r=o(t,0,[1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 DSA public key"}this.setPublicHex(e,i,n,r)},this.readCertPubKeyHex=function(t,e){var i,n,r,s;5!==e&&(e=6);var o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{i=a(t,0,[0,e,0,1,0],"02"),n=a(t,0,[0,e,0,1,1],"02"),r=a(t,0,[0,e,0,1,2],"02"),s=a(t,0,[0,e,1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed X.509 certificate DSA public key"}this.setPublicHex(i,n,r,s)}};var Ut=function(){var t=function(t,i,n){return e(y.AES,t,i,n)},e=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=r;var h=t.decrypt(a,s,{iv:o});return y.enc.Hex.stringify(h)},i=function(t,e,i){return n(y.AES,t,e,i)},n=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a=t.encrypt(r,s,{iv:o}),h=y.enc.Hex.parse(a.toString());return y.enc.Base64.stringify(h)},r={"AES-256-CBC":{proc:t,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,i,n){return e(y.TripleDES,t,i,n)},eproc:function(t,e,i){return n(y.TripleDES,t,e,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,i,n){return e(y.DES,t,i,n)},eproc:function(t,e,i){return n(y.DES,t,e,i)},keylen:8,ivlen:8}},s=function(t){var e={},i=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(e.cipher=i[1],e.ivsalt=i[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var r=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(r=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(r=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=r&&-1!=o){var a=t.substring(r+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,i){for(var n=i.substring(0,16),s=y.enc.Hex.parse(n),o=y.enc.Utf8.parse(e),a=r[t].keylen+r[t].ivlen,h="",u=null;;){var c=y.algo.MD5.create();if(null!=u&&c.update(u),c.update(o),c.update(s),u=c.finalize(),(h+=y.enc.Hex.stringify(u)).length>=2*a)break}var l={};return l.keyhex=h.substr(0,2*r[t].keylen),l.ivhex=h.substr(2*r[t].keylen,2*r[t].ivlen),l},a=function(t,e,i,n){var s=y.enc.Base64.parse(t),o=y.enc.Hex.stringify(s);return(0,r[e].proc)(o,i,n)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,i){return o(t,e,i)},decryptKeyB64:function(t,e,i,n){return a(t,e,i,n)},getDecryptedKeyHex:function(t,e){var i=s(t),n=(i.type,i.cipher),r=i.ivsalt,h=i.data,u=o(n,e,r).keyhex;return a(h,n,u,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,i,n,s){var a="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===r[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==s&&null!=s||(s=function(t){var e=y.lib.WordArray.random(t);return y.enc.Hex.stringify(e)}(r[n].ivlen).toUpperCase());var h=function(t,e,i,n){return(0,r[e].eproc)(t,i,n)}(e,n,o(n,i,s).keyhex,s);a="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+n+","+s+"\r\n",a+="\r\n",a+=h.replace(/(.{64})/g,"$1\r\n"),a+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={},s=i(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;r.ciphertext=n(t,s[1]);var o=i(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=i(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var h=i(t,a[1]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length;if("2a864886f70d0307"!=n(t,h[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(t,h[1]);var u=i(t,a[0]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length;if("2a864886f70d01050c"!=n(t,u[0]))throw"this only supports pkcs5PBKDF2";var c=i(t,u[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;r.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{r.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return r},getPBKDF2KeyHexFromParam:function(t,e){var i=y.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,r=y.PBKDF2(e,i,{keySize:6,iterations:n});return y.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var i=Ht(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=Ut.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=y.enc.Hex.parse(n.ciphertext);var o=y.enc.Hex.parse(r),a=y.enc.Hex.parse(n.encryptionSchemeIV),h=y.TripleDES.decrypt(s,o,{iv:a});return y.enc.Hex.stringify(h)},getKeyFromEncryptedPKCS8PEM:function(t,e){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var s=i(t,0);if(3!=s.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(s[1],2))throw"malformed PKCS8 private key(code:003)";var o=i(t,s[1]);if(2!=o.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(o[0],2))throw"malformed PKCS8 private key(code:005)";if(r.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(r.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw"malformed PKCS8 private key(code:006)";return r.keyidx=e.getVidx(t,s[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Ht(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,i=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==i.algoid)e=new ot;else if("2a8648ce380401"==i.algoid)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";e=new ft.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,i=pt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===i)e=new ot;else if("2a8648ce380401"===i)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";e=new ft.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=i(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(r.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return r.e=n(t,s[1]),r},parsePublicPKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null},s=i(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=i(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?r.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(r.algparam={},r.algparam.p=e.getVbyList(t,a[1],[0],"02"),r.algparam.q=e.getVbyList(t,a[1],[1],"02"),r.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(t,s[1]).substr(2),r}}}();Ut.getKey=function(t,e,i){var n=(y=pt).getChildIdx,r=(y.getV,y.getVbyList),s=ft.crypto,o=s.ECDSA,a=s.DSA,h=ot,u=Ht,c=Ut;if(void 0!==h&&t instanceof h)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(t.n,t.e),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(D=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(D=new h).setPrivate(t.n,t.e,t.d),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(D=new a).setPublic(t.p,t.q,t.g,t.y),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(D=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(xt(t.n),xt(t.e)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(D=new h).setPrivateEx(xt(t.n),xt(t.e),xt(t.d),xt(t.p),xt(t.q),xt(t.dp),xt(t.dq),xt(t.qi)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(D=new h).setPrivate(xt(t.n),xt(t.e),xt(t.d)),D;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);return C.setPublicKeyHex(f),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);var d=("0000000000"+xt(t.d)).slice(-l);return C.setPublicKeyHex(f),C.setPrivateKeyHex(d),C}if("pkcs5prv"===i){var g,p=t,y=pt;if(9===(g=n(p,0)).length)(D=new h).readPKCS5PrvKeyHex(p);else if(6===g.length)(D=new a).readPKCS5PrvKeyHex(p);else{if(!(g.length>2&&"04"===p.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(D=new o).readPKCS5PrvKeyHex(p)}return D}if("pkcs8prv"===i)return D=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===i)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===i)return Jt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Jt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=Ht(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=u(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=r(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),F=r(R,0,[2],"02"),w=r(R,0,[3],"02"),E=r(R,0,[4],"02"),A=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(w,16),new x(E,16),new x(A,16)),D}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var b=c.getDecryptedKeyHex(t,e),I=new ot;return I.readPKCS5PrvKeyHex(b),I}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var C,D=r(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),T=r(R,0,[2,0],"06"),P=r(R,0,[3,0],"03").substr(2);if(void 0===ft.crypto.OID.oidhex2name[T])throw"undefined OID(hex) in KJUR.crypto.OID: "+T;return(C=new o({curve:ft.crypto.OID.oidhex2name[T]})).setPublicKeyHex(P),C.setPrivateKeyHex(D),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;S=r(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),F=r(R,0,[2],"02"),w=r(R,0,[3],"02"),E=r(R,0,[4],"02"),A=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(w,16),new x(E,16),new x(A,16)),D}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw"not supported argument"},Ut.generateKeypair=function(t,e){if("RSA"==t){var i=e;(o=new ot).generate(i,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new ot,r=o.n.toString(16),s=o.e.toString(16);return n.setPublic(r,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,h=e,u=new ft.crypto.ECDSA({curve:h}).generateKeyPairHex();return(o=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),o.setPrivateKeyHex(u.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Ut.getPEM=function(t,e,i,n,r,s){var o=ft,a=o.asn1,h=a.DERObjectIdentifier,u=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,f=o.crypto,d=f.DSA,g=f.ECDSA,p=ot;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function S(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==p&&t instanceof p||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Rt(x=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=v(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===i||null==i)&&1==t.isPrivate){var F=new h({name:t.curveName}).getEncodedHex(),w=m(t).getEncodedHex(),E="";return E+=Rt(F,"EC PARAMETERS"),E+=Rt(w,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=S(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==i&&null!=i&&1==t.isPrivate){var x=v(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==i&&null!=i&&1==t.isPrivate){x=m(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==i&&null!=i&&1==t.isPrivate){x=S(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",x,i,n,s)}var A=function(t,e){var i=b(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},b=function(t,e){var i=y.lib.WordArray.random(8),n=y.lib.WordArray.random(8),r=y.PBKDF2(e,i,{keySize:6,iterations:100}),s=y.enc.Hex.parse(t),o=y.TripleDES.encrypt(s,r,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=y.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=y.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=p&&t instanceof p&&1==t.isPrivate){var I=v(t).getEncodedHex();x=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=A(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){I=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=A(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){I=new u({bigint:t.x}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=A(x,i),"ENCRYPTED PRIVATE KEY")}throw"unsupported object nor format"},Ut.getKeyFromCSRPEM=function(t){var e=Ht(t,"CERTIFICATE REQUEST");return Ut.getKeyFromCSRHex(e)},Ut.getKeyFromCSRHex=function(t){var e=Ut.parseCSRHex(t);return Ut.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Ut.parseCSRHex=function(t){var e=pt,i=e.getChildIdx,n=e.getTLV,r={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=i(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=i(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(s,a[2]),r},Ut.getJWKFromKey=function(t){var e={};if(t instanceof ot&&t.isPrivate)return e.kty="RSA",e.n=Et(t.n.toString(16)),e.e=Et(t.e.toString(16)),e.d=Et(t.d.toString(16)),e.p=Et(t.p.toString(16)),e.q=Et(t.q.toString(16)),e.dp=Et(t.dmp1.toString(16)),e.dq=Et(t.dmq1.toString(16)),e.qi=Et(t.coeff.toString(16)),e;if(t instanceof ot&&t.isPublic)return e.kty="RSA",e.n=Et(t.n.toString(16)),e.e=Et(t.e.toString(16)),e;if(t instanceof ft.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=Et(i.x),e.y=Et(i.y),e.d=Et(t.prvKeyHex),e}if(t instanceof ft.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=Et(i.x),e.y=Et(i.y),e}throw"not supported key object"},ot.getPosArrayOfChildrenFromHex=function(t){return pt.getChildIdx(t,0)},ot.getHexValueArrayOfChildrenFromHex=function(t){var e,i=pt.getV,n=i(t,(e=ot.getPosArrayOfChildrenFromHex(t))[0]),r=i(t,e[1]),s=i(t,e[2]),o=i(t,e[3]),a=i(t,e[4]),h=i(t,e[5]),u=i(t,e[6]),c=i(t,e[7]),l=i(t,e[8]);return(e=new Array).push(n,r,s,o,a,h,u,c,l),e},ot.prototype.readPrivateKeyFromPEMString=function(t){var e=Ht(t),i=ot.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},ot.prototype.readPKCS5PrvKeyHex=function(t){var e=ot.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},ot.prototype.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s,o,a,h,u=pt,c=u.getVbyList;if(!1===u.isASN1HEX(t))throw"not ASN.1 hex string";try{e=c(t,0,[2,0,1],"02"),i=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),r=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw"malformed PKCS#8 plain RSA private key"}this.setPrivateEx(e,i,n,r,s,o,a,h)},ot.prototype.readPKCS5PubKeyHex=function(t){var e=pt,i=e.getV;if(!1===e.isASN1HEX(t))throw"keyHex is not ASN.1 hex string";var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw"wrong hex for PKCS#5 public key";var r=i(t,n[0]),s=i(t,n[1]);this.setPublic(r,s)},ot.prototype.readPKCS8PubKeyHex=function(t){var e=pt;if(!1===e.isASN1HEX(t))throw"not ASN.1 hex string";if("06092a864886f70d010101"!==e.getTLVbyList(t,0,[0,0]))throw"not PKCS8 RSA public key";var i=e.getTLVbyList(t,0,[1,0]);this.readPKCS5PubKeyHex(i)},ot.prototype.readCertPubKeyHex=function(t,e){var i,n;(i=new Jt).readCertHex(t),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var qt=new RegExp("");function zt(t,e){for(var i="",n=e/4-t.length,r=0;r>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function Gt(t){for(var e in ft.crypto.Util.DIGESTINFOHEAD){var i=ft.crypto.Util.DIGESTINFOHEAD[e],n=i.length;if(t.substring(0,n)==i)return[e,t.substring(n)]}return[]}function Jt(){var t=pt,e=t.getChildIdx,i=t.getV,n=t.getTLV,r=t.getVbyList,s=t.getTLVbyList,o=t.getIdxbyList,a=t.getVidx,h=t.oidname,u=Jt,c=Ht;this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){return null===this.hex||0!==this.version?this.version:"a003020102"!==s(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return r(this.hex,0,[0,1+this.foffset],"02")},this.getSignatureAlgorithmField=function(){return h(r(this.hex,0,[0,2+this.foffset,0],"06"))},this.getIssuerHex=function(){return s(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return u.hex2dn(this.getIssuerHex())},this.getSubjectHex=function(){return s(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return u.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=r(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=r(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return t.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return o(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return o(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Ut.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){return h(r(this.hex,0,[1,0],"06"))},this.getSignatureValueHex=function(){return r(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmName(),i=this.getSignatureValueHex(),n=s(this.hex,0,[0],"30"),r=new ft.crypto.Signature({alg:e});return r.init(t),r.updateHex(n),r.verify(i)},this.parseExt=function(){if(3!==this.version)return-1;var i=o(this.hex,0,[0,7,0],"30"),n=e(this.hex,i);this.aExtInfo=new Array;for(var s=0;s0&&(u=new Array(i),(new nt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=It(h(Ct("\0\0\0\0\0\0\0\0"+r+u))),l=[];for(n=0;n>8*a-o&255;for(g[0]&=~p,n=0;nthis.n.bitLength())return 0;var n=Gt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;var r=n[0];return n[1]==function(t){return ft.crypto.Util.hashString(t,r)}(t)},ot.prototype.verifyWithMessageHash=function(t,e){var i=rt(e=(e=e.replace(qt,"")).replace(/[ \n]+/g,""),16);if(i.bitLength()>this.n.bitLength())return 0;var n=Gt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;n[0];return n[1]==t},ot.prototype.verifyPSS=function(t,e,i,n){var r,s=(r=Ct(t),ft.crypto.Util.hashHex(r,i));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(s,e,i,n)},ot.prototype.verifyWithMessageHashPSS=function(t,e,i,n){var r=new x(e,16);if(r.bitLength()>this.n.bitLength())return!1;var s,o=function(t){return ft.crypto.Util.hashHex(t,i)},a=It(t),h=a.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===n||void 0===n)n=h;else if(-2===n)n=c-h-2;else if(n<-2)throw"invalid salt length";if(c>8*c-u&255;if(0!=(f.charCodeAt(0)&g))throw"bits beyond keysize not zero";var p=Yt(d,f.length,o),y=[];for(s=0;s0)&&-1==(":"+i.join(":")+":").indexOf(":"+p+":"))throw"algorithm '"+p+"' not accepted in the list";if("none"!=p&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Ut.getKey(e)),!("RS"!=y&&"PS"!=y||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==y&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===s.jwsalg2sigalg[g.alg])throw"unsupported alg name: "+p;if("none"==(v=s.jwsalg2sigalg[p]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var S,F=null;try{F=h.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(F)}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(d)},ft.jws.JWS.parse=function(t){var e,i,n,r=t.split("."),s={};if(2!=r.length&&3!=r.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=r[0],i=r[1],3==r.length&&(n=r[2]),s.headerObj=ft.jws.JWS.readSafeJSONString(gt(e)),s.payloadObj=ft.jws.JWS.readSafeJSONString(gt(i)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=gt(i):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==n&&(s.sigHex=xt(n)),s},ft.jws.JWS.verifyJWT=function(t,e,i){var n=ft.jws,r=n.JWS,s=r.readSafeJSONString,o=r.inArray,a=r.includedArray,h=t.split("."),u=h[0],c=h[1],l=(xt(h[2]),s(gt(u))),f=s(gt(c));if(void 0===l.alg)return!1;if(void 0===i.alg)throw"acceptField.alg shall be specified";if(!o(l.alg,i.alg))return!1;if(void 0!==f.iss&&"object"==typeof i.iss&&!o(f.iss,i.iss))return!1;if(void 0!==f.sub&&"object"==typeof i.sub&&!o(f.sub,i.sub))return!1;if(void 0!==f.aud&&"object"==typeof i.aud)if("string"==typeof f.aud){if(!o(f.aud,i.aud))return!1}else if("object"==typeof f.aud&&!a(f.aud,i.aud))return!1;var d=n.IntDate.getNow();return void 0!==i.verifyAt&&"number"==typeof i.verifyAt&&(d=i.verifyAt),void 0!==i.gracePeriod&&"number"==typeof i.gracePeriod||(i.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+i.gracePeriodr&&this.aHeader.pop(),this.aSignature.length>r&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignatures=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},e.SecureRandom=nt,e.rng_seed_time=Z,e.BigInteger=x,e.RSAKey=ot,e.ECDSA=ft.crypto.ECDSA,e.DSA=ft.crypto.DSA,e.Signature=ft.crypto.Signature,e.MessageDigest=ft.crypto.MessageDigest,e.Mac=ft.crypto.Mac,e.Cipher=ft.crypto.Cipher,e.KEYUTIL=Ut,e.ASN1HEX=pt,e.X509=Jt,e.CryptoJS=y,e.b64tohex=w,e.b64toBA=E,e.stoBA=yt,e.BAtos=vt,e.BAtohex=mt,e.stohex=St,e.stob64=function(t){return F(St(t))},e.stob64u=function(t){return Ft(F(St(t)))},e.b64utos=function(t){return vt(E(wt(t)))},e.b64tob64u=Ft,e.b64utob64=wt,e.hex2b64=F,e.hextob64u=Et,e.b64utohex=xt,e.utf8tob64u=dt,e.b64utoutf8=gt,e.utf8tob64=function(t){return F(Ot(Kt(t)))},e.b64toutf8=function(t){return decodeURIComponent(jt(w(t)))},e.utf8tohex=At,e.hextoutf8=bt,e.hextorstr=It,e.rstrtohex=Ct,e.hextob64=Dt,e.hextob64nl=Tt,e.b64nltohex=Pt,e.hextopem=Rt,e.pemtohex=Ht,e.hextoArrayBuffer=function(t){if(t.length%2!=0)throw"input is not even length";if(null==t.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var e=new ArrayBuffer(t.length/2),i=new DataView(e),n=0;ne.length&&(i=e.length);for(var n=0;n300)throw new r(`Failed to fetch ${t}. Response=${s}`,i.status);try{return JSON.parse(s)}catch(e){throw new r(`Invalid response while trying to fetch ${t}. Response=${s}`,i.status,e)}}}},function(t,e,i){const n=i(5),r=i(3),s=i(16),o=i(18),a=i(20),h=i(1),u=i(2),c=i(0);t.exports=class{constructor({popup:t=new s,iframe:e=new o,openIdConfigResource:i=new a,utils:h,requestHandler:u=new r,w:l=window,url:f=URL}={}){this.popup=t,this.iframe=e,this.openIdConfigResource=i,this.URL=f,this.utils=h,h||(this.utils=new n({openIdConfigResource:this.openIdConfigResource,url:this.URL,popup:this.popup,jsrsasign:c})),this.request=u.request,this.window=l,this.initialized=!1}async init({clientId:t,discoveryEndpoint:e,popup:i={height:.8*window.screen.height,width:400}}){if(!t)throw new u(h.MISSING_CLIENT_ID);try{new this.URL(e)}catch(t){throw new u(h.INVALID_DISCOVERY_ENDPOINT)}await this.openIdConfigResource.init({discoveryEndpoint:e,requestHandler:this.request}),this.popup.init(i),this.clientId=t,this.initialized=!0}async signin(){this._validateInitalize();const t=this.openIdConfigResource.getAuthorizationEndpoint();return this.utils.performOAuthFlowAndGetTokens({origin:this.window.origin,clientId:this.clientId,endpoint:t})}async silentSignin(){this._validateInitalize();const t=this.openIdConfigResource.getAuthorizationEndpoint(),{codeVerifier:e,nonce:i,state:n,url:r}=this.utils.getAuthParamsAndUrl({clientId:this.clientId,origin:this.window.origin,prompt:h.PROMPT,endpoint:t});let s;this.iframe.open(r);try{s=await this.iframe.waitForMessage({messageType:"authorization_response"})}finally{this.iframe.remove()}this.utils.verifyMessage({message:s,state:n});let o=s.data.code;return await this.utils.retrieveTokens({clientId:this.clientId,authCode:o,codeVerifier:e,nonce:i,openId:this.openIdConfigResource,windowOrigin:this.window.origin})}async getUserInfo(t){if(this._validateInitalize(),"string"!=typeof t)throw new u(h.INVALID_ACCESS_TOKEN);return await this.request(this.openIdConfigResource.getUserInfoEndpoint(),{headers:{Authorization:"Bearer "+t}})}async changePassword(t){let e;if(this._validateInitalize(),!t)throw new u(h.MISSING_ID_TOKEN_PAYLOAD);if("string"==typeof t)throw new u(h.INVALID_ID_TOKEN_PAYLOAD);if(!(t.identities&&t.identities[0]&&t.identities[0].id))throw new u(h.INVALID_ID_TOKEN_PAYLOAD);if("cloud_directory"!==t.identities[0].provider)throw new u(h.NOT_CD_USER);e=t.identities[0].id;const i=this.openIdConfigResource.getIssuer()+h.CHANGE_PASSWORD;return this.utils.performOAuthFlowAndGetTokens({userId:e,origin:this.window.origin,clientId:this.clientId,endpoint:i})}_validateInitalize(){if(!this.initialized)throw new u(h.FAIL_TO_INITIALIZE)}}},function(t,e,i){i(0);const n=i(2),r=i(11),s=i(3),o=i(14),a=i(1);t.exports=class{constructor({requestHandler:t=new s,tokenValidator:e=new o,url:i=URL,openIdConfigResource:n,popup:r,jsrsasign:a=a}={}){this.URL=i,this.request=t.request,this.tokenValidator=e,this.openIdConfigResource=n,this.popup=r,this.rs=a}buildParams(t){return Object.keys(t).map((function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])})).join("&")}getRandomString(t){return this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(t/2)}sha256(t){return this.rs.KJUR.crypto.Util.sha256(t)}getPKCEFields(){const t=this.getRandomString(a.CODE_VERIFIER_LENGTH);return{codeVerifier:t,codeChallenge:this.sha256(t),state:this.getRandomString(a.STATE_LENGTH),nonce:this.getRandomString(a.NONCE_LENGTH)}}getAuthParamsAndUrl({clientId:t,origin:e,prompt:i,endpoint:n,userId:r}){const{codeVerifier:s,codeChallenge:o,state:h,nonce:u}=this.getPKCEFields();let c={client_id:t,response_type:a.RESPONSE_TYPE,state:this.rs.stob64(h),code_challenge:this.rs.stob64(o),code_challenge_method:a.CHALLENGE_METHOD,redirect_uri:e,response_mode:a.RESPONSE_MODE,nonce:u,scope:a.SCOPE};return i&&(c.prompt=i),r&&(c.user_id=r),{codeVerifier:s,nonce:u,state:h,url:n+"?"+this.buildParams(c)}}async performOAuthFlowAndGetTokens({userId:t,origin:e,clientId:i,endpoint:n}){const{codeVerifier:r,state:s,nonce:o,url:a}=this.getAuthParamsAndUrl({userId:t,origin:e,clientId:i,endpoint:n});this.popup.open(),this.popup.navigate(a);const h=await this.popup.waitForMessage({messageType:"authorization_response"});this.popup.close(),this.verifyMessage({message:h,state:s});let u=h.data.code;return await this.retrieveTokens({clientId:i,authCode:u,codeVerifier:r,nonce:o,windowOrigin:e})}verifyMessage({message:t,state:e}){if(t.data.error||t.data.error_description)throw new r({description:t.data.error_description,error:t.data.error});if(this.rs.b64utos(t.data.state)!==e)throw new n(a.INVALID_STATE);if(t.origin!==new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin)throw new n(a.INVALID_ORIGIN)}async retrieveTokens({clientId:t,authCode:e,nonce:i,codeVerifier:n,windowOrigin:r}){let s=this.openIdConfigResource.getIssuer(),o={grant_type:"authorization_code",redirect_uri:r,code:e,code_verifier:n};const a=this.buildParams(o),h=this.openIdConfigResource.getTokenEndpoint(),u=await this.request(h,{method:"POST",headers:{Authorization:"Basic "+this.rs.stob64(`${t}:${n}`),"Content-Type":"application/x-www-form-urlencoded"},body:a}),c=await this.openIdConfigResource.getPublicKeys(),l=this.tokenValidator.decodeAndValidate({token:u.access_token,publicKeys:c,issuer:s,clientId:t,nonce:i}),f=this.tokenValidator.decodeAndValidate({token:u.id_token,publicKeys:c,issuer:s,clientId:t,nonce:i});return{accessToken:u.access_token,accessTokenPayload:l,idToken:u.id_token,idTokenPayload:f}}}},function(t,e,i){"use strict";(function(t){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -var n=i(8),r=i(9),s=i(10);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return b(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function b(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return w(this,t,e,i);case"latin1":case"binary":return E(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function N(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||B(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);B(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);B(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(7))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e,i){const n=i(1),r=i(15);t.exports=class{constructor({jwt:t=i(0)}={}){this.jwt=t}decodeAndValidate({token:t,publicKeys:e,issuer:i,clientId:s,nonce:o}){const a=Math.floor(Date.now()/1e3),h=t.split(".");if(3!==h.length)throw new r(`Invalid JWT token. Got only ${h.length} parts.`);const u=this.jwt.KJUR.jws.JWS.parse(t);if(!u.headerObj)throw new r(n.INVALID_TOKEN);const c=u.headerObj.kid,l=this.getPublicKey(e.keys,c),f=this.jwt.KEYUTIL.getKey(l);if(!this.jwt.KJUR.jws.JWS.verify(t,f,{alg:[n.TOKEN_ALG]}))throw new r(n.INVALID_SIGNATURE);if(u.payloadObj.exp{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e){t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t),this.publicKeys=e(this.getJwksEndpoint())}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}}])})); \ No newline at end of file +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["AppID"] = factory(); + else + root["AppID"] = factory(); +})(window, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./node_modules/base64-js/index.js": +/*!*****************************************!*\ + !*** ./node_modules/base64-js/index.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/base64-js/index.js?"); + +/***/ }), + +/***/ "./node_modules/buffer/index.js": +/*!**************************************!*\ + !*** ./node_modules/buffer/index.js ***! + \**************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("/* WEBPACK VAR INJECTION */(function(global) {/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n\n\nvar base64 = __webpack_require__(/*! base64-js */ \"./node_modules/base64-js/index.js\")\nvar ieee754 = __webpack_require__(/*! ieee754 */ \"./node_modules/ieee754/index.js\")\nvar isArray = __webpack_require__(/*! isarray */ \"./node_modules/isarray/index.js\")\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://AppID/./node_modules/buffer/index.js?"); + +/***/ }), + +/***/ "./node_modules/ieee754/index.js": +/*!***************************************!*\ + !*** ./node_modules/ieee754/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/ieee754/index.js?"); + +/***/ }), + +/***/ "./node_modules/isarray/index.js": +/*!***************************************!*\ + !*** ./node_modules/isarray/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n\n\n//# sourceURL=webpack://AppID/./node_modules/isarray/index.js?"); + +/***/ }), + +/***/ "./node_modules/jsrsasign/lib/jsrsasign.js": +/*!*************************************************!*\ + !*** ./node_modules/jsrsasign/lib/jsrsasign.js ***! + \*************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\nvar navigator = {};\nnavigator.userAgent = false;\n\nvar window = {};\n/*\n * jsrsasign(all) 8.0.12 (2018-04-22) (c) 2010-2018 Kenji Urushima | kjur.github.com/jsrsasign/license\n */\n\n/*!\nCopyright (c) 2011, Yahoo! Inc. All rights reserved.\nCode licensed under the BSD License:\nhttp://developer.yahoo.com/yui/license.html\nversion: 2.9.0\n*/\nif(YAHOO===undefined){var YAHOO={}}YAHOO.lang={extend:function(g,h,f){if(!h||!g){throw new Error(\"YAHOO.lang.extend failed, please check that all dependencies are included.\")}var d=function(){};d.prototype=h.prototype;g.prototype=new d();g.prototype.constructor=g;g.superclass=h.prototype;if(h.prototype.constructor==Object.prototype.constructor){h.prototype.constructor=h}if(f){var b;for(b in f){g.prototype[b]=f[b]}var e=function(){},c=[\"toString\",\"valueOf\"];try{if(/MSIE/.test(navigator.userAgent)){e=function(j,i){for(b=0;b>>2]>>>(24-(r%4)*8))&255;q[(n+r)>>>2]|=o<<(24-((n+r)%4)*8)}}else{for(var r=0;r>>2]=p[r>>>2]}}this.sigBytes+=s;return this},clamp:function(){var o=this.words;var n=this.sigBytes;o[n>>>2]&=4294967295<<(32-(n%4)*8);o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);n.words=this.words.slice(0);return n},random:function(p){var o=[];for(var n=0;n>>2]>>>(24-(n%4)*8))&255;q.push((s>>>4).toString(16));q.push((s&15).toString(16))}return q.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>3]|=parseInt(p.substr(o,2),16)<<(24-(o%8)*4)}return new l.init(q,n/2)}};var d=m.Latin1={stringify:function(q){var r=q.words;var p=q.sigBytes;var n=[];for(var o=0;o>>2]>>>(24-(o%4)*8))&255;n.push(String.fromCharCode(s))}return n.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>2]|=(p.charCodeAt(o)&255)<<(24-(o%4)*8)}return new l.init(q,n)}};var c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error(\"Malformed UTF-8 data\")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}};var i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init();this._nDataBytes=0},_append:function(n){if(typeof n==\"string\"){n=c.parse(n)}this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data;var x=q.words;var n=q.sigBytes;var t=this.blockSize;var v=t*4;var u=n/v;if(w){u=e.ceil(u)}else{u=e.max((u|0)-this._minBufferSize,0)}var s=u*t;var r=e.min(s*4,n);if(s){for(var p=0;p>>2]&255}};f.BlockCipher=n.extend({cfg:n.cfg.extend({mode:m,padding:h}),reset:function(){n.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;\nthis._mode=c.call(a,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var p=f.CipherParams=k.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(g.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;\nreturn(a?l.create([1398893684,1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=l.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return p.create({ciphertext:a,salt:c})}},j=f.SerializableCipher=k.extend({cfg:k.extend({format:m}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return p.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,\nblockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return\"string\"==typeof a?b.parse(a,this):a}}),g=(g.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=l.random(8));a=v.create({keySize:b+c}).compute(a,d);c=l.create(a.words.slice(b),4*c);a.sigBytes=4*b;return p.create({key:a,iv:c,salt:d})}},s=f.PasswordBasedCipher=j.extend({cfg:j.cfg.extend({kdf:g}),encrypt:function(a,\nb,c,d){d=this.cfg.extend(d);c=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=c.iv;a=j.encrypt.call(this,a,b,c.key,d);a.mixIn(c);return a},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=c.iv;return j.decrypt.call(this,a,b,c.key,d)}})}();\n\n/*\nCryptoJS v3.1.2 aes.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){for(var q=CryptoJS,x=q.lib.BlockCipher,r=q.algo,j=[],y=[],z=[],A=[],B=[],C=[],s=[],u=[],v=[],w=[],g=[],k=0;256>k;k++)g[k]=128>k?k<<1:k<<1^283;for(var n=0,l=0,k=0;256>k;k++){var f=l^l<<1^l<<2^l<<3^l<<4,f=f>>>8^f&255^99;j[n]=f;y[f]=n;var t=g[n],D=g[t],E=g[D],b=257*g[f]^16843008*f;z[n]=b<<24|b>>>8;A[n]=b<<16|b>>>16;B[n]=b<<8|b>>>24;C[n]=b;b=16843009*E^65537*D^257*t^16843008*n;s[f]=b<<24|b>>>8;u[f]=b<<16|b>>>16;v[f]=b<<8|b>>>24;w[f]=b;n?(n=t^g[g[g[E^t]]],l^=g[g[l]]):n=l=1}var F=[0,1,2,4,8,\n16,32,64,128,27,54],r=r.AES=x.extend({_doReset:function(){for(var c=this._key,e=c.words,a=c.sigBytes/4,c=4*((this._nRounds=a+6)+1),b=this._keySchedule=[],h=0;h>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255]):(d=d<<8|d>>>24,d=j[d>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255],d^=F[h/a|0]<<24);b[h]=b[h-a]^d}e=this._invKeySchedule=[];for(a=0;aa||4>=h?d:s[j[d>>>24]]^u[j[d>>>16&255]]^v[j[d>>>\n8&255]]^w[j[d&255]]},encryptBlock:function(c,e){this._doCryptBlock(c,e,this._keySchedule,z,A,B,C,j)},decryptBlock:function(c,e){var a=c[e+1];c[e+1]=c[e+3];c[e+3]=a;this._doCryptBlock(c,e,this._invKeySchedule,s,u,v,w,y);a=c[e+1];c[e+1]=c[e+3];c[e+3]=a},_doCryptBlock:function(c,e,a,b,h,d,j,m){for(var n=this._nRounds,f=c[e]^a[0],g=c[e+1]^a[1],k=c[e+2]^a[2],p=c[e+3]^a[3],l=4,t=1;t>>24]^h[g>>>16&255]^d[k>>>8&255]^j[p&255]^a[l++],r=b[g>>>24]^h[k>>>16&255]^d[p>>>8&255]^j[f&255]^a[l++],s=\nb[k>>>24]^h[p>>>16&255]^d[f>>>8&255]^j[g&255]^a[l++],p=b[p>>>24]^h[f>>>16&255]^d[g>>>8&255]^j[k&255]^a[l++],f=q,g=r,k=s;q=(m[f>>>24]<<24|m[g>>>16&255]<<16|m[k>>>8&255]<<8|m[p&255])^a[l++];r=(m[g>>>24]<<24|m[k>>>16&255]<<16|m[p>>>8&255]<<8|m[f&255])^a[l++];s=(m[k>>>24]<<24|m[p>>>16&255]<<16|m[f>>>8&255]<<8|m[g&255])^a[l++];p=(m[p>>>24]<<24|m[f>>>16&255]<<16|m[g>>>8&255]<<8|m[k&255])^a[l++];c[e]=q;c[e+1]=r;c[e+2]=s;c[e+3]=p},keySize:8});q.AES=x._createHelper(r)})();\n\n/*\nCryptoJS v3.1.2 tripledes-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function j(b,c){var a=(this._lBlock>>>b^this._rBlock)&c;this._rBlock^=a;this._lBlock^=a<>>b^this._lBlock)&c;this._lBlock^=a;this._rBlock^=a<a;a++){var f=q[a]-1;c[a]=b[f>>>5]>>>31-f%32&1}b=this._subKeys=[];for(f=0;16>f;f++){for(var d=b[f]=[],e=r[f],a=0;24>a;a++)d[a/6|0]|=c[(p[a]-1+e)%28]<<31-a%6,d[4+(a/6|0)]|=c[28+(p[a+24]-1+e)%28]<<31-a%6;d[0]=d[0]<<1|d[0]>>>31;for(a=1;7>a;a++)d[a]>>>=\n4*(a-1)+3;d[7]=d[7]<<5|d[7]>>>27}c=this._invSubKeys=[];for(a=0;16>a;a++)c[a]=b[15-a]},encryptBlock:function(b,c){this._doCryptBlock(b,c,this._subKeys)},decryptBlock:function(b,c){this._doCryptBlock(b,c,this._invSubKeys)},_doCryptBlock:function(b,c,a){this._lBlock=b[c];this._rBlock=b[c+1];j.call(this,4,252645135);j.call(this,16,65535);l.call(this,2,858993459);l.call(this,8,16711935);j.call(this,1,1431655765);for(var f=0;16>f;f++){for(var d=a[f],e=this._lBlock,h=this._rBlock,g=0,k=0;8>k;k++)g|=s[k][((h^\nd[k])&t[k])>>>0];this._lBlock=h;this._rBlock=e^g}a=this._lBlock;this._lBlock=this._rBlock;this._rBlock=a;j.call(this,1,1431655765);l.call(this,8,16711935);l.call(this,2,858993459);j.call(this,16,65535);j.call(this,4,252645135);b[c]=this._lBlock;b[c+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});h.DES=e._createHelper(m);g=g.TripleDES=e.extend({_doReset:function(){var b=this._key.words;this._des1=m.createEncryptor(n.create(b.slice(0,2)));this._des2=m.createEncryptor(n.create(b.slice(2,4)));this._des3=\nm.createEncryptor(n.create(b.slice(4,6)))},encryptBlock:function(b,c){this._des1.encryptBlock(b,c);this._des2.decryptBlock(b,c);this._des3.encryptBlock(b,c)},decryptBlock:function(b,c){this._des3.decryptBlock(b,c);this._des2.encryptBlock(b,c);this._des1.decryptBlock(b,c)},keySize:6,ivSize:2,blockSize:2});h.TripleDES=e._createHelper(g)})();\n\n/*\nCryptoJS v3.1.2 enc-base64.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join(\"\")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d<\ne;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\"}})();\n\n/*\nCryptoJS v3.1.2 md5.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(E){function h(a,f,g,j,p,h,k){a=a+(f&g|~f&j)+p+k;return(a<>>32-h)+f}function k(a,f,g,j,p,h,k){a=a+(f&j|g&~j)+p+k;return(a<>>32-h)+f}function l(a,f,g,j,h,k,l){a=a+(f^g^j)+h+l;return(a<>>32-k)+f}function n(a,f,g,j,h,k,l){a=a+(g^(f|~j))+h+l;return(a<>>32-k)+f}for(var r=CryptoJS,q=r.lib,F=q.WordArray,s=q.Hasher,q=r.algo,a=[],t=0;64>t;t++)a[t]=4294967296*E.abs(E.sin(t+1))|0;q=q.MD5=s.extend({_doReset:function(){this._hash=new F.init([1732584193,4023233417,2562383102,271733878])},\n_doProcessBlock:function(m,f){for(var g=0;16>g;g++){var j=f+g,p=m[j];m[j]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360}var g=this._hash.words,j=m[f+0],p=m[f+1],q=m[f+2],r=m[f+3],s=m[f+4],t=m[f+5],u=m[f+6],v=m[f+7],w=m[f+8],x=m[f+9],y=m[f+10],z=m[f+11],A=m[f+12],B=m[f+13],C=m[f+14],D=m[f+15],b=g[0],c=g[1],d=g[2],e=g[3],b=h(b,c,d,e,j,7,a[0]),e=h(e,b,c,d,p,12,a[1]),d=h(d,e,b,c,q,17,a[2]),c=h(c,d,e,b,r,22,a[3]),b=h(b,c,d,e,s,7,a[4]),e=h(e,b,c,d,t,12,a[5]),d=h(d,e,b,c,u,17,a[6]),c=h(c,d,e,b,v,22,a[7]),\nb=h(b,c,d,e,w,7,a[8]),e=h(e,b,c,d,x,12,a[9]),d=h(d,e,b,c,y,17,a[10]),c=h(c,d,e,b,z,22,a[11]),b=h(b,c,d,e,A,7,a[12]),e=h(e,b,c,d,B,12,a[13]),d=h(d,e,b,c,C,17,a[14]),c=h(c,d,e,b,D,22,a[15]),b=k(b,c,d,e,p,5,a[16]),e=k(e,b,c,d,u,9,a[17]),d=k(d,e,b,c,z,14,a[18]),c=k(c,d,e,b,j,20,a[19]),b=k(b,c,d,e,t,5,a[20]),e=k(e,b,c,d,y,9,a[21]),d=k(d,e,b,c,D,14,a[22]),c=k(c,d,e,b,s,20,a[23]),b=k(b,c,d,e,x,5,a[24]),e=k(e,b,c,d,C,9,a[25]),d=k(d,e,b,c,r,14,a[26]),c=k(c,d,e,b,w,20,a[27]),b=k(b,c,d,e,B,5,a[28]),e=k(e,b,\nc,d,q,9,a[29]),d=k(d,e,b,c,v,14,a[30]),c=k(c,d,e,b,A,20,a[31]),b=l(b,c,d,e,t,4,a[32]),e=l(e,b,c,d,w,11,a[33]),d=l(d,e,b,c,z,16,a[34]),c=l(c,d,e,b,C,23,a[35]),b=l(b,c,d,e,p,4,a[36]),e=l(e,b,c,d,s,11,a[37]),d=l(d,e,b,c,v,16,a[38]),c=l(c,d,e,b,y,23,a[39]),b=l(b,c,d,e,B,4,a[40]),e=l(e,b,c,d,j,11,a[41]),d=l(d,e,b,c,r,16,a[42]),c=l(c,d,e,b,u,23,a[43]),b=l(b,c,d,e,x,4,a[44]),e=l(e,b,c,d,A,11,a[45]),d=l(d,e,b,c,D,16,a[46]),c=l(c,d,e,b,q,23,a[47]),b=n(b,c,d,e,j,6,a[48]),e=n(e,b,c,d,v,10,a[49]),d=n(d,e,b,c,\nC,15,a[50]),c=n(c,d,e,b,t,21,a[51]),b=n(b,c,d,e,A,6,a[52]),e=n(e,b,c,d,r,10,a[53]),d=n(d,e,b,c,y,15,a[54]),c=n(c,d,e,b,p,21,a[55]),b=n(b,c,d,e,w,6,a[56]),e=n(e,b,c,d,D,10,a[57]),d=n(d,e,b,c,u,15,a[58]),c=n(c,d,e,b,B,21,a[59]),b=n(b,c,d,e,s,6,a[60]),e=n(e,b,c,d,z,10,a[61]),d=n(d,e,b,c,q,15,a[62]),c=n(c,d,e,b,x,21,a[63]);g[0]=g[0]+b|0;g[1]=g[1]+c|0;g[2]=g[2]+d|0;g[3]=g[3]+e|0},_doFinalize:function(){var a=this._data,f=a.words,g=8*this._nDataBytes,j=8*a.sigBytes;f[j>>>5]|=128<<24-j%32;var h=E.floor(g/\n4294967296);f[(j+64>>>9<<4)+15]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;f[(j+64>>>9<<4)+14]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360;a.sigBytes=4*(f.length+1);this._process();a=this._hash;f=a.words;for(g=0;4>g;g++)j=f[g],f[g]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=s.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=s._createHelper(q);r.HmacMD5=s._createHmacHelper(q)})(Math);\n\n/*\nCryptoJS v3.1.2 sha1-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var k=CryptoJS,b=k.lib,m=b.WordArray,l=b.Hasher,d=[],b=k.algo.SHA1=l.extend({_doReset:function(){this._hash=new m.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(n,p){for(var a=this._hash.words,e=a[0],f=a[1],h=a[2],j=a[3],b=a[4],c=0;80>c;c++){if(16>c)d[c]=n[p+c]|0;else{var g=d[c-3]^d[c-8]^d[c-14]^d[c-16];d[c]=g<<1|g>>>31}g=(e<<5|e>>>27)+b+d[c];g=20>c?g+((f&h|~f&j)+1518500249):40>c?g+((f^h^j)+1859775393):60>c?g+((f&h|f&j|h&j)-1894007588):g+((f^h^\nj)-899497514);b=j;j=h;h=f<<30|f>>>2;f=e;e=g}a[0]=a[0]+e|0;a[1]=a[1]+f|0;a[2]=a[2]+h|0;a[3]=a[3]+j|0;a[4]=a[4]+b|0},_doFinalize:function(){var b=this._data,d=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=Math.floor(a/4294967296);d[(e+64>>>9<<4)+15]=a;b.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var b=l.clone.call(this);b._hash=this._hash.clone();return b}});k.SHA1=l._createHelper(b);k.HmacSHA1=l._createHmacHelper(b)})();\n\n/*\nCryptoJS v3.1.2 sha256-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(k){for(var g=CryptoJS,h=g.lib,v=h.WordArray,j=h.Hasher,h=g.algo,s=[],t=[],u=function(q){return 4294967296*(q-(q|0))|0},l=2,b=0;64>b;){var d;a:{d=l;for(var w=k.sqrt(d),r=2;r<=w;r++)if(!(d%r)){d=!1;break a}d=!0}d&&(8>b&&(s[b]=u(k.pow(l,0.5))),t[b]=u(k.pow(l,1/3)),b++);l++}var n=[],h=h.SHA256=j.extend({_doReset:function(){this._hash=new v.init(s.slice(0))},_doProcessBlock:function(q,h){for(var a=this._hash.words,c=a[0],d=a[1],b=a[2],k=a[3],f=a[4],g=a[5],j=a[6],l=a[7],e=0;64>e;e++){if(16>e)n[e]=\nq[h+e]|0;else{var m=n[e-15],p=n[e-2];n[e]=((m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3)+n[e-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[e-16]}m=l+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&g^~f&j)+t[e]+n[e];p=((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&d^c&b^d&b);l=j;j=g;g=f;f=k+m|0;k=b;b=d;d=c;c=m+p|0}a[0]=a[0]+c|0;a[1]=a[1]+d|0;a[2]=a[2]+b|0;a[3]=a[3]+k|0;a[4]=a[4]+f|0;a[5]=a[5]+g|0;a[6]=a[6]+j|0;a[7]=a[7]+l|0},_doFinalize:function(){var d=this._data,b=d.words,a=8*this._nDataBytes,c=8*d.sigBytes;\nb[c>>>5]|=128<<24-c%32;b[(c+64>>>9<<4)+14]=k.floor(a/4294967296);b[(c+64>>>9<<4)+15]=a;d.sigBytes=4*b.length;this._process();return this._hash},clone:function(){var b=j.clone.call(this);b._hash=this._hash.clone();return b}});g.SHA256=j._createHelper(h);g.HmacSHA256=j._createHmacHelper(h)})(Math);\n\n/*\nCryptoJS v3.1.2 sha224-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var b=CryptoJS,d=b.lib.WordArray,a=b.algo,c=a.SHA256,a=a.SHA224=c.extend({_doReset:function(){this._hash=new d.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var a=c._doFinalize.call(this);a.sigBytes-=4;return a}});b.SHA224=c._createHelper(a);b.HmacSHA224=c._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 sha512-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function a(){return d.create.apply(d,arguments)}for(var n=CryptoJS,r=n.lib.Hasher,e=n.x64,d=e.Word,T=e.WordArray,e=n.algo,ea=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),\na(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,\n2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),\na(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,\n3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],w=0;80>w;w++)v[w]=a();e=e.SHA512=r.extend({_doReset:function(){this._hash=new T.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(a,d){for(var f=this._hash.words,\nF=f[0],e=f[1],n=f[2],r=f[3],G=f[4],H=f[5],I=f[6],f=f[7],w=F.high,J=F.low,X=e.high,K=e.low,Y=n.high,L=n.low,Z=r.high,M=r.low,$=G.high,N=G.low,aa=H.high,O=H.low,ba=I.high,P=I.low,ca=f.high,Q=f.low,k=w,g=J,z=X,x=K,A=Y,y=L,U=Z,B=M,l=$,h=N,R=aa,C=O,S=ba,D=P,V=ca,E=Q,m=0;80>m;m++){var s=v[m];if(16>m)var j=s.high=a[d+2*m]|0,b=s.low=a[d+2*m+1]|0;else{var j=v[m-15],b=j.high,p=j.low,j=(b>>>1|p<<31)^(b>>>8|p<<24)^b>>>7,p=(p>>>1|b<<31)^(p>>>8|b<<24)^(p>>>7|b<<25),u=v[m-2],b=u.high,c=u.low,u=(b>>>19|c<<13)^(b<<\n3|c>>>29)^b>>>6,c=(c>>>19|b<<13)^(c<<3|b>>>29)^(c>>>6|b<<26),b=v[m-7],W=b.high,t=v[m-16],q=t.high,t=t.low,b=p+b.low,j=j+W+(b>>>0

>>0?1:0),b=b+c,j=j+u+(b>>>0>>0?1:0),b=b+t,j=j+q+(b>>>0>>0?1:0);s.high=j;s.low=b}var W=l&R^~l&S,t=h&C^~h&D,s=k&z^k&A^z&A,T=g&x^g&y^x&y,p=(k>>>28|g<<4)^(k<<30|g>>>2)^(k<<25|g>>>7),u=(g>>>28|k<<4)^(g<<30|k>>>2)^(g<<25|k>>>7),c=ea[m],fa=c.high,da=c.low,c=E+((h>>>14|l<<18)^(h>>>18|l<<14)^(h<<23|l>>>9)),q=V+((l>>>14|h<<18)^(l>>>18|h<<14)^(l<<23|h>>>9))+(c>>>0>>0?1:\n0),c=c+t,q=q+W+(c>>>0>>0?1:0),c=c+da,q=q+fa+(c>>>0>>0?1:0),c=c+b,q=q+j+(c>>>0>>0?1:0),b=u+T,s=p+s+(b>>>0>>0?1:0),V=S,E=D,S=R,D=C,R=l,C=h,h=B+c|0,l=U+q+(h>>>0>>0?1:0)|0,U=A,B=y,A=z,y=x,z=k,x=g,g=c+b|0,k=q+s+(g>>>0>>0?1:0)|0}J=F.low=J+g;F.high=w+k+(J>>>0>>0?1:0);K=e.low=K+x;e.high=X+z+(K>>>0>>0?1:0);L=n.low=L+y;n.high=Y+A+(L>>>0>>0?1:0);M=r.low=M+B;r.high=Z+U+(M>>>0>>0?1:0);N=G.low=N+h;G.high=$+l+(N>>>0>>0?1:0);O=H.low=O+C;H.high=aa+R+(O>>>0>>0?1:0);P=I.low=P+D;\nI.high=ba+S+(P>>>0>>0?1:0);Q=f.low=Q+E;f.high=ca+V+(Q>>>0>>0?1:0)},_doFinalize:function(){var a=this._data,d=a.words,f=8*this._nDataBytes,e=8*a.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+128>>>10<<5)+30]=Math.floor(f/4294967296);d[(e+128>>>10<<5)+31]=f;a.sigBytes=4*d.length;this._process();return this._hash.toX32()},clone:function(){var a=r.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});n.SHA512=r._createHelper(e);n.HmacSHA512=r._createHmacHelper(e)})();\n\n/*\nCryptoJS v3.1.2 sha384-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,a=c.x64,b=a.Word,e=a.WordArray,a=c.algo,d=a.SHA512,a=a.SHA384=d.extend({_doReset:function(){this._hash=new e.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var a=d._doFinalize.call(this);a.sigBytes-=16;return a}});c.SHA384=\nd._createHelper(a);c.HmacSHA384=d._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 ripemd160-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n/*\n\n(c) 2012 by Cedric Mesnil. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n(function(){var q=CryptoJS,d=q.lib,n=d.WordArray,p=d.Hasher,d=q.algo,x=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),y=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),z=n.create([11,14,15,12,\n5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),A=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),B=n.create([0,1518500249,1859775393,2400959708,2840853838]),C=n.create([1352829926,1548603684,1836072691,\n2053994217,0]),d=d.RIPEMD160=p.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,v){for(var b=0;16>b;b++){var c=v+b,f=e[c];e[c]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360}var c=this._hash.words,f=B.words,d=C.words,n=x.words,q=y.words,p=z.words,w=A.words,t,g,h,j,r,u,k,l,m,s;u=t=c[0];k=g=c[1];l=h=c[2];m=j=c[3];s=r=c[4];for(var a,b=0;80>b;b+=1)a=t+e[v+n[b]]|0,a=16>b?a+((g^h^j)+f[0]):32>b?a+((g&h|~g&j)+f[1]):48>b?\na+(((g|~h)^j)+f[2]):64>b?a+((g&j|h&~j)+f[3]):a+((g^(h|~j))+f[4]),a|=0,a=a<>>32-p[b],a=a+r|0,t=r,r=j,j=h<<10|h>>>22,h=g,g=a,a=u+e[v+q[b]]|0,a=16>b?a+((k^(l|~m))+d[0]):32>b?a+((k&m|l&~m)+d[1]):48>b?a+(((k|~l)^m)+d[2]):64>b?a+((k&l|~k&m)+d[3]):a+((k^l^m)+d[4]),a|=0,a=a<>>32-w[b],a=a+s|0,u=s,s=m,m=l<<10|l>>>22,l=k,k=a;a=c[1]+h+m|0;c[1]=c[2]+j+s|0;c[2]=c[3]+r+u|0;c[3]=c[4]+t+k|0;c[4]=c[0]+g+l|0;c[0]=a},_doFinalize:function(){var e=this._data,d=e.words,b=8*this._nDataBytes,c=8*e.sigBytes;\nd[c>>>5]|=128<<24-c%32;d[(c+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;e.sigBytes=4*(d.length+1);this._process();e=this._hash;d=e.words;for(b=0;5>b;b++)c=d[b],d[b]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return e},clone:function(){var d=p.clone.call(this);d._hash=this._hash.clone();return d}});q.RIPEMD160=p._createHelper(d);q.HmacRIPEMD160=p._createHmacHelper(d)})(Math);\n\n/*\nCryptoJS v3.1.2 hmac.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,k=c.enc.Utf8;c.algo.HMAC=c.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;\"string\"==typeof b&&(b=k.parse(b));var c=a.blockSize,e=4*c;b.sigBytes>e&&(b=a.finalize(b));b.clamp();for(var f=this._oKey=b.clone(),g=this._iKey=b.clone(),h=f.words,j=g.words,d=0;d>6)+b64map.charAt(e&63)}if(b+1==d.length){e=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(e<<2)}else{if(b+2==d.length){e=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(e>>2)+b64map.charAt((e&3)<<4)}}if(b64pad){while((a.length&3)>0){a+=b64pad}}return a}function b64tohex(f){var d=\"\";var e;var b=0;var c;var a;for(e=0;e>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(e){var d=b64tohex(e);var c;var b=new Array();for(c=0;2*c=0){var d=a*this[f++]+b[e]+h;h=Math.floor(d/67108864);b[e++]=d&67108863}return h}function am2(f,q,r,e,o,a){var k=q&32767,p=q>>15;while(--a>=0){var d=this[f]&32767;var g=this[f++]>>15;var b=p*d+g*k;d=k*d+((b&32767)<<15)+r[e]+(o&1073741823);o=(d>>>30)+(b>>>15)+p*g+(o>>>30);r[e++]=d&1073741823}return o}function am3(f,q,r,e,o,a){var k=q&16383,p=q>>14;while(--a>=0){var d=this[f]&16383;var g=this[f++]>>14;var b=p*d+g*k;d=k*d+((b&16383)<<14)+r[e]+o;o=(d>>28)+(b>>14)+p*g;r[e++]=d&268435455}return o}if(j_lm&&(navigator.appName==\"Microsoft Internet Explorer\")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator.appName!=\"Netscape\")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=((1<=0;--a){b[a]=this[a]}b.t=this.t;b.s=this.s}function bnpFromInt(a){this.t=1;this.s=(a<0)?-1:0;if(a>0){this[0]=a}else{if(a<-1){this[0]=a+this.DV}else{this.t=0}}}function nbv(a){var b=nbi();b.fromInt(a);return b}function bnpFromString(h,c){var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==256){e=8}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{this.fromRadix(h,c);return}}}}}}this.t=0;this.s=0;var g=h.length,d=false,f=0;while(--g>=0){var a=(e==8)?h[g]&255:intAt(h,g);if(a<0){if(h.charAt(g)==\"-\"){d=true}continue}d=false;if(f==0){this[this.t++]=a}else{if(f+e>this.DB){this[this.t-1]|=(a&((1<<(this.DB-f))-1))<>(this.DB-f))}else{this[this.t-1]|=a<=this.DB){f-=this.DB}}if(e==8&&(h[0]&128)!=0){this.s=-1;if(f>0){this[this.t-1]|=((1<<(this.DB-f))-1)<0&&this[this.t-1]==a){--this.t}}function bnToString(c){if(this.s<0){return\"-\"+this.negate().toString(c)}var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{return this.toRadix(c)}}}}}var g=(1<0){if(j>j)>0){a=true;h=int2char(l)}while(f>=0){if(j>(j+=this.DB-e)}else{l=(this[f]>>(j-=e))&g;if(j<=0){j+=this.DB;--f}}if(l>0){a=true}if(a){h+=int2char(l)}}}return a?h:\"0\"}function bnNegate(){var a=nbi();BigInteger.ZERO.subTo(this,a);return a}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(b){var d=this.s-b.s;if(d!=0){return d}var c=this.t;d=c-b.t;if(d!=0){return(this.s<0)?-d:d}while(--c>=0){if((d=this[c]-b[c])!=0){return d}}return 0}function nbits(a){var c=1,b;if((b=a>>>16)!=0){a=b;c+=16}if((b=a>>8)!=0){a=b;c+=8}if((b=a>>4)!=0){a=b;c+=4}if((b=a>>2)!=0){a=b;c+=2}if((b=a>>1)!=0){a=b;c+=1}return c}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(c,b){var a;for(a=this.t-1;a>=0;--a){b[a+c]=this[a]}for(a=c-1;a>=0;--a){b[a]=0}b.t=this.t+c;b.s=this.s}function bnpDRShiftTo(c,b){for(var a=c;a=0;--d){e[d+f+1]=(this[d]>>a)|h;h=(this[d]&g)<=0;--d){e[d]=0}e[f]=h;e.t=this.t+f+1;e.s=this.s;e.clamp()}function bnpRShiftTo(g,d){d.s=this.s;var e=Math.floor(g/this.DB);if(e>=this.t){d.t=0;return}var b=g%this.DB;var a=this.DB-b;var f=(1<>b;for(var c=e+1;c>b}if(b>0){d[this.t-e-1]|=(this.s&f)<>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g-=d.s}f.s=(g<0)?-1:0;if(g<-1){f[e++]=this.DV+g}else{if(g>0){f[e++]=g}}f.t=e;f.clamp()}function bnpMultiplyTo(c,e){var b=this.abs(),f=c.abs();var d=b.t;e.t=d+f.t;while(--d>=0){e[d]=0}for(d=0;d=0){d[b]=0}for(b=0;b=a.DV){d[b+a.t]-=a.DV;d[b+a.t+1]=1}}if(d.t>0){d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)}d.s=0;d.clamp()}function bnpDivRemTo(n,h,g){var w=n.abs();if(w.t<=0){return}var k=this.abs();if(k.t0){w.lShiftTo(v,d);k.lShiftTo(v,g)}else{w.copyTo(d);k.copyTo(g)}var p=d.t;var b=d[p-1];if(b==0){return}var o=b*(1<1)?d[p-2]>>this.F2:0);var A=this.FV/o,z=(1<=0){g[g.t++]=1;g.subTo(f,g)}BigInteger.ONE.dlShiftTo(p,f);f.subTo(d,d);while(d.t=0){var c=(g[--u]==b)?this.DM:Math.floor(g[u]*A+(g[u-1]+x)*z);if((g[u]+=d.am(0,c,g,s,0,p))0){g.rShiftTo(v,g)}if(a<0){BigInteger.ZERO.subTo(g,g)}}function bnMod(b){var c=nbi();this.abs().divRemTo(b,null,c);if(this.s<0&&c.compareTo(BigInteger.ZERO)>0){b.subTo(c,c)}return c}function Classic(a){this.m=a}function cConvert(a){if(a.s<0||a.compareTo(this.m)>=0){return a.mod(this.m)}else{return a}}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var a=this[0];if((a&1)==0){return 0}var b=a&3;b=(b*(2-(a&15)*b))&15;b=(b*(2-(a&255)*b))&255;b=(b*(2-(((a&65535)*b)&65535)))&65535;b=(b*(2-a*b%this.DV))%this.DV;return(b>0)?this.DV-b:-b}function Montgomery(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(a.DB-15))-1;this.mt2=2*a.t}function montConvert(a){var b=nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);if(a.s<0&&b.compareTo(BigInteger.ZERO)>0){this.m.subTo(b,b)}return b}function montRevert(a){var b=nbi();a.copyTo(b);this.reduce(b);return b}function montReduce(a){while(a.t<=this.mt2){a[a.t++]=0}for(var c=0;c>15)*this.mpl)&this.um)<<15))&a.DM;b=c+this.m.t;a[b]+=this.m.am(0,d,a,c,0,this.m.t);while(a[b]>=a.DV){a[b]-=a.DV;a[++b]++}}a.clamp();a.drShiftTo(this.m.t,a);if(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(h,j){if(h>4294967295||h<1){return BigInteger.ONE}var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;d.copyTo(f);while(--c>=0){j.sqrTo(f,a);if((h&(1<0){j.mulTo(a,d,f)}else{var b=f;f=a;a=b}}return j.revert(f)}function bnModPowInt(b,a){var c;if(b<256||a.isEven()){c=new Classic(a)}else{c=new Montgomery(a)}return this.exp(b,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction bnClone(){var a=nbi();this.copyTo(a);return a}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this[0]}else{if(this.t==0){return 0}}}return((this[1]&((1<<(32-this.DB))-1))<>24}function bnShortValue(){return(this.t==0)?this.s:(this[0]<<16)>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this[0]<=0)){return 0}else{return 1}}}function bnpToRadix(c){if(c==null){c=10}if(this.signum()==0||c<2||c>36){return\"0\"}var f=this.chunkSize(c);var e=Math.pow(c,f);var i=nbv(e),j=nbi(),h=nbi(),g=\"\";this.divRemTo(i,j,h);while(j.signum()>0){g=(e+h.intValue()).toString(c).substr(1)+g;j.divRemTo(i,j,h)}return h.intValue().toString(c)+g}function bnpFromRadix(m,h){this.fromInt(0);if(h==null){h=10}var f=this.chunkSize(h);var g=Math.pow(h,f),e=false,a=0,l=0;for(var c=0;c=f){this.dMultiply(g);this.dAddOffset(l,0);a=0;l=0}}if(a>0){this.dMultiply(Math.pow(h,a));this.dAddOffset(l,0)}if(e){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(f,e,h){if(\"number\"==typeof e){if(f<2){this.fromInt(1)}else{this.fromNumber(f,h);if(!this.testBit(f-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(f-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(e)){this.dAddOffset(2,0);if(this.bitLength()>f){this.subTo(BigInteger.ONE.shiftLeft(f-1),this)}}}}else{var d=new Array(),g=f&7;d.length=(f>>3)+1;e.nextBytes(d);if(g>0){d[0]&=((1<0){if(e>e)!=(this.s&this.DM)>>e){c[a++]=f|(this.s<<(this.DB-e))}while(b>=0){if(e<8){f=(this[b]&((1<>(e+=this.DB-8)}else{f=(this[b]>>(e-=8))&255;if(e<=0){e+=this.DB;--b}}if((f&128)!=0){f|=-256}if(a==0&&(this.s&128)!=(f&128)){++a}if(a>0||f!=this.s){c[a++]=f}}}return c}function bnEquals(b){return(this.compareTo(b)==0)}function bnMin(b){return(this.compareTo(b)<0)?this:b}function bnMax(b){return(this.compareTo(b)>0)?this:b}function bnpBitwiseTo(c,h,e){var d,g,b=Math.min(c.t,this.t);for(d=0;d>=16;b+=16}if((a&255)==0){a>>=8;b+=8}if((a&15)==0){a>>=4;b+=4}if((a&3)==0){a>>=2;b+=2}if((a&1)==0){++b}return b}function bnGetLowestSetBit(){for(var a=0;a=this.t){return(this.s!=0)}return((this[a]&(1<<(b%this.DB)))!=0)}function bnpChangeBit(c,b){var a=BigInteger.ONE.shiftLeft(c);this.bitwiseTo(a,b,a);return a}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(d,f){var e=0,g=0,b=Math.min(d.t,this.t);while(e>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g+=d.s}f.s=(g<0)?-1:0;if(g>0){f[e++]=g}else{if(g<-1){f[e++]=this.DV+g}}f.t=e;f.clamp()}function bnAdd(b){var c=nbi();this.addTo(b,c);return c}function bnSubtract(b){var c=nbi();this.subTo(b,c);return c}function bnMultiply(b){var c=nbi();this.multiplyTo(b,c);return c}function bnSquare(){var a=nbi();this.squareTo(a);return a}function bnDivide(b){var c=nbi();this.divRemTo(b,c,null);return c}function bnRemainder(b){var c=nbi();this.divRemTo(b,null,c);return c}function bnDivideAndRemainder(b){var d=nbi(),c=nbi();this.divRemTo(b,d,c);return new Array(d,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(b,a){if(b==0){return}while(this.t<=a){this[this.t++]=0}this[a]+=b;while(this[a]>=this.DV){this[a]-=this.DV;if(++a>=this.t){this[this.t++]=0}++this[a]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,c,b){a.multiplyTo(c,b)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp())}function bnpMultiplyLowerTo(b,f,e){var d=Math.min(this.t+b.t,f);e.s=0;e.t=d;while(d>0){e[--d]=0}var c;for(c=e.t-this.t;d=0){d[c]=0}for(c=Math.max(e-this.t,0);c2*this.m.t){return a.mod(this.m)}else{if(a.compareTo(this.m)<0){return a}else{var b=nbi();a.copyTo(b);this.reduce(b);return b}}}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1){a.t=this.m.t+1;a.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0){a.dAddOffset(1,this.m.t+1)}a.subTo(this.r2,a);while(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(q,f){var o=q.bitLength(),h,b=nbv(1),v;if(o<=0){return b}else{if(o<18){h=1}else{if(o<48){h=3}else{if(o<144){h=4}else{if(o<768){h=5}else{h=6}}}}}if(o<8){v=new Classic(f)}else{if(f.isEven()){v=new Barrett(f)}else{v=new Montgomery(f)}}var p=new Array(),d=3,s=h-1,a=(1<1){var A=nbi();v.sqrTo(p[1],A);while(d<=a){p[d]=nbi();v.mulTo(A,p[d-2],p[d]);d+=2}}var l=q.t-1,x,u=true,c=nbi(),y;o=nbits(q[l])-1;while(l>=0){if(o>=s){x=(q[l]>>(o-s))&a}else{x=(q[l]&((1<<(o+1))-1))<<(s-o);if(l>0){x|=q[l-1]>>(this.DB+o-s)}}d=h;while((x&1)==0){x>>=1;--d}if((o-=d)<0){o+=this.DB;--l}if(u){p[x].copyTo(b);u=false}else{while(d>1){v.sqrTo(b,c);v.sqrTo(c,b);d-=2}if(d>0){v.sqrTo(b,c)}else{y=b;b=c;c=y}v.mulTo(c,p[x],b)}while(l>=0&&(q[l]&(1<0){b.rShiftTo(f,b);h.rShiftTo(f,h)}while(b.signum()>0){if((d=b.getLowestSetBit())>0){b.rShiftTo(d,b)}if((d=h.getLowestSetBit())>0){h.rShiftTo(d,h)}if(b.compareTo(h)>=0){b.subTo(h,b);b.rShiftTo(1,b)}else{h.subTo(b,h);h.rShiftTo(1,h)}}if(f>0){h.lShiftTo(f,h)}return h}function bnpModInt(e){if(e<=0){return 0}var c=this.DV%e,b=(this.s<0)?e-1:0;if(this.t>0){if(c==0){b=this[0]%e}else{for(var a=this.t-1;a>=0;--a){b=(c*b+this[a])%e}}}return b}function bnModInverse(f){var j=f.isEven();if((this.isEven()&&j)||f.signum()==0){return BigInteger.ZERO}var i=f.clone(),h=this.clone();var g=nbv(1),e=nbv(0),l=nbv(0),k=nbv(1);while(i.signum()!=0){while(i.isEven()){i.rShiftTo(1,i);if(j){if(!g.isEven()||!e.isEven()){g.addTo(this,g);e.subTo(f,e)}g.rShiftTo(1,g)}else{if(!e.isEven()){e.subTo(f,e)}}e.rShiftTo(1,e)}while(h.isEven()){h.rShiftTo(1,h);if(j){if(!l.isEven()||!k.isEven()){l.addTo(this,l);k.subTo(f,k)}l.rShiftTo(1,l)}else{if(!k.isEven()){k.subTo(f,k)}}k.rShiftTo(1,k)}if(i.compareTo(h)>=0){i.subTo(h,i);if(j){g.subTo(l,g)}e.subTo(k,e)}else{h.subTo(i,h);if(j){l.subTo(g,l)}k.subTo(e,k)}}if(h.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(k.compareTo(f)>=0){return k.subtract(f)}if(k.signum()<0){k.addTo(f,k)}else{return k}if(k.signum()<0){return k.add(f)}else{return k}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(e){var d,b=this.abs();if(b.t==1&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d>1;if(f>lowprimes.length){f=lowprimes.length}var b=nbi();for(var e=0;e>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(window!==undefined&&(window.crypto!==undefined||window.msCrypto!==undefined)){var crypto=window.crypto||window.msCrypto;if(crypto.getRandomValues){var ua=new Uint8Array(32);crypto.getRandomValues(ua);for(t=0;t<32;++t){rng_pool[rng_pptr++]=ua[t]}}else{if(navigator.appName==\"Netscape\"&&navigator.appVersion<\"5\"){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr=0&&h>0){var f=e.charCodeAt(d--);if(f<128){g[--h]=f}else{if((f>127)&&(f<2048)){g[--h]=(f&63)|128;g[--h]=(f>>6)|192}else{g[--h]=(f&63)|128;g[--h]=((f>>6)&63)|128;g[--h]=(f>>12)|224}}}g[--h]=0;var b=new SecureRandom();var a=new Array();while(h>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}g[--h]=a[0]}g[--h]=2;g[--h]=0;return new BigInteger(g)}function oaep_mgf1_arr(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255])));d+=1}return b}function oaep_pad(q,a,f,l){var c=KJUR.crypto.MessageDigest;var o=KJUR.crypto.Util;var b=null;if(!f){f=\"sha1\"}if(typeof f===\"string\"){b=c.getCanonicalAlgName(f);l=c.getHashLength(b);f=function(i){return hextorstr(o.hashHex(rstrtohex(i),b))}}if(q.length+2*l+2>a){throw\"Message too long for RSA\"}var k=\"\",e;for(e=0;e0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{throw\"Invalid RSA public key\"}}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var e=this.doPublic(a);if(e==null){return null}var b=e.toString(16);if((b.length&1)==0){return b}else{return\"0\"+b}}function RSAEncryptOAEP(f,e,b){var a=oaep_pad(f,(this.n.bitLength()+7)>>3,e,b);if(a==null){return null}var g=this.doPublic(a);if(g==null){return null}var d=g.toString(16);if((d.length&1)==0){return d}else{return\"0\"+d}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;RSAKey.prototype.encryptOAEP=RSAEncryptOAEP;RSAKey.prototype.type=\"RSA\";\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction pkcs1unpad2(g,j){var a=g.toByteArray();var f=0;while(f=a.length){return null}}var e=\"\";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}function oaep_unpad(o,b,g,p){var e=KJUR.crypto.MessageDigest;var r=KJUR.crypto.Util;var c=null;if(!g){g=\"sha1\"}if(typeof g===\"string\"){c=e.getCanonicalAlgName(g);p=e.getHashLength(c);g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}}o=o.toByteArray();var h;for(h=0;h0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{throw\"Invalid RSA private key\"}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;this.isPublic=false;if(g==null){throw\"RSASetPrivateEx N == null\"}if(d==null){throw\"RSASetPrivateEx E == null\"}if(g.length==0){throw\"RSASetPrivateEx N.length == 0\"}if(d.length==0){throw\"RSASetPrivateEx E.length == 0\"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{throw\"Invalid RSA private key in RSASetPrivateEx\"}}function RSAGenerate(b,i){var a=new SecureRandom();var f=b>>1;this.e=parseInt(i,16);var c=new BigInteger(i,16);for(;;){for(;;){this.p=new BigInteger(b-f,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(f,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var h=this.p;this.p=this.q;this.q=h}var g=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var e=g.multiply(d);if(e.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(e);this.dmp1=this.d.mod(g);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=true}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}function RSADecryptOAEP(e,d,b){var f=parseBigInt(e,16);var a=this.doPrivate(f);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,d,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP;\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction ECFieldElementFp(b,a){this.x=a;this.q=b}function feFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.x.equals(a.x))}function feFpToBigInteger(){return this.x}function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))}function feFpAdd(a){return new ECFieldElementFp(this.q,this.x.add(a.toBigInteger()).mod(this.q))}function feFpSubtract(a){return new ECFieldElementFp(this.q,this.x.subtract(a.toBigInteger()).mod(this.q))}function feFpMultiply(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger()).mod(this.q))}function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))}function feFpDivide(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger().modInverse(this.q)).mod(this.q))}ECFieldElementFp.prototype.equals=feFpEquals;ECFieldElementFp.prototype.toBigInteger=feFpToBigInteger;ECFieldElementFp.prototype.negate=feFpNegate;ECFieldElementFp.prototype.add=feFpAdd;ECFieldElementFp.prototype.subtract=feFpSubtract;ECFieldElementFp.prototype.multiply=feFpMultiply;ECFieldElementFp.prototype.square=feFpSquare;ECFieldElementFp.prototype.divide=feFpDivide;function ECPointFp(c,a,d,b){this.curve=c;this.x=a;this.y=d;if(b==null){this.z=BigInteger.ONE}else{this.z=b}this.zinv=null}function pointFpGetX(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpGetY(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpEquals(a){if(a==this){return true}if(this.isInfinity()){return a.isInfinity()}if(a.isInfinity()){return this.isInfinity()}var c,b;c=a.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(a.z)).mod(this.curve.q);if(!c.equals(BigInteger.ZERO)){return false}b=a.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(a.z)).mod(this.curve.q);return b.equals(BigInteger.ZERO)}function pointFpIsInfinity(){if((this.x==null)&&(this.y==null)){return true}return this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)}function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)}function pointFpAdd(l){if(this.isInfinity()){return l}if(l.isInfinity()){return this}var p=l.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(l.z)).mod(this.curve.q);var o=l.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(l.z)).mod(this.curve.q);if(BigInteger.ZERO.equals(o)){if(BigInteger.ZERO.equals(p)){return this.twice()}return this.curve.getInfinity()}var j=new BigInteger(\"3\");var e=this.x.toBigInteger();var n=this.y.toBigInteger();var c=l.x.toBigInteger();var k=l.y.toBigInteger();var m=o.square();var i=m.multiply(o);var d=e.multiply(m);var g=p.square().multiply(this.z);var a=g.subtract(d.shiftLeft(1)).multiply(l.z).subtract(i).multiply(o).mod(this.curve.q);var h=d.multiply(j).multiply(p).subtract(n.multiply(i)).subtract(g.multiply(p)).multiply(l.z).add(p.multiply(i)).mod(this.curve.q);var f=i.multiply(this.z).multiply(l.z).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),f)}function pointFpTwice(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var g=new BigInteger(\"3\");var c=this.x.toBigInteger();var h=this.y.toBigInteger();var e=h.multiply(this.z);var j=e.multiply(h).mod(this.curve.q);var i=this.curve.a.toBigInteger();var k=c.square().multiply(g);if(!BigInteger.ZERO.equals(i)){k=k.add(this.z.square().multiply(i))}k=k.mod(this.curve.q);var b=k.square().subtract(c.shiftLeft(3).multiply(j)).shiftLeft(1).multiply(e).mod(this.curve.q);var f=k.multiply(g).multiply(c).subtract(j.shiftLeft(1)).shiftLeft(2).multiply(j).subtract(k.square().multiply(k)).mod(this.curve.q);var d=e.square().multiply(e).shiftLeft(3).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(b),this.curve.fromBigInteger(f),d)}function pointFpMultiply(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add(a?this:l)}}return d}function pointFpMultiplyTwo(c,a,b){var d;if(c.bitLength()>b.bitLength()){d=c.bitLength()-1}else{d=b.bitLength()-1}var f=this.curve.getInfinity();var e=this.add(a);while(d>=0){f=f.twice();if(c.testBit(d)){if(b.testBit(d)){f=f.add(e)}else{f=f.add(this)}}else{if(b.testBit(d)){f=f.add(a)}}--d}return f}ECPointFp.prototype.getX=pointFpGetX;ECPointFp.prototype.getY=pointFpGetY;ECPointFp.prototype.equals=pointFpEquals;ECPointFp.prototype.isInfinity=pointFpIsInfinity;ECPointFp.prototype.negate=pointFpNegate;ECPointFp.prototype.add=pointFpAdd;ECPointFp.prototype.twice=pointFpTwice;ECPointFp.prototype.multiply=pointFpMultiply;ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo;function ECCurveFp(e,d,c){this.q=e;this.a=this.fromBigInteger(d);this.b=this.fromBigInteger(c);this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b))}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)}function curveFpDecodePointHex(d){switch(parseInt(d.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var a=(d.length-2)/2;var c=d.substr(2,a);var b=d.substr(a+2,a);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(b,16)));default:return null}}ECCurveFp.prototype.getQ=curveFpGetQ;ECCurveFp.prototype.getA=curveFpGetA;ECCurveFp.prototype.getB=curveFpGetB;ECCurveFp.prototype.equals=curveFpEquals;ECCurveFp.prototype.getInfinity=curveFpGetInfinity;ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger;ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex;\n/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib\n */\nECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};ECPointFp.prototype.getEncoded=function(c){var d=function(h,f){var g=h.toByteArrayUnsigned();if(fg.length){g.unshift(0)}}return g};var a=this.getX().toBigInteger();var e=this.getY().toBigInteger();var b=d(a,32);if(c){if(e.isEven()){b.unshift(2)}else{b.unshift(3)}}else{b.unshift(4);b=b.concat(d(e,32))}return b};ECPointFp.decodeFrom=function(g,c){var f=c[0];var e=c.length-1;var d=c.slice(1,1+e/2);var b=c.slice(1+e/2,1+e);d.unshift(0);b.unshift(0);var a=new BigInteger(d);var h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.decodeFromHex=function(g,c){var f=c.substr(0,2);var e=c.length-2;var d=c.substr(2,e/2);var b=c.substr(2+e/2,e/2);var a=new BigInteger(d,16);var h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.prototype.add2D=function(c){if(this.isInfinity()){return c}if(c.isInfinity()){return this}if(this.x.equals(c.x)){if(this.y.equals(c.y)){return this.twice()}return this.curve.getInfinity()}var g=c.x.subtract(this.x);var e=c.y.subtract(this.y);var a=e.divide(g);var d=a.square().subtract(this.x).subtract(c.x);var f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var b=this.curve.fromBigInteger(BigInteger.valueOf(2));var e=this.curve.fromBigInteger(BigInteger.valueOf(3));var a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b));var c=a.square().subtract(this.x.multiply(b));var d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)};ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add2D(a?this:l)}}return d};ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger();var i=this.getY().toBigInteger();var f=this.curve.getA().toBigInteger();var c=this.curve.getB().toBigInteger();var h=this.curve.getQ();var e=i.multiply(i).mod(h);var g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)};ECPointFp.prototype.toString=function(){return\"(\"+this.getX().toBigInteger().toString()+\",\"+this.getY().toBigInteger().toString()+\")\"};ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity()){throw new Error(\"Point is at infinity.\")}var a=this.getX().toBigInteger();var b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"x coordinate out of bounds\")}if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"y coordinate out of bounds\")}if(!this.isOnCurve()){throw new Error(\"Point is not on the curve.\")}if(this.multiply(c).isInfinity()){throw new Error(\"Point is not a scalar multiple of G.\")}return true};\n/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval\n */\nvar jsonParse=(function(){var e=\"(?:-?\\\\b(?:0|[1-9][0-9]*)(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\\\b)\";var j='(?:[^\\\\0-\\\\x08\\\\x0a-\\\\x1f\"\\\\\\\\]|\\\\\\\\(?:[\"/\\\\\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:\"'+j+'*\")';var d=new RegExp(\"(?:false|true|null|[\\\\{\\\\}\\\\[\\\\]]|\"+e+\"|\"+i+\")\",\"g\");var k=new RegExp(\"\\\\\\\\(?:([^u])|u(.{4}))\",\"g\");var g={'\"':'\"',\"/\":\"/\",\"\\\\\":\"\\\\\",b:\"\\b\",f:\"\\f\",n:\"\\n\",r:\"\\r\",t:\"\\t\"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String(\"\");var a=\"\\\\\";var f={\"{\":Object,\"[\":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if(\"{\"===v){x={}}else{if(\"[\"===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({\"\":x},\"\")}return x}})();\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.asn1==\"undefined\"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b=\"0\"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!=\"-\"){if(f.length%2==1){f=\"0\"+f}else{if(!f.match(/^[0-7]/)){f=\"00\"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g=\"\";for(var d=0;d15){throw\"ASN.1 length too long to represent by 8x: n = \"+i.toString(16)}var f=128+g;return f.toString(16)+h}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return\"\"}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!=\"undefined\"){if(typeof c==\"string\"){this.setString(c)}else{if(typeof c.str!=\"undefined\"){this.setString(c.str)}else{if(typeof c.hex!=\"undefined\"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(f){utc=f.getTime()+(f.getTimezoneOffset()*60000);var e=new Date(utc);return e};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o==\"utc\"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,\"\");r=r+\".\"+k}}return r+\"Z\"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join(\"0\")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!=\"undefined\"){if(typeof b.array!=\"undefined\"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT=\"01\";this.hTLV=\"0101ff\"};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT=\"02\";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!=\"undefined\"){if(typeof a.bigint!=\"undefined\"){this.setByBigInteger(a.bigint)}else{if(typeof a[\"int\"]!=\"undefined\"){this.setByInteger(a[\"int\"])}else{if(typeof a==\"number\"){this.setByInteger(a)}else{if(typeof a.hex!=\"undefined\"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!==\"undefined\"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex=\"00\"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT=\"03\";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=(l*2))){break}if(d>=200){break}g.push(b);c=b;d++}return g};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){throw\"checking tag doesn't match: \"+e.substr(d,2)+\"!=\"+i}}return d}f=c.shift();b=g.getChildIdx(e,d);return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getTLVbyList=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyList(d,c,b);if(a===undefined){throw\"can't find nthList object\"}if(f!==undefined){if(d.substr(a,2)!=f){throw\"checking tag doesn't match: \"+d.substr(a,2)+\"!=\"+f}}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a===undefined){throw\"can't find nthList object\"}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join(\"0\")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+\".\"+j.join(\".\")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+\"..(total \"+A.length/2+\"bytes)..\"+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=\"\"}var x=c.ommit_long_octet;if(e.substr(l,2)==\"01\"){var h=j(e,l);if(h==\"00\"){return g+\"BOOLEAN FALSE\\n\"}else{return g+\"BOOLEAN TRUE\\n\"}}if(e.substr(l,2)==\"02\"){var h=j(e,l);return g+\"INTEGER \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"03\"){var h=j(e,l);return g+\"BITSTRING \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"04\"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+\"OCTETSTRING, encapsulates\\n\";k=k+y(h,c,0,g+\" \");return k}else{return g+\"OCTETSTRING \"+q(h,x)+\"\\n\"}}if(e.substr(l,2)==\"05\"){return g+\"NULL\\n\"}if(e.substr(l,2)==\"06\"){var m=j(e,l);var a=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(a);var b=a.replace(/\\./g,\" \");if(o!=\"\"){return g+\"ObjectIdentifier \"+o+\" (\"+b+\")\\n\"}else{return g+\"ObjectIdentifier (\"+b+\")\\n\"}}if(e.substr(l,2)==\"0c\"){return g+\"UTF8String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"13\"){return g+\"PrintableString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"14\"){return g+\"TeletexString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"16\"){return g+\"IA5String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"17\"){return g+\"UTCTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"18\"){return g+\"GeneralizedTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"30\"){if(e.substr(l,4)==\"3000\"){return g+\"SEQUENCE {}\\n\"}var k=g+\"SEQUENCE\\n\";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)==\"06\"&&e.substr(d[d.length-1],2)==\"04\"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u0){var m=new f({array:this.extensionsArray});var k=new c({explicit:true,tag:\"a3\",obj:m});this.asn1Array.push(k)}var n=new f({array:this.asn1Array});this.hTLV=n.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension=function(d){KJUR.asn1.x509.Extension.superclass.constructor.call(this);var f=null,a=KJUR,e=a.asn1,h=e.DERObjectIdentifier,i=e.DEROctetString,b=e.DERBitString,g=e.DERBoolean,c=e.DERSequence;this.getEncodedHex=function(){var m=new h({oid:this.oid});var l=new i({hex:this.getExtnValueHex()});var k=new Array();k.push(m);if(this.critical){k.push(new g())}k.push(l);var j=new c({array:k});return j.getEncodedHex()};this.critical=false;if(d!==undefined){if(d.critical!==undefined){this.critical=d.critical}}};YAHOO.lang.extend(KJUR.asn1.x509.Extension,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension.appendByNameToArray=function(e,c,b){var g=e.toLowerCase(),f=KJUR.asn1.x509;if(g==\"basicconstraints\"){var d=new f.BasicConstraints(c);b.push(d)}else{if(g==\"keyusage\"){var d=new f.KeyUsage(c);b.push(d)}else{if(g==\"crldistributionpoints\"){var d=new f.CRLDistributionPoints(c);b.push(d)}else{if(g==\"extkeyusage\"){var d=new f.ExtKeyUsage(c);b.push(d)}else{if(g==\"authoritykeyidentifier\"){var d=new f.AuthorityKeyIdentifier(c);b.push(d)}else{if(g==\"authorityinfoaccess\"){var d=new f.AuthorityInfoAccess(c);b.push(d)}else{if(g==\"subjectaltname\"){var d=new f.SubjectAltName(c);b.push(d)}else{if(g==\"issueraltname\"){var d=new f.IssuerAltName(c);b.push(d)}else{throw\"unsupported extension name: \"+e}}}}}}}}};KJUR.asn1.x509.KeyUsage=function(f){KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this,f);var a=X509.KEYUSAGE_NAME;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.15\";if(f!==undefined){if(f.bin!==undefined){this.asn1ExtnValue=new KJUR.asn1.DERBitString(f)}if(f.names!==undefined&&f.names.length!==undefined){var e=f.names;var d=\"000000000\";for(var c=0;c-1){e.push(new KJUR.asn1.DERInteger({\"int\":this.pathLen}))}var d=new KJUR.asn1.DERSequence({array:e});this.asn1ExtnValue=d;return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.19\";this.cA=false;this.pathLen=-1;if(c!==undefined){if(c.cA!==undefined){this.cA=c.cA}if(c.pathLen!==undefined){this.pathLen=c.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){this.asn1ExtnValue=new a.DERSequence({array:e})};this.setByOneURI=function(h){var e=new c.GeneralNames([{uri:h}]);var g=new c.DistributionPointName(e);var f=new c.DistributionPoint({dpobj:g});this.setByDPArray([f])};this.oid=\"2.5.29.31\";if(d!==undefined){if(d.array!==undefined){this.setByDPArray(d.array)}else{if(d.uri!==undefined){this.setByOneURI(d.uri)}}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLDistributionPoints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.ExtKeyUsage=function(c){KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,c);var b=KJUR,a=b.asn1;this.setPurposeArray=function(d){this.asn1ExtnValue=new a.DERSequence();for(var e=0;e0){var h=new b({array:this.aRevokedCert});this.asn1Array.push(h)}var i=new b({array:this.asn1Array});this.hTLV=i.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize=function(){this.asn1Version=null;this.asn1SignatureAlg=null;this.asn1Issuer=null;this.asn1ThisUpdate=null;this.asn1NextUpdate=null;this.aRevokedCert=new Array()};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertList,KJUR.asn1.ASN1Object);KJUR.asn1.x509.CRLEntry=function(e){KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);var d=null,c=null,b=KJUR,a=b.asn1;this.setCertSerial=function(f){this.sn=new a.DERInteger(f)};this.setRevocationDate=function(f){this.time=new a.x509.Time(f)};this.getEncodedHex=function(){var f=new a.DERSequence({array:[this.sn,this.time]});this.TLV=f.getEncodedHex();return this.TLV};if(e!==undefined){if(e.time!==undefined){this.setRevocationDate(e.time)}if(e.sn!==undefined){this.setCertSerial(e.sn)}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLEntry,KJUR.asn1.ASN1Object);KJUR.asn1.x509.X500Name=function(f){KJUR.asn1.x509.X500Name.superclass.constructor.call(this);this.asn1Array=new Array();var d=KJUR,c=d.asn1,e=c.x509,b=pemtohex;this.setByString=function(g){var k=g.split(\"/\");k.shift();var j=[];for(var l=0;l0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+\",\"+h).replace(/\\\\,/g,\",\");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)===\"\\\\\"){e=true}}b=b.map(function(a){return a.replace(\"/\",\"\\\\/\")});b.reverse();return\"/\"+b.join(\"/\")};KJUR.asn1.x509.RDN=function(a){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=new Array();this.addByString=function(b){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:b}))};this.addByMultiValuedString=function(d){var b=KJUR.asn1.x509.RDN.parseString(d);for(var c=0;c0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+\"+\"+k).replace(/\\\\\\+/g,\"+\");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)===\"\\\\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/\"$/)){var d=(e+\"+\"+k).replace(/^([^=]+)=\"(.*)\"$/,\"$1=$2\");b.push(d);l=false}else{b.push(e+\"+\"+k)}}else{b.push(k)}if(k.match(/^[^=]+=\"/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(d){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var f=null,e=null,a=\"utf8\",c=KJUR,b=c.asn1;this.setByString=function(h){var g=h.match(/^([^=]+)=(.+)$/);if(g){this.setByAttrTypeAndValueStr(g[1],g[2])}else{throw\"malformed attrTypeAndValueStr: \"+h}};this.setByAttrTypeAndValueStr=function(i,h){this.typeObj=KJUR.asn1.x509.OID.atype2obj(i);var g=a;if(i==\"C\"){g=\"prn\"}this.valueObj=this.getValueObj(g,h)};this.getValueObj=function(h,g){if(h==\"utf8\"){return new b.DERUTF8String({str:g})}if(h==\"prn\"){return new b.DERPrintableString({str:g})}if(h==\"tel\"){return new b.DERTeletexString({str:g})}if(h==\"ia5\"){return new b.DERIA5String({str:g})}throw\"unsupported directory string type: type=\"+h+\" value=\"+g};this.getEncodedHex=function(){var g=new b.DERSequence({array:[this.typeObj,this.valueObj]});this.TLV=g.getEncodedHex();return this.TLV};if(d!==undefined){if(d.str!==undefined){this.setByString(d.str)}}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw\"algId and/or subjPubKey not set\"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{\"int\":{bigint:q.n}},{\"int\":{\"int\":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:\"rsaEncryption\"});this.asn1SubjPKey=new b({hex:\"00\"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:\"ecPublicKey\",asn1params:r});this.asn1SubjPKey=new b({hex:\"00\"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{\"int\":{bigint:q.p}},{\"int\":{bigint:q.q}},{\"int\":{bigint:q.g}}]});this.asn1AlgId=new o({name:\"dsa\",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:\"00\"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type==\"utc\"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type==\"utc\"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type=\"utc\";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type=\"utc\"}if(f.str.match(/^[0-9]{14}Z$/)){this.type=\"gen\"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(d){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw\"algorithm not specified\"}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var e=[this.asn1Alg];if(this.asn1Params!==null){e.push(this.asn1Params)}var f=new a.DERSequence({array:e});this.hTLV=f.getEncodedHex();return this.hTLV};if(d!==undefined){if(d.name!==undefined){this.nameAlg=d.name}if(d.asn1params!==undefined){this.asn1Params=d.asn1params}if(d.paramempty!==undefined){this.paramEmpty=d.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){var c=this.nameAlg.toLowerCase();if(c.substr(-7,7)!==\"withdsa\"&&c.substr(-9,9)!==\"withecdsa\"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:\"81\",dns:\"82\",dn:\"a4\",uri:\"86\",ip:\"87\"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type=\"rfc822\";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type=\"dns\";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type=\"uri\";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({str:p.dn})}if(p.ldapdn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certissuer param not cert\"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certsubj param not cert\"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type=\"ip\";this.explicit=false;var q=p.ip;var s;var n=\"malformed IP address\";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex(\"[\"+q.split(\".\").join(\",\")+\"]\");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw\"unsupported type in params=\"+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){r=new b({obj:this.dUnsignedAttrs,tag:\"a1\",explicit:false})}var q=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,o,this.dSigAlg,this.dSig,];if(r!=null){q.push(r)}var p=new h.DERSequence({array:q});this.hTLV=p.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.SignerInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.EncapsulatedContentInfo=function(g){var c=KJUR,b=c.asn1,e=b.DERTaggedObject,a=b.DERSequence,h=b.DERObjectIdentifier,d=b.DEROctetString,f=b.cms;f.EncapsulatedContentInfo.superclass.constructor.call(this);this.dEContentType=new h({name:\"data\"});this.dEContent=null;this.isDetached=false;this.eContentValueHex=null;this.setContentType=function(i){if(i.match(/^[0-2][.][0-9.]+$/)){this.dEContentType=new h({oid:i})}else{this.dEContentType=new h({name:i})}};this.setContentValue=function(i){if(i!==undefined){if(typeof i.hex==\"string\"){this.eContentValueHex=i.hex}else{if(typeof i.str==\"string\"){this.eContentValueHex=utf8tohex(i.str)}}}};this.setContentValueHex=function(i){this.eContentValueHex=i};this.setContentValueStr=function(i){this.eContentValueHex=utf8tohex(i)};this.getEncodedHex=function(){if(typeof this.eContentValueHex!=\"string\"){throw\"eContentValue not yet set\"}var k=new d({hex:this.eContentValueHex});this.dEContent=new e({obj:k,tag:\"a0\",explicit:true});var i=[this.dEContentType];if(!this.isDetached){i.push(this.dEContent)}var j=new a({array:i});this.hTLV=j.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.EncapsulatedContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.ContentInfo=function(f){var c=KJUR,b=c.asn1,d=b.DERTaggedObject,a=b.DERSequence,e=b.x509;KJUR.asn1.cms.ContentInfo.superclass.constructor.call(this);this.dContentType=null;this.dContent=null;this.setContentType=function(g){if(typeof g==\"string\"){this.dContentType=e.OID.name2obj(g)}};this.getEncodedHex=function(){var h=new d({obj:this.dContent,tag:\"a0\",explicit:true});var g=new a({array:[this.dContentType,h]});this.hTLV=g.getEncodedHex();return this.hTLV};if(f!==undefined){if(f.type){this.setContentType(f.type)}if(f.obj&&f.obj instanceof b.ASN1Object){this.dContent=f.obj}}};YAHOO.lang.extend(KJUR.asn1.cms.ContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.SignedData=function(e){var a=KJUR,h=a.asn1,j=h.ASN1Object,g=h.DERInteger,m=h.DERSet,f=h.DERSequence,b=h.DERTaggedObject,l=h.cms,i=l.EncapsulatedContentInfo,d=l.SignerInfo,n=l.ContentInfo,c=h.x509,k=c.AlgorithmIdentifier;KJUR.asn1.cms.SignedData.superclass.constructor.call(this);this.dCMSVersion=new g({\"int\":1});this.dDigestAlgs=null;this.digestAlgNameList=[];this.dEncapContentInfo=new i();this.dCerts=null;this.certificateList=[];this.crlList=[];this.signerInfoList=[new d()];this.addCertificatesByPEM=function(p){var q=pemtohex(p);var r=new j();r.hTLV=q;this.certificateList.push(r)};this.getEncodedHex=function(){if(typeof this.hTLV==\"string\"){return this.hTLV}if(this.dDigestAlgs==null){var u=[];for(var t=0;t0){var v=new m({array:this.certificateList});this.dCerts=new b({obj:v,tag:\"a0\",explicit:false})}}if(this.dCerts!=null){p.push(this.dCerts)}var r=new m({array:this.signerInfoList});p.push(r);var q=new f({array:p});this.hTLV=q.getEncodedHex();return this.hTLV};this.getContentInfo=function(){this.getEncodedHex();var o=new n({type:\"signed-data\",obj:this});return o};this.getContentInfoEncodedHex=function(){var o=this.getContentInfo();var p=o.getEncodedHex();return p};this.getPEM=function(){return hextopem(this.getContentInfoEncodedHex(),\"CMS\")}};YAHOO.lang.extend(KJUR.asn1.cms.SignedData,KJUR.asn1.ASN1Object);KJUR.asn1.cms.CMSUtil=new function(){};KJUR.asn1.cms.CMSUtil.newSignedData=function(d){var b=KJUR,j=b.asn1,q=j.cms,f=q.SignerInfo,n=q.SignedData,o=q.SigningTime,a=q.SigningCertificate,p=q.SigningCertificateV2,c=j.cades,e=c.SignaturePolicyIdentifier;var m=new n();m.dEncapContentInfo.setContentValue(d.content);if(typeof d.certs==\"object\"){for(var h=0;h0){var s=new f({array:this.extensionsArray});var r=new m({array:[s]});var q=new f({array:[new k({oid:\"1.2.840.113549.1.9.14\"}),r]});var p=new c({explicit:true,tag:\"a0\",obj:q});this.asn1Array.push(p)}else{var p=new c({explicit:false,tag:\"a0\",obj:new j()});this.asn1Array.push(p)}var t=new f({array:this.asn1Array});this.hTLV=t.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CSRUtil=new function(){};KJUR.asn1.csr.CSRUtil.newCSRPEM=function(h){var c=KEYUTIL,b=KJUR.asn1.csr;if(h.subject===undefined){throw\"parameter subject undefined\"}if(h.sbjpubkey===undefined){throw\"parameter sbjpubkey undefined\"}if(h.sigalg===undefined){throw\"parameter sigalg undefined\"}if(h.sbjprvkey===undefined){throw\"parameter sbjpubkey undefined\"}var d=new b.CertificationRequestInfo();d.setSubjectByParam(h.subject);d.setSubjectPublicKeyByGetKey(h.sbjpubkey);if(h.ext!==undefined&&h.ext.length!==undefined){for(var e=0;ef.length){f=c[d]}}e=e.replace(f,\"::\");return e.slice(1,-1)}function hextoip(b){var d=\"malformed hex value\";if(!b.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){throw d}if(b.length==8){var c;try{c=parseInt(b.substr(0,2),16)+\".\"+parseInt(b.substr(2,2),16)+\".\"+parseInt(b.substr(4,2),16)+\".\"+parseInt(b.substr(6,2),16);return c}catch(a){throw d}}else{if(b.length==32){return hextoipv6(b)}else{return b}}}function iptohex(f){var j=\"malformed IP address\";f=f.toLowerCase(f);if(f.match(/^[0-9.]+$/)){var b=f.split(\".\");if(b.length!==4){throw j}var g=\"\";try{for(var e=0;e<4;e++){var h=parseInt(b[e]);g+=(\"0\"+h.toString(16)).slice(-2)}return g}catch(c){throw j}}else{if(f.match(/^[0-9a-f:]+$/)&&f.indexOf(\":\")!==-1){return ipv6tohex(f)}else{throw j}}}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b=\"\";for(var c=0;c\"7\"){return\"00\"+a}return a}function intarystrtohex(b){b=b.replace(/^\\s*\\[\\s*/,\"\");b=b.replace(/\\s*\\]\\s*$/,\"\");b=b.replace(/\\s*/g,\"\");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;bd){throw\"key is too short for SigAlg: keylen=\"+j+\",\"+a}var b=\"0001\";var k=\"00\"+c;var g=\"\";var l=d-b.length-k.length;for(var f=0;f=0;--p){q=q.twice2D();q.z=BigInteger.ONE;if(o.testBit(p)){if(n.testBit(p)){q=q.add2D(t)}else{q=q.add2D(s)}}else{if(n.testBit(p)){q=q.add2D(r)}}}return q}this.getBigRandom=function(i){return new BigInteger(i.bitLength(),a).mod(i.subtract(BigInteger.ONE)).add(BigInteger.ONE)};this.setNamedCurve=function(i){this.ecparams=KJUR.crypto.ECParameterDB.getByName(i);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=i};this.setPrivateKeyHex=function(i){this.isPrivate=true;this.prvKeyHex=i};this.setPublicKeyHex=function(i){this.isPublic=true;this.pubKeyHex=i};this.getPublicKeyXYHex=function(){var k=this.pubKeyHex;if(k.substr(0,2)!==\"04\"){throw\"this method supports uncompressed format(04) only\"}var j=this.ecparams.keylen/4;if(k.length!==2+j*2){throw\"malformed public key hex length\"}var i={};i.x=k.substr(2,j);i.y=k.substr(2+j);return i};this.getShortNISTPCurveName=function(){var i=this.curveName;if(i===\"secp256r1\"||i===\"NIST P-256\"||i===\"P-256\"||i===\"prime256v1\"){return\"P-256\"}if(i===\"secp384r1\"||i===\"NIST P-384\"||i===\"P-384\"){return\"P-384\"}return null};this.generateKeyPairHex=function(){var k=this.ecparams.n;var n=this.getBigRandom(k);var l=this.ecparams.G.multiply(n);var q=l.getX().toBigInteger();var o=l.getY().toBigInteger();var i=this.ecparams.keylen/4;var m=(\"0000000000\"+n.toString(16)).slice(-i);var r=(\"0000000000\"+q.toString(16)).slice(-i);var p=(\"0000000000\"+o.toString(16)).slice(-i);var j=\"04\"+r+p;this.setPrivateKeyHex(m);this.setPublicKeyHex(j);return{ecprvhex:m,ecpubhex:j}};this.signWithMessageHash=function(i){return this.signHex(i,this.prvKeyHex)};this.signHex=function(o,j){var t=new BigInteger(j,16);var l=this.ecparams.n;var q=new BigInteger(o,16);do{var m=this.getBigRandom(l);var u=this.ecparams.G;var p=u.multiply(m);var i=p.getX().toBigInteger().mod(l)}while(i.compareTo(BigInteger.ZERO)<=0);var v=m.modInverse(l).multiply(q.add(t.multiply(i))).mod(l);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(i,v)};this.sign=function(m,u){var q=u;var j=this.ecparams.n;var p=BigInteger.fromByteArrayUnsigned(m);do{var l=this.getBigRandom(j);var t=this.ecparams.G;var o=t.multiply(l);var i=o.getX().toBigInteger().mod(j)}while(i.compareTo(BigInteger.ZERO)<=0);var v=l.modInverse(j).multiply(p.add(q.multiply(i))).mod(j);return this.serializeSig(i,v)};this.verifyWithMessageHash=function(j,i){return this.verifyHex(j,i,this.pubKeyHex)};this.verifyHex=function(m,i,p){var l,j;var o=KJUR.crypto.ECDSA.parseSigHex(i);l=o.r;j=o.s;var k;k=ECPointFp.decodeFromHex(this.ecparams.curve,p);var n=new BigInteger(m,16);return this.verifyRaw(n,l,j,k)};this.verify=function(o,p,j){var l,i;if(Bitcoin.Util.isArray(p)){var n=this.parseSig(p);l=n.r;i=n.s}else{if(\"object\"===typeof p&&p.r&&p.s){l=p.r;i=p.s}else{throw\"Invalid value for signature\"}}var k;if(j instanceof ECPointFp){k=j}else{if(Bitcoin.Util.isArray(j)){k=ECPointFp.decodeFrom(this.ecparams.curve,j)}else{throw\"Invalid format for pubkey value, must be byte array or ECPointFp\"}}var m=BigInteger.fromByteArrayUnsigned(o);return this.verifyRaw(m,l,i,k)};this.verifyRaw=function(o,i,w,m){var l=this.ecparams.n;var u=this.ecparams.G;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(l)>=0){return false}if(w.compareTo(BigInteger.ONE)<0||w.compareTo(l)>=0){return false}var p=w.modInverse(l);var k=o.multiply(p).mod(l);var j=i.multiply(p).mod(l);var q=u.multiply(k).add(m.multiply(j));var t=q.getX().toBigInteger().mod(l);return t.equals(i)};this.serializeSig=function(k,j){var l=k.toByteArraySigned();var i=j.toByteArraySigned();var m=[];m.push(2);m.push(l.length);m=m.concat(l);m.push(2);m.push(i.length);m=m.concat(i);m.unshift(m.length);m.unshift(48);return m};this.parseSig=function(n){var m;if(n[0]!=48){throw new Error(\"Signature not a valid DERSequence\")}m=2;if(n[m]!=2){throw new Error(\"First element in signature must be a DERInteger\")}var l=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];if(n[m]!=2){throw new Error(\"Second element in signature must be a DERInteger\")}var i=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];var k=BigInteger.fromByteArrayUnsigned(l);var j=BigInteger.fromByteArrayUnsigned(i);return{r:k,s:j}};this.parseSigCompact=function(m){if(m.length!==65){throw\"Signature has the wrong length\"}var j=m[0]-27;if(j<0||j>7){throw\"Invalid signature type\"}var o=this.ecparams.n;var l=BigInteger.fromByteArrayUnsigned(m.slice(1,33)).mod(o);var k=BigInteger.fromByteArrayUnsigned(m.slice(33,65)).mod(o);return{r:l,s:k,i:j}};this.readPKCS5PrvKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var i,k,o;try{i=p(l,0,[2,0],\"06\");k=p(l,0,[1],\"04\");try{o=p(l,0,[3,0],\"03\").substr(2)}catch(j){}}catch(j){throw\"malformed PKCS#1/5 plain ECC private key\"}this.curveName=m(i);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o);this.setPrivateKeyHex(k);this.isPublic=false};this.readPKCS8PrvKeyHex=function(l){var q=ASN1HEX;var i=KJUR.crypto.ECDSA.getName;var n=q.getVbyList;if(q.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var j,p,m,k;try{j=n(l,0,[1,0],\"06\");p=n(l,0,[1,1],\"06\");m=n(l,0,[2,0,1],\"04\");try{k=n(l,0,[2,0,2,0],\"03\").substr(2)}catch(o){}}catch(o){throw\"malformed PKCS#8 plain ECC private key\"}this.curveName=i(p);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(k);this.setPrivateKeyHex(m);this.isPublic=false};this.readPKCS8PubKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var k,i,o;try{k=p(l,0,[0,0],\"06\");i=p(l,0,[0,1],\"06\");o=p(l,0,[1],\"03\").substr(2)}catch(j){throw\"malformed PKCS#8 ECC public key\"}this.curveName=m(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o)};this.readCertPubKeyHex=function(k,p){if(p!==5){p=6}var m=ASN1HEX;var l=KJUR.crypto.ECDSA.getName;var o=m.getVbyList;if(m.isASN1HEX(k)===false){throw\"not ASN.1 hex string\"}var i,n;try{i=o(k,0,[0,p,0,1],\"06\");n=o(k,0,[0,p,1],\"03\").substr(2)}catch(j){throw\"malformed X.509 certificate ECC public key\"}this.curveName=l(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(n)};if(h!==undefined){if(h.curve!==undefined){this.curveName=h.curve}}if(this.curveName===undefined){this.curveName=e}this.setNamedCurve(this.curveName);if(h!==undefined){if(h.prv!==undefined){this.setPrivateKeyHex(h.prv)}if(h.pub!==undefined){this.setPublicKeyHex(h.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX;var i=j.getChildIdx;var g=j.getV;if(f.substr(0,2)!=\"30\"){throw\"signature is not a ASN.1 sequence\"}var h=i(f,0);if(h.length!=2){throw\"number of signature ASN.1 sequence elements seem wrong\"}var e=h[0];var d=h[1];if(f.substr(e,2)!=\"02\"){throw\"1st item of sequene of signature is not ASN.1 integer\"}if(f.substr(d,2)!=\"02\"){throw\"2nd item of sequene of signature is not ASN.1 integer\"}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(c){var d=KJUR.crypto.ECDSA.parseSigHexInHexRS(c);var b=d.r;var a=d.s;if(b.substr(0,2)==\"00\"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)==\"00\"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b=\"00\"+b}if((a.length%32)==30){a=\"00\"+a}if(b.length%32!=0){throw\"unknown ECDSA sig r length error\"}if(a.length%32!=0){throw\"unknown ECDSA sig s length error\"}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if((((a.length/2)*8)%(16*8))!=0){throw\"unknown ECDSA concatinated r-s sig length error\"}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.getEncodedHex()};KJUR.crypto.ECDSA.getName=function(a){if(a===\"2a8648ce3d030107\"){return\"secp256r1\"}if(a===\"2b8104000a\"){return\"secp256k1\"}if(a===\"2b81040022\"){return\"secp384r1\"}if(\"|secp256r1|NIST P-256|P-256|prime256v1|\".indexOf(a)!==-1){return\"secp256r1\"}if(\"|secp256k1|\".indexOf(a)!==-1){return\"secp256k1\"}if(\"|secp384r1|NIST P-384|P-384|\".indexOf(a)!==-1){return\"secp384r1\"}return null};\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.crypto==\"undefined\"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!=\"undefined\"){d=c[e]}if(typeof b[d]!=\"undefined\"){return b[d]}throw\"unregistered EC curve name: \"+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex(\"04\"+f+k);b[A][\"name\"]=A;b[A][\"keylen\"]=l;b[A][\"curve\"]=r;b[A][\"G\"]=q;b[A][\"n\"]=t;b[A][\"h\"]=w;b[A][\"oid\"]=d;b[A][\"info\"]=x;for(var v=0;v1){g=new BigInteger(i,16)}else{g=null}h=new BigInteger(j,16);this.setPrivate(c,a,e,g,h)};this.setPublic=function(c,b,a,d){this.isPublic=true;this.p=c;this.q=b;this.g=a;this.y=d;this.x=null};this.setPublicHex=function(f,e,d,g){var b,a,h,c;b=new BigInteger(f,16);a=new BigInteger(e,16);h=new BigInteger(d,16);c=new BigInteger(g,16);this.setPublic(b,a,h,c)};this.signWithMessageHash=function(d){var c=this.p;var b=this.q;var f=this.g;var i=this.y;var j=this.x;var e=KJUR.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),b.subtract(BigInteger.ONE));var l=d.substr(0,b.bitLength()/4);var h=new BigInteger(l,16);var a=(f.modPow(e,c)).mod(b);var n=(e.modInverse(b).multiply(h.add(j.multiply(a)))).mod(b);var m=KJUR.asn1.ASN1Util.jsonToASN1HEX({seq:[{\"int\":{bigint:a}},{\"int\":{bigint:n}}]});return m};this.verifyWithMessageHash=function(h,f){var d=this.p;var b=this.q;var j=this.g;var l=this.y;var i=this.parseASN1Signature(f);var a=i[0];var t=i[1];var o=h.substr(0,b.bitLength()/4);var k=new BigInteger(o,16);if(BigInteger.ZERO.compareTo(a)>0||a.compareTo(b)>0){throw\"invalid DSA signature\"}if(BigInteger.ZERO.compareTo(t)>=0||t.compareTo(b)>0){throw\"invalid DSA signature\"}var m=t.modInverse(b);var e=k.multiply(m).mod(b);var c=a.multiply(m).mod(b);var n=j.modPow(e,d).multiply(l.modPow(c,d)).mod(d).mod(b);return n.compareTo(a)==0};this.parseASN1Signature=function(a){try{var d=new BigInteger(ASN1HEX.getVbyList(a,0,[0],\"02\"),16);var c=new BigInteger(ASN1HEX.getVbyList(a,0,[1],\"02\"),16);return[d,c]}catch(b){throw\"malformed ASN.1 DSA signature\"}};this.readPKCS5PrvKeyHex=function(c){var b,a,f,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[1],\"02\");a=d(c,0,[2],\"02\");f=d(c,0,[3],\"02\");g=d(c,0,[4],\"02\");i=d(c,0,[5],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed PKCS#1/5 plain DSA private key\"}this.setPrivateHex(b,a,f,g,i)};this.readPKCS8PrvKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[1,1,0],\"02\");c=i(d,0,[1,1,1],\"02\");b=i(d,0,[1,1,2],\"02\");g=i(d,0,[2,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 plain DSA private key\"}this.setPrivateHex(f,c,b,null,g)};this.readPKCS8PubKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[0,1,0],\"02\");c=i(d,0,[0,1,1],\"02\");b=i(d,0,[0,1,2],\"02\");g=i(d,0,[1,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 DSA public key\"}this.setPublicHex(f,c,b,g)};this.readCertPubKeyHex=function(c,f){if(f!==5){f=6}var b,a,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[0,f,0,1,0],\"02\");a=d(c,0,[0,f,0,1,1],\"02\");g=d(c,0,[0,f,0,1,2],\"02\");i=d(c,0,[0,f,1,0],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed X.509 certificate DSA public key\"}this.setPublicHex(b,a,g,i)}};\nvar KEYUTIL=function(){var d=function(p,r,q){return k(CryptoJS.AES,p,r,q)};var e=function(p,r,q){return k(CryptoJS.TripleDES,p,r,q)};var a=function(p,r,q){return k(CryptoJS.DES,p,r,q)};var k=function(s,x,u,q){var r=CryptoJS.enc.Hex.parse(x);var w=CryptoJS.enc.Hex.parse(u);var p=CryptoJS.enc.Hex.parse(q);var t={};t.key=w;t.iv=p;t.ciphertext=r;var v=s.decrypt(t,w,{iv:p});return CryptoJS.enc.Hex.stringify(v)};var l=function(p,r,q){return g(CryptoJS.AES,p,r,q)};var o=function(p,r,q){return g(CryptoJS.TripleDES,p,r,q)};var f=function(p,r,q){return g(CryptoJS.DES,p,r,q)};var g=function(t,y,v,q){var s=CryptoJS.enc.Hex.parse(y);var x=CryptoJS.enc.Hex.parse(v);var p=CryptoJS.enc.Hex.parse(q);var w=t.encrypt(s,x,{iv:p});var r=CryptoJS.enc.Hex.parse(w.toString());var u=CryptoJS.enc.Base64.stringify(r);return u};var i={\"AES-256-CBC\":{proc:d,eproc:l,keylen:32,ivlen:16},\"AES-192-CBC\":{proc:d,eproc:l,keylen:24,ivlen:16},\"AES-128-CBC\":{proc:d,eproc:l,keylen:16,ivlen:16},\"DES-EDE3-CBC\":{proc:e,eproc:o,keylen:24,ivlen:8},\"DES-CBC\":{proc:a,eproc:f,keylen:8,ivlen:8}};var c=function(p){return i[p][\"proc\"]};var m=function(p){var r=CryptoJS.lib.WordArray.random(p);var q=CryptoJS.enc.Hex.stringify(r);return q};var n=function(v){var w={};var q=v.match(new RegExp(\"DEK-Info: ([^,]+),([0-9A-Fa-f]+)\",\"m\"));if(q){w.cipher=q[1];w.ivsalt=q[2]}var p=v.match(new RegExp(\"-----BEGIN ([A-Z]+) PRIVATE KEY-----\"));if(p){w.type=p[1]}var u=-1;var x=0;if(v.indexOf(\"\\r\\n\\r\\n\")!=-1){u=v.indexOf(\"\\r\\n\\r\\n\");x=2}if(v.indexOf(\"\\n\\n\")!=-1){u=v.indexOf(\"\\n\\n\");x=1}var t=v.indexOf(\"-----END\");if(u!=-1&&t!=-1){var r=v.substring(u+x*2,t-x);r=r.replace(/\\s+/g,\"\");w.data=r}return w};var j=function(q,y,p){var v=p.substring(0,16);var t=CryptoJS.enc.Hex.parse(v);var r=CryptoJS.enc.Utf8.parse(y);var u=i[q][\"keylen\"]+i[q][\"ivlen\"];var x=\"\";var w=null;for(;;){var s=CryptoJS.algo.MD5.create();if(w!=null){s.update(w)}s.update(r);s.update(t);w=s.finalize();x=x+CryptoJS.enc.Hex.stringify(w);if(x.length>=u*2){break}}var z={};z.keyhex=x.substr(0,i[q][\"keylen\"]*2);z.ivhex=x.substr(i[q][\"keylen\"]*2,i[q][\"ivlen\"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v][\"proc\"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s][\"eproc\"];var t=r(p,q,u);return t};return{version:\"1.0.0\",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p=\"\";if(typeof t==\"undefined\"||t==null){t=\"AES-256-CBC\"}if(typeof i[t]==\"undefined\"){throw\"KEYUTIL unsupported algorithm: \"+t}if(typeof r==\"undefined\"||r==null){var v=i[t][\"ivlen\"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,\"$1\\r\\n\");var p=\"-----BEGIN \"+x+\" PRIVATE KEY-----\\r\\n\";p+=\"Proc-Type: 4,ENCRYPTED\\r\\n\";p+=\"DEK-Info: \"+t+\",\"+r+\"\\r\\n\";p+=\"\\r\\n\";p+=q;p+=\"\\r\\n-----END \"+x+\" PRIVATE KEY-----\\r\\n\";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw\"malformed format: SEQUENCE(0).items != 2: \"+r.length}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0).items != 2: \"+A.length}if(w(y,A[0])!=\"2a864886f70d01050d\"){throw\"this only supports pkcs5PBES2\"}var p=z(y,A[1]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0.1).items != 2: \"+p.length}var q=z(y,p[1]);if(q.length!=2){throw\"malformed format: SEQUENCE(0.0.1.1).items != 2: \"+q.length}if(w(y,q[0])!=\"2a864886f70d0307\"){throw\"this only supports TripleDES\"}t.encryptionSchemeAlg=\"TripleDES\";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw\"malformed format: SEQUENCE(0.0.1.0).items != 2: \"+s.length}if(w(y,s[0])!=\"2a864886f70d01050c\"){throw\"this only supports pkcs5PBKDF2\"}var x=z(y,s[1]);if(x.length<2){throw\"malformed format: SEQUENCE(0.0.1.0.1).items < 2: \"+x.length}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw\"malformed format pbkdf2Iter: \"+u}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,\"ENCRYPTED PRIVATE KEY\");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!=\"30\"){throw\"malformed plain PKCS8 private key(code:001)\"}var r=u(s,0);if(r.length!=3){throw\"malformed plain PKCS8 private key(code:002)\"}if(s.substr(r[1],2)!=\"30\"){throw\"malformed PKCS8 private key(code:003)\"}var p=u(s,r[1]);if(p.length!=2){throw\"malformed PKCS8 private key(code:004)\"}if(s.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 private key(code:005)\"}q.algoid=t(s,p[0]);if(s.substr(p[1],2)==\"06\"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!=\"04\"){throw\"malformed PKCS8 private key(code:006)\"}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,\"PRIVATE KEY\");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid==\"2a864886f70d010101\"){r=new RSAKey()}else{if(q.algoid==\"2a8648ce380401\"){r=new KJUR.crypto.DSA()}else{if(q.algoid==\"2a8648ce3d0201\"){r=new KJUR.crypto.ECDSA()}else{throw\"unsupported private key algorithm\"}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],\"06\");if(r===\"2a864886f70d010101\"){p=new RSAKey()}else{if(r===\"2a8648ce380401\"){p=new KJUR.crypto.DSA()}else{if(r===\"2a8648ce3d0201\"){p=new KJUR.crypto.ECDSA()}else{throw\"unsupported PKCS#8 public key hex\"}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!=\"30\"){throw\"malformed RSA key(code:001)\"}var q=t(r,0);if(q.length!=2){throw\"malformed RSA key(code:002)\"}if(r.substr(q[0],2)!=\"02\"){throw\"malformed RSA key(code:003)\"}p.n=s(r,q[0]);if(r.substr(q[1],2)!=\"02\"){throw\"malformed RSA key(code:004)\"}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw\"outer DERSequence shall have 2 elements: \"+r.length}var w=r[0];if(t.substr(w,2)!=\"30\"){throw\"malformed PKCS8 public key(code:001)\"}var p=u(t,w);if(p.length!=2){throw\"malformed PKCS8 public key(code:002)\"}if(t.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 public key(code:003)\"}q.algoid=s(t,p[0]);if(t.substr(p[1],2)==\"06\"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)==\"30\"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],\"02\");q.algparam.q=v.getVbyList(t,p[1],[1],\"02\");q.algparam.g=v.getVbyList(t,p[1],[2],\"02\")}}if(t.substr(r[1],2)!=\"03\"){throw\"malformed PKCS8 public key(code:004)\"}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!=\"undefined\"&&l instanceof w){return l}if(typeof i!=\"undefined\"&&l instanceof i){return l}if(typeof C!=\"undefined\"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;j.setPublicKeyHex(u);return j}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;var b=(\"0000000000\"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n===\"pkcs5prv\"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)===\"04\"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw\"unsupported PKCS#1/5 hexadecimal key\"}}}return P}if(n===\"pkcs8prv\"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n===\"pkcs8pub\"){return F._getKeyFromPublicPKCS8Hex(l)}if(n===\"x509pub\"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf(\"-END CERTIFICATE-\",0)!=-1||l.indexOf(\"-END X509 CERTIFICATE-\",0)!=-1||l.indexOf(\"-END TRUSTED CERTIFICATE-\",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf(\"-END PUBLIC KEY-\")!=-1){var O=pemtohex(l,\"PUBLIC KEY\");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var m=M(l,\"RSA PRIVATE KEY\");return F.getKey(m,null,\"pkcs5prv\")}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var I=M(l,\"DSA PRIVATE KEY\");var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END PRIVATE KEY-\")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf(\"-END EC PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],\"04\");var f=d(I,0,[2,0],\"06\");var A=d(I,0,[3,0],\"03\").substr(2);var e=\"\";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw\"undefined OID(hex) in KJUR.crypto.OID: \"+f}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END ENCRYPTED PRIVATE KEY-\")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw\"not supported argument\"};KEYUTIL.generateKeypair=function(a,c){if(a==\"RSA\"){var b=c;var h=new RSAKey();h.generate(b,\"10001\");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a==\"EC\"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw\"unknown algorithm: \"+a}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.n}},{\"int\":s.e},{\"int\":{bigint:s.d}},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.dmp1}},{\"int\":{bigint:s.dmq1}},{\"int\":{bigint:s.coeff}}]});return G}function B(G){var s=l({seq:[{\"int\":1},{octstr:{hex:G.prvKeyHex}},{tag:[\"a0\",true,{oid:{name:G.curveName}}]},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+G.pubKeyHex}}]}]});return s}function x(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.g}},{\"int\":{bigint:s.y}},{\"int\":{bigint:s.x}}]});return G}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D==\"PKCS8PUB\")){var E=new C(b);var w=E.getEncodedHex();return hextopem(w,\"PUBLIC KEY\")}if(D==\"PKCS1PRV\"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();return hextopem(w,\"RSA PRIVATE KEY\")}if(D==\"PKCS1PRV\"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.getEncodedHex();var h=B(b);var t=h.getEncodedHex();var p=\"\";p+=hextopem(v,\"EC PARAMETERS\");p+=hextopem(t,\"EC PRIVATE KEY\");return p}if(D==\"PKCS1PRV\"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();return hextopem(w,\"DSA PRIVATE KEY\")}if(D==\"PKCS5PRV\"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"RSA\",w,y,m,j)}if(D==\"PKCS5PRV\"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"EC\",w,y,m,j)}if(D==\"PKCS5PRV\"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"DSA\",w,y,m,j)}var o=function(G,s){var I=c(G,s);var H=new l({seq:[{seq:[{oid:{name:\"pkcs5PBES2\"}},{seq:[{seq:[{oid:{name:\"pkcs5PBKDF2\"}},{seq:[{octstr:{hex:I.pbkdf2Salt}},{\"int\":I.pbkdf2Iter}]}]},{seq:[{oid:{name:\"des-EDE3-CBC\"}},{octstr:{hex:I.encryptionSchemeIV}}]}]}]},{octstr:{hex:I.ciphertext}}]});return H.getEncodedHex()};var c=function(N,O){var H=100;var M=CryptoJS.lib.WordArray.random(8);var L=\"DES-EDE3-CBC\";var s=CryptoJS.lib.WordArray.random(8);var I=CryptoJS.PBKDF2(O,M,{keySize:192/32,iterations:H});var J=CryptoJS.enc.Hex.parse(N);var K=CryptoJS.TripleDES.encrypt(J,I,{iv:s})+\"\";var G={};G.ciphertext=K;G.pbkdf2Salt=CryptoJS.enc.Hex.stringify(M);G.pbkdf2Iter=H;G.encryptionSchemeAlg=L;G.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return G};if(D==\"PKCS8PRV\"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"rsaEncryption\"}},{\"null\":true}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var g=new l({seq:[{\"int\":1},{octstr:{hex:b.prvKeyHex}},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+b.pubKeyHex}}]}]});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"ecPublicKey\"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"dsa\"}},{seq:[{\"int\":{bigint:b.p}},{\"int\":{bigint:b.q}},{\"int\":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}throw\"unsupported object nor format\"};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,\"CERTIFICATE REQUEST\");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,\"pkcs8pub\");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!=\"30\"){throw\"malformed CSR(code:001)\"}var e=f(g,0);if(e.length<1){throw\"malformed CSR(code:002)\"}if(g.substr(e[0],2)!=\"30\"){throw\"malformed CSR(code:003)\"}var a=f(g,e[0]);if(a.length<3){throw\"malformed CSR(code:004)\"}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getJWKFromKey=function(d){var b={};if(d instanceof RSAKey&&d.isPrivate){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));b.d=hextob64u(d.d.toString(16));b.p=hextob64u(d.p.toString(16));b.q=hextob64u(d.q.toString(16));b.dp=hextob64u(d.dmp1.toString(16));b.dq=hextob64u(d.dmq1.toString(16));b.qi=hextob64u(d.coeff.toString(16));return b}else{if(d instanceof RSAKey&&d.isPublic){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPrivate){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);b.d=hextob64u(d.prvKeyHex);return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPublic){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);return b}}}}throw\"not supported key object\"};\nRSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,j,l,b,a,f,d,k;var m=ASN1HEX;var g=m.getVbyList;if(m.isASN1HEX(e)===false){throw\"not ASN.1 hex string\"}try{c=g(e,0,[2,0,1],\"02\");j=g(e,0,[2,0,2],\"02\");l=g(e,0,[2,0,3],\"02\");b=g(e,0,[2,0,4],\"02\");a=g(e,0,[2,0,5],\"02\");f=g(e,0,[2,0,6],\"02\");d=g(e,0,[2,0,7],\"02\");k=g(e,0,[2,0,8],\"02\")}catch(i){throw\"malformed PKCS#8 plain RSA private key\"}this.setPrivateEx(c,j,l,b,a,f,d,k)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw\"keyHex is not ASN.1 hex string\"}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!==\"02\"||c.substr(a[1],2)!==\"02\"){throw\"wrong hex for PKCS#5 public key\"}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw\"not ASN.1 hex string\"}if(c.getTLVbyList(b,0,[0,0])!==\"06092a864886f70d010101\"){throw\"not PKCS8 RSA public key\"}var a=c.getTLVbyList(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)};\nvar _RE_HEXDECONLY=new RegExp(\"\");_RE_HEXDECONLY.compile(\"[^0-9a-f]\",\"gi\");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c=\"\";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw\"invalid salt length\"}}}if(c<(g+k+2)){throw\"data too long\"}var f=\"\";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dthis.n.bitLength()){return 0}var i=this.doPublic(b);var e=i.toString(16).replace(/^1f+00/,\"\");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(k){return KJUR.crypto.Util.hashString(k,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){a=a.replace(_RE_HEXDECONLY,\"\");a=a.replace(/[ \\n]+/g,\"\");var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,\"\");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){var k=new BigInteger(s,16);if(k.bitLength()>this.n.bitLength()){return false}var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw\"invalid salt length\"}}}if(m<(h+c+2)){throw\"data too long\"}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw\"bits beyond keysize not zero\"}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q0){var b=\":\"+n.join(\":\")+\":\";if(b.indexOf(\":\"+k+\":\")==-1){throw\"algorithm '\"+k+\"' not accepted in the list\"}}if(k!=\"none\"&&B===null){throw\"key shall be specified to verify.\"}if(typeof B==\"string\"&&B.indexOf(\"-----BEGIN \")!=-1){B=KEYUTIL.getKey(B)}if(z==\"RS\"||z==\"PS\"){if(!(B instanceof m)){throw\"key shall be a RSAKey obj for RS* and PS* algs\"}}if(z==\"ES\"){if(!(B instanceof p)){throw\"key shall be a ECDSA obj for ES* algs\"}}if(k==\"none\"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw\"unsupported alg name: \"+k}else{u=t.jwsalg2sigalg[k]}if(u==\"none\"){throw\"not supported\"}else{if(u.substr(0,4)==\"Hmac\"){var o=null;if(B===undefined){throw\"hexadecimal key shall be specified for HMAC\"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf(\"withECDSA\")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(\".\");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw\"malformed sJWS: wrong number of '.' splitted elements\"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null,\" \");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null,\" \")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;var k=e.split(\".\");var c=k[0];var i=k[1];var q=c+\".\"+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw\"acceptField.alg shall be specified\"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss===\"object\"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub===\"object\"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud===\"object\"){if(typeof g.aud==\"string\"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud==\"object\"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt===\"number\"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!==\"number\"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp==\"number\"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw\"addSignature failed: \"+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw\"malformed header\"}if(typeof g.payload===\"string\"){this.sPayload=g.payload}else{throw\"malformed signatures\"}if(g.signatures.length>0){this.aSignatures=g.signatures}else{throw\"malformed signatures\"}}catch(e){throw\"malformed JWS-JS JSON object: \"+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}};\nexports.SecureRandom = SecureRandom;\nexports.rng_seed_time = rng_seed_time;\n\nexports.BigInteger = BigInteger;\nexports.RSAKey = RSAKey;\nexports.ECDSA = KJUR.crypto.ECDSA;\nexports.DSA = KJUR.crypto.DSA;\nexports.Signature = KJUR.crypto.Signature;\nexports.MessageDigest = KJUR.crypto.MessageDigest;\nexports.Mac = KJUR.crypto.Mac;\nexports.Cipher = KJUR.crypto.Cipher;\nexports.KEYUTIL = KEYUTIL;\nexports.ASN1HEX = ASN1HEX;\nexports.X509 = X509;\nexports.CryptoJS = CryptoJS;\n\n// ext/base64.js\nexports.b64tohex = b64tohex;\nexports.b64toBA = b64toBA;\n\n// base64x.js\nexports.stoBA = stoBA;\nexports.BAtos = BAtos;\nexports.BAtohex = BAtohex;\nexports.stohex = stohex;\nexports.stob64 = stob64;\nexports.stob64u = stob64u;\nexports.b64utos = b64utos;\nexports.b64tob64u = b64tob64u;\nexports.b64utob64 = b64utob64;\nexports.hex2b64 = hex2b64;\nexports.hextob64u = hextob64u;\nexports.b64utohex = b64utohex;\nexports.utf8tob64u = utf8tob64u;\nexports.b64utoutf8 = b64utoutf8;\nexports.utf8tob64 = utf8tob64;\nexports.b64toutf8 = b64toutf8;\nexports.utf8tohex = utf8tohex;\nexports.hextoutf8 = hextoutf8;\nexports.hextorstr = hextorstr;\nexports.rstrtohex = rstrtohex;\nexports.hextob64 = hextob64;\nexports.hextob64nl = hextob64nl;\nexports.b64nltohex = b64nltohex;\nexports.hextopem = hextopem;\nexports.pemtohex = pemtohex;\nexports.hextoArrayBuffer = hextoArrayBuffer;\nexports.ArrayBuffertohex = ArrayBuffertohex;\nexports.zulutomsec = zulutomsec;\nexports.zulutosec = zulutosec;\nexports.zulutodate = zulutodate;\nexports.datetozulu = datetozulu;\nexports.uricmptohex = uricmptohex;\nexports.hextouricmp = hextouricmp;\nexports.ipv6tohex = ipv6tohex;\nexports.hextoipv6 = hextoipv6;\nexports.hextoip = hextoip;\nexports.iptohex = iptohex;\nexports.encodeURIComponentAll = encodeURIComponentAll;\nexports.newline_toUnix = newline_toUnix;\nexports.newline_toDos = newline_toDos;\nexports.hextoposhex = hextoposhex;\nexports.intarystrtohex = intarystrtohex;\nexports.strdiffidx = strdiffidx;\n\n// name spaces\nexports.KJUR = KJUR;\nexports.crypto = KJUR.crypto;\nexports.asn1 = KJUR.asn1;\nexports.jws = KJUR.jws;\nexports.lang = KJUR.lang;\n\n\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://AppID/./node_modules/jsrsasign/lib/jsrsasign.js?"); + +/***/ }), + +/***/ "./node_modules/node-fetch/browser.js": +/*!********************************************!*\ + !*** ./node_modules/node-fetch/browser.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n// ref: https://github.com/tc39/proposal-global\nvar getGlobal = function () {\n\t// the only reliable means to get the global object is\n\t// `Function('return this')()`\n\t// However, this causes CSP violations in Chrome apps.\n\tif (typeof self !== 'undefined') { return self; }\n\tif (typeof window !== 'undefined') { return window; }\n\tif (typeof global !== 'undefined') { return global; }\n\tthrow new Error('unable to locate global object');\n}\n\nvar global = getGlobal();\n\nmodule.exports = exports = global.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = global.fetch.bind(global);\n\nexports.Headers = global.Headers;\nexports.Request = global.Request;\nexports.Response = global.Response;\n\n//# sourceURL=webpack://AppID/./node_modules/node-fetch/browser.js?"); + +/***/ }), + +/***/ "./node_modules/webpack/buildin/global.js": +/*!***********************************!*\ + !*** (webpack)/buildin/global.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://AppID/(webpack)/buildin/global.js?"); + +/***/ }), + +/***/ "./package.json": +/*!**********************!*\ + !*** ./package.json ***! + \**********************/ +/*! exports provided: name, version, description, scripts, repository, main, nyc, dependencies, devDependencies, default */ +/***/ (function(module) { + +eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"ibmcloud-appid-js\\\",\\\"version\\\":\\\"0.0.2\\\",\\\"description\\\":\\\"IBM Cloud App ID SDK for Single Page Applications\\\",\\\"scripts\\\":{\\\"build\\\":\\\"webpack --mode=development\\\",\\\"test\\\":\\\"mocha\\\",\\\"coverage\\\":\\\"nyc --reporter=lcov mocha\\\",\\\"docs\\\":\\\"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json\\\"},\\\"repository\\\":{\\\"type\\\":\\\"git\\\",\\\"url\\\":\\\"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git\\\"},\\\"main\\\":\\\"dist/appid.umd.min.js\\\",\\\"nyc\\\":{\\\"all\\\":true,\\\"include\\\":[\\\"src/*.js\\\"],\\\"exclude\\\":[\\\"**/PopupController.js\\\",\\\"**/IFrameController.js\\\",\\\"**/OpenIDConfigurationResource.js\\\",\\\"**/constants.js\\\"]},\\\"dependencies\\\":{\\\"jsrsasign\\\":\\\"^8.0.12\\\"},\\\"devDependencies\\\":{\\\"node-fetch\\\":\\\"^2.6.0\\\",\\\"@babel/cli\\\":\\\"^7.0.0\\\",\\\"@babel/core\\\":\\\"^7.5.5\\\",\\\"@babel/plugin-transform-runtime\\\":\\\"^7.5.5\\\",\\\"@babel/preset-env\\\":\\\"^7.5.5\\\",\\\"babel-cli\\\":\\\"^7.0.0-beta.3\\\",\\\"chai\\\":\\\"^4.2.0\\\",\\\"coveralls\\\":\\\"^3.0.6\\\",\\\"gulp-babel\\\":\\\"^8.0.0\\\",\\\"mocha\\\":\\\"^6.2.0\\\",\\\"nyc\\\":\\\"^14.1.1\\\",\\\"webpack\\\":\\\"^4.39.1\\\",\\\"webpack-cli\\\":\\\"^3.3.6\\\",\\\"docdash\\\":\\\"^1.1.1\\\",\\\"jsdoc\\\":\\\"^3.6.3\\\"}}\");\n\n//# sourceURL=webpack://AppID/./package.json?"); + +/***/ }), + +/***/ "./src/IFrameController.js": +/*!*********************************!*\ + !*** ./src/IFrameController.js ***! + \*********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const IFrameError = __webpack_require__(/*! ./errors/IFrameError */ \"./src/errors/IFrameError.js\");\n\nclass IFrameController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t}\n\n\topen(url) {\n\t\tthis.iFrame = this.window.document.createElement('iframe');\n\t\tthis.iFrame.src = url;\n\t\tthis.iFrame.width = 0;\n\t\tthis.iFrame.height = 0;\n\t\tthis.window.document.body.appendChild(this.iFrame);\n\t}\n\n\tremove() {\n\t\twindow.document.body.removeChild(this.iFrame);\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\treject(new IFrameError('Silent sign-in timed out'));\n\t\t\t}, 5 * 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tclearInterval(timer);\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = IFrameController;\n\n\n//# sourceURL=webpack://AppID/./src/IFrameController.js?"); + +/***/ }), + +/***/ "./src/OpenIDConfigurationResource.js": +/*!********************************************!*\ + !*** ./src/OpenIDConfigurationResource.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const packagejson = __webpack_require__(/*! ../package.json */ \"./package.json\");\n\nclass OpenIdConfigurationResource {\n\tasync init({discoveryEndpoint, requestHandler}){\n\t\tthis.openIdConfig = await requestHandler(discoveryEndpoint);\n\t\tconst headers = { 'x-filter-type': `spa:v${packagejson.version}` };\n\t\tthis.publicKeys = requestHandler(this.getJwksEndpoint(), { headers: headers });\n\t}\n\n\tgetAuthorizationEndpoint() {\n\t\treturn this.openIdConfig.authorization_endpoint;\n\t}\n\n\tgetUserInfoEndpoint() {\n\t\treturn this.openIdConfig.userinfo_endpoint;\n\t}\n\n\tgetJwksEndpoint() {\n\t\treturn this.openIdConfig.jwks_uri;\n\t}\n\n\tgetTokenEndpoint() {\n\t\treturn this.openIdConfig.token_endpoint;\n\t}\n\n\tgetIssuer() {\n\t\treturn this.openIdConfig.issuer;\n\t}\n\n\tasync getPublicKeys() {\n\t\treturn await this.publicKeys;\n\t}\n}\nmodule.exports = OpenIdConfigurationResource;\n\n\n\n//# sourceURL=webpack://AppID/./src/OpenIDConfigurationResource.js?"); + +/***/ }), + +/***/ "./src/PopupController.js": +/*!********************************!*\ + !*** ./src/PopupController.js ***! + \********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const PopupError = __webpack_require__(/*! ./errors/PopupError */ \"./src/errors/PopupError.js\");\n\nclass PopupController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t};\n\n\tinit(popupConfig){\n\t\tthis.popupConfig = popupConfig;\n\t}\n\n\topen() {\n\t\tconst h = this.popupConfig.height;\n\t\tconst w = this.popupConfig.width;\n\t\tconst left = (window.screen.width - w) / 2;\n\t\tconst top = (window.screen.height - h) / 2;\n\t\tthis.popup = this.window.open('', 'popup', `left=${left},top=${top},width=${w},height=${h},resizable,scrollbars=yes,status=1`);\n\t\tif (!this.popup) {\n\t\t\tthrow new PopupError('Unable to open popup')\n\t\t}\n\t};\n\n\tnavigate(url) {\n\t\tthis.popup.location.href = url;\n\t};\n\n\tclose() {\n\t\tthis.popup.close();\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\tif(this.popup.closed) {\n\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\treject(new PopupError('Popup closed'));\n\t\t\t\t}\n\t\t\t}, 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = PopupController;\n\n\n//# sourceURL=webpack://AppID/./src/PopupController.js?"); + +/***/ }), + +/***/ "./src/RequestHandler.js": +/*!*******************************!*\ + !*** ./src/RequestHandler.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t}\n\t\t\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tif (text !== '') {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); + +/***/ }), + +/***/ "./src/TokenValidator.js": +/*!*******************************!*\ + !*** ./src/TokenValidator.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg:[constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif (decoded.payloadObj.nonce && decoded.payloadObj.nonce !== nonce) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor(let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); + +/***/ }), + +/***/ "./src/constants.js": +/*!**************************!*\ + !*** ./src/constants.js ***! + \**************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN_PAYLOAD: 'Expect id token payload object to have identities field',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN_PAYLOAD: 'Missing id token payload',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tGENERATE_CODE: '/cloud_directory/generate_code',\n\tCHANGE_DETAILS: '/cloud_directory/change_details',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); + +/***/ }), + +/***/ "./src/errors/AppIDError.js": +/*!**********************************!*\ + !*** ./src/errors/AppIDError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class AppIDError extends Error {}\nmodule.exports = AppIDError;\n\n//# sourceURL=webpack://AppID/./src/errors/AppIDError.js?"); + +/***/ }), + +/***/ "./src/errors/IFrameError.js": +/*!***********************************!*\ + !*** ./src/errors/IFrameError.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class IFrameError extends Error {}\nmodule.exports = IFrameError;\n\n//# sourceURL=webpack://AppID/./src/errors/IFrameError.js?"); + +/***/ }), + +/***/ "./src/errors/OAuthError.js": +/*!**********************************!*\ + !*** ./src/errors/OAuthError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class OAuthError extends Error {\n\t// See https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for the possible error messages\n\tconstructor({error, description}) {\n\t\tsuper(description || error);\n\t\tthis.error = error;\n\t\tthis.description = description;\n\t}\n}\nmodule.exports = OAuthError;\n\n//# sourceURL=webpack://AppID/./src/errors/OAuthError.js?"); + +/***/ }), + +/***/ "./src/errors/PopupError.js": +/*!**********************************!*\ + !*** ./src/errors/PopupError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class PopupError extends Error {}\nmodule.exports = PopupError;\n\n//# sourceURL=webpack://AppID/./src/errors/PopupError.js?"); + +/***/ }), + +/***/ "./src/errors/RequestError.js": +/*!************************************!*\ + !*** ./src/errors/RequestError.js ***! + \************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class RequestError extends Error {\n\tconstructor(description, status, originError) {\n\t\tsuper(description);\n\t\tthis.status = status;\n\t\tthis.originError = originError;\n\t}\n}\nmodule.exports = RequestError;\n\n//# sourceURL=webpack://AppID/./src/errors/RequestError.js?"); + +/***/ }), + +/***/ "./src/errors/TokenError.js": +/*!**********************************!*\ + !*** ./src/errors/TokenError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class TokenError extends Error {}\nmodule.exports = TokenError;\n\n//# sourceURL=webpack://AppID/./src/errors/TokenError.js?"); + +/***/ }), + +/***/ "./src/index.js": +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in will attempt to authenticate the user in a hidden iframe.\n\t * You will need to enable Cloud Directory SSO.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * @param {string} idTokenPayload The id token payload.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token payload\"\n\t * @example\n\t * let tokens = await appID.changePassword(idTokenPayload);\n\t */\n\tasync changePassword(idTokenPayload) {\n\t\tthis._validateInitalize();\n\t\tlet userId;\n\n\t\tif (!idTokenPayload) {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN_PAYLOAD);\n\t\t}\n\t\tif (typeof idTokenPayload === 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN_PAYLOAD);\n\t\t}\n\t\tif (idTokenPayload.identities && idTokenPayload.identities[0] && idTokenPayload.identities[0].id) {\n\t\t\tif (idTokenPayload.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = idTokenPayload.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN_PAYLOAD);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\tasync changeDetails(tokens) {\n\t\t// get code\n\t\tconst generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE;\n\t\tconsole.log(generateCodeUrl);\n\t\tconst changeDetailsCode = await this.request(generateCodeUrl, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + tokens.accessToken + ' ' + tokens.idToken\n\t\t\t}\n\t\t});\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS;\n\n\t\t// send code with url\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint,\n\t\t\tchangeDetailsCode\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); + +/***/ }), + +/***/ "./src/utils.js": +/*!**********************!*\ + !*** ./src/utils.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId, changeDetailsCode}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tif (changeDetailsCode) {\n\t\t\tauthParams.code = changeDetailsCode;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint, changeDetailsCode}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint, changeDetailsCode});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); + +/***/ }) + +/******/ }); +}); \ No newline at end of file diff --git a/src/RequestHandler.js b/src/RequestHandler.js index cc77474..1c26466 100644 --- a/src/RequestHandler.js +++ b/src/RequestHandler.js @@ -13,9 +13,13 @@ class RequestHandler { if (!response.ok || response.status > 300) { throw new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status); } + try { return JSON.parse(text); } catch(err) { + if (text !== '') { + return text; + } throw new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err); } }; diff --git a/src/constants.js b/src/constants.js index d9aa802..b5d2bd7 100644 --- a/src/constants.js +++ b/src/constants.js @@ -29,6 +29,8 @@ module.exports = { TOKEN_ALG: 'RS256', VERSION: 4, CHANGE_PASSWORD: '/cloud_directory/change_password', + GENERATE_CODE: '/cloud_directory/generate_code', + CHANGE_DETAILS: '/cloud_directory/change_details', OAUTH: '/oauth/v4/', MALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA', INVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j' diff --git a/src/index.js b/src/index.js index 16215b7..84dcfb3 100644 --- a/src/index.js +++ b/src/index.js @@ -33,7 +33,12 @@ class AppID { this.URL = url; this.utils = utils; if (!utils) { - this.utils = new Utils({openIdConfigResource: this.openIdConfigResource, url: this.URL, popup: this.popup, jsrsasign}); + this.utils = new Utils({ + openIdConfigResource: this.openIdConfigResource, + url: this.URL, + popup: this.popup, + jsrsasign + }); } this.request = requestHandler.request; this.window = w; @@ -176,13 +181,13 @@ class AppID { this._validateInitalize(); let userId; - if (!idTokenPayload){ + if (!idTokenPayload) { throw new AppIDError(constants.MISSING_ID_TOKEN_PAYLOAD); } if (typeof idTokenPayload === 'string') { throw new AppIDError(constants.INVALID_ID_TOKEN_PAYLOAD); } - if(idTokenPayload.identities && idTokenPayload.identities[0] && idTokenPayload.identities[0].id) { + if (idTokenPayload.identities && idTokenPayload.identities[0] && idTokenPayload.identities[0].id) { if (idTokenPayload.identities[0].provider !== 'cloud_directory') { throw new AppIDError(constants.NOT_CD_USER); } @@ -200,6 +205,26 @@ class AppID { }); } + async changeDetails(tokens) { + // get code + const generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE; + console.log(generateCodeUrl); + const changeDetailsCode = await this.request(generateCodeUrl, { + headers: { + 'Authorization': 'Bearer ' + tokens.accessToken + ' ' + tokens.idToken + } + }); + const endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS; + + // send code with url + return this.utils.performOAuthFlowAndGetTokens({ + origin: this.window.origin, + clientId: this.clientId, + endpoint, + changeDetailsCode + }); + } + /** * * @private diff --git a/src/utils.js b/src/utils.js index 5be994e..fdc1656 100644 --- a/src/utils.js +++ b/src/utils.js @@ -45,7 +45,7 @@ class Utils { return {codeVerifier, codeChallenge, state, nonce}; } - getAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId}) { + getAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId, changeDetailsCode}) { const {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields(); let authParams = { client_id: clientId, @@ -67,6 +67,10 @@ class Utils { authParams.user_id = userId; } + if (changeDetailsCode) { + authParams.code = changeDetailsCode; + } + const url = endpoint + '?' + this.buildParams(authParams); return { codeVerifier, @@ -76,8 +80,8 @@ class Utils { }; } - async performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint}) { - const {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint}); + async performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint, changeDetailsCode}) { + const {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint, changeDetailsCode}); this.popup.open(); this.popup.navigate(url); From 2a4f9a533db41ba20215d62005135011720640f5 Mon Sep 17 00:00:00 2001 From: Joyce Huang Date: Fri, 25 Oct 2019 14:26:04 -0500 Subject: [PATCH 2/9] adding docs + error handling --- dist/appid.min.js | 385 ++++++---------------------------------- dist/appid.umd.min.js | 395 ++++++------------------------------------ src/constants.js | 3 + src/index.js | 27 ++- 4 files changed, 127 insertions(+), 683 deletions(-) diff --git a/dist/appid.min.js b/dist/appid.min.js index c15f773..cd99209 100644 --- a/dist/appid.min.js +++ b/dist/appid.min.js @@ -1,335 +1,50 @@ -var AppID = -/******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ "./node_modules/base64-js/index.js": -/*!*****************************************!*\ - !*** ./node_modules/base64-js/index.js ***! - \*****************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/base64-js/index.js?"); - -/***/ }), - -/***/ "./node_modules/buffer/index.js": -/*!**************************************!*\ - !*** ./node_modules/buffer/index.js ***! - \**************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("/* WEBPACK VAR INJECTION */(function(global) {/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n\n\nvar base64 = __webpack_require__(/*! base64-js */ \"./node_modules/base64-js/index.js\")\nvar ieee754 = __webpack_require__(/*! ieee754 */ \"./node_modules/ieee754/index.js\")\nvar isArray = __webpack_require__(/*! isarray */ \"./node_modules/isarray/index.js\")\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://AppID/./node_modules/buffer/index.js?"); - -/***/ }), - -/***/ "./node_modules/ieee754/index.js": -/*!***************************************!*\ - !*** ./node_modules/ieee754/index.js ***! - \***************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/ieee754/index.js?"); - -/***/ }), - -/***/ "./node_modules/isarray/index.js": -/*!***************************************!*\ - !*** ./node_modules/isarray/index.js ***! - \***************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n\n\n//# sourceURL=webpack://AppID/./node_modules/isarray/index.js?"); - -/***/ }), - -/***/ "./node_modules/jsrsasign/lib/jsrsasign.js": -/*!*************************************************!*\ - !*** ./node_modules/jsrsasign/lib/jsrsasign.js ***! - \*************************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\nvar navigator = {};\nnavigator.userAgent = false;\n\nvar window = {};\n/*\n * jsrsasign(all) 8.0.12 (2018-04-22) (c) 2010-2018 Kenji Urushima | kjur.github.com/jsrsasign/license\n */\n\n/*!\nCopyright (c) 2011, Yahoo! Inc. All rights reserved.\nCode licensed under the BSD License:\nhttp://developer.yahoo.com/yui/license.html\nversion: 2.9.0\n*/\nif(YAHOO===undefined){var YAHOO={}}YAHOO.lang={extend:function(g,h,f){if(!h||!g){throw new Error(\"YAHOO.lang.extend failed, please check that all dependencies are included.\")}var d=function(){};d.prototype=h.prototype;g.prototype=new d();g.prototype.constructor=g;g.superclass=h.prototype;if(h.prototype.constructor==Object.prototype.constructor){h.prototype.constructor=h}if(f){var b;for(b in f){g.prototype[b]=f[b]}var e=function(){},c=[\"toString\",\"valueOf\"];try{if(/MSIE/.test(navigator.userAgent)){e=function(j,i){for(b=0;b>>2]>>>(24-(r%4)*8))&255;q[(n+r)>>>2]|=o<<(24-((n+r)%4)*8)}}else{for(var r=0;r>>2]=p[r>>>2]}}this.sigBytes+=s;return this},clamp:function(){var o=this.words;var n=this.sigBytes;o[n>>>2]&=4294967295<<(32-(n%4)*8);o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);n.words=this.words.slice(0);return n},random:function(p){var o=[];for(var n=0;n>>2]>>>(24-(n%4)*8))&255;q.push((s>>>4).toString(16));q.push((s&15).toString(16))}return q.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>3]|=parseInt(p.substr(o,2),16)<<(24-(o%8)*4)}return new l.init(q,n/2)}};var d=m.Latin1={stringify:function(q){var r=q.words;var p=q.sigBytes;var n=[];for(var o=0;o>>2]>>>(24-(o%4)*8))&255;n.push(String.fromCharCode(s))}return n.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>2]|=(p.charCodeAt(o)&255)<<(24-(o%4)*8)}return new l.init(q,n)}};var c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error(\"Malformed UTF-8 data\")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}};var i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init();this._nDataBytes=0},_append:function(n){if(typeof n==\"string\"){n=c.parse(n)}this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data;var x=q.words;var n=q.sigBytes;var t=this.blockSize;var v=t*4;var u=n/v;if(w){u=e.ceil(u)}else{u=e.max((u|0)-this._minBufferSize,0)}var s=u*t;var r=e.min(s*4,n);if(s){for(var p=0;p>>2]&255}};f.BlockCipher=n.extend({cfg:n.cfg.extend({mode:m,padding:h}),reset:function(){n.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;\nthis._mode=c.call(a,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var p=f.CipherParams=k.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(g.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;\nreturn(a?l.create([1398893684,1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=l.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return p.create({ciphertext:a,salt:c})}},j=f.SerializableCipher=k.extend({cfg:k.extend({format:m}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return p.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,\nblockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return\"string\"==typeof a?b.parse(a,this):a}}),g=(g.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=l.random(8));a=v.create({keySize:b+c}).compute(a,d);c=l.create(a.words.slice(b),4*c);a.sigBytes=4*b;return p.create({key:a,iv:c,salt:d})}},s=f.PasswordBasedCipher=j.extend({cfg:j.cfg.extend({kdf:g}),encrypt:function(a,\nb,c,d){d=this.cfg.extend(d);c=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=c.iv;a=j.encrypt.call(this,a,b,c.key,d);a.mixIn(c);return a},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=c.iv;return j.decrypt.call(this,a,b,c.key,d)}})}();\n\n/*\nCryptoJS v3.1.2 aes.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){for(var q=CryptoJS,x=q.lib.BlockCipher,r=q.algo,j=[],y=[],z=[],A=[],B=[],C=[],s=[],u=[],v=[],w=[],g=[],k=0;256>k;k++)g[k]=128>k?k<<1:k<<1^283;for(var n=0,l=0,k=0;256>k;k++){var f=l^l<<1^l<<2^l<<3^l<<4,f=f>>>8^f&255^99;j[n]=f;y[f]=n;var t=g[n],D=g[t],E=g[D],b=257*g[f]^16843008*f;z[n]=b<<24|b>>>8;A[n]=b<<16|b>>>16;B[n]=b<<8|b>>>24;C[n]=b;b=16843009*E^65537*D^257*t^16843008*n;s[f]=b<<24|b>>>8;u[f]=b<<16|b>>>16;v[f]=b<<8|b>>>24;w[f]=b;n?(n=t^g[g[g[E^t]]],l^=g[g[l]]):n=l=1}var F=[0,1,2,4,8,\n16,32,64,128,27,54],r=r.AES=x.extend({_doReset:function(){for(var c=this._key,e=c.words,a=c.sigBytes/4,c=4*((this._nRounds=a+6)+1),b=this._keySchedule=[],h=0;h>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255]):(d=d<<8|d>>>24,d=j[d>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255],d^=F[h/a|0]<<24);b[h]=b[h-a]^d}e=this._invKeySchedule=[];for(a=0;aa||4>=h?d:s[j[d>>>24]]^u[j[d>>>16&255]]^v[j[d>>>\n8&255]]^w[j[d&255]]},encryptBlock:function(c,e){this._doCryptBlock(c,e,this._keySchedule,z,A,B,C,j)},decryptBlock:function(c,e){var a=c[e+1];c[e+1]=c[e+3];c[e+3]=a;this._doCryptBlock(c,e,this._invKeySchedule,s,u,v,w,y);a=c[e+1];c[e+1]=c[e+3];c[e+3]=a},_doCryptBlock:function(c,e,a,b,h,d,j,m){for(var n=this._nRounds,f=c[e]^a[0],g=c[e+1]^a[1],k=c[e+2]^a[2],p=c[e+3]^a[3],l=4,t=1;t>>24]^h[g>>>16&255]^d[k>>>8&255]^j[p&255]^a[l++],r=b[g>>>24]^h[k>>>16&255]^d[p>>>8&255]^j[f&255]^a[l++],s=\nb[k>>>24]^h[p>>>16&255]^d[f>>>8&255]^j[g&255]^a[l++],p=b[p>>>24]^h[f>>>16&255]^d[g>>>8&255]^j[k&255]^a[l++],f=q,g=r,k=s;q=(m[f>>>24]<<24|m[g>>>16&255]<<16|m[k>>>8&255]<<8|m[p&255])^a[l++];r=(m[g>>>24]<<24|m[k>>>16&255]<<16|m[p>>>8&255]<<8|m[f&255])^a[l++];s=(m[k>>>24]<<24|m[p>>>16&255]<<16|m[f>>>8&255]<<8|m[g&255])^a[l++];p=(m[p>>>24]<<24|m[f>>>16&255]<<16|m[g>>>8&255]<<8|m[k&255])^a[l++];c[e]=q;c[e+1]=r;c[e+2]=s;c[e+3]=p},keySize:8});q.AES=x._createHelper(r)})();\n\n/*\nCryptoJS v3.1.2 tripledes-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function j(b,c){var a=(this._lBlock>>>b^this._rBlock)&c;this._rBlock^=a;this._lBlock^=a<>>b^this._lBlock)&c;this._lBlock^=a;this._rBlock^=a<a;a++){var f=q[a]-1;c[a]=b[f>>>5]>>>31-f%32&1}b=this._subKeys=[];for(f=0;16>f;f++){for(var d=b[f]=[],e=r[f],a=0;24>a;a++)d[a/6|0]|=c[(p[a]-1+e)%28]<<31-a%6,d[4+(a/6|0)]|=c[28+(p[a+24]-1+e)%28]<<31-a%6;d[0]=d[0]<<1|d[0]>>>31;for(a=1;7>a;a++)d[a]>>>=\n4*(a-1)+3;d[7]=d[7]<<5|d[7]>>>27}c=this._invSubKeys=[];for(a=0;16>a;a++)c[a]=b[15-a]},encryptBlock:function(b,c){this._doCryptBlock(b,c,this._subKeys)},decryptBlock:function(b,c){this._doCryptBlock(b,c,this._invSubKeys)},_doCryptBlock:function(b,c,a){this._lBlock=b[c];this._rBlock=b[c+1];j.call(this,4,252645135);j.call(this,16,65535);l.call(this,2,858993459);l.call(this,8,16711935);j.call(this,1,1431655765);for(var f=0;16>f;f++){for(var d=a[f],e=this._lBlock,h=this._rBlock,g=0,k=0;8>k;k++)g|=s[k][((h^\nd[k])&t[k])>>>0];this._lBlock=h;this._rBlock=e^g}a=this._lBlock;this._lBlock=this._rBlock;this._rBlock=a;j.call(this,1,1431655765);l.call(this,8,16711935);l.call(this,2,858993459);j.call(this,16,65535);j.call(this,4,252645135);b[c]=this._lBlock;b[c+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});h.DES=e._createHelper(m);g=g.TripleDES=e.extend({_doReset:function(){var b=this._key.words;this._des1=m.createEncryptor(n.create(b.slice(0,2)));this._des2=m.createEncryptor(n.create(b.slice(2,4)));this._des3=\nm.createEncryptor(n.create(b.slice(4,6)))},encryptBlock:function(b,c){this._des1.encryptBlock(b,c);this._des2.decryptBlock(b,c);this._des3.encryptBlock(b,c)},decryptBlock:function(b,c){this._des3.decryptBlock(b,c);this._des2.encryptBlock(b,c);this._des1.decryptBlock(b,c)},keySize:6,ivSize:2,blockSize:2});h.TripleDES=e._createHelper(g)})();\n\n/*\nCryptoJS v3.1.2 enc-base64.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join(\"\")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d<\ne;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\"}})();\n\n/*\nCryptoJS v3.1.2 md5.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(E){function h(a,f,g,j,p,h,k){a=a+(f&g|~f&j)+p+k;return(a<>>32-h)+f}function k(a,f,g,j,p,h,k){a=a+(f&j|g&~j)+p+k;return(a<>>32-h)+f}function l(a,f,g,j,h,k,l){a=a+(f^g^j)+h+l;return(a<>>32-k)+f}function n(a,f,g,j,h,k,l){a=a+(g^(f|~j))+h+l;return(a<>>32-k)+f}for(var r=CryptoJS,q=r.lib,F=q.WordArray,s=q.Hasher,q=r.algo,a=[],t=0;64>t;t++)a[t]=4294967296*E.abs(E.sin(t+1))|0;q=q.MD5=s.extend({_doReset:function(){this._hash=new F.init([1732584193,4023233417,2562383102,271733878])},\n_doProcessBlock:function(m,f){for(var g=0;16>g;g++){var j=f+g,p=m[j];m[j]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360}var g=this._hash.words,j=m[f+0],p=m[f+1],q=m[f+2],r=m[f+3],s=m[f+4],t=m[f+5],u=m[f+6],v=m[f+7],w=m[f+8],x=m[f+9],y=m[f+10],z=m[f+11],A=m[f+12],B=m[f+13],C=m[f+14],D=m[f+15],b=g[0],c=g[1],d=g[2],e=g[3],b=h(b,c,d,e,j,7,a[0]),e=h(e,b,c,d,p,12,a[1]),d=h(d,e,b,c,q,17,a[2]),c=h(c,d,e,b,r,22,a[3]),b=h(b,c,d,e,s,7,a[4]),e=h(e,b,c,d,t,12,a[5]),d=h(d,e,b,c,u,17,a[6]),c=h(c,d,e,b,v,22,a[7]),\nb=h(b,c,d,e,w,7,a[8]),e=h(e,b,c,d,x,12,a[9]),d=h(d,e,b,c,y,17,a[10]),c=h(c,d,e,b,z,22,a[11]),b=h(b,c,d,e,A,7,a[12]),e=h(e,b,c,d,B,12,a[13]),d=h(d,e,b,c,C,17,a[14]),c=h(c,d,e,b,D,22,a[15]),b=k(b,c,d,e,p,5,a[16]),e=k(e,b,c,d,u,9,a[17]),d=k(d,e,b,c,z,14,a[18]),c=k(c,d,e,b,j,20,a[19]),b=k(b,c,d,e,t,5,a[20]),e=k(e,b,c,d,y,9,a[21]),d=k(d,e,b,c,D,14,a[22]),c=k(c,d,e,b,s,20,a[23]),b=k(b,c,d,e,x,5,a[24]),e=k(e,b,c,d,C,9,a[25]),d=k(d,e,b,c,r,14,a[26]),c=k(c,d,e,b,w,20,a[27]),b=k(b,c,d,e,B,5,a[28]),e=k(e,b,\nc,d,q,9,a[29]),d=k(d,e,b,c,v,14,a[30]),c=k(c,d,e,b,A,20,a[31]),b=l(b,c,d,e,t,4,a[32]),e=l(e,b,c,d,w,11,a[33]),d=l(d,e,b,c,z,16,a[34]),c=l(c,d,e,b,C,23,a[35]),b=l(b,c,d,e,p,4,a[36]),e=l(e,b,c,d,s,11,a[37]),d=l(d,e,b,c,v,16,a[38]),c=l(c,d,e,b,y,23,a[39]),b=l(b,c,d,e,B,4,a[40]),e=l(e,b,c,d,j,11,a[41]),d=l(d,e,b,c,r,16,a[42]),c=l(c,d,e,b,u,23,a[43]),b=l(b,c,d,e,x,4,a[44]),e=l(e,b,c,d,A,11,a[45]),d=l(d,e,b,c,D,16,a[46]),c=l(c,d,e,b,q,23,a[47]),b=n(b,c,d,e,j,6,a[48]),e=n(e,b,c,d,v,10,a[49]),d=n(d,e,b,c,\nC,15,a[50]),c=n(c,d,e,b,t,21,a[51]),b=n(b,c,d,e,A,6,a[52]),e=n(e,b,c,d,r,10,a[53]),d=n(d,e,b,c,y,15,a[54]),c=n(c,d,e,b,p,21,a[55]),b=n(b,c,d,e,w,6,a[56]),e=n(e,b,c,d,D,10,a[57]),d=n(d,e,b,c,u,15,a[58]),c=n(c,d,e,b,B,21,a[59]),b=n(b,c,d,e,s,6,a[60]),e=n(e,b,c,d,z,10,a[61]),d=n(d,e,b,c,q,15,a[62]),c=n(c,d,e,b,x,21,a[63]);g[0]=g[0]+b|0;g[1]=g[1]+c|0;g[2]=g[2]+d|0;g[3]=g[3]+e|0},_doFinalize:function(){var a=this._data,f=a.words,g=8*this._nDataBytes,j=8*a.sigBytes;f[j>>>5]|=128<<24-j%32;var h=E.floor(g/\n4294967296);f[(j+64>>>9<<4)+15]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;f[(j+64>>>9<<4)+14]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360;a.sigBytes=4*(f.length+1);this._process();a=this._hash;f=a.words;for(g=0;4>g;g++)j=f[g],f[g]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=s.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=s._createHelper(q);r.HmacMD5=s._createHmacHelper(q)})(Math);\n\n/*\nCryptoJS v3.1.2 sha1-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var k=CryptoJS,b=k.lib,m=b.WordArray,l=b.Hasher,d=[],b=k.algo.SHA1=l.extend({_doReset:function(){this._hash=new m.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(n,p){for(var a=this._hash.words,e=a[0],f=a[1],h=a[2],j=a[3],b=a[4],c=0;80>c;c++){if(16>c)d[c]=n[p+c]|0;else{var g=d[c-3]^d[c-8]^d[c-14]^d[c-16];d[c]=g<<1|g>>>31}g=(e<<5|e>>>27)+b+d[c];g=20>c?g+((f&h|~f&j)+1518500249):40>c?g+((f^h^j)+1859775393):60>c?g+((f&h|f&j|h&j)-1894007588):g+((f^h^\nj)-899497514);b=j;j=h;h=f<<30|f>>>2;f=e;e=g}a[0]=a[0]+e|0;a[1]=a[1]+f|0;a[2]=a[2]+h|0;a[3]=a[3]+j|0;a[4]=a[4]+b|0},_doFinalize:function(){var b=this._data,d=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=Math.floor(a/4294967296);d[(e+64>>>9<<4)+15]=a;b.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var b=l.clone.call(this);b._hash=this._hash.clone();return b}});k.SHA1=l._createHelper(b);k.HmacSHA1=l._createHmacHelper(b)})();\n\n/*\nCryptoJS v3.1.2 sha256-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(k){for(var g=CryptoJS,h=g.lib,v=h.WordArray,j=h.Hasher,h=g.algo,s=[],t=[],u=function(q){return 4294967296*(q-(q|0))|0},l=2,b=0;64>b;){var d;a:{d=l;for(var w=k.sqrt(d),r=2;r<=w;r++)if(!(d%r)){d=!1;break a}d=!0}d&&(8>b&&(s[b]=u(k.pow(l,0.5))),t[b]=u(k.pow(l,1/3)),b++);l++}var n=[],h=h.SHA256=j.extend({_doReset:function(){this._hash=new v.init(s.slice(0))},_doProcessBlock:function(q,h){for(var a=this._hash.words,c=a[0],d=a[1],b=a[2],k=a[3],f=a[4],g=a[5],j=a[6],l=a[7],e=0;64>e;e++){if(16>e)n[e]=\nq[h+e]|0;else{var m=n[e-15],p=n[e-2];n[e]=((m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3)+n[e-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[e-16]}m=l+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&g^~f&j)+t[e]+n[e];p=((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&d^c&b^d&b);l=j;j=g;g=f;f=k+m|0;k=b;b=d;d=c;c=m+p|0}a[0]=a[0]+c|0;a[1]=a[1]+d|0;a[2]=a[2]+b|0;a[3]=a[3]+k|0;a[4]=a[4]+f|0;a[5]=a[5]+g|0;a[6]=a[6]+j|0;a[7]=a[7]+l|0},_doFinalize:function(){var d=this._data,b=d.words,a=8*this._nDataBytes,c=8*d.sigBytes;\nb[c>>>5]|=128<<24-c%32;b[(c+64>>>9<<4)+14]=k.floor(a/4294967296);b[(c+64>>>9<<4)+15]=a;d.sigBytes=4*b.length;this._process();return this._hash},clone:function(){var b=j.clone.call(this);b._hash=this._hash.clone();return b}});g.SHA256=j._createHelper(h);g.HmacSHA256=j._createHmacHelper(h)})(Math);\n\n/*\nCryptoJS v3.1.2 sha224-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var b=CryptoJS,d=b.lib.WordArray,a=b.algo,c=a.SHA256,a=a.SHA224=c.extend({_doReset:function(){this._hash=new d.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var a=c._doFinalize.call(this);a.sigBytes-=4;return a}});b.SHA224=c._createHelper(a);b.HmacSHA224=c._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 sha512-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function a(){return d.create.apply(d,arguments)}for(var n=CryptoJS,r=n.lib.Hasher,e=n.x64,d=e.Word,T=e.WordArray,e=n.algo,ea=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),\na(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,\n2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),\na(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,\n3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],w=0;80>w;w++)v[w]=a();e=e.SHA512=r.extend({_doReset:function(){this._hash=new T.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(a,d){for(var f=this._hash.words,\nF=f[0],e=f[1],n=f[2],r=f[3],G=f[4],H=f[5],I=f[6],f=f[7],w=F.high,J=F.low,X=e.high,K=e.low,Y=n.high,L=n.low,Z=r.high,M=r.low,$=G.high,N=G.low,aa=H.high,O=H.low,ba=I.high,P=I.low,ca=f.high,Q=f.low,k=w,g=J,z=X,x=K,A=Y,y=L,U=Z,B=M,l=$,h=N,R=aa,C=O,S=ba,D=P,V=ca,E=Q,m=0;80>m;m++){var s=v[m];if(16>m)var j=s.high=a[d+2*m]|0,b=s.low=a[d+2*m+1]|0;else{var j=v[m-15],b=j.high,p=j.low,j=(b>>>1|p<<31)^(b>>>8|p<<24)^b>>>7,p=(p>>>1|b<<31)^(p>>>8|b<<24)^(p>>>7|b<<25),u=v[m-2],b=u.high,c=u.low,u=(b>>>19|c<<13)^(b<<\n3|c>>>29)^b>>>6,c=(c>>>19|b<<13)^(c<<3|b>>>29)^(c>>>6|b<<26),b=v[m-7],W=b.high,t=v[m-16],q=t.high,t=t.low,b=p+b.low,j=j+W+(b>>>0

>>0?1:0),b=b+c,j=j+u+(b>>>0>>0?1:0),b=b+t,j=j+q+(b>>>0>>0?1:0);s.high=j;s.low=b}var W=l&R^~l&S,t=h&C^~h&D,s=k&z^k&A^z&A,T=g&x^g&y^x&y,p=(k>>>28|g<<4)^(k<<30|g>>>2)^(k<<25|g>>>7),u=(g>>>28|k<<4)^(g<<30|k>>>2)^(g<<25|k>>>7),c=ea[m],fa=c.high,da=c.low,c=E+((h>>>14|l<<18)^(h>>>18|l<<14)^(h<<23|l>>>9)),q=V+((l>>>14|h<<18)^(l>>>18|h<<14)^(l<<23|h>>>9))+(c>>>0>>0?1:\n0),c=c+t,q=q+W+(c>>>0>>0?1:0),c=c+da,q=q+fa+(c>>>0>>0?1:0),c=c+b,q=q+j+(c>>>0>>0?1:0),b=u+T,s=p+s+(b>>>0>>0?1:0),V=S,E=D,S=R,D=C,R=l,C=h,h=B+c|0,l=U+q+(h>>>0>>0?1:0)|0,U=A,B=y,A=z,y=x,z=k,x=g,g=c+b|0,k=q+s+(g>>>0>>0?1:0)|0}J=F.low=J+g;F.high=w+k+(J>>>0>>0?1:0);K=e.low=K+x;e.high=X+z+(K>>>0>>0?1:0);L=n.low=L+y;n.high=Y+A+(L>>>0>>0?1:0);M=r.low=M+B;r.high=Z+U+(M>>>0>>0?1:0);N=G.low=N+h;G.high=$+l+(N>>>0>>0?1:0);O=H.low=O+C;H.high=aa+R+(O>>>0>>0?1:0);P=I.low=P+D;\nI.high=ba+S+(P>>>0>>0?1:0);Q=f.low=Q+E;f.high=ca+V+(Q>>>0>>0?1:0)},_doFinalize:function(){var a=this._data,d=a.words,f=8*this._nDataBytes,e=8*a.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+128>>>10<<5)+30]=Math.floor(f/4294967296);d[(e+128>>>10<<5)+31]=f;a.sigBytes=4*d.length;this._process();return this._hash.toX32()},clone:function(){var a=r.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});n.SHA512=r._createHelper(e);n.HmacSHA512=r._createHmacHelper(e)})();\n\n/*\nCryptoJS v3.1.2 sha384-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,a=c.x64,b=a.Word,e=a.WordArray,a=c.algo,d=a.SHA512,a=a.SHA384=d.extend({_doReset:function(){this._hash=new e.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var a=d._doFinalize.call(this);a.sigBytes-=16;return a}});c.SHA384=\nd._createHelper(a);c.HmacSHA384=d._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 ripemd160-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n/*\n\n(c) 2012 by Cedric Mesnil. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n(function(){var q=CryptoJS,d=q.lib,n=d.WordArray,p=d.Hasher,d=q.algo,x=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),y=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),z=n.create([11,14,15,12,\n5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),A=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),B=n.create([0,1518500249,1859775393,2400959708,2840853838]),C=n.create([1352829926,1548603684,1836072691,\n2053994217,0]),d=d.RIPEMD160=p.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,v){for(var b=0;16>b;b++){var c=v+b,f=e[c];e[c]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360}var c=this._hash.words,f=B.words,d=C.words,n=x.words,q=y.words,p=z.words,w=A.words,t,g,h,j,r,u,k,l,m,s;u=t=c[0];k=g=c[1];l=h=c[2];m=j=c[3];s=r=c[4];for(var a,b=0;80>b;b+=1)a=t+e[v+n[b]]|0,a=16>b?a+((g^h^j)+f[0]):32>b?a+((g&h|~g&j)+f[1]):48>b?\na+(((g|~h)^j)+f[2]):64>b?a+((g&j|h&~j)+f[3]):a+((g^(h|~j))+f[4]),a|=0,a=a<>>32-p[b],a=a+r|0,t=r,r=j,j=h<<10|h>>>22,h=g,g=a,a=u+e[v+q[b]]|0,a=16>b?a+((k^(l|~m))+d[0]):32>b?a+((k&m|l&~m)+d[1]):48>b?a+(((k|~l)^m)+d[2]):64>b?a+((k&l|~k&m)+d[3]):a+((k^l^m)+d[4]),a|=0,a=a<>>32-w[b],a=a+s|0,u=s,s=m,m=l<<10|l>>>22,l=k,k=a;a=c[1]+h+m|0;c[1]=c[2]+j+s|0;c[2]=c[3]+r+u|0;c[3]=c[4]+t+k|0;c[4]=c[0]+g+l|0;c[0]=a},_doFinalize:function(){var e=this._data,d=e.words,b=8*this._nDataBytes,c=8*e.sigBytes;\nd[c>>>5]|=128<<24-c%32;d[(c+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;e.sigBytes=4*(d.length+1);this._process();e=this._hash;d=e.words;for(b=0;5>b;b++)c=d[b],d[b]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return e},clone:function(){var d=p.clone.call(this);d._hash=this._hash.clone();return d}});q.RIPEMD160=p._createHelper(d);q.HmacRIPEMD160=p._createHmacHelper(d)})(Math);\n\n/*\nCryptoJS v3.1.2 hmac.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,k=c.enc.Utf8;c.algo.HMAC=c.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;\"string\"==typeof b&&(b=k.parse(b));var c=a.blockSize,e=4*c;b.sigBytes>e&&(b=a.finalize(b));b.clamp();for(var f=this._oKey=b.clone(),g=this._iKey=b.clone(),h=f.words,j=g.words,d=0;d>6)+b64map.charAt(e&63)}if(b+1==d.length){e=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(e<<2)}else{if(b+2==d.length){e=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(e>>2)+b64map.charAt((e&3)<<4)}}if(b64pad){while((a.length&3)>0){a+=b64pad}}return a}function b64tohex(f){var d=\"\";var e;var b=0;var c;var a;for(e=0;e>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(e){var d=b64tohex(e);var c;var b=new Array();for(c=0;2*c=0){var d=a*this[f++]+b[e]+h;h=Math.floor(d/67108864);b[e++]=d&67108863}return h}function am2(f,q,r,e,o,a){var k=q&32767,p=q>>15;while(--a>=0){var d=this[f]&32767;var g=this[f++]>>15;var b=p*d+g*k;d=k*d+((b&32767)<<15)+r[e]+(o&1073741823);o=(d>>>30)+(b>>>15)+p*g+(o>>>30);r[e++]=d&1073741823}return o}function am3(f,q,r,e,o,a){var k=q&16383,p=q>>14;while(--a>=0){var d=this[f]&16383;var g=this[f++]>>14;var b=p*d+g*k;d=k*d+((b&16383)<<14)+r[e]+o;o=(d>>28)+(b>>14)+p*g;r[e++]=d&268435455}return o}if(j_lm&&(navigator.appName==\"Microsoft Internet Explorer\")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator.appName!=\"Netscape\")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=((1<=0;--a){b[a]=this[a]}b.t=this.t;b.s=this.s}function bnpFromInt(a){this.t=1;this.s=(a<0)?-1:0;if(a>0){this[0]=a}else{if(a<-1){this[0]=a+this.DV}else{this.t=0}}}function nbv(a){var b=nbi();b.fromInt(a);return b}function bnpFromString(h,c){var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==256){e=8}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{this.fromRadix(h,c);return}}}}}}this.t=0;this.s=0;var g=h.length,d=false,f=0;while(--g>=0){var a=(e==8)?h[g]&255:intAt(h,g);if(a<0){if(h.charAt(g)==\"-\"){d=true}continue}d=false;if(f==0){this[this.t++]=a}else{if(f+e>this.DB){this[this.t-1]|=(a&((1<<(this.DB-f))-1))<>(this.DB-f))}else{this[this.t-1]|=a<=this.DB){f-=this.DB}}if(e==8&&(h[0]&128)!=0){this.s=-1;if(f>0){this[this.t-1]|=((1<<(this.DB-f))-1)<0&&this[this.t-1]==a){--this.t}}function bnToString(c){if(this.s<0){return\"-\"+this.negate().toString(c)}var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{return this.toRadix(c)}}}}}var g=(1<0){if(j>j)>0){a=true;h=int2char(l)}while(f>=0){if(j>(j+=this.DB-e)}else{l=(this[f]>>(j-=e))&g;if(j<=0){j+=this.DB;--f}}if(l>0){a=true}if(a){h+=int2char(l)}}}return a?h:\"0\"}function bnNegate(){var a=nbi();BigInteger.ZERO.subTo(this,a);return a}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(b){var d=this.s-b.s;if(d!=0){return d}var c=this.t;d=c-b.t;if(d!=0){return(this.s<0)?-d:d}while(--c>=0){if((d=this[c]-b[c])!=0){return d}}return 0}function nbits(a){var c=1,b;if((b=a>>>16)!=0){a=b;c+=16}if((b=a>>8)!=0){a=b;c+=8}if((b=a>>4)!=0){a=b;c+=4}if((b=a>>2)!=0){a=b;c+=2}if((b=a>>1)!=0){a=b;c+=1}return c}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(c,b){var a;for(a=this.t-1;a>=0;--a){b[a+c]=this[a]}for(a=c-1;a>=0;--a){b[a]=0}b.t=this.t+c;b.s=this.s}function bnpDRShiftTo(c,b){for(var a=c;a=0;--d){e[d+f+1]=(this[d]>>a)|h;h=(this[d]&g)<=0;--d){e[d]=0}e[f]=h;e.t=this.t+f+1;e.s=this.s;e.clamp()}function bnpRShiftTo(g,d){d.s=this.s;var e=Math.floor(g/this.DB);if(e>=this.t){d.t=0;return}var b=g%this.DB;var a=this.DB-b;var f=(1<>b;for(var c=e+1;c>b}if(b>0){d[this.t-e-1]|=(this.s&f)<>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g-=d.s}f.s=(g<0)?-1:0;if(g<-1){f[e++]=this.DV+g}else{if(g>0){f[e++]=g}}f.t=e;f.clamp()}function bnpMultiplyTo(c,e){var b=this.abs(),f=c.abs();var d=b.t;e.t=d+f.t;while(--d>=0){e[d]=0}for(d=0;d=0){d[b]=0}for(b=0;b=a.DV){d[b+a.t]-=a.DV;d[b+a.t+1]=1}}if(d.t>0){d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)}d.s=0;d.clamp()}function bnpDivRemTo(n,h,g){var w=n.abs();if(w.t<=0){return}var k=this.abs();if(k.t0){w.lShiftTo(v,d);k.lShiftTo(v,g)}else{w.copyTo(d);k.copyTo(g)}var p=d.t;var b=d[p-1];if(b==0){return}var o=b*(1<1)?d[p-2]>>this.F2:0);var A=this.FV/o,z=(1<=0){g[g.t++]=1;g.subTo(f,g)}BigInteger.ONE.dlShiftTo(p,f);f.subTo(d,d);while(d.t=0){var c=(g[--u]==b)?this.DM:Math.floor(g[u]*A+(g[u-1]+x)*z);if((g[u]+=d.am(0,c,g,s,0,p))0){g.rShiftTo(v,g)}if(a<0){BigInteger.ZERO.subTo(g,g)}}function bnMod(b){var c=nbi();this.abs().divRemTo(b,null,c);if(this.s<0&&c.compareTo(BigInteger.ZERO)>0){b.subTo(c,c)}return c}function Classic(a){this.m=a}function cConvert(a){if(a.s<0||a.compareTo(this.m)>=0){return a.mod(this.m)}else{return a}}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var a=this[0];if((a&1)==0){return 0}var b=a&3;b=(b*(2-(a&15)*b))&15;b=(b*(2-(a&255)*b))&255;b=(b*(2-(((a&65535)*b)&65535)))&65535;b=(b*(2-a*b%this.DV))%this.DV;return(b>0)?this.DV-b:-b}function Montgomery(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(a.DB-15))-1;this.mt2=2*a.t}function montConvert(a){var b=nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);if(a.s<0&&b.compareTo(BigInteger.ZERO)>0){this.m.subTo(b,b)}return b}function montRevert(a){var b=nbi();a.copyTo(b);this.reduce(b);return b}function montReduce(a){while(a.t<=this.mt2){a[a.t++]=0}for(var c=0;c>15)*this.mpl)&this.um)<<15))&a.DM;b=c+this.m.t;a[b]+=this.m.am(0,d,a,c,0,this.m.t);while(a[b]>=a.DV){a[b]-=a.DV;a[++b]++}}a.clamp();a.drShiftTo(this.m.t,a);if(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(h,j){if(h>4294967295||h<1){return BigInteger.ONE}var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;d.copyTo(f);while(--c>=0){j.sqrTo(f,a);if((h&(1<0){j.mulTo(a,d,f)}else{var b=f;f=a;a=b}}return j.revert(f)}function bnModPowInt(b,a){var c;if(b<256||a.isEven()){c=new Classic(a)}else{c=new Montgomery(a)}return this.exp(b,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction bnClone(){var a=nbi();this.copyTo(a);return a}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this[0]}else{if(this.t==0){return 0}}}return((this[1]&((1<<(32-this.DB))-1))<>24}function bnShortValue(){return(this.t==0)?this.s:(this[0]<<16)>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this[0]<=0)){return 0}else{return 1}}}function bnpToRadix(c){if(c==null){c=10}if(this.signum()==0||c<2||c>36){return\"0\"}var f=this.chunkSize(c);var e=Math.pow(c,f);var i=nbv(e),j=nbi(),h=nbi(),g=\"\";this.divRemTo(i,j,h);while(j.signum()>0){g=(e+h.intValue()).toString(c).substr(1)+g;j.divRemTo(i,j,h)}return h.intValue().toString(c)+g}function bnpFromRadix(m,h){this.fromInt(0);if(h==null){h=10}var f=this.chunkSize(h);var g=Math.pow(h,f),e=false,a=0,l=0;for(var c=0;c=f){this.dMultiply(g);this.dAddOffset(l,0);a=0;l=0}}if(a>0){this.dMultiply(Math.pow(h,a));this.dAddOffset(l,0)}if(e){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(f,e,h){if(\"number\"==typeof e){if(f<2){this.fromInt(1)}else{this.fromNumber(f,h);if(!this.testBit(f-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(f-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(e)){this.dAddOffset(2,0);if(this.bitLength()>f){this.subTo(BigInteger.ONE.shiftLeft(f-1),this)}}}}else{var d=new Array(),g=f&7;d.length=(f>>3)+1;e.nextBytes(d);if(g>0){d[0]&=((1<0){if(e>e)!=(this.s&this.DM)>>e){c[a++]=f|(this.s<<(this.DB-e))}while(b>=0){if(e<8){f=(this[b]&((1<>(e+=this.DB-8)}else{f=(this[b]>>(e-=8))&255;if(e<=0){e+=this.DB;--b}}if((f&128)!=0){f|=-256}if(a==0&&(this.s&128)!=(f&128)){++a}if(a>0||f!=this.s){c[a++]=f}}}return c}function bnEquals(b){return(this.compareTo(b)==0)}function bnMin(b){return(this.compareTo(b)<0)?this:b}function bnMax(b){return(this.compareTo(b)>0)?this:b}function bnpBitwiseTo(c,h,e){var d,g,b=Math.min(c.t,this.t);for(d=0;d>=16;b+=16}if((a&255)==0){a>>=8;b+=8}if((a&15)==0){a>>=4;b+=4}if((a&3)==0){a>>=2;b+=2}if((a&1)==0){++b}return b}function bnGetLowestSetBit(){for(var a=0;a=this.t){return(this.s!=0)}return((this[a]&(1<<(b%this.DB)))!=0)}function bnpChangeBit(c,b){var a=BigInteger.ONE.shiftLeft(c);this.bitwiseTo(a,b,a);return a}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(d,f){var e=0,g=0,b=Math.min(d.t,this.t);while(e>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g+=d.s}f.s=(g<0)?-1:0;if(g>0){f[e++]=g}else{if(g<-1){f[e++]=this.DV+g}}f.t=e;f.clamp()}function bnAdd(b){var c=nbi();this.addTo(b,c);return c}function bnSubtract(b){var c=nbi();this.subTo(b,c);return c}function bnMultiply(b){var c=nbi();this.multiplyTo(b,c);return c}function bnSquare(){var a=nbi();this.squareTo(a);return a}function bnDivide(b){var c=nbi();this.divRemTo(b,c,null);return c}function bnRemainder(b){var c=nbi();this.divRemTo(b,null,c);return c}function bnDivideAndRemainder(b){var d=nbi(),c=nbi();this.divRemTo(b,d,c);return new Array(d,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(b,a){if(b==0){return}while(this.t<=a){this[this.t++]=0}this[a]+=b;while(this[a]>=this.DV){this[a]-=this.DV;if(++a>=this.t){this[this.t++]=0}++this[a]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,c,b){a.multiplyTo(c,b)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp())}function bnpMultiplyLowerTo(b,f,e){var d=Math.min(this.t+b.t,f);e.s=0;e.t=d;while(d>0){e[--d]=0}var c;for(c=e.t-this.t;d=0){d[c]=0}for(c=Math.max(e-this.t,0);c2*this.m.t){return a.mod(this.m)}else{if(a.compareTo(this.m)<0){return a}else{var b=nbi();a.copyTo(b);this.reduce(b);return b}}}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1){a.t=this.m.t+1;a.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0){a.dAddOffset(1,this.m.t+1)}a.subTo(this.r2,a);while(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(q,f){var o=q.bitLength(),h,b=nbv(1),v;if(o<=0){return b}else{if(o<18){h=1}else{if(o<48){h=3}else{if(o<144){h=4}else{if(o<768){h=5}else{h=6}}}}}if(o<8){v=new Classic(f)}else{if(f.isEven()){v=new Barrett(f)}else{v=new Montgomery(f)}}var p=new Array(),d=3,s=h-1,a=(1<1){var A=nbi();v.sqrTo(p[1],A);while(d<=a){p[d]=nbi();v.mulTo(A,p[d-2],p[d]);d+=2}}var l=q.t-1,x,u=true,c=nbi(),y;o=nbits(q[l])-1;while(l>=0){if(o>=s){x=(q[l]>>(o-s))&a}else{x=(q[l]&((1<<(o+1))-1))<<(s-o);if(l>0){x|=q[l-1]>>(this.DB+o-s)}}d=h;while((x&1)==0){x>>=1;--d}if((o-=d)<0){o+=this.DB;--l}if(u){p[x].copyTo(b);u=false}else{while(d>1){v.sqrTo(b,c);v.sqrTo(c,b);d-=2}if(d>0){v.sqrTo(b,c)}else{y=b;b=c;c=y}v.mulTo(c,p[x],b)}while(l>=0&&(q[l]&(1<0){b.rShiftTo(f,b);h.rShiftTo(f,h)}while(b.signum()>0){if((d=b.getLowestSetBit())>0){b.rShiftTo(d,b)}if((d=h.getLowestSetBit())>0){h.rShiftTo(d,h)}if(b.compareTo(h)>=0){b.subTo(h,b);b.rShiftTo(1,b)}else{h.subTo(b,h);h.rShiftTo(1,h)}}if(f>0){h.lShiftTo(f,h)}return h}function bnpModInt(e){if(e<=0){return 0}var c=this.DV%e,b=(this.s<0)?e-1:0;if(this.t>0){if(c==0){b=this[0]%e}else{for(var a=this.t-1;a>=0;--a){b=(c*b+this[a])%e}}}return b}function bnModInverse(f){var j=f.isEven();if((this.isEven()&&j)||f.signum()==0){return BigInteger.ZERO}var i=f.clone(),h=this.clone();var g=nbv(1),e=nbv(0),l=nbv(0),k=nbv(1);while(i.signum()!=0){while(i.isEven()){i.rShiftTo(1,i);if(j){if(!g.isEven()||!e.isEven()){g.addTo(this,g);e.subTo(f,e)}g.rShiftTo(1,g)}else{if(!e.isEven()){e.subTo(f,e)}}e.rShiftTo(1,e)}while(h.isEven()){h.rShiftTo(1,h);if(j){if(!l.isEven()||!k.isEven()){l.addTo(this,l);k.subTo(f,k)}l.rShiftTo(1,l)}else{if(!k.isEven()){k.subTo(f,k)}}k.rShiftTo(1,k)}if(i.compareTo(h)>=0){i.subTo(h,i);if(j){g.subTo(l,g)}e.subTo(k,e)}else{h.subTo(i,h);if(j){l.subTo(g,l)}k.subTo(e,k)}}if(h.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(k.compareTo(f)>=0){return k.subtract(f)}if(k.signum()<0){k.addTo(f,k)}else{return k}if(k.signum()<0){return k.add(f)}else{return k}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(e){var d,b=this.abs();if(b.t==1&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d>1;if(f>lowprimes.length){f=lowprimes.length}var b=nbi();for(var e=0;e>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(window!==undefined&&(window.crypto!==undefined||window.msCrypto!==undefined)){var crypto=window.crypto||window.msCrypto;if(crypto.getRandomValues){var ua=new Uint8Array(32);crypto.getRandomValues(ua);for(t=0;t<32;++t){rng_pool[rng_pptr++]=ua[t]}}else{if(navigator.appName==\"Netscape\"&&navigator.appVersion<\"5\"){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr=0&&h>0){var f=e.charCodeAt(d--);if(f<128){g[--h]=f}else{if((f>127)&&(f<2048)){g[--h]=(f&63)|128;g[--h]=(f>>6)|192}else{g[--h]=(f&63)|128;g[--h]=((f>>6)&63)|128;g[--h]=(f>>12)|224}}}g[--h]=0;var b=new SecureRandom();var a=new Array();while(h>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}g[--h]=a[0]}g[--h]=2;g[--h]=0;return new BigInteger(g)}function oaep_mgf1_arr(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255])));d+=1}return b}function oaep_pad(q,a,f,l){var c=KJUR.crypto.MessageDigest;var o=KJUR.crypto.Util;var b=null;if(!f){f=\"sha1\"}if(typeof f===\"string\"){b=c.getCanonicalAlgName(f);l=c.getHashLength(b);f=function(i){return hextorstr(o.hashHex(rstrtohex(i),b))}}if(q.length+2*l+2>a){throw\"Message too long for RSA\"}var k=\"\",e;for(e=0;e0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{throw\"Invalid RSA public key\"}}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var e=this.doPublic(a);if(e==null){return null}var b=e.toString(16);if((b.length&1)==0){return b}else{return\"0\"+b}}function RSAEncryptOAEP(f,e,b){var a=oaep_pad(f,(this.n.bitLength()+7)>>3,e,b);if(a==null){return null}var g=this.doPublic(a);if(g==null){return null}var d=g.toString(16);if((d.length&1)==0){return d}else{return\"0\"+d}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;RSAKey.prototype.encryptOAEP=RSAEncryptOAEP;RSAKey.prototype.type=\"RSA\";\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction pkcs1unpad2(g,j){var a=g.toByteArray();var f=0;while(f=a.length){return null}}var e=\"\";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}function oaep_unpad(o,b,g,p){var e=KJUR.crypto.MessageDigest;var r=KJUR.crypto.Util;var c=null;if(!g){g=\"sha1\"}if(typeof g===\"string\"){c=e.getCanonicalAlgName(g);p=e.getHashLength(c);g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}}o=o.toByteArray();var h;for(h=0;h0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{throw\"Invalid RSA private key\"}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;this.isPublic=false;if(g==null){throw\"RSASetPrivateEx N == null\"}if(d==null){throw\"RSASetPrivateEx E == null\"}if(g.length==0){throw\"RSASetPrivateEx N.length == 0\"}if(d.length==0){throw\"RSASetPrivateEx E.length == 0\"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{throw\"Invalid RSA private key in RSASetPrivateEx\"}}function RSAGenerate(b,i){var a=new SecureRandom();var f=b>>1;this.e=parseInt(i,16);var c=new BigInteger(i,16);for(;;){for(;;){this.p=new BigInteger(b-f,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(f,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var h=this.p;this.p=this.q;this.q=h}var g=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var e=g.multiply(d);if(e.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(e);this.dmp1=this.d.mod(g);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=true}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}function RSADecryptOAEP(e,d,b){var f=parseBigInt(e,16);var a=this.doPrivate(f);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,d,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP;\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction ECFieldElementFp(b,a){this.x=a;this.q=b}function feFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.x.equals(a.x))}function feFpToBigInteger(){return this.x}function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))}function feFpAdd(a){return new ECFieldElementFp(this.q,this.x.add(a.toBigInteger()).mod(this.q))}function feFpSubtract(a){return new ECFieldElementFp(this.q,this.x.subtract(a.toBigInteger()).mod(this.q))}function feFpMultiply(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger()).mod(this.q))}function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))}function feFpDivide(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger().modInverse(this.q)).mod(this.q))}ECFieldElementFp.prototype.equals=feFpEquals;ECFieldElementFp.prototype.toBigInteger=feFpToBigInteger;ECFieldElementFp.prototype.negate=feFpNegate;ECFieldElementFp.prototype.add=feFpAdd;ECFieldElementFp.prototype.subtract=feFpSubtract;ECFieldElementFp.prototype.multiply=feFpMultiply;ECFieldElementFp.prototype.square=feFpSquare;ECFieldElementFp.prototype.divide=feFpDivide;function ECPointFp(c,a,d,b){this.curve=c;this.x=a;this.y=d;if(b==null){this.z=BigInteger.ONE}else{this.z=b}this.zinv=null}function pointFpGetX(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpGetY(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpEquals(a){if(a==this){return true}if(this.isInfinity()){return a.isInfinity()}if(a.isInfinity()){return this.isInfinity()}var c,b;c=a.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(a.z)).mod(this.curve.q);if(!c.equals(BigInteger.ZERO)){return false}b=a.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(a.z)).mod(this.curve.q);return b.equals(BigInteger.ZERO)}function pointFpIsInfinity(){if((this.x==null)&&(this.y==null)){return true}return this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)}function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)}function pointFpAdd(l){if(this.isInfinity()){return l}if(l.isInfinity()){return this}var p=l.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(l.z)).mod(this.curve.q);var o=l.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(l.z)).mod(this.curve.q);if(BigInteger.ZERO.equals(o)){if(BigInteger.ZERO.equals(p)){return this.twice()}return this.curve.getInfinity()}var j=new BigInteger(\"3\");var e=this.x.toBigInteger();var n=this.y.toBigInteger();var c=l.x.toBigInteger();var k=l.y.toBigInteger();var m=o.square();var i=m.multiply(o);var d=e.multiply(m);var g=p.square().multiply(this.z);var a=g.subtract(d.shiftLeft(1)).multiply(l.z).subtract(i).multiply(o).mod(this.curve.q);var h=d.multiply(j).multiply(p).subtract(n.multiply(i)).subtract(g.multiply(p)).multiply(l.z).add(p.multiply(i)).mod(this.curve.q);var f=i.multiply(this.z).multiply(l.z).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),f)}function pointFpTwice(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var g=new BigInteger(\"3\");var c=this.x.toBigInteger();var h=this.y.toBigInteger();var e=h.multiply(this.z);var j=e.multiply(h).mod(this.curve.q);var i=this.curve.a.toBigInteger();var k=c.square().multiply(g);if(!BigInteger.ZERO.equals(i)){k=k.add(this.z.square().multiply(i))}k=k.mod(this.curve.q);var b=k.square().subtract(c.shiftLeft(3).multiply(j)).shiftLeft(1).multiply(e).mod(this.curve.q);var f=k.multiply(g).multiply(c).subtract(j.shiftLeft(1)).shiftLeft(2).multiply(j).subtract(k.square().multiply(k)).mod(this.curve.q);var d=e.square().multiply(e).shiftLeft(3).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(b),this.curve.fromBigInteger(f),d)}function pointFpMultiply(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add(a?this:l)}}return d}function pointFpMultiplyTwo(c,a,b){var d;if(c.bitLength()>b.bitLength()){d=c.bitLength()-1}else{d=b.bitLength()-1}var f=this.curve.getInfinity();var e=this.add(a);while(d>=0){f=f.twice();if(c.testBit(d)){if(b.testBit(d)){f=f.add(e)}else{f=f.add(this)}}else{if(b.testBit(d)){f=f.add(a)}}--d}return f}ECPointFp.prototype.getX=pointFpGetX;ECPointFp.prototype.getY=pointFpGetY;ECPointFp.prototype.equals=pointFpEquals;ECPointFp.prototype.isInfinity=pointFpIsInfinity;ECPointFp.prototype.negate=pointFpNegate;ECPointFp.prototype.add=pointFpAdd;ECPointFp.prototype.twice=pointFpTwice;ECPointFp.prototype.multiply=pointFpMultiply;ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo;function ECCurveFp(e,d,c){this.q=e;this.a=this.fromBigInteger(d);this.b=this.fromBigInteger(c);this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b))}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)}function curveFpDecodePointHex(d){switch(parseInt(d.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var a=(d.length-2)/2;var c=d.substr(2,a);var b=d.substr(a+2,a);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(b,16)));default:return null}}ECCurveFp.prototype.getQ=curveFpGetQ;ECCurveFp.prototype.getA=curveFpGetA;ECCurveFp.prototype.getB=curveFpGetB;ECCurveFp.prototype.equals=curveFpEquals;ECCurveFp.prototype.getInfinity=curveFpGetInfinity;ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger;ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex;\n/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib\n */\nECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};ECPointFp.prototype.getEncoded=function(c){var d=function(h,f){var g=h.toByteArrayUnsigned();if(fg.length){g.unshift(0)}}return g};var a=this.getX().toBigInteger();var e=this.getY().toBigInteger();var b=d(a,32);if(c){if(e.isEven()){b.unshift(2)}else{b.unshift(3)}}else{b.unshift(4);b=b.concat(d(e,32))}return b};ECPointFp.decodeFrom=function(g,c){var f=c[0];var e=c.length-1;var d=c.slice(1,1+e/2);var b=c.slice(1+e/2,1+e);d.unshift(0);b.unshift(0);var a=new BigInteger(d);var h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.decodeFromHex=function(g,c){var f=c.substr(0,2);var e=c.length-2;var d=c.substr(2,e/2);var b=c.substr(2+e/2,e/2);var a=new BigInteger(d,16);var h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.prototype.add2D=function(c){if(this.isInfinity()){return c}if(c.isInfinity()){return this}if(this.x.equals(c.x)){if(this.y.equals(c.y)){return this.twice()}return this.curve.getInfinity()}var g=c.x.subtract(this.x);var e=c.y.subtract(this.y);var a=e.divide(g);var d=a.square().subtract(this.x).subtract(c.x);var f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var b=this.curve.fromBigInteger(BigInteger.valueOf(2));var e=this.curve.fromBigInteger(BigInteger.valueOf(3));var a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b));var c=a.square().subtract(this.x.multiply(b));var d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)};ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add2D(a?this:l)}}return d};ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger();var i=this.getY().toBigInteger();var f=this.curve.getA().toBigInteger();var c=this.curve.getB().toBigInteger();var h=this.curve.getQ();var e=i.multiply(i).mod(h);var g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)};ECPointFp.prototype.toString=function(){return\"(\"+this.getX().toBigInteger().toString()+\",\"+this.getY().toBigInteger().toString()+\")\"};ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity()){throw new Error(\"Point is at infinity.\")}var a=this.getX().toBigInteger();var b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"x coordinate out of bounds\")}if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"y coordinate out of bounds\")}if(!this.isOnCurve()){throw new Error(\"Point is not on the curve.\")}if(this.multiply(c).isInfinity()){throw new Error(\"Point is not a scalar multiple of G.\")}return true};\n/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval\n */\nvar jsonParse=(function(){var e=\"(?:-?\\\\b(?:0|[1-9][0-9]*)(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\\\b)\";var j='(?:[^\\\\0-\\\\x08\\\\x0a-\\\\x1f\"\\\\\\\\]|\\\\\\\\(?:[\"/\\\\\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:\"'+j+'*\")';var d=new RegExp(\"(?:false|true|null|[\\\\{\\\\}\\\\[\\\\]]|\"+e+\"|\"+i+\")\",\"g\");var k=new RegExp(\"\\\\\\\\(?:([^u])|u(.{4}))\",\"g\");var g={'\"':'\"',\"/\":\"/\",\"\\\\\":\"\\\\\",b:\"\\b\",f:\"\\f\",n:\"\\n\",r:\"\\r\",t:\"\\t\"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String(\"\");var a=\"\\\\\";var f={\"{\":Object,\"[\":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if(\"{\"===v){x={}}else{if(\"[\"===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({\"\":x},\"\")}return x}})();\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.asn1==\"undefined\"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b=\"0\"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!=\"-\"){if(f.length%2==1){f=\"0\"+f}else{if(!f.match(/^[0-7]/)){f=\"00\"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g=\"\";for(var d=0;d15){throw\"ASN.1 length too long to represent by 8x: n = \"+i.toString(16)}var f=128+g;return f.toString(16)+h}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return\"\"}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!=\"undefined\"){if(typeof c==\"string\"){this.setString(c)}else{if(typeof c.str!=\"undefined\"){this.setString(c.str)}else{if(typeof c.hex!=\"undefined\"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(f){utc=f.getTime()+(f.getTimezoneOffset()*60000);var e=new Date(utc);return e};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o==\"utc\"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,\"\");r=r+\".\"+k}}return r+\"Z\"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join(\"0\")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!=\"undefined\"){if(typeof b.array!=\"undefined\"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT=\"01\";this.hTLV=\"0101ff\"};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT=\"02\";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!=\"undefined\"){if(typeof a.bigint!=\"undefined\"){this.setByBigInteger(a.bigint)}else{if(typeof a[\"int\"]!=\"undefined\"){this.setByInteger(a[\"int\"])}else{if(typeof a==\"number\"){this.setByInteger(a)}else{if(typeof a.hex!=\"undefined\"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!==\"undefined\"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex=\"00\"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT=\"03\";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=(l*2))){break}if(d>=200){break}g.push(b);c=b;d++}return g};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){throw\"checking tag doesn't match: \"+e.substr(d,2)+\"!=\"+i}}return d}f=c.shift();b=g.getChildIdx(e,d);return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getTLVbyList=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyList(d,c,b);if(a===undefined){throw\"can't find nthList object\"}if(f!==undefined){if(d.substr(a,2)!=f){throw\"checking tag doesn't match: \"+d.substr(a,2)+\"!=\"+f}}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a===undefined){throw\"can't find nthList object\"}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join(\"0\")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+\".\"+j.join(\".\")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+\"..(total \"+A.length/2+\"bytes)..\"+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=\"\"}var x=c.ommit_long_octet;if(e.substr(l,2)==\"01\"){var h=j(e,l);if(h==\"00\"){return g+\"BOOLEAN FALSE\\n\"}else{return g+\"BOOLEAN TRUE\\n\"}}if(e.substr(l,2)==\"02\"){var h=j(e,l);return g+\"INTEGER \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"03\"){var h=j(e,l);return g+\"BITSTRING \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"04\"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+\"OCTETSTRING, encapsulates\\n\";k=k+y(h,c,0,g+\" \");return k}else{return g+\"OCTETSTRING \"+q(h,x)+\"\\n\"}}if(e.substr(l,2)==\"05\"){return g+\"NULL\\n\"}if(e.substr(l,2)==\"06\"){var m=j(e,l);var a=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(a);var b=a.replace(/\\./g,\" \");if(o!=\"\"){return g+\"ObjectIdentifier \"+o+\" (\"+b+\")\\n\"}else{return g+\"ObjectIdentifier (\"+b+\")\\n\"}}if(e.substr(l,2)==\"0c\"){return g+\"UTF8String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"13\"){return g+\"PrintableString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"14\"){return g+\"TeletexString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"16\"){return g+\"IA5String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"17\"){return g+\"UTCTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"18\"){return g+\"GeneralizedTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"30\"){if(e.substr(l,4)==\"3000\"){return g+\"SEQUENCE {}\\n\"}var k=g+\"SEQUENCE\\n\";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)==\"06\"&&e.substr(d[d.length-1],2)==\"04\"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u0){var m=new f({array:this.extensionsArray});var k=new c({explicit:true,tag:\"a3\",obj:m});this.asn1Array.push(k)}var n=new f({array:this.asn1Array});this.hTLV=n.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension=function(d){KJUR.asn1.x509.Extension.superclass.constructor.call(this);var f=null,a=KJUR,e=a.asn1,h=e.DERObjectIdentifier,i=e.DEROctetString,b=e.DERBitString,g=e.DERBoolean,c=e.DERSequence;this.getEncodedHex=function(){var m=new h({oid:this.oid});var l=new i({hex:this.getExtnValueHex()});var k=new Array();k.push(m);if(this.critical){k.push(new g())}k.push(l);var j=new c({array:k});return j.getEncodedHex()};this.critical=false;if(d!==undefined){if(d.critical!==undefined){this.critical=d.critical}}};YAHOO.lang.extend(KJUR.asn1.x509.Extension,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension.appendByNameToArray=function(e,c,b){var g=e.toLowerCase(),f=KJUR.asn1.x509;if(g==\"basicconstraints\"){var d=new f.BasicConstraints(c);b.push(d)}else{if(g==\"keyusage\"){var d=new f.KeyUsage(c);b.push(d)}else{if(g==\"crldistributionpoints\"){var d=new f.CRLDistributionPoints(c);b.push(d)}else{if(g==\"extkeyusage\"){var d=new f.ExtKeyUsage(c);b.push(d)}else{if(g==\"authoritykeyidentifier\"){var d=new f.AuthorityKeyIdentifier(c);b.push(d)}else{if(g==\"authorityinfoaccess\"){var d=new f.AuthorityInfoAccess(c);b.push(d)}else{if(g==\"subjectaltname\"){var d=new f.SubjectAltName(c);b.push(d)}else{if(g==\"issueraltname\"){var d=new f.IssuerAltName(c);b.push(d)}else{throw\"unsupported extension name: \"+e}}}}}}}}};KJUR.asn1.x509.KeyUsage=function(f){KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this,f);var a=X509.KEYUSAGE_NAME;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.15\";if(f!==undefined){if(f.bin!==undefined){this.asn1ExtnValue=new KJUR.asn1.DERBitString(f)}if(f.names!==undefined&&f.names.length!==undefined){var e=f.names;var d=\"000000000\";for(var c=0;c-1){e.push(new KJUR.asn1.DERInteger({\"int\":this.pathLen}))}var d=new KJUR.asn1.DERSequence({array:e});this.asn1ExtnValue=d;return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.19\";this.cA=false;this.pathLen=-1;if(c!==undefined){if(c.cA!==undefined){this.cA=c.cA}if(c.pathLen!==undefined){this.pathLen=c.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){this.asn1ExtnValue=new a.DERSequence({array:e})};this.setByOneURI=function(h){var e=new c.GeneralNames([{uri:h}]);var g=new c.DistributionPointName(e);var f=new c.DistributionPoint({dpobj:g});this.setByDPArray([f])};this.oid=\"2.5.29.31\";if(d!==undefined){if(d.array!==undefined){this.setByDPArray(d.array)}else{if(d.uri!==undefined){this.setByOneURI(d.uri)}}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLDistributionPoints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.ExtKeyUsage=function(c){KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,c);var b=KJUR,a=b.asn1;this.setPurposeArray=function(d){this.asn1ExtnValue=new a.DERSequence();for(var e=0;e0){var h=new b({array:this.aRevokedCert});this.asn1Array.push(h)}var i=new b({array:this.asn1Array});this.hTLV=i.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize=function(){this.asn1Version=null;this.asn1SignatureAlg=null;this.asn1Issuer=null;this.asn1ThisUpdate=null;this.asn1NextUpdate=null;this.aRevokedCert=new Array()};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertList,KJUR.asn1.ASN1Object);KJUR.asn1.x509.CRLEntry=function(e){KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);var d=null,c=null,b=KJUR,a=b.asn1;this.setCertSerial=function(f){this.sn=new a.DERInteger(f)};this.setRevocationDate=function(f){this.time=new a.x509.Time(f)};this.getEncodedHex=function(){var f=new a.DERSequence({array:[this.sn,this.time]});this.TLV=f.getEncodedHex();return this.TLV};if(e!==undefined){if(e.time!==undefined){this.setRevocationDate(e.time)}if(e.sn!==undefined){this.setCertSerial(e.sn)}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLEntry,KJUR.asn1.ASN1Object);KJUR.asn1.x509.X500Name=function(f){KJUR.asn1.x509.X500Name.superclass.constructor.call(this);this.asn1Array=new Array();var d=KJUR,c=d.asn1,e=c.x509,b=pemtohex;this.setByString=function(g){var k=g.split(\"/\");k.shift();var j=[];for(var l=0;l0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+\",\"+h).replace(/\\\\,/g,\",\");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)===\"\\\\\"){e=true}}b=b.map(function(a){return a.replace(\"/\",\"\\\\/\")});b.reverse();return\"/\"+b.join(\"/\")};KJUR.asn1.x509.RDN=function(a){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=new Array();this.addByString=function(b){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:b}))};this.addByMultiValuedString=function(d){var b=KJUR.asn1.x509.RDN.parseString(d);for(var c=0;c0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+\"+\"+k).replace(/\\\\\\+/g,\"+\");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)===\"\\\\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/\"$/)){var d=(e+\"+\"+k).replace(/^([^=]+)=\"(.*)\"$/,\"$1=$2\");b.push(d);l=false}else{b.push(e+\"+\"+k)}}else{b.push(k)}if(k.match(/^[^=]+=\"/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(d){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var f=null,e=null,a=\"utf8\",c=KJUR,b=c.asn1;this.setByString=function(h){var g=h.match(/^([^=]+)=(.+)$/);if(g){this.setByAttrTypeAndValueStr(g[1],g[2])}else{throw\"malformed attrTypeAndValueStr: \"+h}};this.setByAttrTypeAndValueStr=function(i,h){this.typeObj=KJUR.asn1.x509.OID.atype2obj(i);var g=a;if(i==\"C\"){g=\"prn\"}this.valueObj=this.getValueObj(g,h)};this.getValueObj=function(h,g){if(h==\"utf8\"){return new b.DERUTF8String({str:g})}if(h==\"prn\"){return new b.DERPrintableString({str:g})}if(h==\"tel\"){return new b.DERTeletexString({str:g})}if(h==\"ia5\"){return new b.DERIA5String({str:g})}throw\"unsupported directory string type: type=\"+h+\" value=\"+g};this.getEncodedHex=function(){var g=new b.DERSequence({array:[this.typeObj,this.valueObj]});this.TLV=g.getEncodedHex();return this.TLV};if(d!==undefined){if(d.str!==undefined){this.setByString(d.str)}}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw\"algId and/or subjPubKey not set\"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{\"int\":{bigint:q.n}},{\"int\":{\"int\":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:\"rsaEncryption\"});this.asn1SubjPKey=new b({hex:\"00\"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:\"ecPublicKey\",asn1params:r});this.asn1SubjPKey=new b({hex:\"00\"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{\"int\":{bigint:q.p}},{\"int\":{bigint:q.q}},{\"int\":{bigint:q.g}}]});this.asn1AlgId=new o({name:\"dsa\",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:\"00\"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type==\"utc\"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type==\"utc\"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type=\"utc\";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type=\"utc\"}if(f.str.match(/^[0-9]{14}Z$/)){this.type=\"gen\"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(d){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw\"algorithm not specified\"}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var e=[this.asn1Alg];if(this.asn1Params!==null){e.push(this.asn1Params)}var f=new a.DERSequence({array:e});this.hTLV=f.getEncodedHex();return this.hTLV};if(d!==undefined){if(d.name!==undefined){this.nameAlg=d.name}if(d.asn1params!==undefined){this.asn1Params=d.asn1params}if(d.paramempty!==undefined){this.paramEmpty=d.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){var c=this.nameAlg.toLowerCase();if(c.substr(-7,7)!==\"withdsa\"&&c.substr(-9,9)!==\"withecdsa\"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:\"81\",dns:\"82\",dn:\"a4\",uri:\"86\",ip:\"87\"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type=\"rfc822\";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type=\"dns\";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type=\"uri\";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({str:p.dn})}if(p.ldapdn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certissuer param not cert\"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certsubj param not cert\"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type=\"ip\";this.explicit=false;var q=p.ip;var s;var n=\"malformed IP address\";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex(\"[\"+q.split(\".\").join(\",\")+\"]\");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw\"unsupported type in params=\"+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){r=new b({obj:this.dUnsignedAttrs,tag:\"a1\",explicit:false})}var q=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,o,this.dSigAlg,this.dSig,];if(r!=null){q.push(r)}var p=new h.DERSequence({array:q});this.hTLV=p.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.SignerInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.EncapsulatedContentInfo=function(g){var c=KJUR,b=c.asn1,e=b.DERTaggedObject,a=b.DERSequence,h=b.DERObjectIdentifier,d=b.DEROctetString,f=b.cms;f.EncapsulatedContentInfo.superclass.constructor.call(this);this.dEContentType=new h({name:\"data\"});this.dEContent=null;this.isDetached=false;this.eContentValueHex=null;this.setContentType=function(i){if(i.match(/^[0-2][.][0-9.]+$/)){this.dEContentType=new h({oid:i})}else{this.dEContentType=new h({name:i})}};this.setContentValue=function(i){if(i!==undefined){if(typeof i.hex==\"string\"){this.eContentValueHex=i.hex}else{if(typeof i.str==\"string\"){this.eContentValueHex=utf8tohex(i.str)}}}};this.setContentValueHex=function(i){this.eContentValueHex=i};this.setContentValueStr=function(i){this.eContentValueHex=utf8tohex(i)};this.getEncodedHex=function(){if(typeof this.eContentValueHex!=\"string\"){throw\"eContentValue not yet set\"}var k=new d({hex:this.eContentValueHex});this.dEContent=new e({obj:k,tag:\"a0\",explicit:true});var i=[this.dEContentType];if(!this.isDetached){i.push(this.dEContent)}var j=new a({array:i});this.hTLV=j.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.EncapsulatedContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.ContentInfo=function(f){var c=KJUR,b=c.asn1,d=b.DERTaggedObject,a=b.DERSequence,e=b.x509;KJUR.asn1.cms.ContentInfo.superclass.constructor.call(this);this.dContentType=null;this.dContent=null;this.setContentType=function(g){if(typeof g==\"string\"){this.dContentType=e.OID.name2obj(g)}};this.getEncodedHex=function(){var h=new d({obj:this.dContent,tag:\"a0\",explicit:true});var g=new a({array:[this.dContentType,h]});this.hTLV=g.getEncodedHex();return this.hTLV};if(f!==undefined){if(f.type){this.setContentType(f.type)}if(f.obj&&f.obj instanceof b.ASN1Object){this.dContent=f.obj}}};YAHOO.lang.extend(KJUR.asn1.cms.ContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.SignedData=function(e){var a=KJUR,h=a.asn1,j=h.ASN1Object,g=h.DERInteger,m=h.DERSet,f=h.DERSequence,b=h.DERTaggedObject,l=h.cms,i=l.EncapsulatedContentInfo,d=l.SignerInfo,n=l.ContentInfo,c=h.x509,k=c.AlgorithmIdentifier;KJUR.asn1.cms.SignedData.superclass.constructor.call(this);this.dCMSVersion=new g({\"int\":1});this.dDigestAlgs=null;this.digestAlgNameList=[];this.dEncapContentInfo=new i();this.dCerts=null;this.certificateList=[];this.crlList=[];this.signerInfoList=[new d()];this.addCertificatesByPEM=function(p){var q=pemtohex(p);var r=new j();r.hTLV=q;this.certificateList.push(r)};this.getEncodedHex=function(){if(typeof this.hTLV==\"string\"){return this.hTLV}if(this.dDigestAlgs==null){var u=[];for(var t=0;t0){var v=new m({array:this.certificateList});this.dCerts=new b({obj:v,tag:\"a0\",explicit:false})}}if(this.dCerts!=null){p.push(this.dCerts)}var r=new m({array:this.signerInfoList});p.push(r);var q=new f({array:p});this.hTLV=q.getEncodedHex();return this.hTLV};this.getContentInfo=function(){this.getEncodedHex();var o=new n({type:\"signed-data\",obj:this});return o};this.getContentInfoEncodedHex=function(){var o=this.getContentInfo();var p=o.getEncodedHex();return p};this.getPEM=function(){return hextopem(this.getContentInfoEncodedHex(),\"CMS\")}};YAHOO.lang.extend(KJUR.asn1.cms.SignedData,KJUR.asn1.ASN1Object);KJUR.asn1.cms.CMSUtil=new function(){};KJUR.asn1.cms.CMSUtil.newSignedData=function(d){var b=KJUR,j=b.asn1,q=j.cms,f=q.SignerInfo,n=q.SignedData,o=q.SigningTime,a=q.SigningCertificate,p=q.SigningCertificateV2,c=j.cades,e=c.SignaturePolicyIdentifier;var m=new n();m.dEncapContentInfo.setContentValue(d.content);if(typeof d.certs==\"object\"){for(var h=0;h0){var s=new f({array:this.extensionsArray});var r=new m({array:[s]});var q=new f({array:[new k({oid:\"1.2.840.113549.1.9.14\"}),r]});var p=new c({explicit:true,tag:\"a0\",obj:q});this.asn1Array.push(p)}else{var p=new c({explicit:false,tag:\"a0\",obj:new j()});this.asn1Array.push(p)}var t=new f({array:this.asn1Array});this.hTLV=t.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CSRUtil=new function(){};KJUR.asn1.csr.CSRUtil.newCSRPEM=function(h){var c=KEYUTIL,b=KJUR.asn1.csr;if(h.subject===undefined){throw\"parameter subject undefined\"}if(h.sbjpubkey===undefined){throw\"parameter sbjpubkey undefined\"}if(h.sigalg===undefined){throw\"parameter sigalg undefined\"}if(h.sbjprvkey===undefined){throw\"parameter sbjpubkey undefined\"}var d=new b.CertificationRequestInfo();d.setSubjectByParam(h.subject);d.setSubjectPublicKeyByGetKey(h.sbjpubkey);if(h.ext!==undefined&&h.ext.length!==undefined){for(var e=0;ef.length){f=c[d]}}e=e.replace(f,\"::\");return e.slice(1,-1)}function hextoip(b){var d=\"malformed hex value\";if(!b.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){throw d}if(b.length==8){var c;try{c=parseInt(b.substr(0,2),16)+\".\"+parseInt(b.substr(2,2),16)+\".\"+parseInt(b.substr(4,2),16)+\".\"+parseInt(b.substr(6,2),16);return c}catch(a){throw d}}else{if(b.length==32){return hextoipv6(b)}else{return b}}}function iptohex(f){var j=\"malformed IP address\";f=f.toLowerCase(f);if(f.match(/^[0-9.]+$/)){var b=f.split(\".\");if(b.length!==4){throw j}var g=\"\";try{for(var e=0;e<4;e++){var h=parseInt(b[e]);g+=(\"0\"+h.toString(16)).slice(-2)}return g}catch(c){throw j}}else{if(f.match(/^[0-9a-f:]+$/)&&f.indexOf(\":\")!==-1){return ipv6tohex(f)}else{throw j}}}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b=\"\";for(var c=0;c\"7\"){return\"00\"+a}return a}function intarystrtohex(b){b=b.replace(/^\\s*\\[\\s*/,\"\");b=b.replace(/\\s*\\]\\s*$/,\"\");b=b.replace(/\\s*/g,\"\");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;bd){throw\"key is too short for SigAlg: keylen=\"+j+\",\"+a}var b=\"0001\";var k=\"00\"+c;var g=\"\";var l=d-b.length-k.length;for(var f=0;f=0;--p){q=q.twice2D();q.z=BigInteger.ONE;if(o.testBit(p)){if(n.testBit(p)){q=q.add2D(t)}else{q=q.add2D(s)}}else{if(n.testBit(p)){q=q.add2D(r)}}}return q}this.getBigRandom=function(i){return new BigInteger(i.bitLength(),a).mod(i.subtract(BigInteger.ONE)).add(BigInteger.ONE)};this.setNamedCurve=function(i){this.ecparams=KJUR.crypto.ECParameterDB.getByName(i);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=i};this.setPrivateKeyHex=function(i){this.isPrivate=true;this.prvKeyHex=i};this.setPublicKeyHex=function(i){this.isPublic=true;this.pubKeyHex=i};this.getPublicKeyXYHex=function(){var k=this.pubKeyHex;if(k.substr(0,2)!==\"04\"){throw\"this method supports uncompressed format(04) only\"}var j=this.ecparams.keylen/4;if(k.length!==2+j*2){throw\"malformed public key hex length\"}var i={};i.x=k.substr(2,j);i.y=k.substr(2+j);return i};this.getShortNISTPCurveName=function(){var i=this.curveName;if(i===\"secp256r1\"||i===\"NIST P-256\"||i===\"P-256\"||i===\"prime256v1\"){return\"P-256\"}if(i===\"secp384r1\"||i===\"NIST P-384\"||i===\"P-384\"){return\"P-384\"}return null};this.generateKeyPairHex=function(){var k=this.ecparams.n;var n=this.getBigRandom(k);var l=this.ecparams.G.multiply(n);var q=l.getX().toBigInteger();var o=l.getY().toBigInteger();var i=this.ecparams.keylen/4;var m=(\"0000000000\"+n.toString(16)).slice(-i);var r=(\"0000000000\"+q.toString(16)).slice(-i);var p=(\"0000000000\"+o.toString(16)).slice(-i);var j=\"04\"+r+p;this.setPrivateKeyHex(m);this.setPublicKeyHex(j);return{ecprvhex:m,ecpubhex:j}};this.signWithMessageHash=function(i){return this.signHex(i,this.prvKeyHex)};this.signHex=function(o,j){var t=new BigInteger(j,16);var l=this.ecparams.n;var q=new BigInteger(o,16);do{var m=this.getBigRandom(l);var u=this.ecparams.G;var p=u.multiply(m);var i=p.getX().toBigInteger().mod(l)}while(i.compareTo(BigInteger.ZERO)<=0);var v=m.modInverse(l).multiply(q.add(t.multiply(i))).mod(l);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(i,v)};this.sign=function(m,u){var q=u;var j=this.ecparams.n;var p=BigInteger.fromByteArrayUnsigned(m);do{var l=this.getBigRandom(j);var t=this.ecparams.G;var o=t.multiply(l);var i=o.getX().toBigInteger().mod(j)}while(i.compareTo(BigInteger.ZERO)<=0);var v=l.modInverse(j).multiply(p.add(q.multiply(i))).mod(j);return this.serializeSig(i,v)};this.verifyWithMessageHash=function(j,i){return this.verifyHex(j,i,this.pubKeyHex)};this.verifyHex=function(m,i,p){var l,j;var o=KJUR.crypto.ECDSA.parseSigHex(i);l=o.r;j=o.s;var k;k=ECPointFp.decodeFromHex(this.ecparams.curve,p);var n=new BigInteger(m,16);return this.verifyRaw(n,l,j,k)};this.verify=function(o,p,j){var l,i;if(Bitcoin.Util.isArray(p)){var n=this.parseSig(p);l=n.r;i=n.s}else{if(\"object\"===typeof p&&p.r&&p.s){l=p.r;i=p.s}else{throw\"Invalid value for signature\"}}var k;if(j instanceof ECPointFp){k=j}else{if(Bitcoin.Util.isArray(j)){k=ECPointFp.decodeFrom(this.ecparams.curve,j)}else{throw\"Invalid format for pubkey value, must be byte array or ECPointFp\"}}var m=BigInteger.fromByteArrayUnsigned(o);return this.verifyRaw(m,l,i,k)};this.verifyRaw=function(o,i,w,m){var l=this.ecparams.n;var u=this.ecparams.G;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(l)>=0){return false}if(w.compareTo(BigInteger.ONE)<0||w.compareTo(l)>=0){return false}var p=w.modInverse(l);var k=o.multiply(p).mod(l);var j=i.multiply(p).mod(l);var q=u.multiply(k).add(m.multiply(j));var t=q.getX().toBigInteger().mod(l);return t.equals(i)};this.serializeSig=function(k,j){var l=k.toByteArraySigned();var i=j.toByteArraySigned();var m=[];m.push(2);m.push(l.length);m=m.concat(l);m.push(2);m.push(i.length);m=m.concat(i);m.unshift(m.length);m.unshift(48);return m};this.parseSig=function(n){var m;if(n[0]!=48){throw new Error(\"Signature not a valid DERSequence\")}m=2;if(n[m]!=2){throw new Error(\"First element in signature must be a DERInteger\")}var l=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];if(n[m]!=2){throw new Error(\"Second element in signature must be a DERInteger\")}var i=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];var k=BigInteger.fromByteArrayUnsigned(l);var j=BigInteger.fromByteArrayUnsigned(i);return{r:k,s:j}};this.parseSigCompact=function(m){if(m.length!==65){throw\"Signature has the wrong length\"}var j=m[0]-27;if(j<0||j>7){throw\"Invalid signature type\"}var o=this.ecparams.n;var l=BigInteger.fromByteArrayUnsigned(m.slice(1,33)).mod(o);var k=BigInteger.fromByteArrayUnsigned(m.slice(33,65)).mod(o);return{r:l,s:k,i:j}};this.readPKCS5PrvKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var i,k,o;try{i=p(l,0,[2,0],\"06\");k=p(l,0,[1],\"04\");try{o=p(l,0,[3,0],\"03\").substr(2)}catch(j){}}catch(j){throw\"malformed PKCS#1/5 plain ECC private key\"}this.curveName=m(i);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o);this.setPrivateKeyHex(k);this.isPublic=false};this.readPKCS8PrvKeyHex=function(l){var q=ASN1HEX;var i=KJUR.crypto.ECDSA.getName;var n=q.getVbyList;if(q.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var j,p,m,k;try{j=n(l,0,[1,0],\"06\");p=n(l,0,[1,1],\"06\");m=n(l,0,[2,0,1],\"04\");try{k=n(l,0,[2,0,2,0],\"03\").substr(2)}catch(o){}}catch(o){throw\"malformed PKCS#8 plain ECC private key\"}this.curveName=i(p);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(k);this.setPrivateKeyHex(m);this.isPublic=false};this.readPKCS8PubKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var k,i,o;try{k=p(l,0,[0,0],\"06\");i=p(l,0,[0,1],\"06\");o=p(l,0,[1],\"03\").substr(2)}catch(j){throw\"malformed PKCS#8 ECC public key\"}this.curveName=m(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o)};this.readCertPubKeyHex=function(k,p){if(p!==5){p=6}var m=ASN1HEX;var l=KJUR.crypto.ECDSA.getName;var o=m.getVbyList;if(m.isASN1HEX(k)===false){throw\"not ASN.1 hex string\"}var i,n;try{i=o(k,0,[0,p,0,1],\"06\");n=o(k,0,[0,p,1],\"03\").substr(2)}catch(j){throw\"malformed X.509 certificate ECC public key\"}this.curveName=l(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(n)};if(h!==undefined){if(h.curve!==undefined){this.curveName=h.curve}}if(this.curveName===undefined){this.curveName=e}this.setNamedCurve(this.curveName);if(h!==undefined){if(h.prv!==undefined){this.setPrivateKeyHex(h.prv)}if(h.pub!==undefined){this.setPublicKeyHex(h.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX;var i=j.getChildIdx;var g=j.getV;if(f.substr(0,2)!=\"30\"){throw\"signature is not a ASN.1 sequence\"}var h=i(f,0);if(h.length!=2){throw\"number of signature ASN.1 sequence elements seem wrong\"}var e=h[0];var d=h[1];if(f.substr(e,2)!=\"02\"){throw\"1st item of sequene of signature is not ASN.1 integer\"}if(f.substr(d,2)!=\"02\"){throw\"2nd item of sequene of signature is not ASN.1 integer\"}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(c){var d=KJUR.crypto.ECDSA.parseSigHexInHexRS(c);var b=d.r;var a=d.s;if(b.substr(0,2)==\"00\"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)==\"00\"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b=\"00\"+b}if((a.length%32)==30){a=\"00\"+a}if(b.length%32!=0){throw\"unknown ECDSA sig r length error\"}if(a.length%32!=0){throw\"unknown ECDSA sig s length error\"}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if((((a.length/2)*8)%(16*8))!=0){throw\"unknown ECDSA concatinated r-s sig length error\"}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.getEncodedHex()};KJUR.crypto.ECDSA.getName=function(a){if(a===\"2a8648ce3d030107\"){return\"secp256r1\"}if(a===\"2b8104000a\"){return\"secp256k1\"}if(a===\"2b81040022\"){return\"secp384r1\"}if(\"|secp256r1|NIST P-256|P-256|prime256v1|\".indexOf(a)!==-1){return\"secp256r1\"}if(\"|secp256k1|\".indexOf(a)!==-1){return\"secp256k1\"}if(\"|secp384r1|NIST P-384|P-384|\".indexOf(a)!==-1){return\"secp384r1\"}return null};\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.crypto==\"undefined\"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!=\"undefined\"){d=c[e]}if(typeof b[d]!=\"undefined\"){return b[d]}throw\"unregistered EC curve name: \"+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex(\"04\"+f+k);b[A][\"name\"]=A;b[A][\"keylen\"]=l;b[A][\"curve\"]=r;b[A][\"G\"]=q;b[A][\"n\"]=t;b[A][\"h\"]=w;b[A][\"oid\"]=d;b[A][\"info\"]=x;for(var v=0;v1){g=new BigInteger(i,16)}else{g=null}h=new BigInteger(j,16);this.setPrivate(c,a,e,g,h)};this.setPublic=function(c,b,a,d){this.isPublic=true;this.p=c;this.q=b;this.g=a;this.y=d;this.x=null};this.setPublicHex=function(f,e,d,g){var b,a,h,c;b=new BigInteger(f,16);a=new BigInteger(e,16);h=new BigInteger(d,16);c=new BigInteger(g,16);this.setPublic(b,a,h,c)};this.signWithMessageHash=function(d){var c=this.p;var b=this.q;var f=this.g;var i=this.y;var j=this.x;var e=KJUR.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),b.subtract(BigInteger.ONE));var l=d.substr(0,b.bitLength()/4);var h=new BigInteger(l,16);var a=(f.modPow(e,c)).mod(b);var n=(e.modInverse(b).multiply(h.add(j.multiply(a)))).mod(b);var m=KJUR.asn1.ASN1Util.jsonToASN1HEX({seq:[{\"int\":{bigint:a}},{\"int\":{bigint:n}}]});return m};this.verifyWithMessageHash=function(h,f){var d=this.p;var b=this.q;var j=this.g;var l=this.y;var i=this.parseASN1Signature(f);var a=i[0];var t=i[1];var o=h.substr(0,b.bitLength()/4);var k=new BigInteger(o,16);if(BigInteger.ZERO.compareTo(a)>0||a.compareTo(b)>0){throw\"invalid DSA signature\"}if(BigInteger.ZERO.compareTo(t)>=0||t.compareTo(b)>0){throw\"invalid DSA signature\"}var m=t.modInverse(b);var e=k.multiply(m).mod(b);var c=a.multiply(m).mod(b);var n=j.modPow(e,d).multiply(l.modPow(c,d)).mod(d).mod(b);return n.compareTo(a)==0};this.parseASN1Signature=function(a){try{var d=new BigInteger(ASN1HEX.getVbyList(a,0,[0],\"02\"),16);var c=new BigInteger(ASN1HEX.getVbyList(a,0,[1],\"02\"),16);return[d,c]}catch(b){throw\"malformed ASN.1 DSA signature\"}};this.readPKCS5PrvKeyHex=function(c){var b,a,f,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[1],\"02\");a=d(c,0,[2],\"02\");f=d(c,0,[3],\"02\");g=d(c,0,[4],\"02\");i=d(c,0,[5],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed PKCS#1/5 plain DSA private key\"}this.setPrivateHex(b,a,f,g,i)};this.readPKCS8PrvKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[1,1,0],\"02\");c=i(d,0,[1,1,1],\"02\");b=i(d,0,[1,1,2],\"02\");g=i(d,0,[2,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 plain DSA private key\"}this.setPrivateHex(f,c,b,null,g)};this.readPKCS8PubKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[0,1,0],\"02\");c=i(d,0,[0,1,1],\"02\");b=i(d,0,[0,1,2],\"02\");g=i(d,0,[1,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 DSA public key\"}this.setPublicHex(f,c,b,g)};this.readCertPubKeyHex=function(c,f){if(f!==5){f=6}var b,a,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[0,f,0,1,0],\"02\");a=d(c,0,[0,f,0,1,1],\"02\");g=d(c,0,[0,f,0,1,2],\"02\");i=d(c,0,[0,f,1,0],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed X.509 certificate DSA public key\"}this.setPublicHex(b,a,g,i)}};\nvar KEYUTIL=function(){var d=function(p,r,q){return k(CryptoJS.AES,p,r,q)};var e=function(p,r,q){return k(CryptoJS.TripleDES,p,r,q)};var a=function(p,r,q){return k(CryptoJS.DES,p,r,q)};var k=function(s,x,u,q){var r=CryptoJS.enc.Hex.parse(x);var w=CryptoJS.enc.Hex.parse(u);var p=CryptoJS.enc.Hex.parse(q);var t={};t.key=w;t.iv=p;t.ciphertext=r;var v=s.decrypt(t,w,{iv:p});return CryptoJS.enc.Hex.stringify(v)};var l=function(p,r,q){return g(CryptoJS.AES,p,r,q)};var o=function(p,r,q){return g(CryptoJS.TripleDES,p,r,q)};var f=function(p,r,q){return g(CryptoJS.DES,p,r,q)};var g=function(t,y,v,q){var s=CryptoJS.enc.Hex.parse(y);var x=CryptoJS.enc.Hex.parse(v);var p=CryptoJS.enc.Hex.parse(q);var w=t.encrypt(s,x,{iv:p});var r=CryptoJS.enc.Hex.parse(w.toString());var u=CryptoJS.enc.Base64.stringify(r);return u};var i={\"AES-256-CBC\":{proc:d,eproc:l,keylen:32,ivlen:16},\"AES-192-CBC\":{proc:d,eproc:l,keylen:24,ivlen:16},\"AES-128-CBC\":{proc:d,eproc:l,keylen:16,ivlen:16},\"DES-EDE3-CBC\":{proc:e,eproc:o,keylen:24,ivlen:8},\"DES-CBC\":{proc:a,eproc:f,keylen:8,ivlen:8}};var c=function(p){return i[p][\"proc\"]};var m=function(p){var r=CryptoJS.lib.WordArray.random(p);var q=CryptoJS.enc.Hex.stringify(r);return q};var n=function(v){var w={};var q=v.match(new RegExp(\"DEK-Info: ([^,]+),([0-9A-Fa-f]+)\",\"m\"));if(q){w.cipher=q[1];w.ivsalt=q[2]}var p=v.match(new RegExp(\"-----BEGIN ([A-Z]+) PRIVATE KEY-----\"));if(p){w.type=p[1]}var u=-1;var x=0;if(v.indexOf(\"\\r\\n\\r\\n\")!=-1){u=v.indexOf(\"\\r\\n\\r\\n\");x=2}if(v.indexOf(\"\\n\\n\")!=-1){u=v.indexOf(\"\\n\\n\");x=1}var t=v.indexOf(\"-----END\");if(u!=-1&&t!=-1){var r=v.substring(u+x*2,t-x);r=r.replace(/\\s+/g,\"\");w.data=r}return w};var j=function(q,y,p){var v=p.substring(0,16);var t=CryptoJS.enc.Hex.parse(v);var r=CryptoJS.enc.Utf8.parse(y);var u=i[q][\"keylen\"]+i[q][\"ivlen\"];var x=\"\";var w=null;for(;;){var s=CryptoJS.algo.MD5.create();if(w!=null){s.update(w)}s.update(r);s.update(t);w=s.finalize();x=x+CryptoJS.enc.Hex.stringify(w);if(x.length>=u*2){break}}var z={};z.keyhex=x.substr(0,i[q][\"keylen\"]*2);z.ivhex=x.substr(i[q][\"keylen\"]*2,i[q][\"ivlen\"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v][\"proc\"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s][\"eproc\"];var t=r(p,q,u);return t};return{version:\"1.0.0\",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p=\"\";if(typeof t==\"undefined\"||t==null){t=\"AES-256-CBC\"}if(typeof i[t]==\"undefined\"){throw\"KEYUTIL unsupported algorithm: \"+t}if(typeof r==\"undefined\"||r==null){var v=i[t][\"ivlen\"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,\"$1\\r\\n\");var p=\"-----BEGIN \"+x+\" PRIVATE KEY-----\\r\\n\";p+=\"Proc-Type: 4,ENCRYPTED\\r\\n\";p+=\"DEK-Info: \"+t+\",\"+r+\"\\r\\n\";p+=\"\\r\\n\";p+=q;p+=\"\\r\\n-----END \"+x+\" PRIVATE KEY-----\\r\\n\";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw\"malformed format: SEQUENCE(0).items != 2: \"+r.length}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0).items != 2: \"+A.length}if(w(y,A[0])!=\"2a864886f70d01050d\"){throw\"this only supports pkcs5PBES2\"}var p=z(y,A[1]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0.1).items != 2: \"+p.length}var q=z(y,p[1]);if(q.length!=2){throw\"malformed format: SEQUENCE(0.0.1.1).items != 2: \"+q.length}if(w(y,q[0])!=\"2a864886f70d0307\"){throw\"this only supports TripleDES\"}t.encryptionSchemeAlg=\"TripleDES\";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw\"malformed format: SEQUENCE(0.0.1.0).items != 2: \"+s.length}if(w(y,s[0])!=\"2a864886f70d01050c\"){throw\"this only supports pkcs5PBKDF2\"}var x=z(y,s[1]);if(x.length<2){throw\"malformed format: SEQUENCE(0.0.1.0.1).items < 2: \"+x.length}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw\"malformed format pbkdf2Iter: \"+u}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,\"ENCRYPTED PRIVATE KEY\");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!=\"30\"){throw\"malformed plain PKCS8 private key(code:001)\"}var r=u(s,0);if(r.length!=3){throw\"malformed plain PKCS8 private key(code:002)\"}if(s.substr(r[1],2)!=\"30\"){throw\"malformed PKCS8 private key(code:003)\"}var p=u(s,r[1]);if(p.length!=2){throw\"malformed PKCS8 private key(code:004)\"}if(s.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 private key(code:005)\"}q.algoid=t(s,p[0]);if(s.substr(p[1],2)==\"06\"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!=\"04\"){throw\"malformed PKCS8 private key(code:006)\"}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,\"PRIVATE KEY\");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid==\"2a864886f70d010101\"){r=new RSAKey()}else{if(q.algoid==\"2a8648ce380401\"){r=new KJUR.crypto.DSA()}else{if(q.algoid==\"2a8648ce3d0201\"){r=new KJUR.crypto.ECDSA()}else{throw\"unsupported private key algorithm\"}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],\"06\");if(r===\"2a864886f70d010101\"){p=new RSAKey()}else{if(r===\"2a8648ce380401\"){p=new KJUR.crypto.DSA()}else{if(r===\"2a8648ce3d0201\"){p=new KJUR.crypto.ECDSA()}else{throw\"unsupported PKCS#8 public key hex\"}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!=\"30\"){throw\"malformed RSA key(code:001)\"}var q=t(r,0);if(q.length!=2){throw\"malformed RSA key(code:002)\"}if(r.substr(q[0],2)!=\"02\"){throw\"malformed RSA key(code:003)\"}p.n=s(r,q[0]);if(r.substr(q[1],2)!=\"02\"){throw\"malformed RSA key(code:004)\"}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw\"outer DERSequence shall have 2 elements: \"+r.length}var w=r[0];if(t.substr(w,2)!=\"30\"){throw\"malformed PKCS8 public key(code:001)\"}var p=u(t,w);if(p.length!=2){throw\"malformed PKCS8 public key(code:002)\"}if(t.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 public key(code:003)\"}q.algoid=s(t,p[0]);if(t.substr(p[1],2)==\"06\"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)==\"30\"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],\"02\");q.algparam.q=v.getVbyList(t,p[1],[1],\"02\");q.algparam.g=v.getVbyList(t,p[1],[2],\"02\")}}if(t.substr(r[1],2)!=\"03\"){throw\"malformed PKCS8 public key(code:004)\"}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!=\"undefined\"&&l instanceof w){return l}if(typeof i!=\"undefined\"&&l instanceof i){return l}if(typeof C!=\"undefined\"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;j.setPublicKeyHex(u);return j}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;var b=(\"0000000000\"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n===\"pkcs5prv\"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)===\"04\"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw\"unsupported PKCS#1/5 hexadecimal key\"}}}return P}if(n===\"pkcs8prv\"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n===\"pkcs8pub\"){return F._getKeyFromPublicPKCS8Hex(l)}if(n===\"x509pub\"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf(\"-END CERTIFICATE-\",0)!=-1||l.indexOf(\"-END X509 CERTIFICATE-\",0)!=-1||l.indexOf(\"-END TRUSTED CERTIFICATE-\",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf(\"-END PUBLIC KEY-\")!=-1){var O=pemtohex(l,\"PUBLIC KEY\");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var m=M(l,\"RSA PRIVATE KEY\");return F.getKey(m,null,\"pkcs5prv\")}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var I=M(l,\"DSA PRIVATE KEY\");var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END PRIVATE KEY-\")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf(\"-END EC PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],\"04\");var f=d(I,0,[2,0],\"06\");var A=d(I,0,[3,0],\"03\").substr(2);var e=\"\";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw\"undefined OID(hex) in KJUR.crypto.OID: \"+f}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END ENCRYPTED PRIVATE KEY-\")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw\"not supported argument\"};KEYUTIL.generateKeypair=function(a,c){if(a==\"RSA\"){var b=c;var h=new RSAKey();h.generate(b,\"10001\");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a==\"EC\"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw\"unknown algorithm: \"+a}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.n}},{\"int\":s.e},{\"int\":{bigint:s.d}},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.dmp1}},{\"int\":{bigint:s.dmq1}},{\"int\":{bigint:s.coeff}}]});return G}function B(G){var s=l({seq:[{\"int\":1},{octstr:{hex:G.prvKeyHex}},{tag:[\"a0\",true,{oid:{name:G.curveName}}]},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+G.pubKeyHex}}]}]});return s}function x(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.g}},{\"int\":{bigint:s.y}},{\"int\":{bigint:s.x}}]});return G}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D==\"PKCS8PUB\")){var E=new C(b);var w=E.getEncodedHex();return hextopem(w,\"PUBLIC KEY\")}if(D==\"PKCS1PRV\"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();return hextopem(w,\"RSA PRIVATE KEY\")}if(D==\"PKCS1PRV\"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.getEncodedHex();var h=B(b);var t=h.getEncodedHex();var p=\"\";p+=hextopem(v,\"EC PARAMETERS\");p+=hextopem(t,\"EC PRIVATE KEY\");return p}if(D==\"PKCS1PRV\"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();return hextopem(w,\"DSA PRIVATE KEY\")}if(D==\"PKCS5PRV\"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"RSA\",w,y,m,j)}if(D==\"PKCS5PRV\"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"EC\",w,y,m,j)}if(D==\"PKCS5PRV\"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"DSA\",w,y,m,j)}var o=function(G,s){var I=c(G,s);var H=new l({seq:[{seq:[{oid:{name:\"pkcs5PBES2\"}},{seq:[{seq:[{oid:{name:\"pkcs5PBKDF2\"}},{seq:[{octstr:{hex:I.pbkdf2Salt}},{\"int\":I.pbkdf2Iter}]}]},{seq:[{oid:{name:\"des-EDE3-CBC\"}},{octstr:{hex:I.encryptionSchemeIV}}]}]}]},{octstr:{hex:I.ciphertext}}]});return H.getEncodedHex()};var c=function(N,O){var H=100;var M=CryptoJS.lib.WordArray.random(8);var L=\"DES-EDE3-CBC\";var s=CryptoJS.lib.WordArray.random(8);var I=CryptoJS.PBKDF2(O,M,{keySize:192/32,iterations:H});var J=CryptoJS.enc.Hex.parse(N);var K=CryptoJS.TripleDES.encrypt(J,I,{iv:s})+\"\";var G={};G.ciphertext=K;G.pbkdf2Salt=CryptoJS.enc.Hex.stringify(M);G.pbkdf2Iter=H;G.encryptionSchemeAlg=L;G.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return G};if(D==\"PKCS8PRV\"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"rsaEncryption\"}},{\"null\":true}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var g=new l({seq:[{\"int\":1},{octstr:{hex:b.prvKeyHex}},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+b.pubKeyHex}}]}]});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"ecPublicKey\"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"dsa\"}},{seq:[{\"int\":{bigint:b.p}},{\"int\":{bigint:b.q}},{\"int\":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}throw\"unsupported object nor format\"};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,\"CERTIFICATE REQUEST\");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,\"pkcs8pub\");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!=\"30\"){throw\"malformed CSR(code:001)\"}var e=f(g,0);if(e.length<1){throw\"malformed CSR(code:002)\"}if(g.substr(e[0],2)!=\"30\"){throw\"malformed CSR(code:003)\"}var a=f(g,e[0]);if(a.length<3){throw\"malformed CSR(code:004)\"}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getJWKFromKey=function(d){var b={};if(d instanceof RSAKey&&d.isPrivate){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));b.d=hextob64u(d.d.toString(16));b.p=hextob64u(d.p.toString(16));b.q=hextob64u(d.q.toString(16));b.dp=hextob64u(d.dmp1.toString(16));b.dq=hextob64u(d.dmq1.toString(16));b.qi=hextob64u(d.coeff.toString(16));return b}else{if(d instanceof RSAKey&&d.isPublic){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPrivate){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);b.d=hextob64u(d.prvKeyHex);return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPublic){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);return b}}}}throw\"not supported key object\"};\nRSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,j,l,b,a,f,d,k;var m=ASN1HEX;var g=m.getVbyList;if(m.isASN1HEX(e)===false){throw\"not ASN.1 hex string\"}try{c=g(e,0,[2,0,1],\"02\");j=g(e,0,[2,0,2],\"02\");l=g(e,0,[2,0,3],\"02\");b=g(e,0,[2,0,4],\"02\");a=g(e,0,[2,0,5],\"02\");f=g(e,0,[2,0,6],\"02\");d=g(e,0,[2,0,7],\"02\");k=g(e,0,[2,0,8],\"02\")}catch(i){throw\"malformed PKCS#8 plain RSA private key\"}this.setPrivateEx(c,j,l,b,a,f,d,k)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw\"keyHex is not ASN.1 hex string\"}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!==\"02\"||c.substr(a[1],2)!==\"02\"){throw\"wrong hex for PKCS#5 public key\"}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw\"not ASN.1 hex string\"}if(c.getTLVbyList(b,0,[0,0])!==\"06092a864886f70d010101\"){throw\"not PKCS8 RSA public key\"}var a=c.getTLVbyList(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)};\nvar _RE_HEXDECONLY=new RegExp(\"\");_RE_HEXDECONLY.compile(\"[^0-9a-f]\",\"gi\");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c=\"\";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw\"invalid salt length\"}}}if(c<(g+k+2)){throw\"data too long\"}var f=\"\";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dthis.n.bitLength()){return 0}var i=this.doPublic(b);var e=i.toString(16).replace(/^1f+00/,\"\");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(k){return KJUR.crypto.Util.hashString(k,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){a=a.replace(_RE_HEXDECONLY,\"\");a=a.replace(/[ \\n]+/g,\"\");var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,\"\");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){var k=new BigInteger(s,16);if(k.bitLength()>this.n.bitLength()){return false}var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw\"invalid salt length\"}}}if(m<(h+c+2)){throw\"data too long\"}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw\"bits beyond keysize not zero\"}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q0){var b=\":\"+n.join(\":\")+\":\";if(b.indexOf(\":\"+k+\":\")==-1){throw\"algorithm '\"+k+\"' not accepted in the list\"}}if(k!=\"none\"&&B===null){throw\"key shall be specified to verify.\"}if(typeof B==\"string\"&&B.indexOf(\"-----BEGIN \")!=-1){B=KEYUTIL.getKey(B)}if(z==\"RS\"||z==\"PS\"){if(!(B instanceof m)){throw\"key shall be a RSAKey obj for RS* and PS* algs\"}}if(z==\"ES\"){if(!(B instanceof p)){throw\"key shall be a ECDSA obj for ES* algs\"}}if(k==\"none\"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw\"unsupported alg name: \"+k}else{u=t.jwsalg2sigalg[k]}if(u==\"none\"){throw\"not supported\"}else{if(u.substr(0,4)==\"Hmac\"){var o=null;if(B===undefined){throw\"hexadecimal key shall be specified for HMAC\"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf(\"withECDSA\")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(\".\");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw\"malformed sJWS: wrong number of '.' splitted elements\"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null,\" \");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null,\" \")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;var k=e.split(\".\");var c=k[0];var i=k[1];var q=c+\".\"+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw\"acceptField.alg shall be specified\"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss===\"object\"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub===\"object\"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud===\"object\"){if(typeof g.aud==\"string\"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud==\"object\"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt===\"number\"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!==\"number\"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp==\"number\"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw\"addSignature failed: \"+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw\"malformed header\"}if(typeof g.payload===\"string\"){this.sPayload=g.payload}else{throw\"malformed signatures\"}if(g.signatures.length>0){this.aSignatures=g.signatures}else{throw\"malformed signatures\"}}catch(e){throw\"malformed JWS-JS JSON object: \"+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}};\nexports.SecureRandom = SecureRandom;\nexports.rng_seed_time = rng_seed_time;\n\nexports.BigInteger = BigInteger;\nexports.RSAKey = RSAKey;\nexports.ECDSA = KJUR.crypto.ECDSA;\nexports.DSA = KJUR.crypto.DSA;\nexports.Signature = KJUR.crypto.Signature;\nexports.MessageDigest = KJUR.crypto.MessageDigest;\nexports.Mac = KJUR.crypto.Mac;\nexports.Cipher = KJUR.crypto.Cipher;\nexports.KEYUTIL = KEYUTIL;\nexports.ASN1HEX = ASN1HEX;\nexports.X509 = X509;\nexports.CryptoJS = CryptoJS;\n\n// ext/base64.js\nexports.b64tohex = b64tohex;\nexports.b64toBA = b64toBA;\n\n// base64x.js\nexports.stoBA = stoBA;\nexports.BAtos = BAtos;\nexports.BAtohex = BAtohex;\nexports.stohex = stohex;\nexports.stob64 = stob64;\nexports.stob64u = stob64u;\nexports.b64utos = b64utos;\nexports.b64tob64u = b64tob64u;\nexports.b64utob64 = b64utob64;\nexports.hex2b64 = hex2b64;\nexports.hextob64u = hextob64u;\nexports.b64utohex = b64utohex;\nexports.utf8tob64u = utf8tob64u;\nexports.b64utoutf8 = b64utoutf8;\nexports.utf8tob64 = utf8tob64;\nexports.b64toutf8 = b64toutf8;\nexports.utf8tohex = utf8tohex;\nexports.hextoutf8 = hextoutf8;\nexports.hextorstr = hextorstr;\nexports.rstrtohex = rstrtohex;\nexports.hextob64 = hextob64;\nexports.hextob64nl = hextob64nl;\nexports.b64nltohex = b64nltohex;\nexports.hextopem = hextopem;\nexports.pemtohex = pemtohex;\nexports.hextoArrayBuffer = hextoArrayBuffer;\nexports.ArrayBuffertohex = ArrayBuffertohex;\nexports.zulutomsec = zulutomsec;\nexports.zulutosec = zulutosec;\nexports.zulutodate = zulutodate;\nexports.datetozulu = datetozulu;\nexports.uricmptohex = uricmptohex;\nexports.hextouricmp = hextouricmp;\nexports.ipv6tohex = ipv6tohex;\nexports.hextoipv6 = hextoipv6;\nexports.hextoip = hextoip;\nexports.iptohex = iptohex;\nexports.encodeURIComponentAll = encodeURIComponentAll;\nexports.newline_toUnix = newline_toUnix;\nexports.newline_toDos = newline_toDos;\nexports.hextoposhex = hextoposhex;\nexports.intarystrtohex = intarystrtohex;\nexports.strdiffidx = strdiffidx;\n\n// name spaces\nexports.KJUR = KJUR;\nexports.crypto = KJUR.crypto;\nexports.asn1 = KJUR.asn1;\nexports.jws = KJUR.jws;\nexports.lang = KJUR.lang;\n\n\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://AppID/./node_modules/jsrsasign/lib/jsrsasign.js?"); - -/***/ }), - -/***/ "./node_modules/node-fetch/browser.js": -/*!********************************************!*\ - !*** ./node_modules/node-fetch/browser.js ***! - \********************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("\n\n// ref: https://github.com/tc39/proposal-global\nvar getGlobal = function () {\n\t// the only reliable means to get the global object is\n\t// `Function('return this')()`\n\t// However, this causes CSP violations in Chrome apps.\n\tif (typeof self !== 'undefined') { return self; }\n\tif (typeof window !== 'undefined') { return window; }\n\tif (typeof global !== 'undefined') { return global; }\n\tthrow new Error('unable to locate global object');\n}\n\nvar global = getGlobal();\n\nmodule.exports = exports = global.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = global.fetch.bind(global);\n\nexports.Headers = global.Headers;\nexports.Request = global.Request;\nexports.Response = global.Response;\n\n//# sourceURL=webpack://AppID/./node_modules/node-fetch/browser.js?"); - -/***/ }), - -/***/ "./node_modules/webpack/buildin/global.js": -/*!***********************************!*\ - !*** (webpack)/buildin/global.js ***! - \***********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://AppID/(webpack)/buildin/global.js?"); - -/***/ }), - -/***/ "./package.json": -/*!**********************!*\ - !*** ./package.json ***! - \**********************/ -/*! exports provided: name, version, description, scripts, repository, main, nyc, dependencies, devDependencies, default */ -/***/ (function(module) { - -eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"ibmcloud-appid-js\\\",\\\"version\\\":\\\"0.0.2\\\",\\\"description\\\":\\\"IBM Cloud App ID SDK for Single Page Applications\\\",\\\"scripts\\\":{\\\"build\\\":\\\"webpack --mode=development\\\",\\\"test\\\":\\\"mocha\\\",\\\"coverage\\\":\\\"nyc --reporter=lcov mocha\\\",\\\"docs\\\":\\\"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json\\\"},\\\"repository\\\":{\\\"type\\\":\\\"git\\\",\\\"url\\\":\\\"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git\\\"},\\\"main\\\":\\\"dist/appid.umd.min.js\\\",\\\"nyc\\\":{\\\"all\\\":true,\\\"include\\\":[\\\"src/*.js\\\"],\\\"exclude\\\":[\\\"**/PopupController.js\\\",\\\"**/IFrameController.js\\\",\\\"**/OpenIDConfigurationResource.js\\\",\\\"**/constants.js\\\"]},\\\"dependencies\\\":{\\\"jsrsasign\\\":\\\"^8.0.12\\\"},\\\"devDependencies\\\":{\\\"node-fetch\\\":\\\"^2.6.0\\\",\\\"@babel/cli\\\":\\\"^7.0.0\\\",\\\"@babel/core\\\":\\\"^7.5.5\\\",\\\"@babel/plugin-transform-runtime\\\":\\\"^7.5.5\\\",\\\"@babel/preset-env\\\":\\\"^7.5.5\\\",\\\"babel-cli\\\":\\\"^7.0.0-beta.3\\\",\\\"chai\\\":\\\"^4.2.0\\\",\\\"coveralls\\\":\\\"^3.0.6\\\",\\\"gulp-babel\\\":\\\"^8.0.0\\\",\\\"mocha\\\":\\\"^6.2.0\\\",\\\"nyc\\\":\\\"^14.1.1\\\",\\\"webpack\\\":\\\"^4.39.1\\\",\\\"webpack-cli\\\":\\\"^3.3.6\\\",\\\"docdash\\\":\\\"^1.1.1\\\",\\\"jsdoc\\\":\\\"^3.6.3\\\"}}\");\n\n//# sourceURL=webpack://AppID/./package.json?"); - -/***/ }), - -/***/ "./src/IFrameController.js": -/*!*********************************!*\ - !*** ./src/IFrameController.js ***! - \*********************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const IFrameError = __webpack_require__(/*! ./errors/IFrameError */ \"./src/errors/IFrameError.js\");\n\nclass IFrameController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t}\n\n\topen(url) {\n\t\tthis.iFrame = this.window.document.createElement('iframe');\n\t\tthis.iFrame.src = url;\n\t\tthis.iFrame.width = 0;\n\t\tthis.iFrame.height = 0;\n\t\tthis.window.document.body.appendChild(this.iFrame);\n\t}\n\n\tremove() {\n\t\twindow.document.body.removeChild(this.iFrame);\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\treject(new IFrameError('Silent sign-in timed out'));\n\t\t\t}, 5 * 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tclearInterval(timer);\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = IFrameController;\n\n\n//# sourceURL=webpack://AppID/./src/IFrameController.js?"); - -/***/ }), - -/***/ "./src/OpenIDConfigurationResource.js": -/*!********************************************!*\ - !*** ./src/OpenIDConfigurationResource.js ***! - \********************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const packagejson = __webpack_require__(/*! ../package.json */ \"./package.json\");\n\nclass OpenIdConfigurationResource {\n\tasync init({discoveryEndpoint, requestHandler}){\n\t\tthis.openIdConfig = await requestHandler(discoveryEndpoint);\n\t\tconst headers = { 'x-filter-type': `spa:v${packagejson.version}` };\n\t\tthis.publicKeys = requestHandler(this.getJwksEndpoint(), { headers: headers });\n\t}\n\n\tgetAuthorizationEndpoint() {\n\t\treturn this.openIdConfig.authorization_endpoint;\n\t}\n\n\tgetUserInfoEndpoint() {\n\t\treturn this.openIdConfig.userinfo_endpoint;\n\t}\n\n\tgetJwksEndpoint() {\n\t\treturn this.openIdConfig.jwks_uri;\n\t}\n\n\tgetTokenEndpoint() {\n\t\treturn this.openIdConfig.token_endpoint;\n\t}\n\n\tgetIssuer() {\n\t\treturn this.openIdConfig.issuer;\n\t}\n\n\tasync getPublicKeys() {\n\t\treturn await this.publicKeys;\n\t}\n}\nmodule.exports = OpenIdConfigurationResource;\n\n\n\n//# sourceURL=webpack://AppID/./src/OpenIDConfigurationResource.js?"); - -/***/ }), - -/***/ "./src/PopupController.js": -/*!********************************!*\ - !*** ./src/PopupController.js ***! - \********************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const PopupError = __webpack_require__(/*! ./errors/PopupError */ \"./src/errors/PopupError.js\");\n\nclass PopupController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t};\n\n\tinit(popupConfig){\n\t\tthis.popupConfig = popupConfig;\n\t}\n\n\topen() {\n\t\tconst h = this.popupConfig.height;\n\t\tconst w = this.popupConfig.width;\n\t\tconst left = (window.screen.width - w) / 2;\n\t\tconst top = (window.screen.height - h) / 2;\n\t\tthis.popup = this.window.open('', 'popup', `left=${left},top=${top},width=${w},height=${h},resizable,scrollbars=yes,status=1`);\n\t\tif (!this.popup) {\n\t\t\tthrow new PopupError('Unable to open popup')\n\t\t}\n\t};\n\n\tnavigate(url) {\n\t\tthis.popup.location.href = url;\n\t};\n\n\tclose() {\n\t\tthis.popup.close();\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\tif(this.popup.closed) {\n\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\treject(new PopupError('Popup closed'));\n\t\t\t\t}\n\t\t\t}, 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = PopupController;\n\n\n//# sourceURL=webpack://AppID/./src/PopupController.js?"); - -/***/ }), - -/***/ "./src/RequestHandler.js": -/*!*******************************!*\ - !*** ./src/RequestHandler.js ***! - \*******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t}\n\t\t\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tif (text !== '') {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); - -/***/ }), - -/***/ "./src/TokenValidator.js": -/*!*******************************!*\ - !*** ./src/TokenValidator.js ***! - \*******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg:[constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif (decoded.payloadObj.nonce && decoded.payloadObj.nonce !== nonce) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor(let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); - -/***/ }), - -/***/ "./src/constants.js": -/*!**************************!*\ - !*** ./src/constants.js ***! - \**************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN_PAYLOAD: 'Expect id token payload object to have identities field',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN_PAYLOAD: 'Missing id token payload',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tGENERATE_CODE: '/cloud_directory/generate_code',\n\tCHANGE_DETAILS: '/cloud_directory/change_details',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); - -/***/ }), - -/***/ "./src/errors/AppIDError.js": -/*!**********************************!*\ - !*** ./src/errors/AppIDError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class AppIDError extends Error {}\nmodule.exports = AppIDError;\n\n//# sourceURL=webpack://AppID/./src/errors/AppIDError.js?"); - -/***/ }), - -/***/ "./src/errors/IFrameError.js": -/*!***********************************!*\ - !*** ./src/errors/IFrameError.js ***! - \***********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class IFrameError extends Error {}\nmodule.exports = IFrameError;\n\n//# sourceURL=webpack://AppID/./src/errors/IFrameError.js?"); - -/***/ }), - -/***/ "./src/errors/OAuthError.js": -/*!**********************************!*\ - !*** ./src/errors/OAuthError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class OAuthError extends Error {\n\t// See https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for the possible error messages\n\tconstructor({error, description}) {\n\t\tsuper(description || error);\n\t\tthis.error = error;\n\t\tthis.description = description;\n\t}\n}\nmodule.exports = OAuthError;\n\n//# sourceURL=webpack://AppID/./src/errors/OAuthError.js?"); - -/***/ }), - -/***/ "./src/errors/PopupError.js": -/*!**********************************!*\ - !*** ./src/errors/PopupError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class PopupError extends Error {}\nmodule.exports = PopupError;\n\n//# sourceURL=webpack://AppID/./src/errors/PopupError.js?"); - -/***/ }), - -/***/ "./src/errors/RequestError.js": -/*!************************************!*\ - !*** ./src/errors/RequestError.js ***! - \************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class RequestError extends Error {\n\tconstructor(description, status, originError) {\n\t\tsuper(description);\n\t\tthis.status = status;\n\t\tthis.originError = originError;\n\t}\n}\nmodule.exports = RequestError;\n\n//# sourceURL=webpack://AppID/./src/errors/RequestError.js?"); - -/***/ }), - -/***/ "./src/errors/TokenError.js": -/*!**********************************!*\ - !*** ./src/errors/TokenError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class TokenError extends Error {}\nmodule.exports = TokenError;\n\n//# sourceURL=webpack://AppID/./src/errors/TokenError.js?"); - -/***/ }), - -/***/ "./src/index.js": -/*!**********************!*\ - !*** ./src/index.js ***! - \**********************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in will attempt to authenticate the user in a hidden iframe.\n\t * You will need to enable Cloud Directory SSO.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * @param {string} idTokenPayload The id token payload.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token payload\"\n\t * @example\n\t * let tokens = await appID.changePassword(idTokenPayload);\n\t */\n\tasync changePassword(idTokenPayload) {\n\t\tthis._validateInitalize();\n\t\tlet userId;\n\n\t\tif (!idTokenPayload) {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN_PAYLOAD);\n\t\t}\n\t\tif (typeof idTokenPayload === 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN_PAYLOAD);\n\t\t}\n\t\tif (idTokenPayload.identities && idTokenPayload.identities[0] && idTokenPayload.identities[0].id) {\n\t\t\tif (idTokenPayload.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = idTokenPayload.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN_PAYLOAD);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\tasync changeDetails(tokens) {\n\t\t// get code\n\t\tconst generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE;\n\t\tconsole.log(generateCodeUrl);\n\t\tconst changeDetailsCode = await this.request(generateCodeUrl, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + tokens.accessToken + ' ' + tokens.idToken\n\t\t\t}\n\t\t});\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS;\n\n\t\t// send code with url\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint,\n\t\t\tchangeDetailsCode\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); - -/***/ }), - -/***/ "./src/utils.js": -/*!**********************!*\ - !*** ./src/utils.js ***! - \**********************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId, changeDetailsCode}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tif (changeDetailsCode) {\n\t\t\tauthParams.code = changeDetailsCode;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint, changeDetailsCode}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint, changeDetailsCode});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); - -/***/ }) - -/******/ }); \ No newline at end of file +var AppID=function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=4)}([function(t,e,i){(function(t){var i={userAgent:!1},n={}; +/*! +Copyright (c) 2011, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.com/yui/license.html +version: 2.9.0 +*/ +if(void 0===r)var r={};r.lang={extend:function(t,e,n){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),n){var s;for(s in n)t.prototype[s]=n[s];var o=function(){},a=["toString","valueOf"];try{/MSIE/.test(i.userAgent)&&(o=function(t,e){for(s=0;s>>2]>>>24-s%4*8&255;e[n+s>>>2]|=o<<24-(n+s)%4*8}else for(s=0;s>>2]=i[s>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=s.ceil(e/4)},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i>>2]>>>24-r%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new u.init(i,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,i=t.sigBytes,n=[],r=0;r>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new u.init(i,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},g=a.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,n=e.sigBytes,r=this.blockSize,o=n/(4*r),a=(o=t?s.ceil(o):s.max((0|o)-this._minBufferSize,0))*r,h=s.min(4*a,n);if(a){for(var c=0;c>>2]}},e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:h,padding:c}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(h=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?n.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=n.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:i})}},e.SerializableCipher=i.extend({cfg:i.extend({format:h}),encrypt:function(t,e,i,n){n=this.cfg.extend(n);var r=t.createEncryptor(i,n);return e=r.finalize(e),r=r.cfg,l.create({ciphertext:e,key:i,iv:r.iv,algorithm:t,mode:r.mode,padding:r.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(i,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,i,r){return r||(r=n.random(8)),t=o.create({keySize:e+i}).compute(t,r),i=n.create(t.words.slice(e),4*i),t.sigBytes=4*e,l.create({key:t,iv:i,salt:r})}},g=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:d}),encrypt:function(t,e,i,n){return i=(n=this.cfg.extend(n)).kdf.execute(i,t.keySize,t.ivSize),n.iv=i.iv,(t=f.encrypt.call(this,t,e,i.key,n)).mixIn(i),t},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),i=n.kdf.execute(i,t.keySize,t.ivSize,e.salt),n.iv=i.iv,f.decrypt.call(this,t,e,i.key,n)}})}(),function(){for(var t=y,e=t.lib.BlockCipher,i=t.algo,n=[],r=[],s=[],o=[],a=[],h=[],u=[],c=[],l=[],f=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var p=0,v=0;for(g=0;256>g;g++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;n[p]=m,r[m]=p;var S=d[p],F=d[S],E=d[F],w=257*d[m]^16843008*m;s[p]=w<<24|w>>>8,o[p]=w<<16|w>>>16,a[p]=w<<8|w>>>24,h[p]=w,w=16843009*E^65537*F^257*S^16843008*p,u[m]=w<<24|w>>>8,c[m]=w<<16|w>>>16,l[m]=w<<8|w>>>24,f[m]=w,p?(p=S^d[d[d[E^S]]],v^=d[d[v]]):p=v=1}var x=[0,1,2,4,8,16,32,64,128,27,54];i=i.AES=e.extend({_doReset:function(){for(var t=(i=this._key).words,e=i.sigBytes/4,i=4*((this._nRounds=e+6)+1),r=this._keySchedule=[],s=0;s>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o]):(o=n[(o=o<<8|o>>>24)>>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o],o^=x[s/e|0]<<24),r[s]=r[s-e]^o}for(t=this._invKeySchedule=[],e=0;ee||4>=s?o:u[n[o>>>24]]^c[n[o>>>16&255]]^l[n[o>>>8&255]]^f[n[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,o,a,h,n)},decryptBlock:function(t,e){var i=t[e+1];t[e+1]=t[e+3],t[e+3]=i,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,r),i=t[e+1],t[e+1]=t[e+3],t[e+3]=i},_doCryptBlock:function(t,e,i,n,r,s,o,a){for(var h=this._nRounds,u=t[e]^i[0],c=t[e+1]^i[1],l=t[e+2]^i[2],f=t[e+3]^i[3],d=4,g=1;g>>24]^r[c>>>16&255]^s[l>>>8&255]^o[255&f]^i[d++],y=n[c>>>24]^r[l>>>16&255]^s[f>>>8&255]^o[255&u]^i[d++],v=n[l>>>24]^r[f>>>16&255]^s[u>>>8&255]^o[255&c]^i[d++];f=n[f>>>24]^r[u>>>16&255]^s[c>>>8&255]^o[255&l]^i[d++],u=p,c=y,l=v}p=(a[u>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&f])^i[d++],y=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[f>>>8&255]<<8|a[255&u])^i[d++],v=(a[l>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[255&c])^i[d++],f=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^i[d++],t[e]=p,t[e+1]=y,t[e+2]=v,t[e+3]=f},keySize:8});t.AES=e._createHelper(i)}(),function(){function t(t,e){var i=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=i,this._lBlock^=i<>>t^this._lBlock)&e;this._lBlock^=i,this._rBlock^=i<i;i++){var n=o[i]-1;e[i]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;16>n;n++){var r=t[n]=[],s=h[n];for(i=0;24>i;i++)r[i/6|0]|=e[(a[i]-1+s)%28]<<31-i%6,r[4+(i/6|0)]|=e[28+(a[i+24]-1+s)%28]<<31-i%6;for(r[0]=r[0]<<1|r[0]>>>31,i=1;7>i;i++)r[i]>>>=4*(i-1)+3;r[7]=r[7]<<5|r[7]>>>27}for(e=this._invSubKeys=[],i=0;16>i;i++)e[i]=t[15-i]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(i,n,r){this._lBlock=i[n],this._rBlock=i[n+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var o=r[s],a=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^o[f])&c[f])>>>0];this._lBlock=h,this._rBlock=a^l}r=this._lBlock,this._lBlock=this._rBlock,this._rBlock=r,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),i[n]=this._lBlock,i[n+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});i.DES=r._createHelper(l),s=s.TripleDES=r.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(n.create(t.slice(0,2))),this._des2=l.createEncryptor(n.create(t.slice(2,4))),this._des3=l.createEncryptor(n.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),i.TripleDES=r._createHelper(s)}(),function(){var t=y,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,i=t.sigBytes,n=this._map;t.clamp(),t=[];for(var r=0;r>>2]>>>24-r%4*8&255)<<16|(e[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|e[r+2>>>2]>>>24-(r+2)%4*8&255,o=0;4>o&&r+.75*o>>6*(3-o)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var i=t.length,n=this._map;(r=n.charAt(64))&&(-1!=(r=t.indexOf(r))&&(i=r));for(var r=[],s=0,o=0;o>>6-o%4*2;r[s>>>2]|=(a|h)<<24-s%4*8,s++}return e.create(r,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,i,n,r,s,o){return((t=t+(e&i|~e&n)+r+o)<>>32-s)+e}function i(t,e,i,n,r,s,o){return((t=t+(e&n|i&~n)+r+o)<>>32-s)+e}function n(t,e,i,n,r,s,o){return((t=t+(e^i^n)+r+o)<>>32-s)+e}function r(t,e,i,n,r,s,o){return((t=t+(i^(e|~n))+r+o)<>>32-s)+e}for(var s=y,o=(h=s.lib).WordArray,a=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var o=0;16>o;o++){var a=t[h=s+o];t[h]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var h=t[s+0],c=(a=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],d=t[s+5],g=t[s+6],p=t[s+7],y=t[s+8],v=t[s+9],m=t[s+10],S=t[s+11],F=t[s+12],E=t[s+13],w=t[s+14],x=t[s+15],A=e(A=o[0],C=o[1],I=o[2],b=o[3],h,7,u[0]),b=e(b,A,C,I,a,12,u[1]),I=e(I,b,A,C,c,17,u[2]),C=e(C,I,b,A,l,22,u[3]);A=e(A,C,I,b,f,7,u[4]),b=e(b,A,C,I,d,12,u[5]),I=e(I,b,A,C,g,17,u[6]),C=e(C,I,b,A,p,22,u[7]),A=e(A,C,I,b,y,7,u[8]),b=e(b,A,C,I,v,12,u[9]),I=e(I,b,A,C,m,17,u[10]),C=e(C,I,b,A,S,22,u[11]),A=e(A,C,I,b,F,7,u[12]),b=e(b,A,C,I,E,12,u[13]),I=e(I,b,A,C,w,17,u[14]),A=i(A,C=e(C,I,b,A,x,22,u[15]),I,b,a,5,u[16]),b=i(b,A,C,I,g,9,u[17]),I=i(I,b,A,C,S,14,u[18]),C=i(C,I,b,A,h,20,u[19]),A=i(A,C,I,b,d,5,u[20]),b=i(b,A,C,I,m,9,u[21]),I=i(I,b,A,C,x,14,u[22]),C=i(C,I,b,A,f,20,u[23]),A=i(A,C,I,b,v,5,u[24]),b=i(b,A,C,I,w,9,u[25]),I=i(I,b,A,C,l,14,u[26]),C=i(C,I,b,A,y,20,u[27]),A=i(A,C,I,b,E,5,u[28]),b=i(b,A,C,I,c,9,u[29]),I=i(I,b,A,C,p,14,u[30]),A=n(A,C=i(C,I,b,A,F,20,u[31]),I,b,d,4,u[32]),b=n(b,A,C,I,y,11,u[33]),I=n(I,b,A,C,S,16,u[34]),C=n(C,I,b,A,w,23,u[35]),A=n(A,C,I,b,a,4,u[36]),b=n(b,A,C,I,f,11,u[37]),I=n(I,b,A,C,p,16,u[38]),C=n(C,I,b,A,m,23,u[39]),A=n(A,C,I,b,E,4,u[40]),b=n(b,A,C,I,h,11,u[41]),I=n(I,b,A,C,l,16,u[42]),C=n(C,I,b,A,g,23,u[43]),A=n(A,C,I,b,v,4,u[44]),b=n(b,A,C,I,F,11,u[45]),I=n(I,b,A,C,x,16,u[46]),A=r(A,C=n(C,I,b,A,c,23,u[47]),I,b,h,6,u[48]),b=r(b,A,C,I,p,10,u[49]),I=r(I,b,A,C,w,15,u[50]),C=r(C,I,b,A,d,21,u[51]),A=r(A,C,I,b,F,6,u[52]),b=r(b,A,C,I,l,10,u[53]),I=r(I,b,A,C,m,15,u[54]),C=r(C,I,b,A,a,21,u[55]),A=r(A,C,I,b,y,6,u[56]),b=r(b,A,C,I,x,10,u[57]),I=r(I,b,A,C,g,15,u[58]),C=r(C,I,b,A,E,21,u[59]),A=r(A,C,I,b,f,6,u[60]),b=r(b,A,C,I,S,10,u[61]),I=r(I,b,A,C,c,15,u[62]),C=r(C,I,b,A,v,21,u[63]);o[0]=o[0]+A|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+b|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;i[r>>>5]|=128<<24-r%32;var s=t.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(i.length+1),this._process(),i=(e=this._hash).words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=a._createHelper(h),s.HmacMD5=a._createHmacHelper(h)}(Math),function(){var t=y,e=(r=t.lib).WordArray,i=r.Hasher,n=[],r=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=this._hash.words,r=i[0],s=i[1],o=i[2],a=i[3],h=i[4],u=0;80>u;u++){if(16>u)n[u]=0|t[e+u];else{var c=n[u-3]^n[u-8]^n[u-14]^n[u-16];n[u]=c<<1|c>>>31}c=(r<<5|r>>>27)+h+n[u],c=20>u?c+(1518500249+(s&o|~s&a)):40>u?c+(1859775393+(s^o^a)):60>u?c+((s&o|s&a|o&a)-1894007588):c+((s^o^a)-899497514),h=a,a=o,o=s<<30|s>>>2,s=r,r=c}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+o|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(i/4294967296),e[15+(n+64>>>9<<4)]=i,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=i._createHelper(r),t.HmacSHA1=i._createHmacHelper(r)}(),function(t){for(var e=y,i=(r=e.lib).WordArray,n=r.Hasher,r=e.algo,s=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=a(t.pow(h,.5))),o[u]=a(t.pow(h,1/3)),u++),h++}var d=[];r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(t,e){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],a=i[3],h=i[4],u=i[5],c=i[6],l=i[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var g=d[f-15],p=d[f-2];d[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[f-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[f-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+o[f]+d[f],p=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&r^n&s^r&s),l=c,c=u,u=h,h=a+g|0,a=s,s=r,r=n,n=g+p|0}i[0]=i[0]+n|0,i[1]=i[1]+r|0,i[2]=i[2]+s|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0,i[5]=i[5]+u|0,i[6]=i[6]+c|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return i[r>>>5]|=128<<24-r%32,i[14+(r+64>>>9<<4)]=t.floor(n/4294967296),i[15+(r+64>>>9<<4)]=n,e.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(r),e.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var t=y,e=t.lib.WordArray,i=(n=t.algo).SHA256,n=n.SHA224=i.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=i._createHelper(n),t.HmacSHA224=i._createHmacHelper(n)}(),function(){function t(){return n.create.apply(n,arguments)}for(var e=y,i=e.lib.Hasher,n=(s=e.x64).Word,r=s.WordArray,s=e.algo,o=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],a=[],h=0;80>h;h++)a[h]=t();s=s.SHA512=i.extend({_doReset:function(){this._hash=new r.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var i=(l=this._hash.words)[0],n=l[1],r=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=i.high,d=i.low,g=n.high,p=n.low,y=r.high,v=r.low,m=s.high,S=s.low,F=h.high,E=h.low,w=u.high,x=u.low,A=c.high,b=c.low,I=l.high,C=l.low,D=f,T=d,P=g,R=p,H=y,N=v,B=m,O=S,j=F,V=E,L=w,_=x,K=A,k=b,M=I,U=C,q=0;80>q;q++){var z=a[q];if(16>q)var G=z.high=0|t[e+2*q],Y=z.low=0|t[e+2*q+1];else{G=((Y=(G=a[q-15]).high)>>>1|(J=G.low)<<31)^(Y>>>8|J<<24)^Y>>>7;var J=(J>>>1|Y<<31)^(J>>>8|Y<<24)^(J>>>7|Y<<25),W=((Y=(W=a[q-2]).high)>>>19|(X=W.low)<<13)^(Y<<3|X>>>29)^Y>>>6,X=(X>>>19|Y<<13)^(X<<3|Y>>>29)^(X>>>6|Y<<26),Z=(Y=a[q-7]).high,$=(Q=a[q-16]).high,Q=Q.low;G=(G=(G=G+Z+((Y=J+Y.low)>>>0>>0?1:0))+W+((Y=Y+X)>>>0>>0?1:0))+$+((Y=Y+Q)>>>0>>0?1:0);z.high=G,z.low=Y}Z=j&L^~j&K,Q=V&_^~V&k,z=D&P^D&H^P&H;var tt=T&R^T&N^R&N,et=(J=(D>>>28|T<<4)^(D<<30|T>>>2)^(D<<25|T>>>7),W=(T>>>28|D<<4)^(T<<30|D>>>2)^(T<<25|D>>>7),(X=o[q]).high),it=X.low;$=M+((j>>>14|V<<18)^(j>>>18|V<<14)^(j<<23|V>>>9))+((X=U+((V>>>14|j<<18)^(V>>>18|j<<14)^(V<<23|j>>>9)))>>>0>>0?1:0),M=K,U=k,K=L,k=_,L=j,_=V,j=B+($=($=($=$+Z+((X=X+Q)>>>0>>0?1:0))+et+((X=X+it)>>>0>>0?1:0))+G+((X=X+Y)>>>0>>0?1:0))+((V=O+X|0)>>>0>>0?1:0)|0,B=H,O=N,H=P,N=R,P=D,R=T,D=$+(z=J+z+((Y=W+tt)>>>0>>0?1:0))+((T=X+Y|0)>>>0>>0?1:0)|0}d=i.low=d+T,i.high=f+D+(d>>>0>>0?1:0),p=n.low=p+R,n.high=g+P+(p>>>0>>0?1:0),v=r.low=v+N,r.high=y+H+(v>>>0>>0?1:0),S=s.low=S+O,s.high=m+B+(S>>>0>>0?1:0),E=h.low=E+V,h.high=F+j+(E>>>0>>0?1:0),x=u.low=x+_,u.high=w+L+(x>>>0<_>>>0?1:0),b=c.low=b+k,c.high=A+K+(b>>>0>>0?1:0),C=l.low=C+U,l.high=I+M+(C>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(i/4294967296),e[31+(n+128>>>10<<5)]=i,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=i._createHelper(s),e.HmacSHA512=i._createHmacHelper(s)}(),function(){var t=y,e=(r=t.x64).Word,i=r.WordArray,n=(r=t.algo).SHA512,r=r.SHA384=n.extend({_doReset:function(){this._hash=new i.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(r),t.HmacSHA384=n._createHmacHelper(r)}(),function(){var t=y,e=(n=t.lib).WordArray,i=n.Hasher,n=t.algo,r=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),o=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);n=n.RIPEMD160=i.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=0;16>i;i++){var n=t[F=e+i];t[F]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var c,l,f,d,g,p,y,v,m,S,F=this._hash.words,E=(n=h.words,u.words),w=r.words,x=s.words,A=o.words,b=a.words;p=c=F[0],y=l=F[1],v=f=F[2],m=d=F[3],S=g=F[4];var I;for(i=0;80>i;i+=1)I=c+t[e+w[i]]|0,I=16>i?I+((l^f^d)+n[0]):32>i?I+((l&f|~l&d)+n[1]):48>i?I+(((l|~f)^d)+n[2]):64>i?I+((l&d|f&~d)+n[3]):I+((l^(f|~d))+n[4]),I=(I=(I|=0)<>>32-A[i])+g|0,c=g,g=d,d=f<<10|f>>>22,f=l,l=I,I=p+t[e+x[i]]|0,I=16>i?I+((y^(v|~m))+E[0]):32>i?I+((y&m|v&~m)+E[1]):48>i?I+(((y|~v)^m)+E[2]):64>i?I+((y&v|~y&m)+E[3]):I+((y^v^m)+E[4]),I=(I=(I|=0)<>>32-b[i])+S|0,p=S,S=m,m=v<<10|v>>>22,v=y,y=I;I=F[1]+f+m|0,F[1]=F[2]+d+S|0,F[2]=F[3]+g+p|0,F[3]=F[4]+c+y|0,F[4]=F[0]+l+v|0,F[0]=I},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,i=0;5>i;i++)n=e[i],e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(n),t.HmacRIPEMD160=i._createHmacHelper(n)}(Math),function(){var t=y,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,i){t=this._hasher=new t.init,"string"==typeof i&&(i=e.parse(i));var n=t.blockSize,r=4*n;i.sigBytes>r&&(i=t.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),o=this._iKey=i.clone(),a=s.words,h=o.words,u=0;u>6)+m.charAt(63&i);if(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),n+=m.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),n+=m.charAt(i>>2)+m.charAt((3&i)<<4)),S)for(;(3&n.length)>0;)n+=S;return n}function E(t){var e,i,n,r="",s=0;for(e=0;e>2),i=3&n,s=1):1==s?(r+=T(i<<2|n>>4),i=15&n,s=2):2==s?(r+=T(i),r+=T(n>>2),i=3&n,s=3):(r+=T(i<<2|n>>4),r+=T(15&n),s=0));return 1==s&&(r+=T(i<<2)),r}function w(t){var e,i=E(t),n=new Array;for(e=0;2*e>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;r=((h=o*h+((32767&c)<<15)+i[n]+(1073741823&r))>>>30)+(c>>>15)+a*u+(r>>>30),i[n++]=1073741823&h}return r},v=30):"Netscape"!=i.appName?(x.prototype.am=function(t,e,i,n,r,s){for(;--s>=0;){var o=e*this[t++]+i[n]+r;r=Math.floor(o/67108864),i[n++]=67108863&o}return r},v=26):(x.prototype.am=function(t,e,i,n,r,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;r=((h=o*h+((16383&c)<<14)+i[n]+r)>>28)+(c>>14)+a*u,i[n++]=268435455&h}return r},v=28),x.prototype.DB=v,x.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function N(t){this.m=t}function B(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function K(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function k(){}function M(t){return t}function U(t){this.r2=A(),this.q3=A(),x.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}N.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},N.prototype.revert=function(t){return t},N.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},N.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},N.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},B.prototype.convert=function(t){var e=A();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(x.ZERO)>0&&this.m.subTo(e,e),e},B.prototype.revert=function(t){var e=A();return t.copyTo(e),this.reduce(e),e},B.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},B.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},B.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},x.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},x.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},x.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,r=!1,s=0;--n>=0;){var o=8==i?255&t[n]:P(t,n);o<0?"-"==t.charAt(n)&&(r=!0):(r=!1,0==s?this[this.t++]=o:s+i>this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},x.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},x.prototype.drShiftTo=function(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>r|a,a=(this[i]&s)<=0;--i)e[i]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},x.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,r=this.DB-n,s=(1<>n;for(var o=i+1;o>n;n>0&&(e[this.t-i-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},x.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),r=i.t;for(e.t=r+n.t;--r>=0;)e[r]=0;for(r=0;r=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},x.prototype.divRemTo=function(t,e,i){var n=t.abs();if(!(n.t<=0)){var r=this.abs();if(r.t0?(n.lShiftTo(h,s),r.lShiftTo(h,i)):(n.copyTo(s),r.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<1?s[u-2]>>this.F2:0),f=this.FV/l,d=(1<=0&&(i[i.t++]=1,i.subTo(v,i)),x.ONE.dlShiftTo(u,v),v.subTo(s,s);s.t=0;){var m=i[--p]==c?this.DM:Math.floor(i[p]*f+(i[p-1]+g)*d);if((i[p]+=s.am(0,m,i,y,0,u))0&&i.rShiftTo(h,i),o<0&&x.ZERO.subTo(i,i)}}},x.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},x.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},x.prototype.exp=function(t,e){if(t>4294967295||t<1)return x.ONE;var i=A(),n=A(),r=e.convert(this),s=H(t)-1;for(r.copyTo(i);--s>=0;)if(e.sqrTo(i,n),(t&1<0)e.mulTo(n,r,i);else{var o=i;i=n,n=o}return e.revert(i)},x.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<0)for(a>a)>0&&(r=!0,s=T(i));o>=0;)a>(a+=this.DB-e)):(i=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),i>0&&(r=!0),r&&(s+=T(i));return r?s:"0"},x.prototype.negate=function(){var t=A();return x.ZERO.subTo(this,t),t},x.prototype.abs=function(){return this.s<0?this.negate():this},x.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},x.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+H(this[this.t-1]^this.s&this.DM)},x.prototype.mod=function(t){var e=A();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(x.ZERO)>0&&t.subTo(e,e),e},x.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new N(e):new B(e),this.exp(t,i)},x.ZERO=R(0),x.ONE=R(1),k.prototype.convert=M,k.prototype.revert=M,k.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},k.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=A();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var q=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],z=(1<<26)/q[q.length-1]; +/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ + */ +function G(){this.i=0,this.j=0,this.S=new Array}x.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},x.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),n=R(i),r=A(),s=A(),o="";for(this.divRemTo(n,r,s);r.signum()>0;)o=(i+s.intValue()).toString(t).substr(1)+o,r.divRemTo(n,r,s);return s.intValue().toString(t)+o},x.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),r=!1,s=0,o=0,a=0;a=i&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),r&&x.ZERO.subTo(this,this)},x.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(x.ONE.shiftLeft(t-1),j,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(x.ONE.shiftLeft(t-1),this);else{var n=new Array,r=7&t;n.length=1+(t>>3),e.nextBytes(n),r>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},x.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},x.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},x.prototype.multiplyLowerTo=function(t,e,i){var n,r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r=0;)i[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},x.prototype.millerRabin=function(t){var e=this.subtract(x.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var n=e.shiftRight(i);(t=t+1>>1)>q.length&&(t=q.length);for(var r=A(),s=0;s>24},x.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},x.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},x.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,r=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[r++]=i|this.s<=0;)n<8?(i=(this[t]&(1<>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(e[r++]=i);return e},x.prototype.equals=function(t){return 0==this.compareTo(t)},x.prototype.min=function(t){return this.compareTo(t)<0?this:t},x.prototype.max=function(t){return this.compareTo(t)>0?this:t},x.prototype.and=function(t){var e=A();return this.bitwiseTo(t,O,e),e},x.prototype.or=function(t){var e=A();return this.bitwiseTo(t,j,e),e},x.prototype.xor=function(t){var e=A();return this.bitwiseTo(t,V,e),e},x.prototype.andNot=function(t){var e=A();return this.bitwiseTo(t,L,e),e},x.prototype.not=function(){for(var t=A(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var c=A();for(n.sqrTo(o[1],c);a<=u;)o[a]=A(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,d=t.t-1,g=!0,p=A();for(r=H(t[d])-1;d>=0;){for(r>=h?l=t[d]>>r-h&u:(l=(t[d]&(1<0&&(l|=t[d-1]>>this.DB+r-h)),a=i;0==(1&l);)l>>=1,--a;if((r-=a)<0&&(r+=this.DB,--d),g)o[l].copyTo(s),g=!1;else{for(;a>1;)n.sqrTo(s,p),n.sqrTo(p,s),a-=2;a>0?n.sqrTo(s,p):(f=s,s=p,p=f),n.mulTo(p,o[l],s)}for(;d>=0&&0==(t[d]&1<=0?(i.subTo(n,i),e&&r.subTo(o,r),s.subTo(a,s)):(n.subTo(i,n),e&&o.subTo(r,o),a.subTo(s,a))}return 0!=n.compareTo(x.ONE)?x.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},x.prototype.pow=function(t){return this.exp(t,new k)},x.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var r=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(r0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(r=e.getLowestSetBit())>0&&e.rShiftTo(r,e),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},x.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=q[q.length-1]){for(e=0;e>8&255,J[W++]^=t>>16&255,J[W++]^=t>>24&255,W>=X&&(W-=X)}((new Date).getTime())}if(null==J){var $;if(J=new Array,W=0,void 0!==n&&(void 0!==n.crypto||void 0!==n.msCrypto)){var Q=n.crypto||n.msCrypto;if(Q.getRandomValues){var tt=new Uint8Array(32);for(Q.getRandomValues(tt),$=0;$<32;++$)J[W++]=tt[$]}else if("Netscape"==i.appName&&i.appVersion<"5"){var et=n.crypto.random(32);for($=0;$>>8,J[W++]=255&$;W=0,Z()}function it(){if(null==Y){for(Z(),(Y=new G).init(J),W=0;W>24,(16711680&r)>>16,(65280&r)>>8,255&r]))),r+=1;return n}function ot(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function at(t,e,i){for(var n="",r=0;n.length>24,(16711680&r)>>16,(65280&r)>>8,255&r])),r+=1;return n} +/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ + */ +function ht(t,e){this.x=e,this.q=t}function ut(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?x.ONE:n,this.zinv=null}function ct(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new ut(this,null,null)}nt.prototype.nextBytes=function(t){var e;for(e=0;e0&&e.length>0))throw"Invalid RSA public key";this.n=rt(t,16),this.e=parseInt(e,16)}},ot.prototype.encrypt=function(t){var e=function(t,e){if(e=0&&e>0;){var r=t.charCodeAt(n--);r<128?i[--e]=r:r>127&&r<2048?(i[--e]=63&r|128,i[--e]=r>>6|192):(i[--e]=63&r|128,i[--e]=r>>6&63|128,i[--e]=r>>12|224)}i[--e]=0;for(var s=new nt,o=new Array;e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new x(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var n=i.toString(16);return 0==(1&n.length)?n:"0"+n},ot.prototype.encryptOAEP=function(t,e,i){var n=function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;if(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t.length+2*n+2>e)throw"Message too long for RSA";var a,h="";for(a=0;a>3,e,i);if(null==n)return null;var r=this.doPublic(n);if(null==r)return null;var s=r.toString(16);return 0==(1&s.length)?s:"0"+s},ot.prototype.type="RSA",ot.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},ot.prototype.setPrivate=function(t,e,i){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=i;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16)}},ot.prototype.setPrivateEx=function(t,e,i,n,r,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16),this.p=rt(n,16),this.q=rt(r,16),this.dmp1=rt(s,16),this.dmq1=rt(o,16),this.coeff=rt(a,16)},ot.prototype.generate=function(t,e){var i=new nt,n=t>>1;this.e=parseInt(e,16);for(var r=new x(e,16);;){for(;this.p=new x(t-n,1,i),0!=this.p.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.p.isProbablePrime(10););for(;this.q=new x(n,1,i),0!=this.q.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(x.ONE),a=this.q.subtract(x.ONE),h=o.multiply(a);if(0==h.gcd(r).compareTo(x.ONE)){this.n=this.p.multiply(this.q),this.d=r.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},ot.prototype.decrypt=function(t){var e=rt(t,16),i=this.doPrivate(e);return null==i?null: +/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ + */ +function(t,e){for(var i=t.toByteArray(),n=0;n=i.length)return null;for(var r="";++n191&&s<224?(r+=String.fromCharCode((31&s)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&s)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},ot.prototype.decryptOAEP=function(t,e,i){var n=rt(t,16),r=this.doPrivate(n);return null==r?null:function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;for(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t=t.toByteArray(),a=0;a>3,e,i)},ht.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ht.prototype.toBigInteger=function(){return this.x},ht.prototype.negate=function(){return new ht(this.q,this.x.negate().mod(this.q))},ht.prototype.add=function(t){return new ht(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ht.prototype.subtract=function(t){return new ht(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ht.prototype.multiply=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ht.prototype.square=function(){return new ht(this.q,this.x.square().mod(this.q))},ht.prototype.divide=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ut.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO))},ut.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(x.ZERO)&&!this.y.toBigInteger().equals(x.ZERO)},ut.prototype.negate=function(){return new ut(this.curve,this.x,this.y.negate(),this.z)},ut.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),i=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(x.ZERO.equals(i))return x.ZERO.equals(e)?this.twice():this.curve.getInfinity();var n=new x("3"),r=this.x.toBigInteger(),s=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),i.square()),a=o.multiply(i),h=r.multiply(o),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(a).multiply(i).mod(this.curve.q),l=h.multiply(n).multiply(e).subtract(s.multiply(a)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),f=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},ut.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new x("3"),e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=i.multiply(this.z),r=n.multiply(i).mod(this.curve.q),s=this.curve.a.toBigInteger(),o=e.square().multiply(t);x.ZERO.equals(s)||(o=o.add(this.z.square().multiply(s)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(r)).shiftLeft(1).multiply(n).mod(this.curve.q),h=o.multiply(t).multiply(e).subtract(r.shiftLeft(1)).shiftLeft(2).multiply(r).subtract(o.square().multiply(o)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),u)},ut.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add(o?this:r))}return s},ut.prototype.multiplyTwo=function(t,e,i){var n;n=t.bitLength()>i.bitLength()?t.bitLength()-1:i.bitLength()-1;for(var r=this.curve.getInfinity(),s=this.add(e);n>=0;)r=r.twice(),t.testBit(n)?r=i.testBit(n)?r.add(s):r.add(this):i.testBit(n)&&(r=r.add(e)),--n;return r},ct.prototype.getQ=function(){return this.q},ct.prototype.getA=function(){return this.a},ct.prototype.getB=function(){return this.b},ct.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ct.prototype.getInfinity=function(){return this.infinity},ct.prototype.fromBigInteger=function(t){return new ht(this.q,t)},ct.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,i=t.substr(2,e),n=t.substr(e+2,e);return new ut(this,this.fromBigInteger(new x(i,16)),this.fromBigInteger(new x(n,16)));default:return null}}, +/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib + */ +ht.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ut.prototype.getEncoded=function(t){var e=function(t,e){var i=t.toByteArrayUnsigned();if(ei.length;)i.unshift(0);return i},i=this.getX().toBigInteger(),n=this.getY().toBigInteger(),r=e(i,32);return t?n.isEven()?r.unshift(2):r.unshift(3):(r.unshift(4),r=r.concat(e(n,32))),r},ut.decodeFrom=function(t,e){e[0];var i=e.length-1,n=e.slice(1,1+i/2),r=e.slice(1+i/2,1+i);n.unshift(0),r.unshift(0);var s=new x(n),o=new x(r);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.decodeFromHex=function(t,e){e.substr(0,2);var i=e.length-2,n=e.substr(2,i/2),r=e.substr(2+i/2,i/2),s=new x(n,16),o=new x(r,16);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),i=t.y.subtract(this.y).divide(e),n=i.square().subtract(this.x).subtract(t.x),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(x.valueOf(2)),e=this.curve.fromBigInteger(x.valueOf(3)),i=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=i.square().subtract(this.x.multiply(t)),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add2D(o?this:r))}return s},ut.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),i=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),r=this.curve.getQ(),s=e.multiply(e).mod(r),o=t.multiply(t).multiply(t).add(i.multiply(t)).add(n).mod(r);return s.equals(o)},ut.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ut.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),i=this.getY().toBigInteger();if(e.compareTo(x.ONE)<0||e.compareTo(t.subtract(x.ONE))>0)throw new Error("x coordinate out of bounds");if(i.compareTo(x.ONE)<0||i.compareTo(t.subtract(x.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0}; +/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval + */ +var lt=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),i={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,n){return e?i[e]:String.fromCharCode(parseInt(n,16))}var r=new String(""),s=(Object,Array,Object.hasOwnProperty);return function(i,o){var a,h,u=i.match(t),c=u[0],l=!1;"{"===c?a={}:"["===c?a=[]:(a=[],l=!0);for(var f=[a],d=1-l,g=u.length;d=0;)delete i[n[h]]}return o.call(t,e,i)};a=y({"":a},"")}return a}}();void 0!==ft&&ft||(ft={}),void 0!==ft.asn1&&ft.asn1||(ft.asn1={}),ft.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},ft.asn1.DERAbstractString=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=At(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},r.lang.extend(ft.asn1.DERAbstractString,ft.asn1.ASN1Object),ft.asn1.DERAbstractTime=function(t){ft.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var n=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var h=n(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=St(t)},this.setByDateValue=function(t,e,i,n,r,s){var o=new Date(Date.UTC(t,e-1,i,n,r,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},r.lang.extend(ft.asn1.DERAbstractTime,ft.asn1.ASN1Object),ft.asn1.DERAbstractStructured=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},r.lang.extend(ft.asn1.DERAbstractStructured,ft.asn1.ASN1Object),ft.asn1.DERBoolean=function(){ft.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},r.lang.extend(ft.asn1.DERBoolean,ft.asn1.ASN1Object),ft.asn1.DERInteger=function(t){ft.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ft.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},r.lang.extend(ft.asn1.DERInteger,ft.asn1.ASN1Object),ft.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ft.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}ft.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7r.length&&(r=n[i]);return(t=t.replace(r,"::")).slice(1,-1)}function _t(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?Lt(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function Kt(t){for(var e=encodeURIComponent(t),i="",n=0;n"7"?"00"+t:t}function Mt(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,i){var n=parseInt(t);if(n<0||255=2*s)break;if(a>=200)break;n.push(h),o=h,a++}return n},pt.getNthChildIdx=function(t,e,i){return pt.getChildIdx(t,e)[i]},pt.getIdxbyList=function(t,e,i,n){var r,s,o=pt;if(0==i.length){if(void 0!==n&&t.substr(e,2)!==n)throw"checking tag doesn't match: "+t.substr(e,2)+"!="+n;return e}return r=i.shift(),s=o.getChildIdx(t,e),o.getIdxbyList(t,s[r],i,n)},pt.getTLVbyList=function(t,e,i,n){var r=pt,s=r.getIdxbyList(t,e,i);if(void 0===s)throw"can't find nthList object";if(void 0!==n&&t.substr(s,2)!=n)throw"checking tag doesn't match: "+t.substr(s,2)+"!="+n;return r.getTLV(t,s)},pt.getVbyList=function(t,e,i,n,r){var s,o,a=pt;if(void 0===(s=a.getIdxbyList(t,e,i,n)))throw"can't find nthList object";return o=a.getV(t,s),!0===r&&(o=o.substr(2)),o},pt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},i=[],n=t.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var s=t.substr(2),o=[],a=0;a0&&(c=c+"."+h.join(".")),c},pt.dump=function(t,e,i,n){var r=pt,s=r.getV,o=r.dump,a=r.getChildIdx,h=t;t instanceof ft.asn1.ASN1Object&&(h=t.getEncodedHex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var c=e.ommit_long_octet;if("01"==h.substr(i,2))return"00"==(l=s(h,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==h.substr(i,2))return n+"INTEGER "+u(l=s(h,i),c)+"\n";if("03"==h.substr(i,2))return n+"BITSTRING "+u(l=s(h,i),c)+"\n";if("04"==h.substr(i,2)){var l=s(h,i);if(r.isASN1HEX(l)){var f=n+"OCTETSTRING, encapsulates\n";return f+=o(l,e,0,n+" ")}return n+"OCTETSTRING "+u(l,c)+"\n"}if("05"==h.substr(i,2))return n+"NULL\n";if("06"==h.substr(i,2)){var d=s(h,i),g=ft.asn1.ASN1Util.oidHexToInt(d),p=ft.asn1.x509.OID.oid2name(g),y=g.replace(/\./g," ");return""!=p?n+"ObjectIdentifier "+p+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0c"==h.substr(i,2))return n+"UTF8String '"+bt(s(h,i))+"'\n";if("13"==h.substr(i,2))return n+"PrintableString '"+bt(s(h,i))+"'\n";if("14"==h.substr(i,2))return n+"TeletexString '"+bt(s(h,i))+"'\n";if("16"==h.substr(i,2))return n+"IA5String '"+bt(s(h,i))+"'\n";if("17"==h.substr(i,2))return n+"UTCTime "+bt(s(h,i))+"\n";if("18"==h.substr(i,2))return n+"GeneralizedTime "+bt(s(h,i))+"\n";if("30"==h.substr(i,2)){if("3000"==h.substr(i,4))return n+"SEQUENCE {}\n";f=n+"SEQUENCE\n";var v=e;if((2==(F=a(h,i)).length||3==F.length)&&"06"==h.substr(F[0],2)&&"04"==h.substr(F[F.length-1],2)){p=r.oidname(s(h,F[0]));var m=JSON.parse(JSON.stringify(e));m.x509ExtName=p,v=m}for(var S=0;S0){var e=new i({array:this.extensionsArray}),n=new r({explicit:!0,tag:"a3",obj:e});this.asn1Array.push(n)}var s=new i({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertificate,ft.asn1.ASN1Object),ft.asn1.x509.Extension=function(t){ft.asn1.x509.Extension.superclass.constructor.call(this);var e=ft.asn1,i=e.DERObjectIdentifier,n=e.DEROctetString,r=(e.DERBitString,e.DERBoolean),s=e.DERSequence;this.getEncodedHex=function(){var t=new i({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new r),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},r.lang.extend(ft.asn1.x509.Extension,ft.asn1.ASN1Object),ft.asn1.x509.Extension.appendByNameToArray=function(t,e,i){var n=t.toLowerCase(),r=ft.asn1.x509;if("basicconstraints"==n){var s=new r.BasicConstraints(e);i.push(s)}else if("keyusage"==n){s=new r.KeyUsage(e);i.push(s)}else if("crldistributionpoints"==n){s=new r.CRLDistributionPoints(e);i.push(s)}else if("extkeyusage"==n){s=new r.ExtKeyUsage(e);i.push(s)}else if("authoritykeyidentifier"==n){s=new r.AuthorityKeyIdentifier(e);i.push(s)}else if("authorityinfoaccess"==n){s=new r.AuthorityInfoAccess(e);i.push(s)}else if("subjectaltname"==n){s=new r.SubjectAltName(e);i.push(s)}else{if("issueraltname"!=n)throw"unsupported extension name: "+t;s=new r.IssuerAltName(e);i.push(s)}},ft.asn1.x509.KeyUsage=function(t){ft.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Jt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new ft.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var i=t.names,n="000000000",r=0;r-1&&t.push(new ft.asn1.DERInteger({int:this.pathLen}));var e=new ft.asn1.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},r.lang.extend(ft.asn1.x509.BasicConstraints,ft.asn1.x509.Extension),ft.asn1.x509.CRLDistributionPoints=function(t){ft.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ft.asn1,i=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){this.asn1ExtnValue=new e.DERSequence({array:t})},this.setByOneURI=function(t){var e=new i.GeneralNames([{uri:t}]),n=new i.DistributionPointName(e),r=new i.DistributionPoint({dpobj:n});this.setByDPArray([r])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},r.lang.extend(ft.asn1.x509.CRLDistributionPoints,ft.asn1.x509.Extension),ft.asn1.x509.ExtKeyUsage=function(t){ft.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=ft.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var i=0;i0){var t=new i({array:this.aRevokedCert});this.asn1Array.push(t)}var e=new i({array:this.asn1Array});return this.hTLV=e.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize=function(){this.asn1Version=null,this.asn1SignatureAlg=null,this.asn1Issuer=null,this.asn1ThisUpdate=null,this.asn1NextUpdate=null,this.aRevokedCert=new Array},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertList,ft.asn1.ASN1Object),ft.asn1.x509.CRLEntry=function(t){ft.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=ft.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},r.lang.extend(ft.asn1.x509.CRLEntry,ft.asn1.ASN1Object),ft.asn1.x509.X500Name=function(t){ft.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=new Array;var e=ft.asn1,i=e.x509,n=Ht;if(this.setByString=function(t){var e=t.split("/");e.shift();for(var n=[],r=0;r0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},ft.asn1.x509.RDN=function(t){ft.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=new Array,this.addByString=function(t){this.asn1Array.push(new ft.asn1.x509.AttributeTypeAndValue({str:t}))},this.addByMultiValuedString=function(t){for(var e=ft.asn1.x509.RDN.parseString(t),i=0;i0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var a=!1,h=[];for(r=0;n.length>0;r++){s=n.shift();if(!0===a){var u=h.pop();if(s.match(/"$/)){o=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(o),a=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(a=!0)}return h},ft.asn1.x509.AttributeTypeAndValue=function(t){ft.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var e=ft.asn1;this.setByString=function(t){var e=t.match(/^([^=]+)=(.+)$/);if(!e)throw"malformed attrTypeAndValueStr: "+t;this.setByAttrTypeAndValueStr(e[1],e[2])},this.setByAttrTypeAndValueStr=function(t,e){this.typeObj=ft.asn1.x509.OID.atype2obj(t);var i="utf8";"C"==t&&(i="prn"),this.valueObj=this.getValueObj(i,e)},this.getValueObj=function(t,i){if("utf8"==t)return new e.DERUTF8String({str:i});if("prn"==t)return new e.DERPrintableString({str:i});if("tel"==t)return new e.DERTeletexString({str:i});if("ia5"==t)return new e.DERIA5String({str:i});throw"unsupported directory string type: type="+t+" value="+i},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.typeObj,this.valueObj]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&void 0!==t.str&&this.setByString(t.str)},r.lang.extend(ft.asn1.x509.AttributeTypeAndValue,ft.asn1.ASN1Object),ft.asn1.x509.SubjectPublicKeyInfo=function(t){ft.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ft,i=e.asn1,n=i.DERInteger,r=i.DERBitString,s=i.DERObjectIdentifier,o=i.DERSequence,a=i.ASN1Util.newObject,h=i.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof ot){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+e})}}catch(t){}try{if(t instanceof ft.crypto.ECDSA){var i=new s({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ft.crypto.DSA){i=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new h({name:"dsa",asn1params:i});var o=new n({bigint:t.y});this.asn1SubjPKey=new r({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},r.lang.extend(ft.asn1.x509.SubjectPublicKeyInfo,ft.asn1.ASN1Object),ft.asn1.x509.Time=function(t){ft.asn1.x509.Time.superclass.constructor.call(this);var e=ft.asn1,i=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},r.lang.extend(ft.asn1.x509.Time,ft.asn1.ASN1Object),ft.asn1.x509.AlgorithmIdentifier=function(t){ft.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ft.asn1;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw"algorithm not specified";null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var t=[this.asn1Alg];null!==this.asn1Params&&t.push(this.asn1Params);var i=new e.DERSequence({array:t});return this.hTLV=i.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},r.lang.extend(ft.asn1.x509.AlgorithmIdentifier,ft.asn1.ASN1Object),ft.asn1.x509.GeneralName=function(t){ft.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=ft.asn1,n=(i.DERSequence,i.DEROctetString),r=i.DERIA5String,s=i.DERTaggedObject,o=i.ASN1Object,a=i.x509.X500Name,h=Ht;this.explicit=!1,this.setByParam=function(t){var i=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",i=new r({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",i=new r({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",i=new r({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,i=new a({str:t.dn})),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var u=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certissuer param not cert";(f=new Jt).hex=u;var c=f.getIssuerHex();(i=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;u=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certsubj param not cert";(f=new Jt).hex=u;c=f.getSubjectHex();(i=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,g=t.ip,p="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(d=Mt("["+g.split(".").join(",")+"]")).length)throw p}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=Vt(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw p;d=g}i=new n({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},r.lang.extend(ft.asn1.x509.GeneralName,ft.asn1.ASN1Object),ft.asn1.x509.GeneralNames=function(t){ft.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ft.asn1;this.setByParamArray=function(t){for(var i=0;i0&&(e=new n({obj:this.dUnsignedAttrs,tag:"a1",explicit:!1}));var r=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,t,this.dSigAlg,this.dSig];null!=e&&r.push(e);var o=new i.DERSequence({array:r});return this.hTLV=o.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.SignerInfo,ft.asn1.ASN1Object),ft.asn1.cms.EncapsulatedContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.dEContentType=new r({name:"data"}),this.dEContent=null,this.isDetached=!1,this.eContentValueHex=null,this.setContentType=function(t){t.match(/^[0-2][.][0-9.]+$/)?this.dEContentType=new r({oid:t}):this.dEContentType=new r({name:t})},this.setContentValue=function(t){void 0!==t&&("string"==typeof t.hex?this.eContentValueHex=t.hex:"string"==typeof t.str&&(this.eContentValueHex=At(t.str)))},this.setContentValueHex=function(t){this.eContentValueHex=t},this.setContentValueStr=function(t){this.eContentValueHex=At(t)},this.getEncodedHex=function(){if("string"!=typeof this.eContentValueHex)throw"eContentValue not yet set";var t=new s({hex:this.eContentValueHex});this.dEContent=new i({obj:t,tag:"a0",explicit:!0});var e=[this.dEContentType];this.isDetached||e.push(this.dEContent);var r=new n({array:e});return this.hTLV=r.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.EncapsulatedContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.ContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.x509;ft.asn1.cms.ContentInfo.superclass.constructor.call(this),this.dContentType=null,this.dContent=null,this.setContentType=function(t){"string"==typeof t&&(this.dContentType=r.OID.name2obj(t))},this.getEncodedHex=function(){var t=new i({obj:this.dContent,tag:"a0",explicit:!0}),e=new n({array:[this.dContentType,t]});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t&&(t.type&&this.setContentType(t.type),t.obj&&t.obj instanceof e.ASN1Object&&(this.dContent=t.obj))},r.lang.extend(ft.asn1.cms.ContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.SignedData=function(t){var e=ft.asn1,i=e.ASN1Object,n=e.DERInteger,r=e.DERSet,s=e.DERSequence,o=e.DERTaggedObject,a=e.cms,h=a.EncapsulatedContentInfo,u=a.SignerInfo,c=a.ContentInfo,l=e.x509.AlgorithmIdentifier;ft.asn1.cms.SignedData.superclass.constructor.call(this),this.dCMSVersion=new n({int:1}),this.dDigestAlgs=null,this.digestAlgNameList=[],this.dEncapContentInfo=new h,this.dCerts=null,this.certificateList=[],this.crlList=[],this.signerInfoList=[new u],this.addCertificatesByPEM=function(t){var e=Ht(t),n=new i;n.hTLV=e,this.certificateList.push(n)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(null==this.dDigestAlgs){for(var t=[],e=0;e0){var h=new r({array:this.certificateList});this.dCerts=new o({obj:h,tag:"a0",explicit:!1})}null!=this.dCerts&&a.push(this.dCerts);var u=new r({array:this.signerInfoList});a.push(u);var c=new s({array:a});return this.hTLV=c.getEncodedHex(),this.hTLV},this.getContentInfo=function(){return this.getEncodedHex(),new c({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},this.getPEM=function(){return Rt(this.getContentInfoEncodedHex(),"CMS")}},r.lang.extend(ft.asn1.cms.SignedData,ft.asn1.ASN1Object),ft.asn1.cms.CMSUtil=new function(){},ft.asn1.cms.CMSUtil.newSignedData=function(t){var e=ft.asn1,i=e.cms,n=i.SignerInfo,r=i.SignedData,s=i.SigningTime,o=i.SigningCertificate,a=i.SigningCertificateV2,h=e.cades.SignaturePolicyIdentifier,u=new r;if(u.dEncapContentInfo.setContentValue(t.content),"object"==typeof t.certs)for(var c=0;c0){var t=new n({array:this.extensionsArray}),e=new r({array:[t]}),i=new n({array:[new a({oid:"1.2.840.113549.1.9.14"}),e]}),h=new o({explicit:!0,tag:"a0",obj:i});this.asn1Array.push(h)}else{h=new o({explicit:!1,tag:"a0",obj:new s});this.asn1Array.push(h)}var u=new n({array:this.asn1Array});return this.hTLV=u.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.csr.CertificationRequestInfo,ft.asn1.ASN1Object),ft.asn1.csr.CSRUtil=new function(){},ft.asn1.csr.CSRUtil.newCSRPEM=function(t){var e=Ut,i=ft.asn1.csr;if(void 0===t.subject)throw"parameter subject undefined";if(void 0===t.sbjpubkey)throw"parameter sbjpubkey undefined";if(void 0===t.sigalg)throw"parameter sigalg undefined";if(void 0===t.sbjprvkey)throw"parameter sbjpubkey undefined";var n=new i.CertificationRequestInfo;if(n.setSubjectByParam(t.subject),n.setSubjectPublicKeyByGetKey(t.sbjpubkey),void 0!==t.ext&&void 0!==t.ext.length)for(var r=0;rr)throw"key is too short for SigAlg: keylen="+i+","+e;for(var s="0001",o="00"+n,a="",h=r-s.length-o.length,u=0;u=0)return!1;if(i.compareTo(x.ONE)<0||i.compareTo(r)>=0)return!1;var o=i.modInverse(r),a=t.multiply(o).mod(r),h=e.multiply(o).mod(r);return s.multiply(a).add(n.multiply(h)).getX().toBigInteger().mod(r).equals(e)},this.serializeSig=function(t,e){var i=t.toByteArraySigned(),n=e.toByteArraySigned(),r=[];return r.push(2),r.push(i.length),(r=r.concat(i)).push(2),r.push(n.length),(r=r.concat(n)).unshift(r.length),r.unshift(48),r},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:x.fromByteArrayUnsigned(i),s:x.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:x.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:x.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[2,0],"06"),i=o(t,0,[1],"04");try{n=o(t,0,[3,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#1/5 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{o(t,0,[1,0],"06"),e=o(t,0,[1,1],"06"),i=o(t,0,[2,0,1],"04");try{n=o(t,0,[2,0,2,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#8 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){var e,i,n=pt,r=ft.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{s(t,0,[0,0],"06"),e=s(t,0,[0,1],"06"),i=s(t,0,[1],"03").substr(2)}catch(t){throw"malformed PKCS#8 ECC public key"}if(this.curveName=r(e),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,e){5!==e&&(e=6);var i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{i=o(t,0,[0,e,0,1],"06"),n=o(t,0,[0,e,1],"03").substr(2)}catch(t){throw"malformed X.509 certificate ECC public key"}if(this.curveName=s(i),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ft.crypto.ECDSA.parseSigHex=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new x(e.r,16),s:new x(e.s,16)}},ft.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=pt,i=e.getChildIdx,n=e.getV;if("30"!=t.substr(0,2))throw"signature is not a ASN.1 sequence";var r=i(t,0);if(2!=r.length)throw"number of signature ASN.1 sequence elements seem wrong";var s=r[0],o=r[1];if("02"!=t.substr(s,2))throw"1st item of sequene of signature is not ASN.1 integer";if("02"!=t.substr(o,2))throw"2nd item of sequene of signature is not ASN.1 integer";return{r:n(t,s),s:n(t,o)}},ft.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t),i=e.r,n=e.s;if("00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),i.length%32==30&&(i="00"+i),n.length%32==30&&(n="00"+n),i.length%32!=0)throw"unknown ECDSA sig r length error";if(n.length%32!=0)throw"unknown ECDSA sig s length error";return i+n},ft.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var e=t.substr(0,t.length/2),i=t.substr(t.length/2);return ft.crypto.ECDSA.hexRSSigToASN1Sig(e,i)},ft.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var i=new x(t,16),n=new x(e,16);return ft.crypto.ECDSA.biRSSigToASN1Sig(i,n)},ft.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var i=ft.asn1,n=new i.DERInteger({bigint:t}),r=new i.DERInteger({bigint:e});return new i.DERSequence({array:[n,r]}).getEncodedHex()},ft.crypto.ECDSA.getName=function(t){return"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040022"===t?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":null},void 0!==ft&&ft||(ft={}),void 0!==ft.crypto&&ft.crypto||(ft.crypto={}),ft.crypto.ECParameterDB=new function(){var t={},e={};function i(t){return new x(t,16)}this.getByName=function(i){var n=i;if(void 0!==e[n]&&(n=e[i]),void 0!==t[n])return t[n];throw"unregistered EC curve name: "+n},this.regist=function(n,r,s,o,a,h,u,c,l,f,d,g){t[n]={};var p=i(s),y=i(o),v=i(a),m=i(h),S=i(u),F=new ct(p,y,v),E=F.decodePointHex("04"+c+l);t[n].name=n,t[n].keylen=r,t[n].curve=F,t[n].G=E,t[n].n=m,t[n].h=S,t[n].oid=d,t[n].info=g;for(var w=0;w1?new x(n,16):null,u=new x(r,16),this.setPrivate(s,o,a,h,u)},this.setPublic=function(t,e,i,n){this.isPublic=!0,this.p=t,this.q=e,this.g=i,this.y=n,this.x=null},this.setPublicHex=function(t,e,i,n){var r,s,o,a;r=new x(t,16),s=new x(e,16),o=new x(i,16),a=new x(n,16),this.setPublic(r,s,o,a)},this.signWithMessageHash=function(t){var e=this.p,i=this.q,n=this.g,r=(this.y,this.x),s=ft.crypto.Util.getRandomBigIntegerMinToMax(x.ONE.add(x.ONE),i.subtract(x.ONE)),o=new x(t.substr(0,i.bitLength()/4),16),a=n.modPow(s,e).mod(i),h=s.modInverse(i).multiply(o.add(r.multiply(a))).mod(i);return ft.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:a}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var i=this.p,n=this.q,r=this.g,s=this.y,o=this.parseASN1Signature(e),a=o[0],h=o[1],u=new x(t.substr(0,n.bitLength()/4),16);if(x.ZERO.compareTo(a)>0||a.compareTo(n)>0)throw"invalid DSA signature";if(x.ZERO.compareTo(h)>=0||h.compareTo(n)>0)throw"invalid DSA signature";var c=h.modInverse(n),l=u.multiply(c).mod(n),f=a.multiply(c).mod(n);return 0==r.modPow(l,i).multiply(s.modPow(f,i)).mod(i).mod(n).compareTo(a)},this.parseASN1Signature=function(t){try{return[new x(pt.getVbyList(t,0,[0],"02"),16),new x(pt.getVbyList(t,0,[1],"02"),16)]}catch(t){throw"malformed ASN.1 DSA signature"}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r,s,o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{e=a(t,0,[1],"02"),i=a(t,0,[2],"02"),n=a(t,0,[3],"02"),r=a(t,0,[4],"02"),s=a(t,0,[5],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#1/5 plain DSA private key"}this.setPrivateHex(e,i,n,r,s)},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[1,1,0],"02"),i=o(t,0,[1,1,1],"02"),n=o(t,0,[1,1,2],"02"),r=o(t,0,[2,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 plain DSA private key"}this.setPrivateHex(e,i,n,null,r)},this.readPKCS8PubKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[0,1,0],"02"),i=o(t,0,[0,1,1],"02"),n=o(t,0,[0,1,2],"02"),r=o(t,0,[1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 DSA public key"}this.setPublicHex(e,i,n,r)},this.readCertPubKeyHex=function(t,e){var i,n,r,s;5!==e&&(e=6);var o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{i=a(t,0,[0,e,0,1,0],"02"),n=a(t,0,[0,e,0,1,1],"02"),r=a(t,0,[0,e,0,1,2],"02"),s=a(t,0,[0,e,1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed X.509 certificate DSA public key"}this.setPublicHex(i,n,r,s)}};var Ut=function(){var t=function(t,i,n){return e(y.AES,t,i,n)},e=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=r;var h=t.decrypt(a,s,{iv:o});return y.enc.Hex.stringify(h)},i=function(t,e,i){return n(y.AES,t,e,i)},n=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a=t.encrypt(r,s,{iv:o}),h=y.enc.Hex.parse(a.toString());return y.enc.Base64.stringify(h)},r={"AES-256-CBC":{proc:t,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,i,n){return e(y.TripleDES,t,i,n)},eproc:function(t,e,i){return n(y.TripleDES,t,e,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,i,n){return e(y.DES,t,i,n)},eproc:function(t,e,i){return n(y.DES,t,e,i)},keylen:8,ivlen:8}},s=function(t){var e={},i=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(e.cipher=i[1],e.ivsalt=i[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var r=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(r=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(r=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=r&&-1!=o){var a=t.substring(r+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,i){for(var n=i.substring(0,16),s=y.enc.Hex.parse(n),o=y.enc.Utf8.parse(e),a=r[t].keylen+r[t].ivlen,h="",u=null;;){var c=y.algo.MD5.create();if(null!=u&&c.update(u),c.update(o),c.update(s),u=c.finalize(),(h+=y.enc.Hex.stringify(u)).length>=2*a)break}var l={};return l.keyhex=h.substr(0,2*r[t].keylen),l.ivhex=h.substr(2*r[t].keylen,2*r[t].ivlen),l},a=function(t,e,i,n){var s=y.enc.Base64.parse(t),o=y.enc.Hex.stringify(s);return(0,r[e].proc)(o,i,n)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,i){return o(t,e,i)},decryptKeyB64:function(t,e,i,n){return a(t,e,i,n)},getDecryptedKeyHex:function(t,e){var i=s(t),n=(i.type,i.cipher),r=i.ivsalt,h=i.data,u=o(n,e,r).keyhex;return a(h,n,u,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,i,n,s){var a="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===r[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==s&&null!=s||(s=function(t){var e=y.lib.WordArray.random(t);return y.enc.Hex.stringify(e)}(r[n].ivlen).toUpperCase());var h=function(t,e,i,n){return(0,r[e].eproc)(t,i,n)}(e,n,o(n,i,s).keyhex,s);a="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+n+","+s+"\r\n",a+="\r\n",a+=h.replace(/(.{64})/g,"$1\r\n"),a+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={},s=i(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;r.ciphertext=n(t,s[1]);var o=i(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=i(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var h=i(t,a[1]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length;if("2a864886f70d0307"!=n(t,h[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(t,h[1]);var u=i(t,a[0]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length;if("2a864886f70d01050c"!=n(t,u[0]))throw"this only supports pkcs5PBKDF2";var c=i(t,u[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;r.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{r.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return r},getPBKDF2KeyHexFromParam:function(t,e){var i=y.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,r=y.PBKDF2(e,i,{keySize:6,iterations:n});return y.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var i=Ht(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=Ut.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=y.enc.Hex.parse(n.ciphertext);var o=y.enc.Hex.parse(r),a=y.enc.Hex.parse(n.encryptionSchemeIV),h=y.TripleDES.decrypt(s,o,{iv:a});return y.enc.Hex.stringify(h)},getKeyFromEncryptedPKCS8PEM:function(t,e){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var s=i(t,0);if(3!=s.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(s[1],2))throw"malformed PKCS8 private key(code:003)";var o=i(t,s[1]);if(2!=o.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(o[0],2))throw"malformed PKCS8 private key(code:005)";if(r.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(r.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw"malformed PKCS8 private key(code:006)";return r.keyidx=e.getVidx(t,s[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Ht(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,i=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==i.algoid)e=new ot;else if("2a8648ce380401"==i.algoid)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";e=new ft.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,i=pt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===i)e=new ot;else if("2a8648ce380401"===i)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";e=new ft.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=i(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(r.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return r.e=n(t,s[1]),r},parsePublicPKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null},s=i(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=i(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?r.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(r.algparam={},r.algparam.p=e.getVbyList(t,a[1],[0],"02"),r.algparam.q=e.getVbyList(t,a[1],[1],"02"),r.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(t,s[1]).substr(2),r}}}();Ut.getKey=function(t,e,i){var n=(y=pt).getChildIdx,r=(y.getV,y.getVbyList),s=ft.crypto,o=s.ECDSA,a=s.DSA,h=ot,u=Ht,c=Ut;if(void 0!==h&&t instanceof h)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(t.n,t.e),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(D=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(D=new h).setPrivate(t.n,t.e,t.d),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(D=new a).setPublic(t.p,t.q,t.g,t.y),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(D=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(xt(t.n),xt(t.e)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(D=new h).setPrivateEx(xt(t.n),xt(t.e),xt(t.d),xt(t.p),xt(t.q),xt(t.dp),xt(t.dq),xt(t.qi)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(D=new h).setPrivate(xt(t.n),xt(t.e),xt(t.d)),D;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);return C.setPublicKeyHex(f),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);var d=("0000000000"+xt(t.d)).slice(-l);return C.setPublicKeyHex(f),C.setPrivateKeyHex(d),C}if("pkcs5prv"===i){var g,p=t,y=pt;if(9===(g=n(p,0)).length)(D=new h).readPKCS5PrvKeyHex(p);else if(6===g.length)(D=new a).readPKCS5PrvKeyHex(p);else{if(!(g.length>2&&"04"===p.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(D=new o).readPKCS5PrvKeyHex(p)}return D}if("pkcs8prv"===i)return D=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===i)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===i)return Jt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Jt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=Ht(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=u(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=r(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),F=r(R,0,[2],"02"),E=r(R,0,[3],"02"),w=r(R,0,[4],"02"),A=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(E,16),new x(w,16),new x(A,16)),D}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var b=c.getDecryptedKeyHex(t,e),I=new ot;return I.readPKCS5PrvKeyHex(b),I}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var C,D=r(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),T=r(R,0,[2,0],"06"),P=r(R,0,[3,0],"03").substr(2);if(void 0===ft.crypto.OID.oidhex2name[T])throw"undefined OID(hex) in KJUR.crypto.OID: "+T;return(C=new o({curve:ft.crypto.OID.oidhex2name[T]})).setPublicKeyHex(P),C.setPrivateKeyHex(D),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;S=r(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),F=r(R,0,[2],"02"),E=r(R,0,[3],"02"),w=r(R,0,[4],"02"),A=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(E,16),new x(w,16),new x(A,16)),D}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw"not supported argument"},Ut.generateKeypair=function(t,e){if("RSA"==t){var i=e;(o=new ot).generate(i,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new ot,r=o.n.toString(16),s=o.e.toString(16);return n.setPublic(r,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,h=e,u=new ft.crypto.ECDSA({curve:h}).generateKeyPairHex();return(o=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),o.setPrivateKeyHex(u.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Ut.getPEM=function(t,e,i,n,r,s){var o=ft,a=o.asn1,h=a.DERObjectIdentifier,u=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,f=o.crypto,d=f.DSA,g=f.ECDSA,p=ot;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function S(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==p&&t instanceof p||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Rt(x=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=v(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===i||null==i)&&1==t.isPrivate){var F=new h({name:t.curveName}).getEncodedHex(),E=m(t).getEncodedHex(),w="";return w+=Rt(F,"EC PARAMETERS"),w+=Rt(E,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=S(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==i&&null!=i&&1==t.isPrivate){var x=v(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==i&&null!=i&&1==t.isPrivate){x=m(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==i&&null!=i&&1==t.isPrivate){x=S(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",x,i,n,s)}var A=function(t,e){var i=b(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},b=function(t,e){var i=y.lib.WordArray.random(8),n=y.lib.WordArray.random(8),r=y.PBKDF2(e,i,{keySize:6,iterations:100}),s=y.enc.Hex.parse(t),o=y.TripleDES.encrypt(s,r,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=y.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=y.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=p&&t instanceof p&&1==t.isPrivate){var I=v(t).getEncodedHex();x=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=A(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){I=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=A(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){I=new u({bigint:t.x}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=A(x,i),"ENCRYPTED PRIVATE KEY")}throw"unsupported object nor format"},Ut.getKeyFromCSRPEM=function(t){var e=Ht(t,"CERTIFICATE REQUEST");return Ut.getKeyFromCSRHex(e)},Ut.getKeyFromCSRHex=function(t){var e=Ut.parseCSRHex(t);return Ut.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Ut.parseCSRHex=function(t){var e=pt,i=e.getChildIdx,n=e.getTLV,r={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=i(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=i(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(s,a[2]),r},Ut.getJWKFromKey=function(t){var e={};if(t instanceof ot&&t.isPrivate)return e.kty="RSA",e.n=wt(t.n.toString(16)),e.e=wt(t.e.toString(16)),e.d=wt(t.d.toString(16)),e.p=wt(t.p.toString(16)),e.q=wt(t.q.toString(16)),e.dp=wt(t.dmp1.toString(16)),e.dq=wt(t.dmq1.toString(16)),e.qi=wt(t.coeff.toString(16)),e;if(t instanceof ot&&t.isPublic)return e.kty="RSA",e.n=wt(t.n.toString(16)),e.e=wt(t.e.toString(16)),e;if(t instanceof ft.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=wt(i.x),e.y=wt(i.y),e.d=wt(t.prvKeyHex),e}if(t instanceof ft.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=wt(i.x),e.y=wt(i.y),e}throw"not supported key object"},ot.getPosArrayOfChildrenFromHex=function(t){return pt.getChildIdx(t,0)},ot.getHexValueArrayOfChildrenFromHex=function(t){var e,i=pt.getV,n=i(t,(e=ot.getPosArrayOfChildrenFromHex(t))[0]),r=i(t,e[1]),s=i(t,e[2]),o=i(t,e[3]),a=i(t,e[4]),h=i(t,e[5]),u=i(t,e[6]),c=i(t,e[7]),l=i(t,e[8]);return(e=new Array).push(n,r,s,o,a,h,u,c,l),e},ot.prototype.readPrivateKeyFromPEMString=function(t){var e=Ht(t),i=ot.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},ot.prototype.readPKCS5PrvKeyHex=function(t){var e=ot.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},ot.prototype.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s,o,a,h,u=pt,c=u.getVbyList;if(!1===u.isASN1HEX(t))throw"not ASN.1 hex string";try{e=c(t,0,[2,0,1],"02"),i=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),r=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw"malformed PKCS#8 plain RSA private key"}this.setPrivateEx(e,i,n,r,s,o,a,h)},ot.prototype.readPKCS5PubKeyHex=function(t){var e=pt,i=e.getV;if(!1===e.isASN1HEX(t))throw"keyHex is not ASN.1 hex string";var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw"wrong hex for PKCS#5 public key";var r=i(t,n[0]),s=i(t,n[1]);this.setPublic(r,s)},ot.prototype.readPKCS8PubKeyHex=function(t){var e=pt;if(!1===e.isASN1HEX(t))throw"not ASN.1 hex string";if("06092a864886f70d010101"!==e.getTLVbyList(t,0,[0,0]))throw"not PKCS8 RSA public key";var i=e.getTLVbyList(t,0,[1,0]);this.readPKCS5PubKeyHex(i)},ot.prototype.readCertPubKeyHex=function(t,e){var i,n;(i=new Jt).readCertHex(t),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var qt=new RegExp("");function zt(t,e){for(var i="",n=e/4-t.length,r=0;r>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function Yt(t){for(var e in ft.crypto.Util.DIGESTINFOHEAD){var i=ft.crypto.Util.DIGESTINFOHEAD[e],n=i.length;if(t.substring(0,n)==i)return[e,t.substring(n)]}return[]}function Jt(){var t=pt,e=t.getChildIdx,i=t.getV,n=t.getTLV,r=t.getVbyList,s=t.getTLVbyList,o=t.getIdxbyList,a=t.getVidx,h=t.oidname,u=Jt,c=Ht;this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){return null===this.hex||0!==this.version?this.version:"a003020102"!==s(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return r(this.hex,0,[0,1+this.foffset],"02")},this.getSignatureAlgorithmField=function(){return h(r(this.hex,0,[0,2+this.foffset,0],"06"))},this.getIssuerHex=function(){return s(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return u.hex2dn(this.getIssuerHex())},this.getSubjectHex=function(){return s(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return u.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=r(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=r(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return t.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return o(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return o(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Ut.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){return h(r(this.hex,0,[1,0],"06"))},this.getSignatureValueHex=function(){return r(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmName(),i=this.getSignatureValueHex(),n=s(this.hex,0,[0],"30"),r=new ft.crypto.Signature({alg:e});return r.init(t),r.updateHex(n),r.verify(i)},this.parseExt=function(){if(3!==this.version)return-1;var i=o(this.hex,0,[0,7,0],"30"),n=e(this.hex,i);this.aExtInfo=new Array;for(var s=0;s0&&(u=new Array(i),(new nt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=It(h(Ct("\0\0\0\0\0\0\0\0"+r+u))),l=[];for(n=0;n>8*a-o&255;for(g[0]&=~p,n=0;nthis.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;var r=n[0];return n[1]==function(t){return ft.crypto.Util.hashString(t,r)}(t)},ot.prototype.verifyWithMessageHash=function(t,e){var i=rt(e=(e=e.replace(qt,"")).replace(/[ \n]+/g,""),16);if(i.bitLength()>this.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;n[0];return n[1]==t},ot.prototype.verifyPSS=function(t,e,i,n){var r,s=(r=Ct(t),ft.crypto.Util.hashHex(r,i));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(s,e,i,n)},ot.prototype.verifyWithMessageHashPSS=function(t,e,i,n){var r=new x(e,16);if(r.bitLength()>this.n.bitLength())return!1;var s,o=function(t){return ft.crypto.Util.hashHex(t,i)},a=It(t),h=a.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===n||void 0===n)n=h;else if(-2===n)n=c-h-2;else if(n<-2)throw"invalid salt length";if(c>8*c-u&255;if(0!=(f.charCodeAt(0)&g))throw"bits beyond keysize not zero";var p=Gt(d,f.length,o),y=[];for(s=0;s0)&&-1==(":"+i.join(":")+":").indexOf(":"+p+":"))throw"algorithm '"+p+"' not accepted in the list";if("none"!=p&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Ut.getKey(e)),!("RS"!=y&&"PS"!=y||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==y&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===s.jwsalg2sigalg[g.alg])throw"unsupported alg name: "+p;if("none"==(v=s.jwsalg2sigalg[p]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var S,F=null;try{F=h.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(F)}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(d)},ft.jws.JWS.parse=function(t){var e,i,n,r=t.split("."),s={};if(2!=r.length&&3!=r.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=r[0],i=r[1],3==r.length&&(n=r[2]),s.headerObj=ft.jws.JWS.readSafeJSONString(gt(e)),s.payloadObj=ft.jws.JWS.readSafeJSONString(gt(i)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=gt(i):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==n&&(s.sigHex=xt(n)),s},ft.jws.JWS.verifyJWT=function(t,e,i){var n=ft.jws,r=n.JWS,s=r.readSafeJSONString,o=r.inArray,a=r.includedArray,h=t.split("."),u=h[0],c=h[1],l=(xt(h[2]),s(gt(u))),f=s(gt(c));if(void 0===l.alg)return!1;if(void 0===i.alg)throw"acceptField.alg shall be specified";if(!o(l.alg,i.alg))return!1;if(void 0!==f.iss&&"object"==typeof i.iss&&!o(f.iss,i.iss))return!1;if(void 0!==f.sub&&"object"==typeof i.sub&&!o(f.sub,i.sub))return!1;if(void 0!==f.aud&&"object"==typeof i.aud)if("string"==typeof f.aud){if(!o(f.aud,i.aud))return!1}else if("object"==typeof f.aud&&!a(f.aud,i.aud))return!1;var d=n.IntDate.getNow();return void 0!==i.verifyAt&&"number"==typeof i.verifyAt&&(d=i.verifyAt),void 0!==i.gracePeriod&&"number"==typeof i.gracePeriod||(i.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+i.gracePeriodr&&this.aHeader.pop(),this.aSignature.length>r&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignatures=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},e.SecureRandom=nt,e.rng_seed_time=Z,e.BigInteger=x,e.RSAKey=ot,e.ECDSA=ft.crypto.ECDSA,e.DSA=ft.crypto.DSA,e.Signature=ft.crypto.Signature,e.MessageDigest=ft.crypto.MessageDigest,e.Mac=ft.crypto.Mac,e.Cipher=ft.crypto.Cipher,e.KEYUTIL=Ut,e.ASN1HEX=pt,e.X509=Jt,e.CryptoJS=y,e.b64tohex=E,e.b64toBA=w,e.stoBA=yt,e.BAtos=vt,e.BAtohex=mt,e.stohex=St,e.stob64=function(t){return F(St(t))},e.stob64u=function(t){return Ft(F(St(t)))},e.b64utos=function(t){return vt(w(Et(t)))},e.b64tob64u=Ft,e.b64utob64=Et,e.hex2b64=F,e.hextob64u=wt,e.b64utohex=xt,e.utf8tob64u=dt,e.b64utoutf8=gt,e.utf8tob64=function(t){return F(Ot(Kt(t)))},e.b64toutf8=function(t){return decodeURIComponent(jt(E(t)))},e.utf8tohex=At,e.hextoutf8=bt,e.hextorstr=It,e.rstrtohex=Ct,e.hextob64=Dt,e.hextob64nl=Tt,e.b64nltohex=Pt,e.hextopem=Rt,e.pemtohex=Ht,e.hextoArrayBuffer=function(t){if(t.length%2!=0)throw"input is not even length";if(null==t.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var e=new ArrayBuffer(t.length/2),i=new DataView(e),n=0;ne.length&&(i=e.length);for(var n=0;n300)throw new r(`Failed to fetch ${t}. Response=${s}`,i.status);try{return JSON.parse(s)}catch(e){if(""!==s)return s;throw new r(`Invalid response while trying to fetch ${t}. Response=${s}`,i.status,e)}}}},function(t,e,i){const n=i(5),r=i(3),s=i(16),o=i(18),a=i(20),h=i(1),u=i(2),c=i(0);t.exports=class{constructor({popup:t=new s,iframe:e=new o,openIdConfigResource:i=new a,utils:h,requestHandler:u=new r,w:l=window,url:f=URL}={}){this.popup=t,this.iframe=e,this.openIdConfigResource=i,this.URL=f,this.utils=h,h||(this.utils=new n({openIdConfigResource:this.openIdConfigResource,url:this.URL,popup:this.popup,jsrsasign:c})),this.request=u.request,this.window=l,this.initialized=!1}async init({clientId:t,discoveryEndpoint:e,popup:i={height:.8*window.screen.height,width:400}}){if(!t)throw new u(h.MISSING_CLIENT_ID);try{new this.URL(e)}catch(t){throw new u(h.INVALID_DISCOVERY_ENDPOINT)}await this.openIdConfigResource.init({discoveryEndpoint:e,requestHandler:this.request}),this.popup.init(i),this.clientId=t,this.initialized=!0}async signin(){this._validateInitalize();const t=this.openIdConfigResource.getAuthorizationEndpoint();return this.utils.performOAuthFlowAndGetTokens({origin:this.window.origin,clientId:this.clientId,endpoint:t})}async silentSignin(){this._validateInitalize();const t=this.openIdConfigResource.getAuthorizationEndpoint(),{codeVerifier:e,nonce:i,state:n,url:r}=this.utils.getAuthParamsAndUrl({clientId:this.clientId,origin:this.window.origin,prompt:h.PROMPT,endpoint:t});let s;this.iframe.open(r);try{s=await this.iframe.waitForMessage({messageType:"authorization_response"})}finally{this.iframe.remove()}this.utils.verifyMessage({message:s,state:n});let o=s.data.code;return await this.utils.retrieveTokens({clientId:this.clientId,authCode:o,codeVerifier:e,nonce:i,openId:this.openIdConfigResource,windowOrigin:this.window.origin})}async getUserInfo(t){if(this._validateInitalize(),"string"!=typeof t)throw new u(h.INVALID_ACCESS_TOKEN);return await this.request(this.openIdConfigResource.getUserInfoEndpoint(),{headers:{Authorization:"Bearer "+t}})}async changePassword(t){let e;if(this._validateInitalize(),!t)throw new u(h.MISSING_ID_TOKEN_PAYLOAD);if("string"==typeof t)throw new u(h.INVALID_ID_TOKEN_PAYLOAD);if(!(t.identities&&t.identities[0]&&t.identities[0].id))throw new u(h.INVALID_ID_TOKEN_PAYLOAD);if("cloud_directory"!==t.identities[0].provider)throw new u(h.NOT_CD_USER);e=t.identities[0].id;const i=this.openIdConfigResource.getIssuer()+h.CHANGE_PASSWORD;return this.utils.performOAuthFlowAndGetTokens({userId:e,origin:this.window.origin,clientId:this.clientId,endpoint:i})}async changeDetails(t){if(!t)throw new u(h.MISSING_TOKENS);if(!t.accessToken&&"string"!=typeof t.accessToken)throw new u(h.MISSING_ACCESS_TOKEN);if(!t.idToken&&"string"!=typeof t.idToken)throw new u(h.MISSING_ID_TOKEN);const e=this.openIdConfigResource.getIssuer()+h.GENERATE_CODE,i=await this.request(e,{headers:{Authorization:"Bearer "+t.accessToken+" "+t.idToken}}),n=this.openIdConfigResource.getIssuer()+h.CHANGE_DETAILS;return this.utils.performOAuthFlowAndGetTokens({origin:this.window.origin,clientId:this.clientId,endpoint:n,changeDetailsCode:i})}_validateInitalize(){if(!this.initialized)throw new u(h.FAIL_TO_INITIALIZE)}}},function(t,e,i){i(0);const n=i(2),r=i(11),s=i(3),o=i(14),a=i(1);t.exports=class{constructor({requestHandler:t=new s,tokenValidator:e=new o,url:i=URL,openIdConfigResource:n,popup:r,jsrsasign:a=a}={}){this.URL=i,this.request=t.request,this.tokenValidator=e,this.openIdConfigResource=n,this.popup=r,this.rs=a}buildParams(t){return Object.keys(t).map((function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])})).join("&")}getRandomString(t){return this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(t/2)}sha256(t){return this.rs.KJUR.crypto.Util.sha256(t)}getPKCEFields(){const t=this.getRandomString(a.CODE_VERIFIER_LENGTH);return{codeVerifier:t,codeChallenge:this.sha256(t),state:this.getRandomString(a.STATE_LENGTH),nonce:this.getRandomString(a.NONCE_LENGTH)}}getAuthParamsAndUrl({clientId:t,origin:e,prompt:i,endpoint:n,userId:r,changeDetailsCode:s}){const{codeVerifier:o,codeChallenge:h,state:u,nonce:c}=this.getPKCEFields();let l={client_id:t,response_type:a.RESPONSE_TYPE,state:this.rs.stob64(u),code_challenge:this.rs.stob64(h),code_challenge_method:a.CHALLENGE_METHOD,redirect_uri:e,response_mode:a.RESPONSE_MODE,nonce:c,scope:a.SCOPE};return i&&(l.prompt=i),r&&(l.user_id=r),s&&(l.code=s),{codeVerifier:o,nonce:c,state:u,url:n+"?"+this.buildParams(l)}}async performOAuthFlowAndGetTokens({userId:t,origin:e,clientId:i,endpoint:n,changeDetailsCode:r}){const{codeVerifier:s,state:o,nonce:a,url:h}=this.getAuthParamsAndUrl({userId:t,origin:e,clientId:i,endpoint:n,changeDetailsCode:r});this.popup.open(),this.popup.navigate(h);const u=await this.popup.waitForMessage({messageType:"authorization_response"});this.popup.close(),this.verifyMessage({message:u,state:o});let c=u.data.code;return await this.retrieveTokens({clientId:i,authCode:c,codeVerifier:s,nonce:a,windowOrigin:e})}verifyMessage({message:t,state:e}){if(t.data.error||t.data.error_description)throw new r({description:t.data.error_description,error:t.data.error});if(this.rs.b64utos(t.data.state)!==e)throw new n(a.INVALID_STATE);if(t.origin!==new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin)throw new n(a.INVALID_ORIGIN)}async retrieveTokens({clientId:t,authCode:e,nonce:i,codeVerifier:n,windowOrigin:r}){let s=this.openIdConfigResource.getIssuer(),o={grant_type:"authorization_code",redirect_uri:r,code:e,code_verifier:n};const a=this.buildParams(o),h=this.openIdConfigResource.getTokenEndpoint(),u=await this.request(h,{method:"POST",headers:{Authorization:"Basic "+this.rs.stob64(`${t}:${n}`),"Content-Type":"application/x-www-form-urlencoded"},body:a}),c=await this.openIdConfigResource.getPublicKeys(),l=this.tokenValidator.decodeAndValidate({token:u.access_token,publicKeys:c,issuer:s,clientId:t,nonce:i}),f=this.tokenValidator.decodeAndValidate({token:u.id_token,publicKeys:c,issuer:s,clientId:t,nonce:i});return{accessToken:u.access_token,accessTokenPayload:l,idToken:u.id_token,idTokenPayload:f}}}},function(t,e,i){"use strict";(function(t){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +var n=i(8),r=i(9),s=i(10);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return b(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function b(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return E(this,t,e,i);case"latin1":case"binary":return w(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function B(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||N(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(7))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e,i){const n=i(1),r=i(15);t.exports=class{constructor({jwt:t=i(0)}={}){this.jwt=t}decodeAndValidate({token:t,publicKeys:e,issuer:i,clientId:s,nonce:o}){const a=Math.floor(Date.now()/1e3),h=t.split(".");if(3!==h.length)throw new r(`Invalid JWT token. Got only ${h.length} parts.`);const u=this.jwt.KJUR.jws.JWS.parse(t);if(!u.headerObj)throw new r(n.INVALID_TOKEN);const c=u.headerObj.kid,l=this.getPublicKey(e.keys,c),f=this.jwt.KEYUTIL.getKey(l);if(!this.jwt.KJUR.jws.JWS.verify(t,f,{alg:[n.TOKEN_ALG]}))throw new r(n.INVALID_SIGNATURE);if(u.payloadObj.exp{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(21);t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t);const i={"x-filter-type":`spa:v${n.version}`};this.publicKeys=e(this.getJwksEndpoint(),{headers:i})}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}},function(t){t.exports=JSON.parse('{"name":"ibmcloud-appid-js","version":"0.0.2","description":"IBM Cloud App ID SDK for Single Page Applications","scripts":{"build":"webpack","test":"mocha","coverage":"nyc --reporter=lcov mocha","docs":"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git"},"main":"dist/appid.umd.min.js","nyc":{"all":true,"include":["src/*.js"],"exclude":["**/PopupController.js","**/IFrameController.js","**/OpenIDConfigurationResource.js","**/constants.js"]},"dependencies":{"jsrsasign":"^8.0.12"},"devDependencies":{"node-fetch":"^2.6.0","@babel/cli":"^7.0.0","@babel/core":"^7.5.5","@babel/plugin-transform-runtime":"^7.5.5","@babel/preset-env":"^7.5.5","babel-cli":"^7.0.0-beta.3","chai":"^4.2.0","coveralls":"^3.0.6","gulp-babel":"^8.0.0","mocha":"^6.2.0","nyc":"^14.1.1","webpack":"^4.39.1","webpack-cli":"^3.3.6","docdash":"^1.1.1","jsdoc":"^3.6.3"}}')}]); \ No newline at end of file diff --git a/dist/appid.umd.min.js b/dist/appid.umd.min.js index 7090f1a..bfcd8e9 100644 --- a/dist/appid.umd.min.js +++ b/dist/appid.umd.min.js @@ -1,345 +1,50 @@ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else if(typeof exports === 'object') - exports["AppID"] = factory(); - else - root["AppID"] = factory(); -})(window, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ "./node_modules/base64-js/index.js": -/*!*****************************************!*\ - !*** ./node_modules/base64-js/index.js ***! - \*****************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/base64-js/index.js?"); - -/***/ }), - -/***/ "./node_modules/buffer/index.js": -/*!**************************************!*\ - !*** ./node_modules/buffer/index.js ***! - \**************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("/* WEBPACK VAR INJECTION */(function(global) {/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n\n\nvar base64 = __webpack_require__(/*! base64-js */ \"./node_modules/base64-js/index.js\")\nvar ieee754 = __webpack_require__(/*! ieee754 */ \"./node_modules/ieee754/index.js\")\nvar isArray = __webpack_require__(/*! isarray */ \"./node_modules/isarray/index.js\")\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://AppID/./node_modules/buffer/index.js?"); - -/***/ }), - -/***/ "./node_modules/ieee754/index.js": -/*!***************************************!*\ - !*** ./node_modules/ieee754/index.js ***! - \***************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/ieee754/index.js?"); - -/***/ }), - -/***/ "./node_modules/isarray/index.js": -/*!***************************************!*\ - !*** ./node_modules/isarray/index.js ***! - \***************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n\n\n//# sourceURL=webpack://AppID/./node_modules/isarray/index.js?"); - -/***/ }), - -/***/ "./node_modules/jsrsasign/lib/jsrsasign.js": -/*!*************************************************!*\ - !*** ./node_modules/jsrsasign/lib/jsrsasign.js ***! - \*************************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\nvar navigator = {};\nnavigator.userAgent = false;\n\nvar window = {};\n/*\n * jsrsasign(all) 8.0.12 (2018-04-22) (c) 2010-2018 Kenji Urushima | kjur.github.com/jsrsasign/license\n */\n\n/*!\nCopyright (c) 2011, Yahoo! Inc. All rights reserved.\nCode licensed under the BSD License:\nhttp://developer.yahoo.com/yui/license.html\nversion: 2.9.0\n*/\nif(YAHOO===undefined){var YAHOO={}}YAHOO.lang={extend:function(g,h,f){if(!h||!g){throw new Error(\"YAHOO.lang.extend failed, please check that all dependencies are included.\")}var d=function(){};d.prototype=h.prototype;g.prototype=new d();g.prototype.constructor=g;g.superclass=h.prototype;if(h.prototype.constructor==Object.prototype.constructor){h.prototype.constructor=h}if(f){var b;for(b in f){g.prototype[b]=f[b]}var e=function(){},c=[\"toString\",\"valueOf\"];try{if(/MSIE/.test(navigator.userAgent)){e=function(j,i){for(b=0;b>>2]>>>(24-(r%4)*8))&255;q[(n+r)>>>2]|=o<<(24-((n+r)%4)*8)}}else{for(var r=0;r>>2]=p[r>>>2]}}this.sigBytes+=s;return this},clamp:function(){var o=this.words;var n=this.sigBytes;o[n>>>2]&=4294967295<<(32-(n%4)*8);o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);n.words=this.words.slice(0);return n},random:function(p){var o=[];for(var n=0;n>>2]>>>(24-(n%4)*8))&255;q.push((s>>>4).toString(16));q.push((s&15).toString(16))}return q.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>3]|=parseInt(p.substr(o,2),16)<<(24-(o%8)*4)}return new l.init(q,n/2)}};var d=m.Latin1={stringify:function(q){var r=q.words;var p=q.sigBytes;var n=[];for(var o=0;o>>2]>>>(24-(o%4)*8))&255;n.push(String.fromCharCode(s))}return n.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>2]|=(p.charCodeAt(o)&255)<<(24-(o%4)*8)}return new l.init(q,n)}};var c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error(\"Malformed UTF-8 data\")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}};var i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init();this._nDataBytes=0},_append:function(n){if(typeof n==\"string\"){n=c.parse(n)}this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data;var x=q.words;var n=q.sigBytes;var t=this.blockSize;var v=t*4;var u=n/v;if(w){u=e.ceil(u)}else{u=e.max((u|0)-this._minBufferSize,0)}var s=u*t;var r=e.min(s*4,n);if(s){for(var p=0;p>>2]&255}};f.BlockCipher=n.extend({cfg:n.cfg.extend({mode:m,padding:h}),reset:function(){n.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;\nthis._mode=c.call(a,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var p=f.CipherParams=k.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(g.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;\nreturn(a?l.create([1398893684,1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=l.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return p.create({ciphertext:a,salt:c})}},j=f.SerializableCipher=k.extend({cfg:k.extend({format:m}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return p.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,\nblockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return\"string\"==typeof a?b.parse(a,this):a}}),g=(g.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=l.random(8));a=v.create({keySize:b+c}).compute(a,d);c=l.create(a.words.slice(b),4*c);a.sigBytes=4*b;return p.create({key:a,iv:c,salt:d})}},s=f.PasswordBasedCipher=j.extend({cfg:j.cfg.extend({kdf:g}),encrypt:function(a,\nb,c,d){d=this.cfg.extend(d);c=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=c.iv;a=j.encrypt.call(this,a,b,c.key,d);a.mixIn(c);return a},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=c.iv;return j.decrypt.call(this,a,b,c.key,d)}})}();\n\n/*\nCryptoJS v3.1.2 aes.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){for(var q=CryptoJS,x=q.lib.BlockCipher,r=q.algo,j=[],y=[],z=[],A=[],B=[],C=[],s=[],u=[],v=[],w=[],g=[],k=0;256>k;k++)g[k]=128>k?k<<1:k<<1^283;for(var n=0,l=0,k=0;256>k;k++){var f=l^l<<1^l<<2^l<<3^l<<4,f=f>>>8^f&255^99;j[n]=f;y[f]=n;var t=g[n],D=g[t],E=g[D],b=257*g[f]^16843008*f;z[n]=b<<24|b>>>8;A[n]=b<<16|b>>>16;B[n]=b<<8|b>>>24;C[n]=b;b=16843009*E^65537*D^257*t^16843008*n;s[f]=b<<24|b>>>8;u[f]=b<<16|b>>>16;v[f]=b<<8|b>>>24;w[f]=b;n?(n=t^g[g[g[E^t]]],l^=g[g[l]]):n=l=1}var F=[0,1,2,4,8,\n16,32,64,128,27,54],r=r.AES=x.extend({_doReset:function(){for(var c=this._key,e=c.words,a=c.sigBytes/4,c=4*((this._nRounds=a+6)+1),b=this._keySchedule=[],h=0;h>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255]):(d=d<<8|d>>>24,d=j[d>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255],d^=F[h/a|0]<<24);b[h]=b[h-a]^d}e=this._invKeySchedule=[];for(a=0;aa||4>=h?d:s[j[d>>>24]]^u[j[d>>>16&255]]^v[j[d>>>\n8&255]]^w[j[d&255]]},encryptBlock:function(c,e){this._doCryptBlock(c,e,this._keySchedule,z,A,B,C,j)},decryptBlock:function(c,e){var a=c[e+1];c[e+1]=c[e+3];c[e+3]=a;this._doCryptBlock(c,e,this._invKeySchedule,s,u,v,w,y);a=c[e+1];c[e+1]=c[e+3];c[e+3]=a},_doCryptBlock:function(c,e,a,b,h,d,j,m){for(var n=this._nRounds,f=c[e]^a[0],g=c[e+1]^a[1],k=c[e+2]^a[2],p=c[e+3]^a[3],l=4,t=1;t>>24]^h[g>>>16&255]^d[k>>>8&255]^j[p&255]^a[l++],r=b[g>>>24]^h[k>>>16&255]^d[p>>>8&255]^j[f&255]^a[l++],s=\nb[k>>>24]^h[p>>>16&255]^d[f>>>8&255]^j[g&255]^a[l++],p=b[p>>>24]^h[f>>>16&255]^d[g>>>8&255]^j[k&255]^a[l++],f=q,g=r,k=s;q=(m[f>>>24]<<24|m[g>>>16&255]<<16|m[k>>>8&255]<<8|m[p&255])^a[l++];r=(m[g>>>24]<<24|m[k>>>16&255]<<16|m[p>>>8&255]<<8|m[f&255])^a[l++];s=(m[k>>>24]<<24|m[p>>>16&255]<<16|m[f>>>8&255]<<8|m[g&255])^a[l++];p=(m[p>>>24]<<24|m[f>>>16&255]<<16|m[g>>>8&255]<<8|m[k&255])^a[l++];c[e]=q;c[e+1]=r;c[e+2]=s;c[e+3]=p},keySize:8});q.AES=x._createHelper(r)})();\n\n/*\nCryptoJS v3.1.2 tripledes-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function j(b,c){var a=(this._lBlock>>>b^this._rBlock)&c;this._rBlock^=a;this._lBlock^=a<>>b^this._lBlock)&c;this._lBlock^=a;this._rBlock^=a<a;a++){var f=q[a]-1;c[a]=b[f>>>5]>>>31-f%32&1}b=this._subKeys=[];for(f=0;16>f;f++){for(var d=b[f]=[],e=r[f],a=0;24>a;a++)d[a/6|0]|=c[(p[a]-1+e)%28]<<31-a%6,d[4+(a/6|0)]|=c[28+(p[a+24]-1+e)%28]<<31-a%6;d[0]=d[0]<<1|d[0]>>>31;for(a=1;7>a;a++)d[a]>>>=\n4*(a-1)+3;d[7]=d[7]<<5|d[7]>>>27}c=this._invSubKeys=[];for(a=0;16>a;a++)c[a]=b[15-a]},encryptBlock:function(b,c){this._doCryptBlock(b,c,this._subKeys)},decryptBlock:function(b,c){this._doCryptBlock(b,c,this._invSubKeys)},_doCryptBlock:function(b,c,a){this._lBlock=b[c];this._rBlock=b[c+1];j.call(this,4,252645135);j.call(this,16,65535);l.call(this,2,858993459);l.call(this,8,16711935);j.call(this,1,1431655765);for(var f=0;16>f;f++){for(var d=a[f],e=this._lBlock,h=this._rBlock,g=0,k=0;8>k;k++)g|=s[k][((h^\nd[k])&t[k])>>>0];this._lBlock=h;this._rBlock=e^g}a=this._lBlock;this._lBlock=this._rBlock;this._rBlock=a;j.call(this,1,1431655765);l.call(this,8,16711935);l.call(this,2,858993459);j.call(this,16,65535);j.call(this,4,252645135);b[c]=this._lBlock;b[c+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});h.DES=e._createHelper(m);g=g.TripleDES=e.extend({_doReset:function(){var b=this._key.words;this._des1=m.createEncryptor(n.create(b.slice(0,2)));this._des2=m.createEncryptor(n.create(b.slice(2,4)));this._des3=\nm.createEncryptor(n.create(b.slice(4,6)))},encryptBlock:function(b,c){this._des1.encryptBlock(b,c);this._des2.decryptBlock(b,c);this._des3.encryptBlock(b,c)},decryptBlock:function(b,c){this._des3.decryptBlock(b,c);this._des2.encryptBlock(b,c);this._des1.decryptBlock(b,c)},keySize:6,ivSize:2,blockSize:2});h.TripleDES=e._createHelper(g)})();\n\n/*\nCryptoJS v3.1.2 enc-base64.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join(\"\")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d<\ne;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\"}})();\n\n/*\nCryptoJS v3.1.2 md5.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(E){function h(a,f,g,j,p,h,k){a=a+(f&g|~f&j)+p+k;return(a<>>32-h)+f}function k(a,f,g,j,p,h,k){a=a+(f&j|g&~j)+p+k;return(a<>>32-h)+f}function l(a,f,g,j,h,k,l){a=a+(f^g^j)+h+l;return(a<>>32-k)+f}function n(a,f,g,j,h,k,l){a=a+(g^(f|~j))+h+l;return(a<>>32-k)+f}for(var r=CryptoJS,q=r.lib,F=q.WordArray,s=q.Hasher,q=r.algo,a=[],t=0;64>t;t++)a[t]=4294967296*E.abs(E.sin(t+1))|0;q=q.MD5=s.extend({_doReset:function(){this._hash=new F.init([1732584193,4023233417,2562383102,271733878])},\n_doProcessBlock:function(m,f){for(var g=0;16>g;g++){var j=f+g,p=m[j];m[j]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360}var g=this._hash.words,j=m[f+0],p=m[f+1],q=m[f+2],r=m[f+3],s=m[f+4],t=m[f+5],u=m[f+6],v=m[f+7],w=m[f+8],x=m[f+9],y=m[f+10],z=m[f+11],A=m[f+12],B=m[f+13],C=m[f+14],D=m[f+15],b=g[0],c=g[1],d=g[2],e=g[3],b=h(b,c,d,e,j,7,a[0]),e=h(e,b,c,d,p,12,a[1]),d=h(d,e,b,c,q,17,a[2]),c=h(c,d,e,b,r,22,a[3]),b=h(b,c,d,e,s,7,a[4]),e=h(e,b,c,d,t,12,a[5]),d=h(d,e,b,c,u,17,a[6]),c=h(c,d,e,b,v,22,a[7]),\nb=h(b,c,d,e,w,7,a[8]),e=h(e,b,c,d,x,12,a[9]),d=h(d,e,b,c,y,17,a[10]),c=h(c,d,e,b,z,22,a[11]),b=h(b,c,d,e,A,7,a[12]),e=h(e,b,c,d,B,12,a[13]),d=h(d,e,b,c,C,17,a[14]),c=h(c,d,e,b,D,22,a[15]),b=k(b,c,d,e,p,5,a[16]),e=k(e,b,c,d,u,9,a[17]),d=k(d,e,b,c,z,14,a[18]),c=k(c,d,e,b,j,20,a[19]),b=k(b,c,d,e,t,5,a[20]),e=k(e,b,c,d,y,9,a[21]),d=k(d,e,b,c,D,14,a[22]),c=k(c,d,e,b,s,20,a[23]),b=k(b,c,d,e,x,5,a[24]),e=k(e,b,c,d,C,9,a[25]),d=k(d,e,b,c,r,14,a[26]),c=k(c,d,e,b,w,20,a[27]),b=k(b,c,d,e,B,5,a[28]),e=k(e,b,\nc,d,q,9,a[29]),d=k(d,e,b,c,v,14,a[30]),c=k(c,d,e,b,A,20,a[31]),b=l(b,c,d,e,t,4,a[32]),e=l(e,b,c,d,w,11,a[33]),d=l(d,e,b,c,z,16,a[34]),c=l(c,d,e,b,C,23,a[35]),b=l(b,c,d,e,p,4,a[36]),e=l(e,b,c,d,s,11,a[37]),d=l(d,e,b,c,v,16,a[38]),c=l(c,d,e,b,y,23,a[39]),b=l(b,c,d,e,B,4,a[40]),e=l(e,b,c,d,j,11,a[41]),d=l(d,e,b,c,r,16,a[42]),c=l(c,d,e,b,u,23,a[43]),b=l(b,c,d,e,x,4,a[44]),e=l(e,b,c,d,A,11,a[45]),d=l(d,e,b,c,D,16,a[46]),c=l(c,d,e,b,q,23,a[47]),b=n(b,c,d,e,j,6,a[48]),e=n(e,b,c,d,v,10,a[49]),d=n(d,e,b,c,\nC,15,a[50]),c=n(c,d,e,b,t,21,a[51]),b=n(b,c,d,e,A,6,a[52]),e=n(e,b,c,d,r,10,a[53]),d=n(d,e,b,c,y,15,a[54]),c=n(c,d,e,b,p,21,a[55]),b=n(b,c,d,e,w,6,a[56]),e=n(e,b,c,d,D,10,a[57]),d=n(d,e,b,c,u,15,a[58]),c=n(c,d,e,b,B,21,a[59]),b=n(b,c,d,e,s,6,a[60]),e=n(e,b,c,d,z,10,a[61]),d=n(d,e,b,c,q,15,a[62]),c=n(c,d,e,b,x,21,a[63]);g[0]=g[0]+b|0;g[1]=g[1]+c|0;g[2]=g[2]+d|0;g[3]=g[3]+e|0},_doFinalize:function(){var a=this._data,f=a.words,g=8*this._nDataBytes,j=8*a.sigBytes;f[j>>>5]|=128<<24-j%32;var h=E.floor(g/\n4294967296);f[(j+64>>>9<<4)+15]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;f[(j+64>>>9<<4)+14]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360;a.sigBytes=4*(f.length+1);this._process();a=this._hash;f=a.words;for(g=0;4>g;g++)j=f[g],f[g]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=s.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=s._createHelper(q);r.HmacMD5=s._createHmacHelper(q)})(Math);\n\n/*\nCryptoJS v3.1.2 sha1-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var k=CryptoJS,b=k.lib,m=b.WordArray,l=b.Hasher,d=[],b=k.algo.SHA1=l.extend({_doReset:function(){this._hash=new m.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(n,p){for(var a=this._hash.words,e=a[0],f=a[1],h=a[2],j=a[3],b=a[4],c=0;80>c;c++){if(16>c)d[c]=n[p+c]|0;else{var g=d[c-3]^d[c-8]^d[c-14]^d[c-16];d[c]=g<<1|g>>>31}g=(e<<5|e>>>27)+b+d[c];g=20>c?g+((f&h|~f&j)+1518500249):40>c?g+((f^h^j)+1859775393):60>c?g+((f&h|f&j|h&j)-1894007588):g+((f^h^\nj)-899497514);b=j;j=h;h=f<<30|f>>>2;f=e;e=g}a[0]=a[0]+e|0;a[1]=a[1]+f|0;a[2]=a[2]+h|0;a[3]=a[3]+j|0;a[4]=a[4]+b|0},_doFinalize:function(){var b=this._data,d=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=Math.floor(a/4294967296);d[(e+64>>>9<<4)+15]=a;b.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var b=l.clone.call(this);b._hash=this._hash.clone();return b}});k.SHA1=l._createHelper(b);k.HmacSHA1=l._createHmacHelper(b)})();\n\n/*\nCryptoJS v3.1.2 sha256-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(k){for(var g=CryptoJS,h=g.lib,v=h.WordArray,j=h.Hasher,h=g.algo,s=[],t=[],u=function(q){return 4294967296*(q-(q|0))|0},l=2,b=0;64>b;){var d;a:{d=l;for(var w=k.sqrt(d),r=2;r<=w;r++)if(!(d%r)){d=!1;break a}d=!0}d&&(8>b&&(s[b]=u(k.pow(l,0.5))),t[b]=u(k.pow(l,1/3)),b++);l++}var n=[],h=h.SHA256=j.extend({_doReset:function(){this._hash=new v.init(s.slice(0))},_doProcessBlock:function(q,h){for(var a=this._hash.words,c=a[0],d=a[1],b=a[2],k=a[3],f=a[4],g=a[5],j=a[6],l=a[7],e=0;64>e;e++){if(16>e)n[e]=\nq[h+e]|0;else{var m=n[e-15],p=n[e-2];n[e]=((m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3)+n[e-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[e-16]}m=l+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&g^~f&j)+t[e]+n[e];p=((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&d^c&b^d&b);l=j;j=g;g=f;f=k+m|0;k=b;b=d;d=c;c=m+p|0}a[0]=a[0]+c|0;a[1]=a[1]+d|0;a[2]=a[2]+b|0;a[3]=a[3]+k|0;a[4]=a[4]+f|0;a[5]=a[5]+g|0;a[6]=a[6]+j|0;a[7]=a[7]+l|0},_doFinalize:function(){var d=this._data,b=d.words,a=8*this._nDataBytes,c=8*d.sigBytes;\nb[c>>>5]|=128<<24-c%32;b[(c+64>>>9<<4)+14]=k.floor(a/4294967296);b[(c+64>>>9<<4)+15]=a;d.sigBytes=4*b.length;this._process();return this._hash},clone:function(){var b=j.clone.call(this);b._hash=this._hash.clone();return b}});g.SHA256=j._createHelper(h);g.HmacSHA256=j._createHmacHelper(h)})(Math);\n\n/*\nCryptoJS v3.1.2 sha224-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var b=CryptoJS,d=b.lib.WordArray,a=b.algo,c=a.SHA256,a=a.SHA224=c.extend({_doReset:function(){this._hash=new d.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var a=c._doFinalize.call(this);a.sigBytes-=4;return a}});b.SHA224=c._createHelper(a);b.HmacSHA224=c._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 sha512-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function a(){return d.create.apply(d,arguments)}for(var n=CryptoJS,r=n.lib.Hasher,e=n.x64,d=e.Word,T=e.WordArray,e=n.algo,ea=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),\na(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,\n2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),\na(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,\n3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],w=0;80>w;w++)v[w]=a();e=e.SHA512=r.extend({_doReset:function(){this._hash=new T.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(a,d){for(var f=this._hash.words,\nF=f[0],e=f[1],n=f[2],r=f[3],G=f[4],H=f[5],I=f[6],f=f[7],w=F.high,J=F.low,X=e.high,K=e.low,Y=n.high,L=n.low,Z=r.high,M=r.low,$=G.high,N=G.low,aa=H.high,O=H.low,ba=I.high,P=I.low,ca=f.high,Q=f.low,k=w,g=J,z=X,x=K,A=Y,y=L,U=Z,B=M,l=$,h=N,R=aa,C=O,S=ba,D=P,V=ca,E=Q,m=0;80>m;m++){var s=v[m];if(16>m)var j=s.high=a[d+2*m]|0,b=s.low=a[d+2*m+1]|0;else{var j=v[m-15],b=j.high,p=j.low,j=(b>>>1|p<<31)^(b>>>8|p<<24)^b>>>7,p=(p>>>1|b<<31)^(p>>>8|b<<24)^(p>>>7|b<<25),u=v[m-2],b=u.high,c=u.low,u=(b>>>19|c<<13)^(b<<\n3|c>>>29)^b>>>6,c=(c>>>19|b<<13)^(c<<3|b>>>29)^(c>>>6|b<<26),b=v[m-7],W=b.high,t=v[m-16],q=t.high,t=t.low,b=p+b.low,j=j+W+(b>>>0

>>0?1:0),b=b+c,j=j+u+(b>>>0>>0?1:0),b=b+t,j=j+q+(b>>>0>>0?1:0);s.high=j;s.low=b}var W=l&R^~l&S,t=h&C^~h&D,s=k&z^k&A^z&A,T=g&x^g&y^x&y,p=(k>>>28|g<<4)^(k<<30|g>>>2)^(k<<25|g>>>7),u=(g>>>28|k<<4)^(g<<30|k>>>2)^(g<<25|k>>>7),c=ea[m],fa=c.high,da=c.low,c=E+((h>>>14|l<<18)^(h>>>18|l<<14)^(h<<23|l>>>9)),q=V+((l>>>14|h<<18)^(l>>>18|h<<14)^(l<<23|h>>>9))+(c>>>0>>0?1:\n0),c=c+t,q=q+W+(c>>>0>>0?1:0),c=c+da,q=q+fa+(c>>>0>>0?1:0),c=c+b,q=q+j+(c>>>0>>0?1:0),b=u+T,s=p+s+(b>>>0>>0?1:0),V=S,E=D,S=R,D=C,R=l,C=h,h=B+c|0,l=U+q+(h>>>0>>0?1:0)|0,U=A,B=y,A=z,y=x,z=k,x=g,g=c+b|0,k=q+s+(g>>>0>>0?1:0)|0}J=F.low=J+g;F.high=w+k+(J>>>0>>0?1:0);K=e.low=K+x;e.high=X+z+(K>>>0>>0?1:0);L=n.low=L+y;n.high=Y+A+(L>>>0>>0?1:0);M=r.low=M+B;r.high=Z+U+(M>>>0>>0?1:0);N=G.low=N+h;G.high=$+l+(N>>>0>>0?1:0);O=H.low=O+C;H.high=aa+R+(O>>>0>>0?1:0);P=I.low=P+D;\nI.high=ba+S+(P>>>0>>0?1:0);Q=f.low=Q+E;f.high=ca+V+(Q>>>0>>0?1:0)},_doFinalize:function(){var a=this._data,d=a.words,f=8*this._nDataBytes,e=8*a.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+128>>>10<<5)+30]=Math.floor(f/4294967296);d[(e+128>>>10<<5)+31]=f;a.sigBytes=4*d.length;this._process();return this._hash.toX32()},clone:function(){var a=r.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});n.SHA512=r._createHelper(e);n.HmacSHA512=r._createHmacHelper(e)})();\n\n/*\nCryptoJS v3.1.2 sha384-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,a=c.x64,b=a.Word,e=a.WordArray,a=c.algo,d=a.SHA512,a=a.SHA384=d.extend({_doReset:function(){this._hash=new e.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var a=d._doFinalize.call(this);a.sigBytes-=16;return a}});c.SHA384=\nd._createHelper(a);c.HmacSHA384=d._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 ripemd160-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n/*\n\n(c) 2012 by Cedric Mesnil. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n(function(){var q=CryptoJS,d=q.lib,n=d.WordArray,p=d.Hasher,d=q.algo,x=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),y=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),z=n.create([11,14,15,12,\n5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),A=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),B=n.create([0,1518500249,1859775393,2400959708,2840853838]),C=n.create([1352829926,1548603684,1836072691,\n2053994217,0]),d=d.RIPEMD160=p.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,v){for(var b=0;16>b;b++){var c=v+b,f=e[c];e[c]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360}var c=this._hash.words,f=B.words,d=C.words,n=x.words,q=y.words,p=z.words,w=A.words,t,g,h,j,r,u,k,l,m,s;u=t=c[0];k=g=c[1];l=h=c[2];m=j=c[3];s=r=c[4];for(var a,b=0;80>b;b+=1)a=t+e[v+n[b]]|0,a=16>b?a+((g^h^j)+f[0]):32>b?a+((g&h|~g&j)+f[1]):48>b?\na+(((g|~h)^j)+f[2]):64>b?a+((g&j|h&~j)+f[3]):a+((g^(h|~j))+f[4]),a|=0,a=a<>>32-p[b],a=a+r|0,t=r,r=j,j=h<<10|h>>>22,h=g,g=a,a=u+e[v+q[b]]|0,a=16>b?a+((k^(l|~m))+d[0]):32>b?a+((k&m|l&~m)+d[1]):48>b?a+(((k|~l)^m)+d[2]):64>b?a+((k&l|~k&m)+d[3]):a+((k^l^m)+d[4]),a|=0,a=a<>>32-w[b],a=a+s|0,u=s,s=m,m=l<<10|l>>>22,l=k,k=a;a=c[1]+h+m|0;c[1]=c[2]+j+s|0;c[2]=c[3]+r+u|0;c[3]=c[4]+t+k|0;c[4]=c[0]+g+l|0;c[0]=a},_doFinalize:function(){var e=this._data,d=e.words,b=8*this._nDataBytes,c=8*e.sigBytes;\nd[c>>>5]|=128<<24-c%32;d[(c+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;e.sigBytes=4*(d.length+1);this._process();e=this._hash;d=e.words;for(b=0;5>b;b++)c=d[b],d[b]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return e},clone:function(){var d=p.clone.call(this);d._hash=this._hash.clone();return d}});q.RIPEMD160=p._createHelper(d);q.HmacRIPEMD160=p._createHmacHelper(d)})(Math);\n\n/*\nCryptoJS v3.1.2 hmac.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,k=c.enc.Utf8;c.algo.HMAC=c.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;\"string\"==typeof b&&(b=k.parse(b));var c=a.blockSize,e=4*c;b.sigBytes>e&&(b=a.finalize(b));b.clamp();for(var f=this._oKey=b.clone(),g=this._iKey=b.clone(),h=f.words,j=g.words,d=0;d>6)+b64map.charAt(e&63)}if(b+1==d.length){e=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(e<<2)}else{if(b+2==d.length){e=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(e>>2)+b64map.charAt((e&3)<<4)}}if(b64pad){while((a.length&3)>0){a+=b64pad}}return a}function b64tohex(f){var d=\"\";var e;var b=0;var c;var a;for(e=0;e>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(e){var d=b64tohex(e);var c;var b=new Array();for(c=0;2*c=0){var d=a*this[f++]+b[e]+h;h=Math.floor(d/67108864);b[e++]=d&67108863}return h}function am2(f,q,r,e,o,a){var k=q&32767,p=q>>15;while(--a>=0){var d=this[f]&32767;var g=this[f++]>>15;var b=p*d+g*k;d=k*d+((b&32767)<<15)+r[e]+(o&1073741823);o=(d>>>30)+(b>>>15)+p*g+(o>>>30);r[e++]=d&1073741823}return o}function am3(f,q,r,e,o,a){var k=q&16383,p=q>>14;while(--a>=0){var d=this[f]&16383;var g=this[f++]>>14;var b=p*d+g*k;d=k*d+((b&16383)<<14)+r[e]+o;o=(d>>28)+(b>>14)+p*g;r[e++]=d&268435455}return o}if(j_lm&&(navigator.appName==\"Microsoft Internet Explorer\")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator.appName!=\"Netscape\")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=((1<=0;--a){b[a]=this[a]}b.t=this.t;b.s=this.s}function bnpFromInt(a){this.t=1;this.s=(a<0)?-1:0;if(a>0){this[0]=a}else{if(a<-1){this[0]=a+this.DV}else{this.t=0}}}function nbv(a){var b=nbi();b.fromInt(a);return b}function bnpFromString(h,c){var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==256){e=8}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{this.fromRadix(h,c);return}}}}}}this.t=0;this.s=0;var g=h.length,d=false,f=0;while(--g>=0){var a=(e==8)?h[g]&255:intAt(h,g);if(a<0){if(h.charAt(g)==\"-\"){d=true}continue}d=false;if(f==0){this[this.t++]=a}else{if(f+e>this.DB){this[this.t-1]|=(a&((1<<(this.DB-f))-1))<>(this.DB-f))}else{this[this.t-1]|=a<=this.DB){f-=this.DB}}if(e==8&&(h[0]&128)!=0){this.s=-1;if(f>0){this[this.t-1]|=((1<<(this.DB-f))-1)<0&&this[this.t-1]==a){--this.t}}function bnToString(c){if(this.s<0){return\"-\"+this.negate().toString(c)}var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{return this.toRadix(c)}}}}}var g=(1<0){if(j>j)>0){a=true;h=int2char(l)}while(f>=0){if(j>(j+=this.DB-e)}else{l=(this[f]>>(j-=e))&g;if(j<=0){j+=this.DB;--f}}if(l>0){a=true}if(a){h+=int2char(l)}}}return a?h:\"0\"}function bnNegate(){var a=nbi();BigInteger.ZERO.subTo(this,a);return a}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(b){var d=this.s-b.s;if(d!=0){return d}var c=this.t;d=c-b.t;if(d!=0){return(this.s<0)?-d:d}while(--c>=0){if((d=this[c]-b[c])!=0){return d}}return 0}function nbits(a){var c=1,b;if((b=a>>>16)!=0){a=b;c+=16}if((b=a>>8)!=0){a=b;c+=8}if((b=a>>4)!=0){a=b;c+=4}if((b=a>>2)!=0){a=b;c+=2}if((b=a>>1)!=0){a=b;c+=1}return c}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(c,b){var a;for(a=this.t-1;a>=0;--a){b[a+c]=this[a]}for(a=c-1;a>=0;--a){b[a]=0}b.t=this.t+c;b.s=this.s}function bnpDRShiftTo(c,b){for(var a=c;a=0;--d){e[d+f+1]=(this[d]>>a)|h;h=(this[d]&g)<=0;--d){e[d]=0}e[f]=h;e.t=this.t+f+1;e.s=this.s;e.clamp()}function bnpRShiftTo(g,d){d.s=this.s;var e=Math.floor(g/this.DB);if(e>=this.t){d.t=0;return}var b=g%this.DB;var a=this.DB-b;var f=(1<>b;for(var c=e+1;c>b}if(b>0){d[this.t-e-1]|=(this.s&f)<>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g-=d.s}f.s=(g<0)?-1:0;if(g<-1){f[e++]=this.DV+g}else{if(g>0){f[e++]=g}}f.t=e;f.clamp()}function bnpMultiplyTo(c,e){var b=this.abs(),f=c.abs();var d=b.t;e.t=d+f.t;while(--d>=0){e[d]=0}for(d=0;d=0){d[b]=0}for(b=0;b=a.DV){d[b+a.t]-=a.DV;d[b+a.t+1]=1}}if(d.t>0){d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)}d.s=0;d.clamp()}function bnpDivRemTo(n,h,g){var w=n.abs();if(w.t<=0){return}var k=this.abs();if(k.t0){w.lShiftTo(v,d);k.lShiftTo(v,g)}else{w.copyTo(d);k.copyTo(g)}var p=d.t;var b=d[p-1];if(b==0){return}var o=b*(1<1)?d[p-2]>>this.F2:0);var A=this.FV/o,z=(1<=0){g[g.t++]=1;g.subTo(f,g)}BigInteger.ONE.dlShiftTo(p,f);f.subTo(d,d);while(d.t=0){var c=(g[--u]==b)?this.DM:Math.floor(g[u]*A+(g[u-1]+x)*z);if((g[u]+=d.am(0,c,g,s,0,p))0){g.rShiftTo(v,g)}if(a<0){BigInteger.ZERO.subTo(g,g)}}function bnMod(b){var c=nbi();this.abs().divRemTo(b,null,c);if(this.s<0&&c.compareTo(BigInteger.ZERO)>0){b.subTo(c,c)}return c}function Classic(a){this.m=a}function cConvert(a){if(a.s<0||a.compareTo(this.m)>=0){return a.mod(this.m)}else{return a}}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var a=this[0];if((a&1)==0){return 0}var b=a&3;b=(b*(2-(a&15)*b))&15;b=(b*(2-(a&255)*b))&255;b=(b*(2-(((a&65535)*b)&65535)))&65535;b=(b*(2-a*b%this.DV))%this.DV;return(b>0)?this.DV-b:-b}function Montgomery(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(a.DB-15))-1;this.mt2=2*a.t}function montConvert(a){var b=nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);if(a.s<0&&b.compareTo(BigInteger.ZERO)>0){this.m.subTo(b,b)}return b}function montRevert(a){var b=nbi();a.copyTo(b);this.reduce(b);return b}function montReduce(a){while(a.t<=this.mt2){a[a.t++]=0}for(var c=0;c>15)*this.mpl)&this.um)<<15))&a.DM;b=c+this.m.t;a[b]+=this.m.am(0,d,a,c,0,this.m.t);while(a[b]>=a.DV){a[b]-=a.DV;a[++b]++}}a.clamp();a.drShiftTo(this.m.t,a);if(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(h,j){if(h>4294967295||h<1){return BigInteger.ONE}var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;d.copyTo(f);while(--c>=0){j.sqrTo(f,a);if((h&(1<0){j.mulTo(a,d,f)}else{var b=f;f=a;a=b}}return j.revert(f)}function bnModPowInt(b,a){var c;if(b<256||a.isEven()){c=new Classic(a)}else{c=new Montgomery(a)}return this.exp(b,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction bnClone(){var a=nbi();this.copyTo(a);return a}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this[0]}else{if(this.t==0){return 0}}}return((this[1]&((1<<(32-this.DB))-1))<>24}function bnShortValue(){return(this.t==0)?this.s:(this[0]<<16)>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this[0]<=0)){return 0}else{return 1}}}function bnpToRadix(c){if(c==null){c=10}if(this.signum()==0||c<2||c>36){return\"0\"}var f=this.chunkSize(c);var e=Math.pow(c,f);var i=nbv(e),j=nbi(),h=nbi(),g=\"\";this.divRemTo(i,j,h);while(j.signum()>0){g=(e+h.intValue()).toString(c).substr(1)+g;j.divRemTo(i,j,h)}return h.intValue().toString(c)+g}function bnpFromRadix(m,h){this.fromInt(0);if(h==null){h=10}var f=this.chunkSize(h);var g=Math.pow(h,f),e=false,a=0,l=0;for(var c=0;c=f){this.dMultiply(g);this.dAddOffset(l,0);a=0;l=0}}if(a>0){this.dMultiply(Math.pow(h,a));this.dAddOffset(l,0)}if(e){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(f,e,h){if(\"number\"==typeof e){if(f<2){this.fromInt(1)}else{this.fromNumber(f,h);if(!this.testBit(f-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(f-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(e)){this.dAddOffset(2,0);if(this.bitLength()>f){this.subTo(BigInteger.ONE.shiftLeft(f-1),this)}}}}else{var d=new Array(),g=f&7;d.length=(f>>3)+1;e.nextBytes(d);if(g>0){d[0]&=((1<0){if(e>e)!=(this.s&this.DM)>>e){c[a++]=f|(this.s<<(this.DB-e))}while(b>=0){if(e<8){f=(this[b]&((1<>(e+=this.DB-8)}else{f=(this[b]>>(e-=8))&255;if(e<=0){e+=this.DB;--b}}if((f&128)!=0){f|=-256}if(a==0&&(this.s&128)!=(f&128)){++a}if(a>0||f!=this.s){c[a++]=f}}}return c}function bnEquals(b){return(this.compareTo(b)==0)}function bnMin(b){return(this.compareTo(b)<0)?this:b}function bnMax(b){return(this.compareTo(b)>0)?this:b}function bnpBitwiseTo(c,h,e){var d,g,b=Math.min(c.t,this.t);for(d=0;d>=16;b+=16}if((a&255)==0){a>>=8;b+=8}if((a&15)==0){a>>=4;b+=4}if((a&3)==0){a>>=2;b+=2}if((a&1)==0){++b}return b}function bnGetLowestSetBit(){for(var a=0;a=this.t){return(this.s!=0)}return((this[a]&(1<<(b%this.DB)))!=0)}function bnpChangeBit(c,b){var a=BigInteger.ONE.shiftLeft(c);this.bitwiseTo(a,b,a);return a}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(d,f){var e=0,g=0,b=Math.min(d.t,this.t);while(e>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g+=d.s}f.s=(g<0)?-1:0;if(g>0){f[e++]=g}else{if(g<-1){f[e++]=this.DV+g}}f.t=e;f.clamp()}function bnAdd(b){var c=nbi();this.addTo(b,c);return c}function bnSubtract(b){var c=nbi();this.subTo(b,c);return c}function bnMultiply(b){var c=nbi();this.multiplyTo(b,c);return c}function bnSquare(){var a=nbi();this.squareTo(a);return a}function bnDivide(b){var c=nbi();this.divRemTo(b,c,null);return c}function bnRemainder(b){var c=nbi();this.divRemTo(b,null,c);return c}function bnDivideAndRemainder(b){var d=nbi(),c=nbi();this.divRemTo(b,d,c);return new Array(d,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(b,a){if(b==0){return}while(this.t<=a){this[this.t++]=0}this[a]+=b;while(this[a]>=this.DV){this[a]-=this.DV;if(++a>=this.t){this[this.t++]=0}++this[a]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,c,b){a.multiplyTo(c,b)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp())}function bnpMultiplyLowerTo(b,f,e){var d=Math.min(this.t+b.t,f);e.s=0;e.t=d;while(d>0){e[--d]=0}var c;for(c=e.t-this.t;d=0){d[c]=0}for(c=Math.max(e-this.t,0);c2*this.m.t){return a.mod(this.m)}else{if(a.compareTo(this.m)<0){return a}else{var b=nbi();a.copyTo(b);this.reduce(b);return b}}}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1){a.t=this.m.t+1;a.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0){a.dAddOffset(1,this.m.t+1)}a.subTo(this.r2,a);while(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(q,f){var o=q.bitLength(),h,b=nbv(1),v;if(o<=0){return b}else{if(o<18){h=1}else{if(o<48){h=3}else{if(o<144){h=4}else{if(o<768){h=5}else{h=6}}}}}if(o<8){v=new Classic(f)}else{if(f.isEven()){v=new Barrett(f)}else{v=new Montgomery(f)}}var p=new Array(),d=3,s=h-1,a=(1<1){var A=nbi();v.sqrTo(p[1],A);while(d<=a){p[d]=nbi();v.mulTo(A,p[d-2],p[d]);d+=2}}var l=q.t-1,x,u=true,c=nbi(),y;o=nbits(q[l])-1;while(l>=0){if(o>=s){x=(q[l]>>(o-s))&a}else{x=(q[l]&((1<<(o+1))-1))<<(s-o);if(l>0){x|=q[l-1]>>(this.DB+o-s)}}d=h;while((x&1)==0){x>>=1;--d}if((o-=d)<0){o+=this.DB;--l}if(u){p[x].copyTo(b);u=false}else{while(d>1){v.sqrTo(b,c);v.sqrTo(c,b);d-=2}if(d>0){v.sqrTo(b,c)}else{y=b;b=c;c=y}v.mulTo(c,p[x],b)}while(l>=0&&(q[l]&(1<0){b.rShiftTo(f,b);h.rShiftTo(f,h)}while(b.signum()>0){if((d=b.getLowestSetBit())>0){b.rShiftTo(d,b)}if((d=h.getLowestSetBit())>0){h.rShiftTo(d,h)}if(b.compareTo(h)>=0){b.subTo(h,b);b.rShiftTo(1,b)}else{h.subTo(b,h);h.rShiftTo(1,h)}}if(f>0){h.lShiftTo(f,h)}return h}function bnpModInt(e){if(e<=0){return 0}var c=this.DV%e,b=(this.s<0)?e-1:0;if(this.t>0){if(c==0){b=this[0]%e}else{for(var a=this.t-1;a>=0;--a){b=(c*b+this[a])%e}}}return b}function bnModInverse(f){var j=f.isEven();if((this.isEven()&&j)||f.signum()==0){return BigInteger.ZERO}var i=f.clone(),h=this.clone();var g=nbv(1),e=nbv(0),l=nbv(0),k=nbv(1);while(i.signum()!=0){while(i.isEven()){i.rShiftTo(1,i);if(j){if(!g.isEven()||!e.isEven()){g.addTo(this,g);e.subTo(f,e)}g.rShiftTo(1,g)}else{if(!e.isEven()){e.subTo(f,e)}}e.rShiftTo(1,e)}while(h.isEven()){h.rShiftTo(1,h);if(j){if(!l.isEven()||!k.isEven()){l.addTo(this,l);k.subTo(f,k)}l.rShiftTo(1,l)}else{if(!k.isEven()){k.subTo(f,k)}}k.rShiftTo(1,k)}if(i.compareTo(h)>=0){i.subTo(h,i);if(j){g.subTo(l,g)}e.subTo(k,e)}else{h.subTo(i,h);if(j){l.subTo(g,l)}k.subTo(e,k)}}if(h.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(k.compareTo(f)>=0){return k.subtract(f)}if(k.signum()<0){k.addTo(f,k)}else{return k}if(k.signum()<0){return k.add(f)}else{return k}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(e){var d,b=this.abs();if(b.t==1&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d>1;if(f>lowprimes.length){f=lowprimes.length}var b=nbi();for(var e=0;e>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(window!==undefined&&(window.crypto!==undefined||window.msCrypto!==undefined)){var crypto=window.crypto||window.msCrypto;if(crypto.getRandomValues){var ua=new Uint8Array(32);crypto.getRandomValues(ua);for(t=0;t<32;++t){rng_pool[rng_pptr++]=ua[t]}}else{if(navigator.appName==\"Netscape\"&&navigator.appVersion<\"5\"){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr=0&&h>0){var f=e.charCodeAt(d--);if(f<128){g[--h]=f}else{if((f>127)&&(f<2048)){g[--h]=(f&63)|128;g[--h]=(f>>6)|192}else{g[--h]=(f&63)|128;g[--h]=((f>>6)&63)|128;g[--h]=(f>>12)|224}}}g[--h]=0;var b=new SecureRandom();var a=new Array();while(h>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}g[--h]=a[0]}g[--h]=2;g[--h]=0;return new BigInteger(g)}function oaep_mgf1_arr(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255])));d+=1}return b}function oaep_pad(q,a,f,l){var c=KJUR.crypto.MessageDigest;var o=KJUR.crypto.Util;var b=null;if(!f){f=\"sha1\"}if(typeof f===\"string\"){b=c.getCanonicalAlgName(f);l=c.getHashLength(b);f=function(i){return hextorstr(o.hashHex(rstrtohex(i),b))}}if(q.length+2*l+2>a){throw\"Message too long for RSA\"}var k=\"\",e;for(e=0;e0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{throw\"Invalid RSA public key\"}}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var e=this.doPublic(a);if(e==null){return null}var b=e.toString(16);if((b.length&1)==0){return b}else{return\"0\"+b}}function RSAEncryptOAEP(f,e,b){var a=oaep_pad(f,(this.n.bitLength()+7)>>3,e,b);if(a==null){return null}var g=this.doPublic(a);if(g==null){return null}var d=g.toString(16);if((d.length&1)==0){return d}else{return\"0\"+d}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;RSAKey.prototype.encryptOAEP=RSAEncryptOAEP;RSAKey.prototype.type=\"RSA\";\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction pkcs1unpad2(g,j){var a=g.toByteArray();var f=0;while(f=a.length){return null}}var e=\"\";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}function oaep_unpad(o,b,g,p){var e=KJUR.crypto.MessageDigest;var r=KJUR.crypto.Util;var c=null;if(!g){g=\"sha1\"}if(typeof g===\"string\"){c=e.getCanonicalAlgName(g);p=e.getHashLength(c);g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}}o=o.toByteArray();var h;for(h=0;h0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{throw\"Invalid RSA private key\"}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;this.isPublic=false;if(g==null){throw\"RSASetPrivateEx N == null\"}if(d==null){throw\"RSASetPrivateEx E == null\"}if(g.length==0){throw\"RSASetPrivateEx N.length == 0\"}if(d.length==0){throw\"RSASetPrivateEx E.length == 0\"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{throw\"Invalid RSA private key in RSASetPrivateEx\"}}function RSAGenerate(b,i){var a=new SecureRandom();var f=b>>1;this.e=parseInt(i,16);var c=new BigInteger(i,16);for(;;){for(;;){this.p=new BigInteger(b-f,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(f,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var h=this.p;this.p=this.q;this.q=h}var g=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var e=g.multiply(d);if(e.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(e);this.dmp1=this.d.mod(g);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=true}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}function RSADecryptOAEP(e,d,b){var f=parseBigInt(e,16);var a=this.doPrivate(f);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,d,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP;\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction ECFieldElementFp(b,a){this.x=a;this.q=b}function feFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.x.equals(a.x))}function feFpToBigInteger(){return this.x}function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))}function feFpAdd(a){return new ECFieldElementFp(this.q,this.x.add(a.toBigInteger()).mod(this.q))}function feFpSubtract(a){return new ECFieldElementFp(this.q,this.x.subtract(a.toBigInteger()).mod(this.q))}function feFpMultiply(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger()).mod(this.q))}function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))}function feFpDivide(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger().modInverse(this.q)).mod(this.q))}ECFieldElementFp.prototype.equals=feFpEquals;ECFieldElementFp.prototype.toBigInteger=feFpToBigInteger;ECFieldElementFp.prototype.negate=feFpNegate;ECFieldElementFp.prototype.add=feFpAdd;ECFieldElementFp.prototype.subtract=feFpSubtract;ECFieldElementFp.prototype.multiply=feFpMultiply;ECFieldElementFp.prototype.square=feFpSquare;ECFieldElementFp.prototype.divide=feFpDivide;function ECPointFp(c,a,d,b){this.curve=c;this.x=a;this.y=d;if(b==null){this.z=BigInteger.ONE}else{this.z=b}this.zinv=null}function pointFpGetX(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpGetY(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpEquals(a){if(a==this){return true}if(this.isInfinity()){return a.isInfinity()}if(a.isInfinity()){return this.isInfinity()}var c,b;c=a.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(a.z)).mod(this.curve.q);if(!c.equals(BigInteger.ZERO)){return false}b=a.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(a.z)).mod(this.curve.q);return b.equals(BigInteger.ZERO)}function pointFpIsInfinity(){if((this.x==null)&&(this.y==null)){return true}return this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)}function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)}function pointFpAdd(l){if(this.isInfinity()){return l}if(l.isInfinity()){return this}var p=l.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(l.z)).mod(this.curve.q);var o=l.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(l.z)).mod(this.curve.q);if(BigInteger.ZERO.equals(o)){if(BigInteger.ZERO.equals(p)){return this.twice()}return this.curve.getInfinity()}var j=new BigInteger(\"3\");var e=this.x.toBigInteger();var n=this.y.toBigInteger();var c=l.x.toBigInteger();var k=l.y.toBigInteger();var m=o.square();var i=m.multiply(o);var d=e.multiply(m);var g=p.square().multiply(this.z);var a=g.subtract(d.shiftLeft(1)).multiply(l.z).subtract(i).multiply(o).mod(this.curve.q);var h=d.multiply(j).multiply(p).subtract(n.multiply(i)).subtract(g.multiply(p)).multiply(l.z).add(p.multiply(i)).mod(this.curve.q);var f=i.multiply(this.z).multiply(l.z).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),f)}function pointFpTwice(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var g=new BigInteger(\"3\");var c=this.x.toBigInteger();var h=this.y.toBigInteger();var e=h.multiply(this.z);var j=e.multiply(h).mod(this.curve.q);var i=this.curve.a.toBigInteger();var k=c.square().multiply(g);if(!BigInteger.ZERO.equals(i)){k=k.add(this.z.square().multiply(i))}k=k.mod(this.curve.q);var b=k.square().subtract(c.shiftLeft(3).multiply(j)).shiftLeft(1).multiply(e).mod(this.curve.q);var f=k.multiply(g).multiply(c).subtract(j.shiftLeft(1)).shiftLeft(2).multiply(j).subtract(k.square().multiply(k)).mod(this.curve.q);var d=e.square().multiply(e).shiftLeft(3).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(b),this.curve.fromBigInteger(f),d)}function pointFpMultiply(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add(a?this:l)}}return d}function pointFpMultiplyTwo(c,a,b){var d;if(c.bitLength()>b.bitLength()){d=c.bitLength()-1}else{d=b.bitLength()-1}var f=this.curve.getInfinity();var e=this.add(a);while(d>=0){f=f.twice();if(c.testBit(d)){if(b.testBit(d)){f=f.add(e)}else{f=f.add(this)}}else{if(b.testBit(d)){f=f.add(a)}}--d}return f}ECPointFp.prototype.getX=pointFpGetX;ECPointFp.prototype.getY=pointFpGetY;ECPointFp.prototype.equals=pointFpEquals;ECPointFp.prototype.isInfinity=pointFpIsInfinity;ECPointFp.prototype.negate=pointFpNegate;ECPointFp.prototype.add=pointFpAdd;ECPointFp.prototype.twice=pointFpTwice;ECPointFp.prototype.multiply=pointFpMultiply;ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo;function ECCurveFp(e,d,c){this.q=e;this.a=this.fromBigInteger(d);this.b=this.fromBigInteger(c);this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b))}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)}function curveFpDecodePointHex(d){switch(parseInt(d.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var a=(d.length-2)/2;var c=d.substr(2,a);var b=d.substr(a+2,a);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(b,16)));default:return null}}ECCurveFp.prototype.getQ=curveFpGetQ;ECCurveFp.prototype.getA=curveFpGetA;ECCurveFp.prototype.getB=curveFpGetB;ECCurveFp.prototype.equals=curveFpEquals;ECCurveFp.prototype.getInfinity=curveFpGetInfinity;ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger;ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex;\n/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib\n */\nECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};ECPointFp.prototype.getEncoded=function(c){var d=function(h,f){var g=h.toByteArrayUnsigned();if(fg.length){g.unshift(0)}}return g};var a=this.getX().toBigInteger();var e=this.getY().toBigInteger();var b=d(a,32);if(c){if(e.isEven()){b.unshift(2)}else{b.unshift(3)}}else{b.unshift(4);b=b.concat(d(e,32))}return b};ECPointFp.decodeFrom=function(g,c){var f=c[0];var e=c.length-1;var d=c.slice(1,1+e/2);var b=c.slice(1+e/2,1+e);d.unshift(0);b.unshift(0);var a=new BigInteger(d);var h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.decodeFromHex=function(g,c){var f=c.substr(0,2);var e=c.length-2;var d=c.substr(2,e/2);var b=c.substr(2+e/2,e/2);var a=new BigInteger(d,16);var h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.prototype.add2D=function(c){if(this.isInfinity()){return c}if(c.isInfinity()){return this}if(this.x.equals(c.x)){if(this.y.equals(c.y)){return this.twice()}return this.curve.getInfinity()}var g=c.x.subtract(this.x);var e=c.y.subtract(this.y);var a=e.divide(g);var d=a.square().subtract(this.x).subtract(c.x);var f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var b=this.curve.fromBigInteger(BigInteger.valueOf(2));var e=this.curve.fromBigInteger(BigInteger.valueOf(3));var a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b));var c=a.square().subtract(this.x.multiply(b));var d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)};ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add2D(a?this:l)}}return d};ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger();var i=this.getY().toBigInteger();var f=this.curve.getA().toBigInteger();var c=this.curve.getB().toBigInteger();var h=this.curve.getQ();var e=i.multiply(i).mod(h);var g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)};ECPointFp.prototype.toString=function(){return\"(\"+this.getX().toBigInteger().toString()+\",\"+this.getY().toBigInteger().toString()+\")\"};ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity()){throw new Error(\"Point is at infinity.\")}var a=this.getX().toBigInteger();var b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"x coordinate out of bounds\")}if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"y coordinate out of bounds\")}if(!this.isOnCurve()){throw new Error(\"Point is not on the curve.\")}if(this.multiply(c).isInfinity()){throw new Error(\"Point is not a scalar multiple of G.\")}return true};\n/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval\n */\nvar jsonParse=(function(){var e=\"(?:-?\\\\b(?:0|[1-9][0-9]*)(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\\\b)\";var j='(?:[^\\\\0-\\\\x08\\\\x0a-\\\\x1f\"\\\\\\\\]|\\\\\\\\(?:[\"/\\\\\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:\"'+j+'*\")';var d=new RegExp(\"(?:false|true|null|[\\\\{\\\\}\\\\[\\\\]]|\"+e+\"|\"+i+\")\",\"g\");var k=new RegExp(\"\\\\\\\\(?:([^u])|u(.{4}))\",\"g\");var g={'\"':'\"',\"/\":\"/\",\"\\\\\":\"\\\\\",b:\"\\b\",f:\"\\f\",n:\"\\n\",r:\"\\r\",t:\"\\t\"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String(\"\");var a=\"\\\\\";var f={\"{\":Object,\"[\":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if(\"{\"===v){x={}}else{if(\"[\"===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({\"\":x},\"\")}return x}})();\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.asn1==\"undefined\"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b=\"0\"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!=\"-\"){if(f.length%2==1){f=\"0\"+f}else{if(!f.match(/^[0-7]/)){f=\"00\"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g=\"\";for(var d=0;d15){throw\"ASN.1 length too long to represent by 8x: n = \"+i.toString(16)}var f=128+g;return f.toString(16)+h}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return\"\"}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!=\"undefined\"){if(typeof c==\"string\"){this.setString(c)}else{if(typeof c.str!=\"undefined\"){this.setString(c.str)}else{if(typeof c.hex!=\"undefined\"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(f){utc=f.getTime()+(f.getTimezoneOffset()*60000);var e=new Date(utc);return e};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o==\"utc\"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,\"\");r=r+\".\"+k}}return r+\"Z\"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join(\"0\")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!=\"undefined\"){if(typeof b.array!=\"undefined\"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT=\"01\";this.hTLV=\"0101ff\"};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT=\"02\";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!=\"undefined\"){if(typeof a.bigint!=\"undefined\"){this.setByBigInteger(a.bigint)}else{if(typeof a[\"int\"]!=\"undefined\"){this.setByInteger(a[\"int\"])}else{if(typeof a==\"number\"){this.setByInteger(a)}else{if(typeof a.hex!=\"undefined\"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!==\"undefined\"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex=\"00\"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT=\"03\";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=(l*2))){break}if(d>=200){break}g.push(b);c=b;d++}return g};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){throw\"checking tag doesn't match: \"+e.substr(d,2)+\"!=\"+i}}return d}f=c.shift();b=g.getChildIdx(e,d);return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getTLVbyList=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyList(d,c,b);if(a===undefined){throw\"can't find nthList object\"}if(f!==undefined){if(d.substr(a,2)!=f){throw\"checking tag doesn't match: \"+d.substr(a,2)+\"!=\"+f}}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a===undefined){throw\"can't find nthList object\"}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join(\"0\")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+\".\"+j.join(\".\")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+\"..(total \"+A.length/2+\"bytes)..\"+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=\"\"}var x=c.ommit_long_octet;if(e.substr(l,2)==\"01\"){var h=j(e,l);if(h==\"00\"){return g+\"BOOLEAN FALSE\\n\"}else{return g+\"BOOLEAN TRUE\\n\"}}if(e.substr(l,2)==\"02\"){var h=j(e,l);return g+\"INTEGER \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"03\"){var h=j(e,l);return g+\"BITSTRING \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"04\"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+\"OCTETSTRING, encapsulates\\n\";k=k+y(h,c,0,g+\" \");return k}else{return g+\"OCTETSTRING \"+q(h,x)+\"\\n\"}}if(e.substr(l,2)==\"05\"){return g+\"NULL\\n\"}if(e.substr(l,2)==\"06\"){var m=j(e,l);var a=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(a);var b=a.replace(/\\./g,\" \");if(o!=\"\"){return g+\"ObjectIdentifier \"+o+\" (\"+b+\")\\n\"}else{return g+\"ObjectIdentifier (\"+b+\")\\n\"}}if(e.substr(l,2)==\"0c\"){return g+\"UTF8String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"13\"){return g+\"PrintableString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"14\"){return g+\"TeletexString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"16\"){return g+\"IA5String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"17\"){return g+\"UTCTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"18\"){return g+\"GeneralizedTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"30\"){if(e.substr(l,4)==\"3000\"){return g+\"SEQUENCE {}\\n\"}var k=g+\"SEQUENCE\\n\";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)==\"06\"&&e.substr(d[d.length-1],2)==\"04\"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u0){var m=new f({array:this.extensionsArray});var k=new c({explicit:true,tag:\"a3\",obj:m});this.asn1Array.push(k)}var n=new f({array:this.asn1Array});this.hTLV=n.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension=function(d){KJUR.asn1.x509.Extension.superclass.constructor.call(this);var f=null,a=KJUR,e=a.asn1,h=e.DERObjectIdentifier,i=e.DEROctetString,b=e.DERBitString,g=e.DERBoolean,c=e.DERSequence;this.getEncodedHex=function(){var m=new h({oid:this.oid});var l=new i({hex:this.getExtnValueHex()});var k=new Array();k.push(m);if(this.critical){k.push(new g())}k.push(l);var j=new c({array:k});return j.getEncodedHex()};this.critical=false;if(d!==undefined){if(d.critical!==undefined){this.critical=d.critical}}};YAHOO.lang.extend(KJUR.asn1.x509.Extension,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension.appendByNameToArray=function(e,c,b){var g=e.toLowerCase(),f=KJUR.asn1.x509;if(g==\"basicconstraints\"){var d=new f.BasicConstraints(c);b.push(d)}else{if(g==\"keyusage\"){var d=new f.KeyUsage(c);b.push(d)}else{if(g==\"crldistributionpoints\"){var d=new f.CRLDistributionPoints(c);b.push(d)}else{if(g==\"extkeyusage\"){var d=new f.ExtKeyUsage(c);b.push(d)}else{if(g==\"authoritykeyidentifier\"){var d=new f.AuthorityKeyIdentifier(c);b.push(d)}else{if(g==\"authorityinfoaccess\"){var d=new f.AuthorityInfoAccess(c);b.push(d)}else{if(g==\"subjectaltname\"){var d=new f.SubjectAltName(c);b.push(d)}else{if(g==\"issueraltname\"){var d=new f.IssuerAltName(c);b.push(d)}else{throw\"unsupported extension name: \"+e}}}}}}}}};KJUR.asn1.x509.KeyUsage=function(f){KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this,f);var a=X509.KEYUSAGE_NAME;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.15\";if(f!==undefined){if(f.bin!==undefined){this.asn1ExtnValue=new KJUR.asn1.DERBitString(f)}if(f.names!==undefined&&f.names.length!==undefined){var e=f.names;var d=\"000000000\";for(var c=0;c-1){e.push(new KJUR.asn1.DERInteger({\"int\":this.pathLen}))}var d=new KJUR.asn1.DERSequence({array:e});this.asn1ExtnValue=d;return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.19\";this.cA=false;this.pathLen=-1;if(c!==undefined){if(c.cA!==undefined){this.cA=c.cA}if(c.pathLen!==undefined){this.pathLen=c.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){this.asn1ExtnValue=new a.DERSequence({array:e})};this.setByOneURI=function(h){var e=new c.GeneralNames([{uri:h}]);var g=new c.DistributionPointName(e);var f=new c.DistributionPoint({dpobj:g});this.setByDPArray([f])};this.oid=\"2.5.29.31\";if(d!==undefined){if(d.array!==undefined){this.setByDPArray(d.array)}else{if(d.uri!==undefined){this.setByOneURI(d.uri)}}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLDistributionPoints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.ExtKeyUsage=function(c){KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,c);var b=KJUR,a=b.asn1;this.setPurposeArray=function(d){this.asn1ExtnValue=new a.DERSequence();for(var e=0;e0){var h=new b({array:this.aRevokedCert});this.asn1Array.push(h)}var i=new b({array:this.asn1Array});this.hTLV=i.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize=function(){this.asn1Version=null;this.asn1SignatureAlg=null;this.asn1Issuer=null;this.asn1ThisUpdate=null;this.asn1NextUpdate=null;this.aRevokedCert=new Array()};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertList,KJUR.asn1.ASN1Object);KJUR.asn1.x509.CRLEntry=function(e){KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);var d=null,c=null,b=KJUR,a=b.asn1;this.setCertSerial=function(f){this.sn=new a.DERInteger(f)};this.setRevocationDate=function(f){this.time=new a.x509.Time(f)};this.getEncodedHex=function(){var f=new a.DERSequence({array:[this.sn,this.time]});this.TLV=f.getEncodedHex();return this.TLV};if(e!==undefined){if(e.time!==undefined){this.setRevocationDate(e.time)}if(e.sn!==undefined){this.setCertSerial(e.sn)}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLEntry,KJUR.asn1.ASN1Object);KJUR.asn1.x509.X500Name=function(f){KJUR.asn1.x509.X500Name.superclass.constructor.call(this);this.asn1Array=new Array();var d=KJUR,c=d.asn1,e=c.x509,b=pemtohex;this.setByString=function(g){var k=g.split(\"/\");k.shift();var j=[];for(var l=0;l0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+\",\"+h).replace(/\\\\,/g,\",\");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)===\"\\\\\"){e=true}}b=b.map(function(a){return a.replace(\"/\",\"\\\\/\")});b.reverse();return\"/\"+b.join(\"/\")};KJUR.asn1.x509.RDN=function(a){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=new Array();this.addByString=function(b){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:b}))};this.addByMultiValuedString=function(d){var b=KJUR.asn1.x509.RDN.parseString(d);for(var c=0;c0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+\"+\"+k).replace(/\\\\\\+/g,\"+\");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)===\"\\\\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/\"$/)){var d=(e+\"+\"+k).replace(/^([^=]+)=\"(.*)\"$/,\"$1=$2\");b.push(d);l=false}else{b.push(e+\"+\"+k)}}else{b.push(k)}if(k.match(/^[^=]+=\"/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(d){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var f=null,e=null,a=\"utf8\",c=KJUR,b=c.asn1;this.setByString=function(h){var g=h.match(/^([^=]+)=(.+)$/);if(g){this.setByAttrTypeAndValueStr(g[1],g[2])}else{throw\"malformed attrTypeAndValueStr: \"+h}};this.setByAttrTypeAndValueStr=function(i,h){this.typeObj=KJUR.asn1.x509.OID.atype2obj(i);var g=a;if(i==\"C\"){g=\"prn\"}this.valueObj=this.getValueObj(g,h)};this.getValueObj=function(h,g){if(h==\"utf8\"){return new b.DERUTF8String({str:g})}if(h==\"prn\"){return new b.DERPrintableString({str:g})}if(h==\"tel\"){return new b.DERTeletexString({str:g})}if(h==\"ia5\"){return new b.DERIA5String({str:g})}throw\"unsupported directory string type: type=\"+h+\" value=\"+g};this.getEncodedHex=function(){var g=new b.DERSequence({array:[this.typeObj,this.valueObj]});this.TLV=g.getEncodedHex();return this.TLV};if(d!==undefined){if(d.str!==undefined){this.setByString(d.str)}}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw\"algId and/or subjPubKey not set\"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{\"int\":{bigint:q.n}},{\"int\":{\"int\":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:\"rsaEncryption\"});this.asn1SubjPKey=new b({hex:\"00\"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:\"ecPublicKey\",asn1params:r});this.asn1SubjPKey=new b({hex:\"00\"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{\"int\":{bigint:q.p}},{\"int\":{bigint:q.q}},{\"int\":{bigint:q.g}}]});this.asn1AlgId=new o({name:\"dsa\",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:\"00\"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type==\"utc\"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type==\"utc\"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type=\"utc\";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type=\"utc\"}if(f.str.match(/^[0-9]{14}Z$/)){this.type=\"gen\"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(d){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw\"algorithm not specified\"}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var e=[this.asn1Alg];if(this.asn1Params!==null){e.push(this.asn1Params)}var f=new a.DERSequence({array:e});this.hTLV=f.getEncodedHex();return this.hTLV};if(d!==undefined){if(d.name!==undefined){this.nameAlg=d.name}if(d.asn1params!==undefined){this.asn1Params=d.asn1params}if(d.paramempty!==undefined){this.paramEmpty=d.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){var c=this.nameAlg.toLowerCase();if(c.substr(-7,7)!==\"withdsa\"&&c.substr(-9,9)!==\"withecdsa\"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:\"81\",dns:\"82\",dn:\"a4\",uri:\"86\",ip:\"87\"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type=\"rfc822\";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type=\"dns\";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type=\"uri\";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({str:p.dn})}if(p.ldapdn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certissuer param not cert\"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certsubj param not cert\"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type=\"ip\";this.explicit=false;var q=p.ip;var s;var n=\"malformed IP address\";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex(\"[\"+q.split(\".\").join(\",\")+\"]\");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw\"unsupported type in params=\"+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){r=new b({obj:this.dUnsignedAttrs,tag:\"a1\",explicit:false})}var q=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,o,this.dSigAlg,this.dSig,];if(r!=null){q.push(r)}var p=new h.DERSequence({array:q});this.hTLV=p.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.SignerInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.EncapsulatedContentInfo=function(g){var c=KJUR,b=c.asn1,e=b.DERTaggedObject,a=b.DERSequence,h=b.DERObjectIdentifier,d=b.DEROctetString,f=b.cms;f.EncapsulatedContentInfo.superclass.constructor.call(this);this.dEContentType=new h({name:\"data\"});this.dEContent=null;this.isDetached=false;this.eContentValueHex=null;this.setContentType=function(i){if(i.match(/^[0-2][.][0-9.]+$/)){this.dEContentType=new h({oid:i})}else{this.dEContentType=new h({name:i})}};this.setContentValue=function(i){if(i!==undefined){if(typeof i.hex==\"string\"){this.eContentValueHex=i.hex}else{if(typeof i.str==\"string\"){this.eContentValueHex=utf8tohex(i.str)}}}};this.setContentValueHex=function(i){this.eContentValueHex=i};this.setContentValueStr=function(i){this.eContentValueHex=utf8tohex(i)};this.getEncodedHex=function(){if(typeof this.eContentValueHex!=\"string\"){throw\"eContentValue not yet set\"}var k=new d({hex:this.eContentValueHex});this.dEContent=new e({obj:k,tag:\"a0\",explicit:true});var i=[this.dEContentType];if(!this.isDetached){i.push(this.dEContent)}var j=new a({array:i});this.hTLV=j.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.EncapsulatedContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.ContentInfo=function(f){var c=KJUR,b=c.asn1,d=b.DERTaggedObject,a=b.DERSequence,e=b.x509;KJUR.asn1.cms.ContentInfo.superclass.constructor.call(this);this.dContentType=null;this.dContent=null;this.setContentType=function(g){if(typeof g==\"string\"){this.dContentType=e.OID.name2obj(g)}};this.getEncodedHex=function(){var h=new d({obj:this.dContent,tag:\"a0\",explicit:true});var g=new a({array:[this.dContentType,h]});this.hTLV=g.getEncodedHex();return this.hTLV};if(f!==undefined){if(f.type){this.setContentType(f.type)}if(f.obj&&f.obj instanceof b.ASN1Object){this.dContent=f.obj}}};YAHOO.lang.extend(KJUR.asn1.cms.ContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.SignedData=function(e){var a=KJUR,h=a.asn1,j=h.ASN1Object,g=h.DERInteger,m=h.DERSet,f=h.DERSequence,b=h.DERTaggedObject,l=h.cms,i=l.EncapsulatedContentInfo,d=l.SignerInfo,n=l.ContentInfo,c=h.x509,k=c.AlgorithmIdentifier;KJUR.asn1.cms.SignedData.superclass.constructor.call(this);this.dCMSVersion=new g({\"int\":1});this.dDigestAlgs=null;this.digestAlgNameList=[];this.dEncapContentInfo=new i();this.dCerts=null;this.certificateList=[];this.crlList=[];this.signerInfoList=[new d()];this.addCertificatesByPEM=function(p){var q=pemtohex(p);var r=new j();r.hTLV=q;this.certificateList.push(r)};this.getEncodedHex=function(){if(typeof this.hTLV==\"string\"){return this.hTLV}if(this.dDigestAlgs==null){var u=[];for(var t=0;t0){var v=new m({array:this.certificateList});this.dCerts=new b({obj:v,tag:\"a0\",explicit:false})}}if(this.dCerts!=null){p.push(this.dCerts)}var r=new m({array:this.signerInfoList});p.push(r);var q=new f({array:p});this.hTLV=q.getEncodedHex();return this.hTLV};this.getContentInfo=function(){this.getEncodedHex();var o=new n({type:\"signed-data\",obj:this});return o};this.getContentInfoEncodedHex=function(){var o=this.getContentInfo();var p=o.getEncodedHex();return p};this.getPEM=function(){return hextopem(this.getContentInfoEncodedHex(),\"CMS\")}};YAHOO.lang.extend(KJUR.asn1.cms.SignedData,KJUR.asn1.ASN1Object);KJUR.asn1.cms.CMSUtil=new function(){};KJUR.asn1.cms.CMSUtil.newSignedData=function(d){var b=KJUR,j=b.asn1,q=j.cms,f=q.SignerInfo,n=q.SignedData,o=q.SigningTime,a=q.SigningCertificate,p=q.SigningCertificateV2,c=j.cades,e=c.SignaturePolicyIdentifier;var m=new n();m.dEncapContentInfo.setContentValue(d.content);if(typeof d.certs==\"object\"){for(var h=0;h0){var s=new f({array:this.extensionsArray});var r=new m({array:[s]});var q=new f({array:[new k({oid:\"1.2.840.113549.1.9.14\"}),r]});var p=new c({explicit:true,tag:\"a0\",obj:q});this.asn1Array.push(p)}else{var p=new c({explicit:false,tag:\"a0\",obj:new j()});this.asn1Array.push(p)}var t=new f({array:this.asn1Array});this.hTLV=t.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CSRUtil=new function(){};KJUR.asn1.csr.CSRUtil.newCSRPEM=function(h){var c=KEYUTIL,b=KJUR.asn1.csr;if(h.subject===undefined){throw\"parameter subject undefined\"}if(h.sbjpubkey===undefined){throw\"parameter sbjpubkey undefined\"}if(h.sigalg===undefined){throw\"parameter sigalg undefined\"}if(h.sbjprvkey===undefined){throw\"parameter sbjpubkey undefined\"}var d=new b.CertificationRequestInfo();d.setSubjectByParam(h.subject);d.setSubjectPublicKeyByGetKey(h.sbjpubkey);if(h.ext!==undefined&&h.ext.length!==undefined){for(var e=0;ef.length){f=c[d]}}e=e.replace(f,\"::\");return e.slice(1,-1)}function hextoip(b){var d=\"malformed hex value\";if(!b.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){throw d}if(b.length==8){var c;try{c=parseInt(b.substr(0,2),16)+\".\"+parseInt(b.substr(2,2),16)+\".\"+parseInt(b.substr(4,2),16)+\".\"+parseInt(b.substr(6,2),16);return c}catch(a){throw d}}else{if(b.length==32){return hextoipv6(b)}else{return b}}}function iptohex(f){var j=\"malformed IP address\";f=f.toLowerCase(f);if(f.match(/^[0-9.]+$/)){var b=f.split(\".\");if(b.length!==4){throw j}var g=\"\";try{for(var e=0;e<4;e++){var h=parseInt(b[e]);g+=(\"0\"+h.toString(16)).slice(-2)}return g}catch(c){throw j}}else{if(f.match(/^[0-9a-f:]+$/)&&f.indexOf(\":\")!==-1){return ipv6tohex(f)}else{throw j}}}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b=\"\";for(var c=0;c\"7\"){return\"00\"+a}return a}function intarystrtohex(b){b=b.replace(/^\\s*\\[\\s*/,\"\");b=b.replace(/\\s*\\]\\s*$/,\"\");b=b.replace(/\\s*/g,\"\");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;bd){throw\"key is too short for SigAlg: keylen=\"+j+\",\"+a}var b=\"0001\";var k=\"00\"+c;var g=\"\";var l=d-b.length-k.length;for(var f=0;f=0;--p){q=q.twice2D();q.z=BigInteger.ONE;if(o.testBit(p)){if(n.testBit(p)){q=q.add2D(t)}else{q=q.add2D(s)}}else{if(n.testBit(p)){q=q.add2D(r)}}}return q}this.getBigRandom=function(i){return new BigInteger(i.bitLength(),a).mod(i.subtract(BigInteger.ONE)).add(BigInteger.ONE)};this.setNamedCurve=function(i){this.ecparams=KJUR.crypto.ECParameterDB.getByName(i);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=i};this.setPrivateKeyHex=function(i){this.isPrivate=true;this.prvKeyHex=i};this.setPublicKeyHex=function(i){this.isPublic=true;this.pubKeyHex=i};this.getPublicKeyXYHex=function(){var k=this.pubKeyHex;if(k.substr(0,2)!==\"04\"){throw\"this method supports uncompressed format(04) only\"}var j=this.ecparams.keylen/4;if(k.length!==2+j*2){throw\"malformed public key hex length\"}var i={};i.x=k.substr(2,j);i.y=k.substr(2+j);return i};this.getShortNISTPCurveName=function(){var i=this.curveName;if(i===\"secp256r1\"||i===\"NIST P-256\"||i===\"P-256\"||i===\"prime256v1\"){return\"P-256\"}if(i===\"secp384r1\"||i===\"NIST P-384\"||i===\"P-384\"){return\"P-384\"}return null};this.generateKeyPairHex=function(){var k=this.ecparams.n;var n=this.getBigRandom(k);var l=this.ecparams.G.multiply(n);var q=l.getX().toBigInteger();var o=l.getY().toBigInteger();var i=this.ecparams.keylen/4;var m=(\"0000000000\"+n.toString(16)).slice(-i);var r=(\"0000000000\"+q.toString(16)).slice(-i);var p=(\"0000000000\"+o.toString(16)).slice(-i);var j=\"04\"+r+p;this.setPrivateKeyHex(m);this.setPublicKeyHex(j);return{ecprvhex:m,ecpubhex:j}};this.signWithMessageHash=function(i){return this.signHex(i,this.prvKeyHex)};this.signHex=function(o,j){var t=new BigInteger(j,16);var l=this.ecparams.n;var q=new BigInteger(o,16);do{var m=this.getBigRandom(l);var u=this.ecparams.G;var p=u.multiply(m);var i=p.getX().toBigInteger().mod(l)}while(i.compareTo(BigInteger.ZERO)<=0);var v=m.modInverse(l).multiply(q.add(t.multiply(i))).mod(l);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(i,v)};this.sign=function(m,u){var q=u;var j=this.ecparams.n;var p=BigInteger.fromByteArrayUnsigned(m);do{var l=this.getBigRandom(j);var t=this.ecparams.G;var o=t.multiply(l);var i=o.getX().toBigInteger().mod(j)}while(i.compareTo(BigInteger.ZERO)<=0);var v=l.modInverse(j).multiply(p.add(q.multiply(i))).mod(j);return this.serializeSig(i,v)};this.verifyWithMessageHash=function(j,i){return this.verifyHex(j,i,this.pubKeyHex)};this.verifyHex=function(m,i,p){var l,j;var o=KJUR.crypto.ECDSA.parseSigHex(i);l=o.r;j=o.s;var k;k=ECPointFp.decodeFromHex(this.ecparams.curve,p);var n=new BigInteger(m,16);return this.verifyRaw(n,l,j,k)};this.verify=function(o,p,j){var l,i;if(Bitcoin.Util.isArray(p)){var n=this.parseSig(p);l=n.r;i=n.s}else{if(\"object\"===typeof p&&p.r&&p.s){l=p.r;i=p.s}else{throw\"Invalid value for signature\"}}var k;if(j instanceof ECPointFp){k=j}else{if(Bitcoin.Util.isArray(j)){k=ECPointFp.decodeFrom(this.ecparams.curve,j)}else{throw\"Invalid format for pubkey value, must be byte array or ECPointFp\"}}var m=BigInteger.fromByteArrayUnsigned(o);return this.verifyRaw(m,l,i,k)};this.verifyRaw=function(o,i,w,m){var l=this.ecparams.n;var u=this.ecparams.G;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(l)>=0){return false}if(w.compareTo(BigInteger.ONE)<0||w.compareTo(l)>=0){return false}var p=w.modInverse(l);var k=o.multiply(p).mod(l);var j=i.multiply(p).mod(l);var q=u.multiply(k).add(m.multiply(j));var t=q.getX().toBigInteger().mod(l);return t.equals(i)};this.serializeSig=function(k,j){var l=k.toByteArraySigned();var i=j.toByteArraySigned();var m=[];m.push(2);m.push(l.length);m=m.concat(l);m.push(2);m.push(i.length);m=m.concat(i);m.unshift(m.length);m.unshift(48);return m};this.parseSig=function(n){var m;if(n[0]!=48){throw new Error(\"Signature not a valid DERSequence\")}m=2;if(n[m]!=2){throw new Error(\"First element in signature must be a DERInteger\")}var l=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];if(n[m]!=2){throw new Error(\"Second element in signature must be a DERInteger\")}var i=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];var k=BigInteger.fromByteArrayUnsigned(l);var j=BigInteger.fromByteArrayUnsigned(i);return{r:k,s:j}};this.parseSigCompact=function(m){if(m.length!==65){throw\"Signature has the wrong length\"}var j=m[0]-27;if(j<0||j>7){throw\"Invalid signature type\"}var o=this.ecparams.n;var l=BigInteger.fromByteArrayUnsigned(m.slice(1,33)).mod(o);var k=BigInteger.fromByteArrayUnsigned(m.slice(33,65)).mod(o);return{r:l,s:k,i:j}};this.readPKCS5PrvKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var i,k,o;try{i=p(l,0,[2,0],\"06\");k=p(l,0,[1],\"04\");try{o=p(l,0,[3,0],\"03\").substr(2)}catch(j){}}catch(j){throw\"malformed PKCS#1/5 plain ECC private key\"}this.curveName=m(i);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o);this.setPrivateKeyHex(k);this.isPublic=false};this.readPKCS8PrvKeyHex=function(l){var q=ASN1HEX;var i=KJUR.crypto.ECDSA.getName;var n=q.getVbyList;if(q.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var j,p,m,k;try{j=n(l,0,[1,0],\"06\");p=n(l,0,[1,1],\"06\");m=n(l,0,[2,0,1],\"04\");try{k=n(l,0,[2,0,2,0],\"03\").substr(2)}catch(o){}}catch(o){throw\"malformed PKCS#8 plain ECC private key\"}this.curveName=i(p);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(k);this.setPrivateKeyHex(m);this.isPublic=false};this.readPKCS8PubKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var k,i,o;try{k=p(l,0,[0,0],\"06\");i=p(l,0,[0,1],\"06\");o=p(l,0,[1],\"03\").substr(2)}catch(j){throw\"malformed PKCS#8 ECC public key\"}this.curveName=m(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o)};this.readCertPubKeyHex=function(k,p){if(p!==5){p=6}var m=ASN1HEX;var l=KJUR.crypto.ECDSA.getName;var o=m.getVbyList;if(m.isASN1HEX(k)===false){throw\"not ASN.1 hex string\"}var i,n;try{i=o(k,0,[0,p,0,1],\"06\");n=o(k,0,[0,p,1],\"03\").substr(2)}catch(j){throw\"malformed X.509 certificate ECC public key\"}this.curveName=l(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(n)};if(h!==undefined){if(h.curve!==undefined){this.curveName=h.curve}}if(this.curveName===undefined){this.curveName=e}this.setNamedCurve(this.curveName);if(h!==undefined){if(h.prv!==undefined){this.setPrivateKeyHex(h.prv)}if(h.pub!==undefined){this.setPublicKeyHex(h.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX;var i=j.getChildIdx;var g=j.getV;if(f.substr(0,2)!=\"30\"){throw\"signature is not a ASN.1 sequence\"}var h=i(f,0);if(h.length!=2){throw\"number of signature ASN.1 sequence elements seem wrong\"}var e=h[0];var d=h[1];if(f.substr(e,2)!=\"02\"){throw\"1st item of sequene of signature is not ASN.1 integer\"}if(f.substr(d,2)!=\"02\"){throw\"2nd item of sequene of signature is not ASN.1 integer\"}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(c){var d=KJUR.crypto.ECDSA.parseSigHexInHexRS(c);var b=d.r;var a=d.s;if(b.substr(0,2)==\"00\"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)==\"00\"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b=\"00\"+b}if((a.length%32)==30){a=\"00\"+a}if(b.length%32!=0){throw\"unknown ECDSA sig r length error\"}if(a.length%32!=0){throw\"unknown ECDSA sig s length error\"}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if((((a.length/2)*8)%(16*8))!=0){throw\"unknown ECDSA concatinated r-s sig length error\"}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.getEncodedHex()};KJUR.crypto.ECDSA.getName=function(a){if(a===\"2a8648ce3d030107\"){return\"secp256r1\"}if(a===\"2b8104000a\"){return\"secp256k1\"}if(a===\"2b81040022\"){return\"secp384r1\"}if(\"|secp256r1|NIST P-256|P-256|prime256v1|\".indexOf(a)!==-1){return\"secp256r1\"}if(\"|secp256k1|\".indexOf(a)!==-1){return\"secp256k1\"}if(\"|secp384r1|NIST P-384|P-384|\".indexOf(a)!==-1){return\"secp384r1\"}return null};\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.crypto==\"undefined\"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!=\"undefined\"){d=c[e]}if(typeof b[d]!=\"undefined\"){return b[d]}throw\"unregistered EC curve name: \"+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex(\"04\"+f+k);b[A][\"name\"]=A;b[A][\"keylen\"]=l;b[A][\"curve\"]=r;b[A][\"G\"]=q;b[A][\"n\"]=t;b[A][\"h\"]=w;b[A][\"oid\"]=d;b[A][\"info\"]=x;for(var v=0;v1){g=new BigInteger(i,16)}else{g=null}h=new BigInteger(j,16);this.setPrivate(c,a,e,g,h)};this.setPublic=function(c,b,a,d){this.isPublic=true;this.p=c;this.q=b;this.g=a;this.y=d;this.x=null};this.setPublicHex=function(f,e,d,g){var b,a,h,c;b=new BigInteger(f,16);a=new BigInteger(e,16);h=new BigInteger(d,16);c=new BigInteger(g,16);this.setPublic(b,a,h,c)};this.signWithMessageHash=function(d){var c=this.p;var b=this.q;var f=this.g;var i=this.y;var j=this.x;var e=KJUR.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),b.subtract(BigInteger.ONE));var l=d.substr(0,b.bitLength()/4);var h=new BigInteger(l,16);var a=(f.modPow(e,c)).mod(b);var n=(e.modInverse(b).multiply(h.add(j.multiply(a)))).mod(b);var m=KJUR.asn1.ASN1Util.jsonToASN1HEX({seq:[{\"int\":{bigint:a}},{\"int\":{bigint:n}}]});return m};this.verifyWithMessageHash=function(h,f){var d=this.p;var b=this.q;var j=this.g;var l=this.y;var i=this.parseASN1Signature(f);var a=i[0];var t=i[1];var o=h.substr(0,b.bitLength()/4);var k=new BigInteger(o,16);if(BigInteger.ZERO.compareTo(a)>0||a.compareTo(b)>0){throw\"invalid DSA signature\"}if(BigInteger.ZERO.compareTo(t)>=0||t.compareTo(b)>0){throw\"invalid DSA signature\"}var m=t.modInverse(b);var e=k.multiply(m).mod(b);var c=a.multiply(m).mod(b);var n=j.modPow(e,d).multiply(l.modPow(c,d)).mod(d).mod(b);return n.compareTo(a)==0};this.parseASN1Signature=function(a){try{var d=new BigInteger(ASN1HEX.getVbyList(a,0,[0],\"02\"),16);var c=new BigInteger(ASN1HEX.getVbyList(a,0,[1],\"02\"),16);return[d,c]}catch(b){throw\"malformed ASN.1 DSA signature\"}};this.readPKCS5PrvKeyHex=function(c){var b,a,f,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[1],\"02\");a=d(c,0,[2],\"02\");f=d(c,0,[3],\"02\");g=d(c,0,[4],\"02\");i=d(c,0,[5],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed PKCS#1/5 plain DSA private key\"}this.setPrivateHex(b,a,f,g,i)};this.readPKCS8PrvKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[1,1,0],\"02\");c=i(d,0,[1,1,1],\"02\");b=i(d,0,[1,1,2],\"02\");g=i(d,0,[2,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 plain DSA private key\"}this.setPrivateHex(f,c,b,null,g)};this.readPKCS8PubKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[0,1,0],\"02\");c=i(d,0,[0,1,1],\"02\");b=i(d,0,[0,1,2],\"02\");g=i(d,0,[1,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 DSA public key\"}this.setPublicHex(f,c,b,g)};this.readCertPubKeyHex=function(c,f){if(f!==5){f=6}var b,a,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[0,f,0,1,0],\"02\");a=d(c,0,[0,f,0,1,1],\"02\");g=d(c,0,[0,f,0,1,2],\"02\");i=d(c,0,[0,f,1,0],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed X.509 certificate DSA public key\"}this.setPublicHex(b,a,g,i)}};\nvar KEYUTIL=function(){var d=function(p,r,q){return k(CryptoJS.AES,p,r,q)};var e=function(p,r,q){return k(CryptoJS.TripleDES,p,r,q)};var a=function(p,r,q){return k(CryptoJS.DES,p,r,q)};var k=function(s,x,u,q){var r=CryptoJS.enc.Hex.parse(x);var w=CryptoJS.enc.Hex.parse(u);var p=CryptoJS.enc.Hex.parse(q);var t={};t.key=w;t.iv=p;t.ciphertext=r;var v=s.decrypt(t,w,{iv:p});return CryptoJS.enc.Hex.stringify(v)};var l=function(p,r,q){return g(CryptoJS.AES,p,r,q)};var o=function(p,r,q){return g(CryptoJS.TripleDES,p,r,q)};var f=function(p,r,q){return g(CryptoJS.DES,p,r,q)};var g=function(t,y,v,q){var s=CryptoJS.enc.Hex.parse(y);var x=CryptoJS.enc.Hex.parse(v);var p=CryptoJS.enc.Hex.parse(q);var w=t.encrypt(s,x,{iv:p});var r=CryptoJS.enc.Hex.parse(w.toString());var u=CryptoJS.enc.Base64.stringify(r);return u};var i={\"AES-256-CBC\":{proc:d,eproc:l,keylen:32,ivlen:16},\"AES-192-CBC\":{proc:d,eproc:l,keylen:24,ivlen:16},\"AES-128-CBC\":{proc:d,eproc:l,keylen:16,ivlen:16},\"DES-EDE3-CBC\":{proc:e,eproc:o,keylen:24,ivlen:8},\"DES-CBC\":{proc:a,eproc:f,keylen:8,ivlen:8}};var c=function(p){return i[p][\"proc\"]};var m=function(p){var r=CryptoJS.lib.WordArray.random(p);var q=CryptoJS.enc.Hex.stringify(r);return q};var n=function(v){var w={};var q=v.match(new RegExp(\"DEK-Info: ([^,]+),([0-9A-Fa-f]+)\",\"m\"));if(q){w.cipher=q[1];w.ivsalt=q[2]}var p=v.match(new RegExp(\"-----BEGIN ([A-Z]+) PRIVATE KEY-----\"));if(p){w.type=p[1]}var u=-1;var x=0;if(v.indexOf(\"\\r\\n\\r\\n\")!=-1){u=v.indexOf(\"\\r\\n\\r\\n\");x=2}if(v.indexOf(\"\\n\\n\")!=-1){u=v.indexOf(\"\\n\\n\");x=1}var t=v.indexOf(\"-----END\");if(u!=-1&&t!=-1){var r=v.substring(u+x*2,t-x);r=r.replace(/\\s+/g,\"\");w.data=r}return w};var j=function(q,y,p){var v=p.substring(0,16);var t=CryptoJS.enc.Hex.parse(v);var r=CryptoJS.enc.Utf8.parse(y);var u=i[q][\"keylen\"]+i[q][\"ivlen\"];var x=\"\";var w=null;for(;;){var s=CryptoJS.algo.MD5.create();if(w!=null){s.update(w)}s.update(r);s.update(t);w=s.finalize();x=x+CryptoJS.enc.Hex.stringify(w);if(x.length>=u*2){break}}var z={};z.keyhex=x.substr(0,i[q][\"keylen\"]*2);z.ivhex=x.substr(i[q][\"keylen\"]*2,i[q][\"ivlen\"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v][\"proc\"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s][\"eproc\"];var t=r(p,q,u);return t};return{version:\"1.0.0\",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p=\"\";if(typeof t==\"undefined\"||t==null){t=\"AES-256-CBC\"}if(typeof i[t]==\"undefined\"){throw\"KEYUTIL unsupported algorithm: \"+t}if(typeof r==\"undefined\"||r==null){var v=i[t][\"ivlen\"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,\"$1\\r\\n\");var p=\"-----BEGIN \"+x+\" PRIVATE KEY-----\\r\\n\";p+=\"Proc-Type: 4,ENCRYPTED\\r\\n\";p+=\"DEK-Info: \"+t+\",\"+r+\"\\r\\n\";p+=\"\\r\\n\";p+=q;p+=\"\\r\\n-----END \"+x+\" PRIVATE KEY-----\\r\\n\";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw\"malformed format: SEQUENCE(0).items != 2: \"+r.length}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0).items != 2: \"+A.length}if(w(y,A[0])!=\"2a864886f70d01050d\"){throw\"this only supports pkcs5PBES2\"}var p=z(y,A[1]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0.1).items != 2: \"+p.length}var q=z(y,p[1]);if(q.length!=2){throw\"malformed format: SEQUENCE(0.0.1.1).items != 2: \"+q.length}if(w(y,q[0])!=\"2a864886f70d0307\"){throw\"this only supports TripleDES\"}t.encryptionSchemeAlg=\"TripleDES\";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw\"malformed format: SEQUENCE(0.0.1.0).items != 2: \"+s.length}if(w(y,s[0])!=\"2a864886f70d01050c\"){throw\"this only supports pkcs5PBKDF2\"}var x=z(y,s[1]);if(x.length<2){throw\"malformed format: SEQUENCE(0.0.1.0.1).items < 2: \"+x.length}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw\"malformed format pbkdf2Iter: \"+u}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,\"ENCRYPTED PRIVATE KEY\");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!=\"30\"){throw\"malformed plain PKCS8 private key(code:001)\"}var r=u(s,0);if(r.length!=3){throw\"malformed plain PKCS8 private key(code:002)\"}if(s.substr(r[1],2)!=\"30\"){throw\"malformed PKCS8 private key(code:003)\"}var p=u(s,r[1]);if(p.length!=2){throw\"malformed PKCS8 private key(code:004)\"}if(s.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 private key(code:005)\"}q.algoid=t(s,p[0]);if(s.substr(p[1],2)==\"06\"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!=\"04\"){throw\"malformed PKCS8 private key(code:006)\"}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,\"PRIVATE KEY\");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid==\"2a864886f70d010101\"){r=new RSAKey()}else{if(q.algoid==\"2a8648ce380401\"){r=new KJUR.crypto.DSA()}else{if(q.algoid==\"2a8648ce3d0201\"){r=new KJUR.crypto.ECDSA()}else{throw\"unsupported private key algorithm\"}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],\"06\");if(r===\"2a864886f70d010101\"){p=new RSAKey()}else{if(r===\"2a8648ce380401\"){p=new KJUR.crypto.DSA()}else{if(r===\"2a8648ce3d0201\"){p=new KJUR.crypto.ECDSA()}else{throw\"unsupported PKCS#8 public key hex\"}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!=\"30\"){throw\"malformed RSA key(code:001)\"}var q=t(r,0);if(q.length!=2){throw\"malformed RSA key(code:002)\"}if(r.substr(q[0],2)!=\"02\"){throw\"malformed RSA key(code:003)\"}p.n=s(r,q[0]);if(r.substr(q[1],2)!=\"02\"){throw\"malformed RSA key(code:004)\"}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw\"outer DERSequence shall have 2 elements: \"+r.length}var w=r[0];if(t.substr(w,2)!=\"30\"){throw\"malformed PKCS8 public key(code:001)\"}var p=u(t,w);if(p.length!=2){throw\"malformed PKCS8 public key(code:002)\"}if(t.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 public key(code:003)\"}q.algoid=s(t,p[0]);if(t.substr(p[1],2)==\"06\"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)==\"30\"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],\"02\");q.algparam.q=v.getVbyList(t,p[1],[1],\"02\");q.algparam.g=v.getVbyList(t,p[1],[2],\"02\")}}if(t.substr(r[1],2)!=\"03\"){throw\"malformed PKCS8 public key(code:004)\"}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!=\"undefined\"&&l instanceof w){return l}if(typeof i!=\"undefined\"&&l instanceof i){return l}if(typeof C!=\"undefined\"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;j.setPublicKeyHex(u);return j}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;var b=(\"0000000000\"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n===\"pkcs5prv\"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)===\"04\"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw\"unsupported PKCS#1/5 hexadecimal key\"}}}return P}if(n===\"pkcs8prv\"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n===\"pkcs8pub\"){return F._getKeyFromPublicPKCS8Hex(l)}if(n===\"x509pub\"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf(\"-END CERTIFICATE-\",0)!=-1||l.indexOf(\"-END X509 CERTIFICATE-\",0)!=-1||l.indexOf(\"-END TRUSTED CERTIFICATE-\",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf(\"-END PUBLIC KEY-\")!=-1){var O=pemtohex(l,\"PUBLIC KEY\");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var m=M(l,\"RSA PRIVATE KEY\");return F.getKey(m,null,\"pkcs5prv\")}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var I=M(l,\"DSA PRIVATE KEY\");var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END PRIVATE KEY-\")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf(\"-END EC PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],\"04\");var f=d(I,0,[2,0],\"06\");var A=d(I,0,[3,0],\"03\").substr(2);var e=\"\";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw\"undefined OID(hex) in KJUR.crypto.OID: \"+f}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END ENCRYPTED PRIVATE KEY-\")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw\"not supported argument\"};KEYUTIL.generateKeypair=function(a,c){if(a==\"RSA\"){var b=c;var h=new RSAKey();h.generate(b,\"10001\");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a==\"EC\"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw\"unknown algorithm: \"+a}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.n}},{\"int\":s.e},{\"int\":{bigint:s.d}},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.dmp1}},{\"int\":{bigint:s.dmq1}},{\"int\":{bigint:s.coeff}}]});return G}function B(G){var s=l({seq:[{\"int\":1},{octstr:{hex:G.prvKeyHex}},{tag:[\"a0\",true,{oid:{name:G.curveName}}]},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+G.pubKeyHex}}]}]});return s}function x(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.g}},{\"int\":{bigint:s.y}},{\"int\":{bigint:s.x}}]});return G}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D==\"PKCS8PUB\")){var E=new C(b);var w=E.getEncodedHex();return hextopem(w,\"PUBLIC KEY\")}if(D==\"PKCS1PRV\"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();return hextopem(w,\"RSA PRIVATE KEY\")}if(D==\"PKCS1PRV\"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.getEncodedHex();var h=B(b);var t=h.getEncodedHex();var p=\"\";p+=hextopem(v,\"EC PARAMETERS\");p+=hextopem(t,\"EC PRIVATE KEY\");return p}if(D==\"PKCS1PRV\"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();return hextopem(w,\"DSA PRIVATE KEY\")}if(D==\"PKCS5PRV\"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"RSA\",w,y,m,j)}if(D==\"PKCS5PRV\"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"EC\",w,y,m,j)}if(D==\"PKCS5PRV\"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"DSA\",w,y,m,j)}var o=function(G,s){var I=c(G,s);var H=new l({seq:[{seq:[{oid:{name:\"pkcs5PBES2\"}},{seq:[{seq:[{oid:{name:\"pkcs5PBKDF2\"}},{seq:[{octstr:{hex:I.pbkdf2Salt}},{\"int\":I.pbkdf2Iter}]}]},{seq:[{oid:{name:\"des-EDE3-CBC\"}},{octstr:{hex:I.encryptionSchemeIV}}]}]}]},{octstr:{hex:I.ciphertext}}]});return H.getEncodedHex()};var c=function(N,O){var H=100;var M=CryptoJS.lib.WordArray.random(8);var L=\"DES-EDE3-CBC\";var s=CryptoJS.lib.WordArray.random(8);var I=CryptoJS.PBKDF2(O,M,{keySize:192/32,iterations:H});var J=CryptoJS.enc.Hex.parse(N);var K=CryptoJS.TripleDES.encrypt(J,I,{iv:s})+\"\";var G={};G.ciphertext=K;G.pbkdf2Salt=CryptoJS.enc.Hex.stringify(M);G.pbkdf2Iter=H;G.encryptionSchemeAlg=L;G.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return G};if(D==\"PKCS8PRV\"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"rsaEncryption\"}},{\"null\":true}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var g=new l({seq:[{\"int\":1},{octstr:{hex:b.prvKeyHex}},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+b.pubKeyHex}}]}]});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"ecPublicKey\"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"dsa\"}},{seq:[{\"int\":{bigint:b.p}},{\"int\":{bigint:b.q}},{\"int\":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}throw\"unsupported object nor format\"};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,\"CERTIFICATE REQUEST\");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,\"pkcs8pub\");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!=\"30\"){throw\"malformed CSR(code:001)\"}var e=f(g,0);if(e.length<1){throw\"malformed CSR(code:002)\"}if(g.substr(e[0],2)!=\"30\"){throw\"malformed CSR(code:003)\"}var a=f(g,e[0]);if(a.length<3){throw\"malformed CSR(code:004)\"}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getJWKFromKey=function(d){var b={};if(d instanceof RSAKey&&d.isPrivate){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));b.d=hextob64u(d.d.toString(16));b.p=hextob64u(d.p.toString(16));b.q=hextob64u(d.q.toString(16));b.dp=hextob64u(d.dmp1.toString(16));b.dq=hextob64u(d.dmq1.toString(16));b.qi=hextob64u(d.coeff.toString(16));return b}else{if(d instanceof RSAKey&&d.isPublic){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPrivate){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);b.d=hextob64u(d.prvKeyHex);return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPublic){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);return b}}}}throw\"not supported key object\"};\nRSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,j,l,b,a,f,d,k;var m=ASN1HEX;var g=m.getVbyList;if(m.isASN1HEX(e)===false){throw\"not ASN.1 hex string\"}try{c=g(e,0,[2,0,1],\"02\");j=g(e,0,[2,0,2],\"02\");l=g(e,0,[2,0,3],\"02\");b=g(e,0,[2,0,4],\"02\");a=g(e,0,[2,0,5],\"02\");f=g(e,0,[2,0,6],\"02\");d=g(e,0,[2,0,7],\"02\");k=g(e,0,[2,0,8],\"02\")}catch(i){throw\"malformed PKCS#8 plain RSA private key\"}this.setPrivateEx(c,j,l,b,a,f,d,k)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw\"keyHex is not ASN.1 hex string\"}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!==\"02\"||c.substr(a[1],2)!==\"02\"){throw\"wrong hex for PKCS#5 public key\"}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw\"not ASN.1 hex string\"}if(c.getTLVbyList(b,0,[0,0])!==\"06092a864886f70d010101\"){throw\"not PKCS8 RSA public key\"}var a=c.getTLVbyList(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)};\nvar _RE_HEXDECONLY=new RegExp(\"\");_RE_HEXDECONLY.compile(\"[^0-9a-f]\",\"gi\");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c=\"\";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw\"invalid salt length\"}}}if(c<(g+k+2)){throw\"data too long\"}var f=\"\";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dthis.n.bitLength()){return 0}var i=this.doPublic(b);var e=i.toString(16).replace(/^1f+00/,\"\");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(k){return KJUR.crypto.Util.hashString(k,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){a=a.replace(_RE_HEXDECONLY,\"\");a=a.replace(/[ \\n]+/g,\"\");var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,\"\");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){var k=new BigInteger(s,16);if(k.bitLength()>this.n.bitLength()){return false}var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw\"invalid salt length\"}}}if(m<(h+c+2)){throw\"data too long\"}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw\"bits beyond keysize not zero\"}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q0){var b=\":\"+n.join(\":\")+\":\";if(b.indexOf(\":\"+k+\":\")==-1){throw\"algorithm '\"+k+\"' not accepted in the list\"}}if(k!=\"none\"&&B===null){throw\"key shall be specified to verify.\"}if(typeof B==\"string\"&&B.indexOf(\"-----BEGIN \")!=-1){B=KEYUTIL.getKey(B)}if(z==\"RS\"||z==\"PS\"){if(!(B instanceof m)){throw\"key shall be a RSAKey obj for RS* and PS* algs\"}}if(z==\"ES\"){if(!(B instanceof p)){throw\"key shall be a ECDSA obj for ES* algs\"}}if(k==\"none\"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw\"unsupported alg name: \"+k}else{u=t.jwsalg2sigalg[k]}if(u==\"none\"){throw\"not supported\"}else{if(u.substr(0,4)==\"Hmac\"){var o=null;if(B===undefined){throw\"hexadecimal key shall be specified for HMAC\"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf(\"withECDSA\")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(\".\");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw\"malformed sJWS: wrong number of '.' splitted elements\"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null,\" \");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null,\" \")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;var k=e.split(\".\");var c=k[0];var i=k[1];var q=c+\".\"+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw\"acceptField.alg shall be specified\"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss===\"object\"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub===\"object\"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud===\"object\"){if(typeof g.aud==\"string\"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud==\"object\"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt===\"number\"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!==\"number\"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp==\"number\"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw\"addSignature failed: \"+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw\"malformed header\"}if(typeof g.payload===\"string\"){this.sPayload=g.payload}else{throw\"malformed signatures\"}if(g.signatures.length>0){this.aSignatures=g.signatures}else{throw\"malformed signatures\"}}catch(e){throw\"malformed JWS-JS JSON object: \"+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}};\nexports.SecureRandom = SecureRandom;\nexports.rng_seed_time = rng_seed_time;\n\nexports.BigInteger = BigInteger;\nexports.RSAKey = RSAKey;\nexports.ECDSA = KJUR.crypto.ECDSA;\nexports.DSA = KJUR.crypto.DSA;\nexports.Signature = KJUR.crypto.Signature;\nexports.MessageDigest = KJUR.crypto.MessageDigest;\nexports.Mac = KJUR.crypto.Mac;\nexports.Cipher = KJUR.crypto.Cipher;\nexports.KEYUTIL = KEYUTIL;\nexports.ASN1HEX = ASN1HEX;\nexports.X509 = X509;\nexports.CryptoJS = CryptoJS;\n\n// ext/base64.js\nexports.b64tohex = b64tohex;\nexports.b64toBA = b64toBA;\n\n// base64x.js\nexports.stoBA = stoBA;\nexports.BAtos = BAtos;\nexports.BAtohex = BAtohex;\nexports.stohex = stohex;\nexports.stob64 = stob64;\nexports.stob64u = stob64u;\nexports.b64utos = b64utos;\nexports.b64tob64u = b64tob64u;\nexports.b64utob64 = b64utob64;\nexports.hex2b64 = hex2b64;\nexports.hextob64u = hextob64u;\nexports.b64utohex = b64utohex;\nexports.utf8tob64u = utf8tob64u;\nexports.b64utoutf8 = b64utoutf8;\nexports.utf8tob64 = utf8tob64;\nexports.b64toutf8 = b64toutf8;\nexports.utf8tohex = utf8tohex;\nexports.hextoutf8 = hextoutf8;\nexports.hextorstr = hextorstr;\nexports.rstrtohex = rstrtohex;\nexports.hextob64 = hextob64;\nexports.hextob64nl = hextob64nl;\nexports.b64nltohex = b64nltohex;\nexports.hextopem = hextopem;\nexports.pemtohex = pemtohex;\nexports.hextoArrayBuffer = hextoArrayBuffer;\nexports.ArrayBuffertohex = ArrayBuffertohex;\nexports.zulutomsec = zulutomsec;\nexports.zulutosec = zulutosec;\nexports.zulutodate = zulutodate;\nexports.datetozulu = datetozulu;\nexports.uricmptohex = uricmptohex;\nexports.hextouricmp = hextouricmp;\nexports.ipv6tohex = ipv6tohex;\nexports.hextoipv6 = hextoipv6;\nexports.hextoip = hextoip;\nexports.iptohex = iptohex;\nexports.encodeURIComponentAll = encodeURIComponentAll;\nexports.newline_toUnix = newline_toUnix;\nexports.newline_toDos = newline_toDos;\nexports.hextoposhex = hextoposhex;\nexports.intarystrtohex = intarystrtohex;\nexports.strdiffidx = strdiffidx;\n\n// name spaces\nexports.KJUR = KJUR;\nexports.crypto = KJUR.crypto;\nexports.asn1 = KJUR.asn1;\nexports.jws = KJUR.jws;\nexports.lang = KJUR.lang;\n\n\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://AppID/./node_modules/jsrsasign/lib/jsrsasign.js?"); - -/***/ }), - -/***/ "./node_modules/node-fetch/browser.js": -/*!********************************************!*\ - !*** ./node_modules/node-fetch/browser.js ***! - \********************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("\n\n// ref: https://github.com/tc39/proposal-global\nvar getGlobal = function () {\n\t// the only reliable means to get the global object is\n\t// `Function('return this')()`\n\t// However, this causes CSP violations in Chrome apps.\n\tif (typeof self !== 'undefined') { return self; }\n\tif (typeof window !== 'undefined') { return window; }\n\tif (typeof global !== 'undefined') { return global; }\n\tthrow new Error('unable to locate global object');\n}\n\nvar global = getGlobal();\n\nmodule.exports = exports = global.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = global.fetch.bind(global);\n\nexports.Headers = global.Headers;\nexports.Request = global.Request;\nexports.Response = global.Response;\n\n//# sourceURL=webpack://AppID/./node_modules/node-fetch/browser.js?"); - -/***/ }), - -/***/ "./node_modules/webpack/buildin/global.js": -/*!***********************************!*\ - !*** (webpack)/buildin/global.js ***! - \***********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://AppID/(webpack)/buildin/global.js?"); - -/***/ }), - -/***/ "./package.json": -/*!**********************!*\ - !*** ./package.json ***! - \**********************/ -/*! exports provided: name, version, description, scripts, repository, main, nyc, dependencies, devDependencies, default */ -/***/ (function(module) { - -eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"ibmcloud-appid-js\\\",\\\"version\\\":\\\"0.0.2\\\",\\\"description\\\":\\\"IBM Cloud App ID SDK for Single Page Applications\\\",\\\"scripts\\\":{\\\"build\\\":\\\"webpack --mode=development\\\",\\\"test\\\":\\\"mocha\\\",\\\"coverage\\\":\\\"nyc --reporter=lcov mocha\\\",\\\"docs\\\":\\\"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json\\\"},\\\"repository\\\":{\\\"type\\\":\\\"git\\\",\\\"url\\\":\\\"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git\\\"},\\\"main\\\":\\\"dist/appid.umd.min.js\\\",\\\"nyc\\\":{\\\"all\\\":true,\\\"include\\\":[\\\"src/*.js\\\"],\\\"exclude\\\":[\\\"**/PopupController.js\\\",\\\"**/IFrameController.js\\\",\\\"**/OpenIDConfigurationResource.js\\\",\\\"**/constants.js\\\"]},\\\"dependencies\\\":{\\\"jsrsasign\\\":\\\"^8.0.12\\\"},\\\"devDependencies\\\":{\\\"node-fetch\\\":\\\"^2.6.0\\\",\\\"@babel/cli\\\":\\\"^7.0.0\\\",\\\"@babel/core\\\":\\\"^7.5.5\\\",\\\"@babel/plugin-transform-runtime\\\":\\\"^7.5.5\\\",\\\"@babel/preset-env\\\":\\\"^7.5.5\\\",\\\"babel-cli\\\":\\\"^7.0.0-beta.3\\\",\\\"chai\\\":\\\"^4.2.0\\\",\\\"coveralls\\\":\\\"^3.0.6\\\",\\\"gulp-babel\\\":\\\"^8.0.0\\\",\\\"mocha\\\":\\\"^6.2.0\\\",\\\"nyc\\\":\\\"^14.1.1\\\",\\\"webpack\\\":\\\"^4.39.1\\\",\\\"webpack-cli\\\":\\\"^3.3.6\\\",\\\"docdash\\\":\\\"^1.1.1\\\",\\\"jsdoc\\\":\\\"^3.6.3\\\"}}\");\n\n//# sourceURL=webpack://AppID/./package.json?"); - -/***/ }), - -/***/ "./src/IFrameController.js": -/*!*********************************!*\ - !*** ./src/IFrameController.js ***! - \*********************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const IFrameError = __webpack_require__(/*! ./errors/IFrameError */ \"./src/errors/IFrameError.js\");\n\nclass IFrameController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t}\n\n\topen(url) {\n\t\tthis.iFrame = this.window.document.createElement('iframe');\n\t\tthis.iFrame.src = url;\n\t\tthis.iFrame.width = 0;\n\t\tthis.iFrame.height = 0;\n\t\tthis.window.document.body.appendChild(this.iFrame);\n\t}\n\n\tremove() {\n\t\twindow.document.body.removeChild(this.iFrame);\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\treject(new IFrameError('Silent sign-in timed out'));\n\t\t\t}, 5 * 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tclearInterval(timer);\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = IFrameController;\n\n\n//# sourceURL=webpack://AppID/./src/IFrameController.js?"); - -/***/ }), - -/***/ "./src/OpenIDConfigurationResource.js": -/*!********************************************!*\ - !*** ./src/OpenIDConfigurationResource.js ***! - \********************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const packagejson = __webpack_require__(/*! ../package.json */ \"./package.json\");\n\nclass OpenIdConfigurationResource {\n\tasync init({discoveryEndpoint, requestHandler}){\n\t\tthis.openIdConfig = await requestHandler(discoveryEndpoint);\n\t\tconst headers = { 'x-filter-type': `spa:v${packagejson.version}` };\n\t\tthis.publicKeys = requestHandler(this.getJwksEndpoint(), { headers: headers });\n\t}\n\n\tgetAuthorizationEndpoint() {\n\t\treturn this.openIdConfig.authorization_endpoint;\n\t}\n\n\tgetUserInfoEndpoint() {\n\t\treturn this.openIdConfig.userinfo_endpoint;\n\t}\n\n\tgetJwksEndpoint() {\n\t\treturn this.openIdConfig.jwks_uri;\n\t}\n\n\tgetTokenEndpoint() {\n\t\treturn this.openIdConfig.token_endpoint;\n\t}\n\n\tgetIssuer() {\n\t\treturn this.openIdConfig.issuer;\n\t}\n\n\tasync getPublicKeys() {\n\t\treturn await this.publicKeys;\n\t}\n}\nmodule.exports = OpenIdConfigurationResource;\n\n\n\n//# sourceURL=webpack://AppID/./src/OpenIDConfigurationResource.js?"); - -/***/ }), - -/***/ "./src/PopupController.js": -/*!********************************!*\ - !*** ./src/PopupController.js ***! - \********************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const PopupError = __webpack_require__(/*! ./errors/PopupError */ \"./src/errors/PopupError.js\");\n\nclass PopupController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t};\n\n\tinit(popupConfig){\n\t\tthis.popupConfig = popupConfig;\n\t}\n\n\topen() {\n\t\tconst h = this.popupConfig.height;\n\t\tconst w = this.popupConfig.width;\n\t\tconst left = (window.screen.width - w) / 2;\n\t\tconst top = (window.screen.height - h) / 2;\n\t\tthis.popup = this.window.open('', 'popup', `left=${left},top=${top},width=${w},height=${h},resizable,scrollbars=yes,status=1`);\n\t\tif (!this.popup) {\n\t\t\tthrow new PopupError('Unable to open popup')\n\t\t}\n\t};\n\n\tnavigate(url) {\n\t\tthis.popup.location.href = url;\n\t};\n\n\tclose() {\n\t\tthis.popup.close();\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\tif(this.popup.closed) {\n\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\treject(new PopupError('Popup closed'));\n\t\t\t\t}\n\t\t\t}, 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = PopupController;\n\n\n//# sourceURL=webpack://AppID/./src/PopupController.js?"); - -/***/ }), - -/***/ "./src/RequestHandler.js": -/*!*******************************!*\ - !*** ./src/RequestHandler.js ***! - \*******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t}\n\t\t\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tif (text !== '') {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); - -/***/ }), - -/***/ "./src/TokenValidator.js": -/*!*******************************!*\ - !*** ./src/TokenValidator.js ***! - \*******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg:[constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif (decoded.payloadObj.nonce && decoded.payloadObj.nonce !== nonce) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor(let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); - -/***/ }), - -/***/ "./src/constants.js": -/*!**************************!*\ - !*** ./src/constants.js ***! - \**************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN_PAYLOAD: 'Expect id token payload object to have identities field',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN_PAYLOAD: 'Missing id token payload',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tGENERATE_CODE: '/cloud_directory/generate_code',\n\tCHANGE_DETAILS: '/cloud_directory/change_details',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); - -/***/ }), - -/***/ "./src/errors/AppIDError.js": -/*!**********************************!*\ - !*** ./src/errors/AppIDError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class AppIDError extends Error {}\nmodule.exports = AppIDError;\n\n//# sourceURL=webpack://AppID/./src/errors/AppIDError.js?"); - -/***/ }), - -/***/ "./src/errors/IFrameError.js": -/*!***********************************!*\ - !*** ./src/errors/IFrameError.js ***! - \***********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class IFrameError extends Error {}\nmodule.exports = IFrameError;\n\n//# sourceURL=webpack://AppID/./src/errors/IFrameError.js?"); - -/***/ }), - -/***/ "./src/errors/OAuthError.js": -/*!**********************************!*\ - !*** ./src/errors/OAuthError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class OAuthError extends Error {\n\t// See https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for the possible error messages\n\tconstructor({error, description}) {\n\t\tsuper(description || error);\n\t\tthis.error = error;\n\t\tthis.description = description;\n\t}\n}\nmodule.exports = OAuthError;\n\n//# sourceURL=webpack://AppID/./src/errors/OAuthError.js?"); - -/***/ }), - -/***/ "./src/errors/PopupError.js": -/*!**********************************!*\ - !*** ./src/errors/PopupError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class PopupError extends Error {}\nmodule.exports = PopupError;\n\n//# sourceURL=webpack://AppID/./src/errors/PopupError.js?"); - -/***/ }), - -/***/ "./src/errors/RequestError.js": -/*!************************************!*\ - !*** ./src/errors/RequestError.js ***! - \************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class RequestError extends Error {\n\tconstructor(description, status, originError) {\n\t\tsuper(description);\n\t\tthis.status = status;\n\t\tthis.originError = originError;\n\t}\n}\nmodule.exports = RequestError;\n\n//# sourceURL=webpack://AppID/./src/errors/RequestError.js?"); - -/***/ }), - -/***/ "./src/errors/TokenError.js": -/*!**********************************!*\ - !*** ./src/errors/TokenError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class TokenError extends Error {}\nmodule.exports = TokenError;\n\n//# sourceURL=webpack://AppID/./src/errors/TokenError.js?"); - -/***/ }), - -/***/ "./src/index.js": -/*!**********************!*\ - !*** ./src/index.js ***! - \**********************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in will attempt to authenticate the user in a hidden iframe.\n\t * You will need to enable Cloud Directory SSO.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * @param {string} idTokenPayload The id token payload.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token payload\"\n\t * @example\n\t * let tokens = await appID.changePassword(idTokenPayload);\n\t */\n\tasync changePassword(idTokenPayload) {\n\t\tthis._validateInitalize();\n\t\tlet userId;\n\n\t\tif (!idTokenPayload) {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN_PAYLOAD);\n\t\t}\n\t\tif (typeof idTokenPayload === 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN_PAYLOAD);\n\t\t}\n\t\tif (idTokenPayload.identities && idTokenPayload.identities[0] && idTokenPayload.identities[0].id) {\n\t\t\tif (idTokenPayload.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = idTokenPayload.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN_PAYLOAD);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\tasync changeDetails(tokens) {\n\t\t// get code\n\t\tconst generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE;\n\t\tconsole.log(generateCodeUrl);\n\t\tconst changeDetailsCode = await this.request(generateCodeUrl, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + tokens.accessToken + ' ' + tokens.idToken\n\t\t\t}\n\t\t});\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS;\n\n\t\t// send code with url\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint,\n\t\t\tchangeDetailsCode\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); - -/***/ }), - -/***/ "./src/utils.js": -/*!**********************!*\ - !*** ./src/utils.js ***! - \**********************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId, changeDetailsCode}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tif (changeDetailsCode) {\n\t\t\tauthParams.code = changeDetailsCode;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint, changeDetailsCode}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint, changeDetailsCode});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); - -/***/ }) - -/******/ }); -}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.AppID=e():t.AppID=e()}(window,(function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=4)}([function(t,e,i){(function(t){var i={userAgent:!1},n={}; +/*! +Copyright (c) 2011, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.com/yui/license.html +version: 2.9.0 +*/ +if(void 0===r)var r={};r.lang={extend:function(t,e,n){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),n){var s;for(s in n)t.prototype[s]=n[s];var o=function(){},a=["toString","valueOf"];try{/MSIE/.test(i.userAgent)&&(o=function(t,e){for(s=0;s>>2]>>>24-s%4*8&255;e[n+s>>>2]|=o<<24-(n+s)%4*8}else for(s=0;s>>2]=i[s>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=s.ceil(e/4)},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i>>2]>>>24-r%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new u.init(i,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,i=t.sigBytes,n=[],r=0;r>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new u.init(i,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},g=a.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,n=e.sigBytes,r=this.blockSize,o=n/(4*r),a=(o=t?s.ceil(o):s.max((0|o)-this._minBufferSize,0))*r,h=s.min(4*a,n);if(a){for(var c=0;c>>2]}},e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:h,padding:c}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(h=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?n.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=n.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:i})}},e.SerializableCipher=i.extend({cfg:i.extend({format:h}),encrypt:function(t,e,i,n){n=this.cfg.extend(n);var r=t.createEncryptor(i,n);return e=r.finalize(e),r=r.cfg,l.create({ciphertext:e,key:i,iv:r.iv,algorithm:t,mode:r.mode,padding:r.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(i,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,i,r){return r||(r=n.random(8)),t=o.create({keySize:e+i}).compute(t,r),i=n.create(t.words.slice(e),4*i),t.sigBytes=4*e,l.create({key:t,iv:i,salt:r})}},g=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:d}),encrypt:function(t,e,i,n){return i=(n=this.cfg.extend(n)).kdf.execute(i,t.keySize,t.ivSize),n.iv=i.iv,(t=f.encrypt.call(this,t,e,i.key,n)).mixIn(i),t},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),i=n.kdf.execute(i,t.keySize,t.ivSize,e.salt),n.iv=i.iv,f.decrypt.call(this,t,e,i.key,n)}})}(),function(){for(var t=y,e=t.lib.BlockCipher,i=t.algo,n=[],r=[],s=[],o=[],a=[],h=[],u=[],c=[],l=[],f=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var p=0,v=0;for(g=0;256>g;g++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;n[p]=m,r[m]=p;var S=d[p],F=d[S],E=d[F],w=257*d[m]^16843008*m;s[p]=w<<24|w>>>8,o[p]=w<<16|w>>>16,a[p]=w<<8|w>>>24,h[p]=w,w=16843009*E^65537*F^257*S^16843008*p,u[m]=w<<24|w>>>8,c[m]=w<<16|w>>>16,l[m]=w<<8|w>>>24,f[m]=w,p?(p=S^d[d[d[E^S]]],v^=d[d[v]]):p=v=1}var x=[0,1,2,4,8,16,32,64,128,27,54];i=i.AES=e.extend({_doReset:function(){for(var t=(i=this._key).words,e=i.sigBytes/4,i=4*((this._nRounds=e+6)+1),r=this._keySchedule=[],s=0;s>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o]):(o=n[(o=o<<8|o>>>24)>>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o],o^=x[s/e|0]<<24),r[s]=r[s-e]^o}for(t=this._invKeySchedule=[],e=0;ee||4>=s?o:u[n[o>>>24]]^c[n[o>>>16&255]]^l[n[o>>>8&255]]^f[n[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,o,a,h,n)},decryptBlock:function(t,e){var i=t[e+1];t[e+1]=t[e+3],t[e+3]=i,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,r),i=t[e+1],t[e+1]=t[e+3],t[e+3]=i},_doCryptBlock:function(t,e,i,n,r,s,o,a){for(var h=this._nRounds,u=t[e]^i[0],c=t[e+1]^i[1],l=t[e+2]^i[2],f=t[e+3]^i[3],d=4,g=1;g>>24]^r[c>>>16&255]^s[l>>>8&255]^o[255&f]^i[d++],y=n[c>>>24]^r[l>>>16&255]^s[f>>>8&255]^o[255&u]^i[d++],v=n[l>>>24]^r[f>>>16&255]^s[u>>>8&255]^o[255&c]^i[d++];f=n[f>>>24]^r[u>>>16&255]^s[c>>>8&255]^o[255&l]^i[d++],u=p,c=y,l=v}p=(a[u>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&f])^i[d++],y=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[f>>>8&255]<<8|a[255&u])^i[d++],v=(a[l>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[255&c])^i[d++],f=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^i[d++],t[e]=p,t[e+1]=y,t[e+2]=v,t[e+3]=f},keySize:8});t.AES=e._createHelper(i)}(),function(){function t(t,e){var i=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=i,this._lBlock^=i<>>t^this._lBlock)&e;this._lBlock^=i,this._rBlock^=i<i;i++){var n=o[i]-1;e[i]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;16>n;n++){var r=t[n]=[],s=h[n];for(i=0;24>i;i++)r[i/6|0]|=e[(a[i]-1+s)%28]<<31-i%6,r[4+(i/6|0)]|=e[28+(a[i+24]-1+s)%28]<<31-i%6;for(r[0]=r[0]<<1|r[0]>>>31,i=1;7>i;i++)r[i]>>>=4*(i-1)+3;r[7]=r[7]<<5|r[7]>>>27}for(e=this._invSubKeys=[],i=0;16>i;i++)e[i]=t[15-i]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(i,n,r){this._lBlock=i[n],this._rBlock=i[n+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var o=r[s],a=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^o[f])&c[f])>>>0];this._lBlock=h,this._rBlock=a^l}r=this._lBlock,this._lBlock=this._rBlock,this._rBlock=r,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),i[n]=this._lBlock,i[n+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});i.DES=r._createHelper(l),s=s.TripleDES=r.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(n.create(t.slice(0,2))),this._des2=l.createEncryptor(n.create(t.slice(2,4))),this._des3=l.createEncryptor(n.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),i.TripleDES=r._createHelper(s)}(),function(){var t=y,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,i=t.sigBytes,n=this._map;t.clamp(),t=[];for(var r=0;r>>2]>>>24-r%4*8&255)<<16|(e[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|e[r+2>>>2]>>>24-(r+2)%4*8&255,o=0;4>o&&r+.75*o>>6*(3-o)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var i=t.length,n=this._map;(r=n.charAt(64))&&(-1!=(r=t.indexOf(r))&&(i=r));for(var r=[],s=0,o=0;o>>6-o%4*2;r[s>>>2]|=(a|h)<<24-s%4*8,s++}return e.create(r,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,i,n,r,s,o){return((t=t+(e&i|~e&n)+r+o)<>>32-s)+e}function i(t,e,i,n,r,s,o){return((t=t+(e&n|i&~n)+r+o)<>>32-s)+e}function n(t,e,i,n,r,s,o){return((t=t+(e^i^n)+r+o)<>>32-s)+e}function r(t,e,i,n,r,s,o){return((t=t+(i^(e|~n))+r+o)<>>32-s)+e}for(var s=y,o=(h=s.lib).WordArray,a=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var o=0;16>o;o++){var a=t[h=s+o];t[h]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var h=t[s+0],c=(a=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],d=t[s+5],g=t[s+6],p=t[s+7],y=t[s+8],v=t[s+9],m=t[s+10],S=t[s+11],F=t[s+12],E=t[s+13],w=t[s+14],x=t[s+15],b=e(b=o[0],C=o[1],I=o[2],A=o[3],h,7,u[0]),A=e(A,b,C,I,a,12,u[1]),I=e(I,A,b,C,c,17,u[2]),C=e(C,I,A,b,l,22,u[3]);b=e(b,C,I,A,f,7,u[4]),A=e(A,b,C,I,d,12,u[5]),I=e(I,A,b,C,g,17,u[6]),C=e(C,I,A,b,p,22,u[7]),b=e(b,C,I,A,y,7,u[8]),A=e(A,b,C,I,v,12,u[9]),I=e(I,A,b,C,m,17,u[10]),C=e(C,I,A,b,S,22,u[11]),b=e(b,C,I,A,F,7,u[12]),A=e(A,b,C,I,E,12,u[13]),I=e(I,A,b,C,w,17,u[14]),b=i(b,C=e(C,I,A,b,x,22,u[15]),I,A,a,5,u[16]),A=i(A,b,C,I,g,9,u[17]),I=i(I,A,b,C,S,14,u[18]),C=i(C,I,A,b,h,20,u[19]),b=i(b,C,I,A,d,5,u[20]),A=i(A,b,C,I,m,9,u[21]),I=i(I,A,b,C,x,14,u[22]),C=i(C,I,A,b,f,20,u[23]),b=i(b,C,I,A,v,5,u[24]),A=i(A,b,C,I,w,9,u[25]),I=i(I,A,b,C,l,14,u[26]),C=i(C,I,A,b,y,20,u[27]),b=i(b,C,I,A,E,5,u[28]),A=i(A,b,C,I,c,9,u[29]),I=i(I,A,b,C,p,14,u[30]),b=n(b,C=i(C,I,A,b,F,20,u[31]),I,A,d,4,u[32]),A=n(A,b,C,I,y,11,u[33]),I=n(I,A,b,C,S,16,u[34]),C=n(C,I,A,b,w,23,u[35]),b=n(b,C,I,A,a,4,u[36]),A=n(A,b,C,I,f,11,u[37]),I=n(I,A,b,C,p,16,u[38]),C=n(C,I,A,b,m,23,u[39]),b=n(b,C,I,A,E,4,u[40]),A=n(A,b,C,I,h,11,u[41]),I=n(I,A,b,C,l,16,u[42]),C=n(C,I,A,b,g,23,u[43]),b=n(b,C,I,A,v,4,u[44]),A=n(A,b,C,I,F,11,u[45]),I=n(I,A,b,C,x,16,u[46]),b=r(b,C=n(C,I,A,b,c,23,u[47]),I,A,h,6,u[48]),A=r(A,b,C,I,p,10,u[49]),I=r(I,A,b,C,w,15,u[50]),C=r(C,I,A,b,d,21,u[51]),b=r(b,C,I,A,F,6,u[52]),A=r(A,b,C,I,l,10,u[53]),I=r(I,A,b,C,m,15,u[54]),C=r(C,I,A,b,a,21,u[55]),b=r(b,C,I,A,y,6,u[56]),A=r(A,b,C,I,x,10,u[57]),I=r(I,A,b,C,g,15,u[58]),C=r(C,I,A,b,E,21,u[59]),b=r(b,C,I,A,f,6,u[60]),A=r(A,b,C,I,S,10,u[61]),I=r(I,A,b,C,c,15,u[62]),C=r(C,I,A,b,v,21,u[63]);o[0]=o[0]+b|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+A|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;i[r>>>5]|=128<<24-r%32;var s=t.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(i.length+1),this._process(),i=(e=this._hash).words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=a._createHelper(h),s.HmacMD5=a._createHmacHelper(h)}(Math),function(){var t=y,e=(r=t.lib).WordArray,i=r.Hasher,n=[],r=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=this._hash.words,r=i[0],s=i[1],o=i[2],a=i[3],h=i[4],u=0;80>u;u++){if(16>u)n[u]=0|t[e+u];else{var c=n[u-3]^n[u-8]^n[u-14]^n[u-16];n[u]=c<<1|c>>>31}c=(r<<5|r>>>27)+h+n[u],c=20>u?c+(1518500249+(s&o|~s&a)):40>u?c+(1859775393+(s^o^a)):60>u?c+((s&o|s&a|o&a)-1894007588):c+((s^o^a)-899497514),h=a,a=o,o=s<<30|s>>>2,s=r,r=c}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+o|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(i/4294967296),e[15+(n+64>>>9<<4)]=i,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=i._createHelper(r),t.HmacSHA1=i._createHmacHelper(r)}(),function(t){for(var e=y,i=(r=e.lib).WordArray,n=r.Hasher,r=e.algo,s=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=a(t.pow(h,.5))),o[u]=a(t.pow(h,1/3)),u++),h++}var d=[];r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(t,e){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],a=i[3],h=i[4],u=i[5],c=i[6],l=i[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var g=d[f-15],p=d[f-2];d[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[f-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[f-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+o[f]+d[f],p=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&r^n&s^r&s),l=c,c=u,u=h,h=a+g|0,a=s,s=r,r=n,n=g+p|0}i[0]=i[0]+n|0,i[1]=i[1]+r|0,i[2]=i[2]+s|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0,i[5]=i[5]+u|0,i[6]=i[6]+c|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return i[r>>>5]|=128<<24-r%32,i[14+(r+64>>>9<<4)]=t.floor(n/4294967296),i[15+(r+64>>>9<<4)]=n,e.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(r),e.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var t=y,e=t.lib.WordArray,i=(n=t.algo).SHA256,n=n.SHA224=i.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=i._createHelper(n),t.HmacSHA224=i._createHmacHelper(n)}(),function(){function t(){return n.create.apply(n,arguments)}for(var e=y,i=e.lib.Hasher,n=(s=e.x64).Word,r=s.WordArray,s=e.algo,o=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],a=[],h=0;80>h;h++)a[h]=t();s=s.SHA512=i.extend({_doReset:function(){this._hash=new r.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var i=(l=this._hash.words)[0],n=l[1],r=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=i.high,d=i.low,g=n.high,p=n.low,y=r.high,v=r.low,m=s.high,S=s.low,F=h.high,E=h.low,w=u.high,x=u.low,b=c.high,A=c.low,I=l.high,C=l.low,D=f,T=d,P=g,R=p,H=y,N=v,B=m,O=S,j=F,V=E,L=w,_=x,K=b,k=A,M=I,U=C,q=0;80>q;q++){var z=a[q];if(16>q)var G=z.high=0|t[e+2*q],Y=z.low=0|t[e+2*q+1];else{G=((Y=(G=a[q-15]).high)>>>1|(J=G.low)<<31)^(Y>>>8|J<<24)^Y>>>7;var J=(J>>>1|Y<<31)^(J>>>8|Y<<24)^(J>>>7|Y<<25),W=((Y=(W=a[q-2]).high)>>>19|(X=W.low)<<13)^(Y<<3|X>>>29)^Y>>>6,X=(X>>>19|Y<<13)^(X<<3|Y>>>29)^(X>>>6|Y<<26),Z=(Y=a[q-7]).high,$=(Q=a[q-16]).high,Q=Q.low;G=(G=(G=G+Z+((Y=J+Y.low)>>>0>>0?1:0))+W+((Y=Y+X)>>>0>>0?1:0))+$+((Y=Y+Q)>>>0>>0?1:0);z.high=G,z.low=Y}Z=j&L^~j&K,Q=V&_^~V&k,z=D&P^D&H^P&H;var tt=T&R^T&N^R&N,et=(J=(D>>>28|T<<4)^(D<<30|T>>>2)^(D<<25|T>>>7),W=(T>>>28|D<<4)^(T<<30|D>>>2)^(T<<25|D>>>7),(X=o[q]).high),it=X.low;$=M+((j>>>14|V<<18)^(j>>>18|V<<14)^(j<<23|V>>>9))+((X=U+((V>>>14|j<<18)^(V>>>18|j<<14)^(V<<23|j>>>9)))>>>0>>0?1:0),M=K,U=k,K=L,k=_,L=j,_=V,j=B+($=($=($=$+Z+((X=X+Q)>>>0>>0?1:0))+et+((X=X+it)>>>0>>0?1:0))+G+((X=X+Y)>>>0>>0?1:0))+((V=O+X|0)>>>0>>0?1:0)|0,B=H,O=N,H=P,N=R,P=D,R=T,D=$+(z=J+z+((Y=W+tt)>>>0>>0?1:0))+((T=X+Y|0)>>>0>>0?1:0)|0}d=i.low=d+T,i.high=f+D+(d>>>0>>0?1:0),p=n.low=p+R,n.high=g+P+(p>>>0>>0?1:0),v=r.low=v+N,r.high=y+H+(v>>>0>>0?1:0),S=s.low=S+O,s.high=m+B+(S>>>0>>0?1:0),E=h.low=E+V,h.high=F+j+(E>>>0>>0?1:0),x=u.low=x+_,u.high=w+L+(x>>>0<_>>>0?1:0),A=c.low=A+k,c.high=b+K+(A>>>0>>0?1:0),C=l.low=C+U,l.high=I+M+(C>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(i/4294967296),e[31+(n+128>>>10<<5)]=i,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=i._createHelper(s),e.HmacSHA512=i._createHmacHelper(s)}(),function(){var t=y,e=(r=t.x64).Word,i=r.WordArray,n=(r=t.algo).SHA512,r=r.SHA384=n.extend({_doReset:function(){this._hash=new i.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(r),t.HmacSHA384=n._createHmacHelper(r)}(),function(){var t=y,e=(n=t.lib).WordArray,i=n.Hasher,n=t.algo,r=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),o=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);n=n.RIPEMD160=i.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=0;16>i;i++){var n=t[F=e+i];t[F]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var c,l,f,d,g,p,y,v,m,S,F=this._hash.words,E=(n=h.words,u.words),w=r.words,x=s.words,b=o.words,A=a.words;p=c=F[0],y=l=F[1],v=f=F[2],m=d=F[3],S=g=F[4];var I;for(i=0;80>i;i+=1)I=c+t[e+w[i]]|0,I=16>i?I+((l^f^d)+n[0]):32>i?I+((l&f|~l&d)+n[1]):48>i?I+(((l|~f)^d)+n[2]):64>i?I+((l&d|f&~d)+n[3]):I+((l^(f|~d))+n[4]),I=(I=(I|=0)<>>32-b[i])+g|0,c=g,g=d,d=f<<10|f>>>22,f=l,l=I,I=p+t[e+x[i]]|0,I=16>i?I+((y^(v|~m))+E[0]):32>i?I+((y&m|v&~m)+E[1]):48>i?I+(((y|~v)^m)+E[2]):64>i?I+((y&v|~y&m)+E[3]):I+((y^v^m)+E[4]),I=(I=(I|=0)<>>32-A[i])+S|0,p=S,S=m,m=v<<10|v>>>22,v=y,y=I;I=F[1]+f+m|0,F[1]=F[2]+d+S|0,F[2]=F[3]+g+p|0,F[3]=F[4]+c+y|0,F[4]=F[0]+l+v|0,F[0]=I},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,i=0;5>i;i++)n=e[i],e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(n),t.HmacRIPEMD160=i._createHmacHelper(n)}(Math),function(){var t=y,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,i){t=this._hasher=new t.init,"string"==typeof i&&(i=e.parse(i));var n=t.blockSize,r=4*n;i.sigBytes>r&&(i=t.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),o=this._iKey=i.clone(),a=s.words,h=o.words,u=0;u>6)+m.charAt(63&i);if(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),n+=m.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),n+=m.charAt(i>>2)+m.charAt((3&i)<<4)),S)for(;(3&n.length)>0;)n+=S;return n}function E(t){var e,i,n,r="",s=0;for(e=0;e>2),i=3&n,s=1):1==s?(r+=T(i<<2|n>>4),i=15&n,s=2):2==s?(r+=T(i),r+=T(n>>2),i=3&n,s=3):(r+=T(i<<2|n>>4),r+=T(15&n),s=0));return 1==s&&(r+=T(i<<2)),r}function w(t){var e,i=E(t),n=new Array;for(e=0;2*e>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;r=((h=o*h+((32767&c)<<15)+i[n]+(1073741823&r))>>>30)+(c>>>15)+a*u+(r>>>30),i[n++]=1073741823&h}return r},v=30):"Netscape"!=i.appName?(x.prototype.am=function(t,e,i,n,r,s){for(;--s>=0;){var o=e*this[t++]+i[n]+r;r=Math.floor(o/67108864),i[n++]=67108863&o}return r},v=26):(x.prototype.am=function(t,e,i,n,r,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;r=((h=o*h+((16383&c)<<14)+i[n]+r)>>28)+(c>>14)+a*u,i[n++]=268435455&h}return r},v=28),x.prototype.DB=v,x.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function N(t){this.m=t}function B(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function K(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function k(){}function M(t){return t}function U(t){this.r2=b(),this.q3=b(),x.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}N.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},N.prototype.revert=function(t){return t},N.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},N.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},N.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},B.prototype.convert=function(t){var e=b();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(x.ZERO)>0&&this.m.subTo(e,e),e},B.prototype.revert=function(t){var e=b();return t.copyTo(e),this.reduce(e),e},B.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},B.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},B.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},x.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},x.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},x.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,r=!1,s=0;--n>=0;){var o=8==i?255&t[n]:P(t,n);o<0?"-"==t.charAt(n)&&(r=!0):(r=!1,0==s?this[this.t++]=o:s+i>this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},x.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},x.prototype.drShiftTo=function(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>r|a,a=(this[i]&s)<=0;--i)e[i]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},x.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,r=this.DB-n,s=(1<>n;for(var o=i+1;o>n;n>0&&(e[this.t-i-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},x.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),r=i.t;for(e.t=r+n.t;--r>=0;)e[r]=0;for(r=0;r=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},x.prototype.divRemTo=function(t,e,i){var n=t.abs();if(!(n.t<=0)){var r=this.abs();if(r.t0?(n.lShiftTo(h,s),r.lShiftTo(h,i)):(n.copyTo(s),r.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<1?s[u-2]>>this.F2:0),f=this.FV/l,d=(1<=0&&(i[i.t++]=1,i.subTo(v,i)),x.ONE.dlShiftTo(u,v),v.subTo(s,s);s.t=0;){var m=i[--p]==c?this.DM:Math.floor(i[p]*f+(i[p-1]+g)*d);if((i[p]+=s.am(0,m,i,y,0,u))0&&i.rShiftTo(h,i),o<0&&x.ZERO.subTo(i,i)}}},x.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},x.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},x.prototype.exp=function(t,e){if(t>4294967295||t<1)return x.ONE;var i=b(),n=b(),r=e.convert(this),s=H(t)-1;for(r.copyTo(i);--s>=0;)if(e.sqrTo(i,n),(t&1<0)e.mulTo(n,r,i);else{var o=i;i=n,n=o}return e.revert(i)},x.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<0)for(a>a)>0&&(r=!0,s=T(i));o>=0;)a>(a+=this.DB-e)):(i=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),i>0&&(r=!0),r&&(s+=T(i));return r?s:"0"},x.prototype.negate=function(){var t=b();return x.ZERO.subTo(this,t),t},x.prototype.abs=function(){return this.s<0?this.negate():this},x.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},x.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+H(this[this.t-1]^this.s&this.DM)},x.prototype.mod=function(t){var e=b();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(x.ZERO)>0&&t.subTo(e,e),e},x.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new N(e):new B(e),this.exp(t,i)},x.ZERO=R(0),x.ONE=R(1),k.prototype.convert=M,k.prototype.revert=M,k.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},k.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=b();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var q=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],z=(1<<26)/q[q.length-1]; +/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ + */ +function G(){this.i=0,this.j=0,this.S=new Array}x.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},x.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),n=R(i),r=b(),s=b(),o="";for(this.divRemTo(n,r,s);r.signum()>0;)o=(i+s.intValue()).toString(t).substr(1)+o,r.divRemTo(n,r,s);return s.intValue().toString(t)+o},x.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),r=!1,s=0,o=0,a=0;a=i&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),r&&x.ZERO.subTo(this,this)},x.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(x.ONE.shiftLeft(t-1),j,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(x.ONE.shiftLeft(t-1),this);else{var n=new Array,r=7&t;n.length=1+(t>>3),e.nextBytes(n),r>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},x.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},x.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},x.prototype.multiplyLowerTo=function(t,e,i){var n,r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r=0;)i[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},x.prototype.millerRabin=function(t){var e=this.subtract(x.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var n=e.shiftRight(i);(t=t+1>>1)>q.length&&(t=q.length);for(var r=b(),s=0;s>24},x.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},x.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},x.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,r=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[r++]=i|this.s<=0;)n<8?(i=(this[t]&(1<>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(e[r++]=i);return e},x.prototype.equals=function(t){return 0==this.compareTo(t)},x.prototype.min=function(t){return this.compareTo(t)<0?this:t},x.prototype.max=function(t){return this.compareTo(t)>0?this:t},x.prototype.and=function(t){var e=b();return this.bitwiseTo(t,O,e),e},x.prototype.or=function(t){var e=b();return this.bitwiseTo(t,j,e),e},x.prototype.xor=function(t){var e=b();return this.bitwiseTo(t,V,e),e},x.prototype.andNot=function(t){var e=b();return this.bitwiseTo(t,L,e),e},x.prototype.not=function(){for(var t=b(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var c=b();for(n.sqrTo(o[1],c);a<=u;)o[a]=b(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,d=t.t-1,g=!0,p=b();for(r=H(t[d])-1;d>=0;){for(r>=h?l=t[d]>>r-h&u:(l=(t[d]&(1<0&&(l|=t[d-1]>>this.DB+r-h)),a=i;0==(1&l);)l>>=1,--a;if((r-=a)<0&&(r+=this.DB,--d),g)o[l].copyTo(s),g=!1;else{for(;a>1;)n.sqrTo(s,p),n.sqrTo(p,s),a-=2;a>0?n.sqrTo(s,p):(f=s,s=p,p=f),n.mulTo(p,o[l],s)}for(;d>=0&&0==(t[d]&1<=0?(i.subTo(n,i),e&&r.subTo(o,r),s.subTo(a,s)):(n.subTo(i,n),e&&o.subTo(r,o),a.subTo(s,a))}return 0!=n.compareTo(x.ONE)?x.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},x.prototype.pow=function(t){return this.exp(t,new k)},x.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var r=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(r0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(r=e.getLowestSetBit())>0&&e.rShiftTo(r,e),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},x.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=q[q.length-1]){for(e=0;e>8&255,J[W++]^=t>>16&255,J[W++]^=t>>24&255,W>=X&&(W-=X)}((new Date).getTime())}if(null==J){var $;if(J=new Array,W=0,void 0!==n&&(void 0!==n.crypto||void 0!==n.msCrypto)){var Q=n.crypto||n.msCrypto;if(Q.getRandomValues){var tt=new Uint8Array(32);for(Q.getRandomValues(tt),$=0;$<32;++$)J[W++]=tt[$]}else if("Netscape"==i.appName&&i.appVersion<"5"){var et=n.crypto.random(32);for($=0;$>>8,J[W++]=255&$;W=0,Z()}function it(){if(null==Y){for(Z(),(Y=new G).init(J),W=0;W>24,(16711680&r)>>16,(65280&r)>>8,255&r]))),r+=1;return n}function ot(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function at(t,e,i){for(var n="",r=0;n.length>24,(16711680&r)>>16,(65280&r)>>8,255&r])),r+=1;return n} +/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ + */ +function ht(t,e){this.x=e,this.q=t}function ut(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?x.ONE:n,this.zinv=null}function ct(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new ut(this,null,null)}nt.prototype.nextBytes=function(t){var e;for(e=0;e0&&e.length>0))throw"Invalid RSA public key";this.n=rt(t,16),this.e=parseInt(e,16)}},ot.prototype.encrypt=function(t){var e=function(t,e){if(e=0&&e>0;){var r=t.charCodeAt(n--);r<128?i[--e]=r:r>127&&r<2048?(i[--e]=63&r|128,i[--e]=r>>6|192):(i[--e]=63&r|128,i[--e]=r>>6&63|128,i[--e]=r>>12|224)}i[--e]=0;for(var s=new nt,o=new Array;e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new x(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var n=i.toString(16);return 0==(1&n.length)?n:"0"+n},ot.prototype.encryptOAEP=function(t,e,i){var n=function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;if(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t.length+2*n+2>e)throw"Message too long for RSA";var a,h="";for(a=0;a>3,e,i);if(null==n)return null;var r=this.doPublic(n);if(null==r)return null;var s=r.toString(16);return 0==(1&s.length)?s:"0"+s},ot.prototype.type="RSA",ot.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},ot.prototype.setPrivate=function(t,e,i){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=i;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16)}},ot.prototype.setPrivateEx=function(t,e,i,n,r,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16),this.p=rt(n,16),this.q=rt(r,16),this.dmp1=rt(s,16),this.dmq1=rt(o,16),this.coeff=rt(a,16)},ot.prototype.generate=function(t,e){var i=new nt,n=t>>1;this.e=parseInt(e,16);for(var r=new x(e,16);;){for(;this.p=new x(t-n,1,i),0!=this.p.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.p.isProbablePrime(10););for(;this.q=new x(n,1,i),0!=this.q.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(x.ONE),a=this.q.subtract(x.ONE),h=o.multiply(a);if(0==h.gcd(r).compareTo(x.ONE)){this.n=this.p.multiply(this.q),this.d=r.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},ot.prototype.decrypt=function(t){var e=rt(t,16),i=this.doPrivate(e);return null==i?null: +/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ + */ +function(t,e){for(var i=t.toByteArray(),n=0;n=i.length)return null;for(var r="";++n191&&s<224?(r+=String.fromCharCode((31&s)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&s)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},ot.prototype.decryptOAEP=function(t,e,i){var n=rt(t,16),r=this.doPrivate(n);return null==r?null:function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;for(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t=t.toByteArray(),a=0;a>3,e,i)},ht.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ht.prototype.toBigInteger=function(){return this.x},ht.prototype.negate=function(){return new ht(this.q,this.x.negate().mod(this.q))},ht.prototype.add=function(t){return new ht(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ht.prototype.subtract=function(t){return new ht(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ht.prototype.multiply=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ht.prototype.square=function(){return new ht(this.q,this.x.square().mod(this.q))},ht.prototype.divide=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ut.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO))},ut.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(x.ZERO)&&!this.y.toBigInteger().equals(x.ZERO)},ut.prototype.negate=function(){return new ut(this.curve,this.x,this.y.negate(),this.z)},ut.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),i=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(x.ZERO.equals(i))return x.ZERO.equals(e)?this.twice():this.curve.getInfinity();var n=new x("3"),r=this.x.toBigInteger(),s=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),i.square()),a=o.multiply(i),h=r.multiply(o),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(a).multiply(i).mod(this.curve.q),l=h.multiply(n).multiply(e).subtract(s.multiply(a)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),f=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},ut.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new x("3"),e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=i.multiply(this.z),r=n.multiply(i).mod(this.curve.q),s=this.curve.a.toBigInteger(),o=e.square().multiply(t);x.ZERO.equals(s)||(o=o.add(this.z.square().multiply(s)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(r)).shiftLeft(1).multiply(n).mod(this.curve.q),h=o.multiply(t).multiply(e).subtract(r.shiftLeft(1)).shiftLeft(2).multiply(r).subtract(o.square().multiply(o)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),u)},ut.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add(o?this:r))}return s},ut.prototype.multiplyTwo=function(t,e,i){var n;n=t.bitLength()>i.bitLength()?t.bitLength()-1:i.bitLength()-1;for(var r=this.curve.getInfinity(),s=this.add(e);n>=0;)r=r.twice(),t.testBit(n)?r=i.testBit(n)?r.add(s):r.add(this):i.testBit(n)&&(r=r.add(e)),--n;return r},ct.prototype.getQ=function(){return this.q},ct.prototype.getA=function(){return this.a},ct.prototype.getB=function(){return this.b},ct.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ct.prototype.getInfinity=function(){return this.infinity},ct.prototype.fromBigInteger=function(t){return new ht(this.q,t)},ct.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,i=t.substr(2,e),n=t.substr(e+2,e);return new ut(this,this.fromBigInteger(new x(i,16)),this.fromBigInteger(new x(n,16)));default:return null}}, +/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib + */ +ht.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ut.prototype.getEncoded=function(t){var e=function(t,e){var i=t.toByteArrayUnsigned();if(ei.length;)i.unshift(0);return i},i=this.getX().toBigInteger(),n=this.getY().toBigInteger(),r=e(i,32);return t?n.isEven()?r.unshift(2):r.unshift(3):(r.unshift(4),r=r.concat(e(n,32))),r},ut.decodeFrom=function(t,e){e[0];var i=e.length-1,n=e.slice(1,1+i/2),r=e.slice(1+i/2,1+i);n.unshift(0),r.unshift(0);var s=new x(n),o=new x(r);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.decodeFromHex=function(t,e){e.substr(0,2);var i=e.length-2,n=e.substr(2,i/2),r=e.substr(2+i/2,i/2),s=new x(n,16),o=new x(r,16);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),i=t.y.subtract(this.y).divide(e),n=i.square().subtract(this.x).subtract(t.x),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(x.valueOf(2)),e=this.curve.fromBigInteger(x.valueOf(3)),i=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=i.square().subtract(this.x.multiply(t)),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add2D(o?this:r))}return s},ut.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),i=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),r=this.curve.getQ(),s=e.multiply(e).mod(r),o=t.multiply(t).multiply(t).add(i.multiply(t)).add(n).mod(r);return s.equals(o)},ut.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ut.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),i=this.getY().toBigInteger();if(e.compareTo(x.ONE)<0||e.compareTo(t.subtract(x.ONE))>0)throw new Error("x coordinate out of bounds");if(i.compareTo(x.ONE)<0||i.compareTo(t.subtract(x.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0}; +/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval + */ +var lt=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),i={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,n){return e?i[e]:String.fromCharCode(parseInt(n,16))}var r=new String(""),s=(Object,Array,Object.hasOwnProperty);return function(i,o){var a,h,u=i.match(t),c=u[0],l=!1;"{"===c?a={}:"["===c?a=[]:(a=[],l=!0);for(var f=[a],d=1-l,g=u.length;d=0;)delete i[n[h]]}return o.call(t,e,i)};a=y({"":a},"")}return a}}();void 0!==ft&&ft||(ft={}),void 0!==ft.asn1&&ft.asn1||(ft.asn1={}),ft.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},ft.asn1.DERAbstractString=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=bt(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},r.lang.extend(ft.asn1.DERAbstractString,ft.asn1.ASN1Object),ft.asn1.DERAbstractTime=function(t){ft.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var n=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var h=n(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=St(t)},this.setByDateValue=function(t,e,i,n,r,s){var o=new Date(Date.UTC(t,e-1,i,n,r,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},r.lang.extend(ft.asn1.DERAbstractTime,ft.asn1.ASN1Object),ft.asn1.DERAbstractStructured=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},r.lang.extend(ft.asn1.DERAbstractStructured,ft.asn1.ASN1Object),ft.asn1.DERBoolean=function(){ft.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},r.lang.extend(ft.asn1.DERBoolean,ft.asn1.ASN1Object),ft.asn1.DERInteger=function(t){ft.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ft.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},r.lang.extend(ft.asn1.DERInteger,ft.asn1.ASN1Object),ft.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ft.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}ft.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7r.length&&(r=n[i]);return(t=t.replace(r,"::")).slice(1,-1)}function _t(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?Lt(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function Kt(t){for(var e=encodeURIComponent(t),i="",n=0;n"7"?"00"+t:t}function Mt(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,i){var n=parseInt(t);if(n<0||255=2*s)break;if(a>=200)break;n.push(h),o=h,a++}return n},pt.getNthChildIdx=function(t,e,i){return pt.getChildIdx(t,e)[i]},pt.getIdxbyList=function(t,e,i,n){var r,s,o=pt;if(0==i.length){if(void 0!==n&&t.substr(e,2)!==n)throw"checking tag doesn't match: "+t.substr(e,2)+"!="+n;return e}return r=i.shift(),s=o.getChildIdx(t,e),o.getIdxbyList(t,s[r],i,n)},pt.getTLVbyList=function(t,e,i,n){var r=pt,s=r.getIdxbyList(t,e,i);if(void 0===s)throw"can't find nthList object";if(void 0!==n&&t.substr(s,2)!=n)throw"checking tag doesn't match: "+t.substr(s,2)+"!="+n;return r.getTLV(t,s)},pt.getVbyList=function(t,e,i,n,r){var s,o,a=pt;if(void 0===(s=a.getIdxbyList(t,e,i,n)))throw"can't find nthList object";return o=a.getV(t,s),!0===r&&(o=o.substr(2)),o},pt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},i=[],n=t.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var s=t.substr(2),o=[],a=0;a0&&(c=c+"."+h.join(".")),c},pt.dump=function(t,e,i,n){var r=pt,s=r.getV,o=r.dump,a=r.getChildIdx,h=t;t instanceof ft.asn1.ASN1Object&&(h=t.getEncodedHex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var c=e.ommit_long_octet;if("01"==h.substr(i,2))return"00"==(l=s(h,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==h.substr(i,2))return n+"INTEGER "+u(l=s(h,i),c)+"\n";if("03"==h.substr(i,2))return n+"BITSTRING "+u(l=s(h,i),c)+"\n";if("04"==h.substr(i,2)){var l=s(h,i);if(r.isASN1HEX(l)){var f=n+"OCTETSTRING, encapsulates\n";return f+=o(l,e,0,n+" ")}return n+"OCTETSTRING "+u(l,c)+"\n"}if("05"==h.substr(i,2))return n+"NULL\n";if("06"==h.substr(i,2)){var d=s(h,i),g=ft.asn1.ASN1Util.oidHexToInt(d),p=ft.asn1.x509.OID.oid2name(g),y=g.replace(/\./g," ");return""!=p?n+"ObjectIdentifier "+p+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0c"==h.substr(i,2))return n+"UTF8String '"+At(s(h,i))+"'\n";if("13"==h.substr(i,2))return n+"PrintableString '"+At(s(h,i))+"'\n";if("14"==h.substr(i,2))return n+"TeletexString '"+At(s(h,i))+"'\n";if("16"==h.substr(i,2))return n+"IA5String '"+At(s(h,i))+"'\n";if("17"==h.substr(i,2))return n+"UTCTime "+At(s(h,i))+"\n";if("18"==h.substr(i,2))return n+"GeneralizedTime "+At(s(h,i))+"\n";if("30"==h.substr(i,2)){if("3000"==h.substr(i,4))return n+"SEQUENCE {}\n";f=n+"SEQUENCE\n";var v=e;if((2==(F=a(h,i)).length||3==F.length)&&"06"==h.substr(F[0],2)&&"04"==h.substr(F[F.length-1],2)){p=r.oidname(s(h,F[0]));var m=JSON.parse(JSON.stringify(e));m.x509ExtName=p,v=m}for(var S=0;S0){var e=new i({array:this.extensionsArray}),n=new r({explicit:!0,tag:"a3",obj:e});this.asn1Array.push(n)}var s=new i({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertificate,ft.asn1.ASN1Object),ft.asn1.x509.Extension=function(t){ft.asn1.x509.Extension.superclass.constructor.call(this);var e=ft.asn1,i=e.DERObjectIdentifier,n=e.DEROctetString,r=(e.DERBitString,e.DERBoolean),s=e.DERSequence;this.getEncodedHex=function(){var t=new i({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new r),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},r.lang.extend(ft.asn1.x509.Extension,ft.asn1.ASN1Object),ft.asn1.x509.Extension.appendByNameToArray=function(t,e,i){var n=t.toLowerCase(),r=ft.asn1.x509;if("basicconstraints"==n){var s=new r.BasicConstraints(e);i.push(s)}else if("keyusage"==n){s=new r.KeyUsage(e);i.push(s)}else if("crldistributionpoints"==n){s=new r.CRLDistributionPoints(e);i.push(s)}else if("extkeyusage"==n){s=new r.ExtKeyUsage(e);i.push(s)}else if("authoritykeyidentifier"==n){s=new r.AuthorityKeyIdentifier(e);i.push(s)}else if("authorityinfoaccess"==n){s=new r.AuthorityInfoAccess(e);i.push(s)}else if("subjectaltname"==n){s=new r.SubjectAltName(e);i.push(s)}else{if("issueraltname"!=n)throw"unsupported extension name: "+t;s=new r.IssuerAltName(e);i.push(s)}},ft.asn1.x509.KeyUsage=function(t){ft.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Jt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new ft.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var i=t.names,n="000000000",r=0;r-1&&t.push(new ft.asn1.DERInteger({int:this.pathLen}));var e=new ft.asn1.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},r.lang.extend(ft.asn1.x509.BasicConstraints,ft.asn1.x509.Extension),ft.asn1.x509.CRLDistributionPoints=function(t){ft.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ft.asn1,i=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){this.asn1ExtnValue=new e.DERSequence({array:t})},this.setByOneURI=function(t){var e=new i.GeneralNames([{uri:t}]),n=new i.DistributionPointName(e),r=new i.DistributionPoint({dpobj:n});this.setByDPArray([r])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},r.lang.extend(ft.asn1.x509.CRLDistributionPoints,ft.asn1.x509.Extension),ft.asn1.x509.ExtKeyUsage=function(t){ft.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=ft.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var i=0;i0){var t=new i({array:this.aRevokedCert});this.asn1Array.push(t)}var e=new i({array:this.asn1Array});return this.hTLV=e.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize=function(){this.asn1Version=null,this.asn1SignatureAlg=null,this.asn1Issuer=null,this.asn1ThisUpdate=null,this.asn1NextUpdate=null,this.aRevokedCert=new Array},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertList,ft.asn1.ASN1Object),ft.asn1.x509.CRLEntry=function(t){ft.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=ft.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},r.lang.extend(ft.asn1.x509.CRLEntry,ft.asn1.ASN1Object),ft.asn1.x509.X500Name=function(t){ft.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=new Array;var e=ft.asn1,i=e.x509,n=Ht;if(this.setByString=function(t){var e=t.split("/");e.shift();for(var n=[],r=0;r0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},ft.asn1.x509.RDN=function(t){ft.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=new Array,this.addByString=function(t){this.asn1Array.push(new ft.asn1.x509.AttributeTypeAndValue({str:t}))},this.addByMultiValuedString=function(t){for(var e=ft.asn1.x509.RDN.parseString(t),i=0;i0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var a=!1,h=[];for(r=0;n.length>0;r++){s=n.shift();if(!0===a){var u=h.pop();if(s.match(/"$/)){o=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(o),a=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(a=!0)}return h},ft.asn1.x509.AttributeTypeAndValue=function(t){ft.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var e=ft.asn1;this.setByString=function(t){var e=t.match(/^([^=]+)=(.+)$/);if(!e)throw"malformed attrTypeAndValueStr: "+t;this.setByAttrTypeAndValueStr(e[1],e[2])},this.setByAttrTypeAndValueStr=function(t,e){this.typeObj=ft.asn1.x509.OID.atype2obj(t);var i="utf8";"C"==t&&(i="prn"),this.valueObj=this.getValueObj(i,e)},this.getValueObj=function(t,i){if("utf8"==t)return new e.DERUTF8String({str:i});if("prn"==t)return new e.DERPrintableString({str:i});if("tel"==t)return new e.DERTeletexString({str:i});if("ia5"==t)return new e.DERIA5String({str:i});throw"unsupported directory string type: type="+t+" value="+i},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.typeObj,this.valueObj]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&void 0!==t.str&&this.setByString(t.str)},r.lang.extend(ft.asn1.x509.AttributeTypeAndValue,ft.asn1.ASN1Object),ft.asn1.x509.SubjectPublicKeyInfo=function(t){ft.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ft,i=e.asn1,n=i.DERInteger,r=i.DERBitString,s=i.DERObjectIdentifier,o=i.DERSequence,a=i.ASN1Util.newObject,h=i.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof ot){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+e})}}catch(t){}try{if(t instanceof ft.crypto.ECDSA){var i=new s({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ft.crypto.DSA){i=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new h({name:"dsa",asn1params:i});var o=new n({bigint:t.y});this.asn1SubjPKey=new r({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},r.lang.extend(ft.asn1.x509.SubjectPublicKeyInfo,ft.asn1.ASN1Object),ft.asn1.x509.Time=function(t){ft.asn1.x509.Time.superclass.constructor.call(this);var e=ft.asn1,i=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},r.lang.extend(ft.asn1.x509.Time,ft.asn1.ASN1Object),ft.asn1.x509.AlgorithmIdentifier=function(t){ft.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ft.asn1;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw"algorithm not specified";null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var t=[this.asn1Alg];null!==this.asn1Params&&t.push(this.asn1Params);var i=new e.DERSequence({array:t});return this.hTLV=i.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},r.lang.extend(ft.asn1.x509.AlgorithmIdentifier,ft.asn1.ASN1Object),ft.asn1.x509.GeneralName=function(t){ft.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=ft.asn1,n=(i.DERSequence,i.DEROctetString),r=i.DERIA5String,s=i.DERTaggedObject,o=i.ASN1Object,a=i.x509.X500Name,h=Ht;this.explicit=!1,this.setByParam=function(t){var i=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",i=new r({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",i=new r({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",i=new r({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,i=new a({str:t.dn})),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var u=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certissuer param not cert";(f=new Jt).hex=u;var c=f.getIssuerHex();(i=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;u=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certsubj param not cert";(f=new Jt).hex=u;c=f.getSubjectHex();(i=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,g=t.ip,p="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(d=Mt("["+g.split(".").join(",")+"]")).length)throw p}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=Vt(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw p;d=g}i=new n({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},r.lang.extend(ft.asn1.x509.GeneralName,ft.asn1.ASN1Object),ft.asn1.x509.GeneralNames=function(t){ft.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ft.asn1;this.setByParamArray=function(t){for(var i=0;i0&&(e=new n({obj:this.dUnsignedAttrs,tag:"a1",explicit:!1}));var r=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,t,this.dSigAlg,this.dSig];null!=e&&r.push(e);var o=new i.DERSequence({array:r});return this.hTLV=o.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.SignerInfo,ft.asn1.ASN1Object),ft.asn1.cms.EncapsulatedContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.dEContentType=new r({name:"data"}),this.dEContent=null,this.isDetached=!1,this.eContentValueHex=null,this.setContentType=function(t){t.match(/^[0-2][.][0-9.]+$/)?this.dEContentType=new r({oid:t}):this.dEContentType=new r({name:t})},this.setContentValue=function(t){void 0!==t&&("string"==typeof t.hex?this.eContentValueHex=t.hex:"string"==typeof t.str&&(this.eContentValueHex=bt(t.str)))},this.setContentValueHex=function(t){this.eContentValueHex=t},this.setContentValueStr=function(t){this.eContentValueHex=bt(t)},this.getEncodedHex=function(){if("string"!=typeof this.eContentValueHex)throw"eContentValue not yet set";var t=new s({hex:this.eContentValueHex});this.dEContent=new i({obj:t,tag:"a0",explicit:!0});var e=[this.dEContentType];this.isDetached||e.push(this.dEContent);var r=new n({array:e});return this.hTLV=r.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.EncapsulatedContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.ContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.x509;ft.asn1.cms.ContentInfo.superclass.constructor.call(this),this.dContentType=null,this.dContent=null,this.setContentType=function(t){"string"==typeof t&&(this.dContentType=r.OID.name2obj(t))},this.getEncodedHex=function(){var t=new i({obj:this.dContent,tag:"a0",explicit:!0}),e=new n({array:[this.dContentType,t]});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t&&(t.type&&this.setContentType(t.type),t.obj&&t.obj instanceof e.ASN1Object&&(this.dContent=t.obj))},r.lang.extend(ft.asn1.cms.ContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.SignedData=function(t){var e=ft.asn1,i=e.ASN1Object,n=e.DERInteger,r=e.DERSet,s=e.DERSequence,o=e.DERTaggedObject,a=e.cms,h=a.EncapsulatedContentInfo,u=a.SignerInfo,c=a.ContentInfo,l=e.x509.AlgorithmIdentifier;ft.asn1.cms.SignedData.superclass.constructor.call(this),this.dCMSVersion=new n({int:1}),this.dDigestAlgs=null,this.digestAlgNameList=[],this.dEncapContentInfo=new h,this.dCerts=null,this.certificateList=[],this.crlList=[],this.signerInfoList=[new u],this.addCertificatesByPEM=function(t){var e=Ht(t),n=new i;n.hTLV=e,this.certificateList.push(n)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(null==this.dDigestAlgs){for(var t=[],e=0;e0){var h=new r({array:this.certificateList});this.dCerts=new o({obj:h,tag:"a0",explicit:!1})}null!=this.dCerts&&a.push(this.dCerts);var u=new r({array:this.signerInfoList});a.push(u);var c=new s({array:a});return this.hTLV=c.getEncodedHex(),this.hTLV},this.getContentInfo=function(){return this.getEncodedHex(),new c({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},this.getPEM=function(){return Rt(this.getContentInfoEncodedHex(),"CMS")}},r.lang.extend(ft.asn1.cms.SignedData,ft.asn1.ASN1Object),ft.asn1.cms.CMSUtil=new function(){},ft.asn1.cms.CMSUtil.newSignedData=function(t){var e=ft.asn1,i=e.cms,n=i.SignerInfo,r=i.SignedData,s=i.SigningTime,o=i.SigningCertificate,a=i.SigningCertificateV2,h=e.cades.SignaturePolicyIdentifier,u=new r;if(u.dEncapContentInfo.setContentValue(t.content),"object"==typeof t.certs)for(var c=0;c0){var t=new n({array:this.extensionsArray}),e=new r({array:[t]}),i=new n({array:[new a({oid:"1.2.840.113549.1.9.14"}),e]}),h=new o({explicit:!0,tag:"a0",obj:i});this.asn1Array.push(h)}else{h=new o({explicit:!1,tag:"a0",obj:new s});this.asn1Array.push(h)}var u=new n({array:this.asn1Array});return this.hTLV=u.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.csr.CertificationRequestInfo,ft.asn1.ASN1Object),ft.asn1.csr.CSRUtil=new function(){},ft.asn1.csr.CSRUtil.newCSRPEM=function(t){var e=Ut,i=ft.asn1.csr;if(void 0===t.subject)throw"parameter subject undefined";if(void 0===t.sbjpubkey)throw"parameter sbjpubkey undefined";if(void 0===t.sigalg)throw"parameter sigalg undefined";if(void 0===t.sbjprvkey)throw"parameter sbjpubkey undefined";var n=new i.CertificationRequestInfo;if(n.setSubjectByParam(t.subject),n.setSubjectPublicKeyByGetKey(t.sbjpubkey),void 0!==t.ext&&void 0!==t.ext.length)for(var r=0;rr)throw"key is too short for SigAlg: keylen="+i+","+e;for(var s="0001",o="00"+n,a="",h=r-s.length-o.length,u=0;u=0)return!1;if(i.compareTo(x.ONE)<0||i.compareTo(r)>=0)return!1;var o=i.modInverse(r),a=t.multiply(o).mod(r),h=e.multiply(o).mod(r);return s.multiply(a).add(n.multiply(h)).getX().toBigInteger().mod(r).equals(e)},this.serializeSig=function(t,e){var i=t.toByteArraySigned(),n=e.toByteArraySigned(),r=[];return r.push(2),r.push(i.length),(r=r.concat(i)).push(2),r.push(n.length),(r=r.concat(n)).unshift(r.length),r.unshift(48),r},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:x.fromByteArrayUnsigned(i),s:x.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:x.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:x.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[2,0],"06"),i=o(t,0,[1],"04");try{n=o(t,0,[3,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#1/5 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{o(t,0,[1,0],"06"),e=o(t,0,[1,1],"06"),i=o(t,0,[2,0,1],"04");try{n=o(t,0,[2,0,2,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#8 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){var e,i,n=pt,r=ft.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{s(t,0,[0,0],"06"),e=s(t,0,[0,1],"06"),i=s(t,0,[1],"03").substr(2)}catch(t){throw"malformed PKCS#8 ECC public key"}if(this.curveName=r(e),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,e){5!==e&&(e=6);var i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{i=o(t,0,[0,e,0,1],"06"),n=o(t,0,[0,e,1],"03").substr(2)}catch(t){throw"malformed X.509 certificate ECC public key"}if(this.curveName=s(i),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ft.crypto.ECDSA.parseSigHex=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new x(e.r,16),s:new x(e.s,16)}},ft.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=pt,i=e.getChildIdx,n=e.getV;if("30"!=t.substr(0,2))throw"signature is not a ASN.1 sequence";var r=i(t,0);if(2!=r.length)throw"number of signature ASN.1 sequence elements seem wrong";var s=r[0],o=r[1];if("02"!=t.substr(s,2))throw"1st item of sequene of signature is not ASN.1 integer";if("02"!=t.substr(o,2))throw"2nd item of sequene of signature is not ASN.1 integer";return{r:n(t,s),s:n(t,o)}},ft.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t),i=e.r,n=e.s;if("00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),i.length%32==30&&(i="00"+i),n.length%32==30&&(n="00"+n),i.length%32!=0)throw"unknown ECDSA sig r length error";if(n.length%32!=0)throw"unknown ECDSA sig s length error";return i+n},ft.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var e=t.substr(0,t.length/2),i=t.substr(t.length/2);return ft.crypto.ECDSA.hexRSSigToASN1Sig(e,i)},ft.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var i=new x(t,16),n=new x(e,16);return ft.crypto.ECDSA.biRSSigToASN1Sig(i,n)},ft.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var i=ft.asn1,n=new i.DERInteger({bigint:t}),r=new i.DERInteger({bigint:e});return new i.DERSequence({array:[n,r]}).getEncodedHex()},ft.crypto.ECDSA.getName=function(t){return"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040022"===t?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":null},void 0!==ft&&ft||(ft={}),void 0!==ft.crypto&&ft.crypto||(ft.crypto={}),ft.crypto.ECParameterDB=new function(){var t={},e={};function i(t){return new x(t,16)}this.getByName=function(i){var n=i;if(void 0!==e[n]&&(n=e[i]),void 0!==t[n])return t[n];throw"unregistered EC curve name: "+n},this.regist=function(n,r,s,o,a,h,u,c,l,f,d,g){t[n]={};var p=i(s),y=i(o),v=i(a),m=i(h),S=i(u),F=new ct(p,y,v),E=F.decodePointHex("04"+c+l);t[n].name=n,t[n].keylen=r,t[n].curve=F,t[n].G=E,t[n].n=m,t[n].h=S,t[n].oid=d,t[n].info=g;for(var w=0;w1?new x(n,16):null,u=new x(r,16),this.setPrivate(s,o,a,h,u)},this.setPublic=function(t,e,i,n){this.isPublic=!0,this.p=t,this.q=e,this.g=i,this.y=n,this.x=null},this.setPublicHex=function(t,e,i,n){var r,s,o,a;r=new x(t,16),s=new x(e,16),o=new x(i,16),a=new x(n,16),this.setPublic(r,s,o,a)},this.signWithMessageHash=function(t){var e=this.p,i=this.q,n=this.g,r=(this.y,this.x),s=ft.crypto.Util.getRandomBigIntegerMinToMax(x.ONE.add(x.ONE),i.subtract(x.ONE)),o=new x(t.substr(0,i.bitLength()/4),16),a=n.modPow(s,e).mod(i),h=s.modInverse(i).multiply(o.add(r.multiply(a))).mod(i);return ft.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:a}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var i=this.p,n=this.q,r=this.g,s=this.y,o=this.parseASN1Signature(e),a=o[0],h=o[1],u=new x(t.substr(0,n.bitLength()/4),16);if(x.ZERO.compareTo(a)>0||a.compareTo(n)>0)throw"invalid DSA signature";if(x.ZERO.compareTo(h)>=0||h.compareTo(n)>0)throw"invalid DSA signature";var c=h.modInverse(n),l=u.multiply(c).mod(n),f=a.multiply(c).mod(n);return 0==r.modPow(l,i).multiply(s.modPow(f,i)).mod(i).mod(n).compareTo(a)},this.parseASN1Signature=function(t){try{return[new x(pt.getVbyList(t,0,[0],"02"),16),new x(pt.getVbyList(t,0,[1],"02"),16)]}catch(t){throw"malformed ASN.1 DSA signature"}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r,s,o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{e=a(t,0,[1],"02"),i=a(t,0,[2],"02"),n=a(t,0,[3],"02"),r=a(t,0,[4],"02"),s=a(t,0,[5],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#1/5 plain DSA private key"}this.setPrivateHex(e,i,n,r,s)},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[1,1,0],"02"),i=o(t,0,[1,1,1],"02"),n=o(t,0,[1,1,2],"02"),r=o(t,0,[2,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 plain DSA private key"}this.setPrivateHex(e,i,n,null,r)},this.readPKCS8PubKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[0,1,0],"02"),i=o(t,0,[0,1,1],"02"),n=o(t,0,[0,1,2],"02"),r=o(t,0,[1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 DSA public key"}this.setPublicHex(e,i,n,r)},this.readCertPubKeyHex=function(t,e){var i,n,r,s;5!==e&&(e=6);var o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{i=a(t,0,[0,e,0,1,0],"02"),n=a(t,0,[0,e,0,1,1],"02"),r=a(t,0,[0,e,0,1,2],"02"),s=a(t,0,[0,e,1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed X.509 certificate DSA public key"}this.setPublicHex(i,n,r,s)}};var Ut=function(){var t=function(t,i,n){return e(y.AES,t,i,n)},e=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=r;var h=t.decrypt(a,s,{iv:o});return y.enc.Hex.stringify(h)},i=function(t,e,i){return n(y.AES,t,e,i)},n=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a=t.encrypt(r,s,{iv:o}),h=y.enc.Hex.parse(a.toString());return y.enc.Base64.stringify(h)},r={"AES-256-CBC":{proc:t,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,i,n){return e(y.TripleDES,t,i,n)},eproc:function(t,e,i){return n(y.TripleDES,t,e,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,i,n){return e(y.DES,t,i,n)},eproc:function(t,e,i){return n(y.DES,t,e,i)},keylen:8,ivlen:8}},s=function(t){var e={},i=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(e.cipher=i[1],e.ivsalt=i[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var r=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(r=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(r=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=r&&-1!=o){var a=t.substring(r+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,i){for(var n=i.substring(0,16),s=y.enc.Hex.parse(n),o=y.enc.Utf8.parse(e),a=r[t].keylen+r[t].ivlen,h="",u=null;;){var c=y.algo.MD5.create();if(null!=u&&c.update(u),c.update(o),c.update(s),u=c.finalize(),(h+=y.enc.Hex.stringify(u)).length>=2*a)break}var l={};return l.keyhex=h.substr(0,2*r[t].keylen),l.ivhex=h.substr(2*r[t].keylen,2*r[t].ivlen),l},a=function(t,e,i,n){var s=y.enc.Base64.parse(t),o=y.enc.Hex.stringify(s);return(0,r[e].proc)(o,i,n)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,i){return o(t,e,i)},decryptKeyB64:function(t,e,i,n){return a(t,e,i,n)},getDecryptedKeyHex:function(t,e){var i=s(t),n=(i.type,i.cipher),r=i.ivsalt,h=i.data,u=o(n,e,r).keyhex;return a(h,n,u,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,i,n,s){var a="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===r[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==s&&null!=s||(s=function(t){var e=y.lib.WordArray.random(t);return y.enc.Hex.stringify(e)}(r[n].ivlen).toUpperCase());var h=function(t,e,i,n){return(0,r[e].eproc)(t,i,n)}(e,n,o(n,i,s).keyhex,s);a="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+n+","+s+"\r\n",a+="\r\n",a+=h.replace(/(.{64})/g,"$1\r\n"),a+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={},s=i(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;r.ciphertext=n(t,s[1]);var o=i(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=i(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var h=i(t,a[1]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length;if("2a864886f70d0307"!=n(t,h[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(t,h[1]);var u=i(t,a[0]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length;if("2a864886f70d01050c"!=n(t,u[0]))throw"this only supports pkcs5PBKDF2";var c=i(t,u[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;r.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{r.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return r},getPBKDF2KeyHexFromParam:function(t,e){var i=y.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,r=y.PBKDF2(e,i,{keySize:6,iterations:n});return y.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var i=Ht(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=Ut.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=y.enc.Hex.parse(n.ciphertext);var o=y.enc.Hex.parse(r),a=y.enc.Hex.parse(n.encryptionSchemeIV),h=y.TripleDES.decrypt(s,o,{iv:a});return y.enc.Hex.stringify(h)},getKeyFromEncryptedPKCS8PEM:function(t,e){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var s=i(t,0);if(3!=s.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(s[1],2))throw"malformed PKCS8 private key(code:003)";var o=i(t,s[1]);if(2!=o.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(o[0],2))throw"malformed PKCS8 private key(code:005)";if(r.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(r.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw"malformed PKCS8 private key(code:006)";return r.keyidx=e.getVidx(t,s[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Ht(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,i=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==i.algoid)e=new ot;else if("2a8648ce380401"==i.algoid)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";e=new ft.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,i=pt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===i)e=new ot;else if("2a8648ce380401"===i)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";e=new ft.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=i(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(r.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return r.e=n(t,s[1]),r},parsePublicPKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null},s=i(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=i(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?r.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(r.algparam={},r.algparam.p=e.getVbyList(t,a[1],[0],"02"),r.algparam.q=e.getVbyList(t,a[1],[1],"02"),r.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(t,s[1]).substr(2),r}}}();Ut.getKey=function(t,e,i){var n=(y=pt).getChildIdx,r=(y.getV,y.getVbyList),s=ft.crypto,o=s.ECDSA,a=s.DSA,h=ot,u=Ht,c=Ut;if(void 0!==h&&t instanceof h)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(t.n,t.e),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(D=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(D=new h).setPrivate(t.n,t.e,t.d),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(D=new a).setPublic(t.p,t.q,t.g,t.y),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(D=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(xt(t.n),xt(t.e)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(D=new h).setPrivateEx(xt(t.n),xt(t.e),xt(t.d),xt(t.p),xt(t.q),xt(t.dp),xt(t.dq),xt(t.qi)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(D=new h).setPrivate(xt(t.n),xt(t.e),xt(t.d)),D;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);return C.setPublicKeyHex(f),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);var d=("0000000000"+xt(t.d)).slice(-l);return C.setPublicKeyHex(f),C.setPrivateKeyHex(d),C}if("pkcs5prv"===i){var g,p=t,y=pt;if(9===(g=n(p,0)).length)(D=new h).readPKCS5PrvKeyHex(p);else if(6===g.length)(D=new a).readPKCS5PrvKeyHex(p);else{if(!(g.length>2&&"04"===p.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(D=new o).readPKCS5PrvKeyHex(p)}return D}if("pkcs8prv"===i)return D=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===i)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===i)return Jt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Jt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=Ht(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=u(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=r(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),F=r(R,0,[2],"02"),E=r(R,0,[3],"02"),w=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(E,16),new x(w,16),new x(b,16)),D}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var A=c.getDecryptedKeyHex(t,e),I=new ot;return I.readPKCS5PrvKeyHex(A),I}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var C,D=r(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),T=r(R,0,[2,0],"06"),P=r(R,0,[3,0],"03").substr(2);if(void 0===ft.crypto.OID.oidhex2name[T])throw"undefined OID(hex) in KJUR.crypto.OID: "+T;return(C=new o({curve:ft.crypto.OID.oidhex2name[T]})).setPublicKeyHex(P),C.setPrivateKeyHex(D),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;S=r(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),F=r(R,0,[2],"02"),E=r(R,0,[3],"02"),w=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(E,16),new x(w,16),new x(b,16)),D}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw"not supported argument"},Ut.generateKeypair=function(t,e){if("RSA"==t){var i=e;(o=new ot).generate(i,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new ot,r=o.n.toString(16),s=o.e.toString(16);return n.setPublic(r,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,h=e,u=new ft.crypto.ECDSA({curve:h}).generateKeyPairHex();return(o=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),o.setPrivateKeyHex(u.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Ut.getPEM=function(t,e,i,n,r,s){var o=ft,a=o.asn1,h=a.DERObjectIdentifier,u=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,f=o.crypto,d=f.DSA,g=f.ECDSA,p=ot;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function S(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==p&&t instanceof p||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Rt(x=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=v(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===i||null==i)&&1==t.isPrivate){var F=new h({name:t.curveName}).getEncodedHex(),E=m(t).getEncodedHex(),w="";return w+=Rt(F,"EC PARAMETERS"),w+=Rt(E,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=S(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==i&&null!=i&&1==t.isPrivate){var x=v(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==i&&null!=i&&1==t.isPrivate){x=m(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==i&&null!=i&&1==t.isPrivate){x=S(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",x,i,n,s)}var b=function(t,e){var i=A(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},A=function(t,e){var i=y.lib.WordArray.random(8),n=y.lib.WordArray.random(8),r=y.PBKDF2(e,i,{keySize:6,iterations:100}),s=y.enc.Hex.parse(t),o=y.TripleDES.encrypt(s,r,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=y.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=y.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=p&&t instanceof p&&1==t.isPrivate){var I=v(t).getEncodedHex();x=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){I=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){I=new u({bigint:t.x}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=b(x,i),"ENCRYPTED PRIVATE KEY")}throw"unsupported object nor format"},Ut.getKeyFromCSRPEM=function(t){var e=Ht(t,"CERTIFICATE REQUEST");return Ut.getKeyFromCSRHex(e)},Ut.getKeyFromCSRHex=function(t){var e=Ut.parseCSRHex(t);return Ut.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Ut.parseCSRHex=function(t){var e=pt,i=e.getChildIdx,n=e.getTLV,r={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=i(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=i(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(s,a[2]),r},Ut.getJWKFromKey=function(t){var e={};if(t instanceof ot&&t.isPrivate)return e.kty="RSA",e.n=wt(t.n.toString(16)),e.e=wt(t.e.toString(16)),e.d=wt(t.d.toString(16)),e.p=wt(t.p.toString(16)),e.q=wt(t.q.toString(16)),e.dp=wt(t.dmp1.toString(16)),e.dq=wt(t.dmq1.toString(16)),e.qi=wt(t.coeff.toString(16)),e;if(t instanceof ot&&t.isPublic)return e.kty="RSA",e.n=wt(t.n.toString(16)),e.e=wt(t.e.toString(16)),e;if(t instanceof ft.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=wt(i.x),e.y=wt(i.y),e.d=wt(t.prvKeyHex),e}if(t instanceof ft.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=wt(i.x),e.y=wt(i.y),e}throw"not supported key object"},ot.getPosArrayOfChildrenFromHex=function(t){return pt.getChildIdx(t,0)},ot.getHexValueArrayOfChildrenFromHex=function(t){var e,i=pt.getV,n=i(t,(e=ot.getPosArrayOfChildrenFromHex(t))[0]),r=i(t,e[1]),s=i(t,e[2]),o=i(t,e[3]),a=i(t,e[4]),h=i(t,e[5]),u=i(t,e[6]),c=i(t,e[7]),l=i(t,e[8]);return(e=new Array).push(n,r,s,o,a,h,u,c,l),e},ot.prototype.readPrivateKeyFromPEMString=function(t){var e=Ht(t),i=ot.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},ot.prototype.readPKCS5PrvKeyHex=function(t){var e=ot.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},ot.prototype.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s,o,a,h,u=pt,c=u.getVbyList;if(!1===u.isASN1HEX(t))throw"not ASN.1 hex string";try{e=c(t,0,[2,0,1],"02"),i=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),r=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw"malformed PKCS#8 plain RSA private key"}this.setPrivateEx(e,i,n,r,s,o,a,h)},ot.prototype.readPKCS5PubKeyHex=function(t){var e=pt,i=e.getV;if(!1===e.isASN1HEX(t))throw"keyHex is not ASN.1 hex string";var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw"wrong hex for PKCS#5 public key";var r=i(t,n[0]),s=i(t,n[1]);this.setPublic(r,s)},ot.prototype.readPKCS8PubKeyHex=function(t){var e=pt;if(!1===e.isASN1HEX(t))throw"not ASN.1 hex string";if("06092a864886f70d010101"!==e.getTLVbyList(t,0,[0,0]))throw"not PKCS8 RSA public key";var i=e.getTLVbyList(t,0,[1,0]);this.readPKCS5PubKeyHex(i)},ot.prototype.readCertPubKeyHex=function(t,e){var i,n;(i=new Jt).readCertHex(t),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var qt=new RegExp("");function zt(t,e){for(var i="",n=e/4-t.length,r=0;r>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function Yt(t){for(var e in ft.crypto.Util.DIGESTINFOHEAD){var i=ft.crypto.Util.DIGESTINFOHEAD[e],n=i.length;if(t.substring(0,n)==i)return[e,t.substring(n)]}return[]}function Jt(){var t=pt,e=t.getChildIdx,i=t.getV,n=t.getTLV,r=t.getVbyList,s=t.getTLVbyList,o=t.getIdxbyList,a=t.getVidx,h=t.oidname,u=Jt,c=Ht;this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){return null===this.hex||0!==this.version?this.version:"a003020102"!==s(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return r(this.hex,0,[0,1+this.foffset],"02")},this.getSignatureAlgorithmField=function(){return h(r(this.hex,0,[0,2+this.foffset,0],"06"))},this.getIssuerHex=function(){return s(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return u.hex2dn(this.getIssuerHex())},this.getSubjectHex=function(){return s(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return u.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=r(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=r(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return t.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return o(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return o(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Ut.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){return h(r(this.hex,0,[1,0],"06"))},this.getSignatureValueHex=function(){return r(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmName(),i=this.getSignatureValueHex(),n=s(this.hex,0,[0],"30"),r=new ft.crypto.Signature({alg:e});return r.init(t),r.updateHex(n),r.verify(i)},this.parseExt=function(){if(3!==this.version)return-1;var i=o(this.hex,0,[0,7,0],"30"),n=e(this.hex,i);this.aExtInfo=new Array;for(var s=0;s0&&(u=new Array(i),(new nt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=It(h(Ct("\0\0\0\0\0\0\0\0"+r+u))),l=[];for(n=0;n>8*a-o&255;for(g[0]&=~p,n=0;nthis.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;var r=n[0];return n[1]==function(t){return ft.crypto.Util.hashString(t,r)}(t)},ot.prototype.verifyWithMessageHash=function(t,e){var i=rt(e=(e=e.replace(qt,"")).replace(/[ \n]+/g,""),16);if(i.bitLength()>this.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;n[0];return n[1]==t},ot.prototype.verifyPSS=function(t,e,i,n){var r,s=(r=Ct(t),ft.crypto.Util.hashHex(r,i));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(s,e,i,n)},ot.prototype.verifyWithMessageHashPSS=function(t,e,i,n){var r=new x(e,16);if(r.bitLength()>this.n.bitLength())return!1;var s,o=function(t){return ft.crypto.Util.hashHex(t,i)},a=It(t),h=a.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===n||void 0===n)n=h;else if(-2===n)n=c-h-2;else if(n<-2)throw"invalid salt length";if(c>8*c-u&255;if(0!=(f.charCodeAt(0)&g))throw"bits beyond keysize not zero";var p=Gt(d,f.length,o),y=[];for(s=0;s0)&&-1==(":"+i.join(":")+":").indexOf(":"+p+":"))throw"algorithm '"+p+"' not accepted in the list";if("none"!=p&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Ut.getKey(e)),!("RS"!=y&&"PS"!=y||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==y&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===s.jwsalg2sigalg[g.alg])throw"unsupported alg name: "+p;if("none"==(v=s.jwsalg2sigalg[p]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var S,F=null;try{F=h.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(F)}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(d)},ft.jws.JWS.parse=function(t){var e,i,n,r=t.split("."),s={};if(2!=r.length&&3!=r.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=r[0],i=r[1],3==r.length&&(n=r[2]),s.headerObj=ft.jws.JWS.readSafeJSONString(gt(e)),s.payloadObj=ft.jws.JWS.readSafeJSONString(gt(i)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=gt(i):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==n&&(s.sigHex=xt(n)),s},ft.jws.JWS.verifyJWT=function(t,e,i){var n=ft.jws,r=n.JWS,s=r.readSafeJSONString,o=r.inArray,a=r.includedArray,h=t.split("."),u=h[0],c=h[1],l=(xt(h[2]),s(gt(u))),f=s(gt(c));if(void 0===l.alg)return!1;if(void 0===i.alg)throw"acceptField.alg shall be specified";if(!o(l.alg,i.alg))return!1;if(void 0!==f.iss&&"object"==typeof i.iss&&!o(f.iss,i.iss))return!1;if(void 0!==f.sub&&"object"==typeof i.sub&&!o(f.sub,i.sub))return!1;if(void 0!==f.aud&&"object"==typeof i.aud)if("string"==typeof f.aud){if(!o(f.aud,i.aud))return!1}else if("object"==typeof f.aud&&!a(f.aud,i.aud))return!1;var d=n.IntDate.getNow();return void 0!==i.verifyAt&&"number"==typeof i.verifyAt&&(d=i.verifyAt),void 0!==i.gracePeriod&&"number"==typeof i.gracePeriod||(i.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+i.gracePeriodr&&this.aHeader.pop(),this.aSignature.length>r&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignatures=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},e.SecureRandom=nt,e.rng_seed_time=Z,e.BigInteger=x,e.RSAKey=ot,e.ECDSA=ft.crypto.ECDSA,e.DSA=ft.crypto.DSA,e.Signature=ft.crypto.Signature,e.MessageDigest=ft.crypto.MessageDigest,e.Mac=ft.crypto.Mac,e.Cipher=ft.crypto.Cipher,e.KEYUTIL=Ut,e.ASN1HEX=pt,e.X509=Jt,e.CryptoJS=y,e.b64tohex=E,e.b64toBA=w,e.stoBA=yt,e.BAtos=vt,e.BAtohex=mt,e.stohex=St,e.stob64=function(t){return F(St(t))},e.stob64u=function(t){return Ft(F(St(t)))},e.b64utos=function(t){return vt(w(Et(t)))},e.b64tob64u=Ft,e.b64utob64=Et,e.hex2b64=F,e.hextob64u=wt,e.b64utohex=xt,e.utf8tob64u=dt,e.b64utoutf8=gt,e.utf8tob64=function(t){return F(Ot(Kt(t)))},e.b64toutf8=function(t){return decodeURIComponent(jt(E(t)))},e.utf8tohex=bt,e.hextoutf8=At,e.hextorstr=It,e.rstrtohex=Ct,e.hextob64=Dt,e.hextob64nl=Tt,e.b64nltohex=Pt,e.hextopem=Rt,e.pemtohex=Ht,e.hextoArrayBuffer=function(t){if(t.length%2!=0)throw"input is not even length";if(null==t.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var e=new ArrayBuffer(t.length/2),i=new DataView(e),n=0;ne.length&&(i=e.length);for(var n=0;n300)throw new r(`Failed to fetch ${t}. Response=${s}`,i.status);try{return JSON.parse(s)}catch(e){if(""!==s)return s;throw new r(`Invalid response while trying to fetch ${t}. Response=${s}`,i.status,e)}}}},function(t,e,i){const n=i(5),r=i(3),s=i(16),o=i(18),a=i(20),h=i(1),u=i(2),c=i(0);t.exports=class{constructor({popup:t=new s,iframe:e=new o,openIdConfigResource:i=new a,utils:h,requestHandler:u=new r,w:l=window,url:f=URL}={}){this.popup=t,this.iframe=e,this.openIdConfigResource=i,this.URL=f,this.utils=h,h||(this.utils=new n({openIdConfigResource:this.openIdConfigResource,url:this.URL,popup:this.popup,jsrsasign:c})),this.request=u.request,this.window=l,this.initialized=!1}async init({clientId:t,discoveryEndpoint:e,popup:i={height:.8*window.screen.height,width:400}}){if(!t)throw new u(h.MISSING_CLIENT_ID);try{new this.URL(e)}catch(t){throw new u(h.INVALID_DISCOVERY_ENDPOINT)}await this.openIdConfigResource.init({discoveryEndpoint:e,requestHandler:this.request}),this.popup.init(i),this.clientId=t,this.initialized=!0}async signin(){this._validateInitalize();const t=this.openIdConfigResource.getAuthorizationEndpoint();return this.utils.performOAuthFlowAndGetTokens({origin:this.window.origin,clientId:this.clientId,endpoint:t})}async silentSignin(){this._validateInitalize();const t=this.openIdConfigResource.getAuthorizationEndpoint(),{codeVerifier:e,nonce:i,state:n,url:r}=this.utils.getAuthParamsAndUrl({clientId:this.clientId,origin:this.window.origin,prompt:h.PROMPT,endpoint:t});let s;this.iframe.open(r);try{s=await this.iframe.waitForMessage({messageType:"authorization_response"})}finally{this.iframe.remove()}this.utils.verifyMessage({message:s,state:n});let o=s.data.code;return await this.utils.retrieveTokens({clientId:this.clientId,authCode:o,codeVerifier:e,nonce:i,openId:this.openIdConfigResource,windowOrigin:this.window.origin})}async getUserInfo(t){if(this._validateInitalize(),"string"!=typeof t)throw new u(h.INVALID_ACCESS_TOKEN);return await this.request(this.openIdConfigResource.getUserInfoEndpoint(),{headers:{Authorization:"Bearer "+t}})}async changePassword(t){let e;if(this._validateInitalize(),!t)throw new u(h.MISSING_ID_TOKEN_PAYLOAD);if("string"==typeof t)throw new u(h.INVALID_ID_TOKEN_PAYLOAD);if(!(t.identities&&t.identities[0]&&t.identities[0].id))throw new u(h.INVALID_ID_TOKEN_PAYLOAD);if("cloud_directory"!==t.identities[0].provider)throw new u(h.NOT_CD_USER);e=t.identities[0].id;const i=this.openIdConfigResource.getIssuer()+h.CHANGE_PASSWORD;return this.utils.performOAuthFlowAndGetTokens({userId:e,origin:this.window.origin,clientId:this.clientId,endpoint:i})}async changeDetails(t){if(!t)throw new u(h.MISSING_TOKENS);if(!t.accessToken&&"string"!=typeof t.accessToken)throw new u(h.MISSING_ACCESS_TOKEN);if(!t.idToken&&"string"!=typeof t.idToken)throw new u(h.MISSING_ID_TOKEN);const e=this.openIdConfigResource.getIssuer()+h.GENERATE_CODE,i=await this.request(e,{headers:{Authorization:"Bearer "+t.accessToken+" "+t.idToken}}),n=this.openIdConfigResource.getIssuer()+h.CHANGE_DETAILS;return this.utils.performOAuthFlowAndGetTokens({origin:this.window.origin,clientId:this.clientId,endpoint:n,changeDetailsCode:i})}_validateInitalize(){if(!this.initialized)throw new u(h.FAIL_TO_INITIALIZE)}}},function(t,e,i){i(0);const n=i(2),r=i(11),s=i(3),o=i(14),a=i(1);t.exports=class{constructor({requestHandler:t=new s,tokenValidator:e=new o,url:i=URL,openIdConfigResource:n,popup:r,jsrsasign:a=a}={}){this.URL=i,this.request=t.request,this.tokenValidator=e,this.openIdConfigResource=n,this.popup=r,this.rs=a}buildParams(t){return Object.keys(t).map((function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])})).join("&")}getRandomString(t){return this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(t/2)}sha256(t){return this.rs.KJUR.crypto.Util.sha256(t)}getPKCEFields(){const t=this.getRandomString(a.CODE_VERIFIER_LENGTH);return{codeVerifier:t,codeChallenge:this.sha256(t),state:this.getRandomString(a.STATE_LENGTH),nonce:this.getRandomString(a.NONCE_LENGTH)}}getAuthParamsAndUrl({clientId:t,origin:e,prompt:i,endpoint:n,userId:r,changeDetailsCode:s}){const{codeVerifier:o,codeChallenge:h,state:u,nonce:c}=this.getPKCEFields();let l={client_id:t,response_type:a.RESPONSE_TYPE,state:this.rs.stob64(u),code_challenge:this.rs.stob64(h),code_challenge_method:a.CHALLENGE_METHOD,redirect_uri:e,response_mode:a.RESPONSE_MODE,nonce:c,scope:a.SCOPE};return i&&(l.prompt=i),r&&(l.user_id=r),s&&(l.code=s),{codeVerifier:o,nonce:c,state:u,url:n+"?"+this.buildParams(l)}}async performOAuthFlowAndGetTokens({userId:t,origin:e,clientId:i,endpoint:n,changeDetailsCode:r}){const{codeVerifier:s,state:o,nonce:a,url:h}=this.getAuthParamsAndUrl({userId:t,origin:e,clientId:i,endpoint:n,changeDetailsCode:r});this.popup.open(),this.popup.navigate(h);const u=await this.popup.waitForMessage({messageType:"authorization_response"});this.popup.close(),this.verifyMessage({message:u,state:o});let c=u.data.code;return await this.retrieveTokens({clientId:i,authCode:c,codeVerifier:s,nonce:a,windowOrigin:e})}verifyMessage({message:t,state:e}){if(t.data.error||t.data.error_description)throw new r({description:t.data.error_description,error:t.data.error});if(this.rs.b64utos(t.data.state)!==e)throw new n(a.INVALID_STATE);if(t.origin!==new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin)throw new n(a.INVALID_ORIGIN)}async retrieveTokens({clientId:t,authCode:e,nonce:i,codeVerifier:n,windowOrigin:r}){let s=this.openIdConfigResource.getIssuer(),o={grant_type:"authorization_code",redirect_uri:r,code:e,code_verifier:n};const a=this.buildParams(o),h=this.openIdConfigResource.getTokenEndpoint(),u=await this.request(h,{method:"POST",headers:{Authorization:"Basic "+this.rs.stob64(`${t}:${n}`),"Content-Type":"application/x-www-form-urlencoded"},body:a}),c=await this.openIdConfigResource.getPublicKeys(),l=this.tokenValidator.decodeAndValidate({token:u.access_token,publicKeys:c,issuer:s,clientId:t,nonce:i}),f=this.tokenValidator.decodeAndValidate({token:u.id_token,publicKeys:c,issuer:s,clientId:t,nonce:i});return{accessToken:u.access_token,accessTokenPayload:l,idToken:u.id_token,idTokenPayload:f}}}},function(t,e,i){"use strict";(function(t){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +var n=i(8),r=i(9),s=i(10);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return A(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function A(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return E(this,t,e,i);case"latin1":case"binary":return w(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function B(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||N(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(7))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e,i){const n=i(1),r=i(15);t.exports=class{constructor({jwt:t=i(0)}={}){this.jwt=t}decodeAndValidate({token:t,publicKeys:e,issuer:i,clientId:s,nonce:o}){const a=Math.floor(Date.now()/1e3),h=t.split(".");if(3!==h.length)throw new r(`Invalid JWT token. Got only ${h.length} parts.`);const u=this.jwt.KJUR.jws.JWS.parse(t);if(!u.headerObj)throw new r(n.INVALID_TOKEN);const c=u.headerObj.kid,l=this.getPublicKey(e.keys,c),f=this.jwt.KEYUTIL.getKey(l);if(!this.jwt.KJUR.jws.JWS.verify(t,f,{alg:[n.TOKEN_ALG]}))throw new r(n.INVALID_SIGNATURE);if(u.payloadObj.exp{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(21);t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t);const i={"x-filter-type":`spa:v${n.version}`};this.publicKeys=e(this.getJwksEndpoint(),{headers:i})}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}},function(t){t.exports=JSON.parse('{"name":"ibmcloud-appid-js","version":"0.0.2","description":"IBM Cloud App ID SDK for Single Page Applications","scripts":{"build":"webpack","test":"mocha","coverage":"nyc --reporter=lcov mocha","docs":"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git"},"main":"dist/appid.umd.min.js","nyc":{"all":true,"include":["src/*.js"],"exclude":["**/PopupController.js","**/IFrameController.js","**/OpenIDConfigurationResource.js","**/constants.js"]},"dependencies":{"jsrsasign":"^8.0.12"},"devDependencies":{"node-fetch":"^2.6.0","@babel/cli":"^7.0.0","@babel/core":"^7.5.5","@babel/plugin-transform-runtime":"^7.5.5","@babel/preset-env":"^7.5.5","babel-cli":"^7.0.0-beta.3","chai":"^4.2.0","coveralls":"^3.0.6","gulp-babel":"^8.0.0","mocha":"^6.2.0","nyc":"^14.1.1","webpack":"^4.39.1","webpack-cli":"^3.3.6","docdash":"^1.1.1","jsdoc":"^3.6.3"}}')}])})); \ No newline at end of file diff --git a/src/constants.js b/src/constants.js index b5d2bd7..1fa6dac 100644 --- a/src/constants.js +++ b/src/constants.js @@ -16,6 +16,9 @@ module.exports = { NOT_CD_USER: 'Must be a Cloud Directory user', MISSING_CLIENT_ID: 'Missing client ID', MISSING_ID_TOKEN_PAYLOAD: 'Missing id token payload', + MISSING_TOKENS: 'Missing tokens object', + MISSING_ACCESS_TOKEN: 'Missing access token string', + MISSING_ID_TOKEN: 'Missing access token string', INVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint', FAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.', RESPONSE_TYPE: 'code', diff --git a/src/index.js b/src/index.js index 84dcfb3..bebebb5 100644 --- a/src/index.js +++ b/src/index.js @@ -205,10 +205,32 @@ class AppID { }); } + /** + * This method will open a popup to the change details widget for Cloud Directory users. + * You must enable users to manage their account from your app in Cloud Directory settings. + * @param {Object} tokens App ID tokens + * @returns {Promise} + * @throws {AppIDError} "Missing id token string" + * @throws {AppIDError} "Missing access token string" + * @throws {AppIDError} "Missing tokens object" + * @example + * let tokens = {accessToken, idToken} + * let newTokens = await appID.changeDetails(tokens); + */ async changeDetails(tokens) { - // get code + if (!tokens) { + throw new AppIDError(constants.MISSING_TOKENS); + } + + if (!tokens.accessToken && typeof tokens.accessToken !== 'string') { + throw new AppIDError(constants.MISSING_ACCESS_TOKEN); + } + + if (!tokens.idToken && typeof tokens.idToken !== 'string') { + throw new AppIDError(constants.MISSING_ID_TOKEN); + } + const generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE; - console.log(generateCodeUrl); const changeDetailsCode = await this.request(generateCodeUrl, { headers: { 'Authorization': 'Bearer ' + tokens.accessToken + ' ' + tokens.idToken @@ -216,7 +238,6 @@ class AppID { }); const endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS; - // send code with url return this.utils.performOAuthFlowAndGetTokens({ origin: this.window.origin, clientId: this.clientId, From f17654b6b81c60e080d48590d36911e47a4b44c4 Mon Sep 17 00:00:00 2001 From: Joyce Huang Date: Fri, 25 Oct 2019 16:32:29 -0500 Subject: [PATCH 3/9] temp --- dist/appid.min.js | 385 ++++++++++++++++++++++++++++++++++------ dist/appid.umd.min.js | 395 ++++++++++++++++++++++++++++++++++++------ src/TokenValidator.js | 7 +- src/index.js | 3 +- 4 files changed, 686 insertions(+), 104 deletions(-) diff --git a/dist/appid.min.js b/dist/appid.min.js index cd99209..7e8958f 100644 --- a/dist/appid.min.js +++ b/dist/appid.min.js @@ -1,50 +1,335 @@ -var AppID=function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=4)}([function(t,e,i){(function(t){var i={userAgent:!1},n={}; -/*! -Copyright (c) 2011, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.9.0 -*/ -if(void 0===r)var r={};r.lang={extend:function(t,e,n){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),n){var s;for(s in n)t.prototype[s]=n[s];var o=function(){},a=["toString","valueOf"];try{/MSIE/.test(i.userAgent)&&(o=function(t,e){for(s=0;s>>2]>>>24-s%4*8&255;e[n+s>>>2]|=o<<24-(n+s)%4*8}else for(s=0;s>>2]=i[s>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=s.ceil(e/4)},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i>>2]>>>24-r%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new u.init(i,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,i=t.sigBytes,n=[],r=0;r>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new u.init(i,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},g=a.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,n=e.sigBytes,r=this.blockSize,o=n/(4*r),a=(o=t?s.ceil(o):s.max((0|o)-this._minBufferSize,0))*r,h=s.min(4*a,n);if(a){for(var c=0;c>>2]}},e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:h,padding:c}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(h=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?n.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=n.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:i})}},e.SerializableCipher=i.extend({cfg:i.extend({format:h}),encrypt:function(t,e,i,n){n=this.cfg.extend(n);var r=t.createEncryptor(i,n);return e=r.finalize(e),r=r.cfg,l.create({ciphertext:e,key:i,iv:r.iv,algorithm:t,mode:r.mode,padding:r.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(i,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,i,r){return r||(r=n.random(8)),t=o.create({keySize:e+i}).compute(t,r),i=n.create(t.words.slice(e),4*i),t.sigBytes=4*e,l.create({key:t,iv:i,salt:r})}},g=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:d}),encrypt:function(t,e,i,n){return i=(n=this.cfg.extend(n)).kdf.execute(i,t.keySize,t.ivSize),n.iv=i.iv,(t=f.encrypt.call(this,t,e,i.key,n)).mixIn(i),t},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),i=n.kdf.execute(i,t.keySize,t.ivSize,e.salt),n.iv=i.iv,f.decrypt.call(this,t,e,i.key,n)}})}(),function(){for(var t=y,e=t.lib.BlockCipher,i=t.algo,n=[],r=[],s=[],o=[],a=[],h=[],u=[],c=[],l=[],f=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var p=0,v=0;for(g=0;256>g;g++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;n[p]=m,r[m]=p;var S=d[p],F=d[S],E=d[F],w=257*d[m]^16843008*m;s[p]=w<<24|w>>>8,o[p]=w<<16|w>>>16,a[p]=w<<8|w>>>24,h[p]=w,w=16843009*E^65537*F^257*S^16843008*p,u[m]=w<<24|w>>>8,c[m]=w<<16|w>>>16,l[m]=w<<8|w>>>24,f[m]=w,p?(p=S^d[d[d[E^S]]],v^=d[d[v]]):p=v=1}var x=[0,1,2,4,8,16,32,64,128,27,54];i=i.AES=e.extend({_doReset:function(){for(var t=(i=this._key).words,e=i.sigBytes/4,i=4*((this._nRounds=e+6)+1),r=this._keySchedule=[],s=0;s>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o]):(o=n[(o=o<<8|o>>>24)>>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o],o^=x[s/e|0]<<24),r[s]=r[s-e]^o}for(t=this._invKeySchedule=[],e=0;ee||4>=s?o:u[n[o>>>24]]^c[n[o>>>16&255]]^l[n[o>>>8&255]]^f[n[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,o,a,h,n)},decryptBlock:function(t,e){var i=t[e+1];t[e+1]=t[e+3],t[e+3]=i,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,r),i=t[e+1],t[e+1]=t[e+3],t[e+3]=i},_doCryptBlock:function(t,e,i,n,r,s,o,a){for(var h=this._nRounds,u=t[e]^i[0],c=t[e+1]^i[1],l=t[e+2]^i[2],f=t[e+3]^i[3],d=4,g=1;g>>24]^r[c>>>16&255]^s[l>>>8&255]^o[255&f]^i[d++],y=n[c>>>24]^r[l>>>16&255]^s[f>>>8&255]^o[255&u]^i[d++],v=n[l>>>24]^r[f>>>16&255]^s[u>>>8&255]^o[255&c]^i[d++];f=n[f>>>24]^r[u>>>16&255]^s[c>>>8&255]^o[255&l]^i[d++],u=p,c=y,l=v}p=(a[u>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&f])^i[d++],y=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[f>>>8&255]<<8|a[255&u])^i[d++],v=(a[l>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[255&c])^i[d++],f=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^i[d++],t[e]=p,t[e+1]=y,t[e+2]=v,t[e+3]=f},keySize:8});t.AES=e._createHelper(i)}(),function(){function t(t,e){var i=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=i,this._lBlock^=i<>>t^this._lBlock)&e;this._lBlock^=i,this._rBlock^=i<i;i++){var n=o[i]-1;e[i]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;16>n;n++){var r=t[n]=[],s=h[n];for(i=0;24>i;i++)r[i/6|0]|=e[(a[i]-1+s)%28]<<31-i%6,r[4+(i/6|0)]|=e[28+(a[i+24]-1+s)%28]<<31-i%6;for(r[0]=r[0]<<1|r[0]>>>31,i=1;7>i;i++)r[i]>>>=4*(i-1)+3;r[7]=r[7]<<5|r[7]>>>27}for(e=this._invSubKeys=[],i=0;16>i;i++)e[i]=t[15-i]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(i,n,r){this._lBlock=i[n],this._rBlock=i[n+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var o=r[s],a=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^o[f])&c[f])>>>0];this._lBlock=h,this._rBlock=a^l}r=this._lBlock,this._lBlock=this._rBlock,this._rBlock=r,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),i[n]=this._lBlock,i[n+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});i.DES=r._createHelper(l),s=s.TripleDES=r.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(n.create(t.slice(0,2))),this._des2=l.createEncryptor(n.create(t.slice(2,4))),this._des3=l.createEncryptor(n.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),i.TripleDES=r._createHelper(s)}(),function(){var t=y,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,i=t.sigBytes,n=this._map;t.clamp(),t=[];for(var r=0;r>>2]>>>24-r%4*8&255)<<16|(e[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|e[r+2>>>2]>>>24-(r+2)%4*8&255,o=0;4>o&&r+.75*o>>6*(3-o)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var i=t.length,n=this._map;(r=n.charAt(64))&&(-1!=(r=t.indexOf(r))&&(i=r));for(var r=[],s=0,o=0;o>>6-o%4*2;r[s>>>2]|=(a|h)<<24-s%4*8,s++}return e.create(r,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,i,n,r,s,o){return((t=t+(e&i|~e&n)+r+o)<>>32-s)+e}function i(t,e,i,n,r,s,o){return((t=t+(e&n|i&~n)+r+o)<>>32-s)+e}function n(t,e,i,n,r,s,o){return((t=t+(e^i^n)+r+o)<>>32-s)+e}function r(t,e,i,n,r,s,o){return((t=t+(i^(e|~n))+r+o)<>>32-s)+e}for(var s=y,o=(h=s.lib).WordArray,a=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var o=0;16>o;o++){var a=t[h=s+o];t[h]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var h=t[s+0],c=(a=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],d=t[s+5],g=t[s+6],p=t[s+7],y=t[s+8],v=t[s+9],m=t[s+10],S=t[s+11],F=t[s+12],E=t[s+13],w=t[s+14],x=t[s+15],A=e(A=o[0],C=o[1],I=o[2],b=o[3],h,7,u[0]),b=e(b,A,C,I,a,12,u[1]),I=e(I,b,A,C,c,17,u[2]),C=e(C,I,b,A,l,22,u[3]);A=e(A,C,I,b,f,7,u[4]),b=e(b,A,C,I,d,12,u[5]),I=e(I,b,A,C,g,17,u[6]),C=e(C,I,b,A,p,22,u[7]),A=e(A,C,I,b,y,7,u[8]),b=e(b,A,C,I,v,12,u[9]),I=e(I,b,A,C,m,17,u[10]),C=e(C,I,b,A,S,22,u[11]),A=e(A,C,I,b,F,7,u[12]),b=e(b,A,C,I,E,12,u[13]),I=e(I,b,A,C,w,17,u[14]),A=i(A,C=e(C,I,b,A,x,22,u[15]),I,b,a,5,u[16]),b=i(b,A,C,I,g,9,u[17]),I=i(I,b,A,C,S,14,u[18]),C=i(C,I,b,A,h,20,u[19]),A=i(A,C,I,b,d,5,u[20]),b=i(b,A,C,I,m,9,u[21]),I=i(I,b,A,C,x,14,u[22]),C=i(C,I,b,A,f,20,u[23]),A=i(A,C,I,b,v,5,u[24]),b=i(b,A,C,I,w,9,u[25]),I=i(I,b,A,C,l,14,u[26]),C=i(C,I,b,A,y,20,u[27]),A=i(A,C,I,b,E,5,u[28]),b=i(b,A,C,I,c,9,u[29]),I=i(I,b,A,C,p,14,u[30]),A=n(A,C=i(C,I,b,A,F,20,u[31]),I,b,d,4,u[32]),b=n(b,A,C,I,y,11,u[33]),I=n(I,b,A,C,S,16,u[34]),C=n(C,I,b,A,w,23,u[35]),A=n(A,C,I,b,a,4,u[36]),b=n(b,A,C,I,f,11,u[37]),I=n(I,b,A,C,p,16,u[38]),C=n(C,I,b,A,m,23,u[39]),A=n(A,C,I,b,E,4,u[40]),b=n(b,A,C,I,h,11,u[41]),I=n(I,b,A,C,l,16,u[42]),C=n(C,I,b,A,g,23,u[43]),A=n(A,C,I,b,v,4,u[44]),b=n(b,A,C,I,F,11,u[45]),I=n(I,b,A,C,x,16,u[46]),A=r(A,C=n(C,I,b,A,c,23,u[47]),I,b,h,6,u[48]),b=r(b,A,C,I,p,10,u[49]),I=r(I,b,A,C,w,15,u[50]),C=r(C,I,b,A,d,21,u[51]),A=r(A,C,I,b,F,6,u[52]),b=r(b,A,C,I,l,10,u[53]),I=r(I,b,A,C,m,15,u[54]),C=r(C,I,b,A,a,21,u[55]),A=r(A,C,I,b,y,6,u[56]),b=r(b,A,C,I,x,10,u[57]),I=r(I,b,A,C,g,15,u[58]),C=r(C,I,b,A,E,21,u[59]),A=r(A,C,I,b,f,6,u[60]),b=r(b,A,C,I,S,10,u[61]),I=r(I,b,A,C,c,15,u[62]),C=r(C,I,b,A,v,21,u[63]);o[0]=o[0]+A|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+b|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;i[r>>>5]|=128<<24-r%32;var s=t.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(i.length+1),this._process(),i=(e=this._hash).words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=a._createHelper(h),s.HmacMD5=a._createHmacHelper(h)}(Math),function(){var t=y,e=(r=t.lib).WordArray,i=r.Hasher,n=[],r=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=this._hash.words,r=i[0],s=i[1],o=i[2],a=i[3],h=i[4],u=0;80>u;u++){if(16>u)n[u]=0|t[e+u];else{var c=n[u-3]^n[u-8]^n[u-14]^n[u-16];n[u]=c<<1|c>>>31}c=(r<<5|r>>>27)+h+n[u],c=20>u?c+(1518500249+(s&o|~s&a)):40>u?c+(1859775393+(s^o^a)):60>u?c+((s&o|s&a|o&a)-1894007588):c+((s^o^a)-899497514),h=a,a=o,o=s<<30|s>>>2,s=r,r=c}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+o|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(i/4294967296),e[15+(n+64>>>9<<4)]=i,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=i._createHelper(r),t.HmacSHA1=i._createHmacHelper(r)}(),function(t){for(var e=y,i=(r=e.lib).WordArray,n=r.Hasher,r=e.algo,s=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=a(t.pow(h,.5))),o[u]=a(t.pow(h,1/3)),u++),h++}var d=[];r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(t,e){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],a=i[3],h=i[4],u=i[5],c=i[6],l=i[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var g=d[f-15],p=d[f-2];d[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[f-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[f-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+o[f]+d[f],p=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&r^n&s^r&s),l=c,c=u,u=h,h=a+g|0,a=s,s=r,r=n,n=g+p|0}i[0]=i[0]+n|0,i[1]=i[1]+r|0,i[2]=i[2]+s|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0,i[5]=i[5]+u|0,i[6]=i[6]+c|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return i[r>>>5]|=128<<24-r%32,i[14+(r+64>>>9<<4)]=t.floor(n/4294967296),i[15+(r+64>>>9<<4)]=n,e.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(r),e.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var t=y,e=t.lib.WordArray,i=(n=t.algo).SHA256,n=n.SHA224=i.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=i._createHelper(n),t.HmacSHA224=i._createHmacHelper(n)}(),function(){function t(){return n.create.apply(n,arguments)}for(var e=y,i=e.lib.Hasher,n=(s=e.x64).Word,r=s.WordArray,s=e.algo,o=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],a=[],h=0;80>h;h++)a[h]=t();s=s.SHA512=i.extend({_doReset:function(){this._hash=new r.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var i=(l=this._hash.words)[0],n=l[1],r=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=i.high,d=i.low,g=n.high,p=n.low,y=r.high,v=r.low,m=s.high,S=s.low,F=h.high,E=h.low,w=u.high,x=u.low,A=c.high,b=c.low,I=l.high,C=l.low,D=f,T=d,P=g,R=p,H=y,N=v,B=m,O=S,j=F,V=E,L=w,_=x,K=A,k=b,M=I,U=C,q=0;80>q;q++){var z=a[q];if(16>q)var G=z.high=0|t[e+2*q],Y=z.low=0|t[e+2*q+1];else{G=((Y=(G=a[q-15]).high)>>>1|(J=G.low)<<31)^(Y>>>8|J<<24)^Y>>>7;var J=(J>>>1|Y<<31)^(J>>>8|Y<<24)^(J>>>7|Y<<25),W=((Y=(W=a[q-2]).high)>>>19|(X=W.low)<<13)^(Y<<3|X>>>29)^Y>>>6,X=(X>>>19|Y<<13)^(X<<3|Y>>>29)^(X>>>6|Y<<26),Z=(Y=a[q-7]).high,$=(Q=a[q-16]).high,Q=Q.low;G=(G=(G=G+Z+((Y=J+Y.low)>>>0>>0?1:0))+W+((Y=Y+X)>>>0>>0?1:0))+$+((Y=Y+Q)>>>0>>0?1:0);z.high=G,z.low=Y}Z=j&L^~j&K,Q=V&_^~V&k,z=D&P^D&H^P&H;var tt=T&R^T&N^R&N,et=(J=(D>>>28|T<<4)^(D<<30|T>>>2)^(D<<25|T>>>7),W=(T>>>28|D<<4)^(T<<30|D>>>2)^(T<<25|D>>>7),(X=o[q]).high),it=X.low;$=M+((j>>>14|V<<18)^(j>>>18|V<<14)^(j<<23|V>>>9))+((X=U+((V>>>14|j<<18)^(V>>>18|j<<14)^(V<<23|j>>>9)))>>>0>>0?1:0),M=K,U=k,K=L,k=_,L=j,_=V,j=B+($=($=($=$+Z+((X=X+Q)>>>0>>0?1:0))+et+((X=X+it)>>>0>>0?1:0))+G+((X=X+Y)>>>0>>0?1:0))+((V=O+X|0)>>>0>>0?1:0)|0,B=H,O=N,H=P,N=R,P=D,R=T,D=$+(z=J+z+((Y=W+tt)>>>0>>0?1:0))+((T=X+Y|0)>>>0>>0?1:0)|0}d=i.low=d+T,i.high=f+D+(d>>>0>>0?1:0),p=n.low=p+R,n.high=g+P+(p>>>0>>0?1:0),v=r.low=v+N,r.high=y+H+(v>>>0>>0?1:0),S=s.low=S+O,s.high=m+B+(S>>>0>>0?1:0),E=h.low=E+V,h.high=F+j+(E>>>0>>0?1:0),x=u.low=x+_,u.high=w+L+(x>>>0<_>>>0?1:0),b=c.low=b+k,c.high=A+K+(b>>>0>>0?1:0),C=l.low=C+U,l.high=I+M+(C>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(i/4294967296),e[31+(n+128>>>10<<5)]=i,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=i._createHelper(s),e.HmacSHA512=i._createHmacHelper(s)}(),function(){var t=y,e=(r=t.x64).Word,i=r.WordArray,n=(r=t.algo).SHA512,r=r.SHA384=n.extend({_doReset:function(){this._hash=new i.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(r),t.HmacSHA384=n._createHmacHelper(r)}(),function(){var t=y,e=(n=t.lib).WordArray,i=n.Hasher,n=t.algo,r=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),o=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);n=n.RIPEMD160=i.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=0;16>i;i++){var n=t[F=e+i];t[F]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var c,l,f,d,g,p,y,v,m,S,F=this._hash.words,E=(n=h.words,u.words),w=r.words,x=s.words,A=o.words,b=a.words;p=c=F[0],y=l=F[1],v=f=F[2],m=d=F[3],S=g=F[4];var I;for(i=0;80>i;i+=1)I=c+t[e+w[i]]|0,I=16>i?I+((l^f^d)+n[0]):32>i?I+((l&f|~l&d)+n[1]):48>i?I+(((l|~f)^d)+n[2]):64>i?I+((l&d|f&~d)+n[3]):I+((l^(f|~d))+n[4]),I=(I=(I|=0)<>>32-A[i])+g|0,c=g,g=d,d=f<<10|f>>>22,f=l,l=I,I=p+t[e+x[i]]|0,I=16>i?I+((y^(v|~m))+E[0]):32>i?I+((y&m|v&~m)+E[1]):48>i?I+(((y|~v)^m)+E[2]):64>i?I+((y&v|~y&m)+E[3]):I+((y^v^m)+E[4]),I=(I=(I|=0)<>>32-b[i])+S|0,p=S,S=m,m=v<<10|v>>>22,v=y,y=I;I=F[1]+f+m|0,F[1]=F[2]+d+S|0,F[2]=F[3]+g+p|0,F[3]=F[4]+c+y|0,F[4]=F[0]+l+v|0,F[0]=I},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,i=0;5>i;i++)n=e[i],e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(n),t.HmacRIPEMD160=i._createHmacHelper(n)}(Math),function(){var t=y,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,i){t=this._hasher=new t.init,"string"==typeof i&&(i=e.parse(i));var n=t.blockSize,r=4*n;i.sigBytes>r&&(i=t.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),o=this._iKey=i.clone(),a=s.words,h=o.words,u=0;u>6)+m.charAt(63&i);if(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),n+=m.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),n+=m.charAt(i>>2)+m.charAt((3&i)<<4)),S)for(;(3&n.length)>0;)n+=S;return n}function E(t){var e,i,n,r="",s=0;for(e=0;e>2),i=3&n,s=1):1==s?(r+=T(i<<2|n>>4),i=15&n,s=2):2==s?(r+=T(i),r+=T(n>>2),i=3&n,s=3):(r+=T(i<<2|n>>4),r+=T(15&n),s=0));return 1==s&&(r+=T(i<<2)),r}function w(t){var e,i=E(t),n=new Array;for(e=0;2*e>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;r=((h=o*h+((32767&c)<<15)+i[n]+(1073741823&r))>>>30)+(c>>>15)+a*u+(r>>>30),i[n++]=1073741823&h}return r},v=30):"Netscape"!=i.appName?(x.prototype.am=function(t,e,i,n,r,s){for(;--s>=0;){var o=e*this[t++]+i[n]+r;r=Math.floor(o/67108864),i[n++]=67108863&o}return r},v=26):(x.prototype.am=function(t,e,i,n,r,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;r=((h=o*h+((16383&c)<<14)+i[n]+r)>>28)+(c>>14)+a*u,i[n++]=268435455&h}return r},v=28),x.prototype.DB=v,x.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function N(t){this.m=t}function B(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function K(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function k(){}function M(t){return t}function U(t){this.r2=A(),this.q3=A(),x.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}N.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},N.prototype.revert=function(t){return t},N.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},N.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},N.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},B.prototype.convert=function(t){var e=A();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(x.ZERO)>0&&this.m.subTo(e,e),e},B.prototype.revert=function(t){var e=A();return t.copyTo(e),this.reduce(e),e},B.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},B.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},B.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},x.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},x.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},x.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,r=!1,s=0;--n>=0;){var o=8==i?255&t[n]:P(t,n);o<0?"-"==t.charAt(n)&&(r=!0):(r=!1,0==s?this[this.t++]=o:s+i>this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},x.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},x.prototype.drShiftTo=function(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>r|a,a=(this[i]&s)<=0;--i)e[i]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},x.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,r=this.DB-n,s=(1<>n;for(var o=i+1;o>n;n>0&&(e[this.t-i-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},x.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),r=i.t;for(e.t=r+n.t;--r>=0;)e[r]=0;for(r=0;r=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},x.prototype.divRemTo=function(t,e,i){var n=t.abs();if(!(n.t<=0)){var r=this.abs();if(r.t0?(n.lShiftTo(h,s),r.lShiftTo(h,i)):(n.copyTo(s),r.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<1?s[u-2]>>this.F2:0),f=this.FV/l,d=(1<=0&&(i[i.t++]=1,i.subTo(v,i)),x.ONE.dlShiftTo(u,v),v.subTo(s,s);s.t=0;){var m=i[--p]==c?this.DM:Math.floor(i[p]*f+(i[p-1]+g)*d);if((i[p]+=s.am(0,m,i,y,0,u))0&&i.rShiftTo(h,i),o<0&&x.ZERO.subTo(i,i)}}},x.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},x.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},x.prototype.exp=function(t,e){if(t>4294967295||t<1)return x.ONE;var i=A(),n=A(),r=e.convert(this),s=H(t)-1;for(r.copyTo(i);--s>=0;)if(e.sqrTo(i,n),(t&1<0)e.mulTo(n,r,i);else{var o=i;i=n,n=o}return e.revert(i)},x.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<0)for(a>a)>0&&(r=!0,s=T(i));o>=0;)a>(a+=this.DB-e)):(i=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),i>0&&(r=!0),r&&(s+=T(i));return r?s:"0"},x.prototype.negate=function(){var t=A();return x.ZERO.subTo(this,t),t},x.prototype.abs=function(){return this.s<0?this.negate():this},x.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},x.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+H(this[this.t-1]^this.s&this.DM)},x.prototype.mod=function(t){var e=A();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(x.ZERO)>0&&t.subTo(e,e),e},x.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new N(e):new B(e),this.exp(t,i)},x.ZERO=R(0),x.ONE=R(1),k.prototype.convert=M,k.prototype.revert=M,k.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},k.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=A();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var q=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],z=(1<<26)/q[q.length-1]; -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function G(){this.i=0,this.j=0,this.S=new Array}x.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},x.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),n=R(i),r=A(),s=A(),o="";for(this.divRemTo(n,r,s);r.signum()>0;)o=(i+s.intValue()).toString(t).substr(1)+o,r.divRemTo(n,r,s);return s.intValue().toString(t)+o},x.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),r=!1,s=0,o=0,a=0;a=i&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),r&&x.ZERO.subTo(this,this)},x.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(x.ONE.shiftLeft(t-1),j,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(x.ONE.shiftLeft(t-1),this);else{var n=new Array,r=7&t;n.length=1+(t>>3),e.nextBytes(n),r>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},x.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},x.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},x.prototype.multiplyLowerTo=function(t,e,i){var n,r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r=0;)i[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},x.prototype.millerRabin=function(t){var e=this.subtract(x.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var n=e.shiftRight(i);(t=t+1>>1)>q.length&&(t=q.length);for(var r=A(),s=0;s>24},x.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},x.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},x.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,r=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[r++]=i|this.s<=0;)n<8?(i=(this[t]&(1<>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(e[r++]=i);return e},x.prototype.equals=function(t){return 0==this.compareTo(t)},x.prototype.min=function(t){return this.compareTo(t)<0?this:t},x.prototype.max=function(t){return this.compareTo(t)>0?this:t},x.prototype.and=function(t){var e=A();return this.bitwiseTo(t,O,e),e},x.prototype.or=function(t){var e=A();return this.bitwiseTo(t,j,e),e},x.prototype.xor=function(t){var e=A();return this.bitwiseTo(t,V,e),e},x.prototype.andNot=function(t){var e=A();return this.bitwiseTo(t,L,e),e},x.prototype.not=function(){for(var t=A(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var c=A();for(n.sqrTo(o[1],c);a<=u;)o[a]=A(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,d=t.t-1,g=!0,p=A();for(r=H(t[d])-1;d>=0;){for(r>=h?l=t[d]>>r-h&u:(l=(t[d]&(1<0&&(l|=t[d-1]>>this.DB+r-h)),a=i;0==(1&l);)l>>=1,--a;if((r-=a)<0&&(r+=this.DB,--d),g)o[l].copyTo(s),g=!1;else{for(;a>1;)n.sqrTo(s,p),n.sqrTo(p,s),a-=2;a>0?n.sqrTo(s,p):(f=s,s=p,p=f),n.mulTo(p,o[l],s)}for(;d>=0&&0==(t[d]&1<=0?(i.subTo(n,i),e&&r.subTo(o,r),s.subTo(a,s)):(n.subTo(i,n),e&&o.subTo(r,o),a.subTo(s,a))}return 0!=n.compareTo(x.ONE)?x.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},x.prototype.pow=function(t){return this.exp(t,new k)},x.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var r=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(r0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(r=e.getLowestSetBit())>0&&e.rShiftTo(r,e),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},x.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=q[q.length-1]){for(e=0;e>8&255,J[W++]^=t>>16&255,J[W++]^=t>>24&255,W>=X&&(W-=X)}((new Date).getTime())}if(null==J){var $;if(J=new Array,W=0,void 0!==n&&(void 0!==n.crypto||void 0!==n.msCrypto)){var Q=n.crypto||n.msCrypto;if(Q.getRandomValues){var tt=new Uint8Array(32);for(Q.getRandomValues(tt),$=0;$<32;++$)J[W++]=tt[$]}else if("Netscape"==i.appName&&i.appVersion<"5"){var et=n.crypto.random(32);for($=0;$>>8,J[W++]=255&$;W=0,Z()}function it(){if(null==Y){for(Z(),(Y=new G).init(J),W=0;W>24,(16711680&r)>>16,(65280&r)>>8,255&r]))),r+=1;return n}function ot(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function at(t,e,i){for(var n="",r=0;n.length>24,(16711680&r)>>16,(65280&r)>>8,255&r])),r+=1;return n} -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function ht(t,e){this.x=e,this.q=t}function ut(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?x.ONE:n,this.zinv=null}function ct(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new ut(this,null,null)}nt.prototype.nextBytes=function(t){var e;for(e=0;e0&&e.length>0))throw"Invalid RSA public key";this.n=rt(t,16),this.e=parseInt(e,16)}},ot.prototype.encrypt=function(t){var e=function(t,e){if(e=0&&e>0;){var r=t.charCodeAt(n--);r<128?i[--e]=r:r>127&&r<2048?(i[--e]=63&r|128,i[--e]=r>>6|192):(i[--e]=63&r|128,i[--e]=r>>6&63|128,i[--e]=r>>12|224)}i[--e]=0;for(var s=new nt,o=new Array;e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new x(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var n=i.toString(16);return 0==(1&n.length)?n:"0"+n},ot.prototype.encryptOAEP=function(t,e,i){var n=function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;if(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t.length+2*n+2>e)throw"Message too long for RSA";var a,h="";for(a=0;a>3,e,i);if(null==n)return null;var r=this.doPublic(n);if(null==r)return null;var s=r.toString(16);return 0==(1&s.length)?s:"0"+s},ot.prototype.type="RSA",ot.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},ot.prototype.setPrivate=function(t,e,i){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=i;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16)}},ot.prototype.setPrivateEx=function(t,e,i,n,r,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16),this.p=rt(n,16),this.q=rt(r,16),this.dmp1=rt(s,16),this.dmq1=rt(o,16),this.coeff=rt(a,16)},ot.prototype.generate=function(t,e){var i=new nt,n=t>>1;this.e=parseInt(e,16);for(var r=new x(e,16);;){for(;this.p=new x(t-n,1,i),0!=this.p.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.p.isProbablePrime(10););for(;this.q=new x(n,1,i),0!=this.q.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(x.ONE),a=this.q.subtract(x.ONE),h=o.multiply(a);if(0==h.gcd(r).compareTo(x.ONE)){this.n=this.p.multiply(this.q),this.d=r.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},ot.prototype.decrypt=function(t){var e=rt(t,16),i=this.doPrivate(e);return null==i?null: -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function(t,e){for(var i=t.toByteArray(),n=0;n=i.length)return null;for(var r="";++n191&&s<224?(r+=String.fromCharCode((31&s)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&s)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},ot.prototype.decryptOAEP=function(t,e,i){var n=rt(t,16),r=this.doPrivate(n);return null==r?null:function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;for(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t=t.toByteArray(),a=0;a>3,e,i)},ht.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ht.prototype.toBigInteger=function(){return this.x},ht.prototype.negate=function(){return new ht(this.q,this.x.negate().mod(this.q))},ht.prototype.add=function(t){return new ht(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ht.prototype.subtract=function(t){return new ht(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ht.prototype.multiply=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ht.prototype.square=function(){return new ht(this.q,this.x.square().mod(this.q))},ht.prototype.divide=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ut.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO))},ut.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(x.ZERO)&&!this.y.toBigInteger().equals(x.ZERO)},ut.prototype.negate=function(){return new ut(this.curve,this.x,this.y.negate(),this.z)},ut.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),i=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(x.ZERO.equals(i))return x.ZERO.equals(e)?this.twice():this.curve.getInfinity();var n=new x("3"),r=this.x.toBigInteger(),s=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),i.square()),a=o.multiply(i),h=r.multiply(o),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(a).multiply(i).mod(this.curve.q),l=h.multiply(n).multiply(e).subtract(s.multiply(a)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),f=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},ut.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new x("3"),e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=i.multiply(this.z),r=n.multiply(i).mod(this.curve.q),s=this.curve.a.toBigInteger(),o=e.square().multiply(t);x.ZERO.equals(s)||(o=o.add(this.z.square().multiply(s)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(r)).shiftLeft(1).multiply(n).mod(this.curve.q),h=o.multiply(t).multiply(e).subtract(r.shiftLeft(1)).shiftLeft(2).multiply(r).subtract(o.square().multiply(o)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),u)},ut.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add(o?this:r))}return s},ut.prototype.multiplyTwo=function(t,e,i){var n;n=t.bitLength()>i.bitLength()?t.bitLength()-1:i.bitLength()-1;for(var r=this.curve.getInfinity(),s=this.add(e);n>=0;)r=r.twice(),t.testBit(n)?r=i.testBit(n)?r.add(s):r.add(this):i.testBit(n)&&(r=r.add(e)),--n;return r},ct.prototype.getQ=function(){return this.q},ct.prototype.getA=function(){return this.a},ct.prototype.getB=function(){return this.b},ct.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ct.prototype.getInfinity=function(){return this.infinity},ct.prototype.fromBigInteger=function(t){return new ht(this.q,t)},ct.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,i=t.substr(2,e),n=t.substr(e+2,e);return new ut(this,this.fromBigInteger(new x(i,16)),this.fromBigInteger(new x(n,16)));default:return null}}, -/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib - */ -ht.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ut.prototype.getEncoded=function(t){var e=function(t,e){var i=t.toByteArrayUnsigned();if(ei.length;)i.unshift(0);return i},i=this.getX().toBigInteger(),n=this.getY().toBigInteger(),r=e(i,32);return t?n.isEven()?r.unshift(2):r.unshift(3):(r.unshift(4),r=r.concat(e(n,32))),r},ut.decodeFrom=function(t,e){e[0];var i=e.length-1,n=e.slice(1,1+i/2),r=e.slice(1+i/2,1+i);n.unshift(0),r.unshift(0);var s=new x(n),o=new x(r);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.decodeFromHex=function(t,e){e.substr(0,2);var i=e.length-2,n=e.substr(2,i/2),r=e.substr(2+i/2,i/2),s=new x(n,16),o=new x(r,16);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),i=t.y.subtract(this.y).divide(e),n=i.square().subtract(this.x).subtract(t.x),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(x.valueOf(2)),e=this.curve.fromBigInteger(x.valueOf(3)),i=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=i.square().subtract(this.x.multiply(t)),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add2D(o?this:r))}return s},ut.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),i=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),r=this.curve.getQ(),s=e.multiply(e).mod(r),o=t.multiply(t).multiply(t).add(i.multiply(t)).add(n).mod(r);return s.equals(o)},ut.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ut.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),i=this.getY().toBigInteger();if(e.compareTo(x.ONE)<0||e.compareTo(t.subtract(x.ONE))>0)throw new Error("x coordinate out of bounds");if(i.compareTo(x.ONE)<0||i.compareTo(t.subtract(x.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0}; -/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval - */ -var lt=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),i={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,n){return e?i[e]:String.fromCharCode(parseInt(n,16))}var r=new String(""),s=(Object,Array,Object.hasOwnProperty);return function(i,o){var a,h,u=i.match(t),c=u[0],l=!1;"{"===c?a={}:"["===c?a=[]:(a=[],l=!0);for(var f=[a],d=1-l,g=u.length;d=0;)delete i[n[h]]}return o.call(t,e,i)};a=y({"":a},"")}return a}}();void 0!==ft&&ft||(ft={}),void 0!==ft.asn1&&ft.asn1||(ft.asn1={}),ft.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},ft.asn1.DERAbstractString=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=At(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},r.lang.extend(ft.asn1.DERAbstractString,ft.asn1.ASN1Object),ft.asn1.DERAbstractTime=function(t){ft.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var n=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var h=n(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=St(t)},this.setByDateValue=function(t,e,i,n,r,s){var o=new Date(Date.UTC(t,e-1,i,n,r,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},r.lang.extend(ft.asn1.DERAbstractTime,ft.asn1.ASN1Object),ft.asn1.DERAbstractStructured=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},r.lang.extend(ft.asn1.DERAbstractStructured,ft.asn1.ASN1Object),ft.asn1.DERBoolean=function(){ft.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},r.lang.extend(ft.asn1.DERBoolean,ft.asn1.ASN1Object),ft.asn1.DERInteger=function(t){ft.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ft.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},r.lang.extend(ft.asn1.DERInteger,ft.asn1.ASN1Object),ft.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ft.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}ft.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7r.length&&(r=n[i]);return(t=t.replace(r,"::")).slice(1,-1)}function _t(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?Lt(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function Kt(t){for(var e=encodeURIComponent(t),i="",n=0;n"7"?"00"+t:t}function Mt(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,i){var n=parseInt(t);if(n<0||255=2*s)break;if(a>=200)break;n.push(h),o=h,a++}return n},pt.getNthChildIdx=function(t,e,i){return pt.getChildIdx(t,e)[i]},pt.getIdxbyList=function(t,e,i,n){var r,s,o=pt;if(0==i.length){if(void 0!==n&&t.substr(e,2)!==n)throw"checking tag doesn't match: "+t.substr(e,2)+"!="+n;return e}return r=i.shift(),s=o.getChildIdx(t,e),o.getIdxbyList(t,s[r],i,n)},pt.getTLVbyList=function(t,e,i,n){var r=pt,s=r.getIdxbyList(t,e,i);if(void 0===s)throw"can't find nthList object";if(void 0!==n&&t.substr(s,2)!=n)throw"checking tag doesn't match: "+t.substr(s,2)+"!="+n;return r.getTLV(t,s)},pt.getVbyList=function(t,e,i,n,r){var s,o,a=pt;if(void 0===(s=a.getIdxbyList(t,e,i,n)))throw"can't find nthList object";return o=a.getV(t,s),!0===r&&(o=o.substr(2)),o},pt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},i=[],n=t.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var s=t.substr(2),o=[],a=0;a0&&(c=c+"."+h.join(".")),c},pt.dump=function(t,e,i,n){var r=pt,s=r.getV,o=r.dump,a=r.getChildIdx,h=t;t instanceof ft.asn1.ASN1Object&&(h=t.getEncodedHex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var c=e.ommit_long_octet;if("01"==h.substr(i,2))return"00"==(l=s(h,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==h.substr(i,2))return n+"INTEGER "+u(l=s(h,i),c)+"\n";if("03"==h.substr(i,2))return n+"BITSTRING "+u(l=s(h,i),c)+"\n";if("04"==h.substr(i,2)){var l=s(h,i);if(r.isASN1HEX(l)){var f=n+"OCTETSTRING, encapsulates\n";return f+=o(l,e,0,n+" ")}return n+"OCTETSTRING "+u(l,c)+"\n"}if("05"==h.substr(i,2))return n+"NULL\n";if("06"==h.substr(i,2)){var d=s(h,i),g=ft.asn1.ASN1Util.oidHexToInt(d),p=ft.asn1.x509.OID.oid2name(g),y=g.replace(/\./g," ");return""!=p?n+"ObjectIdentifier "+p+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0c"==h.substr(i,2))return n+"UTF8String '"+bt(s(h,i))+"'\n";if("13"==h.substr(i,2))return n+"PrintableString '"+bt(s(h,i))+"'\n";if("14"==h.substr(i,2))return n+"TeletexString '"+bt(s(h,i))+"'\n";if("16"==h.substr(i,2))return n+"IA5String '"+bt(s(h,i))+"'\n";if("17"==h.substr(i,2))return n+"UTCTime "+bt(s(h,i))+"\n";if("18"==h.substr(i,2))return n+"GeneralizedTime "+bt(s(h,i))+"\n";if("30"==h.substr(i,2)){if("3000"==h.substr(i,4))return n+"SEQUENCE {}\n";f=n+"SEQUENCE\n";var v=e;if((2==(F=a(h,i)).length||3==F.length)&&"06"==h.substr(F[0],2)&&"04"==h.substr(F[F.length-1],2)){p=r.oidname(s(h,F[0]));var m=JSON.parse(JSON.stringify(e));m.x509ExtName=p,v=m}for(var S=0;S0){var e=new i({array:this.extensionsArray}),n=new r({explicit:!0,tag:"a3",obj:e});this.asn1Array.push(n)}var s=new i({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertificate,ft.asn1.ASN1Object),ft.asn1.x509.Extension=function(t){ft.asn1.x509.Extension.superclass.constructor.call(this);var e=ft.asn1,i=e.DERObjectIdentifier,n=e.DEROctetString,r=(e.DERBitString,e.DERBoolean),s=e.DERSequence;this.getEncodedHex=function(){var t=new i({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new r),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},r.lang.extend(ft.asn1.x509.Extension,ft.asn1.ASN1Object),ft.asn1.x509.Extension.appendByNameToArray=function(t,e,i){var n=t.toLowerCase(),r=ft.asn1.x509;if("basicconstraints"==n){var s=new r.BasicConstraints(e);i.push(s)}else if("keyusage"==n){s=new r.KeyUsage(e);i.push(s)}else if("crldistributionpoints"==n){s=new r.CRLDistributionPoints(e);i.push(s)}else if("extkeyusage"==n){s=new r.ExtKeyUsage(e);i.push(s)}else if("authoritykeyidentifier"==n){s=new r.AuthorityKeyIdentifier(e);i.push(s)}else if("authorityinfoaccess"==n){s=new r.AuthorityInfoAccess(e);i.push(s)}else if("subjectaltname"==n){s=new r.SubjectAltName(e);i.push(s)}else{if("issueraltname"!=n)throw"unsupported extension name: "+t;s=new r.IssuerAltName(e);i.push(s)}},ft.asn1.x509.KeyUsage=function(t){ft.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Jt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new ft.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var i=t.names,n="000000000",r=0;r-1&&t.push(new ft.asn1.DERInteger({int:this.pathLen}));var e=new ft.asn1.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},r.lang.extend(ft.asn1.x509.BasicConstraints,ft.asn1.x509.Extension),ft.asn1.x509.CRLDistributionPoints=function(t){ft.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ft.asn1,i=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){this.asn1ExtnValue=new e.DERSequence({array:t})},this.setByOneURI=function(t){var e=new i.GeneralNames([{uri:t}]),n=new i.DistributionPointName(e),r=new i.DistributionPoint({dpobj:n});this.setByDPArray([r])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},r.lang.extend(ft.asn1.x509.CRLDistributionPoints,ft.asn1.x509.Extension),ft.asn1.x509.ExtKeyUsage=function(t){ft.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=ft.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var i=0;i0){var t=new i({array:this.aRevokedCert});this.asn1Array.push(t)}var e=new i({array:this.asn1Array});return this.hTLV=e.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize=function(){this.asn1Version=null,this.asn1SignatureAlg=null,this.asn1Issuer=null,this.asn1ThisUpdate=null,this.asn1NextUpdate=null,this.aRevokedCert=new Array},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertList,ft.asn1.ASN1Object),ft.asn1.x509.CRLEntry=function(t){ft.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=ft.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},r.lang.extend(ft.asn1.x509.CRLEntry,ft.asn1.ASN1Object),ft.asn1.x509.X500Name=function(t){ft.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=new Array;var e=ft.asn1,i=e.x509,n=Ht;if(this.setByString=function(t){var e=t.split("/");e.shift();for(var n=[],r=0;r0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},ft.asn1.x509.RDN=function(t){ft.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=new Array,this.addByString=function(t){this.asn1Array.push(new ft.asn1.x509.AttributeTypeAndValue({str:t}))},this.addByMultiValuedString=function(t){for(var e=ft.asn1.x509.RDN.parseString(t),i=0;i0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var a=!1,h=[];for(r=0;n.length>0;r++){s=n.shift();if(!0===a){var u=h.pop();if(s.match(/"$/)){o=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(o),a=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(a=!0)}return h},ft.asn1.x509.AttributeTypeAndValue=function(t){ft.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var e=ft.asn1;this.setByString=function(t){var e=t.match(/^([^=]+)=(.+)$/);if(!e)throw"malformed attrTypeAndValueStr: "+t;this.setByAttrTypeAndValueStr(e[1],e[2])},this.setByAttrTypeAndValueStr=function(t,e){this.typeObj=ft.asn1.x509.OID.atype2obj(t);var i="utf8";"C"==t&&(i="prn"),this.valueObj=this.getValueObj(i,e)},this.getValueObj=function(t,i){if("utf8"==t)return new e.DERUTF8String({str:i});if("prn"==t)return new e.DERPrintableString({str:i});if("tel"==t)return new e.DERTeletexString({str:i});if("ia5"==t)return new e.DERIA5String({str:i});throw"unsupported directory string type: type="+t+" value="+i},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.typeObj,this.valueObj]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&void 0!==t.str&&this.setByString(t.str)},r.lang.extend(ft.asn1.x509.AttributeTypeAndValue,ft.asn1.ASN1Object),ft.asn1.x509.SubjectPublicKeyInfo=function(t){ft.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ft,i=e.asn1,n=i.DERInteger,r=i.DERBitString,s=i.DERObjectIdentifier,o=i.DERSequence,a=i.ASN1Util.newObject,h=i.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof ot){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+e})}}catch(t){}try{if(t instanceof ft.crypto.ECDSA){var i=new s({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ft.crypto.DSA){i=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new h({name:"dsa",asn1params:i});var o=new n({bigint:t.y});this.asn1SubjPKey=new r({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},r.lang.extend(ft.asn1.x509.SubjectPublicKeyInfo,ft.asn1.ASN1Object),ft.asn1.x509.Time=function(t){ft.asn1.x509.Time.superclass.constructor.call(this);var e=ft.asn1,i=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},r.lang.extend(ft.asn1.x509.Time,ft.asn1.ASN1Object),ft.asn1.x509.AlgorithmIdentifier=function(t){ft.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ft.asn1;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw"algorithm not specified";null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var t=[this.asn1Alg];null!==this.asn1Params&&t.push(this.asn1Params);var i=new e.DERSequence({array:t});return this.hTLV=i.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},r.lang.extend(ft.asn1.x509.AlgorithmIdentifier,ft.asn1.ASN1Object),ft.asn1.x509.GeneralName=function(t){ft.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=ft.asn1,n=(i.DERSequence,i.DEROctetString),r=i.DERIA5String,s=i.DERTaggedObject,o=i.ASN1Object,a=i.x509.X500Name,h=Ht;this.explicit=!1,this.setByParam=function(t){var i=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",i=new r({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",i=new r({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",i=new r({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,i=new a({str:t.dn})),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var u=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certissuer param not cert";(f=new Jt).hex=u;var c=f.getIssuerHex();(i=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;u=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certsubj param not cert";(f=new Jt).hex=u;c=f.getSubjectHex();(i=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,g=t.ip,p="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(d=Mt("["+g.split(".").join(",")+"]")).length)throw p}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=Vt(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw p;d=g}i=new n({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},r.lang.extend(ft.asn1.x509.GeneralName,ft.asn1.ASN1Object),ft.asn1.x509.GeneralNames=function(t){ft.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ft.asn1;this.setByParamArray=function(t){for(var i=0;i0&&(e=new n({obj:this.dUnsignedAttrs,tag:"a1",explicit:!1}));var r=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,t,this.dSigAlg,this.dSig];null!=e&&r.push(e);var o=new i.DERSequence({array:r});return this.hTLV=o.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.SignerInfo,ft.asn1.ASN1Object),ft.asn1.cms.EncapsulatedContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.dEContentType=new r({name:"data"}),this.dEContent=null,this.isDetached=!1,this.eContentValueHex=null,this.setContentType=function(t){t.match(/^[0-2][.][0-9.]+$/)?this.dEContentType=new r({oid:t}):this.dEContentType=new r({name:t})},this.setContentValue=function(t){void 0!==t&&("string"==typeof t.hex?this.eContentValueHex=t.hex:"string"==typeof t.str&&(this.eContentValueHex=At(t.str)))},this.setContentValueHex=function(t){this.eContentValueHex=t},this.setContentValueStr=function(t){this.eContentValueHex=At(t)},this.getEncodedHex=function(){if("string"!=typeof this.eContentValueHex)throw"eContentValue not yet set";var t=new s({hex:this.eContentValueHex});this.dEContent=new i({obj:t,tag:"a0",explicit:!0});var e=[this.dEContentType];this.isDetached||e.push(this.dEContent);var r=new n({array:e});return this.hTLV=r.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.EncapsulatedContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.ContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.x509;ft.asn1.cms.ContentInfo.superclass.constructor.call(this),this.dContentType=null,this.dContent=null,this.setContentType=function(t){"string"==typeof t&&(this.dContentType=r.OID.name2obj(t))},this.getEncodedHex=function(){var t=new i({obj:this.dContent,tag:"a0",explicit:!0}),e=new n({array:[this.dContentType,t]});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t&&(t.type&&this.setContentType(t.type),t.obj&&t.obj instanceof e.ASN1Object&&(this.dContent=t.obj))},r.lang.extend(ft.asn1.cms.ContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.SignedData=function(t){var e=ft.asn1,i=e.ASN1Object,n=e.DERInteger,r=e.DERSet,s=e.DERSequence,o=e.DERTaggedObject,a=e.cms,h=a.EncapsulatedContentInfo,u=a.SignerInfo,c=a.ContentInfo,l=e.x509.AlgorithmIdentifier;ft.asn1.cms.SignedData.superclass.constructor.call(this),this.dCMSVersion=new n({int:1}),this.dDigestAlgs=null,this.digestAlgNameList=[],this.dEncapContentInfo=new h,this.dCerts=null,this.certificateList=[],this.crlList=[],this.signerInfoList=[new u],this.addCertificatesByPEM=function(t){var e=Ht(t),n=new i;n.hTLV=e,this.certificateList.push(n)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(null==this.dDigestAlgs){for(var t=[],e=0;e0){var h=new r({array:this.certificateList});this.dCerts=new o({obj:h,tag:"a0",explicit:!1})}null!=this.dCerts&&a.push(this.dCerts);var u=new r({array:this.signerInfoList});a.push(u);var c=new s({array:a});return this.hTLV=c.getEncodedHex(),this.hTLV},this.getContentInfo=function(){return this.getEncodedHex(),new c({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},this.getPEM=function(){return Rt(this.getContentInfoEncodedHex(),"CMS")}},r.lang.extend(ft.asn1.cms.SignedData,ft.asn1.ASN1Object),ft.asn1.cms.CMSUtil=new function(){},ft.asn1.cms.CMSUtil.newSignedData=function(t){var e=ft.asn1,i=e.cms,n=i.SignerInfo,r=i.SignedData,s=i.SigningTime,o=i.SigningCertificate,a=i.SigningCertificateV2,h=e.cades.SignaturePolicyIdentifier,u=new r;if(u.dEncapContentInfo.setContentValue(t.content),"object"==typeof t.certs)for(var c=0;c0){var t=new n({array:this.extensionsArray}),e=new r({array:[t]}),i=new n({array:[new a({oid:"1.2.840.113549.1.9.14"}),e]}),h=new o({explicit:!0,tag:"a0",obj:i});this.asn1Array.push(h)}else{h=new o({explicit:!1,tag:"a0",obj:new s});this.asn1Array.push(h)}var u=new n({array:this.asn1Array});return this.hTLV=u.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.csr.CertificationRequestInfo,ft.asn1.ASN1Object),ft.asn1.csr.CSRUtil=new function(){},ft.asn1.csr.CSRUtil.newCSRPEM=function(t){var e=Ut,i=ft.asn1.csr;if(void 0===t.subject)throw"parameter subject undefined";if(void 0===t.sbjpubkey)throw"parameter sbjpubkey undefined";if(void 0===t.sigalg)throw"parameter sigalg undefined";if(void 0===t.sbjprvkey)throw"parameter sbjpubkey undefined";var n=new i.CertificationRequestInfo;if(n.setSubjectByParam(t.subject),n.setSubjectPublicKeyByGetKey(t.sbjpubkey),void 0!==t.ext&&void 0!==t.ext.length)for(var r=0;rr)throw"key is too short for SigAlg: keylen="+i+","+e;for(var s="0001",o="00"+n,a="",h=r-s.length-o.length,u=0;u=0)return!1;if(i.compareTo(x.ONE)<0||i.compareTo(r)>=0)return!1;var o=i.modInverse(r),a=t.multiply(o).mod(r),h=e.multiply(o).mod(r);return s.multiply(a).add(n.multiply(h)).getX().toBigInteger().mod(r).equals(e)},this.serializeSig=function(t,e){var i=t.toByteArraySigned(),n=e.toByteArraySigned(),r=[];return r.push(2),r.push(i.length),(r=r.concat(i)).push(2),r.push(n.length),(r=r.concat(n)).unshift(r.length),r.unshift(48),r},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:x.fromByteArrayUnsigned(i),s:x.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:x.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:x.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[2,0],"06"),i=o(t,0,[1],"04");try{n=o(t,0,[3,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#1/5 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{o(t,0,[1,0],"06"),e=o(t,0,[1,1],"06"),i=o(t,0,[2,0,1],"04");try{n=o(t,0,[2,0,2,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#8 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){var e,i,n=pt,r=ft.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{s(t,0,[0,0],"06"),e=s(t,0,[0,1],"06"),i=s(t,0,[1],"03").substr(2)}catch(t){throw"malformed PKCS#8 ECC public key"}if(this.curveName=r(e),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,e){5!==e&&(e=6);var i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{i=o(t,0,[0,e,0,1],"06"),n=o(t,0,[0,e,1],"03").substr(2)}catch(t){throw"malformed X.509 certificate ECC public key"}if(this.curveName=s(i),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ft.crypto.ECDSA.parseSigHex=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new x(e.r,16),s:new x(e.s,16)}},ft.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=pt,i=e.getChildIdx,n=e.getV;if("30"!=t.substr(0,2))throw"signature is not a ASN.1 sequence";var r=i(t,0);if(2!=r.length)throw"number of signature ASN.1 sequence elements seem wrong";var s=r[0],o=r[1];if("02"!=t.substr(s,2))throw"1st item of sequene of signature is not ASN.1 integer";if("02"!=t.substr(o,2))throw"2nd item of sequene of signature is not ASN.1 integer";return{r:n(t,s),s:n(t,o)}},ft.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t),i=e.r,n=e.s;if("00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),i.length%32==30&&(i="00"+i),n.length%32==30&&(n="00"+n),i.length%32!=0)throw"unknown ECDSA sig r length error";if(n.length%32!=0)throw"unknown ECDSA sig s length error";return i+n},ft.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var e=t.substr(0,t.length/2),i=t.substr(t.length/2);return ft.crypto.ECDSA.hexRSSigToASN1Sig(e,i)},ft.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var i=new x(t,16),n=new x(e,16);return ft.crypto.ECDSA.biRSSigToASN1Sig(i,n)},ft.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var i=ft.asn1,n=new i.DERInteger({bigint:t}),r=new i.DERInteger({bigint:e});return new i.DERSequence({array:[n,r]}).getEncodedHex()},ft.crypto.ECDSA.getName=function(t){return"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040022"===t?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":null},void 0!==ft&&ft||(ft={}),void 0!==ft.crypto&&ft.crypto||(ft.crypto={}),ft.crypto.ECParameterDB=new function(){var t={},e={};function i(t){return new x(t,16)}this.getByName=function(i){var n=i;if(void 0!==e[n]&&(n=e[i]),void 0!==t[n])return t[n];throw"unregistered EC curve name: "+n},this.regist=function(n,r,s,o,a,h,u,c,l,f,d,g){t[n]={};var p=i(s),y=i(o),v=i(a),m=i(h),S=i(u),F=new ct(p,y,v),E=F.decodePointHex("04"+c+l);t[n].name=n,t[n].keylen=r,t[n].curve=F,t[n].G=E,t[n].n=m,t[n].h=S,t[n].oid=d,t[n].info=g;for(var w=0;w1?new x(n,16):null,u=new x(r,16),this.setPrivate(s,o,a,h,u)},this.setPublic=function(t,e,i,n){this.isPublic=!0,this.p=t,this.q=e,this.g=i,this.y=n,this.x=null},this.setPublicHex=function(t,e,i,n){var r,s,o,a;r=new x(t,16),s=new x(e,16),o=new x(i,16),a=new x(n,16),this.setPublic(r,s,o,a)},this.signWithMessageHash=function(t){var e=this.p,i=this.q,n=this.g,r=(this.y,this.x),s=ft.crypto.Util.getRandomBigIntegerMinToMax(x.ONE.add(x.ONE),i.subtract(x.ONE)),o=new x(t.substr(0,i.bitLength()/4),16),a=n.modPow(s,e).mod(i),h=s.modInverse(i).multiply(o.add(r.multiply(a))).mod(i);return ft.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:a}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var i=this.p,n=this.q,r=this.g,s=this.y,o=this.parseASN1Signature(e),a=o[0],h=o[1],u=new x(t.substr(0,n.bitLength()/4),16);if(x.ZERO.compareTo(a)>0||a.compareTo(n)>0)throw"invalid DSA signature";if(x.ZERO.compareTo(h)>=0||h.compareTo(n)>0)throw"invalid DSA signature";var c=h.modInverse(n),l=u.multiply(c).mod(n),f=a.multiply(c).mod(n);return 0==r.modPow(l,i).multiply(s.modPow(f,i)).mod(i).mod(n).compareTo(a)},this.parseASN1Signature=function(t){try{return[new x(pt.getVbyList(t,0,[0],"02"),16),new x(pt.getVbyList(t,0,[1],"02"),16)]}catch(t){throw"malformed ASN.1 DSA signature"}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r,s,o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{e=a(t,0,[1],"02"),i=a(t,0,[2],"02"),n=a(t,0,[3],"02"),r=a(t,0,[4],"02"),s=a(t,0,[5],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#1/5 plain DSA private key"}this.setPrivateHex(e,i,n,r,s)},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[1,1,0],"02"),i=o(t,0,[1,1,1],"02"),n=o(t,0,[1,1,2],"02"),r=o(t,0,[2,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 plain DSA private key"}this.setPrivateHex(e,i,n,null,r)},this.readPKCS8PubKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[0,1,0],"02"),i=o(t,0,[0,1,1],"02"),n=o(t,0,[0,1,2],"02"),r=o(t,0,[1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 DSA public key"}this.setPublicHex(e,i,n,r)},this.readCertPubKeyHex=function(t,e){var i,n,r,s;5!==e&&(e=6);var o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{i=a(t,0,[0,e,0,1,0],"02"),n=a(t,0,[0,e,0,1,1],"02"),r=a(t,0,[0,e,0,1,2],"02"),s=a(t,0,[0,e,1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed X.509 certificate DSA public key"}this.setPublicHex(i,n,r,s)}};var Ut=function(){var t=function(t,i,n){return e(y.AES,t,i,n)},e=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=r;var h=t.decrypt(a,s,{iv:o});return y.enc.Hex.stringify(h)},i=function(t,e,i){return n(y.AES,t,e,i)},n=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a=t.encrypt(r,s,{iv:o}),h=y.enc.Hex.parse(a.toString());return y.enc.Base64.stringify(h)},r={"AES-256-CBC":{proc:t,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,i,n){return e(y.TripleDES,t,i,n)},eproc:function(t,e,i){return n(y.TripleDES,t,e,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,i,n){return e(y.DES,t,i,n)},eproc:function(t,e,i){return n(y.DES,t,e,i)},keylen:8,ivlen:8}},s=function(t){var e={},i=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(e.cipher=i[1],e.ivsalt=i[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var r=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(r=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(r=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=r&&-1!=o){var a=t.substring(r+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,i){for(var n=i.substring(0,16),s=y.enc.Hex.parse(n),o=y.enc.Utf8.parse(e),a=r[t].keylen+r[t].ivlen,h="",u=null;;){var c=y.algo.MD5.create();if(null!=u&&c.update(u),c.update(o),c.update(s),u=c.finalize(),(h+=y.enc.Hex.stringify(u)).length>=2*a)break}var l={};return l.keyhex=h.substr(0,2*r[t].keylen),l.ivhex=h.substr(2*r[t].keylen,2*r[t].ivlen),l},a=function(t,e,i,n){var s=y.enc.Base64.parse(t),o=y.enc.Hex.stringify(s);return(0,r[e].proc)(o,i,n)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,i){return o(t,e,i)},decryptKeyB64:function(t,e,i,n){return a(t,e,i,n)},getDecryptedKeyHex:function(t,e){var i=s(t),n=(i.type,i.cipher),r=i.ivsalt,h=i.data,u=o(n,e,r).keyhex;return a(h,n,u,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,i,n,s){var a="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===r[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==s&&null!=s||(s=function(t){var e=y.lib.WordArray.random(t);return y.enc.Hex.stringify(e)}(r[n].ivlen).toUpperCase());var h=function(t,e,i,n){return(0,r[e].eproc)(t,i,n)}(e,n,o(n,i,s).keyhex,s);a="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+n+","+s+"\r\n",a+="\r\n",a+=h.replace(/(.{64})/g,"$1\r\n"),a+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={},s=i(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;r.ciphertext=n(t,s[1]);var o=i(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=i(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var h=i(t,a[1]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length;if("2a864886f70d0307"!=n(t,h[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(t,h[1]);var u=i(t,a[0]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length;if("2a864886f70d01050c"!=n(t,u[0]))throw"this only supports pkcs5PBKDF2";var c=i(t,u[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;r.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{r.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return r},getPBKDF2KeyHexFromParam:function(t,e){var i=y.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,r=y.PBKDF2(e,i,{keySize:6,iterations:n});return y.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var i=Ht(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=Ut.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=y.enc.Hex.parse(n.ciphertext);var o=y.enc.Hex.parse(r),a=y.enc.Hex.parse(n.encryptionSchemeIV),h=y.TripleDES.decrypt(s,o,{iv:a});return y.enc.Hex.stringify(h)},getKeyFromEncryptedPKCS8PEM:function(t,e){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var s=i(t,0);if(3!=s.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(s[1],2))throw"malformed PKCS8 private key(code:003)";var o=i(t,s[1]);if(2!=o.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(o[0],2))throw"malformed PKCS8 private key(code:005)";if(r.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(r.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw"malformed PKCS8 private key(code:006)";return r.keyidx=e.getVidx(t,s[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Ht(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,i=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==i.algoid)e=new ot;else if("2a8648ce380401"==i.algoid)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";e=new ft.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,i=pt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===i)e=new ot;else if("2a8648ce380401"===i)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";e=new ft.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=i(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(r.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return r.e=n(t,s[1]),r},parsePublicPKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null},s=i(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=i(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?r.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(r.algparam={},r.algparam.p=e.getVbyList(t,a[1],[0],"02"),r.algparam.q=e.getVbyList(t,a[1],[1],"02"),r.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(t,s[1]).substr(2),r}}}();Ut.getKey=function(t,e,i){var n=(y=pt).getChildIdx,r=(y.getV,y.getVbyList),s=ft.crypto,o=s.ECDSA,a=s.DSA,h=ot,u=Ht,c=Ut;if(void 0!==h&&t instanceof h)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(t.n,t.e),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(D=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(D=new h).setPrivate(t.n,t.e,t.d),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(D=new a).setPublic(t.p,t.q,t.g,t.y),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(D=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(xt(t.n),xt(t.e)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(D=new h).setPrivateEx(xt(t.n),xt(t.e),xt(t.d),xt(t.p),xt(t.q),xt(t.dp),xt(t.dq),xt(t.qi)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(D=new h).setPrivate(xt(t.n),xt(t.e),xt(t.d)),D;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);return C.setPublicKeyHex(f),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);var d=("0000000000"+xt(t.d)).slice(-l);return C.setPublicKeyHex(f),C.setPrivateKeyHex(d),C}if("pkcs5prv"===i){var g,p=t,y=pt;if(9===(g=n(p,0)).length)(D=new h).readPKCS5PrvKeyHex(p);else if(6===g.length)(D=new a).readPKCS5PrvKeyHex(p);else{if(!(g.length>2&&"04"===p.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(D=new o).readPKCS5PrvKeyHex(p)}return D}if("pkcs8prv"===i)return D=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===i)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===i)return Jt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Jt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=Ht(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=u(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=r(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),F=r(R,0,[2],"02"),E=r(R,0,[3],"02"),w=r(R,0,[4],"02"),A=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(E,16),new x(w,16),new x(A,16)),D}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var b=c.getDecryptedKeyHex(t,e),I=new ot;return I.readPKCS5PrvKeyHex(b),I}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var C,D=r(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),T=r(R,0,[2,0],"06"),P=r(R,0,[3,0],"03").substr(2);if(void 0===ft.crypto.OID.oidhex2name[T])throw"undefined OID(hex) in KJUR.crypto.OID: "+T;return(C=new o({curve:ft.crypto.OID.oidhex2name[T]})).setPublicKeyHex(P),C.setPrivateKeyHex(D),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;S=r(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),F=r(R,0,[2],"02"),E=r(R,0,[3],"02"),w=r(R,0,[4],"02"),A=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(E,16),new x(w,16),new x(A,16)),D}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw"not supported argument"},Ut.generateKeypair=function(t,e){if("RSA"==t){var i=e;(o=new ot).generate(i,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new ot,r=o.n.toString(16),s=o.e.toString(16);return n.setPublic(r,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,h=e,u=new ft.crypto.ECDSA({curve:h}).generateKeyPairHex();return(o=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),o.setPrivateKeyHex(u.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Ut.getPEM=function(t,e,i,n,r,s){var o=ft,a=o.asn1,h=a.DERObjectIdentifier,u=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,f=o.crypto,d=f.DSA,g=f.ECDSA,p=ot;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function S(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==p&&t instanceof p||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Rt(x=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=v(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===i||null==i)&&1==t.isPrivate){var F=new h({name:t.curveName}).getEncodedHex(),E=m(t).getEncodedHex(),w="";return w+=Rt(F,"EC PARAMETERS"),w+=Rt(E,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=S(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==i&&null!=i&&1==t.isPrivate){var x=v(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==i&&null!=i&&1==t.isPrivate){x=m(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==i&&null!=i&&1==t.isPrivate){x=S(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",x,i,n,s)}var A=function(t,e){var i=b(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},b=function(t,e){var i=y.lib.WordArray.random(8),n=y.lib.WordArray.random(8),r=y.PBKDF2(e,i,{keySize:6,iterations:100}),s=y.enc.Hex.parse(t),o=y.TripleDES.encrypt(s,r,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=y.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=y.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=p&&t instanceof p&&1==t.isPrivate){var I=v(t).getEncodedHex();x=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=A(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){I=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=A(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){I=new u({bigint:t.x}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=A(x,i),"ENCRYPTED PRIVATE KEY")}throw"unsupported object nor format"},Ut.getKeyFromCSRPEM=function(t){var e=Ht(t,"CERTIFICATE REQUEST");return Ut.getKeyFromCSRHex(e)},Ut.getKeyFromCSRHex=function(t){var e=Ut.parseCSRHex(t);return Ut.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Ut.parseCSRHex=function(t){var e=pt,i=e.getChildIdx,n=e.getTLV,r={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=i(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=i(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(s,a[2]),r},Ut.getJWKFromKey=function(t){var e={};if(t instanceof ot&&t.isPrivate)return e.kty="RSA",e.n=wt(t.n.toString(16)),e.e=wt(t.e.toString(16)),e.d=wt(t.d.toString(16)),e.p=wt(t.p.toString(16)),e.q=wt(t.q.toString(16)),e.dp=wt(t.dmp1.toString(16)),e.dq=wt(t.dmq1.toString(16)),e.qi=wt(t.coeff.toString(16)),e;if(t instanceof ot&&t.isPublic)return e.kty="RSA",e.n=wt(t.n.toString(16)),e.e=wt(t.e.toString(16)),e;if(t instanceof ft.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=wt(i.x),e.y=wt(i.y),e.d=wt(t.prvKeyHex),e}if(t instanceof ft.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=wt(i.x),e.y=wt(i.y),e}throw"not supported key object"},ot.getPosArrayOfChildrenFromHex=function(t){return pt.getChildIdx(t,0)},ot.getHexValueArrayOfChildrenFromHex=function(t){var e,i=pt.getV,n=i(t,(e=ot.getPosArrayOfChildrenFromHex(t))[0]),r=i(t,e[1]),s=i(t,e[2]),o=i(t,e[3]),a=i(t,e[4]),h=i(t,e[5]),u=i(t,e[6]),c=i(t,e[7]),l=i(t,e[8]);return(e=new Array).push(n,r,s,o,a,h,u,c,l),e},ot.prototype.readPrivateKeyFromPEMString=function(t){var e=Ht(t),i=ot.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},ot.prototype.readPKCS5PrvKeyHex=function(t){var e=ot.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},ot.prototype.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s,o,a,h,u=pt,c=u.getVbyList;if(!1===u.isASN1HEX(t))throw"not ASN.1 hex string";try{e=c(t,0,[2,0,1],"02"),i=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),r=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw"malformed PKCS#8 plain RSA private key"}this.setPrivateEx(e,i,n,r,s,o,a,h)},ot.prototype.readPKCS5PubKeyHex=function(t){var e=pt,i=e.getV;if(!1===e.isASN1HEX(t))throw"keyHex is not ASN.1 hex string";var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw"wrong hex for PKCS#5 public key";var r=i(t,n[0]),s=i(t,n[1]);this.setPublic(r,s)},ot.prototype.readPKCS8PubKeyHex=function(t){var e=pt;if(!1===e.isASN1HEX(t))throw"not ASN.1 hex string";if("06092a864886f70d010101"!==e.getTLVbyList(t,0,[0,0]))throw"not PKCS8 RSA public key";var i=e.getTLVbyList(t,0,[1,0]);this.readPKCS5PubKeyHex(i)},ot.prototype.readCertPubKeyHex=function(t,e){var i,n;(i=new Jt).readCertHex(t),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var qt=new RegExp("");function zt(t,e){for(var i="",n=e/4-t.length,r=0;r>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function Yt(t){for(var e in ft.crypto.Util.DIGESTINFOHEAD){var i=ft.crypto.Util.DIGESTINFOHEAD[e],n=i.length;if(t.substring(0,n)==i)return[e,t.substring(n)]}return[]}function Jt(){var t=pt,e=t.getChildIdx,i=t.getV,n=t.getTLV,r=t.getVbyList,s=t.getTLVbyList,o=t.getIdxbyList,a=t.getVidx,h=t.oidname,u=Jt,c=Ht;this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){return null===this.hex||0!==this.version?this.version:"a003020102"!==s(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return r(this.hex,0,[0,1+this.foffset],"02")},this.getSignatureAlgorithmField=function(){return h(r(this.hex,0,[0,2+this.foffset,0],"06"))},this.getIssuerHex=function(){return s(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return u.hex2dn(this.getIssuerHex())},this.getSubjectHex=function(){return s(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return u.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=r(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=r(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return t.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return o(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return o(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Ut.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){return h(r(this.hex,0,[1,0],"06"))},this.getSignatureValueHex=function(){return r(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmName(),i=this.getSignatureValueHex(),n=s(this.hex,0,[0],"30"),r=new ft.crypto.Signature({alg:e});return r.init(t),r.updateHex(n),r.verify(i)},this.parseExt=function(){if(3!==this.version)return-1;var i=o(this.hex,0,[0,7,0],"30"),n=e(this.hex,i);this.aExtInfo=new Array;for(var s=0;s0&&(u=new Array(i),(new nt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=It(h(Ct("\0\0\0\0\0\0\0\0"+r+u))),l=[];for(n=0;n>8*a-o&255;for(g[0]&=~p,n=0;nthis.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;var r=n[0];return n[1]==function(t){return ft.crypto.Util.hashString(t,r)}(t)},ot.prototype.verifyWithMessageHash=function(t,e){var i=rt(e=(e=e.replace(qt,"")).replace(/[ \n]+/g,""),16);if(i.bitLength()>this.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;n[0];return n[1]==t},ot.prototype.verifyPSS=function(t,e,i,n){var r,s=(r=Ct(t),ft.crypto.Util.hashHex(r,i));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(s,e,i,n)},ot.prototype.verifyWithMessageHashPSS=function(t,e,i,n){var r=new x(e,16);if(r.bitLength()>this.n.bitLength())return!1;var s,o=function(t){return ft.crypto.Util.hashHex(t,i)},a=It(t),h=a.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===n||void 0===n)n=h;else if(-2===n)n=c-h-2;else if(n<-2)throw"invalid salt length";if(c>8*c-u&255;if(0!=(f.charCodeAt(0)&g))throw"bits beyond keysize not zero";var p=Gt(d,f.length,o),y=[];for(s=0;s0)&&-1==(":"+i.join(":")+":").indexOf(":"+p+":"))throw"algorithm '"+p+"' not accepted in the list";if("none"!=p&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Ut.getKey(e)),!("RS"!=y&&"PS"!=y||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==y&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===s.jwsalg2sigalg[g.alg])throw"unsupported alg name: "+p;if("none"==(v=s.jwsalg2sigalg[p]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var S,F=null;try{F=h.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(F)}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(d)},ft.jws.JWS.parse=function(t){var e,i,n,r=t.split("."),s={};if(2!=r.length&&3!=r.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=r[0],i=r[1],3==r.length&&(n=r[2]),s.headerObj=ft.jws.JWS.readSafeJSONString(gt(e)),s.payloadObj=ft.jws.JWS.readSafeJSONString(gt(i)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=gt(i):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==n&&(s.sigHex=xt(n)),s},ft.jws.JWS.verifyJWT=function(t,e,i){var n=ft.jws,r=n.JWS,s=r.readSafeJSONString,o=r.inArray,a=r.includedArray,h=t.split("."),u=h[0],c=h[1],l=(xt(h[2]),s(gt(u))),f=s(gt(c));if(void 0===l.alg)return!1;if(void 0===i.alg)throw"acceptField.alg shall be specified";if(!o(l.alg,i.alg))return!1;if(void 0!==f.iss&&"object"==typeof i.iss&&!o(f.iss,i.iss))return!1;if(void 0!==f.sub&&"object"==typeof i.sub&&!o(f.sub,i.sub))return!1;if(void 0!==f.aud&&"object"==typeof i.aud)if("string"==typeof f.aud){if(!o(f.aud,i.aud))return!1}else if("object"==typeof f.aud&&!a(f.aud,i.aud))return!1;var d=n.IntDate.getNow();return void 0!==i.verifyAt&&"number"==typeof i.verifyAt&&(d=i.verifyAt),void 0!==i.gracePeriod&&"number"==typeof i.gracePeriod||(i.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+i.gracePeriodr&&this.aHeader.pop(),this.aSignature.length>r&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignatures=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},e.SecureRandom=nt,e.rng_seed_time=Z,e.BigInteger=x,e.RSAKey=ot,e.ECDSA=ft.crypto.ECDSA,e.DSA=ft.crypto.DSA,e.Signature=ft.crypto.Signature,e.MessageDigest=ft.crypto.MessageDigest,e.Mac=ft.crypto.Mac,e.Cipher=ft.crypto.Cipher,e.KEYUTIL=Ut,e.ASN1HEX=pt,e.X509=Jt,e.CryptoJS=y,e.b64tohex=E,e.b64toBA=w,e.stoBA=yt,e.BAtos=vt,e.BAtohex=mt,e.stohex=St,e.stob64=function(t){return F(St(t))},e.stob64u=function(t){return Ft(F(St(t)))},e.b64utos=function(t){return vt(w(Et(t)))},e.b64tob64u=Ft,e.b64utob64=Et,e.hex2b64=F,e.hextob64u=wt,e.b64utohex=xt,e.utf8tob64u=dt,e.b64utoutf8=gt,e.utf8tob64=function(t){return F(Ot(Kt(t)))},e.b64toutf8=function(t){return decodeURIComponent(jt(E(t)))},e.utf8tohex=At,e.hextoutf8=bt,e.hextorstr=It,e.rstrtohex=Ct,e.hextob64=Dt,e.hextob64nl=Tt,e.b64nltohex=Pt,e.hextopem=Rt,e.pemtohex=Ht,e.hextoArrayBuffer=function(t){if(t.length%2!=0)throw"input is not even length";if(null==t.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var e=new ArrayBuffer(t.length/2),i=new DataView(e),n=0;ne.length&&(i=e.length);for(var n=0;n300)throw new r(`Failed to fetch ${t}. Response=${s}`,i.status);try{return JSON.parse(s)}catch(e){if(""!==s)return s;throw new r(`Invalid response while trying to fetch ${t}. Response=${s}`,i.status,e)}}}},function(t,e,i){const n=i(5),r=i(3),s=i(16),o=i(18),a=i(20),h=i(1),u=i(2),c=i(0);t.exports=class{constructor({popup:t=new s,iframe:e=new o,openIdConfigResource:i=new a,utils:h,requestHandler:u=new r,w:l=window,url:f=URL}={}){this.popup=t,this.iframe=e,this.openIdConfigResource=i,this.URL=f,this.utils=h,h||(this.utils=new n({openIdConfigResource:this.openIdConfigResource,url:this.URL,popup:this.popup,jsrsasign:c})),this.request=u.request,this.window=l,this.initialized=!1}async init({clientId:t,discoveryEndpoint:e,popup:i={height:.8*window.screen.height,width:400}}){if(!t)throw new u(h.MISSING_CLIENT_ID);try{new this.URL(e)}catch(t){throw new u(h.INVALID_DISCOVERY_ENDPOINT)}await this.openIdConfigResource.init({discoveryEndpoint:e,requestHandler:this.request}),this.popup.init(i),this.clientId=t,this.initialized=!0}async signin(){this._validateInitalize();const t=this.openIdConfigResource.getAuthorizationEndpoint();return this.utils.performOAuthFlowAndGetTokens({origin:this.window.origin,clientId:this.clientId,endpoint:t})}async silentSignin(){this._validateInitalize();const t=this.openIdConfigResource.getAuthorizationEndpoint(),{codeVerifier:e,nonce:i,state:n,url:r}=this.utils.getAuthParamsAndUrl({clientId:this.clientId,origin:this.window.origin,prompt:h.PROMPT,endpoint:t});let s;this.iframe.open(r);try{s=await this.iframe.waitForMessage({messageType:"authorization_response"})}finally{this.iframe.remove()}this.utils.verifyMessage({message:s,state:n});let o=s.data.code;return await this.utils.retrieveTokens({clientId:this.clientId,authCode:o,codeVerifier:e,nonce:i,openId:this.openIdConfigResource,windowOrigin:this.window.origin})}async getUserInfo(t){if(this._validateInitalize(),"string"!=typeof t)throw new u(h.INVALID_ACCESS_TOKEN);return await this.request(this.openIdConfigResource.getUserInfoEndpoint(),{headers:{Authorization:"Bearer "+t}})}async changePassword(t){let e;if(this._validateInitalize(),!t)throw new u(h.MISSING_ID_TOKEN_PAYLOAD);if("string"==typeof t)throw new u(h.INVALID_ID_TOKEN_PAYLOAD);if(!(t.identities&&t.identities[0]&&t.identities[0].id))throw new u(h.INVALID_ID_TOKEN_PAYLOAD);if("cloud_directory"!==t.identities[0].provider)throw new u(h.NOT_CD_USER);e=t.identities[0].id;const i=this.openIdConfigResource.getIssuer()+h.CHANGE_PASSWORD;return this.utils.performOAuthFlowAndGetTokens({userId:e,origin:this.window.origin,clientId:this.clientId,endpoint:i})}async changeDetails(t){if(!t)throw new u(h.MISSING_TOKENS);if(!t.accessToken&&"string"!=typeof t.accessToken)throw new u(h.MISSING_ACCESS_TOKEN);if(!t.idToken&&"string"!=typeof t.idToken)throw new u(h.MISSING_ID_TOKEN);const e=this.openIdConfigResource.getIssuer()+h.GENERATE_CODE,i=await this.request(e,{headers:{Authorization:"Bearer "+t.accessToken+" "+t.idToken}}),n=this.openIdConfigResource.getIssuer()+h.CHANGE_DETAILS;return this.utils.performOAuthFlowAndGetTokens({origin:this.window.origin,clientId:this.clientId,endpoint:n,changeDetailsCode:i})}_validateInitalize(){if(!this.initialized)throw new u(h.FAIL_TO_INITIALIZE)}}},function(t,e,i){i(0);const n=i(2),r=i(11),s=i(3),o=i(14),a=i(1);t.exports=class{constructor({requestHandler:t=new s,tokenValidator:e=new o,url:i=URL,openIdConfigResource:n,popup:r,jsrsasign:a=a}={}){this.URL=i,this.request=t.request,this.tokenValidator=e,this.openIdConfigResource=n,this.popup=r,this.rs=a}buildParams(t){return Object.keys(t).map((function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])})).join("&")}getRandomString(t){return this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(t/2)}sha256(t){return this.rs.KJUR.crypto.Util.sha256(t)}getPKCEFields(){const t=this.getRandomString(a.CODE_VERIFIER_LENGTH);return{codeVerifier:t,codeChallenge:this.sha256(t),state:this.getRandomString(a.STATE_LENGTH),nonce:this.getRandomString(a.NONCE_LENGTH)}}getAuthParamsAndUrl({clientId:t,origin:e,prompt:i,endpoint:n,userId:r,changeDetailsCode:s}){const{codeVerifier:o,codeChallenge:h,state:u,nonce:c}=this.getPKCEFields();let l={client_id:t,response_type:a.RESPONSE_TYPE,state:this.rs.stob64(u),code_challenge:this.rs.stob64(h),code_challenge_method:a.CHALLENGE_METHOD,redirect_uri:e,response_mode:a.RESPONSE_MODE,nonce:c,scope:a.SCOPE};return i&&(l.prompt=i),r&&(l.user_id=r),s&&(l.code=s),{codeVerifier:o,nonce:c,state:u,url:n+"?"+this.buildParams(l)}}async performOAuthFlowAndGetTokens({userId:t,origin:e,clientId:i,endpoint:n,changeDetailsCode:r}){const{codeVerifier:s,state:o,nonce:a,url:h}=this.getAuthParamsAndUrl({userId:t,origin:e,clientId:i,endpoint:n,changeDetailsCode:r});this.popup.open(),this.popup.navigate(h);const u=await this.popup.waitForMessage({messageType:"authorization_response"});this.popup.close(),this.verifyMessage({message:u,state:o});let c=u.data.code;return await this.retrieveTokens({clientId:i,authCode:c,codeVerifier:s,nonce:a,windowOrigin:e})}verifyMessage({message:t,state:e}){if(t.data.error||t.data.error_description)throw new r({description:t.data.error_description,error:t.data.error});if(this.rs.b64utos(t.data.state)!==e)throw new n(a.INVALID_STATE);if(t.origin!==new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin)throw new n(a.INVALID_ORIGIN)}async retrieveTokens({clientId:t,authCode:e,nonce:i,codeVerifier:n,windowOrigin:r}){let s=this.openIdConfigResource.getIssuer(),o={grant_type:"authorization_code",redirect_uri:r,code:e,code_verifier:n};const a=this.buildParams(o),h=this.openIdConfigResource.getTokenEndpoint(),u=await this.request(h,{method:"POST",headers:{Authorization:"Basic "+this.rs.stob64(`${t}:${n}`),"Content-Type":"application/x-www-form-urlencoded"},body:a}),c=await this.openIdConfigResource.getPublicKeys(),l=this.tokenValidator.decodeAndValidate({token:u.access_token,publicKeys:c,issuer:s,clientId:t,nonce:i}),f=this.tokenValidator.decodeAndValidate({token:u.id_token,publicKeys:c,issuer:s,clientId:t,nonce:i});return{accessToken:u.access_token,accessTokenPayload:l,idToken:u.id_token,idTokenPayload:f}}}},function(t,e,i){"use strict";(function(t){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -var n=i(8),r=i(9),s=i(10);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return b(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function b(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return E(this,t,e,i);case"latin1":case"binary":return w(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function B(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||N(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(7))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e,i){const n=i(1),r=i(15);t.exports=class{constructor({jwt:t=i(0)}={}){this.jwt=t}decodeAndValidate({token:t,publicKeys:e,issuer:i,clientId:s,nonce:o}){const a=Math.floor(Date.now()/1e3),h=t.split(".");if(3!==h.length)throw new r(`Invalid JWT token. Got only ${h.length} parts.`);const u=this.jwt.KJUR.jws.JWS.parse(t);if(!u.headerObj)throw new r(n.INVALID_TOKEN);const c=u.headerObj.kid,l=this.getPublicKey(e.keys,c),f=this.jwt.KEYUTIL.getKey(l);if(!this.jwt.KJUR.jws.JWS.verify(t,f,{alg:[n.TOKEN_ALG]}))throw new r(n.INVALID_SIGNATURE);if(u.payloadObj.exp{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(21);t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t);const i={"x-filter-type":`spa:v${n.version}`};this.publicKeys=e(this.getJwksEndpoint(),{headers:i})}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}},function(t){t.exports=JSON.parse('{"name":"ibmcloud-appid-js","version":"0.0.2","description":"IBM Cloud App ID SDK for Single Page Applications","scripts":{"build":"webpack","test":"mocha","coverage":"nyc --reporter=lcov mocha","docs":"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git"},"main":"dist/appid.umd.min.js","nyc":{"all":true,"include":["src/*.js"],"exclude":["**/PopupController.js","**/IFrameController.js","**/OpenIDConfigurationResource.js","**/constants.js"]},"dependencies":{"jsrsasign":"^8.0.12"},"devDependencies":{"node-fetch":"^2.6.0","@babel/cli":"^7.0.0","@babel/core":"^7.5.5","@babel/plugin-transform-runtime":"^7.5.5","@babel/preset-env":"^7.5.5","babel-cli":"^7.0.0-beta.3","chai":"^4.2.0","coveralls":"^3.0.6","gulp-babel":"^8.0.0","mocha":"^6.2.0","nyc":"^14.1.1","webpack":"^4.39.1","webpack-cli":"^3.3.6","docdash":"^1.1.1","jsdoc":"^3.6.3"}}')}]); \ No newline at end of file +var AppID = +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./node_modules/base64-js/index.js": +/*!*****************************************!*\ + !*** ./node_modules/base64-js/index.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/base64-js/index.js?"); + +/***/ }), + +/***/ "./node_modules/buffer/index.js": +/*!**************************************!*\ + !*** ./node_modules/buffer/index.js ***! + \**************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("/* WEBPACK VAR INJECTION */(function(global) {/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n\n\nvar base64 = __webpack_require__(/*! base64-js */ \"./node_modules/base64-js/index.js\")\nvar ieee754 = __webpack_require__(/*! ieee754 */ \"./node_modules/ieee754/index.js\")\nvar isArray = __webpack_require__(/*! isarray */ \"./node_modules/isarray/index.js\")\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://AppID/./node_modules/buffer/index.js?"); + +/***/ }), + +/***/ "./node_modules/ieee754/index.js": +/*!***************************************!*\ + !*** ./node_modules/ieee754/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/ieee754/index.js?"); + +/***/ }), + +/***/ "./node_modules/isarray/index.js": +/*!***************************************!*\ + !*** ./node_modules/isarray/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n\n\n//# sourceURL=webpack://AppID/./node_modules/isarray/index.js?"); + +/***/ }), + +/***/ "./node_modules/jsrsasign/lib/jsrsasign.js": +/*!*************************************************!*\ + !*** ./node_modules/jsrsasign/lib/jsrsasign.js ***! + \*************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\nvar navigator = {};\nnavigator.userAgent = false;\n\nvar window = {};\n/*\n * jsrsasign(all) 8.0.12 (2018-04-22) (c) 2010-2018 Kenji Urushima | kjur.github.com/jsrsasign/license\n */\n\n/*!\nCopyright (c) 2011, Yahoo! Inc. All rights reserved.\nCode licensed under the BSD License:\nhttp://developer.yahoo.com/yui/license.html\nversion: 2.9.0\n*/\nif(YAHOO===undefined){var YAHOO={}}YAHOO.lang={extend:function(g,h,f){if(!h||!g){throw new Error(\"YAHOO.lang.extend failed, please check that all dependencies are included.\")}var d=function(){};d.prototype=h.prototype;g.prototype=new d();g.prototype.constructor=g;g.superclass=h.prototype;if(h.prototype.constructor==Object.prototype.constructor){h.prototype.constructor=h}if(f){var b;for(b in f){g.prototype[b]=f[b]}var e=function(){},c=[\"toString\",\"valueOf\"];try{if(/MSIE/.test(navigator.userAgent)){e=function(j,i){for(b=0;b>>2]>>>(24-(r%4)*8))&255;q[(n+r)>>>2]|=o<<(24-((n+r)%4)*8)}}else{for(var r=0;r>>2]=p[r>>>2]}}this.sigBytes+=s;return this},clamp:function(){var o=this.words;var n=this.sigBytes;o[n>>>2]&=4294967295<<(32-(n%4)*8);o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);n.words=this.words.slice(0);return n},random:function(p){var o=[];for(var n=0;n>>2]>>>(24-(n%4)*8))&255;q.push((s>>>4).toString(16));q.push((s&15).toString(16))}return q.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>3]|=parseInt(p.substr(o,2),16)<<(24-(o%8)*4)}return new l.init(q,n/2)}};var d=m.Latin1={stringify:function(q){var r=q.words;var p=q.sigBytes;var n=[];for(var o=0;o>>2]>>>(24-(o%4)*8))&255;n.push(String.fromCharCode(s))}return n.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>2]|=(p.charCodeAt(o)&255)<<(24-(o%4)*8)}return new l.init(q,n)}};var c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error(\"Malformed UTF-8 data\")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}};var i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init();this._nDataBytes=0},_append:function(n){if(typeof n==\"string\"){n=c.parse(n)}this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data;var x=q.words;var n=q.sigBytes;var t=this.blockSize;var v=t*4;var u=n/v;if(w){u=e.ceil(u)}else{u=e.max((u|0)-this._minBufferSize,0)}var s=u*t;var r=e.min(s*4,n);if(s){for(var p=0;p>>2]&255}};f.BlockCipher=n.extend({cfg:n.cfg.extend({mode:m,padding:h}),reset:function(){n.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;\nthis._mode=c.call(a,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var p=f.CipherParams=k.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(g.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;\nreturn(a?l.create([1398893684,1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=l.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return p.create({ciphertext:a,salt:c})}},j=f.SerializableCipher=k.extend({cfg:k.extend({format:m}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return p.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,\nblockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return\"string\"==typeof a?b.parse(a,this):a}}),g=(g.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=l.random(8));a=v.create({keySize:b+c}).compute(a,d);c=l.create(a.words.slice(b),4*c);a.sigBytes=4*b;return p.create({key:a,iv:c,salt:d})}},s=f.PasswordBasedCipher=j.extend({cfg:j.cfg.extend({kdf:g}),encrypt:function(a,\nb,c,d){d=this.cfg.extend(d);c=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=c.iv;a=j.encrypt.call(this,a,b,c.key,d);a.mixIn(c);return a},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=c.iv;return j.decrypt.call(this,a,b,c.key,d)}})}();\n\n/*\nCryptoJS v3.1.2 aes.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){for(var q=CryptoJS,x=q.lib.BlockCipher,r=q.algo,j=[],y=[],z=[],A=[],B=[],C=[],s=[],u=[],v=[],w=[],g=[],k=0;256>k;k++)g[k]=128>k?k<<1:k<<1^283;for(var n=0,l=0,k=0;256>k;k++){var f=l^l<<1^l<<2^l<<3^l<<4,f=f>>>8^f&255^99;j[n]=f;y[f]=n;var t=g[n],D=g[t],E=g[D],b=257*g[f]^16843008*f;z[n]=b<<24|b>>>8;A[n]=b<<16|b>>>16;B[n]=b<<8|b>>>24;C[n]=b;b=16843009*E^65537*D^257*t^16843008*n;s[f]=b<<24|b>>>8;u[f]=b<<16|b>>>16;v[f]=b<<8|b>>>24;w[f]=b;n?(n=t^g[g[g[E^t]]],l^=g[g[l]]):n=l=1}var F=[0,1,2,4,8,\n16,32,64,128,27,54],r=r.AES=x.extend({_doReset:function(){for(var c=this._key,e=c.words,a=c.sigBytes/4,c=4*((this._nRounds=a+6)+1),b=this._keySchedule=[],h=0;h>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255]):(d=d<<8|d>>>24,d=j[d>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255],d^=F[h/a|0]<<24);b[h]=b[h-a]^d}e=this._invKeySchedule=[];for(a=0;aa||4>=h?d:s[j[d>>>24]]^u[j[d>>>16&255]]^v[j[d>>>\n8&255]]^w[j[d&255]]},encryptBlock:function(c,e){this._doCryptBlock(c,e,this._keySchedule,z,A,B,C,j)},decryptBlock:function(c,e){var a=c[e+1];c[e+1]=c[e+3];c[e+3]=a;this._doCryptBlock(c,e,this._invKeySchedule,s,u,v,w,y);a=c[e+1];c[e+1]=c[e+3];c[e+3]=a},_doCryptBlock:function(c,e,a,b,h,d,j,m){for(var n=this._nRounds,f=c[e]^a[0],g=c[e+1]^a[1],k=c[e+2]^a[2],p=c[e+3]^a[3],l=4,t=1;t>>24]^h[g>>>16&255]^d[k>>>8&255]^j[p&255]^a[l++],r=b[g>>>24]^h[k>>>16&255]^d[p>>>8&255]^j[f&255]^a[l++],s=\nb[k>>>24]^h[p>>>16&255]^d[f>>>8&255]^j[g&255]^a[l++],p=b[p>>>24]^h[f>>>16&255]^d[g>>>8&255]^j[k&255]^a[l++],f=q,g=r,k=s;q=(m[f>>>24]<<24|m[g>>>16&255]<<16|m[k>>>8&255]<<8|m[p&255])^a[l++];r=(m[g>>>24]<<24|m[k>>>16&255]<<16|m[p>>>8&255]<<8|m[f&255])^a[l++];s=(m[k>>>24]<<24|m[p>>>16&255]<<16|m[f>>>8&255]<<8|m[g&255])^a[l++];p=(m[p>>>24]<<24|m[f>>>16&255]<<16|m[g>>>8&255]<<8|m[k&255])^a[l++];c[e]=q;c[e+1]=r;c[e+2]=s;c[e+3]=p},keySize:8});q.AES=x._createHelper(r)})();\n\n/*\nCryptoJS v3.1.2 tripledes-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function j(b,c){var a=(this._lBlock>>>b^this._rBlock)&c;this._rBlock^=a;this._lBlock^=a<>>b^this._lBlock)&c;this._lBlock^=a;this._rBlock^=a<a;a++){var f=q[a]-1;c[a]=b[f>>>5]>>>31-f%32&1}b=this._subKeys=[];for(f=0;16>f;f++){for(var d=b[f]=[],e=r[f],a=0;24>a;a++)d[a/6|0]|=c[(p[a]-1+e)%28]<<31-a%6,d[4+(a/6|0)]|=c[28+(p[a+24]-1+e)%28]<<31-a%6;d[0]=d[0]<<1|d[0]>>>31;for(a=1;7>a;a++)d[a]>>>=\n4*(a-1)+3;d[7]=d[7]<<5|d[7]>>>27}c=this._invSubKeys=[];for(a=0;16>a;a++)c[a]=b[15-a]},encryptBlock:function(b,c){this._doCryptBlock(b,c,this._subKeys)},decryptBlock:function(b,c){this._doCryptBlock(b,c,this._invSubKeys)},_doCryptBlock:function(b,c,a){this._lBlock=b[c];this._rBlock=b[c+1];j.call(this,4,252645135);j.call(this,16,65535);l.call(this,2,858993459);l.call(this,8,16711935);j.call(this,1,1431655765);for(var f=0;16>f;f++){for(var d=a[f],e=this._lBlock,h=this._rBlock,g=0,k=0;8>k;k++)g|=s[k][((h^\nd[k])&t[k])>>>0];this._lBlock=h;this._rBlock=e^g}a=this._lBlock;this._lBlock=this._rBlock;this._rBlock=a;j.call(this,1,1431655765);l.call(this,8,16711935);l.call(this,2,858993459);j.call(this,16,65535);j.call(this,4,252645135);b[c]=this._lBlock;b[c+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});h.DES=e._createHelper(m);g=g.TripleDES=e.extend({_doReset:function(){var b=this._key.words;this._des1=m.createEncryptor(n.create(b.slice(0,2)));this._des2=m.createEncryptor(n.create(b.slice(2,4)));this._des3=\nm.createEncryptor(n.create(b.slice(4,6)))},encryptBlock:function(b,c){this._des1.encryptBlock(b,c);this._des2.decryptBlock(b,c);this._des3.encryptBlock(b,c)},decryptBlock:function(b,c){this._des3.decryptBlock(b,c);this._des2.encryptBlock(b,c);this._des1.decryptBlock(b,c)},keySize:6,ivSize:2,blockSize:2});h.TripleDES=e._createHelper(g)})();\n\n/*\nCryptoJS v3.1.2 enc-base64.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join(\"\")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d<\ne;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\"}})();\n\n/*\nCryptoJS v3.1.2 md5.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(E){function h(a,f,g,j,p,h,k){a=a+(f&g|~f&j)+p+k;return(a<>>32-h)+f}function k(a,f,g,j,p,h,k){a=a+(f&j|g&~j)+p+k;return(a<>>32-h)+f}function l(a,f,g,j,h,k,l){a=a+(f^g^j)+h+l;return(a<>>32-k)+f}function n(a,f,g,j,h,k,l){a=a+(g^(f|~j))+h+l;return(a<>>32-k)+f}for(var r=CryptoJS,q=r.lib,F=q.WordArray,s=q.Hasher,q=r.algo,a=[],t=0;64>t;t++)a[t]=4294967296*E.abs(E.sin(t+1))|0;q=q.MD5=s.extend({_doReset:function(){this._hash=new F.init([1732584193,4023233417,2562383102,271733878])},\n_doProcessBlock:function(m,f){for(var g=0;16>g;g++){var j=f+g,p=m[j];m[j]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360}var g=this._hash.words,j=m[f+0],p=m[f+1],q=m[f+2],r=m[f+3],s=m[f+4],t=m[f+5],u=m[f+6],v=m[f+7],w=m[f+8],x=m[f+9],y=m[f+10],z=m[f+11],A=m[f+12],B=m[f+13],C=m[f+14],D=m[f+15],b=g[0],c=g[1],d=g[2],e=g[3],b=h(b,c,d,e,j,7,a[0]),e=h(e,b,c,d,p,12,a[1]),d=h(d,e,b,c,q,17,a[2]),c=h(c,d,e,b,r,22,a[3]),b=h(b,c,d,e,s,7,a[4]),e=h(e,b,c,d,t,12,a[5]),d=h(d,e,b,c,u,17,a[6]),c=h(c,d,e,b,v,22,a[7]),\nb=h(b,c,d,e,w,7,a[8]),e=h(e,b,c,d,x,12,a[9]),d=h(d,e,b,c,y,17,a[10]),c=h(c,d,e,b,z,22,a[11]),b=h(b,c,d,e,A,7,a[12]),e=h(e,b,c,d,B,12,a[13]),d=h(d,e,b,c,C,17,a[14]),c=h(c,d,e,b,D,22,a[15]),b=k(b,c,d,e,p,5,a[16]),e=k(e,b,c,d,u,9,a[17]),d=k(d,e,b,c,z,14,a[18]),c=k(c,d,e,b,j,20,a[19]),b=k(b,c,d,e,t,5,a[20]),e=k(e,b,c,d,y,9,a[21]),d=k(d,e,b,c,D,14,a[22]),c=k(c,d,e,b,s,20,a[23]),b=k(b,c,d,e,x,5,a[24]),e=k(e,b,c,d,C,9,a[25]),d=k(d,e,b,c,r,14,a[26]),c=k(c,d,e,b,w,20,a[27]),b=k(b,c,d,e,B,5,a[28]),e=k(e,b,\nc,d,q,9,a[29]),d=k(d,e,b,c,v,14,a[30]),c=k(c,d,e,b,A,20,a[31]),b=l(b,c,d,e,t,4,a[32]),e=l(e,b,c,d,w,11,a[33]),d=l(d,e,b,c,z,16,a[34]),c=l(c,d,e,b,C,23,a[35]),b=l(b,c,d,e,p,4,a[36]),e=l(e,b,c,d,s,11,a[37]),d=l(d,e,b,c,v,16,a[38]),c=l(c,d,e,b,y,23,a[39]),b=l(b,c,d,e,B,4,a[40]),e=l(e,b,c,d,j,11,a[41]),d=l(d,e,b,c,r,16,a[42]),c=l(c,d,e,b,u,23,a[43]),b=l(b,c,d,e,x,4,a[44]),e=l(e,b,c,d,A,11,a[45]),d=l(d,e,b,c,D,16,a[46]),c=l(c,d,e,b,q,23,a[47]),b=n(b,c,d,e,j,6,a[48]),e=n(e,b,c,d,v,10,a[49]),d=n(d,e,b,c,\nC,15,a[50]),c=n(c,d,e,b,t,21,a[51]),b=n(b,c,d,e,A,6,a[52]),e=n(e,b,c,d,r,10,a[53]),d=n(d,e,b,c,y,15,a[54]),c=n(c,d,e,b,p,21,a[55]),b=n(b,c,d,e,w,6,a[56]),e=n(e,b,c,d,D,10,a[57]),d=n(d,e,b,c,u,15,a[58]),c=n(c,d,e,b,B,21,a[59]),b=n(b,c,d,e,s,6,a[60]),e=n(e,b,c,d,z,10,a[61]),d=n(d,e,b,c,q,15,a[62]),c=n(c,d,e,b,x,21,a[63]);g[0]=g[0]+b|0;g[1]=g[1]+c|0;g[2]=g[2]+d|0;g[3]=g[3]+e|0},_doFinalize:function(){var a=this._data,f=a.words,g=8*this._nDataBytes,j=8*a.sigBytes;f[j>>>5]|=128<<24-j%32;var h=E.floor(g/\n4294967296);f[(j+64>>>9<<4)+15]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;f[(j+64>>>9<<4)+14]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360;a.sigBytes=4*(f.length+1);this._process();a=this._hash;f=a.words;for(g=0;4>g;g++)j=f[g],f[g]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=s.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=s._createHelper(q);r.HmacMD5=s._createHmacHelper(q)})(Math);\n\n/*\nCryptoJS v3.1.2 sha1-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var k=CryptoJS,b=k.lib,m=b.WordArray,l=b.Hasher,d=[],b=k.algo.SHA1=l.extend({_doReset:function(){this._hash=new m.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(n,p){for(var a=this._hash.words,e=a[0],f=a[1],h=a[2],j=a[3],b=a[4],c=0;80>c;c++){if(16>c)d[c]=n[p+c]|0;else{var g=d[c-3]^d[c-8]^d[c-14]^d[c-16];d[c]=g<<1|g>>>31}g=(e<<5|e>>>27)+b+d[c];g=20>c?g+((f&h|~f&j)+1518500249):40>c?g+((f^h^j)+1859775393):60>c?g+((f&h|f&j|h&j)-1894007588):g+((f^h^\nj)-899497514);b=j;j=h;h=f<<30|f>>>2;f=e;e=g}a[0]=a[0]+e|0;a[1]=a[1]+f|0;a[2]=a[2]+h|0;a[3]=a[3]+j|0;a[4]=a[4]+b|0},_doFinalize:function(){var b=this._data,d=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=Math.floor(a/4294967296);d[(e+64>>>9<<4)+15]=a;b.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var b=l.clone.call(this);b._hash=this._hash.clone();return b}});k.SHA1=l._createHelper(b);k.HmacSHA1=l._createHmacHelper(b)})();\n\n/*\nCryptoJS v3.1.2 sha256-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(k){for(var g=CryptoJS,h=g.lib,v=h.WordArray,j=h.Hasher,h=g.algo,s=[],t=[],u=function(q){return 4294967296*(q-(q|0))|0},l=2,b=0;64>b;){var d;a:{d=l;for(var w=k.sqrt(d),r=2;r<=w;r++)if(!(d%r)){d=!1;break a}d=!0}d&&(8>b&&(s[b]=u(k.pow(l,0.5))),t[b]=u(k.pow(l,1/3)),b++);l++}var n=[],h=h.SHA256=j.extend({_doReset:function(){this._hash=new v.init(s.slice(0))},_doProcessBlock:function(q,h){for(var a=this._hash.words,c=a[0],d=a[1],b=a[2],k=a[3],f=a[4],g=a[5],j=a[6],l=a[7],e=0;64>e;e++){if(16>e)n[e]=\nq[h+e]|0;else{var m=n[e-15],p=n[e-2];n[e]=((m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3)+n[e-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[e-16]}m=l+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&g^~f&j)+t[e]+n[e];p=((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&d^c&b^d&b);l=j;j=g;g=f;f=k+m|0;k=b;b=d;d=c;c=m+p|0}a[0]=a[0]+c|0;a[1]=a[1]+d|0;a[2]=a[2]+b|0;a[3]=a[3]+k|0;a[4]=a[4]+f|0;a[5]=a[5]+g|0;a[6]=a[6]+j|0;a[7]=a[7]+l|0},_doFinalize:function(){var d=this._data,b=d.words,a=8*this._nDataBytes,c=8*d.sigBytes;\nb[c>>>5]|=128<<24-c%32;b[(c+64>>>9<<4)+14]=k.floor(a/4294967296);b[(c+64>>>9<<4)+15]=a;d.sigBytes=4*b.length;this._process();return this._hash},clone:function(){var b=j.clone.call(this);b._hash=this._hash.clone();return b}});g.SHA256=j._createHelper(h);g.HmacSHA256=j._createHmacHelper(h)})(Math);\n\n/*\nCryptoJS v3.1.2 sha224-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var b=CryptoJS,d=b.lib.WordArray,a=b.algo,c=a.SHA256,a=a.SHA224=c.extend({_doReset:function(){this._hash=new d.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var a=c._doFinalize.call(this);a.sigBytes-=4;return a}});b.SHA224=c._createHelper(a);b.HmacSHA224=c._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 sha512-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function a(){return d.create.apply(d,arguments)}for(var n=CryptoJS,r=n.lib.Hasher,e=n.x64,d=e.Word,T=e.WordArray,e=n.algo,ea=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),\na(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,\n2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),\na(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,\n3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],w=0;80>w;w++)v[w]=a();e=e.SHA512=r.extend({_doReset:function(){this._hash=new T.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(a,d){for(var f=this._hash.words,\nF=f[0],e=f[1],n=f[2],r=f[3],G=f[4],H=f[5],I=f[6],f=f[7],w=F.high,J=F.low,X=e.high,K=e.low,Y=n.high,L=n.low,Z=r.high,M=r.low,$=G.high,N=G.low,aa=H.high,O=H.low,ba=I.high,P=I.low,ca=f.high,Q=f.low,k=w,g=J,z=X,x=K,A=Y,y=L,U=Z,B=M,l=$,h=N,R=aa,C=O,S=ba,D=P,V=ca,E=Q,m=0;80>m;m++){var s=v[m];if(16>m)var j=s.high=a[d+2*m]|0,b=s.low=a[d+2*m+1]|0;else{var j=v[m-15],b=j.high,p=j.low,j=(b>>>1|p<<31)^(b>>>8|p<<24)^b>>>7,p=(p>>>1|b<<31)^(p>>>8|b<<24)^(p>>>7|b<<25),u=v[m-2],b=u.high,c=u.low,u=(b>>>19|c<<13)^(b<<\n3|c>>>29)^b>>>6,c=(c>>>19|b<<13)^(c<<3|b>>>29)^(c>>>6|b<<26),b=v[m-7],W=b.high,t=v[m-16],q=t.high,t=t.low,b=p+b.low,j=j+W+(b>>>0

>>0?1:0),b=b+c,j=j+u+(b>>>0>>0?1:0),b=b+t,j=j+q+(b>>>0>>0?1:0);s.high=j;s.low=b}var W=l&R^~l&S,t=h&C^~h&D,s=k&z^k&A^z&A,T=g&x^g&y^x&y,p=(k>>>28|g<<4)^(k<<30|g>>>2)^(k<<25|g>>>7),u=(g>>>28|k<<4)^(g<<30|k>>>2)^(g<<25|k>>>7),c=ea[m],fa=c.high,da=c.low,c=E+((h>>>14|l<<18)^(h>>>18|l<<14)^(h<<23|l>>>9)),q=V+((l>>>14|h<<18)^(l>>>18|h<<14)^(l<<23|h>>>9))+(c>>>0>>0?1:\n0),c=c+t,q=q+W+(c>>>0>>0?1:0),c=c+da,q=q+fa+(c>>>0>>0?1:0),c=c+b,q=q+j+(c>>>0>>0?1:0),b=u+T,s=p+s+(b>>>0>>0?1:0),V=S,E=D,S=R,D=C,R=l,C=h,h=B+c|0,l=U+q+(h>>>0>>0?1:0)|0,U=A,B=y,A=z,y=x,z=k,x=g,g=c+b|0,k=q+s+(g>>>0>>0?1:0)|0}J=F.low=J+g;F.high=w+k+(J>>>0>>0?1:0);K=e.low=K+x;e.high=X+z+(K>>>0>>0?1:0);L=n.low=L+y;n.high=Y+A+(L>>>0>>0?1:0);M=r.low=M+B;r.high=Z+U+(M>>>0>>0?1:0);N=G.low=N+h;G.high=$+l+(N>>>0>>0?1:0);O=H.low=O+C;H.high=aa+R+(O>>>0>>0?1:0);P=I.low=P+D;\nI.high=ba+S+(P>>>0>>0?1:0);Q=f.low=Q+E;f.high=ca+V+(Q>>>0>>0?1:0)},_doFinalize:function(){var a=this._data,d=a.words,f=8*this._nDataBytes,e=8*a.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+128>>>10<<5)+30]=Math.floor(f/4294967296);d[(e+128>>>10<<5)+31]=f;a.sigBytes=4*d.length;this._process();return this._hash.toX32()},clone:function(){var a=r.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});n.SHA512=r._createHelper(e);n.HmacSHA512=r._createHmacHelper(e)})();\n\n/*\nCryptoJS v3.1.2 sha384-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,a=c.x64,b=a.Word,e=a.WordArray,a=c.algo,d=a.SHA512,a=a.SHA384=d.extend({_doReset:function(){this._hash=new e.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var a=d._doFinalize.call(this);a.sigBytes-=16;return a}});c.SHA384=\nd._createHelper(a);c.HmacSHA384=d._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 ripemd160-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n/*\n\n(c) 2012 by Cedric Mesnil. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n(function(){var q=CryptoJS,d=q.lib,n=d.WordArray,p=d.Hasher,d=q.algo,x=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),y=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),z=n.create([11,14,15,12,\n5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),A=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),B=n.create([0,1518500249,1859775393,2400959708,2840853838]),C=n.create([1352829926,1548603684,1836072691,\n2053994217,0]),d=d.RIPEMD160=p.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,v){for(var b=0;16>b;b++){var c=v+b,f=e[c];e[c]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360}var c=this._hash.words,f=B.words,d=C.words,n=x.words,q=y.words,p=z.words,w=A.words,t,g,h,j,r,u,k,l,m,s;u=t=c[0];k=g=c[1];l=h=c[2];m=j=c[3];s=r=c[4];for(var a,b=0;80>b;b+=1)a=t+e[v+n[b]]|0,a=16>b?a+((g^h^j)+f[0]):32>b?a+((g&h|~g&j)+f[1]):48>b?\na+(((g|~h)^j)+f[2]):64>b?a+((g&j|h&~j)+f[3]):a+((g^(h|~j))+f[4]),a|=0,a=a<>>32-p[b],a=a+r|0,t=r,r=j,j=h<<10|h>>>22,h=g,g=a,a=u+e[v+q[b]]|0,a=16>b?a+((k^(l|~m))+d[0]):32>b?a+((k&m|l&~m)+d[1]):48>b?a+(((k|~l)^m)+d[2]):64>b?a+((k&l|~k&m)+d[3]):a+((k^l^m)+d[4]),a|=0,a=a<>>32-w[b],a=a+s|0,u=s,s=m,m=l<<10|l>>>22,l=k,k=a;a=c[1]+h+m|0;c[1]=c[2]+j+s|0;c[2]=c[3]+r+u|0;c[3]=c[4]+t+k|0;c[4]=c[0]+g+l|0;c[0]=a},_doFinalize:function(){var e=this._data,d=e.words,b=8*this._nDataBytes,c=8*e.sigBytes;\nd[c>>>5]|=128<<24-c%32;d[(c+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;e.sigBytes=4*(d.length+1);this._process();e=this._hash;d=e.words;for(b=0;5>b;b++)c=d[b],d[b]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return e},clone:function(){var d=p.clone.call(this);d._hash=this._hash.clone();return d}});q.RIPEMD160=p._createHelper(d);q.HmacRIPEMD160=p._createHmacHelper(d)})(Math);\n\n/*\nCryptoJS v3.1.2 hmac.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,k=c.enc.Utf8;c.algo.HMAC=c.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;\"string\"==typeof b&&(b=k.parse(b));var c=a.blockSize,e=4*c;b.sigBytes>e&&(b=a.finalize(b));b.clamp();for(var f=this._oKey=b.clone(),g=this._iKey=b.clone(),h=f.words,j=g.words,d=0;d>6)+b64map.charAt(e&63)}if(b+1==d.length){e=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(e<<2)}else{if(b+2==d.length){e=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(e>>2)+b64map.charAt((e&3)<<4)}}if(b64pad){while((a.length&3)>0){a+=b64pad}}return a}function b64tohex(f){var d=\"\";var e;var b=0;var c;var a;for(e=0;e>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(e){var d=b64tohex(e);var c;var b=new Array();for(c=0;2*c=0){var d=a*this[f++]+b[e]+h;h=Math.floor(d/67108864);b[e++]=d&67108863}return h}function am2(f,q,r,e,o,a){var k=q&32767,p=q>>15;while(--a>=0){var d=this[f]&32767;var g=this[f++]>>15;var b=p*d+g*k;d=k*d+((b&32767)<<15)+r[e]+(o&1073741823);o=(d>>>30)+(b>>>15)+p*g+(o>>>30);r[e++]=d&1073741823}return o}function am3(f,q,r,e,o,a){var k=q&16383,p=q>>14;while(--a>=0){var d=this[f]&16383;var g=this[f++]>>14;var b=p*d+g*k;d=k*d+((b&16383)<<14)+r[e]+o;o=(d>>28)+(b>>14)+p*g;r[e++]=d&268435455}return o}if(j_lm&&(navigator.appName==\"Microsoft Internet Explorer\")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator.appName!=\"Netscape\")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=((1<=0;--a){b[a]=this[a]}b.t=this.t;b.s=this.s}function bnpFromInt(a){this.t=1;this.s=(a<0)?-1:0;if(a>0){this[0]=a}else{if(a<-1){this[0]=a+this.DV}else{this.t=0}}}function nbv(a){var b=nbi();b.fromInt(a);return b}function bnpFromString(h,c){var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==256){e=8}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{this.fromRadix(h,c);return}}}}}}this.t=0;this.s=0;var g=h.length,d=false,f=0;while(--g>=0){var a=(e==8)?h[g]&255:intAt(h,g);if(a<0){if(h.charAt(g)==\"-\"){d=true}continue}d=false;if(f==0){this[this.t++]=a}else{if(f+e>this.DB){this[this.t-1]|=(a&((1<<(this.DB-f))-1))<>(this.DB-f))}else{this[this.t-1]|=a<=this.DB){f-=this.DB}}if(e==8&&(h[0]&128)!=0){this.s=-1;if(f>0){this[this.t-1]|=((1<<(this.DB-f))-1)<0&&this[this.t-1]==a){--this.t}}function bnToString(c){if(this.s<0){return\"-\"+this.negate().toString(c)}var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{return this.toRadix(c)}}}}}var g=(1<0){if(j>j)>0){a=true;h=int2char(l)}while(f>=0){if(j>(j+=this.DB-e)}else{l=(this[f]>>(j-=e))&g;if(j<=0){j+=this.DB;--f}}if(l>0){a=true}if(a){h+=int2char(l)}}}return a?h:\"0\"}function bnNegate(){var a=nbi();BigInteger.ZERO.subTo(this,a);return a}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(b){var d=this.s-b.s;if(d!=0){return d}var c=this.t;d=c-b.t;if(d!=0){return(this.s<0)?-d:d}while(--c>=0){if((d=this[c]-b[c])!=0){return d}}return 0}function nbits(a){var c=1,b;if((b=a>>>16)!=0){a=b;c+=16}if((b=a>>8)!=0){a=b;c+=8}if((b=a>>4)!=0){a=b;c+=4}if((b=a>>2)!=0){a=b;c+=2}if((b=a>>1)!=0){a=b;c+=1}return c}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(c,b){var a;for(a=this.t-1;a>=0;--a){b[a+c]=this[a]}for(a=c-1;a>=0;--a){b[a]=0}b.t=this.t+c;b.s=this.s}function bnpDRShiftTo(c,b){for(var a=c;a=0;--d){e[d+f+1]=(this[d]>>a)|h;h=(this[d]&g)<=0;--d){e[d]=0}e[f]=h;e.t=this.t+f+1;e.s=this.s;e.clamp()}function bnpRShiftTo(g,d){d.s=this.s;var e=Math.floor(g/this.DB);if(e>=this.t){d.t=0;return}var b=g%this.DB;var a=this.DB-b;var f=(1<>b;for(var c=e+1;c>b}if(b>0){d[this.t-e-1]|=(this.s&f)<>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g-=d.s}f.s=(g<0)?-1:0;if(g<-1){f[e++]=this.DV+g}else{if(g>0){f[e++]=g}}f.t=e;f.clamp()}function bnpMultiplyTo(c,e){var b=this.abs(),f=c.abs();var d=b.t;e.t=d+f.t;while(--d>=0){e[d]=0}for(d=0;d=0){d[b]=0}for(b=0;b=a.DV){d[b+a.t]-=a.DV;d[b+a.t+1]=1}}if(d.t>0){d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)}d.s=0;d.clamp()}function bnpDivRemTo(n,h,g){var w=n.abs();if(w.t<=0){return}var k=this.abs();if(k.t0){w.lShiftTo(v,d);k.lShiftTo(v,g)}else{w.copyTo(d);k.copyTo(g)}var p=d.t;var b=d[p-1];if(b==0){return}var o=b*(1<1)?d[p-2]>>this.F2:0);var A=this.FV/o,z=(1<=0){g[g.t++]=1;g.subTo(f,g)}BigInteger.ONE.dlShiftTo(p,f);f.subTo(d,d);while(d.t=0){var c=(g[--u]==b)?this.DM:Math.floor(g[u]*A+(g[u-1]+x)*z);if((g[u]+=d.am(0,c,g,s,0,p))0){g.rShiftTo(v,g)}if(a<0){BigInteger.ZERO.subTo(g,g)}}function bnMod(b){var c=nbi();this.abs().divRemTo(b,null,c);if(this.s<0&&c.compareTo(BigInteger.ZERO)>0){b.subTo(c,c)}return c}function Classic(a){this.m=a}function cConvert(a){if(a.s<0||a.compareTo(this.m)>=0){return a.mod(this.m)}else{return a}}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var a=this[0];if((a&1)==0){return 0}var b=a&3;b=(b*(2-(a&15)*b))&15;b=(b*(2-(a&255)*b))&255;b=(b*(2-(((a&65535)*b)&65535)))&65535;b=(b*(2-a*b%this.DV))%this.DV;return(b>0)?this.DV-b:-b}function Montgomery(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(a.DB-15))-1;this.mt2=2*a.t}function montConvert(a){var b=nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);if(a.s<0&&b.compareTo(BigInteger.ZERO)>0){this.m.subTo(b,b)}return b}function montRevert(a){var b=nbi();a.copyTo(b);this.reduce(b);return b}function montReduce(a){while(a.t<=this.mt2){a[a.t++]=0}for(var c=0;c>15)*this.mpl)&this.um)<<15))&a.DM;b=c+this.m.t;a[b]+=this.m.am(0,d,a,c,0,this.m.t);while(a[b]>=a.DV){a[b]-=a.DV;a[++b]++}}a.clamp();a.drShiftTo(this.m.t,a);if(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(h,j){if(h>4294967295||h<1){return BigInteger.ONE}var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;d.copyTo(f);while(--c>=0){j.sqrTo(f,a);if((h&(1<0){j.mulTo(a,d,f)}else{var b=f;f=a;a=b}}return j.revert(f)}function bnModPowInt(b,a){var c;if(b<256||a.isEven()){c=new Classic(a)}else{c=new Montgomery(a)}return this.exp(b,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction bnClone(){var a=nbi();this.copyTo(a);return a}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this[0]}else{if(this.t==0){return 0}}}return((this[1]&((1<<(32-this.DB))-1))<>24}function bnShortValue(){return(this.t==0)?this.s:(this[0]<<16)>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this[0]<=0)){return 0}else{return 1}}}function bnpToRadix(c){if(c==null){c=10}if(this.signum()==0||c<2||c>36){return\"0\"}var f=this.chunkSize(c);var e=Math.pow(c,f);var i=nbv(e),j=nbi(),h=nbi(),g=\"\";this.divRemTo(i,j,h);while(j.signum()>0){g=(e+h.intValue()).toString(c).substr(1)+g;j.divRemTo(i,j,h)}return h.intValue().toString(c)+g}function bnpFromRadix(m,h){this.fromInt(0);if(h==null){h=10}var f=this.chunkSize(h);var g=Math.pow(h,f),e=false,a=0,l=0;for(var c=0;c=f){this.dMultiply(g);this.dAddOffset(l,0);a=0;l=0}}if(a>0){this.dMultiply(Math.pow(h,a));this.dAddOffset(l,0)}if(e){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(f,e,h){if(\"number\"==typeof e){if(f<2){this.fromInt(1)}else{this.fromNumber(f,h);if(!this.testBit(f-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(f-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(e)){this.dAddOffset(2,0);if(this.bitLength()>f){this.subTo(BigInteger.ONE.shiftLeft(f-1),this)}}}}else{var d=new Array(),g=f&7;d.length=(f>>3)+1;e.nextBytes(d);if(g>0){d[0]&=((1<0){if(e>e)!=(this.s&this.DM)>>e){c[a++]=f|(this.s<<(this.DB-e))}while(b>=0){if(e<8){f=(this[b]&((1<>(e+=this.DB-8)}else{f=(this[b]>>(e-=8))&255;if(e<=0){e+=this.DB;--b}}if((f&128)!=0){f|=-256}if(a==0&&(this.s&128)!=(f&128)){++a}if(a>0||f!=this.s){c[a++]=f}}}return c}function bnEquals(b){return(this.compareTo(b)==0)}function bnMin(b){return(this.compareTo(b)<0)?this:b}function bnMax(b){return(this.compareTo(b)>0)?this:b}function bnpBitwiseTo(c,h,e){var d,g,b=Math.min(c.t,this.t);for(d=0;d>=16;b+=16}if((a&255)==0){a>>=8;b+=8}if((a&15)==0){a>>=4;b+=4}if((a&3)==0){a>>=2;b+=2}if((a&1)==0){++b}return b}function bnGetLowestSetBit(){for(var a=0;a=this.t){return(this.s!=0)}return((this[a]&(1<<(b%this.DB)))!=0)}function bnpChangeBit(c,b){var a=BigInteger.ONE.shiftLeft(c);this.bitwiseTo(a,b,a);return a}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(d,f){var e=0,g=0,b=Math.min(d.t,this.t);while(e>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g+=d.s}f.s=(g<0)?-1:0;if(g>0){f[e++]=g}else{if(g<-1){f[e++]=this.DV+g}}f.t=e;f.clamp()}function bnAdd(b){var c=nbi();this.addTo(b,c);return c}function bnSubtract(b){var c=nbi();this.subTo(b,c);return c}function bnMultiply(b){var c=nbi();this.multiplyTo(b,c);return c}function bnSquare(){var a=nbi();this.squareTo(a);return a}function bnDivide(b){var c=nbi();this.divRemTo(b,c,null);return c}function bnRemainder(b){var c=nbi();this.divRemTo(b,null,c);return c}function bnDivideAndRemainder(b){var d=nbi(),c=nbi();this.divRemTo(b,d,c);return new Array(d,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(b,a){if(b==0){return}while(this.t<=a){this[this.t++]=0}this[a]+=b;while(this[a]>=this.DV){this[a]-=this.DV;if(++a>=this.t){this[this.t++]=0}++this[a]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,c,b){a.multiplyTo(c,b)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp())}function bnpMultiplyLowerTo(b,f,e){var d=Math.min(this.t+b.t,f);e.s=0;e.t=d;while(d>0){e[--d]=0}var c;for(c=e.t-this.t;d=0){d[c]=0}for(c=Math.max(e-this.t,0);c2*this.m.t){return a.mod(this.m)}else{if(a.compareTo(this.m)<0){return a}else{var b=nbi();a.copyTo(b);this.reduce(b);return b}}}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1){a.t=this.m.t+1;a.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0){a.dAddOffset(1,this.m.t+1)}a.subTo(this.r2,a);while(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(q,f){var o=q.bitLength(),h,b=nbv(1),v;if(o<=0){return b}else{if(o<18){h=1}else{if(o<48){h=3}else{if(o<144){h=4}else{if(o<768){h=5}else{h=6}}}}}if(o<8){v=new Classic(f)}else{if(f.isEven()){v=new Barrett(f)}else{v=new Montgomery(f)}}var p=new Array(),d=3,s=h-1,a=(1<1){var A=nbi();v.sqrTo(p[1],A);while(d<=a){p[d]=nbi();v.mulTo(A,p[d-2],p[d]);d+=2}}var l=q.t-1,x,u=true,c=nbi(),y;o=nbits(q[l])-1;while(l>=0){if(o>=s){x=(q[l]>>(o-s))&a}else{x=(q[l]&((1<<(o+1))-1))<<(s-o);if(l>0){x|=q[l-1]>>(this.DB+o-s)}}d=h;while((x&1)==0){x>>=1;--d}if((o-=d)<0){o+=this.DB;--l}if(u){p[x].copyTo(b);u=false}else{while(d>1){v.sqrTo(b,c);v.sqrTo(c,b);d-=2}if(d>0){v.sqrTo(b,c)}else{y=b;b=c;c=y}v.mulTo(c,p[x],b)}while(l>=0&&(q[l]&(1<0){b.rShiftTo(f,b);h.rShiftTo(f,h)}while(b.signum()>0){if((d=b.getLowestSetBit())>0){b.rShiftTo(d,b)}if((d=h.getLowestSetBit())>0){h.rShiftTo(d,h)}if(b.compareTo(h)>=0){b.subTo(h,b);b.rShiftTo(1,b)}else{h.subTo(b,h);h.rShiftTo(1,h)}}if(f>0){h.lShiftTo(f,h)}return h}function bnpModInt(e){if(e<=0){return 0}var c=this.DV%e,b=(this.s<0)?e-1:0;if(this.t>0){if(c==0){b=this[0]%e}else{for(var a=this.t-1;a>=0;--a){b=(c*b+this[a])%e}}}return b}function bnModInverse(f){var j=f.isEven();if((this.isEven()&&j)||f.signum()==0){return BigInteger.ZERO}var i=f.clone(),h=this.clone();var g=nbv(1),e=nbv(0),l=nbv(0),k=nbv(1);while(i.signum()!=0){while(i.isEven()){i.rShiftTo(1,i);if(j){if(!g.isEven()||!e.isEven()){g.addTo(this,g);e.subTo(f,e)}g.rShiftTo(1,g)}else{if(!e.isEven()){e.subTo(f,e)}}e.rShiftTo(1,e)}while(h.isEven()){h.rShiftTo(1,h);if(j){if(!l.isEven()||!k.isEven()){l.addTo(this,l);k.subTo(f,k)}l.rShiftTo(1,l)}else{if(!k.isEven()){k.subTo(f,k)}}k.rShiftTo(1,k)}if(i.compareTo(h)>=0){i.subTo(h,i);if(j){g.subTo(l,g)}e.subTo(k,e)}else{h.subTo(i,h);if(j){l.subTo(g,l)}k.subTo(e,k)}}if(h.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(k.compareTo(f)>=0){return k.subtract(f)}if(k.signum()<0){k.addTo(f,k)}else{return k}if(k.signum()<0){return k.add(f)}else{return k}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(e){var d,b=this.abs();if(b.t==1&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d>1;if(f>lowprimes.length){f=lowprimes.length}var b=nbi();for(var e=0;e>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(window!==undefined&&(window.crypto!==undefined||window.msCrypto!==undefined)){var crypto=window.crypto||window.msCrypto;if(crypto.getRandomValues){var ua=new Uint8Array(32);crypto.getRandomValues(ua);for(t=0;t<32;++t){rng_pool[rng_pptr++]=ua[t]}}else{if(navigator.appName==\"Netscape\"&&navigator.appVersion<\"5\"){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr=0&&h>0){var f=e.charCodeAt(d--);if(f<128){g[--h]=f}else{if((f>127)&&(f<2048)){g[--h]=(f&63)|128;g[--h]=(f>>6)|192}else{g[--h]=(f&63)|128;g[--h]=((f>>6)&63)|128;g[--h]=(f>>12)|224}}}g[--h]=0;var b=new SecureRandom();var a=new Array();while(h>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}g[--h]=a[0]}g[--h]=2;g[--h]=0;return new BigInteger(g)}function oaep_mgf1_arr(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255])));d+=1}return b}function oaep_pad(q,a,f,l){var c=KJUR.crypto.MessageDigest;var o=KJUR.crypto.Util;var b=null;if(!f){f=\"sha1\"}if(typeof f===\"string\"){b=c.getCanonicalAlgName(f);l=c.getHashLength(b);f=function(i){return hextorstr(o.hashHex(rstrtohex(i),b))}}if(q.length+2*l+2>a){throw\"Message too long for RSA\"}var k=\"\",e;for(e=0;e0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{throw\"Invalid RSA public key\"}}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var e=this.doPublic(a);if(e==null){return null}var b=e.toString(16);if((b.length&1)==0){return b}else{return\"0\"+b}}function RSAEncryptOAEP(f,e,b){var a=oaep_pad(f,(this.n.bitLength()+7)>>3,e,b);if(a==null){return null}var g=this.doPublic(a);if(g==null){return null}var d=g.toString(16);if((d.length&1)==0){return d}else{return\"0\"+d}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;RSAKey.prototype.encryptOAEP=RSAEncryptOAEP;RSAKey.prototype.type=\"RSA\";\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction pkcs1unpad2(g,j){var a=g.toByteArray();var f=0;while(f=a.length){return null}}var e=\"\";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}function oaep_unpad(o,b,g,p){var e=KJUR.crypto.MessageDigest;var r=KJUR.crypto.Util;var c=null;if(!g){g=\"sha1\"}if(typeof g===\"string\"){c=e.getCanonicalAlgName(g);p=e.getHashLength(c);g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}}o=o.toByteArray();var h;for(h=0;h0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{throw\"Invalid RSA private key\"}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;this.isPublic=false;if(g==null){throw\"RSASetPrivateEx N == null\"}if(d==null){throw\"RSASetPrivateEx E == null\"}if(g.length==0){throw\"RSASetPrivateEx N.length == 0\"}if(d.length==0){throw\"RSASetPrivateEx E.length == 0\"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{throw\"Invalid RSA private key in RSASetPrivateEx\"}}function RSAGenerate(b,i){var a=new SecureRandom();var f=b>>1;this.e=parseInt(i,16);var c=new BigInteger(i,16);for(;;){for(;;){this.p=new BigInteger(b-f,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(f,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var h=this.p;this.p=this.q;this.q=h}var g=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var e=g.multiply(d);if(e.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(e);this.dmp1=this.d.mod(g);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=true}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}function RSADecryptOAEP(e,d,b){var f=parseBigInt(e,16);var a=this.doPrivate(f);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,d,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP;\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction ECFieldElementFp(b,a){this.x=a;this.q=b}function feFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.x.equals(a.x))}function feFpToBigInteger(){return this.x}function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))}function feFpAdd(a){return new ECFieldElementFp(this.q,this.x.add(a.toBigInteger()).mod(this.q))}function feFpSubtract(a){return new ECFieldElementFp(this.q,this.x.subtract(a.toBigInteger()).mod(this.q))}function feFpMultiply(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger()).mod(this.q))}function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))}function feFpDivide(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger().modInverse(this.q)).mod(this.q))}ECFieldElementFp.prototype.equals=feFpEquals;ECFieldElementFp.prototype.toBigInteger=feFpToBigInteger;ECFieldElementFp.prototype.negate=feFpNegate;ECFieldElementFp.prototype.add=feFpAdd;ECFieldElementFp.prototype.subtract=feFpSubtract;ECFieldElementFp.prototype.multiply=feFpMultiply;ECFieldElementFp.prototype.square=feFpSquare;ECFieldElementFp.prototype.divide=feFpDivide;function ECPointFp(c,a,d,b){this.curve=c;this.x=a;this.y=d;if(b==null){this.z=BigInteger.ONE}else{this.z=b}this.zinv=null}function pointFpGetX(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpGetY(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpEquals(a){if(a==this){return true}if(this.isInfinity()){return a.isInfinity()}if(a.isInfinity()){return this.isInfinity()}var c,b;c=a.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(a.z)).mod(this.curve.q);if(!c.equals(BigInteger.ZERO)){return false}b=a.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(a.z)).mod(this.curve.q);return b.equals(BigInteger.ZERO)}function pointFpIsInfinity(){if((this.x==null)&&(this.y==null)){return true}return this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)}function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)}function pointFpAdd(l){if(this.isInfinity()){return l}if(l.isInfinity()){return this}var p=l.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(l.z)).mod(this.curve.q);var o=l.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(l.z)).mod(this.curve.q);if(BigInteger.ZERO.equals(o)){if(BigInteger.ZERO.equals(p)){return this.twice()}return this.curve.getInfinity()}var j=new BigInteger(\"3\");var e=this.x.toBigInteger();var n=this.y.toBigInteger();var c=l.x.toBigInteger();var k=l.y.toBigInteger();var m=o.square();var i=m.multiply(o);var d=e.multiply(m);var g=p.square().multiply(this.z);var a=g.subtract(d.shiftLeft(1)).multiply(l.z).subtract(i).multiply(o).mod(this.curve.q);var h=d.multiply(j).multiply(p).subtract(n.multiply(i)).subtract(g.multiply(p)).multiply(l.z).add(p.multiply(i)).mod(this.curve.q);var f=i.multiply(this.z).multiply(l.z).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),f)}function pointFpTwice(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var g=new BigInteger(\"3\");var c=this.x.toBigInteger();var h=this.y.toBigInteger();var e=h.multiply(this.z);var j=e.multiply(h).mod(this.curve.q);var i=this.curve.a.toBigInteger();var k=c.square().multiply(g);if(!BigInteger.ZERO.equals(i)){k=k.add(this.z.square().multiply(i))}k=k.mod(this.curve.q);var b=k.square().subtract(c.shiftLeft(3).multiply(j)).shiftLeft(1).multiply(e).mod(this.curve.q);var f=k.multiply(g).multiply(c).subtract(j.shiftLeft(1)).shiftLeft(2).multiply(j).subtract(k.square().multiply(k)).mod(this.curve.q);var d=e.square().multiply(e).shiftLeft(3).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(b),this.curve.fromBigInteger(f),d)}function pointFpMultiply(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add(a?this:l)}}return d}function pointFpMultiplyTwo(c,a,b){var d;if(c.bitLength()>b.bitLength()){d=c.bitLength()-1}else{d=b.bitLength()-1}var f=this.curve.getInfinity();var e=this.add(a);while(d>=0){f=f.twice();if(c.testBit(d)){if(b.testBit(d)){f=f.add(e)}else{f=f.add(this)}}else{if(b.testBit(d)){f=f.add(a)}}--d}return f}ECPointFp.prototype.getX=pointFpGetX;ECPointFp.prototype.getY=pointFpGetY;ECPointFp.prototype.equals=pointFpEquals;ECPointFp.prototype.isInfinity=pointFpIsInfinity;ECPointFp.prototype.negate=pointFpNegate;ECPointFp.prototype.add=pointFpAdd;ECPointFp.prototype.twice=pointFpTwice;ECPointFp.prototype.multiply=pointFpMultiply;ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo;function ECCurveFp(e,d,c){this.q=e;this.a=this.fromBigInteger(d);this.b=this.fromBigInteger(c);this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b))}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)}function curveFpDecodePointHex(d){switch(parseInt(d.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var a=(d.length-2)/2;var c=d.substr(2,a);var b=d.substr(a+2,a);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(b,16)));default:return null}}ECCurveFp.prototype.getQ=curveFpGetQ;ECCurveFp.prototype.getA=curveFpGetA;ECCurveFp.prototype.getB=curveFpGetB;ECCurveFp.prototype.equals=curveFpEquals;ECCurveFp.prototype.getInfinity=curveFpGetInfinity;ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger;ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex;\n/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib\n */\nECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};ECPointFp.prototype.getEncoded=function(c){var d=function(h,f){var g=h.toByteArrayUnsigned();if(fg.length){g.unshift(0)}}return g};var a=this.getX().toBigInteger();var e=this.getY().toBigInteger();var b=d(a,32);if(c){if(e.isEven()){b.unshift(2)}else{b.unshift(3)}}else{b.unshift(4);b=b.concat(d(e,32))}return b};ECPointFp.decodeFrom=function(g,c){var f=c[0];var e=c.length-1;var d=c.slice(1,1+e/2);var b=c.slice(1+e/2,1+e);d.unshift(0);b.unshift(0);var a=new BigInteger(d);var h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.decodeFromHex=function(g,c){var f=c.substr(0,2);var e=c.length-2;var d=c.substr(2,e/2);var b=c.substr(2+e/2,e/2);var a=new BigInteger(d,16);var h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.prototype.add2D=function(c){if(this.isInfinity()){return c}if(c.isInfinity()){return this}if(this.x.equals(c.x)){if(this.y.equals(c.y)){return this.twice()}return this.curve.getInfinity()}var g=c.x.subtract(this.x);var e=c.y.subtract(this.y);var a=e.divide(g);var d=a.square().subtract(this.x).subtract(c.x);var f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var b=this.curve.fromBigInteger(BigInteger.valueOf(2));var e=this.curve.fromBigInteger(BigInteger.valueOf(3));var a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b));var c=a.square().subtract(this.x.multiply(b));var d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)};ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add2D(a?this:l)}}return d};ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger();var i=this.getY().toBigInteger();var f=this.curve.getA().toBigInteger();var c=this.curve.getB().toBigInteger();var h=this.curve.getQ();var e=i.multiply(i).mod(h);var g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)};ECPointFp.prototype.toString=function(){return\"(\"+this.getX().toBigInteger().toString()+\",\"+this.getY().toBigInteger().toString()+\")\"};ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity()){throw new Error(\"Point is at infinity.\")}var a=this.getX().toBigInteger();var b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"x coordinate out of bounds\")}if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"y coordinate out of bounds\")}if(!this.isOnCurve()){throw new Error(\"Point is not on the curve.\")}if(this.multiply(c).isInfinity()){throw new Error(\"Point is not a scalar multiple of G.\")}return true};\n/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval\n */\nvar jsonParse=(function(){var e=\"(?:-?\\\\b(?:0|[1-9][0-9]*)(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\\\b)\";var j='(?:[^\\\\0-\\\\x08\\\\x0a-\\\\x1f\"\\\\\\\\]|\\\\\\\\(?:[\"/\\\\\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:\"'+j+'*\")';var d=new RegExp(\"(?:false|true|null|[\\\\{\\\\}\\\\[\\\\]]|\"+e+\"|\"+i+\")\",\"g\");var k=new RegExp(\"\\\\\\\\(?:([^u])|u(.{4}))\",\"g\");var g={'\"':'\"',\"/\":\"/\",\"\\\\\":\"\\\\\",b:\"\\b\",f:\"\\f\",n:\"\\n\",r:\"\\r\",t:\"\\t\"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String(\"\");var a=\"\\\\\";var f={\"{\":Object,\"[\":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if(\"{\"===v){x={}}else{if(\"[\"===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({\"\":x},\"\")}return x}})();\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.asn1==\"undefined\"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b=\"0\"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!=\"-\"){if(f.length%2==1){f=\"0\"+f}else{if(!f.match(/^[0-7]/)){f=\"00\"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g=\"\";for(var d=0;d15){throw\"ASN.1 length too long to represent by 8x: n = \"+i.toString(16)}var f=128+g;return f.toString(16)+h}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return\"\"}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!=\"undefined\"){if(typeof c==\"string\"){this.setString(c)}else{if(typeof c.str!=\"undefined\"){this.setString(c.str)}else{if(typeof c.hex!=\"undefined\"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(f){utc=f.getTime()+(f.getTimezoneOffset()*60000);var e=new Date(utc);return e};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o==\"utc\"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,\"\");r=r+\".\"+k}}return r+\"Z\"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join(\"0\")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!=\"undefined\"){if(typeof b.array!=\"undefined\"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT=\"01\";this.hTLV=\"0101ff\"};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT=\"02\";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!=\"undefined\"){if(typeof a.bigint!=\"undefined\"){this.setByBigInteger(a.bigint)}else{if(typeof a[\"int\"]!=\"undefined\"){this.setByInteger(a[\"int\"])}else{if(typeof a==\"number\"){this.setByInteger(a)}else{if(typeof a.hex!=\"undefined\"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!==\"undefined\"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex=\"00\"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT=\"03\";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=(l*2))){break}if(d>=200){break}g.push(b);c=b;d++}return g};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){throw\"checking tag doesn't match: \"+e.substr(d,2)+\"!=\"+i}}return d}f=c.shift();b=g.getChildIdx(e,d);return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getTLVbyList=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyList(d,c,b);if(a===undefined){throw\"can't find nthList object\"}if(f!==undefined){if(d.substr(a,2)!=f){throw\"checking tag doesn't match: \"+d.substr(a,2)+\"!=\"+f}}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a===undefined){throw\"can't find nthList object\"}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join(\"0\")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+\".\"+j.join(\".\")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+\"..(total \"+A.length/2+\"bytes)..\"+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=\"\"}var x=c.ommit_long_octet;if(e.substr(l,2)==\"01\"){var h=j(e,l);if(h==\"00\"){return g+\"BOOLEAN FALSE\\n\"}else{return g+\"BOOLEAN TRUE\\n\"}}if(e.substr(l,2)==\"02\"){var h=j(e,l);return g+\"INTEGER \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"03\"){var h=j(e,l);return g+\"BITSTRING \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"04\"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+\"OCTETSTRING, encapsulates\\n\";k=k+y(h,c,0,g+\" \");return k}else{return g+\"OCTETSTRING \"+q(h,x)+\"\\n\"}}if(e.substr(l,2)==\"05\"){return g+\"NULL\\n\"}if(e.substr(l,2)==\"06\"){var m=j(e,l);var a=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(a);var b=a.replace(/\\./g,\" \");if(o!=\"\"){return g+\"ObjectIdentifier \"+o+\" (\"+b+\")\\n\"}else{return g+\"ObjectIdentifier (\"+b+\")\\n\"}}if(e.substr(l,2)==\"0c\"){return g+\"UTF8String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"13\"){return g+\"PrintableString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"14\"){return g+\"TeletexString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"16\"){return g+\"IA5String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"17\"){return g+\"UTCTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"18\"){return g+\"GeneralizedTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"30\"){if(e.substr(l,4)==\"3000\"){return g+\"SEQUENCE {}\\n\"}var k=g+\"SEQUENCE\\n\";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)==\"06\"&&e.substr(d[d.length-1],2)==\"04\"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u0){var m=new f({array:this.extensionsArray});var k=new c({explicit:true,tag:\"a3\",obj:m});this.asn1Array.push(k)}var n=new f({array:this.asn1Array});this.hTLV=n.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension=function(d){KJUR.asn1.x509.Extension.superclass.constructor.call(this);var f=null,a=KJUR,e=a.asn1,h=e.DERObjectIdentifier,i=e.DEROctetString,b=e.DERBitString,g=e.DERBoolean,c=e.DERSequence;this.getEncodedHex=function(){var m=new h({oid:this.oid});var l=new i({hex:this.getExtnValueHex()});var k=new Array();k.push(m);if(this.critical){k.push(new g())}k.push(l);var j=new c({array:k});return j.getEncodedHex()};this.critical=false;if(d!==undefined){if(d.critical!==undefined){this.critical=d.critical}}};YAHOO.lang.extend(KJUR.asn1.x509.Extension,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension.appendByNameToArray=function(e,c,b){var g=e.toLowerCase(),f=KJUR.asn1.x509;if(g==\"basicconstraints\"){var d=new f.BasicConstraints(c);b.push(d)}else{if(g==\"keyusage\"){var d=new f.KeyUsage(c);b.push(d)}else{if(g==\"crldistributionpoints\"){var d=new f.CRLDistributionPoints(c);b.push(d)}else{if(g==\"extkeyusage\"){var d=new f.ExtKeyUsage(c);b.push(d)}else{if(g==\"authoritykeyidentifier\"){var d=new f.AuthorityKeyIdentifier(c);b.push(d)}else{if(g==\"authorityinfoaccess\"){var d=new f.AuthorityInfoAccess(c);b.push(d)}else{if(g==\"subjectaltname\"){var d=new f.SubjectAltName(c);b.push(d)}else{if(g==\"issueraltname\"){var d=new f.IssuerAltName(c);b.push(d)}else{throw\"unsupported extension name: \"+e}}}}}}}}};KJUR.asn1.x509.KeyUsage=function(f){KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this,f);var a=X509.KEYUSAGE_NAME;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.15\";if(f!==undefined){if(f.bin!==undefined){this.asn1ExtnValue=new KJUR.asn1.DERBitString(f)}if(f.names!==undefined&&f.names.length!==undefined){var e=f.names;var d=\"000000000\";for(var c=0;c-1){e.push(new KJUR.asn1.DERInteger({\"int\":this.pathLen}))}var d=new KJUR.asn1.DERSequence({array:e});this.asn1ExtnValue=d;return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.19\";this.cA=false;this.pathLen=-1;if(c!==undefined){if(c.cA!==undefined){this.cA=c.cA}if(c.pathLen!==undefined){this.pathLen=c.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){this.asn1ExtnValue=new a.DERSequence({array:e})};this.setByOneURI=function(h){var e=new c.GeneralNames([{uri:h}]);var g=new c.DistributionPointName(e);var f=new c.DistributionPoint({dpobj:g});this.setByDPArray([f])};this.oid=\"2.5.29.31\";if(d!==undefined){if(d.array!==undefined){this.setByDPArray(d.array)}else{if(d.uri!==undefined){this.setByOneURI(d.uri)}}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLDistributionPoints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.ExtKeyUsage=function(c){KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,c);var b=KJUR,a=b.asn1;this.setPurposeArray=function(d){this.asn1ExtnValue=new a.DERSequence();for(var e=0;e0){var h=new b({array:this.aRevokedCert});this.asn1Array.push(h)}var i=new b({array:this.asn1Array});this.hTLV=i.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize=function(){this.asn1Version=null;this.asn1SignatureAlg=null;this.asn1Issuer=null;this.asn1ThisUpdate=null;this.asn1NextUpdate=null;this.aRevokedCert=new Array()};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertList,KJUR.asn1.ASN1Object);KJUR.asn1.x509.CRLEntry=function(e){KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);var d=null,c=null,b=KJUR,a=b.asn1;this.setCertSerial=function(f){this.sn=new a.DERInteger(f)};this.setRevocationDate=function(f){this.time=new a.x509.Time(f)};this.getEncodedHex=function(){var f=new a.DERSequence({array:[this.sn,this.time]});this.TLV=f.getEncodedHex();return this.TLV};if(e!==undefined){if(e.time!==undefined){this.setRevocationDate(e.time)}if(e.sn!==undefined){this.setCertSerial(e.sn)}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLEntry,KJUR.asn1.ASN1Object);KJUR.asn1.x509.X500Name=function(f){KJUR.asn1.x509.X500Name.superclass.constructor.call(this);this.asn1Array=new Array();var d=KJUR,c=d.asn1,e=c.x509,b=pemtohex;this.setByString=function(g){var k=g.split(\"/\");k.shift();var j=[];for(var l=0;l0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+\",\"+h).replace(/\\\\,/g,\",\");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)===\"\\\\\"){e=true}}b=b.map(function(a){return a.replace(\"/\",\"\\\\/\")});b.reverse();return\"/\"+b.join(\"/\")};KJUR.asn1.x509.RDN=function(a){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=new Array();this.addByString=function(b){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:b}))};this.addByMultiValuedString=function(d){var b=KJUR.asn1.x509.RDN.parseString(d);for(var c=0;c0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+\"+\"+k).replace(/\\\\\\+/g,\"+\");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)===\"\\\\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/\"$/)){var d=(e+\"+\"+k).replace(/^([^=]+)=\"(.*)\"$/,\"$1=$2\");b.push(d);l=false}else{b.push(e+\"+\"+k)}}else{b.push(k)}if(k.match(/^[^=]+=\"/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(d){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var f=null,e=null,a=\"utf8\",c=KJUR,b=c.asn1;this.setByString=function(h){var g=h.match(/^([^=]+)=(.+)$/);if(g){this.setByAttrTypeAndValueStr(g[1],g[2])}else{throw\"malformed attrTypeAndValueStr: \"+h}};this.setByAttrTypeAndValueStr=function(i,h){this.typeObj=KJUR.asn1.x509.OID.atype2obj(i);var g=a;if(i==\"C\"){g=\"prn\"}this.valueObj=this.getValueObj(g,h)};this.getValueObj=function(h,g){if(h==\"utf8\"){return new b.DERUTF8String({str:g})}if(h==\"prn\"){return new b.DERPrintableString({str:g})}if(h==\"tel\"){return new b.DERTeletexString({str:g})}if(h==\"ia5\"){return new b.DERIA5String({str:g})}throw\"unsupported directory string type: type=\"+h+\" value=\"+g};this.getEncodedHex=function(){var g=new b.DERSequence({array:[this.typeObj,this.valueObj]});this.TLV=g.getEncodedHex();return this.TLV};if(d!==undefined){if(d.str!==undefined){this.setByString(d.str)}}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw\"algId and/or subjPubKey not set\"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{\"int\":{bigint:q.n}},{\"int\":{\"int\":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:\"rsaEncryption\"});this.asn1SubjPKey=new b({hex:\"00\"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:\"ecPublicKey\",asn1params:r});this.asn1SubjPKey=new b({hex:\"00\"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{\"int\":{bigint:q.p}},{\"int\":{bigint:q.q}},{\"int\":{bigint:q.g}}]});this.asn1AlgId=new o({name:\"dsa\",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:\"00\"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type==\"utc\"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type==\"utc\"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type=\"utc\";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type=\"utc\"}if(f.str.match(/^[0-9]{14}Z$/)){this.type=\"gen\"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(d){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw\"algorithm not specified\"}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var e=[this.asn1Alg];if(this.asn1Params!==null){e.push(this.asn1Params)}var f=new a.DERSequence({array:e});this.hTLV=f.getEncodedHex();return this.hTLV};if(d!==undefined){if(d.name!==undefined){this.nameAlg=d.name}if(d.asn1params!==undefined){this.asn1Params=d.asn1params}if(d.paramempty!==undefined){this.paramEmpty=d.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){var c=this.nameAlg.toLowerCase();if(c.substr(-7,7)!==\"withdsa\"&&c.substr(-9,9)!==\"withecdsa\"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:\"81\",dns:\"82\",dn:\"a4\",uri:\"86\",ip:\"87\"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type=\"rfc822\";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type=\"dns\";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type=\"uri\";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({str:p.dn})}if(p.ldapdn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certissuer param not cert\"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certsubj param not cert\"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type=\"ip\";this.explicit=false;var q=p.ip;var s;var n=\"malformed IP address\";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex(\"[\"+q.split(\".\").join(\",\")+\"]\");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw\"unsupported type in params=\"+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){r=new b({obj:this.dUnsignedAttrs,tag:\"a1\",explicit:false})}var q=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,o,this.dSigAlg,this.dSig,];if(r!=null){q.push(r)}var p=new h.DERSequence({array:q});this.hTLV=p.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.SignerInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.EncapsulatedContentInfo=function(g){var c=KJUR,b=c.asn1,e=b.DERTaggedObject,a=b.DERSequence,h=b.DERObjectIdentifier,d=b.DEROctetString,f=b.cms;f.EncapsulatedContentInfo.superclass.constructor.call(this);this.dEContentType=new h({name:\"data\"});this.dEContent=null;this.isDetached=false;this.eContentValueHex=null;this.setContentType=function(i){if(i.match(/^[0-2][.][0-9.]+$/)){this.dEContentType=new h({oid:i})}else{this.dEContentType=new h({name:i})}};this.setContentValue=function(i){if(i!==undefined){if(typeof i.hex==\"string\"){this.eContentValueHex=i.hex}else{if(typeof i.str==\"string\"){this.eContentValueHex=utf8tohex(i.str)}}}};this.setContentValueHex=function(i){this.eContentValueHex=i};this.setContentValueStr=function(i){this.eContentValueHex=utf8tohex(i)};this.getEncodedHex=function(){if(typeof this.eContentValueHex!=\"string\"){throw\"eContentValue not yet set\"}var k=new d({hex:this.eContentValueHex});this.dEContent=new e({obj:k,tag:\"a0\",explicit:true});var i=[this.dEContentType];if(!this.isDetached){i.push(this.dEContent)}var j=new a({array:i});this.hTLV=j.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.EncapsulatedContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.ContentInfo=function(f){var c=KJUR,b=c.asn1,d=b.DERTaggedObject,a=b.DERSequence,e=b.x509;KJUR.asn1.cms.ContentInfo.superclass.constructor.call(this);this.dContentType=null;this.dContent=null;this.setContentType=function(g){if(typeof g==\"string\"){this.dContentType=e.OID.name2obj(g)}};this.getEncodedHex=function(){var h=new d({obj:this.dContent,tag:\"a0\",explicit:true});var g=new a({array:[this.dContentType,h]});this.hTLV=g.getEncodedHex();return this.hTLV};if(f!==undefined){if(f.type){this.setContentType(f.type)}if(f.obj&&f.obj instanceof b.ASN1Object){this.dContent=f.obj}}};YAHOO.lang.extend(KJUR.asn1.cms.ContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.SignedData=function(e){var a=KJUR,h=a.asn1,j=h.ASN1Object,g=h.DERInteger,m=h.DERSet,f=h.DERSequence,b=h.DERTaggedObject,l=h.cms,i=l.EncapsulatedContentInfo,d=l.SignerInfo,n=l.ContentInfo,c=h.x509,k=c.AlgorithmIdentifier;KJUR.asn1.cms.SignedData.superclass.constructor.call(this);this.dCMSVersion=new g({\"int\":1});this.dDigestAlgs=null;this.digestAlgNameList=[];this.dEncapContentInfo=new i();this.dCerts=null;this.certificateList=[];this.crlList=[];this.signerInfoList=[new d()];this.addCertificatesByPEM=function(p){var q=pemtohex(p);var r=new j();r.hTLV=q;this.certificateList.push(r)};this.getEncodedHex=function(){if(typeof this.hTLV==\"string\"){return this.hTLV}if(this.dDigestAlgs==null){var u=[];for(var t=0;t0){var v=new m({array:this.certificateList});this.dCerts=new b({obj:v,tag:\"a0\",explicit:false})}}if(this.dCerts!=null){p.push(this.dCerts)}var r=new m({array:this.signerInfoList});p.push(r);var q=new f({array:p});this.hTLV=q.getEncodedHex();return this.hTLV};this.getContentInfo=function(){this.getEncodedHex();var o=new n({type:\"signed-data\",obj:this});return o};this.getContentInfoEncodedHex=function(){var o=this.getContentInfo();var p=o.getEncodedHex();return p};this.getPEM=function(){return hextopem(this.getContentInfoEncodedHex(),\"CMS\")}};YAHOO.lang.extend(KJUR.asn1.cms.SignedData,KJUR.asn1.ASN1Object);KJUR.asn1.cms.CMSUtil=new function(){};KJUR.asn1.cms.CMSUtil.newSignedData=function(d){var b=KJUR,j=b.asn1,q=j.cms,f=q.SignerInfo,n=q.SignedData,o=q.SigningTime,a=q.SigningCertificate,p=q.SigningCertificateV2,c=j.cades,e=c.SignaturePolicyIdentifier;var m=new n();m.dEncapContentInfo.setContentValue(d.content);if(typeof d.certs==\"object\"){for(var h=0;h0){var s=new f({array:this.extensionsArray});var r=new m({array:[s]});var q=new f({array:[new k({oid:\"1.2.840.113549.1.9.14\"}),r]});var p=new c({explicit:true,tag:\"a0\",obj:q});this.asn1Array.push(p)}else{var p=new c({explicit:false,tag:\"a0\",obj:new j()});this.asn1Array.push(p)}var t=new f({array:this.asn1Array});this.hTLV=t.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CSRUtil=new function(){};KJUR.asn1.csr.CSRUtil.newCSRPEM=function(h){var c=KEYUTIL,b=KJUR.asn1.csr;if(h.subject===undefined){throw\"parameter subject undefined\"}if(h.sbjpubkey===undefined){throw\"parameter sbjpubkey undefined\"}if(h.sigalg===undefined){throw\"parameter sigalg undefined\"}if(h.sbjprvkey===undefined){throw\"parameter sbjpubkey undefined\"}var d=new b.CertificationRequestInfo();d.setSubjectByParam(h.subject);d.setSubjectPublicKeyByGetKey(h.sbjpubkey);if(h.ext!==undefined&&h.ext.length!==undefined){for(var e=0;ef.length){f=c[d]}}e=e.replace(f,\"::\");return e.slice(1,-1)}function hextoip(b){var d=\"malformed hex value\";if(!b.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){throw d}if(b.length==8){var c;try{c=parseInt(b.substr(0,2),16)+\".\"+parseInt(b.substr(2,2),16)+\".\"+parseInt(b.substr(4,2),16)+\".\"+parseInt(b.substr(6,2),16);return c}catch(a){throw d}}else{if(b.length==32){return hextoipv6(b)}else{return b}}}function iptohex(f){var j=\"malformed IP address\";f=f.toLowerCase(f);if(f.match(/^[0-9.]+$/)){var b=f.split(\".\");if(b.length!==4){throw j}var g=\"\";try{for(var e=0;e<4;e++){var h=parseInt(b[e]);g+=(\"0\"+h.toString(16)).slice(-2)}return g}catch(c){throw j}}else{if(f.match(/^[0-9a-f:]+$/)&&f.indexOf(\":\")!==-1){return ipv6tohex(f)}else{throw j}}}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b=\"\";for(var c=0;c\"7\"){return\"00\"+a}return a}function intarystrtohex(b){b=b.replace(/^\\s*\\[\\s*/,\"\");b=b.replace(/\\s*\\]\\s*$/,\"\");b=b.replace(/\\s*/g,\"\");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;bd){throw\"key is too short for SigAlg: keylen=\"+j+\",\"+a}var b=\"0001\";var k=\"00\"+c;var g=\"\";var l=d-b.length-k.length;for(var f=0;f=0;--p){q=q.twice2D();q.z=BigInteger.ONE;if(o.testBit(p)){if(n.testBit(p)){q=q.add2D(t)}else{q=q.add2D(s)}}else{if(n.testBit(p)){q=q.add2D(r)}}}return q}this.getBigRandom=function(i){return new BigInteger(i.bitLength(),a).mod(i.subtract(BigInteger.ONE)).add(BigInteger.ONE)};this.setNamedCurve=function(i){this.ecparams=KJUR.crypto.ECParameterDB.getByName(i);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=i};this.setPrivateKeyHex=function(i){this.isPrivate=true;this.prvKeyHex=i};this.setPublicKeyHex=function(i){this.isPublic=true;this.pubKeyHex=i};this.getPublicKeyXYHex=function(){var k=this.pubKeyHex;if(k.substr(0,2)!==\"04\"){throw\"this method supports uncompressed format(04) only\"}var j=this.ecparams.keylen/4;if(k.length!==2+j*2){throw\"malformed public key hex length\"}var i={};i.x=k.substr(2,j);i.y=k.substr(2+j);return i};this.getShortNISTPCurveName=function(){var i=this.curveName;if(i===\"secp256r1\"||i===\"NIST P-256\"||i===\"P-256\"||i===\"prime256v1\"){return\"P-256\"}if(i===\"secp384r1\"||i===\"NIST P-384\"||i===\"P-384\"){return\"P-384\"}return null};this.generateKeyPairHex=function(){var k=this.ecparams.n;var n=this.getBigRandom(k);var l=this.ecparams.G.multiply(n);var q=l.getX().toBigInteger();var o=l.getY().toBigInteger();var i=this.ecparams.keylen/4;var m=(\"0000000000\"+n.toString(16)).slice(-i);var r=(\"0000000000\"+q.toString(16)).slice(-i);var p=(\"0000000000\"+o.toString(16)).slice(-i);var j=\"04\"+r+p;this.setPrivateKeyHex(m);this.setPublicKeyHex(j);return{ecprvhex:m,ecpubhex:j}};this.signWithMessageHash=function(i){return this.signHex(i,this.prvKeyHex)};this.signHex=function(o,j){var t=new BigInteger(j,16);var l=this.ecparams.n;var q=new BigInteger(o,16);do{var m=this.getBigRandom(l);var u=this.ecparams.G;var p=u.multiply(m);var i=p.getX().toBigInteger().mod(l)}while(i.compareTo(BigInteger.ZERO)<=0);var v=m.modInverse(l).multiply(q.add(t.multiply(i))).mod(l);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(i,v)};this.sign=function(m,u){var q=u;var j=this.ecparams.n;var p=BigInteger.fromByteArrayUnsigned(m);do{var l=this.getBigRandom(j);var t=this.ecparams.G;var o=t.multiply(l);var i=o.getX().toBigInteger().mod(j)}while(i.compareTo(BigInteger.ZERO)<=0);var v=l.modInverse(j).multiply(p.add(q.multiply(i))).mod(j);return this.serializeSig(i,v)};this.verifyWithMessageHash=function(j,i){return this.verifyHex(j,i,this.pubKeyHex)};this.verifyHex=function(m,i,p){var l,j;var o=KJUR.crypto.ECDSA.parseSigHex(i);l=o.r;j=o.s;var k;k=ECPointFp.decodeFromHex(this.ecparams.curve,p);var n=new BigInteger(m,16);return this.verifyRaw(n,l,j,k)};this.verify=function(o,p,j){var l,i;if(Bitcoin.Util.isArray(p)){var n=this.parseSig(p);l=n.r;i=n.s}else{if(\"object\"===typeof p&&p.r&&p.s){l=p.r;i=p.s}else{throw\"Invalid value for signature\"}}var k;if(j instanceof ECPointFp){k=j}else{if(Bitcoin.Util.isArray(j)){k=ECPointFp.decodeFrom(this.ecparams.curve,j)}else{throw\"Invalid format for pubkey value, must be byte array or ECPointFp\"}}var m=BigInteger.fromByteArrayUnsigned(o);return this.verifyRaw(m,l,i,k)};this.verifyRaw=function(o,i,w,m){var l=this.ecparams.n;var u=this.ecparams.G;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(l)>=0){return false}if(w.compareTo(BigInteger.ONE)<0||w.compareTo(l)>=0){return false}var p=w.modInverse(l);var k=o.multiply(p).mod(l);var j=i.multiply(p).mod(l);var q=u.multiply(k).add(m.multiply(j));var t=q.getX().toBigInteger().mod(l);return t.equals(i)};this.serializeSig=function(k,j){var l=k.toByteArraySigned();var i=j.toByteArraySigned();var m=[];m.push(2);m.push(l.length);m=m.concat(l);m.push(2);m.push(i.length);m=m.concat(i);m.unshift(m.length);m.unshift(48);return m};this.parseSig=function(n){var m;if(n[0]!=48){throw new Error(\"Signature not a valid DERSequence\")}m=2;if(n[m]!=2){throw new Error(\"First element in signature must be a DERInteger\")}var l=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];if(n[m]!=2){throw new Error(\"Second element in signature must be a DERInteger\")}var i=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];var k=BigInteger.fromByteArrayUnsigned(l);var j=BigInteger.fromByteArrayUnsigned(i);return{r:k,s:j}};this.parseSigCompact=function(m){if(m.length!==65){throw\"Signature has the wrong length\"}var j=m[0]-27;if(j<0||j>7){throw\"Invalid signature type\"}var o=this.ecparams.n;var l=BigInteger.fromByteArrayUnsigned(m.slice(1,33)).mod(o);var k=BigInteger.fromByteArrayUnsigned(m.slice(33,65)).mod(o);return{r:l,s:k,i:j}};this.readPKCS5PrvKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var i,k,o;try{i=p(l,0,[2,0],\"06\");k=p(l,0,[1],\"04\");try{o=p(l,0,[3,0],\"03\").substr(2)}catch(j){}}catch(j){throw\"malformed PKCS#1/5 plain ECC private key\"}this.curveName=m(i);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o);this.setPrivateKeyHex(k);this.isPublic=false};this.readPKCS8PrvKeyHex=function(l){var q=ASN1HEX;var i=KJUR.crypto.ECDSA.getName;var n=q.getVbyList;if(q.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var j,p,m,k;try{j=n(l,0,[1,0],\"06\");p=n(l,0,[1,1],\"06\");m=n(l,0,[2,0,1],\"04\");try{k=n(l,0,[2,0,2,0],\"03\").substr(2)}catch(o){}}catch(o){throw\"malformed PKCS#8 plain ECC private key\"}this.curveName=i(p);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(k);this.setPrivateKeyHex(m);this.isPublic=false};this.readPKCS8PubKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var k,i,o;try{k=p(l,0,[0,0],\"06\");i=p(l,0,[0,1],\"06\");o=p(l,0,[1],\"03\").substr(2)}catch(j){throw\"malformed PKCS#8 ECC public key\"}this.curveName=m(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o)};this.readCertPubKeyHex=function(k,p){if(p!==5){p=6}var m=ASN1HEX;var l=KJUR.crypto.ECDSA.getName;var o=m.getVbyList;if(m.isASN1HEX(k)===false){throw\"not ASN.1 hex string\"}var i,n;try{i=o(k,0,[0,p,0,1],\"06\");n=o(k,0,[0,p,1],\"03\").substr(2)}catch(j){throw\"malformed X.509 certificate ECC public key\"}this.curveName=l(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(n)};if(h!==undefined){if(h.curve!==undefined){this.curveName=h.curve}}if(this.curveName===undefined){this.curveName=e}this.setNamedCurve(this.curveName);if(h!==undefined){if(h.prv!==undefined){this.setPrivateKeyHex(h.prv)}if(h.pub!==undefined){this.setPublicKeyHex(h.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX;var i=j.getChildIdx;var g=j.getV;if(f.substr(0,2)!=\"30\"){throw\"signature is not a ASN.1 sequence\"}var h=i(f,0);if(h.length!=2){throw\"number of signature ASN.1 sequence elements seem wrong\"}var e=h[0];var d=h[1];if(f.substr(e,2)!=\"02\"){throw\"1st item of sequene of signature is not ASN.1 integer\"}if(f.substr(d,2)!=\"02\"){throw\"2nd item of sequene of signature is not ASN.1 integer\"}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(c){var d=KJUR.crypto.ECDSA.parseSigHexInHexRS(c);var b=d.r;var a=d.s;if(b.substr(0,2)==\"00\"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)==\"00\"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b=\"00\"+b}if((a.length%32)==30){a=\"00\"+a}if(b.length%32!=0){throw\"unknown ECDSA sig r length error\"}if(a.length%32!=0){throw\"unknown ECDSA sig s length error\"}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if((((a.length/2)*8)%(16*8))!=0){throw\"unknown ECDSA concatinated r-s sig length error\"}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.getEncodedHex()};KJUR.crypto.ECDSA.getName=function(a){if(a===\"2a8648ce3d030107\"){return\"secp256r1\"}if(a===\"2b8104000a\"){return\"secp256k1\"}if(a===\"2b81040022\"){return\"secp384r1\"}if(\"|secp256r1|NIST P-256|P-256|prime256v1|\".indexOf(a)!==-1){return\"secp256r1\"}if(\"|secp256k1|\".indexOf(a)!==-1){return\"secp256k1\"}if(\"|secp384r1|NIST P-384|P-384|\".indexOf(a)!==-1){return\"secp384r1\"}return null};\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.crypto==\"undefined\"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!=\"undefined\"){d=c[e]}if(typeof b[d]!=\"undefined\"){return b[d]}throw\"unregistered EC curve name: \"+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex(\"04\"+f+k);b[A][\"name\"]=A;b[A][\"keylen\"]=l;b[A][\"curve\"]=r;b[A][\"G\"]=q;b[A][\"n\"]=t;b[A][\"h\"]=w;b[A][\"oid\"]=d;b[A][\"info\"]=x;for(var v=0;v1){g=new BigInteger(i,16)}else{g=null}h=new BigInteger(j,16);this.setPrivate(c,a,e,g,h)};this.setPublic=function(c,b,a,d){this.isPublic=true;this.p=c;this.q=b;this.g=a;this.y=d;this.x=null};this.setPublicHex=function(f,e,d,g){var b,a,h,c;b=new BigInteger(f,16);a=new BigInteger(e,16);h=new BigInteger(d,16);c=new BigInteger(g,16);this.setPublic(b,a,h,c)};this.signWithMessageHash=function(d){var c=this.p;var b=this.q;var f=this.g;var i=this.y;var j=this.x;var e=KJUR.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),b.subtract(BigInteger.ONE));var l=d.substr(0,b.bitLength()/4);var h=new BigInteger(l,16);var a=(f.modPow(e,c)).mod(b);var n=(e.modInverse(b).multiply(h.add(j.multiply(a)))).mod(b);var m=KJUR.asn1.ASN1Util.jsonToASN1HEX({seq:[{\"int\":{bigint:a}},{\"int\":{bigint:n}}]});return m};this.verifyWithMessageHash=function(h,f){var d=this.p;var b=this.q;var j=this.g;var l=this.y;var i=this.parseASN1Signature(f);var a=i[0];var t=i[1];var o=h.substr(0,b.bitLength()/4);var k=new BigInteger(o,16);if(BigInteger.ZERO.compareTo(a)>0||a.compareTo(b)>0){throw\"invalid DSA signature\"}if(BigInteger.ZERO.compareTo(t)>=0||t.compareTo(b)>0){throw\"invalid DSA signature\"}var m=t.modInverse(b);var e=k.multiply(m).mod(b);var c=a.multiply(m).mod(b);var n=j.modPow(e,d).multiply(l.modPow(c,d)).mod(d).mod(b);return n.compareTo(a)==0};this.parseASN1Signature=function(a){try{var d=new BigInteger(ASN1HEX.getVbyList(a,0,[0],\"02\"),16);var c=new BigInteger(ASN1HEX.getVbyList(a,0,[1],\"02\"),16);return[d,c]}catch(b){throw\"malformed ASN.1 DSA signature\"}};this.readPKCS5PrvKeyHex=function(c){var b,a,f,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[1],\"02\");a=d(c,0,[2],\"02\");f=d(c,0,[3],\"02\");g=d(c,0,[4],\"02\");i=d(c,0,[5],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed PKCS#1/5 plain DSA private key\"}this.setPrivateHex(b,a,f,g,i)};this.readPKCS8PrvKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[1,1,0],\"02\");c=i(d,0,[1,1,1],\"02\");b=i(d,0,[1,1,2],\"02\");g=i(d,0,[2,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 plain DSA private key\"}this.setPrivateHex(f,c,b,null,g)};this.readPKCS8PubKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[0,1,0],\"02\");c=i(d,0,[0,1,1],\"02\");b=i(d,0,[0,1,2],\"02\");g=i(d,0,[1,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 DSA public key\"}this.setPublicHex(f,c,b,g)};this.readCertPubKeyHex=function(c,f){if(f!==5){f=6}var b,a,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[0,f,0,1,0],\"02\");a=d(c,0,[0,f,0,1,1],\"02\");g=d(c,0,[0,f,0,1,2],\"02\");i=d(c,0,[0,f,1,0],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed X.509 certificate DSA public key\"}this.setPublicHex(b,a,g,i)}};\nvar KEYUTIL=function(){var d=function(p,r,q){return k(CryptoJS.AES,p,r,q)};var e=function(p,r,q){return k(CryptoJS.TripleDES,p,r,q)};var a=function(p,r,q){return k(CryptoJS.DES,p,r,q)};var k=function(s,x,u,q){var r=CryptoJS.enc.Hex.parse(x);var w=CryptoJS.enc.Hex.parse(u);var p=CryptoJS.enc.Hex.parse(q);var t={};t.key=w;t.iv=p;t.ciphertext=r;var v=s.decrypt(t,w,{iv:p});return CryptoJS.enc.Hex.stringify(v)};var l=function(p,r,q){return g(CryptoJS.AES,p,r,q)};var o=function(p,r,q){return g(CryptoJS.TripleDES,p,r,q)};var f=function(p,r,q){return g(CryptoJS.DES,p,r,q)};var g=function(t,y,v,q){var s=CryptoJS.enc.Hex.parse(y);var x=CryptoJS.enc.Hex.parse(v);var p=CryptoJS.enc.Hex.parse(q);var w=t.encrypt(s,x,{iv:p});var r=CryptoJS.enc.Hex.parse(w.toString());var u=CryptoJS.enc.Base64.stringify(r);return u};var i={\"AES-256-CBC\":{proc:d,eproc:l,keylen:32,ivlen:16},\"AES-192-CBC\":{proc:d,eproc:l,keylen:24,ivlen:16},\"AES-128-CBC\":{proc:d,eproc:l,keylen:16,ivlen:16},\"DES-EDE3-CBC\":{proc:e,eproc:o,keylen:24,ivlen:8},\"DES-CBC\":{proc:a,eproc:f,keylen:8,ivlen:8}};var c=function(p){return i[p][\"proc\"]};var m=function(p){var r=CryptoJS.lib.WordArray.random(p);var q=CryptoJS.enc.Hex.stringify(r);return q};var n=function(v){var w={};var q=v.match(new RegExp(\"DEK-Info: ([^,]+),([0-9A-Fa-f]+)\",\"m\"));if(q){w.cipher=q[1];w.ivsalt=q[2]}var p=v.match(new RegExp(\"-----BEGIN ([A-Z]+) PRIVATE KEY-----\"));if(p){w.type=p[1]}var u=-1;var x=0;if(v.indexOf(\"\\r\\n\\r\\n\")!=-1){u=v.indexOf(\"\\r\\n\\r\\n\");x=2}if(v.indexOf(\"\\n\\n\")!=-1){u=v.indexOf(\"\\n\\n\");x=1}var t=v.indexOf(\"-----END\");if(u!=-1&&t!=-1){var r=v.substring(u+x*2,t-x);r=r.replace(/\\s+/g,\"\");w.data=r}return w};var j=function(q,y,p){var v=p.substring(0,16);var t=CryptoJS.enc.Hex.parse(v);var r=CryptoJS.enc.Utf8.parse(y);var u=i[q][\"keylen\"]+i[q][\"ivlen\"];var x=\"\";var w=null;for(;;){var s=CryptoJS.algo.MD5.create();if(w!=null){s.update(w)}s.update(r);s.update(t);w=s.finalize();x=x+CryptoJS.enc.Hex.stringify(w);if(x.length>=u*2){break}}var z={};z.keyhex=x.substr(0,i[q][\"keylen\"]*2);z.ivhex=x.substr(i[q][\"keylen\"]*2,i[q][\"ivlen\"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v][\"proc\"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s][\"eproc\"];var t=r(p,q,u);return t};return{version:\"1.0.0\",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p=\"\";if(typeof t==\"undefined\"||t==null){t=\"AES-256-CBC\"}if(typeof i[t]==\"undefined\"){throw\"KEYUTIL unsupported algorithm: \"+t}if(typeof r==\"undefined\"||r==null){var v=i[t][\"ivlen\"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,\"$1\\r\\n\");var p=\"-----BEGIN \"+x+\" PRIVATE KEY-----\\r\\n\";p+=\"Proc-Type: 4,ENCRYPTED\\r\\n\";p+=\"DEK-Info: \"+t+\",\"+r+\"\\r\\n\";p+=\"\\r\\n\";p+=q;p+=\"\\r\\n-----END \"+x+\" PRIVATE KEY-----\\r\\n\";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw\"malformed format: SEQUENCE(0).items != 2: \"+r.length}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0).items != 2: \"+A.length}if(w(y,A[0])!=\"2a864886f70d01050d\"){throw\"this only supports pkcs5PBES2\"}var p=z(y,A[1]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0.1).items != 2: \"+p.length}var q=z(y,p[1]);if(q.length!=2){throw\"malformed format: SEQUENCE(0.0.1.1).items != 2: \"+q.length}if(w(y,q[0])!=\"2a864886f70d0307\"){throw\"this only supports TripleDES\"}t.encryptionSchemeAlg=\"TripleDES\";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw\"malformed format: SEQUENCE(0.0.1.0).items != 2: \"+s.length}if(w(y,s[0])!=\"2a864886f70d01050c\"){throw\"this only supports pkcs5PBKDF2\"}var x=z(y,s[1]);if(x.length<2){throw\"malformed format: SEQUENCE(0.0.1.0.1).items < 2: \"+x.length}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw\"malformed format pbkdf2Iter: \"+u}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,\"ENCRYPTED PRIVATE KEY\");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!=\"30\"){throw\"malformed plain PKCS8 private key(code:001)\"}var r=u(s,0);if(r.length!=3){throw\"malformed plain PKCS8 private key(code:002)\"}if(s.substr(r[1],2)!=\"30\"){throw\"malformed PKCS8 private key(code:003)\"}var p=u(s,r[1]);if(p.length!=2){throw\"malformed PKCS8 private key(code:004)\"}if(s.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 private key(code:005)\"}q.algoid=t(s,p[0]);if(s.substr(p[1],2)==\"06\"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!=\"04\"){throw\"malformed PKCS8 private key(code:006)\"}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,\"PRIVATE KEY\");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid==\"2a864886f70d010101\"){r=new RSAKey()}else{if(q.algoid==\"2a8648ce380401\"){r=new KJUR.crypto.DSA()}else{if(q.algoid==\"2a8648ce3d0201\"){r=new KJUR.crypto.ECDSA()}else{throw\"unsupported private key algorithm\"}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],\"06\");if(r===\"2a864886f70d010101\"){p=new RSAKey()}else{if(r===\"2a8648ce380401\"){p=new KJUR.crypto.DSA()}else{if(r===\"2a8648ce3d0201\"){p=new KJUR.crypto.ECDSA()}else{throw\"unsupported PKCS#8 public key hex\"}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!=\"30\"){throw\"malformed RSA key(code:001)\"}var q=t(r,0);if(q.length!=2){throw\"malformed RSA key(code:002)\"}if(r.substr(q[0],2)!=\"02\"){throw\"malformed RSA key(code:003)\"}p.n=s(r,q[0]);if(r.substr(q[1],2)!=\"02\"){throw\"malformed RSA key(code:004)\"}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw\"outer DERSequence shall have 2 elements: \"+r.length}var w=r[0];if(t.substr(w,2)!=\"30\"){throw\"malformed PKCS8 public key(code:001)\"}var p=u(t,w);if(p.length!=2){throw\"malformed PKCS8 public key(code:002)\"}if(t.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 public key(code:003)\"}q.algoid=s(t,p[0]);if(t.substr(p[1],2)==\"06\"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)==\"30\"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],\"02\");q.algparam.q=v.getVbyList(t,p[1],[1],\"02\");q.algparam.g=v.getVbyList(t,p[1],[2],\"02\")}}if(t.substr(r[1],2)!=\"03\"){throw\"malformed PKCS8 public key(code:004)\"}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!=\"undefined\"&&l instanceof w){return l}if(typeof i!=\"undefined\"&&l instanceof i){return l}if(typeof C!=\"undefined\"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;j.setPublicKeyHex(u);return j}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;var b=(\"0000000000\"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n===\"pkcs5prv\"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)===\"04\"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw\"unsupported PKCS#1/5 hexadecimal key\"}}}return P}if(n===\"pkcs8prv\"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n===\"pkcs8pub\"){return F._getKeyFromPublicPKCS8Hex(l)}if(n===\"x509pub\"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf(\"-END CERTIFICATE-\",0)!=-1||l.indexOf(\"-END X509 CERTIFICATE-\",0)!=-1||l.indexOf(\"-END TRUSTED CERTIFICATE-\",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf(\"-END PUBLIC KEY-\")!=-1){var O=pemtohex(l,\"PUBLIC KEY\");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var m=M(l,\"RSA PRIVATE KEY\");return F.getKey(m,null,\"pkcs5prv\")}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var I=M(l,\"DSA PRIVATE KEY\");var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END PRIVATE KEY-\")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf(\"-END EC PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],\"04\");var f=d(I,0,[2,0],\"06\");var A=d(I,0,[3,0],\"03\").substr(2);var e=\"\";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw\"undefined OID(hex) in KJUR.crypto.OID: \"+f}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END ENCRYPTED PRIVATE KEY-\")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw\"not supported argument\"};KEYUTIL.generateKeypair=function(a,c){if(a==\"RSA\"){var b=c;var h=new RSAKey();h.generate(b,\"10001\");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a==\"EC\"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw\"unknown algorithm: \"+a}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.n}},{\"int\":s.e},{\"int\":{bigint:s.d}},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.dmp1}},{\"int\":{bigint:s.dmq1}},{\"int\":{bigint:s.coeff}}]});return G}function B(G){var s=l({seq:[{\"int\":1},{octstr:{hex:G.prvKeyHex}},{tag:[\"a0\",true,{oid:{name:G.curveName}}]},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+G.pubKeyHex}}]}]});return s}function x(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.g}},{\"int\":{bigint:s.y}},{\"int\":{bigint:s.x}}]});return G}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D==\"PKCS8PUB\")){var E=new C(b);var w=E.getEncodedHex();return hextopem(w,\"PUBLIC KEY\")}if(D==\"PKCS1PRV\"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();return hextopem(w,\"RSA PRIVATE KEY\")}if(D==\"PKCS1PRV\"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.getEncodedHex();var h=B(b);var t=h.getEncodedHex();var p=\"\";p+=hextopem(v,\"EC PARAMETERS\");p+=hextopem(t,\"EC PRIVATE KEY\");return p}if(D==\"PKCS1PRV\"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();return hextopem(w,\"DSA PRIVATE KEY\")}if(D==\"PKCS5PRV\"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"RSA\",w,y,m,j)}if(D==\"PKCS5PRV\"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"EC\",w,y,m,j)}if(D==\"PKCS5PRV\"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"DSA\",w,y,m,j)}var o=function(G,s){var I=c(G,s);var H=new l({seq:[{seq:[{oid:{name:\"pkcs5PBES2\"}},{seq:[{seq:[{oid:{name:\"pkcs5PBKDF2\"}},{seq:[{octstr:{hex:I.pbkdf2Salt}},{\"int\":I.pbkdf2Iter}]}]},{seq:[{oid:{name:\"des-EDE3-CBC\"}},{octstr:{hex:I.encryptionSchemeIV}}]}]}]},{octstr:{hex:I.ciphertext}}]});return H.getEncodedHex()};var c=function(N,O){var H=100;var M=CryptoJS.lib.WordArray.random(8);var L=\"DES-EDE3-CBC\";var s=CryptoJS.lib.WordArray.random(8);var I=CryptoJS.PBKDF2(O,M,{keySize:192/32,iterations:H});var J=CryptoJS.enc.Hex.parse(N);var K=CryptoJS.TripleDES.encrypt(J,I,{iv:s})+\"\";var G={};G.ciphertext=K;G.pbkdf2Salt=CryptoJS.enc.Hex.stringify(M);G.pbkdf2Iter=H;G.encryptionSchemeAlg=L;G.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return G};if(D==\"PKCS8PRV\"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"rsaEncryption\"}},{\"null\":true}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var g=new l({seq:[{\"int\":1},{octstr:{hex:b.prvKeyHex}},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+b.pubKeyHex}}]}]});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"ecPublicKey\"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"dsa\"}},{seq:[{\"int\":{bigint:b.p}},{\"int\":{bigint:b.q}},{\"int\":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}throw\"unsupported object nor format\"};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,\"CERTIFICATE REQUEST\");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,\"pkcs8pub\");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!=\"30\"){throw\"malformed CSR(code:001)\"}var e=f(g,0);if(e.length<1){throw\"malformed CSR(code:002)\"}if(g.substr(e[0],2)!=\"30\"){throw\"malformed CSR(code:003)\"}var a=f(g,e[0]);if(a.length<3){throw\"malformed CSR(code:004)\"}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getJWKFromKey=function(d){var b={};if(d instanceof RSAKey&&d.isPrivate){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));b.d=hextob64u(d.d.toString(16));b.p=hextob64u(d.p.toString(16));b.q=hextob64u(d.q.toString(16));b.dp=hextob64u(d.dmp1.toString(16));b.dq=hextob64u(d.dmq1.toString(16));b.qi=hextob64u(d.coeff.toString(16));return b}else{if(d instanceof RSAKey&&d.isPublic){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPrivate){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);b.d=hextob64u(d.prvKeyHex);return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPublic){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);return b}}}}throw\"not supported key object\"};\nRSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,j,l,b,a,f,d,k;var m=ASN1HEX;var g=m.getVbyList;if(m.isASN1HEX(e)===false){throw\"not ASN.1 hex string\"}try{c=g(e,0,[2,0,1],\"02\");j=g(e,0,[2,0,2],\"02\");l=g(e,0,[2,0,3],\"02\");b=g(e,0,[2,0,4],\"02\");a=g(e,0,[2,0,5],\"02\");f=g(e,0,[2,0,6],\"02\");d=g(e,0,[2,0,7],\"02\");k=g(e,0,[2,0,8],\"02\")}catch(i){throw\"malformed PKCS#8 plain RSA private key\"}this.setPrivateEx(c,j,l,b,a,f,d,k)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw\"keyHex is not ASN.1 hex string\"}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!==\"02\"||c.substr(a[1],2)!==\"02\"){throw\"wrong hex for PKCS#5 public key\"}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw\"not ASN.1 hex string\"}if(c.getTLVbyList(b,0,[0,0])!==\"06092a864886f70d010101\"){throw\"not PKCS8 RSA public key\"}var a=c.getTLVbyList(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)};\nvar _RE_HEXDECONLY=new RegExp(\"\");_RE_HEXDECONLY.compile(\"[^0-9a-f]\",\"gi\");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c=\"\";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw\"invalid salt length\"}}}if(c<(g+k+2)){throw\"data too long\"}var f=\"\";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dthis.n.bitLength()){return 0}var i=this.doPublic(b);var e=i.toString(16).replace(/^1f+00/,\"\");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(k){return KJUR.crypto.Util.hashString(k,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){a=a.replace(_RE_HEXDECONLY,\"\");a=a.replace(/[ \\n]+/g,\"\");var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,\"\");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){var k=new BigInteger(s,16);if(k.bitLength()>this.n.bitLength()){return false}var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw\"invalid salt length\"}}}if(m<(h+c+2)){throw\"data too long\"}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw\"bits beyond keysize not zero\"}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q0){var b=\":\"+n.join(\":\")+\":\";if(b.indexOf(\":\"+k+\":\")==-1){throw\"algorithm '\"+k+\"' not accepted in the list\"}}if(k!=\"none\"&&B===null){throw\"key shall be specified to verify.\"}if(typeof B==\"string\"&&B.indexOf(\"-----BEGIN \")!=-1){B=KEYUTIL.getKey(B)}if(z==\"RS\"||z==\"PS\"){if(!(B instanceof m)){throw\"key shall be a RSAKey obj for RS* and PS* algs\"}}if(z==\"ES\"){if(!(B instanceof p)){throw\"key shall be a ECDSA obj for ES* algs\"}}if(k==\"none\"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw\"unsupported alg name: \"+k}else{u=t.jwsalg2sigalg[k]}if(u==\"none\"){throw\"not supported\"}else{if(u.substr(0,4)==\"Hmac\"){var o=null;if(B===undefined){throw\"hexadecimal key shall be specified for HMAC\"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf(\"withECDSA\")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(\".\");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw\"malformed sJWS: wrong number of '.' splitted elements\"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null,\" \");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null,\" \")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;var k=e.split(\".\");var c=k[0];var i=k[1];var q=c+\".\"+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw\"acceptField.alg shall be specified\"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss===\"object\"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub===\"object\"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud===\"object\"){if(typeof g.aud==\"string\"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud==\"object\"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt===\"number\"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!==\"number\"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp==\"number\"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw\"addSignature failed: \"+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw\"malformed header\"}if(typeof g.payload===\"string\"){this.sPayload=g.payload}else{throw\"malformed signatures\"}if(g.signatures.length>0){this.aSignatures=g.signatures}else{throw\"malformed signatures\"}}catch(e){throw\"malformed JWS-JS JSON object: \"+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}};\nexports.SecureRandom = SecureRandom;\nexports.rng_seed_time = rng_seed_time;\n\nexports.BigInteger = BigInteger;\nexports.RSAKey = RSAKey;\nexports.ECDSA = KJUR.crypto.ECDSA;\nexports.DSA = KJUR.crypto.DSA;\nexports.Signature = KJUR.crypto.Signature;\nexports.MessageDigest = KJUR.crypto.MessageDigest;\nexports.Mac = KJUR.crypto.Mac;\nexports.Cipher = KJUR.crypto.Cipher;\nexports.KEYUTIL = KEYUTIL;\nexports.ASN1HEX = ASN1HEX;\nexports.X509 = X509;\nexports.CryptoJS = CryptoJS;\n\n// ext/base64.js\nexports.b64tohex = b64tohex;\nexports.b64toBA = b64toBA;\n\n// base64x.js\nexports.stoBA = stoBA;\nexports.BAtos = BAtos;\nexports.BAtohex = BAtohex;\nexports.stohex = stohex;\nexports.stob64 = stob64;\nexports.stob64u = stob64u;\nexports.b64utos = b64utos;\nexports.b64tob64u = b64tob64u;\nexports.b64utob64 = b64utob64;\nexports.hex2b64 = hex2b64;\nexports.hextob64u = hextob64u;\nexports.b64utohex = b64utohex;\nexports.utf8tob64u = utf8tob64u;\nexports.b64utoutf8 = b64utoutf8;\nexports.utf8tob64 = utf8tob64;\nexports.b64toutf8 = b64toutf8;\nexports.utf8tohex = utf8tohex;\nexports.hextoutf8 = hextoutf8;\nexports.hextorstr = hextorstr;\nexports.rstrtohex = rstrtohex;\nexports.hextob64 = hextob64;\nexports.hextob64nl = hextob64nl;\nexports.b64nltohex = b64nltohex;\nexports.hextopem = hextopem;\nexports.pemtohex = pemtohex;\nexports.hextoArrayBuffer = hextoArrayBuffer;\nexports.ArrayBuffertohex = ArrayBuffertohex;\nexports.zulutomsec = zulutomsec;\nexports.zulutosec = zulutosec;\nexports.zulutodate = zulutodate;\nexports.datetozulu = datetozulu;\nexports.uricmptohex = uricmptohex;\nexports.hextouricmp = hextouricmp;\nexports.ipv6tohex = ipv6tohex;\nexports.hextoipv6 = hextoipv6;\nexports.hextoip = hextoip;\nexports.iptohex = iptohex;\nexports.encodeURIComponentAll = encodeURIComponentAll;\nexports.newline_toUnix = newline_toUnix;\nexports.newline_toDos = newline_toDos;\nexports.hextoposhex = hextoposhex;\nexports.intarystrtohex = intarystrtohex;\nexports.strdiffidx = strdiffidx;\n\n// name spaces\nexports.KJUR = KJUR;\nexports.crypto = KJUR.crypto;\nexports.asn1 = KJUR.asn1;\nexports.jws = KJUR.jws;\nexports.lang = KJUR.lang;\n\n\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://AppID/./node_modules/jsrsasign/lib/jsrsasign.js?"); + +/***/ }), + +/***/ "./node_modules/node-fetch/browser.js": +/*!********************************************!*\ + !*** ./node_modules/node-fetch/browser.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n// ref: https://github.com/tc39/proposal-global\nvar getGlobal = function () {\n\t// the only reliable means to get the global object is\n\t// `Function('return this')()`\n\t// However, this causes CSP violations in Chrome apps.\n\tif (typeof self !== 'undefined') { return self; }\n\tif (typeof window !== 'undefined') { return window; }\n\tif (typeof global !== 'undefined') { return global; }\n\tthrow new Error('unable to locate global object');\n}\n\nvar global = getGlobal();\n\nmodule.exports = exports = global.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = global.fetch.bind(global);\n\nexports.Headers = global.Headers;\nexports.Request = global.Request;\nexports.Response = global.Response;\n\n//# sourceURL=webpack://AppID/./node_modules/node-fetch/browser.js?"); + +/***/ }), + +/***/ "./node_modules/webpack/buildin/global.js": +/*!***********************************!*\ + !*** (webpack)/buildin/global.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://AppID/(webpack)/buildin/global.js?"); + +/***/ }), + +/***/ "./package.json": +/*!**********************!*\ + !*** ./package.json ***! + \**********************/ +/*! exports provided: name, version, description, scripts, repository, main, nyc, dependencies, devDependencies, default */ +/***/ (function(module) { + +eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"ibmcloud-appid-js\\\",\\\"version\\\":\\\"0.0.2\\\",\\\"description\\\":\\\"IBM Cloud App ID SDK for Single Page Applications\\\",\\\"scripts\\\":{\\\"build\\\":\\\"webpack --mode=development\\\",\\\"test\\\":\\\"mocha\\\",\\\"coverage\\\":\\\"nyc --reporter=lcov mocha\\\",\\\"docs\\\":\\\"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json\\\"},\\\"repository\\\":{\\\"type\\\":\\\"git\\\",\\\"url\\\":\\\"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git\\\"},\\\"main\\\":\\\"dist/appid.umd.min.js\\\",\\\"nyc\\\":{\\\"all\\\":true,\\\"include\\\":[\\\"src/*.js\\\"],\\\"exclude\\\":[\\\"**/PopupController.js\\\",\\\"**/IFrameController.js\\\",\\\"**/OpenIDConfigurationResource.js\\\",\\\"**/constants.js\\\"]},\\\"dependencies\\\":{\\\"jsrsasign\\\":\\\"^8.0.12\\\"},\\\"devDependencies\\\":{\\\"node-fetch\\\":\\\"^2.6.0\\\",\\\"@babel/cli\\\":\\\"^7.0.0\\\",\\\"@babel/core\\\":\\\"^7.5.5\\\",\\\"@babel/plugin-transform-runtime\\\":\\\"^7.5.5\\\",\\\"@babel/preset-env\\\":\\\"^7.5.5\\\",\\\"babel-cli\\\":\\\"^7.0.0-beta.3\\\",\\\"chai\\\":\\\"^4.2.0\\\",\\\"coveralls\\\":\\\"^3.0.6\\\",\\\"gulp-babel\\\":\\\"^8.0.0\\\",\\\"mocha\\\":\\\"^6.2.0\\\",\\\"nyc\\\":\\\"^14.1.1\\\",\\\"webpack\\\":\\\"^4.39.1\\\",\\\"webpack-cli\\\":\\\"^3.3.6\\\",\\\"docdash\\\":\\\"^1.1.1\\\",\\\"jsdoc\\\":\\\"^3.6.3\\\"}}\");\n\n//# sourceURL=webpack://AppID/./package.json?"); + +/***/ }), + +/***/ "./src/IFrameController.js": +/*!*********************************!*\ + !*** ./src/IFrameController.js ***! + \*********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const IFrameError = __webpack_require__(/*! ./errors/IFrameError */ \"./src/errors/IFrameError.js\");\n\nclass IFrameController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t}\n\n\topen(url) {\n\t\tthis.iFrame = this.window.document.createElement('iframe');\n\t\tthis.iFrame.src = url;\n\t\tthis.iFrame.width = 0;\n\t\tthis.iFrame.height = 0;\n\t\tthis.window.document.body.appendChild(this.iFrame);\n\t}\n\n\tremove() {\n\t\twindow.document.body.removeChild(this.iFrame);\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\treject(new IFrameError('Silent sign-in timed out'));\n\t\t\t}, 5 * 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tclearInterval(timer);\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = IFrameController;\n\n\n//# sourceURL=webpack://AppID/./src/IFrameController.js?"); + +/***/ }), + +/***/ "./src/OpenIDConfigurationResource.js": +/*!********************************************!*\ + !*** ./src/OpenIDConfigurationResource.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const packagejson = __webpack_require__(/*! ../package.json */ \"./package.json\");\n\nclass OpenIdConfigurationResource {\n\tasync init({discoveryEndpoint, requestHandler}){\n\t\tthis.openIdConfig = await requestHandler(discoveryEndpoint);\n\t\tconst headers = { 'x-filter-type': `spa:v${packagejson.version}` };\n\t\tthis.publicKeys = requestHandler(this.getJwksEndpoint(), { headers: headers });\n\t}\n\n\tgetAuthorizationEndpoint() {\n\t\treturn this.openIdConfig.authorization_endpoint;\n\t}\n\n\tgetUserInfoEndpoint() {\n\t\treturn this.openIdConfig.userinfo_endpoint;\n\t}\n\n\tgetJwksEndpoint() {\n\t\treturn this.openIdConfig.jwks_uri;\n\t}\n\n\tgetTokenEndpoint() {\n\t\treturn this.openIdConfig.token_endpoint;\n\t}\n\n\tgetIssuer() {\n\t\treturn this.openIdConfig.issuer;\n\t}\n\n\tasync getPublicKeys() {\n\t\treturn await this.publicKeys;\n\t}\n}\nmodule.exports = OpenIdConfigurationResource;\n\n\n\n//# sourceURL=webpack://AppID/./src/OpenIDConfigurationResource.js?"); + +/***/ }), + +/***/ "./src/PopupController.js": +/*!********************************!*\ + !*** ./src/PopupController.js ***! + \********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const PopupError = __webpack_require__(/*! ./errors/PopupError */ \"./src/errors/PopupError.js\");\n\nclass PopupController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t};\n\n\tinit(popupConfig){\n\t\tthis.popupConfig = popupConfig;\n\t}\n\n\topen() {\n\t\tconst h = this.popupConfig.height;\n\t\tconst w = this.popupConfig.width;\n\t\tconst left = (window.screen.width - w) / 2;\n\t\tconst top = (window.screen.height - h) / 2;\n\t\tthis.popup = this.window.open('', 'popup', `left=${left},top=${top},width=${w},height=${h},resizable,scrollbars=yes,status=1`);\n\t\tif (!this.popup) {\n\t\t\tthrow new PopupError('Unable to open popup')\n\t\t}\n\t};\n\n\tnavigate(url) {\n\t\tthis.popup.location.href = url;\n\t};\n\n\tclose() {\n\t\tthis.popup.close();\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\tif(this.popup.closed) {\n\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\treject(new PopupError('Popup closed'));\n\t\t\t\t}\n\t\t\t}, 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = PopupController;\n\n\n//# sourceURL=webpack://AppID/./src/PopupController.js?"); + +/***/ }), + +/***/ "./src/RequestHandler.js": +/*!*******************************!*\ + !*** ./src/RequestHandler.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t}\n\t\t\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tif (text !== '') {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); + +/***/ }), + +/***/ "./src/TokenValidator.js": +/*!*******************************!*\ + !*** ./src/TokenValidator.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg:[constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif (decoded.payloadObj.nonce && decoded.payloadObj.nonce !== nonce) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor(let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); + +/***/ }), + +/***/ "./src/constants.js": +/*!**************************!*\ + !*** ./src/constants.js ***! + \**************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN_PAYLOAD: 'Expect id token payload object to have identities field',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN_PAYLOAD: 'Missing id token payload',\n\tMISSING_TOKENS: 'Missing tokens object',\n\tMISSING_ACCESS_TOKEN: 'Missing access token string',\n\tMISSING_ID_TOKEN: 'Missing access token string',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tGENERATE_CODE: '/cloud_directory/generate_code',\n\tCHANGE_DETAILS: '/cloud_directory/change_details',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); + +/***/ }), + +/***/ "./src/errors/AppIDError.js": +/*!**********************************!*\ + !*** ./src/errors/AppIDError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class AppIDError extends Error {}\nmodule.exports = AppIDError;\n\n//# sourceURL=webpack://AppID/./src/errors/AppIDError.js?"); + +/***/ }), + +/***/ "./src/errors/IFrameError.js": +/*!***********************************!*\ + !*** ./src/errors/IFrameError.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class IFrameError extends Error {}\nmodule.exports = IFrameError;\n\n//# sourceURL=webpack://AppID/./src/errors/IFrameError.js?"); + +/***/ }), + +/***/ "./src/errors/OAuthError.js": +/*!**********************************!*\ + !*** ./src/errors/OAuthError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class OAuthError extends Error {\n\t// See https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for the possible error messages\n\tconstructor({error, description}) {\n\t\tsuper(description || error);\n\t\tthis.error = error;\n\t\tthis.description = description;\n\t}\n}\nmodule.exports = OAuthError;\n\n//# sourceURL=webpack://AppID/./src/errors/OAuthError.js?"); + +/***/ }), + +/***/ "./src/errors/PopupError.js": +/*!**********************************!*\ + !*** ./src/errors/PopupError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class PopupError extends Error {}\nmodule.exports = PopupError;\n\n//# sourceURL=webpack://AppID/./src/errors/PopupError.js?"); + +/***/ }), + +/***/ "./src/errors/RequestError.js": +/*!************************************!*\ + !*** ./src/errors/RequestError.js ***! + \************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class RequestError extends Error {\n\tconstructor(description, status, originError) {\n\t\tsuper(description);\n\t\tthis.status = status;\n\t\tthis.originError = originError;\n\t}\n}\nmodule.exports = RequestError;\n\n//# sourceURL=webpack://AppID/./src/errors/RequestError.js?"); + +/***/ }), + +/***/ "./src/errors/TokenError.js": +/*!**********************************!*\ + !*** ./src/errors/TokenError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class TokenError extends Error {}\nmodule.exports = TokenError;\n\n//# sourceURL=webpack://AppID/./src/errors/TokenError.js?"); + +/***/ }), + +/***/ "./src/index.js": +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in will attempt to authenticate the user in a hidden iframe.\n\t * You will need to enable Cloud Directory SSO.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * @param {string} idTokenPayload The id token payload.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token payload\"\n\t * @example\n\t * let tokens = await appID.changePassword(idTokenPayload);\n\t */\n\tasync changePassword(idTokenPayload) {\n\t\tthis._validateInitalize();\n\t\tlet userId;\n\n\t\tif (!idTokenPayload) {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN_PAYLOAD);\n\t\t}\n\t\tif (typeof idTokenPayload === 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN_PAYLOAD);\n\t\t}\n\t\tif (idTokenPayload.identities && idTokenPayload.identities[0] && idTokenPayload.identities[0].id) {\n\t\t\tif (idTokenPayload.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = idTokenPayload.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN_PAYLOAD);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change details widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {Object} tokens App ID tokens\n\t * @returns {Promise}\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @throws {AppIDError} \"Missing access token string\"\n\t * @throws {AppIDError} \"Missing tokens object\"\n\t * @example\n\t * let tokens = {accessToken, idToken}\n\t * let newTokens = await appID.changeDetails(tokens);\n\t */\n\tasync changeDetails(tokens) {\n\t\tif (!tokens) {\n\t\t\tthrow new AppIDError(constants.MISSING_TOKENS);\n\t\t}\n\n\t\tif (!tokens.accessToken && typeof tokens.accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ACCESS_TOKEN);\n\t\t}\n\n\t\tif (!tokens.idToken && typeof tokens.idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tconst generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE;\n\t\tconst changeDetailsCode = await this.request(generateCodeUrl, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + tokens.accessToken + ' ' + tokens.idToken\n\t\t\t}\n\t\t});\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS;\n\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint,\n\t\t\tchangeDetailsCode\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); + +/***/ }), + +/***/ "./src/utils.js": +/*!**********************!*\ + !*** ./src/utils.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId, changeDetailsCode}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tif (changeDetailsCode) {\n\t\t\tauthParams.code = changeDetailsCode;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint, changeDetailsCode}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint, changeDetailsCode});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); + +/***/ }) + +/******/ }); \ No newline at end of file diff --git a/dist/appid.umd.min.js b/dist/appid.umd.min.js index bfcd8e9..2bbc98c 100644 --- a/dist/appid.umd.min.js +++ b/dist/appid.umd.min.js @@ -1,50 +1,345 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.AppID=e():t.AppID=e()}(window,(function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=4)}([function(t,e,i){(function(t){var i={userAgent:!1},n={}; -/*! -Copyright (c) 2011, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.9.0 -*/ -if(void 0===r)var r={};r.lang={extend:function(t,e,n){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),n){var s;for(s in n)t.prototype[s]=n[s];var o=function(){},a=["toString","valueOf"];try{/MSIE/.test(i.userAgent)&&(o=function(t,e){for(s=0;s>>2]>>>24-s%4*8&255;e[n+s>>>2]|=o<<24-(n+s)%4*8}else for(s=0;s>>2]=i[s>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=s.ceil(e/4)},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i>>2]>>>24-r%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new u.init(i,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,i=t.sigBytes,n=[],r=0;r>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new u.init(i,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},g=a.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,n=e.sigBytes,r=this.blockSize,o=n/(4*r),a=(o=t?s.ceil(o):s.max((0|o)-this._minBufferSize,0))*r,h=s.min(4*a,n);if(a){for(var c=0;c>>2]}},e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:h,padding:c}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(h=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?n.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=n.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:i})}},e.SerializableCipher=i.extend({cfg:i.extend({format:h}),encrypt:function(t,e,i,n){n=this.cfg.extend(n);var r=t.createEncryptor(i,n);return e=r.finalize(e),r=r.cfg,l.create({ciphertext:e,key:i,iv:r.iv,algorithm:t,mode:r.mode,padding:r.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(i,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,i,r){return r||(r=n.random(8)),t=o.create({keySize:e+i}).compute(t,r),i=n.create(t.words.slice(e),4*i),t.sigBytes=4*e,l.create({key:t,iv:i,salt:r})}},g=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:d}),encrypt:function(t,e,i,n){return i=(n=this.cfg.extend(n)).kdf.execute(i,t.keySize,t.ivSize),n.iv=i.iv,(t=f.encrypt.call(this,t,e,i.key,n)).mixIn(i),t},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),i=n.kdf.execute(i,t.keySize,t.ivSize,e.salt),n.iv=i.iv,f.decrypt.call(this,t,e,i.key,n)}})}(),function(){for(var t=y,e=t.lib.BlockCipher,i=t.algo,n=[],r=[],s=[],o=[],a=[],h=[],u=[],c=[],l=[],f=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var p=0,v=0;for(g=0;256>g;g++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;n[p]=m,r[m]=p;var S=d[p],F=d[S],E=d[F],w=257*d[m]^16843008*m;s[p]=w<<24|w>>>8,o[p]=w<<16|w>>>16,a[p]=w<<8|w>>>24,h[p]=w,w=16843009*E^65537*F^257*S^16843008*p,u[m]=w<<24|w>>>8,c[m]=w<<16|w>>>16,l[m]=w<<8|w>>>24,f[m]=w,p?(p=S^d[d[d[E^S]]],v^=d[d[v]]):p=v=1}var x=[0,1,2,4,8,16,32,64,128,27,54];i=i.AES=e.extend({_doReset:function(){for(var t=(i=this._key).words,e=i.sigBytes/4,i=4*((this._nRounds=e+6)+1),r=this._keySchedule=[],s=0;s>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o]):(o=n[(o=o<<8|o>>>24)>>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o],o^=x[s/e|0]<<24),r[s]=r[s-e]^o}for(t=this._invKeySchedule=[],e=0;ee||4>=s?o:u[n[o>>>24]]^c[n[o>>>16&255]]^l[n[o>>>8&255]]^f[n[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,o,a,h,n)},decryptBlock:function(t,e){var i=t[e+1];t[e+1]=t[e+3],t[e+3]=i,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,r),i=t[e+1],t[e+1]=t[e+3],t[e+3]=i},_doCryptBlock:function(t,e,i,n,r,s,o,a){for(var h=this._nRounds,u=t[e]^i[0],c=t[e+1]^i[1],l=t[e+2]^i[2],f=t[e+3]^i[3],d=4,g=1;g>>24]^r[c>>>16&255]^s[l>>>8&255]^o[255&f]^i[d++],y=n[c>>>24]^r[l>>>16&255]^s[f>>>8&255]^o[255&u]^i[d++],v=n[l>>>24]^r[f>>>16&255]^s[u>>>8&255]^o[255&c]^i[d++];f=n[f>>>24]^r[u>>>16&255]^s[c>>>8&255]^o[255&l]^i[d++],u=p,c=y,l=v}p=(a[u>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&f])^i[d++],y=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[f>>>8&255]<<8|a[255&u])^i[d++],v=(a[l>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[255&c])^i[d++],f=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^i[d++],t[e]=p,t[e+1]=y,t[e+2]=v,t[e+3]=f},keySize:8});t.AES=e._createHelper(i)}(),function(){function t(t,e){var i=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=i,this._lBlock^=i<>>t^this._lBlock)&e;this._lBlock^=i,this._rBlock^=i<i;i++){var n=o[i]-1;e[i]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;16>n;n++){var r=t[n]=[],s=h[n];for(i=0;24>i;i++)r[i/6|0]|=e[(a[i]-1+s)%28]<<31-i%6,r[4+(i/6|0)]|=e[28+(a[i+24]-1+s)%28]<<31-i%6;for(r[0]=r[0]<<1|r[0]>>>31,i=1;7>i;i++)r[i]>>>=4*(i-1)+3;r[7]=r[7]<<5|r[7]>>>27}for(e=this._invSubKeys=[],i=0;16>i;i++)e[i]=t[15-i]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(i,n,r){this._lBlock=i[n],this._rBlock=i[n+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var o=r[s],a=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^o[f])&c[f])>>>0];this._lBlock=h,this._rBlock=a^l}r=this._lBlock,this._lBlock=this._rBlock,this._rBlock=r,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),i[n]=this._lBlock,i[n+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});i.DES=r._createHelper(l),s=s.TripleDES=r.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(n.create(t.slice(0,2))),this._des2=l.createEncryptor(n.create(t.slice(2,4))),this._des3=l.createEncryptor(n.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),i.TripleDES=r._createHelper(s)}(),function(){var t=y,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,i=t.sigBytes,n=this._map;t.clamp(),t=[];for(var r=0;r>>2]>>>24-r%4*8&255)<<16|(e[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|e[r+2>>>2]>>>24-(r+2)%4*8&255,o=0;4>o&&r+.75*o>>6*(3-o)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var i=t.length,n=this._map;(r=n.charAt(64))&&(-1!=(r=t.indexOf(r))&&(i=r));for(var r=[],s=0,o=0;o>>6-o%4*2;r[s>>>2]|=(a|h)<<24-s%4*8,s++}return e.create(r,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,i,n,r,s,o){return((t=t+(e&i|~e&n)+r+o)<>>32-s)+e}function i(t,e,i,n,r,s,o){return((t=t+(e&n|i&~n)+r+o)<>>32-s)+e}function n(t,e,i,n,r,s,o){return((t=t+(e^i^n)+r+o)<>>32-s)+e}function r(t,e,i,n,r,s,o){return((t=t+(i^(e|~n))+r+o)<>>32-s)+e}for(var s=y,o=(h=s.lib).WordArray,a=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var o=0;16>o;o++){var a=t[h=s+o];t[h]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var h=t[s+0],c=(a=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],d=t[s+5],g=t[s+6],p=t[s+7],y=t[s+8],v=t[s+9],m=t[s+10],S=t[s+11],F=t[s+12],E=t[s+13],w=t[s+14],x=t[s+15],b=e(b=o[0],C=o[1],I=o[2],A=o[3],h,7,u[0]),A=e(A,b,C,I,a,12,u[1]),I=e(I,A,b,C,c,17,u[2]),C=e(C,I,A,b,l,22,u[3]);b=e(b,C,I,A,f,7,u[4]),A=e(A,b,C,I,d,12,u[5]),I=e(I,A,b,C,g,17,u[6]),C=e(C,I,A,b,p,22,u[7]),b=e(b,C,I,A,y,7,u[8]),A=e(A,b,C,I,v,12,u[9]),I=e(I,A,b,C,m,17,u[10]),C=e(C,I,A,b,S,22,u[11]),b=e(b,C,I,A,F,7,u[12]),A=e(A,b,C,I,E,12,u[13]),I=e(I,A,b,C,w,17,u[14]),b=i(b,C=e(C,I,A,b,x,22,u[15]),I,A,a,5,u[16]),A=i(A,b,C,I,g,9,u[17]),I=i(I,A,b,C,S,14,u[18]),C=i(C,I,A,b,h,20,u[19]),b=i(b,C,I,A,d,5,u[20]),A=i(A,b,C,I,m,9,u[21]),I=i(I,A,b,C,x,14,u[22]),C=i(C,I,A,b,f,20,u[23]),b=i(b,C,I,A,v,5,u[24]),A=i(A,b,C,I,w,9,u[25]),I=i(I,A,b,C,l,14,u[26]),C=i(C,I,A,b,y,20,u[27]),b=i(b,C,I,A,E,5,u[28]),A=i(A,b,C,I,c,9,u[29]),I=i(I,A,b,C,p,14,u[30]),b=n(b,C=i(C,I,A,b,F,20,u[31]),I,A,d,4,u[32]),A=n(A,b,C,I,y,11,u[33]),I=n(I,A,b,C,S,16,u[34]),C=n(C,I,A,b,w,23,u[35]),b=n(b,C,I,A,a,4,u[36]),A=n(A,b,C,I,f,11,u[37]),I=n(I,A,b,C,p,16,u[38]),C=n(C,I,A,b,m,23,u[39]),b=n(b,C,I,A,E,4,u[40]),A=n(A,b,C,I,h,11,u[41]),I=n(I,A,b,C,l,16,u[42]),C=n(C,I,A,b,g,23,u[43]),b=n(b,C,I,A,v,4,u[44]),A=n(A,b,C,I,F,11,u[45]),I=n(I,A,b,C,x,16,u[46]),b=r(b,C=n(C,I,A,b,c,23,u[47]),I,A,h,6,u[48]),A=r(A,b,C,I,p,10,u[49]),I=r(I,A,b,C,w,15,u[50]),C=r(C,I,A,b,d,21,u[51]),b=r(b,C,I,A,F,6,u[52]),A=r(A,b,C,I,l,10,u[53]),I=r(I,A,b,C,m,15,u[54]),C=r(C,I,A,b,a,21,u[55]),b=r(b,C,I,A,y,6,u[56]),A=r(A,b,C,I,x,10,u[57]),I=r(I,A,b,C,g,15,u[58]),C=r(C,I,A,b,E,21,u[59]),b=r(b,C,I,A,f,6,u[60]),A=r(A,b,C,I,S,10,u[61]),I=r(I,A,b,C,c,15,u[62]),C=r(C,I,A,b,v,21,u[63]);o[0]=o[0]+b|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+A|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;i[r>>>5]|=128<<24-r%32;var s=t.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(i.length+1),this._process(),i=(e=this._hash).words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=a._createHelper(h),s.HmacMD5=a._createHmacHelper(h)}(Math),function(){var t=y,e=(r=t.lib).WordArray,i=r.Hasher,n=[],r=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=this._hash.words,r=i[0],s=i[1],o=i[2],a=i[3],h=i[4],u=0;80>u;u++){if(16>u)n[u]=0|t[e+u];else{var c=n[u-3]^n[u-8]^n[u-14]^n[u-16];n[u]=c<<1|c>>>31}c=(r<<5|r>>>27)+h+n[u],c=20>u?c+(1518500249+(s&o|~s&a)):40>u?c+(1859775393+(s^o^a)):60>u?c+((s&o|s&a|o&a)-1894007588):c+((s^o^a)-899497514),h=a,a=o,o=s<<30|s>>>2,s=r,r=c}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+o|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(i/4294967296),e[15+(n+64>>>9<<4)]=i,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=i._createHelper(r),t.HmacSHA1=i._createHmacHelper(r)}(),function(t){for(var e=y,i=(r=e.lib).WordArray,n=r.Hasher,r=e.algo,s=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=a(t.pow(h,.5))),o[u]=a(t.pow(h,1/3)),u++),h++}var d=[];r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(t,e){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],a=i[3],h=i[4],u=i[5],c=i[6],l=i[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var g=d[f-15],p=d[f-2];d[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[f-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[f-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+o[f]+d[f],p=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&r^n&s^r&s),l=c,c=u,u=h,h=a+g|0,a=s,s=r,r=n,n=g+p|0}i[0]=i[0]+n|0,i[1]=i[1]+r|0,i[2]=i[2]+s|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0,i[5]=i[5]+u|0,i[6]=i[6]+c|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return i[r>>>5]|=128<<24-r%32,i[14+(r+64>>>9<<4)]=t.floor(n/4294967296),i[15+(r+64>>>9<<4)]=n,e.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(r),e.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var t=y,e=t.lib.WordArray,i=(n=t.algo).SHA256,n=n.SHA224=i.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=i._createHelper(n),t.HmacSHA224=i._createHmacHelper(n)}(),function(){function t(){return n.create.apply(n,arguments)}for(var e=y,i=e.lib.Hasher,n=(s=e.x64).Word,r=s.WordArray,s=e.algo,o=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],a=[],h=0;80>h;h++)a[h]=t();s=s.SHA512=i.extend({_doReset:function(){this._hash=new r.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var i=(l=this._hash.words)[0],n=l[1],r=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=i.high,d=i.low,g=n.high,p=n.low,y=r.high,v=r.low,m=s.high,S=s.low,F=h.high,E=h.low,w=u.high,x=u.low,b=c.high,A=c.low,I=l.high,C=l.low,D=f,T=d,P=g,R=p,H=y,N=v,B=m,O=S,j=F,V=E,L=w,_=x,K=b,k=A,M=I,U=C,q=0;80>q;q++){var z=a[q];if(16>q)var G=z.high=0|t[e+2*q],Y=z.low=0|t[e+2*q+1];else{G=((Y=(G=a[q-15]).high)>>>1|(J=G.low)<<31)^(Y>>>8|J<<24)^Y>>>7;var J=(J>>>1|Y<<31)^(J>>>8|Y<<24)^(J>>>7|Y<<25),W=((Y=(W=a[q-2]).high)>>>19|(X=W.low)<<13)^(Y<<3|X>>>29)^Y>>>6,X=(X>>>19|Y<<13)^(X<<3|Y>>>29)^(X>>>6|Y<<26),Z=(Y=a[q-7]).high,$=(Q=a[q-16]).high,Q=Q.low;G=(G=(G=G+Z+((Y=J+Y.low)>>>0>>0?1:0))+W+((Y=Y+X)>>>0>>0?1:0))+$+((Y=Y+Q)>>>0>>0?1:0);z.high=G,z.low=Y}Z=j&L^~j&K,Q=V&_^~V&k,z=D&P^D&H^P&H;var tt=T&R^T&N^R&N,et=(J=(D>>>28|T<<4)^(D<<30|T>>>2)^(D<<25|T>>>7),W=(T>>>28|D<<4)^(T<<30|D>>>2)^(T<<25|D>>>7),(X=o[q]).high),it=X.low;$=M+((j>>>14|V<<18)^(j>>>18|V<<14)^(j<<23|V>>>9))+((X=U+((V>>>14|j<<18)^(V>>>18|j<<14)^(V<<23|j>>>9)))>>>0>>0?1:0),M=K,U=k,K=L,k=_,L=j,_=V,j=B+($=($=($=$+Z+((X=X+Q)>>>0>>0?1:0))+et+((X=X+it)>>>0>>0?1:0))+G+((X=X+Y)>>>0>>0?1:0))+((V=O+X|0)>>>0>>0?1:0)|0,B=H,O=N,H=P,N=R,P=D,R=T,D=$+(z=J+z+((Y=W+tt)>>>0>>0?1:0))+((T=X+Y|0)>>>0>>0?1:0)|0}d=i.low=d+T,i.high=f+D+(d>>>0>>0?1:0),p=n.low=p+R,n.high=g+P+(p>>>0>>0?1:0),v=r.low=v+N,r.high=y+H+(v>>>0>>0?1:0),S=s.low=S+O,s.high=m+B+(S>>>0>>0?1:0),E=h.low=E+V,h.high=F+j+(E>>>0>>0?1:0),x=u.low=x+_,u.high=w+L+(x>>>0<_>>>0?1:0),A=c.low=A+k,c.high=b+K+(A>>>0>>0?1:0),C=l.low=C+U,l.high=I+M+(C>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(i/4294967296),e[31+(n+128>>>10<<5)]=i,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=i._createHelper(s),e.HmacSHA512=i._createHmacHelper(s)}(),function(){var t=y,e=(r=t.x64).Word,i=r.WordArray,n=(r=t.algo).SHA512,r=r.SHA384=n.extend({_doReset:function(){this._hash=new i.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(r),t.HmacSHA384=n._createHmacHelper(r)}(),function(){var t=y,e=(n=t.lib).WordArray,i=n.Hasher,n=t.algo,r=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),o=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);n=n.RIPEMD160=i.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=0;16>i;i++){var n=t[F=e+i];t[F]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var c,l,f,d,g,p,y,v,m,S,F=this._hash.words,E=(n=h.words,u.words),w=r.words,x=s.words,b=o.words,A=a.words;p=c=F[0],y=l=F[1],v=f=F[2],m=d=F[3],S=g=F[4];var I;for(i=0;80>i;i+=1)I=c+t[e+w[i]]|0,I=16>i?I+((l^f^d)+n[0]):32>i?I+((l&f|~l&d)+n[1]):48>i?I+(((l|~f)^d)+n[2]):64>i?I+((l&d|f&~d)+n[3]):I+((l^(f|~d))+n[4]),I=(I=(I|=0)<>>32-b[i])+g|0,c=g,g=d,d=f<<10|f>>>22,f=l,l=I,I=p+t[e+x[i]]|0,I=16>i?I+((y^(v|~m))+E[0]):32>i?I+((y&m|v&~m)+E[1]):48>i?I+(((y|~v)^m)+E[2]):64>i?I+((y&v|~y&m)+E[3]):I+((y^v^m)+E[4]),I=(I=(I|=0)<>>32-A[i])+S|0,p=S,S=m,m=v<<10|v>>>22,v=y,y=I;I=F[1]+f+m|0,F[1]=F[2]+d+S|0,F[2]=F[3]+g+p|0,F[3]=F[4]+c+y|0,F[4]=F[0]+l+v|0,F[0]=I},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,i=0;5>i;i++)n=e[i],e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(n),t.HmacRIPEMD160=i._createHmacHelper(n)}(Math),function(){var t=y,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,i){t=this._hasher=new t.init,"string"==typeof i&&(i=e.parse(i));var n=t.blockSize,r=4*n;i.sigBytes>r&&(i=t.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),o=this._iKey=i.clone(),a=s.words,h=o.words,u=0;u>6)+m.charAt(63&i);if(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),n+=m.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),n+=m.charAt(i>>2)+m.charAt((3&i)<<4)),S)for(;(3&n.length)>0;)n+=S;return n}function E(t){var e,i,n,r="",s=0;for(e=0;e>2),i=3&n,s=1):1==s?(r+=T(i<<2|n>>4),i=15&n,s=2):2==s?(r+=T(i),r+=T(n>>2),i=3&n,s=3):(r+=T(i<<2|n>>4),r+=T(15&n),s=0));return 1==s&&(r+=T(i<<2)),r}function w(t){var e,i=E(t),n=new Array;for(e=0;2*e>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;r=((h=o*h+((32767&c)<<15)+i[n]+(1073741823&r))>>>30)+(c>>>15)+a*u+(r>>>30),i[n++]=1073741823&h}return r},v=30):"Netscape"!=i.appName?(x.prototype.am=function(t,e,i,n,r,s){for(;--s>=0;){var o=e*this[t++]+i[n]+r;r=Math.floor(o/67108864),i[n++]=67108863&o}return r},v=26):(x.prototype.am=function(t,e,i,n,r,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;r=((h=o*h+((16383&c)<<14)+i[n]+r)>>28)+(c>>14)+a*u,i[n++]=268435455&h}return r},v=28),x.prototype.DB=v,x.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function N(t){this.m=t}function B(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function K(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function k(){}function M(t){return t}function U(t){this.r2=b(),this.q3=b(),x.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}N.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},N.prototype.revert=function(t){return t},N.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},N.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},N.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},B.prototype.convert=function(t){var e=b();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(x.ZERO)>0&&this.m.subTo(e,e),e},B.prototype.revert=function(t){var e=b();return t.copyTo(e),this.reduce(e),e},B.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},B.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},B.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},x.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},x.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},x.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,r=!1,s=0;--n>=0;){var o=8==i?255&t[n]:P(t,n);o<0?"-"==t.charAt(n)&&(r=!0):(r=!1,0==s?this[this.t++]=o:s+i>this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},x.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},x.prototype.drShiftTo=function(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>r|a,a=(this[i]&s)<=0;--i)e[i]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},x.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,r=this.DB-n,s=(1<>n;for(var o=i+1;o>n;n>0&&(e[this.t-i-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},x.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),r=i.t;for(e.t=r+n.t;--r>=0;)e[r]=0;for(r=0;r=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},x.prototype.divRemTo=function(t,e,i){var n=t.abs();if(!(n.t<=0)){var r=this.abs();if(r.t0?(n.lShiftTo(h,s),r.lShiftTo(h,i)):(n.copyTo(s),r.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<1?s[u-2]>>this.F2:0),f=this.FV/l,d=(1<=0&&(i[i.t++]=1,i.subTo(v,i)),x.ONE.dlShiftTo(u,v),v.subTo(s,s);s.t=0;){var m=i[--p]==c?this.DM:Math.floor(i[p]*f+(i[p-1]+g)*d);if((i[p]+=s.am(0,m,i,y,0,u))0&&i.rShiftTo(h,i),o<0&&x.ZERO.subTo(i,i)}}},x.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},x.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},x.prototype.exp=function(t,e){if(t>4294967295||t<1)return x.ONE;var i=b(),n=b(),r=e.convert(this),s=H(t)-1;for(r.copyTo(i);--s>=0;)if(e.sqrTo(i,n),(t&1<0)e.mulTo(n,r,i);else{var o=i;i=n,n=o}return e.revert(i)},x.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<0)for(a>a)>0&&(r=!0,s=T(i));o>=0;)a>(a+=this.DB-e)):(i=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),i>0&&(r=!0),r&&(s+=T(i));return r?s:"0"},x.prototype.negate=function(){var t=b();return x.ZERO.subTo(this,t),t},x.prototype.abs=function(){return this.s<0?this.negate():this},x.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},x.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+H(this[this.t-1]^this.s&this.DM)},x.prototype.mod=function(t){var e=b();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(x.ZERO)>0&&t.subTo(e,e),e},x.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new N(e):new B(e),this.exp(t,i)},x.ZERO=R(0),x.ONE=R(1),k.prototype.convert=M,k.prototype.revert=M,k.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},k.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=b();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var q=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],z=(1<<26)/q[q.length-1]; -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function G(){this.i=0,this.j=0,this.S=new Array}x.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},x.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),n=R(i),r=b(),s=b(),o="";for(this.divRemTo(n,r,s);r.signum()>0;)o=(i+s.intValue()).toString(t).substr(1)+o,r.divRemTo(n,r,s);return s.intValue().toString(t)+o},x.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),r=!1,s=0,o=0,a=0;a=i&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),r&&x.ZERO.subTo(this,this)},x.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(x.ONE.shiftLeft(t-1),j,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(x.ONE.shiftLeft(t-1),this);else{var n=new Array,r=7&t;n.length=1+(t>>3),e.nextBytes(n),r>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},x.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},x.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},x.prototype.multiplyLowerTo=function(t,e,i){var n,r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r=0;)i[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},x.prototype.millerRabin=function(t){var e=this.subtract(x.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var n=e.shiftRight(i);(t=t+1>>1)>q.length&&(t=q.length);for(var r=b(),s=0;s>24},x.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},x.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},x.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,r=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[r++]=i|this.s<=0;)n<8?(i=(this[t]&(1<>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(e[r++]=i);return e},x.prototype.equals=function(t){return 0==this.compareTo(t)},x.prototype.min=function(t){return this.compareTo(t)<0?this:t},x.prototype.max=function(t){return this.compareTo(t)>0?this:t},x.prototype.and=function(t){var e=b();return this.bitwiseTo(t,O,e),e},x.prototype.or=function(t){var e=b();return this.bitwiseTo(t,j,e),e},x.prototype.xor=function(t){var e=b();return this.bitwiseTo(t,V,e),e},x.prototype.andNot=function(t){var e=b();return this.bitwiseTo(t,L,e),e},x.prototype.not=function(){for(var t=b(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var c=b();for(n.sqrTo(o[1],c);a<=u;)o[a]=b(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,d=t.t-1,g=!0,p=b();for(r=H(t[d])-1;d>=0;){for(r>=h?l=t[d]>>r-h&u:(l=(t[d]&(1<0&&(l|=t[d-1]>>this.DB+r-h)),a=i;0==(1&l);)l>>=1,--a;if((r-=a)<0&&(r+=this.DB,--d),g)o[l].copyTo(s),g=!1;else{for(;a>1;)n.sqrTo(s,p),n.sqrTo(p,s),a-=2;a>0?n.sqrTo(s,p):(f=s,s=p,p=f),n.mulTo(p,o[l],s)}for(;d>=0&&0==(t[d]&1<=0?(i.subTo(n,i),e&&r.subTo(o,r),s.subTo(a,s)):(n.subTo(i,n),e&&o.subTo(r,o),a.subTo(s,a))}return 0!=n.compareTo(x.ONE)?x.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},x.prototype.pow=function(t){return this.exp(t,new k)},x.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var r=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(r0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(r=e.getLowestSetBit())>0&&e.rShiftTo(r,e),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},x.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=q[q.length-1]){for(e=0;e>8&255,J[W++]^=t>>16&255,J[W++]^=t>>24&255,W>=X&&(W-=X)}((new Date).getTime())}if(null==J){var $;if(J=new Array,W=0,void 0!==n&&(void 0!==n.crypto||void 0!==n.msCrypto)){var Q=n.crypto||n.msCrypto;if(Q.getRandomValues){var tt=new Uint8Array(32);for(Q.getRandomValues(tt),$=0;$<32;++$)J[W++]=tt[$]}else if("Netscape"==i.appName&&i.appVersion<"5"){var et=n.crypto.random(32);for($=0;$>>8,J[W++]=255&$;W=0,Z()}function it(){if(null==Y){for(Z(),(Y=new G).init(J),W=0;W>24,(16711680&r)>>16,(65280&r)>>8,255&r]))),r+=1;return n}function ot(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function at(t,e,i){for(var n="",r=0;n.length>24,(16711680&r)>>16,(65280&r)>>8,255&r])),r+=1;return n} -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function ht(t,e){this.x=e,this.q=t}function ut(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?x.ONE:n,this.zinv=null}function ct(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new ut(this,null,null)}nt.prototype.nextBytes=function(t){var e;for(e=0;e0&&e.length>0))throw"Invalid RSA public key";this.n=rt(t,16),this.e=parseInt(e,16)}},ot.prototype.encrypt=function(t){var e=function(t,e){if(e=0&&e>0;){var r=t.charCodeAt(n--);r<128?i[--e]=r:r>127&&r<2048?(i[--e]=63&r|128,i[--e]=r>>6|192):(i[--e]=63&r|128,i[--e]=r>>6&63|128,i[--e]=r>>12|224)}i[--e]=0;for(var s=new nt,o=new Array;e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new x(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var n=i.toString(16);return 0==(1&n.length)?n:"0"+n},ot.prototype.encryptOAEP=function(t,e,i){var n=function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;if(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t.length+2*n+2>e)throw"Message too long for RSA";var a,h="";for(a=0;a>3,e,i);if(null==n)return null;var r=this.doPublic(n);if(null==r)return null;var s=r.toString(16);return 0==(1&s.length)?s:"0"+s},ot.prototype.type="RSA",ot.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},ot.prototype.setPrivate=function(t,e,i){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=i;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16)}},ot.prototype.setPrivateEx=function(t,e,i,n,r,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16),this.p=rt(n,16),this.q=rt(r,16),this.dmp1=rt(s,16),this.dmq1=rt(o,16),this.coeff=rt(a,16)},ot.prototype.generate=function(t,e){var i=new nt,n=t>>1;this.e=parseInt(e,16);for(var r=new x(e,16);;){for(;this.p=new x(t-n,1,i),0!=this.p.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.p.isProbablePrime(10););for(;this.q=new x(n,1,i),0!=this.q.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(x.ONE),a=this.q.subtract(x.ONE),h=o.multiply(a);if(0==h.gcd(r).compareTo(x.ONE)){this.n=this.p.multiply(this.q),this.d=r.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},ot.prototype.decrypt=function(t){var e=rt(t,16),i=this.doPrivate(e);return null==i?null: -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function(t,e){for(var i=t.toByteArray(),n=0;n=i.length)return null;for(var r="";++n191&&s<224?(r+=String.fromCharCode((31&s)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&s)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},ot.prototype.decryptOAEP=function(t,e,i){var n=rt(t,16),r=this.doPrivate(n);return null==r?null:function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;for(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t=t.toByteArray(),a=0;a>3,e,i)},ht.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ht.prototype.toBigInteger=function(){return this.x},ht.prototype.negate=function(){return new ht(this.q,this.x.negate().mod(this.q))},ht.prototype.add=function(t){return new ht(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ht.prototype.subtract=function(t){return new ht(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ht.prototype.multiply=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ht.prototype.square=function(){return new ht(this.q,this.x.square().mod(this.q))},ht.prototype.divide=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ut.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO))},ut.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(x.ZERO)&&!this.y.toBigInteger().equals(x.ZERO)},ut.prototype.negate=function(){return new ut(this.curve,this.x,this.y.negate(),this.z)},ut.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),i=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(x.ZERO.equals(i))return x.ZERO.equals(e)?this.twice():this.curve.getInfinity();var n=new x("3"),r=this.x.toBigInteger(),s=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),i.square()),a=o.multiply(i),h=r.multiply(o),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(a).multiply(i).mod(this.curve.q),l=h.multiply(n).multiply(e).subtract(s.multiply(a)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),f=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},ut.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new x("3"),e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=i.multiply(this.z),r=n.multiply(i).mod(this.curve.q),s=this.curve.a.toBigInteger(),o=e.square().multiply(t);x.ZERO.equals(s)||(o=o.add(this.z.square().multiply(s)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(r)).shiftLeft(1).multiply(n).mod(this.curve.q),h=o.multiply(t).multiply(e).subtract(r.shiftLeft(1)).shiftLeft(2).multiply(r).subtract(o.square().multiply(o)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),u)},ut.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add(o?this:r))}return s},ut.prototype.multiplyTwo=function(t,e,i){var n;n=t.bitLength()>i.bitLength()?t.bitLength()-1:i.bitLength()-1;for(var r=this.curve.getInfinity(),s=this.add(e);n>=0;)r=r.twice(),t.testBit(n)?r=i.testBit(n)?r.add(s):r.add(this):i.testBit(n)&&(r=r.add(e)),--n;return r},ct.prototype.getQ=function(){return this.q},ct.prototype.getA=function(){return this.a},ct.prototype.getB=function(){return this.b},ct.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ct.prototype.getInfinity=function(){return this.infinity},ct.prototype.fromBigInteger=function(t){return new ht(this.q,t)},ct.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,i=t.substr(2,e),n=t.substr(e+2,e);return new ut(this,this.fromBigInteger(new x(i,16)),this.fromBigInteger(new x(n,16)));default:return null}}, -/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib - */ -ht.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ut.prototype.getEncoded=function(t){var e=function(t,e){var i=t.toByteArrayUnsigned();if(ei.length;)i.unshift(0);return i},i=this.getX().toBigInteger(),n=this.getY().toBigInteger(),r=e(i,32);return t?n.isEven()?r.unshift(2):r.unshift(3):(r.unshift(4),r=r.concat(e(n,32))),r},ut.decodeFrom=function(t,e){e[0];var i=e.length-1,n=e.slice(1,1+i/2),r=e.slice(1+i/2,1+i);n.unshift(0),r.unshift(0);var s=new x(n),o=new x(r);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.decodeFromHex=function(t,e){e.substr(0,2);var i=e.length-2,n=e.substr(2,i/2),r=e.substr(2+i/2,i/2),s=new x(n,16),o=new x(r,16);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),i=t.y.subtract(this.y).divide(e),n=i.square().subtract(this.x).subtract(t.x),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(x.valueOf(2)),e=this.curve.fromBigInteger(x.valueOf(3)),i=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=i.square().subtract(this.x.multiply(t)),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add2D(o?this:r))}return s},ut.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),i=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),r=this.curve.getQ(),s=e.multiply(e).mod(r),o=t.multiply(t).multiply(t).add(i.multiply(t)).add(n).mod(r);return s.equals(o)},ut.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ut.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),i=this.getY().toBigInteger();if(e.compareTo(x.ONE)<0||e.compareTo(t.subtract(x.ONE))>0)throw new Error("x coordinate out of bounds");if(i.compareTo(x.ONE)<0||i.compareTo(t.subtract(x.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0}; -/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval - */ -var lt=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),i={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,n){return e?i[e]:String.fromCharCode(parseInt(n,16))}var r=new String(""),s=(Object,Array,Object.hasOwnProperty);return function(i,o){var a,h,u=i.match(t),c=u[0],l=!1;"{"===c?a={}:"["===c?a=[]:(a=[],l=!0);for(var f=[a],d=1-l,g=u.length;d=0;)delete i[n[h]]}return o.call(t,e,i)};a=y({"":a},"")}return a}}();void 0!==ft&&ft||(ft={}),void 0!==ft.asn1&&ft.asn1||(ft.asn1={}),ft.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},ft.asn1.DERAbstractString=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=bt(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},r.lang.extend(ft.asn1.DERAbstractString,ft.asn1.ASN1Object),ft.asn1.DERAbstractTime=function(t){ft.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var n=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var h=n(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=St(t)},this.setByDateValue=function(t,e,i,n,r,s){var o=new Date(Date.UTC(t,e-1,i,n,r,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},r.lang.extend(ft.asn1.DERAbstractTime,ft.asn1.ASN1Object),ft.asn1.DERAbstractStructured=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},r.lang.extend(ft.asn1.DERAbstractStructured,ft.asn1.ASN1Object),ft.asn1.DERBoolean=function(){ft.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},r.lang.extend(ft.asn1.DERBoolean,ft.asn1.ASN1Object),ft.asn1.DERInteger=function(t){ft.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ft.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},r.lang.extend(ft.asn1.DERInteger,ft.asn1.ASN1Object),ft.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ft.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}ft.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7r.length&&(r=n[i]);return(t=t.replace(r,"::")).slice(1,-1)}function _t(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?Lt(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function Kt(t){for(var e=encodeURIComponent(t),i="",n=0;n"7"?"00"+t:t}function Mt(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,i){var n=parseInt(t);if(n<0||255=2*s)break;if(a>=200)break;n.push(h),o=h,a++}return n},pt.getNthChildIdx=function(t,e,i){return pt.getChildIdx(t,e)[i]},pt.getIdxbyList=function(t,e,i,n){var r,s,o=pt;if(0==i.length){if(void 0!==n&&t.substr(e,2)!==n)throw"checking tag doesn't match: "+t.substr(e,2)+"!="+n;return e}return r=i.shift(),s=o.getChildIdx(t,e),o.getIdxbyList(t,s[r],i,n)},pt.getTLVbyList=function(t,e,i,n){var r=pt,s=r.getIdxbyList(t,e,i);if(void 0===s)throw"can't find nthList object";if(void 0!==n&&t.substr(s,2)!=n)throw"checking tag doesn't match: "+t.substr(s,2)+"!="+n;return r.getTLV(t,s)},pt.getVbyList=function(t,e,i,n,r){var s,o,a=pt;if(void 0===(s=a.getIdxbyList(t,e,i,n)))throw"can't find nthList object";return o=a.getV(t,s),!0===r&&(o=o.substr(2)),o},pt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},i=[],n=t.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var s=t.substr(2),o=[],a=0;a0&&(c=c+"."+h.join(".")),c},pt.dump=function(t,e,i,n){var r=pt,s=r.getV,o=r.dump,a=r.getChildIdx,h=t;t instanceof ft.asn1.ASN1Object&&(h=t.getEncodedHex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var c=e.ommit_long_octet;if("01"==h.substr(i,2))return"00"==(l=s(h,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==h.substr(i,2))return n+"INTEGER "+u(l=s(h,i),c)+"\n";if("03"==h.substr(i,2))return n+"BITSTRING "+u(l=s(h,i),c)+"\n";if("04"==h.substr(i,2)){var l=s(h,i);if(r.isASN1HEX(l)){var f=n+"OCTETSTRING, encapsulates\n";return f+=o(l,e,0,n+" ")}return n+"OCTETSTRING "+u(l,c)+"\n"}if("05"==h.substr(i,2))return n+"NULL\n";if("06"==h.substr(i,2)){var d=s(h,i),g=ft.asn1.ASN1Util.oidHexToInt(d),p=ft.asn1.x509.OID.oid2name(g),y=g.replace(/\./g," ");return""!=p?n+"ObjectIdentifier "+p+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0c"==h.substr(i,2))return n+"UTF8String '"+At(s(h,i))+"'\n";if("13"==h.substr(i,2))return n+"PrintableString '"+At(s(h,i))+"'\n";if("14"==h.substr(i,2))return n+"TeletexString '"+At(s(h,i))+"'\n";if("16"==h.substr(i,2))return n+"IA5String '"+At(s(h,i))+"'\n";if("17"==h.substr(i,2))return n+"UTCTime "+At(s(h,i))+"\n";if("18"==h.substr(i,2))return n+"GeneralizedTime "+At(s(h,i))+"\n";if("30"==h.substr(i,2)){if("3000"==h.substr(i,4))return n+"SEQUENCE {}\n";f=n+"SEQUENCE\n";var v=e;if((2==(F=a(h,i)).length||3==F.length)&&"06"==h.substr(F[0],2)&&"04"==h.substr(F[F.length-1],2)){p=r.oidname(s(h,F[0]));var m=JSON.parse(JSON.stringify(e));m.x509ExtName=p,v=m}for(var S=0;S0){var e=new i({array:this.extensionsArray}),n=new r({explicit:!0,tag:"a3",obj:e});this.asn1Array.push(n)}var s=new i({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertificate,ft.asn1.ASN1Object),ft.asn1.x509.Extension=function(t){ft.asn1.x509.Extension.superclass.constructor.call(this);var e=ft.asn1,i=e.DERObjectIdentifier,n=e.DEROctetString,r=(e.DERBitString,e.DERBoolean),s=e.DERSequence;this.getEncodedHex=function(){var t=new i({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new r),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},r.lang.extend(ft.asn1.x509.Extension,ft.asn1.ASN1Object),ft.asn1.x509.Extension.appendByNameToArray=function(t,e,i){var n=t.toLowerCase(),r=ft.asn1.x509;if("basicconstraints"==n){var s=new r.BasicConstraints(e);i.push(s)}else if("keyusage"==n){s=new r.KeyUsage(e);i.push(s)}else if("crldistributionpoints"==n){s=new r.CRLDistributionPoints(e);i.push(s)}else if("extkeyusage"==n){s=new r.ExtKeyUsage(e);i.push(s)}else if("authoritykeyidentifier"==n){s=new r.AuthorityKeyIdentifier(e);i.push(s)}else if("authorityinfoaccess"==n){s=new r.AuthorityInfoAccess(e);i.push(s)}else if("subjectaltname"==n){s=new r.SubjectAltName(e);i.push(s)}else{if("issueraltname"!=n)throw"unsupported extension name: "+t;s=new r.IssuerAltName(e);i.push(s)}},ft.asn1.x509.KeyUsage=function(t){ft.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Jt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new ft.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var i=t.names,n="000000000",r=0;r-1&&t.push(new ft.asn1.DERInteger({int:this.pathLen}));var e=new ft.asn1.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},r.lang.extend(ft.asn1.x509.BasicConstraints,ft.asn1.x509.Extension),ft.asn1.x509.CRLDistributionPoints=function(t){ft.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ft.asn1,i=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){this.asn1ExtnValue=new e.DERSequence({array:t})},this.setByOneURI=function(t){var e=new i.GeneralNames([{uri:t}]),n=new i.DistributionPointName(e),r=new i.DistributionPoint({dpobj:n});this.setByDPArray([r])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},r.lang.extend(ft.asn1.x509.CRLDistributionPoints,ft.asn1.x509.Extension),ft.asn1.x509.ExtKeyUsage=function(t){ft.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=ft.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var i=0;i0){var t=new i({array:this.aRevokedCert});this.asn1Array.push(t)}var e=new i({array:this.asn1Array});return this.hTLV=e.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize=function(){this.asn1Version=null,this.asn1SignatureAlg=null,this.asn1Issuer=null,this.asn1ThisUpdate=null,this.asn1NextUpdate=null,this.aRevokedCert=new Array},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertList,ft.asn1.ASN1Object),ft.asn1.x509.CRLEntry=function(t){ft.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=ft.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},r.lang.extend(ft.asn1.x509.CRLEntry,ft.asn1.ASN1Object),ft.asn1.x509.X500Name=function(t){ft.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=new Array;var e=ft.asn1,i=e.x509,n=Ht;if(this.setByString=function(t){var e=t.split("/");e.shift();for(var n=[],r=0;r0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},ft.asn1.x509.RDN=function(t){ft.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=new Array,this.addByString=function(t){this.asn1Array.push(new ft.asn1.x509.AttributeTypeAndValue({str:t}))},this.addByMultiValuedString=function(t){for(var e=ft.asn1.x509.RDN.parseString(t),i=0;i0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var a=!1,h=[];for(r=0;n.length>0;r++){s=n.shift();if(!0===a){var u=h.pop();if(s.match(/"$/)){o=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(o),a=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(a=!0)}return h},ft.asn1.x509.AttributeTypeAndValue=function(t){ft.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var e=ft.asn1;this.setByString=function(t){var e=t.match(/^([^=]+)=(.+)$/);if(!e)throw"malformed attrTypeAndValueStr: "+t;this.setByAttrTypeAndValueStr(e[1],e[2])},this.setByAttrTypeAndValueStr=function(t,e){this.typeObj=ft.asn1.x509.OID.atype2obj(t);var i="utf8";"C"==t&&(i="prn"),this.valueObj=this.getValueObj(i,e)},this.getValueObj=function(t,i){if("utf8"==t)return new e.DERUTF8String({str:i});if("prn"==t)return new e.DERPrintableString({str:i});if("tel"==t)return new e.DERTeletexString({str:i});if("ia5"==t)return new e.DERIA5String({str:i});throw"unsupported directory string type: type="+t+" value="+i},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.typeObj,this.valueObj]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&void 0!==t.str&&this.setByString(t.str)},r.lang.extend(ft.asn1.x509.AttributeTypeAndValue,ft.asn1.ASN1Object),ft.asn1.x509.SubjectPublicKeyInfo=function(t){ft.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ft,i=e.asn1,n=i.DERInteger,r=i.DERBitString,s=i.DERObjectIdentifier,o=i.DERSequence,a=i.ASN1Util.newObject,h=i.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof ot){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+e})}}catch(t){}try{if(t instanceof ft.crypto.ECDSA){var i=new s({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ft.crypto.DSA){i=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new h({name:"dsa",asn1params:i});var o=new n({bigint:t.y});this.asn1SubjPKey=new r({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},r.lang.extend(ft.asn1.x509.SubjectPublicKeyInfo,ft.asn1.ASN1Object),ft.asn1.x509.Time=function(t){ft.asn1.x509.Time.superclass.constructor.call(this);var e=ft.asn1,i=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},r.lang.extend(ft.asn1.x509.Time,ft.asn1.ASN1Object),ft.asn1.x509.AlgorithmIdentifier=function(t){ft.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ft.asn1;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw"algorithm not specified";null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var t=[this.asn1Alg];null!==this.asn1Params&&t.push(this.asn1Params);var i=new e.DERSequence({array:t});return this.hTLV=i.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},r.lang.extend(ft.asn1.x509.AlgorithmIdentifier,ft.asn1.ASN1Object),ft.asn1.x509.GeneralName=function(t){ft.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=ft.asn1,n=(i.DERSequence,i.DEROctetString),r=i.DERIA5String,s=i.DERTaggedObject,o=i.ASN1Object,a=i.x509.X500Name,h=Ht;this.explicit=!1,this.setByParam=function(t){var i=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",i=new r({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",i=new r({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",i=new r({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,i=new a({str:t.dn})),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var u=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certissuer param not cert";(f=new Jt).hex=u;var c=f.getIssuerHex();(i=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;u=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certsubj param not cert";(f=new Jt).hex=u;c=f.getSubjectHex();(i=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,g=t.ip,p="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(d=Mt("["+g.split(".").join(",")+"]")).length)throw p}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=Vt(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw p;d=g}i=new n({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},r.lang.extend(ft.asn1.x509.GeneralName,ft.asn1.ASN1Object),ft.asn1.x509.GeneralNames=function(t){ft.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ft.asn1;this.setByParamArray=function(t){for(var i=0;i0&&(e=new n({obj:this.dUnsignedAttrs,tag:"a1",explicit:!1}));var r=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,t,this.dSigAlg,this.dSig];null!=e&&r.push(e);var o=new i.DERSequence({array:r});return this.hTLV=o.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.SignerInfo,ft.asn1.ASN1Object),ft.asn1.cms.EncapsulatedContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.dEContentType=new r({name:"data"}),this.dEContent=null,this.isDetached=!1,this.eContentValueHex=null,this.setContentType=function(t){t.match(/^[0-2][.][0-9.]+$/)?this.dEContentType=new r({oid:t}):this.dEContentType=new r({name:t})},this.setContentValue=function(t){void 0!==t&&("string"==typeof t.hex?this.eContentValueHex=t.hex:"string"==typeof t.str&&(this.eContentValueHex=bt(t.str)))},this.setContentValueHex=function(t){this.eContentValueHex=t},this.setContentValueStr=function(t){this.eContentValueHex=bt(t)},this.getEncodedHex=function(){if("string"!=typeof this.eContentValueHex)throw"eContentValue not yet set";var t=new s({hex:this.eContentValueHex});this.dEContent=new i({obj:t,tag:"a0",explicit:!0});var e=[this.dEContentType];this.isDetached||e.push(this.dEContent);var r=new n({array:e});return this.hTLV=r.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.EncapsulatedContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.ContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.x509;ft.asn1.cms.ContentInfo.superclass.constructor.call(this),this.dContentType=null,this.dContent=null,this.setContentType=function(t){"string"==typeof t&&(this.dContentType=r.OID.name2obj(t))},this.getEncodedHex=function(){var t=new i({obj:this.dContent,tag:"a0",explicit:!0}),e=new n({array:[this.dContentType,t]});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t&&(t.type&&this.setContentType(t.type),t.obj&&t.obj instanceof e.ASN1Object&&(this.dContent=t.obj))},r.lang.extend(ft.asn1.cms.ContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.SignedData=function(t){var e=ft.asn1,i=e.ASN1Object,n=e.DERInteger,r=e.DERSet,s=e.DERSequence,o=e.DERTaggedObject,a=e.cms,h=a.EncapsulatedContentInfo,u=a.SignerInfo,c=a.ContentInfo,l=e.x509.AlgorithmIdentifier;ft.asn1.cms.SignedData.superclass.constructor.call(this),this.dCMSVersion=new n({int:1}),this.dDigestAlgs=null,this.digestAlgNameList=[],this.dEncapContentInfo=new h,this.dCerts=null,this.certificateList=[],this.crlList=[],this.signerInfoList=[new u],this.addCertificatesByPEM=function(t){var e=Ht(t),n=new i;n.hTLV=e,this.certificateList.push(n)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(null==this.dDigestAlgs){for(var t=[],e=0;e0){var h=new r({array:this.certificateList});this.dCerts=new o({obj:h,tag:"a0",explicit:!1})}null!=this.dCerts&&a.push(this.dCerts);var u=new r({array:this.signerInfoList});a.push(u);var c=new s({array:a});return this.hTLV=c.getEncodedHex(),this.hTLV},this.getContentInfo=function(){return this.getEncodedHex(),new c({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},this.getPEM=function(){return Rt(this.getContentInfoEncodedHex(),"CMS")}},r.lang.extend(ft.asn1.cms.SignedData,ft.asn1.ASN1Object),ft.asn1.cms.CMSUtil=new function(){},ft.asn1.cms.CMSUtil.newSignedData=function(t){var e=ft.asn1,i=e.cms,n=i.SignerInfo,r=i.SignedData,s=i.SigningTime,o=i.SigningCertificate,a=i.SigningCertificateV2,h=e.cades.SignaturePolicyIdentifier,u=new r;if(u.dEncapContentInfo.setContentValue(t.content),"object"==typeof t.certs)for(var c=0;c0){var t=new n({array:this.extensionsArray}),e=new r({array:[t]}),i=new n({array:[new a({oid:"1.2.840.113549.1.9.14"}),e]}),h=new o({explicit:!0,tag:"a0",obj:i});this.asn1Array.push(h)}else{h=new o({explicit:!1,tag:"a0",obj:new s});this.asn1Array.push(h)}var u=new n({array:this.asn1Array});return this.hTLV=u.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.csr.CertificationRequestInfo,ft.asn1.ASN1Object),ft.asn1.csr.CSRUtil=new function(){},ft.asn1.csr.CSRUtil.newCSRPEM=function(t){var e=Ut,i=ft.asn1.csr;if(void 0===t.subject)throw"parameter subject undefined";if(void 0===t.sbjpubkey)throw"parameter sbjpubkey undefined";if(void 0===t.sigalg)throw"parameter sigalg undefined";if(void 0===t.sbjprvkey)throw"parameter sbjpubkey undefined";var n=new i.CertificationRequestInfo;if(n.setSubjectByParam(t.subject),n.setSubjectPublicKeyByGetKey(t.sbjpubkey),void 0!==t.ext&&void 0!==t.ext.length)for(var r=0;rr)throw"key is too short for SigAlg: keylen="+i+","+e;for(var s="0001",o="00"+n,a="",h=r-s.length-o.length,u=0;u=0)return!1;if(i.compareTo(x.ONE)<0||i.compareTo(r)>=0)return!1;var o=i.modInverse(r),a=t.multiply(o).mod(r),h=e.multiply(o).mod(r);return s.multiply(a).add(n.multiply(h)).getX().toBigInteger().mod(r).equals(e)},this.serializeSig=function(t,e){var i=t.toByteArraySigned(),n=e.toByteArraySigned(),r=[];return r.push(2),r.push(i.length),(r=r.concat(i)).push(2),r.push(n.length),(r=r.concat(n)).unshift(r.length),r.unshift(48),r},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:x.fromByteArrayUnsigned(i),s:x.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:x.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:x.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[2,0],"06"),i=o(t,0,[1],"04");try{n=o(t,0,[3,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#1/5 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{o(t,0,[1,0],"06"),e=o(t,0,[1,1],"06"),i=o(t,0,[2,0,1],"04");try{n=o(t,0,[2,0,2,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#8 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){var e,i,n=pt,r=ft.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{s(t,0,[0,0],"06"),e=s(t,0,[0,1],"06"),i=s(t,0,[1],"03").substr(2)}catch(t){throw"malformed PKCS#8 ECC public key"}if(this.curveName=r(e),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,e){5!==e&&(e=6);var i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{i=o(t,0,[0,e,0,1],"06"),n=o(t,0,[0,e,1],"03").substr(2)}catch(t){throw"malformed X.509 certificate ECC public key"}if(this.curveName=s(i),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ft.crypto.ECDSA.parseSigHex=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new x(e.r,16),s:new x(e.s,16)}},ft.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=pt,i=e.getChildIdx,n=e.getV;if("30"!=t.substr(0,2))throw"signature is not a ASN.1 sequence";var r=i(t,0);if(2!=r.length)throw"number of signature ASN.1 sequence elements seem wrong";var s=r[0],o=r[1];if("02"!=t.substr(s,2))throw"1st item of sequene of signature is not ASN.1 integer";if("02"!=t.substr(o,2))throw"2nd item of sequene of signature is not ASN.1 integer";return{r:n(t,s),s:n(t,o)}},ft.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t),i=e.r,n=e.s;if("00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),i.length%32==30&&(i="00"+i),n.length%32==30&&(n="00"+n),i.length%32!=0)throw"unknown ECDSA sig r length error";if(n.length%32!=0)throw"unknown ECDSA sig s length error";return i+n},ft.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var e=t.substr(0,t.length/2),i=t.substr(t.length/2);return ft.crypto.ECDSA.hexRSSigToASN1Sig(e,i)},ft.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var i=new x(t,16),n=new x(e,16);return ft.crypto.ECDSA.biRSSigToASN1Sig(i,n)},ft.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var i=ft.asn1,n=new i.DERInteger({bigint:t}),r=new i.DERInteger({bigint:e});return new i.DERSequence({array:[n,r]}).getEncodedHex()},ft.crypto.ECDSA.getName=function(t){return"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040022"===t?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":null},void 0!==ft&&ft||(ft={}),void 0!==ft.crypto&&ft.crypto||(ft.crypto={}),ft.crypto.ECParameterDB=new function(){var t={},e={};function i(t){return new x(t,16)}this.getByName=function(i){var n=i;if(void 0!==e[n]&&(n=e[i]),void 0!==t[n])return t[n];throw"unregistered EC curve name: "+n},this.regist=function(n,r,s,o,a,h,u,c,l,f,d,g){t[n]={};var p=i(s),y=i(o),v=i(a),m=i(h),S=i(u),F=new ct(p,y,v),E=F.decodePointHex("04"+c+l);t[n].name=n,t[n].keylen=r,t[n].curve=F,t[n].G=E,t[n].n=m,t[n].h=S,t[n].oid=d,t[n].info=g;for(var w=0;w1?new x(n,16):null,u=new x(r,16),this.setPrivate(s,o,a,h,u)},this.setPublic=function(t,e,i,n){this.isPublic=!0,this.p=t,this.q=e,this.g=i,this.y=n,this.x=null},this.setPublicHex=function(t,e,i,n){var r,s,o,a;r=new x(t,16),s=new x(e,16),o=new x(i,16),a=new x(n,16),this.setPublic(r,s,o,a)},this.signWithMessageHash=function(t){var e=this.p,i=this.q,n=this.g,r=(this.y,this.x),s=ft.crypto.Util.getRandomBigIntegerMinToMax(x.ONE.add(x.ONE),i.subtract(x.ONE)),o=new x(t.substr(0,i.bitLength()/4),16),a=n.modPow(s,e).mod(i),h=s.modInverse(i).multiply(o.add(r.multiply(a))).mod(i);return ft.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:a}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var i=this.p,n=this.q,r=this.g,s=this.y,o=this.parseASN1Signature(e),a=o[0],h=o[1],u=new x(t.substr(0,n.bitLength()/4),16);if(x.ZERO.compareTo(a)>0||a.compareTo(n)>0)throw"invalid DSA signature";if(x.ZERO.compareTo(h)>=0||h.compareTo(n)>0)throw"invalid DSA signature";var c=h.modInverse(n),l=u.multiply(c).mod(n),f=a.multiply(c).mod(n);return 0==r.modPow(l,i).multiply(s.modPow(f,i)).mod(i).mod(n).compareTo(a)},this.parseASN1Signature=function(t){try{return[new x(pt.getVbyList(t,0,[0],"02"),16),new x(pt.getVbyList(t,0,[1],"02"),16)]}catch(t){throw"malformed ASN.1 DSA signature"}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r,s,o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{e=a(t,0,[1],"02"),i=a(t,0,[2],"02"),n=a(t,0,[3],"02"),r=a(t,0,[4],"02"),s=a(t,0,[5],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#1/5 plain DSA private key"}this.setPrivateHex(e,i,n,r,s)},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[1,1,0],"02"),i=o(t,0,[1,1,1],"02"),n=o(t,0,[1,1,2],"02"),r=o(t,0,[2,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 plain DSA private key"}this.setPrivateHex(e,i,n,null,r)},this.readPKCS8PubKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[0,1,0],"02"),i=o(t,0,[0,1,1],"02"),n=o(t,0,[0,1,2],"02"),r=o(t,0,[1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 DSA public key"}this.setPublicHex(e,i,n,r)},this.readCertPubKeyHex=function(t,e){var i,n,r,s;5!==e&&(e=6);var o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{i=a(t,0,[0,e,0,1,0],"02"),n=a(t,0,[0,e,0,1,1],"02"),r=a(t,0,[0,e,0,1,2],"02"),s=a(t,0,[0,e,1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed X.509 certificate DSA public key"}this.setPublicHex(i,n,r,s)}};var Ut=function(){var t=function(t,i,n){return e(y.AES,t,i,n)},e=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=r;var h=t.decrypt(a,s,{iv:o});return y.enc.Hex.stringify(h)},i=function(t,e,i){return n(y.AES,t,e,i)},n=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a=t.encrypt(r,s,{iv:o}),h=y.enc.Hex.parse(a.toString());return y.enc.Base64.stringify(h)},r={"AES-256-CBC":{proc:t,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,i,n){return e(y.TripleDES,t,i,n)},eproc:function(t,e,i){return n(y.TripleDES,t,e,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,i,n){return e(y.DES,t,i,n)},eproc:function(t,e,i){return n(y.DES,t,e,i)},keylen:8,ivlen:8}},s=function(t){var e={},i=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(e.cipher=i[1],e.ivsalt=i[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var r=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(r=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(r=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=r&&-1!=o){var a=t.substring(r+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,i){for(var n=i.substring(0,16),s=y.enc.Hex.parse(n),o=y.enc.Utf8.parse(e),a=r[t].keylen+r[t].ivlen,h="",u=null;;){var c=y.algo.MD5.create();if(null!=u&&c.update(u),c.update(o),c.update(s),u=c.finalize(),(h+=y.enc.Hex.stringify(u)).length>=2*a)break}var l={};return l.keyhex=h.substr(0,2*r[t].keylen),l.ivhex=h.substr(2*r[t].keylen,2*r[t].ivlen),l},a=function(t,e,i,n){var s=y.enc.Base64.parse(t),o=y.enc.Hex.stringify(s);return(0,r[e].proc)(o,i,n)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,i){return o(t,e,i)},decryptKeyB64:function(t,e,i,n){return a(t,e,i,n)},getDecryptedKeyHex:function(t,e){var i=s(t),n=(i.type,i.cipher),r=i.ivsalt,h=i.data,u=o(n,e,r).keyhex;return a(h,n,u,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,i,n,s){var a="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===r[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==s&&null!=s||(s=function(t){var e=y.lib.WordArray.random(t);return y.enc.Hex.stringify(e)}(r[n].ivlen).toUpperCase());var h=function(t,e,i,n){return(0,r[e].eproc)(t,i,n)}(e,n,o(n,i,s).keyhex,s);a="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+n+","+s+"\r\n",a+="\r\n",a+=h.replace(/(.{64})/g,"$1\r\n"),a+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={},s=i(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;r.ciphertext=n(t,s[1]);var o=i(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=i(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var h=i(t,a[1]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length;if("2a864886f70d0307"!=n(t,h[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(t,h[1]);var u=i(t,a[0]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length;if("2a864886f70d01050c"!=n(t,u[0]))throw"this only supports pkcs5PBKDF2";var c=i(t,u[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;r.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{r.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return r},getPBKDF2KeyHexFromParam:function(t,e){var i=y.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,r=y.PBKDF2(e,i,{keySize:6,iterations:n});return y.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var i=Ht(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=Ut.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=y.enc.Hex.parse(n.ciphertext);var o=y.enc.Hex.parse(r),a=y.enc.Hex.parse(n.encryptionSchemeIV),h=y.TripleDES.decrypt(s,o,{iv:a});return y.enc.Hex.stringify(h)},getKeyFromEncryptedPKCS8PEM:function(t,e){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var s=i(t,0);if(3!=s.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(s[1],2))throw"malformed PKCS8 private key(code:003)";var o=i(t,s[1]);if(2!=o.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(o[0],2))throw"malformed PKCS8 private key(code:005)";if(r.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(r.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw"malformed PKCS8 private key(code:006)";return r.keyidx=e.getVidx(t,s[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Ht(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,i=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==i.algoid)e=new ot;else if("2a8648ce380401"==i.algoid)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";e=new ft.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,i=pt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===i)e=new ot;else if("2a8648ce380401"===i)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";e=new ft.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=i(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(r.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return r.e=n(t,s[1]),r},parsePublicPKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null},s=i(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=i(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?r.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(r.algparam={},r.algparam.p=e.getVbyList(t,a[1],[0],"02"),r.algparam.q=e.getVbyList(t,a[1],[1],"02"),r.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(t,s[1]).substr(2),r}}}();Ut.getKey=function(t,e,i){var n=(y=pt).getChildIdx,r=(y.getV,y.getVbyList),s=ft.crypto,o=s.ECDSA,a=s.DSA,h=ot,u=Ht,c=Ut;if(void 0!==h&&t instanceof h)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(t.n,t.e),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(D=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(D=new h).setPrivate(t.n,t.e,t.d),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(D=new a).setPublic(t.p,t.q,t.g,t.y),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(D=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(xt(t.n),xt(t.e)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(D=new h).setPrivateEx(xt(t.n),xt(t.e),xt(t.d),xt(t.p),xt(t.q),xt(t.dp),xt(t.dq),xt(t.qi)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(D=new h).setPrivate(xt(t.n),xt(t.e),xt(t.d)),D;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);return C.setPublicKeyHex(f),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);var d=("0000000000"+xt(t.d)).slice(-l);return C.setPublicKeyHex(f),C.setPrivateKeyHex(d),C}if("pkcs5prv"===i){var g,p=t,y=pt;if(9===(g=n(p,0)).length)(D=new h).readPKCS5PrvKeyHex(p);else if(6===g.length)(D=new a).readPKCS5PrvKeyHex(p);else{if(!(g.length>2&&"04"===p.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(D=new o).readPKCS5PrvKeyHex(p)}return D}if("pkcs8prv"===i)return D=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===i)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===i)return Jt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Jt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=Ht(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=u(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=r(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),F=r(R,0,[2],"02"),E=r(R,0,[3],"02"),w=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(E,16),new x(w,16),new x(b,16)),D}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var A=c.getDecryptedKeyHex(t,e),I=new ot;return I.readPKCS5PrvKeyHex(A),I}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var C,D=r(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),T=r(R,0,[2,0],"06"),P=r(R,0,[3,0],"03").substr(2);if(void 0===ft.crypto.OID.oidhex2name[T])throw"undefined OID(hex) in KJUR.crypto.OID: "+T;return(C=new o({curve:ft.crypto.OID.oidhex2name[T]})).setPublicKeyHex(P),C.setPrivateKeyHex(D),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;S=r(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),F=r(R,0,[2],"02"),E=r(R,0,[3],"02"),w=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(E,16),new x(w,16),new x(b,16)),D}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw"not supported argument"},Ut.generateKeypair=function(t,e){if("RSA"==t){var i=e;(o=new ot).generate(i,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new ot,r=o.n.toString(16),s=o.e.toString(16);return n.setPublic(r,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,h=e,u=new ft.crypto.ECDSA({curve:h}).generateKeyPairHex();return(o=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),o.setPrivateKeyHex(u.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Ut.getPEM=function(t,e,i,n,r,s){var o=ft,a=o.asn1,h=a.DERObjectIdentifier,u=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,f=o.crypto,d=f.DSA,g=f.ECDSA,p=ot;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function S(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==p&&t instanceof p||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Rt(x=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=v(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===i||null==i)&&1==t.isPrivate){var F=new h({name:t.curveName}).getEncodedHex(),E=m(t).getEncodedHex(),w="";return w+=Rt(F,"EC PARAMETERS"),w+=Rt(E,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=S(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==i&&null!=i&&1==t.isPrivate){var x=v(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==i&&null!=i&&1==t.isPrivate){x=m(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==i&&null!=i&&1==t.isPrivate){x=S(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",x,i,n,s)}var b=function(t,e){var i=A(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},A=function(t,e){var i=y.lib.WordArray.random(8),n=y.lib.WordArray.random(8),r=y.PBKDF2(e,i,{keySize:6,iterations:100}),s=y.enc.Hex.parse(t),o=y.TripleDES.encrypt(s,r,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=y.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=y.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=p&&t instanceof p&&1==t.isPrivate){var I=v(t).getEncodedHex();x=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){I=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){I=new u({bigint:t.x}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=b(x,i),"ENCRYPTED PRIVATE KEY")}throw"unsupported object nor format"},Ut.getKeyFromCSRPEM=function(t){var e=Ht(t,"CERTIFICATE REQUEST");return Ut.getKeyFromCSRHex(e)},Ut.getKeyFromCSRHex=function(t){var e=Ut.parseCSRHex(t);return Ut.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Ut.parseCSRHex=function(t){var e=pt,i=e.getChildIdx,n=e.getTLV,r={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=i(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=i(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(s,a[2]),r},Ut.getJWKFromKey=function(t){var e={};if(t instanceof ot&&t.isPrivate)return e.kty="RSA",e.n=wt(t.n.toString(16)),e.e=wt(t.e.toString(16)),e.d=wt(t.d.toString(16)),e.p=wt(t.p.toString(16)),e.q=wt(t.q.toString(16)),e.dp=wt(t.dmp1.toString(16)),e.dq=wt(t.dmq1.toString(16)),e.qi=wt(t.coeff.toString(16)),e;if(t instanceof ot&&t.isPublic)return e.kty="RSA",e.n=wt(t.n.toString(16)),e.e=wt(t.e.toString(16)),e;if(t instanceof ft.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=wt(i.x),e.y=wt(i.y),e.d=wt(t.prvKeyHex),e}if(t instanceof ft.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=wt(i.x),e.y=wt(i.y),e}throw"not supported key object"},ot.getPosArrayOfChildrenFromHex=function(t){return pt.getChildIdx(t,0)},ot.getHexValueArrayOfChildrenFromHex=function(t){var e,i=pt.getV,n=i(t,(e=ot.getPosArrayOfChildrenFromHex(t))[0]),r=i(t,e[1]),s=i(t,e[2]),o=i(t,e[3]),a=i(t,e[4]),h=i(t,e[5]),u=i(t,e[6]),c=i(t,e[7]),l=i(t,e[8]);return(e=new Array).push(n,r,s,o,a,h,u,c,l),e},ot.prototype.readPrivateKeyFromPEMString=function(t){var e=Ht(t),i=ot.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},ot.prototype.readPKCS5PrvKeyHex=function(t){var e=ot.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},ot.prototype.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s,o,a,h,u=pt,c=u.getVbyList;if(!1===u.isASN1HEX(t))throw"not ASN.1 hex string";try{e=c(t,0,[2,0,1],"02"),i=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),r=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw"malformed PKCS#8 plain RSA private key"}this.setPrivateEx(e,i,n,r,s,o,a,h)},ot.prototype.readPKCS5PubKeyHex=function(t){var e=pt,i=e.getV;if(!1===e.isASN1HEX(t))throw"keyHex is not ASN.1 hex string";var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw"wrong hex for PKCS#5 public key";var r=i(t,n[0]),s=i(t,n[1]);this.setPublic(r,s)},ot.prototype.readPKCS8PubKeyHex=function(t){var e=pt;if(!1===e.isASN1HEX(t))throw"not ASN.1 hex string";if("06092a864886f70d010101"!==e.getTLVbyList(t,0,[0,0]))throw"not PKCS8 RSA public key";var i=e.getTLVbyList(t,0,[1,0]);this.readPKCS5PubKeyHex(i)},ot.prototype.readCertPubKeyHex=function(t,e){var i,n;(i=new Jt).readCertHex(t),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var qt=new RegExp("");function zt(t,e){for(var i="",n=e/4-t.length,r=0;r>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function Yt(t){for(var e in ft.crypto.Util.DIGESTINFOHEAD){var i=ft.crypto.Util.DIGESTINFOHEAD[e],n=i.length;if(t.substring(0,n)==i)return[e,t.substring(n)]}return[]}function Jt(){var t=pt,e=t.getChildIdx,i=t.getV,n=t.getTLV,r=t.getVbyList,s=t.getTLVbyList,o=t.getIdxbyList,a=t.getVidx,h=t.oidname,u=Jt,c=Ht;this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){return null===this.hex||0!==this.version?this.version:"a003020102"!==s(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return r(this.hex,0,[0,1+this.foffset],"02")},this.getSignatureAlgorithmField=function(){return h(r(this.hex,0,[0,2+this.foffset,0],"06"))},this.getIssuerHex=function(){return s(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return u.hex2dn(this.getIssuerHex())},this.getSubjectHex=function(){return s(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return u.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=r(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=r(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return t.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return o(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return o(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Ut.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){return h(r(this.hex,0,[1,0],"06"))},this.getSignatureValueHex=function(){return r(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmName(),i=this.getSignatureValueHex(),n=s(this.hex,0,[0],"30"),r=new ft.crypto.Signature({alg:e});return r.init(t),r.updateHex(n),r.verify(i)},this.parseExt=function(){if(3!==this.version)return-1;var i=o(this.hex,0,[0,7,0],"30"),n=e(this.hex,i);this.aExtInfo=new Array;for(var s=0;s0&&(u=new Array(i),(new nt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=It(h(Ct("\0\0\0\0\0\0\0\0"+r+u))),l=[];for(n=0;n>8*a-o&255;for(g[0]&=~p,n=0;nthis.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;var r=n[0];return n[1]==function(t){return ft.crypto.Util.hashString(t,r)}(t)},ot.prototype.verifyWithMessageHash=function(t,e){var i=rt(e=(e=e.replace(qt,"")).replace(/[ \n]+/g,""),16);if(i.bitLength()>this.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;n[0];return n[1]==t},ot.prototype.verifyPSS=function(t,e,i,n){var r,s=(r=Ct(t),ft.crypto.Util.hashHex(r,i));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(s,e,i,n)},ot.prototype.verifyWithMessageHashPSS=function(t,e,i,n){var r=new x(e,16);if(r.bitLength()>this.n.bitLength())return!1;var s,o=function(t){return ft.crypto.Util.hashHex(t,i)},a=It(t),h=a.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===n||void 0===n)n=h;else if(-2===n)n=c-h-2;else if(n<-2)throw"invalid salt length";if(c>8*c-u&255;if(0!=(f.charCodeAt(0)&g))throw"bits beyond keysize not zero";var p=Gt(d,f.length,o),y=[];for(s=0;s0)&&-1==(":"+i.join(":")+":").indexOf(":"+p+":"))throw"algorithm '"+p+"' not accepted in the list";if("none"!=p&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Ut.getKey(e)),!("RS"!=y&&"PS"!=y||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==y&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===s.jwsalg2sigalg[g.alg])throw"unsupported alg name: "+p;if("none"==(v=s.jwsalg2sigalg[p]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var S,F=null;try{F=h.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(F)}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(d)},ft.jws.JWS.parse=function(t){var e,i,n,r=t.split("."),s={};if(2!=r.length&&3!=r.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=r[0],i=r[1],3==r.length&&(n=r[2]),s.headerObj=ft.jws.JWS.readSafeJSONString(gt(e)),s.payloadObj=ft.jws.JWS.readSafeJSONString(gt(i)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=gt(i):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==n&&(s.sigHex=xt(n)),s},ft.jws.JWS.verifyJWT=function(t,e,i){var n=ft.jws,r=n.JWS,s=r.readSafeJSONString,o=r.inArray,a=r.includedArray,h=t.split("."),u=h[0],c=h[1],l=(xt(h[2]),s(gt(u))),f=s(gt(c));if(void 0===l.alg)return!1;if(void 0===i.alg)throw"acceptField.alg shall be specified";if(!o(l.alg,i.alg))return!1;if(void 0!==f.iss&&"object"==typeof i.iss&&!o(f.iss,i.iss))return!1;if(void 0!==f.sub&&"object"==typeof i.sub&&!o(f.sub,i.sub))return!1;if(void 0!==f.aud&&"object"==typeof i.aud)if("string"==typeof f.aud){if(!o(f.aud,i.aud))return!1}else if("object"==typeof f.aud&&!a(f.aud,i.aud))return!1;var d=n.IntDate.getNow();return void 0!==i.verifyAt&&"number"==typeof i.verifyAt&&(d=i.verifyAt),void 0!==i.gracePeriod&&"number"==typeof i.gracePeriod||(i.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+i.gracePeriodr&&this.aHeader.pop(),this.aSignature.length>r&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignatures=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},e.SecureRandom=nt,e.rng_seed_time=Z,e.BigInteger=x,e.RSAKey=ot,e.ECDSA=ft.crypto.ECDSA,e.DSA=ft.crypto.DSA,e.Signature=ft.crypto.Signature,e.MessageDigest=ft.crypto.MessageDigest,e.Mac=ft.crypto.Mac,e.Cipher=ft.crypto.Cipher,e.KEYUTIL=Ut,e.ASN1HEX=pt,e.X509=Jt,e.CryptoJS=y,e.b64tohex=E,e.b64toBA=w,e.stoBA=yt,e.BAtos=vt,e.BAtohex=mt,e.stohex=St,e.stob64=function(t){return F(St(t))},e.stob64u=function(t){return Ft(F(St(t)))},e.b64utos=function(t){return vt(w(Et(t)))},e.b64tob64u=Ft,e.b64utob64=Et,e.hex2b64=F,e.hextob64u=wt,e.b64utohex=xt,e.utf8tob64u=dt,e.b64utoutf8=gt,e.utf8tob64=function(t){return F(Ot(Kt(t)))},e.b64toutf8=function(t){return decodeURIComponent(jt(E(t)))},e.utf8tohex=bt,e.hextoutf8=At,e.hextorstr=It,e.rstrtohex=Ct,e.hextob64=Dt,e.hextob64nl=Tt,e.b64nltohex=Pt,e.hextopem=Rt,e.pemtohex=Ht,e.hextoArrayBuffer=function(t){if(t.length%2!=0)throw"input is not even length";if(null==t.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var e=new ArrayBuffer(t.length/2),i=new DataView(e),n=0;ne.length&&(i=e.length);for(var n=0;n300)throw new r(`Failed to fetch ${t}. Response=${s}`,i.status);try{return JSON.parse(s)}catch(e){if(""!==s)return s;throw new r(`Invalid response while trying to fetch ${t}. Response=${s}`,i.status,e)}}}},function(t,e,i){const n=i(5),r=i(3),s=i(16),o=i(18),a=i(20),h=i(1),u=i(2),c=i(0);t.exports=class{constructor({popup:t=new s,iframe:e=new o,openIdConfigResource:i=new a,utils:h,requestHandler:u=new r,w:l=window,url:f=URL}={}){this.popup=t,this.iframe=e,this.openIdConfigResource=i,this.URL=f,this.utils=h,h||(this.utils=new n({openIdConfigResource:this.openIdConfigResource,url:this.URL,popup:this.popup,jsrsasign:c})),this.request=u.request,this.window=l,this.initialized=!1}async init({clientId:t,discoveryEndpoint:e,popup:i={height:.8*window.screen.height,width:400}}){if(!t)throw new u(h.MISSING_CLIENT_ID);try{new this.URL(e)}catch(t){throw new u(h.INVALID_DISCOVERY_ENDPOINT)}await this.openIdConfigResource.init({discoveryEndpoint:e,requestHandler:this.request}),this.popup.init(i),this.clientId=t,this.initialized=!0}async signin(){this._validateInitalize();const t=this.openIdConfigResource.getAuthorizationEndpoint();return this.utils.performOAuthFlowAndGetTokens({origin:this.window.origin,clientId:this.clientId,endpoint:t})}async silentSignin(){this._validateInitalize();const t=this.openIdConfigResource.getAuthorizationEndpoint(),{codeVerifier:e,nonce:i,state:n,url:r}=this.utils.getAuthParamsAndUrl({clientId:this.clientId,origin:this.window.origin,prompt:h.PROMPT,endpoint:t});let s;this.iframe.open(r);try{s=await this.iframe.waitForMessage({messageType:"authorization_response"})}finally{this.iframe.remove()}this.utils.verifyMessage({message:s,state:n});let o=s.data.code;return await this.utils.retrieveTokens({clientId:this.clientId,authCode:o,codeVerifier:e,nonce:i,openId:this.openIdConfigResource,windowOrigin:this.window.origin})}async getUserInfo(t){if(this._validateInitalize(),"string"!=typeof t)throw new u(h.INVALID_ACCESS_TOKEN);return await this.request(this.openIdConfigResource.getUserInfoEndpoint(),{headers:{Authorization:"Bearer "+t}})}async changePassword(t){let e;if(this._validateInitalize(),!t)throw new u(h.MISSING_ID_TOKEN_PAYLOAD);if("string"==typeof t)throw new u(h.INVALID_ID_TOKEN_PAYLOAD);if(!(t.identities&&t.identities[0]&&t.identities[0].id))throw new u(h.INVALID_ID_TOKEN_PAYLOAD);if("cloud_directory"!==t.identities[0].provider)throw new u(h.NOT_CD_USER);e=t.identities[0].id;const i=this.openIdConfigResource.getIssuer()+h.CHANGE_PASSWORD;return this.utils.performOAuthFlowAndGetTokens({userId:e,origin:this.window.origin,clientId:this.clientId,endpoint:i})}async changeDetails(t){if(!t)throw new u(h.MISSING_TOKENS);if(!t.accessToken&&"string"!=typeof t.accessToken)throw new u(h.MISSING_ACCESS_TOKEN);if(!t.idToken&&"string"!=typeof t.idToken)throw new u(h.MISSING_ID_TOKEN);const e=this.openIdConfigResource.getIssuer()+h.GENERATE_CODE,i=await this.request(e,{headers:{Authorization:"Bearer "+t.accessToken+" "+t.idToken}}),n=this.openIdConfigResource.getIssuer()+h.CHANGE_DETAILS;return this.utils.performOAuthFlowAndGetTokens({origin:this.window.origin,clientId:this.clientId,endpoint:n,changeDetailsCode:i})}_validateInitalize(){if(!this.initialized)throw new u(h.FAIL_TO_INITIALIZE)}}},function(t,e,i){i(0);const n=i(2),r=i(11),s=i(3),o=i(14),a=i(1);t.exports=class{constructor({requestHandler:t=new s,tokenValidator:e=new o,url:i=URL,openIdConfigResource:n,popup:r,jsrsasign:a=a}={}){this.URL=i,this.request=t.request,this.tokenValidator=e,this.openIdConfigResource=n,this.popup=r,this.rs=a}buildParams(t){return Object.keys(t).map((function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])})).join("&")}getRandomString(t){return this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(t/2)}sha256(t){return this.rs.KJUR.crypto.Util.sha256(t)}getPKCEFields(){const t=this.getRandomString(a.CODE_VERIFIER_LENGTH);return{codeVerifier:t,codeChallenge:this.sha256(t),state:this.getRandomString(a.STATE_LENGTH),nonce:this.getRandomString(a.NONCE_LENGTH)}}getAuthParamsAndUrl({clientId:t,origin:e,prompt:i,endpoint:n,userId:r,changeDetailsCode:s}){const{codeVerifier:o,codeChallenge:h,state:u,nonce:c}=this.getPKCEFields();let l={client_id:t,response_type:a.RESPONSE_TYPE,state:this.rs.stob64(u),code_challenge:this.rs.stob64(h),code_challenge_method:a.CHALLENGE_METHOD,redirect_uri:e,response_mode:a.RESPONSE_MODE,nonce:c,scope:a.SCOPE};return i&&(l.prompt=i),r&&(l.user_id=r),s&&(l.code=s),{codeVerifier:o,nonce:c,state:u,url:n+"?"+this.buildParams(l)}}async performOAuthFlowAndGetTokens({userId:t,origin:e,clientId:i,endpoint:n,changeDetailsCode:r}){const{codeVerifier:s,state:o,nonce:a,url:h}=this.getAuthParamsAndUrl({userId:t,origin:e,clientId:i,endpoint:n,changeDetailsCode:r});this.popup.open(),this.popup.navigate(h);const u=await this.popup.waitForMessage({messageType:"authorization_response"});this.popup.close(),this.verifyMessage({message:u,state:o});let c=u.data.code;return await this.retrieveTokens({clientId:i,authCode:c,codeVerifier:s,nonce:a,windowOrigin:e})}verifyMessage({message:t,state:e}){if(t.data.error||t.data.error_description)throw new r({description:t.data.error_description,error:t.data.error});if(this.rs.b64utos(t.data.state)!==e)throw new n(a.INVALID_STATE);if(t.origin!==new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin)throw new n(a.INVALID_ORIGIN)}async retrieveTokens({clientId:t,authCode:e,nonce:i,codeVerifier:n,windowOrigin:r}){let s=this.openIdConfigResource.getIssuer(),o={grant_type:"authorization_code",redirect_uri:r,code:e,code_verifier:n};const a=this.buildParams(o),h=this.openIdConfigResource.getTokenEndpoint(),u=await this.request(h,{method:"POST",headers:{Authorization:"Basic "+this.rs.stob64(`${t}:${n}`),"Content-Type":"application/x-www-form-urlencoded"},body:a}),c=await this.openIdConfigResource.getPublicKeys(),l=this.tokenValidator.decodeAndValidate({token:u.access_token,publicKeys:c,issuer:s,clientId:t,nonce:i}),f=this.tokenValidator.decodeAndValidate({token:u.id_token,publicKeys:c,issuer:s,clientId:t,nonce:i});return{accessToken:u.access_token,accessTokenPayload:l,idToken:u.id_token,idTokenPayload:f}}}},function(t,e,i){"use strict";(function(t){ -/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */ -var n=i(8),r=i(9),s=i(10);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return A(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function A(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return E(this,t,e,i);case"latin1":case"binary":return w(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function B(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||N(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(7))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e,i){const n=i(1),r=i(15);t.exports=class{constructor({jwt:t=i(0)}={}){this.jwt=t}decodeAndValidate({token:t,publicKeys:e,issuer:i,clientId:s,nonce:o}){const a=Math.floor(Date.now()/1e3),h=t.split(".");if(3!==h.length)throw new r(`Invalid JWT token. Got only ${h.length} parts.`);const u=this.jwt.KJUR.jws.JWS.parse(t);if(!u.headerObj)throw new r(n.INVALID_TOKEN);const c=u.headerObj.kid,l=this.getPublicKey(e.keys,c),f=this.jwt.KEYUTIL.getKey(l);if(!this.jwt.KJUR.jws.JWS.verify(t,f,{alg:[n.TOKEN_ALG]}))throw new r(n.INVALID_SIGNATURE);if(u.payloadObj.exp{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(21);t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t);const i={"x-filter-type":`spa:v${n.version}`};this.publicKeys=e(this.getJwksEndpoint(),{headers:i})}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}},function(t){t.exports=JSON.parse('{"name":"ibmcloud-appid-js","version":"0.0.2","description":"IBM Cloud App ID SDK for Single Page Applications","scripts":{"build":"webpack","test":"mocha","coverage":"nyc --reporter=lcov mocha","docs":"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git"},"main":"dist/appid.umd.min.js","nyc":{"all":true,"include":["src/*.js"],"exclude":["**/PopupController.js","**/IFrameController.js","**/OpenIDConfigurationResource.js","**/constants.js"]},"dependencies":{"jsrsasign":"^8.0.12"},"devDependencies":{"node-fetch":"^2.6.0","@babel/cli":"^7.0.0","@babel/core":"^7.5.5","@babel/plugin-transform-runtime":"^7.5.5","@babel/preset-env":"^7.5.5","babel-cli":"^7.0.0-beta.3","chai":"^4.2.0","coveralls":"^3.0.6","gulp-babel":"^8.0.0","mocha":"^6.2.0","nyc":"^14.1.1","webpack":"^4.39.1","webpack-cli":"^3.3.6","docdash":"^1.1.1","jsdoc":"^3.6.3"}}')}])})); \ No newline at end of file +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["AppID"] = factory(); + else + root["AppID"] = factory(); +})(window, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./node_modules/base64-js/index.js": +/*!*****************************************!*\ + !*** ./node_modules/base64-js/index.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/base64-js/index.js?"); + +/***/ }), + +/***/ "./node_modules/buffer/index.js": +/*!**************************************!*\ + !*** ./node_modules/buffer/index.js ***! + \**************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("/* WEBPACK VAR INJECTION */(function(global) {/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n\n\nvar base64 = __webpack_require__(/*! base64-js */ \"./node_modules/base64-js/index.js\")\nvar ieee754 = __webpack_require__(/*! ieee754 */ \"./node_modules/ieee754/index.js\")\nvar isArray = __webpack_require__(/*! isarray */ \"./node_modules/isarray/index.js\")\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://AppID/./node_modules/buffer/index.js?"); + +/***/ }), + +/***/ "./node_modules/ieee754/index.js": +/*!***************************************!*\ + !*** ./node_modules/ieee754/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/ieee754/index.js?"); + +/***/ }), + +/***/ "./node_modules/isarray/index.js": +/*!***************************************!*\ + !*** ./node_modules/isarray/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n\n\n//# sourceURL=webpack://AppID/./node_modules/isarray/index.js?"); + +/***/ }), + +/***/ "./node_modules/jsrsasign/lib/jsrsasign.js": +/*!*************************************************!*\ + !*** ./node_modules/jsrsasign/lib/jsrsasign.js ***! + \*************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\nvar navigator = {};\nnavigator.userAgent = false;\n\nvar window = {};\n/*\n * jsrsasign(all) 8.0.12 (2018-04-22) (c) 2010-2018 Kenji Urushima | kjur.github.com/jsrsasign/license\n */\n\n/*!\nCopyright (c) 2011, Yahoo! Inc. All rights reserved.\nCode licensed under the BSD License:\nhttp://developer.yahoo.com/yui/license.html\nversion: 2.9.0\n*/\nif(YAHOO===undefined){var YAHOO={}}YAHOO.lang={extend:function(g,h,f){if(!h||!g){throw new Error(\"YAHOO.lang.extend failed, please check that all dependencies are included.\")}var d=function(){};d.prototype=h.prototype;g.prototype=new d();g.prototype.constructor=g;g.superclass=h.prototype;if(h.prototype.constructor==Object.prototype.constructor){h.prototype.constructor=h}if(f){var b;for(b in f){g.prototype[b]=f[b]}var e=function(){},c=[\"toString\",\"valueOf\"];try{if(/MSIE/.test(navigator.userAgent)){e=function(j,i){for(b=0;b>>2]>>>(24-(r%4)*8))&255;q[(n+r)>>>2]|=o<<(24-((n+r)%4)*8)}}else{for(var r=0;r>>2]=p[r>>>2]}}this.sigBytes+=s;return this},clamp:function(){var o=this.words;var n=this.sigBytes;o[n>>>2]&=4294967295<<(32-(n%4)*8);o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);n.words=this.words.slice(0);return n},random:function(p){var o=[];for(var n=0;n>>2]>>>(24-(n%4)*8))&255;q.push((s>>>4).toString(16));q.push((s&15).toString(16))}return q.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>3]|=parseInt(p.substr(o,2),16)<<(24-(o%8)*4)}return new l.init(q,n/2)}};var d=m.Latin1={stringify:function(q){var r=q.words;var p=q.sigBytes;var n=[];for(var o=0;o>>2]>>>(24-(o%4)*8))&255;n.push(String.fromCharCode(s))}return n.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>2]|=(p.charCodeAt(o)&255)<<(24-(o%4)*8)}return new l.init(q,n)}};var c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error(\"Malformed UTF-8 data\")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}};var i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init();this._nDataBytes=0},_append:function(n){if(typeof n==\"string\"){n=c.parse(n)}this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data;var x=q.words;var n=q.sigBytes;var t=this.blockSize;var v=t*4;var u=n/v;if(w){u=e.ceil(u)}else{u=e.max((u|0)-this._minBufferSize,0)}var s=u*t;var r=e.min(s*4,n);if(s){for(var p=0;p>>2]&255}};f.BlockCipher=n.extend({cfg:n.cfg.extend({mode:m,padding:h}),reset:function(){n.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;\nthis._mode=c.call(a,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var p=f.CipherParams=k.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(g.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;\nreturn(a?l.create([1398893684,1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=l.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return p.create({ciphertext:a,salt:c})}},j=f.SerializableCipher=k.extend({cfg:k.extend({format:m}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return p.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,\nblockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return\"string\"==typeof a?b.parse(a,this):a}}),g=(g.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=l.random(8));a=v.create({keySize:b+c}).compute(a,d);c=l.create(a.words.slice(b),4*c);a.sigBytes=4*b;return p.create({key:a,iv:c,salt:d})}},s=f.PasswordBasedCipher=j.extend({cfg:j.cfg.extend({kdf:g}),encrypt:function(a,\nb,c,d){d=this.cfg.extend(d);c=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=c.iv;a=j.encrypt.call(this,a,b,c.key,d);a.mixIn(c);return a},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=c.iv;return j.decrypt.call(this,a,b,c.key,d)}})}();\n\n/*\nCryptoJS v3.1.2 aes.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){for(var q=CryptoJS,x=q.lib.BlockCipher,r=q.algo,j=[],y=[],z=[],A=[],B=[],C=[],s=[],u=[],v=[],w=[],g=[],k=0;256>k;k++)g[k]=128>k?k<<1:k<<1^283;for(var n=0,l=0,k=0;256>k;k++){var f=l^l<<1^l<<2^l<<3^l<<4,f=f>>>8^f&255^99;j[n]=f;y[f]=n;var t=g[n],D=g[t],E=g[D],b=257*g[f]^16843008*f;z[n]=b<<24|b>>>8;A[n]=b<<16|b>>>16;B[n]=b<<8|b>>>24;C[n]=b;b=16843009*E^65537*D^257*t^16843008*n;s[f]=b<<24|b>>>8;u[f]=b<<16|b>>>16;v[f]=b<<8|b>>>24;w[f]=b;n?(n=t^g[g[g[E^t]]],l^=g[g[l]]):n=l=1}var F=[0,1,2,4,8,\n16,32,64,128,27,54],r=r.AES=x.extend({_doReset:function(){for(var c=this._key,e=c.words,a=c.sigBytes/4,c=4*((this._nRounds=a+6)+1),b=this._keySchedule=[],h=0;h>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255]):(d=d<<8|d>>>24,d=j[d>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255],d^=F[h/a|0]<<24);b[h]=b[h-a]^d}e=this._invKeySchedule=[];for(a=0;aa||4>=h?d:s[j[d>>>24]]^u[j[d>>>16&255]]^v[j[d>>>\n8&255]]^w[j[d&255]]},encryptBlock:function(c,e){this._doCryptBlock(c,e,this._keySchedule,z,A,B,C,j)},decryptBlock:function(c,e){var a=c[e+1];c[e+1]=c[e+3];c[e+3]=a;this._doCryptBlock(c,e,this._invKeySchedule,s,u,v,w,y);a=c[e+1];c[e+1]=c[e+3];c[e+3]=a},_doCryptBlock:function(c,e,a,b,h,d,j,m){for(var n=this._nRounds,f=c[e]^a[0],g=c[e+1]^a[1],k=c[e+2]^a[2],p=c[e+3]^a[3],l=4,t=1;t>>24]^h[g>>>16&255]^d[k>>>8&255]^j[p&255]^a[l++],r=b[g>>>24]^h[k>>>16&255]^d[p>>>8&255]^j[f&255]^a[l++],s=\nb[k>>>24]^h[p>>>16&255]^d[f>>>8&255]^j[g&255]^a[l++],p=b[p>>>24]^h[f>>>16&255]^d[g>>>8&255]^j[k&255]^a[l++],f=q,g=r,k=s;q=(m[f>>>24]<<24|m[g>>>16&255]<<16|m[k>>>8&255]<<8|m[p&255])^a[l++];r=(m[g>>>24]<<24|m[k>>>16&255]<<16|m[p>>>8&255]<<8|m[f&255])^a[l++];s=(m[k>>>24]<<24|m[p>>>16&255]<<16|m[f>>>8&255]<<8|m[g&255])^a[l++];p=(m[p>>>24]<<24|m[f>>>16&255]<<16|m[g>>>8&255]<<8|m[k&255])^a[l++];c[e]=q;c[e+1]=r;c[e+2]=s;c[e+3]=p},keySize:8});q.AES=x._createHelper(r)})();\n\n/*\nCryptoJS v3.1.2 tripledes-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function j(b,c){var a=(this._lBlock>>>b^this._rBlock)&c;this._rBlock^=a;this._lBlock^=a<>>b^this._lBlock)&c;this._lBlock^=a;this._rBlock^=a<a;a++){var f=q[a]-1;c[a]=b[f>>>5]>>>31-f%32&1}b=this._subKeys=[];for(f=0;16>f;f++){for(var d=b[f]=[],e=r[f],a=0;24>a;a++)d[a/6|0]|=c[(p[a]-1+e)%28]<<31-a%6,d[4+(a/6|0)]|=c[28+(p[a+24]-1+e)%28]<<31-a%6;d[0]=d[0]<<1|d[0]>>>31;for(a=1;7>a;a++)d[a]>>>=\n4*(a-1)+3;d[7]=d[7]<<5|d[7]>>>27}c=this._invSubKeys=[];for(a=0;16>a;a++)c[a]=b[15-a]},encryptBlock:function(b,c){this._doCryptBlock(b,c,this._subKeys)},decryptBlock:function(b,c){this._doCryptBlock(b,c,this._invSubKeys)},_doCryptBlock:function(b,c,a){this._lBlock=b[c];this._rBlock=b[c+1];j.call(this,4,252645135);j.call(this,16,65535);l.call(this,2,858993459);l.call(this,8,16711935);j.call(this,1,1431655765);for(var f=0;16>f;f++){for(var d=a[f],e=this._lBlock,h=this._rBlock,g=0,k=0;8>k;k++)g|=s[k][((h^\nd[k])&t[k])>>>0];this._lBlock=h;this._rBlock=e^g}a=this._lBlock;this._lBlock=this._rBlock;this._rBlock=a;j.call(this,1,1431655765);l.call(this,8,16711935);l.call(this,2,858993459);j.call(this,16,65535);j.call(this,4,252645135);b[c]=this._lBlock;b[c+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});h.DES=e._createHelper(m);g=g.TripleDES=e.extend({_doReset:function(){var b=this._key.words;this._des1=m.createEncryptor(n.create(b.slice(0,2)));this._des2=m.createEncryptor(n.create(b.slice(2,4)));this._des3=\nm.createEncryptor(n.create(b.slice(4,6)))},encryptBlock:function(b,c){this._des1.encryptBlock(b,c);this._des2.decryptBlock(b,c);this._des3.encryptBlock(b,c)},decryptBlock:function(b,c){this._des3.decryptBlock(b,c);this._des2.encryptBlock(b,c);this._des1.decryptBlock(b,c)},keySize:6,ivSize:2,blockSize:2});h.TripleDES=e._createHelper(g)})();\n\n/*\nCryptoJS v3.1.2 enc-base64.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join(\"\")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d<\ne;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\"}})();\n\n/*\nCryptoJS v3.1.2 md5.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(E){function h(a,f,g,j,p,h,k){a=a+(f&g|~f&j)+p+k;return(a<>>32-h)+f}function k(a,f,g,j,p,h,k){a=a+(f&j|g&~j)+p+k;return(a<>>32-h)+f}function l(a,f,g,j,h,k,l){a=a+(f^g^j)+h+l;return(a<>>32-k)+f}function n(a,f,g,j,h,k,l){a=a+(g^(f|~j))+h+l;return(a<>>32-k)+f}for(var r=CryptoJS,q=r.lib,F=q.WordArray,s=q.Hasher,q=r.algo,a=[],t=0;64>t;t++)a[t]=4294967296*E.abs(E.sin(t+1))|0;q=q.MD5=s.extend({_doReset:function(){this._hash=new F.init([1732584193,4023233417,2562383102,271733878])},\n_doProcessBlock:function(m,f){for(var g=0;16>g;g++){var j=f+g,p=m[j];m[j]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360}var g=this._hash.words,j=m[f+0],p=m[f+1],q=m[f+2],r=m[f+3],s=m[f+4],t=m[f+5],u=m[f+6],v=m[f+7],w=m[f+8],x=m[f+9],y=m[f+10],z=m[f+11],A=m[f+12],B=m[f+13],C=m[f+14],D=m[f+15],b=g[0],c=g[1],d=g[2],e=g[3],b=h(b,c,d,e,j,7,a[0]),e=h(e,b,c,d,p,12,a[1]),d=h(d,e,b,c,q,17,a[2]),c=h(c,d,e,b,r,22,a[3]),b=h(b,c,d,e,s,7,a[4]),e=h(e,b,c,d,t,12,a[5]),d=h(d,e,b,c,u,17,a[6]),c=h(c,d,e,b,v,22,a[7]),\nb=h(b,c,d,e,w,7,a[8]),e=h(e,b,c,d,x,12,a[9]),d=h(d,e,b,c,y,17,a[10]),c=h(c,d,e,b,z,22,a[11]),b=h(b,c,d,e,A,7,a[12]),e=h(e,b,c,d,B,12,a[13]),d=h(d,e,b,c,C,17,a[14]),c=h(c,d,e,b,D,22,a[15]),b=k(b,c,d,e,p,5,a[16]),e=k(e,b,c,d,u,9,a[17]),d=k(d,e,b,c,z,14,a[18]),c=k(c,d,e,b,j,20,a[19]),b=k(b,c,d,e,t,5,a[20]),e=k(e,b,c,d,y,9,a[21]),d=k(d,e,b,c,D,14,a[22]),c=k(c,d,e,b,s,20,a[23]),b=k(b,c,d,e,x,5,a[24]),e=k(e,b,c,d,C,9,a[25]),d=k(d,e,b,c,r,14,a[26]),c=k(c,d,e,b,w,20,a[27]),b=k(b,c,d,e,B,5,a[28]),e=k(e,b,\nc,d,q,9,a[29]),d=k(d,e,b,c,v,14,a[30]),c=k(c,d,e,b,A,20,a[31]),b=l(b,c,d,e,t,4,a[32]),e=l(e,b,c,d,w,11,a[33]),d=l(d,e,b,c,z,16,a[34]),c=l(c,d,e,b,C,23,a[35]),b=l(b,c,d,e,p,4,a[36]),e=l(e,b,c,d,s,11,a[37]),d=l(d,e,b,c,v,16,a[38]),c=l(c,d,e,b,y,23,a[39]),b=l(b,c,d,e,B,4,a[40]),e=l(e,b,c,d,j,11,a[41]),d=l(d,e,b,c,r,16,a[42]),c=l(c,d,e,b,u,23,a[43]),b=l(b,c,d,e,x,4,a[44]),e=l(e,b,c,d,A,11,a[45]),d=l(d,e,b,c,D,16,a[46]),c=l(c,d,e,b,q,23,a[47]),b=n(b,c,d,e,j,6,a[48]),e=n(e,b,c,d,v,10,a[49]),d=n(d,e,b,c,\nC,15,a[50]),c=n(c,d,e,b,t,21,a[51]),b=n(b,c,d,e,A,6,a[52]),e=n(e,b,c,d,r,10,a[53]),d=n(d,e,b,c,y,15,a[54]),c=n(c,d,e,b,p,21,a[55]),b=n(b,c,d,e,w,6,a[56]),e=n(e,b,c,d,D,10,a[57]),d=n(d,e,b,c,u,15,a[58]),c=n(c,d,e,b,B,21,a[59]),b=n(b,c,d,e,s,6,a[60]),e=n(e,b,c,d,z,10,a[61]),d=n(d,e,b,c,q,15,a[62]),c=n(c,d,e,b,x,21,a[63]);g[0]=g[0]+b|0;g[1]=g[1]+c|0;g[2]=g[2]+d|0;g[3]=g[3]+e|0},_doFinalize:function(){var a=this._data,f=a.words,g=8*this._nDataBytes,j=8*a.sigBytes;f[j>>>5]|=128<<24-j%32;var h=E.floor(g/\n4294967296);f[(j+64>>>9<<4)+15]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;f[(j+64>>>9<<4)+14]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360;a.sigBytes=4*(f.length+1);this._process();a=this._hash;f=a.words;for(g=0;4>g;g++)j=f[g],f[g]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=s.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=s._createHelper(q);r.HmacMD5=s._createHmacHelper(q)})(Math);\n\n/*\nCryptoJS v3.1.2 sha1-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var k=CryptoJS,b=k.lib,m=b.WordArray,l=b.Hasher,d=[],b=k.algo.SHA1=l.extend({_doReset:function(){this._hash=new m.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(n,p){for(var a=this._hash.words,e=a[0],f=a[1],h=a[2],j=a[3],b=a[4],c=0;80>c;c++){if(16>c)d[c]=n[p+c]|0;else{var g=d[c-3]^d[c-8]^d[c-14]^d[c-16];d[c]=g<<1|g>>>31}g=(e<<5|e>>>27)+b+d[c];g=20>c?g+((f&h|~f&j)+1518500249):40>c?g+((f^h^j)+1859775393):60>c?g+((f&h|f&j|h&j)-1894007588):g+((f^h^\nj)-899497514);b=j;j=h;h=f<<30|f>>>2;f=e;e=g}a[0]=a[0]+e|0;a[1]=a[1]+f|0;a[2]=a[2]+h|0;a[3]=a[3]+j|0;a[4]=a[4]+b|0},_doFinalize:function(){var b=this._data,d=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=Math.floor(a/4294967296);d[(e+64>>>9<<4)+15]=a;b.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var b=l.clone.call(this);b._hash=this._hash.clone();return b}});k.SHA1=l._createHelper(b);k.HmacSHA1=l._createHmacHelper(b)})();\n\n/*\nCryptoJS v3.1.2 sha256-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(k){for(var g=CryptoJS,h=g.lib,v=h.WordArray,j=h.Hasher,h=g.algo,s=[],t=[],u=function(q){return 4294967296*(q-(q|0))|0},l=2,b=0;64>b;){var d;a:{d=l;for(var w=k.sqrt(d),r=2;r<=w;r++)if(!(d%r)){d=!1;break a}d=!0}d&&(8>b&&(s[b]=u(k.pow(l,0.5))),t[b]=u(k.pow(l,1/3)),b++);l++}var n=[],h=h.SHA256=j.extend({_doReset:function(){this._hash=new v.init(s.slice(0))},_doProcessBlock:function(q,h){for(var a=this._hash.words,c=a[0],d=a[1],b=a[2],k=a[3],f=a[4],g=a[5],j=a[6],l=a[7],e=0;64>e;e++){if(16>e)n[e]=\nq[h+e]|0;else{var m=n[e-15],p=n[e-2];n[e]=((m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3)+n[e-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[e-16]}m=l+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&g^~f&j)+t[e]+n[e];p=((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&d^c&b^d&b);l=j;j=g;g=f;f=k+m|0;k=b;b=d;d=c;c=m+p|0}a[0]=a[0]+c|0;a[1]=a[1]+d|0;a[2]=a[2]+b|0;a[3]=a[3]+k|0;a[4]=a[4]+f|0;a[5]=a[5]+g|0;a[6]=a[6]+j|0;a[7]=a[7]+l|0},_doFinalize:function(){var d=this._data,b=d.words,a=8*this._nDataBytes,c=8*d.sigBytes;\nb[c>>>5]|=128<<24-c%32;b[(c+64>>>9<<4)+14]=k.floor(a/4294967296);b[(c+64>>>9<<4)+15]=a;d.sigBytes=4*b.length;this._process();return this._hash},clone:function(){var b=j.clone.call(this);b._hash=this._hash.clone();return b}});g.SHA256=j._createHelper(h);g.HmacSHA256=j._createHmacHelper(h)})(Math);\n\n/*\nCryptoJS v3.1.2 sha224-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var b=CryptoJS,d=b.lib.WordArray,a=b.algo,c=a.SHA256,a=a.SHA224=c.extend({_doReset:function(){this._hash=new d.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var a=c._doFinalize.call(this);a.sigBytes-=4;return a}});b.SHA224=c._createHelper(a);b.HmacSHA224=c._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 sha512-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function a(){return d.create.apply(d,arguments)}for(var n=CryptoJS,r=n.lib.Hasher,e=n.x64,d=e.Word,T=e.WordArray,e=n.algo,ea=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),\na(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,\n2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),\na(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,\n3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],w=0;80>w;w++)v[w]=a();e=e.SHA512=r.extend({_doReset:function(){this._hash=new T.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(a,d){for(var f=this._hash.words,\nF=f[0],e=f[1],n=f[2],r=f[3],G=f[4],H=f[5],I=f[6],f=f[7],w=F.high,J=F.low,X=e.high,K=e.low,Y=n.high,L=n.low,Z=r.high,M=r.low,$=G.high,N=G.low,aa=H.high,O=H.low,ba=I.high,P=I.low,ca=f.high,Q=f.low,k=w,g=J,z=X,x=K,A=Y,y=L,U=Z,B=M,l=$,h=N,R=aa,C=O,S=ba,D=P,V=ca,E=Q,m=0;80>m;m++){var s=v[m];if(16>m)var j=s.high=a[d+2*m]|0,b=s.low=a[d+2*m+1]|0;else{var j=v[m-15],b=j.high,p=j.low,j=(b>>>1|p<<31)^(b>>>8|p<<24)^b>>>7,p=(p>>>1|b<<31)^(p>>>8|b<<24)^(p>>>7|b<<25),u=v[m-2],b=u.high,c=u.low,u=(b>>>19|c<<13)^(b<<\n3|c>>>29)^b>>>6,c=(c>>>19|b<<13)^(c<<3|b>>>29)^(c>>>6|b<<26),b=v[m-7],W=b.high,t=v[m-16],q=t.high,t=t.low,b=p+b.low,j=j+W+(b>>>0

>>0?1:0),b=b+c,j=j+u+(b>>>0>>0?1:0),b=b+t,j=j+q+(b>>>0>>0?1:0);s.high=j;s.low=b}var W=l&R^~l&S,t=h&C^~h&D,s=k&z^k&A^z&A,T=g&x^g&y^x&y,p=(k>>>28|g<<4)^(k<<30|g>>>2)^(k<<25|g>>>7),u=(g>>>28|k<<4)^(g<<30|k>>>2)^(g<<25|k>>>7),c=ea[m],fa=c.high,da=c.low,c=E+((h>>>14|l<<18)^(h>>>18|l<<14)^(h<<23|l>>>9)),q=V+((l>>>14|h<<18)^(l>>>18|h<<14)^(l<<23|h>>>9))+(c>>>0>>0?1:\n0),c=c+t,q=q+W+(c>>>0>>0?1:0),c=c+da,q=q+fa+(c>>>0>>0?1:0),c=c+b,q=q+j+(c>>>0>>0?1:0),b=u+T,s=p+s+(b>>>0>>0?1:0),V=S,E=D,S=R,D=C,R=l,C=h,h=B+c|0,l=U+q+(h>>>0>>0?1:0)|0,U=A,B=y,A=z,y=x,z=k,x=g,g=c+b|0,k=q+s+(g>>>0>>0?1:0)|0}J=F.low=J+g;F.high=w+k+(J>>>0>>0?1:0);K=e.low=K+x;e.high=X+z+(K>>>0>>0?1:0);L=n.low=L+y;n.high=Y+A+(L>>>0>>0?1:0);M=r.low=M+B;r.high=Z+U+(M>>>0>>0?1:0);N=G.low=N+h;G.high=$+l+(N>>>0>>0?1:0);O=H.low=O+C;H.high=aa+R+(O>>>0>>0?1:0);P=I.low=P+D;\nI.high=ba+S+(P>>>0>>0?1:0);Q=f.low=Q+E;f.high=ca+V+(Q>>>0>>0?1:0)},_doFinalize:function(){var a=this._data,d=a.words,f=8*this._nDataBytes,e=8*a.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+128>>>10<<5)+30]=Math.floor(f/4294967296);d[(e+128>>>10<<5)+31]=f;a.sigBytes=4*d.length;this._process();return this._hash.toX32()},clone:function(){var a=r.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});n.SHA512=r._createHelper(e);n.HmacSHA512=r._createHmacHelper(e)})();\n\n/*\nCryptoJS v3.1.2 sha384-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,a=c.x64,b=a.Word,e=a.WordArray,a=c.algo,d=a.SHA512,a=a.SHA384=d.extend({_doReset:function(){this._hash=new e.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var a=d._doFinalize.call(this);a.sigBytes-=16;return a}});c.SHA384=\nd._createHelper(a);c.HmacSHA384=d._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 ripemd160-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n/*\n\n(c) 2012 by Cedric Mesnil. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n(function(){var q=CryptoJS,d=q.lib,n=d.WordArray,p=d.Hasher,d=q.algo,x=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),y=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),z=n.create([11,14,15,12,\n5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),A=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),B=n.create([0,1518500249,1859775393,2400959708,2840853838]),C=n.create([1352829926,1548603684,1836072691,\n2053994217,0]),d=d.RIPEMD160=p.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,v){for(var b=0;16>b;b++){var c=v+b,f=e[c];e[c]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360}var c=this._hash.words,f=B.words,d=C.words,n=x.words,q=y.words,p=z.words,w=A.words,t,g,h,j,r,u,k,l,m,s;u=t=c[0];k=g=c[1];l=h=c[2];m=j=c[3];s=r=c[4];for(var a,b=0;80>b;b+=1)a=t+e[v+n[b]]|0,a=16>b?a+((g^h^j)+f[0]):32>b?a+((g&h|~g&j)+f[1]):48>b?\na+(((g|~h)^j)+f[2]):64>b?a+((g&j|h&~j)+f[3]):a+((g^(h|~j))+f[4]),a|=0,a=a<>>32-p[b],a=a+r|0,t=r,r=j,j=h<<10|h>>>22,h=g,g=a,a=u+e[v+q[b]]|0,a=16>b?a+((k^(l|~m))+d[0]):32>b?a+((k&m|l&~m)+d[1]):48>b?a+(((k|~l)^m)+d[2]):64>b?a+((k&l|~k&m)+d[3]):a+((k^l^m)+d[4]),a|=0,a=a<>>32-w[b],a=a+s|0,u=s,s=m,m=l<<10|l>>>22,l=k,k=a;a=c[1]+h+m|0;c[1]=c[2]+j+s|0;c[2]=c[3]+r+u|0;c[3]=c[4]+t+k|0;c[4]=c[0]+g+l|0;c[0]=a},_doFinalize:function(){var e=this._data,d=e.words,b=8*this._nDataBytes,c=8*e.sigBytes;\nd[c>>>5]|=128<<24-c%32;d[(c+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;e.sigBytes=4*(d.length+1);this._process();e=this._hash;d=e.words;for(b=0;5>b;b++)c=d[b],d[b]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return e},clone:function(){var d=p.clone.call(this);d._hash=this._hash.clone();return d}});q.RIPEMD160=p._createHelper(d);q.HmacRIPEMD160=p._createHmacHelper(d)})(Math);\n\n/*\nCryptoJS v3.1.2 hmac.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,k=c.enc.Utf8;c.algo.HMAC=c.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;\"string\"==typeof b&&(b=k.parse(b));var c=a.blockSize,e=4*c;b.sigBytes>e&&(b=a.finalize(b));b.clamp();for(var f=this._oKey=b.clone(),g=this._iKey=b.clone(),h=f.words,j=g.words,d=0;d>6)+b64map.charAt(e&63)}if(b+1==d.length){e=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(e<<2)}else{if(b+2==d.length){e=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(e>>2)+b64map.charAt((e&3)<<4)}}if(b64pad){while((a.length&3)>0){a+=b64pad}}return a}function b64tohex(f){var d=\"\";var e;var b=0;var c;var a;for(e=0;e>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(e){var d=b64tohex(e);var c;var b=new Array();for(c=0;2*c=0){var d=a*this[f++]+b[e]+h;h=Math.floor(d/67108864);b[e++]=d&67108863}return h}function am2(f,q,r,e,o,a){var k=q&32767,p=q>>15;while(--a>=0){var d=this[f]&32767;var g=this[f++]>>15;var b=p*d+g*k;d=k*d+((b&32767)<<15)+r[e]+(o&1073741823);o=(d>>>30)+(b>>>15)+p*g+(o>>>30);r[e++]=d&1073741823}return o}function am3(f,q,r,e,o,a){var k=q&16383,p=q>>14;while(--a>=0){var d=this[f]&16383;var g=this[f++]>>14;var b=p*d+g*k;d=k*d+((b&16383)<<14)+r[e]+o;o=(d>>28)+(b>>14)+p*g;r[e++]=d&268435455}return o}if(j_lm&&(navigator.appName==\"Microsoft Internet Explorer\")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator.appName!=\"Netscape\")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=((1<=0;--a){b[a]=this[a]}b.t=this.t;b.s=this.s}function bnpFromInt(a){this.t=1;this.s=(a<0)?-1:0;if(a>0){this[0]=a}else{if(a<-1){this[0]=a+this.DV}else{this.t=0}}}function nbv(a){var b=nbi();b.fromInt(a);return b}function bnpFromString(h,c){var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==256){e=8}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{this.fromRadix(h,c);return}}}}}}this.t=0;this.s=0;var g=h.length,d=false,f=0;while(--g>=0){var a=(e==8)?h[g]&255:intAt(h,g);if(a<0){if(h.charAt(g)==\"-\"){d=true}continue}d=false;if(f==0){this[this.t++]=a}else{if(f+e>this.DB){this[this.t-1]|=(a&((1<<(this.DB-f))-1))<>(this.DB-f))}else{this[this.t-1]|=a<=this.DB){f-=this.DB}}if(e==8&&(h[0]&128)!=0){this.s=-1;if(f>0){this[this.t-1]|=((1<<(this.DB-f))-1)<0&&this[this.t-1]==a){--this.t}}function bnToString(c){if(this.s<0){return\"-\"+this.negate().toString(c)}var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{return this.toRadix(c)}}}}}var g=(1<0){if(j>j)>0){a=true;h=int2char(l)}while(f>=0){if(j>(j+=this.DB-e)}else{l=(this[f]>>(j-=e))&g;if(j<=0){j+=this.DB;--f}}if(l>0){a=true}if(a){h+=int2char(l)}}}return a?h:\"0\"}function bnNegate(){var a=nbi();BigInteger.ZERO.subTo(this,a);return a}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(b){var d=this.s-b.s;if(d!=0){return d}var c=this.t;d=c-b.t;if(d!=0){return(this.s<0)?-d:d}while(--c>=0){if((d=this[c]-b[c])!=0){return d}}return 0}function nbits(a){var c=1,b;if((b=a>>>16)!=0){a=b;c+=16}if((b=a>>8)!=0){a=b;c+=8}if((b=a>>4)!=0){a=b;c+=4}if((b=a>>2)!=0){a=b;c+=2}if((b=a>>1)!=0){a=b;c+=1}return c}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(c,b){var a;for(a=this.t-1;a>=0;--a){b[a+c]=this[a]}for(a=c-1;a>=0;--a){b[a]=0}b.t=this.t+c;b.s=this.s}function bnpDRShiftTo(c,b){for(var a=c;a=0;--d){e[d+f+1]=(this[d]>>a)|h;h=(this[d]&g)<=0;--d){e[d]=0}e[f]=h;e.t=this.t+f+1;e.s=this.s;e.clamp()}function bnpRShiftTo(g,d){d.s=this.s;var e=Math.floor(g/this.DB);if(e>=this.t){d.t=0;return}var b=g%this.DB;var a=this.DB-b;var f=(1<>b;for(var c=e+1;c>b}if(b>0){d[this.t-e-1]|=(this.s&f)<>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g-=d.s}f.s=(g<0)?-1:0;if(g<-1){f[e++]=this.DV+g}else{if(g>0){f[e++]=g}}f.t=e;f.clamp()}function bnpMultiplyTo(c,e){var b=this.abs(),f=c.abs();var d=b.t;e.t=d+f.t;while(--d>=0){e[d]=0}for(d=0;d=0){d[b]=0}for(b=0;b=a.DV){d[b+a.t]-=a.DV;d[b+a.t+1]=1}}if(d.t>0){d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)}d.s=0;d.clamp()}function bnpDivRemTo(n,h,g){var w=n.abs();if(w.t<=0){return}var k=this.abs();if(k.t0){w.lShiftTo(v,d);k.lShiftTo(v,g)}else{w.copyTo(d);k.copyTo(g)}var p=d.t;var b=d[p-1];if(b==0){return}var o=b*(1<1)?d[p-2]>>this.F2:0);var A=this.FV/o,z=(1<=0){g[g.t++]=1;g.subTo(f,g)}BigInteger.ONE.dlShiftTo(p,f);f.subTo(d,d);while(d.t=0){var c=(g[--u]==b)?this.DM:Math.floor(g[u]*A+(g[u-1]+x)*z);if((g[u]+=d.am(0,c,g,s,0,p))0){g.rShiftTo(v,g)}if(a<0){BigInteger.ZERO.subTo(g,g)}}function bnMod(b){var c=nbi();this.abs().divRemTo(b,null,c);if(this.s<0&&c.compareTo(BigInteger.ZERO)>0){b.subTo(c,c)}return c}function Classic(a){this.m=a}function cConvert(a){if(a.s<0||a.compareTo(this.m)>=0){return a.mod(this.m)}else{return a}}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var a=this[0];if((a&1)==0){return 0}var b=a&3;b=(b*(2-(a&15)*b))&15;b=(b*(2-(a&255)*b))&255;b=(b*(2-(((a&65535)*b)&65535)))&65535;b=(b*(2-a*b%this.DV))%this.DV;return(b>0)?this.DV-b:-b}function Montgomery(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(a.DB-15))-1;this.mt2=2*a.t}function montConvert(a){var b=nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);if(a.s<0&&b.compareTo(BigInteger.ZERO)>0){this.m.subTo(b,b)}return b}function montRevert(a){var b=nbi();a.copyTo(b);this.reduce(b);return b}function montReduce(a){while(a.t<=this.mt2){a[a.t++]=0}for(var c=0;c>15)*this.mpl)&this.um)<<15))&a.DM;b=c+this.m.t;a[b]+=this.m.am(0,d,a,c,0,this.m.t);while(a[b]>=a.DV){a[b]-=a.DV;a[++b]++}}a.clamp();a.drShiftTo(this.m.t,a);if(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(h,j){if(h>4294967295||h<1){return BigInteger.ONE}var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;d.copyTo(f);while(--c>=0){j.sqrTo(f,a);if((h&(1<0){j.mulTo(a,d,f)}else{var b=f;f=a;a=b}}return j.revert(f)}function bnModPowInt(b,a){var c;if(b<256||a.isEven()){c=new Classic(a)}else{c=new Montgomery(a)}return this.exp(b,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction bnClone(){var a=nbi();this.copyTo(a);return a}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this[0]}else{if(this.t==0){return 0}}}return((this[1]&((1<<(32-this.DB))-1))<>24}function bnShortValue(){return(this.t==0)?this.s:(this[0]<<16)>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this[0]<=0)){return 0}else{return 1}}}function bnpToRadix(c){if(c==null){c=10}if(this.signum()==0||c<2||c>36){return\"0\"}var f=this.chunkSize(c);var e=Math.pow(c,f);var i=nbv(e),j=nbi(),h=nbi(),g=\"\";this.divRemTo(i,j,h);while(j.signum()>0){g=(e+h.intValue()).toString(c).substr(1)+g;j.divRemTo(i,j,h)}return h.intValue().toString(c)+g}function bnpFromRadix(m,h){this.fromInt(0);if(h==null){h=10}var f=this.chunkSize(h);var g=Math.pow(h,f),e=false,a=0,l=0;for(var c=0;c=f){this.dMultiply(g);this.dAddOffset(l,0);a=0;l=0}}if(a>0){this.dMultiply(Math.pow(h,a));this.dAddOffset(l,0)}if(e){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(f,e,h){if(\"number\"==typeof e){if(f<2){this.fromInt(1)}else{this.fromNumber(f,h);if(!this.testBit(f-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(f-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(e)){this.dAddOffset(2,0);if(this.bitLength()>f){this.subTo(BigInteger.ONE.shiftLeft(f-1),this)}}}}else{var d=new Array(),g=f&7;d.length=(f>>3)+1;e.nextBytes(d);if(g>0){d[0]&=((1<0){if(e>e)!=(this.s&this.DM)>>e){c[a++]=f|(this.s<<(this.DB-e))}while(b>=0){if(e<8){f=(this[b]&((1<>(e+=this.DB-8)}else{f=(this[b]>>(e-=8))&255;if(e<=0){e+=this.DB;--b}}if((f&128)!=0){f|=-256}if(a==0&&(this.s&128)!=(f&128)){++a}if(a>0||f!=this.s){c[a++]=f}}}return c}function bnEquals(b){return(this.compareTo(b)==0)}function bnMin(b){return(this.compareTo(b)<0)?this:b}function bnMax(b){return(this.compareTo(b)>0)?this:b}function bnpBitwiseTo(c,h,e){var d,g,b=Math.min(c.t,this.t);for(d=0;d>=16;b+=16}if((a&255)==0){a>>=8;b+=8}if((a&15)==0){a>>=4;b+=4}if((a&3)==0){a>>=2;b+=2}if((a&1)==0){++b}return b}function bnGetLowestSetBit(){for(var a=0;a=this.t){return(this.s!=0)}return((this[a]&(1<<(b%this.DB)))!=0)}function bnpChangeBit(c,b){var a=BigInteger.ONE.shiftLeft(c);this.bitwiseTo(a,b,a);return a}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(d,f){var e=0,g=0,b=Math.min(d.t,this.t);while(e>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g+=d.s}f.s=(g<0)?-1:0;if(g>0){f[e++]=g}else{if(g<-1){f[e++]=this.DV+g}}f.t=e;f.clamp()}function bnAdd(b){var c=nbi();this.addTo(b,c);return c}function bnSubtract(b){var c=nbi();this.subTo(b,c);return c}function bnMultiply(b){var c=nbi();this.multiplyTo(b,c);return c}function bnSquare(){var a=nbi();this.squareTo(a);return a}function bnDivide(b){var c=nbi();this.divRemTo(b,c,null);return c}function bnRemainder(b){var c=nbi();this.divRemTo(b,null,c);return c}function bnDivideAndRemainder(b){var d=nbi(),c=nbi();this.divRemTo(b,d,c);return new Array(d,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(b,a){if(b==0){return}while(this.t<=a){this[this.t++]=0}this[a]+=b;while(this[a]>=this.DV){this[a]-=this.DV;if(++a>=this.t){this[this.t++]=0}++this[a]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,c,b){a.multiplyTo(c,b)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp())}function bnpMultiplyLowerTo(b,f,e){var d=Math.min(this.t+b.t,f);e.s=0;e.t=d;while(d>0){e[--d]=0}var c;for(c=e.t-this.t;d=0){d[c]=0}for(c=Math.max(e-this.t,0);c2*this.m.t){return a.mod(this.m)}else{if(a.compareTo(this.m)<0){return a}else{var b=nbi();a.copyTo(b);this.reduce(b);return b}}}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1){a.t=this.m.t+1;a.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0){a.dAddOffset(1,this.m.t+1)}a.subTo(this.r2,a);while(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(q,f){var o=q.bitLength(),h,b=nbv(1),v;if(o<=0){return b}else{if(o<18){h=1}else{if(o<48){h=3}else{if(o<144){h=4}else{if(o<768){h=5}else{h=6}}}}}if(o<8){v=new Classic(f)}else{if(f.isEven()){v=new Barrett(f)}else{v=new Montgomery(f)}}var p=new Array(),d=3,s=h-1,a=(1<1){var A=nbi();v.sqrTo(p[1],A);while(d<=a){p[d]=nbi();v.mulTo(A,p[d-2],p[d]);d+=2}}var l=q.t-1,x,u=true,c=nbi(),y;o=nbits(q[l])-1;while(l>=0){if(o>=s){x=(q[l]>>(o-s))&a}else{x=(q[l]&((1<<(o+1))-1))<<(s-o);if(l>0){x|=q[l-1]>>(this.DB+o-s)}}d=h;while((x&1)==0){x>>=1;--d}if((o-=d)<0){o+=this.DB;--l}if(u){p[x].copyTo(b);u=false}else{while(d>1){v.sqrTo(b,c);v.sqrTo(c,b);d-=2}if(d>0){v.sqrTo(b,c)}else{y=b;b=c;c=y}v.mulTo(c,p[x],b)}while(l>=0&&(q[l]&(1<0){b.rShiftTo(f,b);h.rShiftTo(f,h)}while(b.signum()>0){if((d=b.getLowestSetBit())>0){b.rShiftTo(d,b)}if((d=h.getLowestSetBit())>0){h.rShiftTo(d,h)}if(b.compareTo(h)>=0){b.subTo(h,b);b.rShiftTo(1,b)}else{h.subTo(b,h);h.rShiftTo(1,h)}}if(f>0){h.lShiftTo(f,h)}return h}function bnpModInt(e){if(e<=0){return 0}var c=this.DV%e,b=(this.s<0)?e-1:0;if(this.t>0){if(c==0){b=this[0]%e}else{for(var a=this.t-1;a>=0;--a){b=(c*b+this[a])%e}}}return b}function bnModInverse(f){var j=f.isEven();if((this.isEven()&&j)||f.signum()==0){return BigInteger.ZERO}var i=f.clone(),h=this.clone();var g=nbv(1),e=nbv(0),l=nbv(0),k=nbv(1);while(i.signum()!=0){while(i.isEven()){i.rShiftTo(1,i);if(j){if(!g.isEven()||!e.isEven()){g.addTo(this,g);e.subTo(f,e)}g.rShiftTo(1,g)}else{if(!e.isEven()){e.subTo(f,e)}}e.rShiftTo(1,e)}while(h.isEven()){h.rShiftTo(1,h);if(j){if(!l.isEven()||!k.isEven()){l.addTo(this,l);k.subTo(f,k)}l.rShiftTo(1,l)}else{if(!k.isEven()){k.subTo(f,k)}}k.rShiftTo(1,k)}if(i.compareTo(h)>=0){i.subTo(h,i);if(j){g.subTo(l,g)}e.subTo(k,e)}else{h.subTo(i,h);if(j){l.subTo(g,l)}k.subTo(e,k)}}if(h.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(k.compareTo(f)>=0){return k.subtract(f)}if(k.signum()<0){k.addTo(f,k)}else{return k}if(k.signum()<0){return k.add(f)}else{return k}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(e){var d,b=this.abs();if(b.t==1&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d>1;if(f>lowprimes.length){f=lowprimes.length}var b=nbi();for(var e=0;e>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(window!==undefined&&(window.crypto!==undefined||window.msCrypto!==undefined)){var crypto=window.crypto||window.msCrypto;if(crypto.getRandomValues){var ua=new Uint8Array(32);crypto.getRandomValues(ua);for(t=0;t<32;++t){rng_pool[rng_pptr++]=ua[t]}}else{if(navigator.appName==\"Netscape\"&&navigator.appVersion<\"5\"){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr=0&&h>0){var f=e.charCodeAt(d--);if(f<128){g[--h]=f}else{if((f>127)&&(f<2048)){g[--h]=(f&63)|128;g[--h]=(f>>6)|192}else{g[--h]=(f&63)|128;g[--h]=((f>>6)&63)|128;g[--h]=(f>>12)|224}}}g[--h]=0;var b=new SecureRandom();var a=new Array();while(h>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}g[--h]=a[0]}g[--h]=2;g[--h]=0;return new BigInteger(g)}function oaep_mgf1_arr(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255])));d+=1}return b}function oaep_pad(q,a,f,l){var c=KJUR.crypto.MessageDigest;var o=KJUR.crypto.Util;var b=null;if(!f){f=\"sha1\"}if(typeof f===\"string\"){b=c.getCanonicalAlgName(f);l=c.getHashLength(b);f=function(i){return hextorstr(o.hashHex(rstrtohex(i),b))}}if(q.length+2*l+2>a){throw\"Message too long for RSA\"}var k=\"\",e;for(e=0;e0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{throw\"Invalid RSA public key\"}}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var e=this.doPublic(a);if(e==null){return null}var b=e.toString(16);if((b.length&1)==0){return b}else{return\"0\"+b}}function RSAEncryptOAEP(f,e,b){var a=oaep_pad(f,(this.n.bitLength()+7)>>3,e,b);if(a==null){return null}var g=this.doPublic(a);if(g==null){return null}var d=g.toString(16);if((d.length&1)==0){return d}else{return\"0\"+d}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;RSAKey.prototype.encryptOAEP=RSAEncryptOAEP;RSAKey.prototype.type=\"RSA\";\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction pkcs1unpad2(g,j){var a=g.toByteArray();var f=0;while(f=a.length){return null}}var e=\"\";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}function oaep_unpad(o,b,g,p){var e=KJUR.crypto.MessageDigest;var r=KJUR.crypto.Util;var c=null;if(!g){g=\"sha1\"}if(typeof g===\"string\"){c=e.getCanonicalAlgName(g);p=e.getHashLength(c);g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}}o=o.toByteArray();var h;for(h=0;h0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{throw\"Invalid RSA private key\"}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;this.isPublic=false;if(g==null){throw\"RSASetPrivateEx N == null\"}if(d==null){throw\"RSASetPrivateEx E == null\"}if(g.length==0){throw\"RSASetPrivateEx N.length == 0\"}if(d.length==0){throw\"RSASetPrivateEx E.length == 0\"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{throw\"Invalid RSA private key in RSASetPrivateEx\"}}function RSAGenerate(b,i){var a=new SecureRandom();var f=b>>1;this.e=parseInt(i,16);var c=new BigInteger(i,16);for(;;){for(;;){this.p=new BigInteger(b-f,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(f,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var h=this.p;this.p=this.q;this.q=h}var g=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var e=g.multiply(d);if(e.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(e);this.dmp1=this.d.mod(g);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=true}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}function RSADecryptOAEP(e,d,b){var f=parseBigInt(e,16);var a=this.doPrivate(f);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,d,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP;\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction ECFieldElementFp(b,a){this.x=a;this.q=b}function feFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.x.equals(a.x))}function feFpToBigInteger(){return this.x}function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))}function feFpAdd(a){return new ECFieldElementFp(this.q,this.x.add(a.toBigInteger()).mod(this.q))}function feFpSubtract(a){return new ECFieldElementFp(this.q,this.x.subtract(a.toBigInteger()).mod(this.q))}function feFpMultiply(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger()).mod(this.q))}function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))}function feFpDivide(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger().modInverse(this.q)).mod(this.q))}ECFieldElementFp.prototype.equals=feFpEquals;ECFieldElementFp.prototype.toBigInteger=feFpToBigInteger;ECFieldElementFp.prototype.negate=feFpNegate;ECFieldElementFp.prototype.add=feFpAdd;ECFieldElementFp.prototype.subtract=feFpSubtract;ECFieldElementFp.prototype.multiply=feFpMultiply;ECFieldElementFp.prototype.square=feFpSquare;ECFieldElementFp.prototype.divide=feFpDivide;function ECPointFp(c,a,d,b){this.curve=c;this.x=a;this.y=d;if(b==null){this.z=BigInteger.ONE}else{this.z=b}this.zinv=null}function pointFpGetX(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpGetY(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpEquals(a){if(a==this){return true}if(this.isInfinity()){return a.isInfinity()}if(a.isInfinity()){return this.isInfinity()}var c,b;c=a.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(a.z)).mod(this.curve.q);if(!c.equals(BigInteger.ZERO)){return false}b=a.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(a.z)).mod(this.curve.q);return b.equals(BigInteger.ZERO)}function pointFpIsInfinity(){if((this.x==null)&&(this.y==null)){return true}return this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)}function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)}function pointFpAdd(l){if(this.isInfinity()){return l}if(l.isInfinity()){return this}var p=l.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(l.z)).mod(this.curve.q);var o=l.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(l.z)).mod(this.curve.q);if(BigInteger.ZERO.equals(o)){if(BigInteger.ZERO.equals(p)){return this.twice()}return this.curve.getInfinity()}var j=new BigInteger(\"3\");var e=this.x.toBigInteger();var n=this.y.toBigInteger();var c=l.x.toBigInteger();var k=l.y.toBigInteger();var m=o.square();var i=m.multiply(o);var d=e.multiply(m);var g=p.square().multiply(this.z);var a=g.subtract(d.shiftLeft(1)).multiply(l.z).subtract(i).multiply(o).mod(this.curve.q);var h=d.multiply(j).multiply(p).subtract(n.multiply(i)).subtract(g.multiply(p)).multiply(l.z).add(p.multiply(i)).mod(this.curve.q);var f=i.multiply(this.z).multiply(l.z).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),f)}function pointFpTwice(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var g=new BigInteger(\"3\");var c=this.x.toBigInteger();var h=this.y.toBigInteger();var e=h.multiply(this.z);var j=e.multiply(h).mod(this.curve.q);var i=this.curve.a.toBigInteger();var k=c.square().multiply(g);if(!BigInteger.ZERO.equals(i)){k=k.add(this.z.square().multiply(i))}k=k.mod(this.curve.q);var b=k.square().subtract(c.shiftLeft(3).multiply(j)).shiftLeft(1).multiply(e).mod(this.curve.q);var f=k.multiply(g).multiply(c).subtract(j.shiftLeft(1)).shiftLeft(2).multiply(j).subtract(k.square().multiply(k)).mod(this.curve.q);var d=e.square().multiply(e).shiftLeft(3).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(b),this.curve.fromBigInteger(f),d)}function pointFpMultiply(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add(a?this:l)}}return d}function pointFpMultiplyTwo(c,a,b){var d;if(c.bitLength()>b.bitLength()){d=c.bitLength()-1}else{d=b.bitLength()-1}var f=this.curve.getInfinity();var e=this.add(a);while(d>=0){f=f.twice();if(c.testBit(d)){if(b.testBit(d)){f=f.add(e)}else{f=f.add(this)}}else{if(b.testBit(d)){f=f.add(a)}}--d}return f}ECPointFp.prototype.getX=pointFpGetX;ECPointFp.prototype.getY=pointFpGetY;ECPointFp.prototype.equals=pointFpEquals;ECPointFp.prototype.isInfinity=pointFpIsInfinity;ECPointFp.prototype.negate=pointFpNegate;ECPointFp.prototype.add=pointFpAdd;ECPointFp.prototype.twice=pointFpTwice;ECPointFp.prototype.multiply=pointFpMultiply;ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo;function ECCurveFp(e,d,c){this.q=e;this.a=this.fromBigInteger(d);this.b=this.fromBigInteger(c);this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b))}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)}function curveFpDecodePointHex(d){switch(parseInt(d.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var a=(d.length-2)/2;var c=d.substr(2,a);var b=d.substr(a+2,a);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(b,16)));default:return null}}ECCurveFp.prototype.getQ=curveFpGetQ;ECCurveFp.prototype.getA=curveFpGetA;ECCurveFp.prototype.getB=curveFpGetB;ECCurveFp.prototype.equals=curveFpEquals;ECCurveFp.prototype.getInfinity=curveFpGetInfinity;ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger;ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex;\n/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib\n */\nECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};ECPointFp.prototype.getEncoded=function(c){var d=function(h,f){var g=h.toByteArrayUnsigned();if(fg.length){g.unshift(0)}}return g};var a=this.getX().toBigInteger();var e=this.getY().toBigInteger();var b=d(a,32);if(c){if(e.isEven()){b.unshift(2)}else{b.unshift(3)}}else{b.unshift(4);b=b.concat(d(e,32))}return b};ECPointFp.decodeFrom=function(g,c){var f=c[0];var e=c.length-1;var d=c.slice(1,1+e/2);var b=c.slice(1+e/2,1+e);d.unshift(0);b.unshift(0);var a=new BigInteger(d);var h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.decodeFromHex=function(g,c){var f=c.substr(0,2);var e=c.length-2;var d=c.substr(2,e/2);var b=c.substr(2+e/2,e/2);var a=new BigInteger(d,16);var h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.prototype.add2D=function(c){if(this.isInfinity()){return c}if(c.isInfinity()){return this}if(this.x.equals(c.x)){if(this.y.equals(c.y)){return this.twice()}return this.curve.getInfinity()}var g=c.x.subtract(this.x);var e=c.y.subtract(this.y);var a=e.divide(g);var d=a.square().subtract(this.x).subtract(c.x);var f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var b=this.curve.fromBigInteger(BigInteger.valueOf(2));var e=this.curve.fromBigInteger(BigInteger.valueOf(3));var a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b));var c=a.square().subtract(this.x.multiply(b));var d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)};ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add2D(a?this:l)}}return d};ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger();var i=this.getY().toBigInteger();var f=this.curve.getA().toBigInteger();var c=this.curve.getB().toBigInteger();var h=this.curve.getQ();var e=i.multiply(i).mod(h);var g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)};ECPointFp.prototype.toString=function(){return\"(\"+this.getX().toBigInteger().toString()+\",\"+this.getY().toBigInteger().toString()+\")\"};ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity()){throw new Error(\"Point is at infinity.\")}var a=this.getX().toBigInteger();var b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"x coordinate out of bounds\")}if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"y coordinate out of bounds\")}if(!this.isOnCurve()){throw new Error(\"Point is not on the curve.\")}if(this.multiply(c).isInfinity()){throw new Error(\"Point is not a scalar multiple of G.\")}return true};\n/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval\n */\nvar jsonParse=(function(){var e=\"(?:-?\\\\b(?:0|[1-9][0-9]*)(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\\\b)\";var j='(?:[^\\\\0-\\\\x08\\\\x0a-\\\\x1f\"\\\\\\\\]|\\\\\\\\(?:[\"/\\\\\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:\"'+j+'*\")';var d=new RegExp(\"(?:false|true|null|[\\\\{\\\\}\\\\[\\\\]]|\"+e+\"|\"+i+\")\",\"g\");var k=new RegExp(\"\\\\\\\\(?:([^u])|u(.{4}))\",\"g\");var g={'\"':'\"',\"/\":\"/\",\"\\\\\":\"\\\\\",b:\"\\b\",f:\"\\f\",n:\"\\n\",r:\"\\r\",t:\"\\t\"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String(\"\");var a=\"\\\\\";var f={\"{\":Object,\"[\":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if(\"{\"===v){x={}}else{if(\"[\"===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({\"\":x},\"\")}return x}})();\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.asn1==\"undefined\"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b=\"0\"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!=\"-\"){if(f.length%2==1){f=\"0\"+f}else{if(!f.match(/^[0-7]/)){f=\"00\"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g=\"\";for(var d=0;d15){throw\"ASN.1 length too long to represent by 8x: n = \"+i.toString(16)}var f=128+g;return f.toString(16)+h}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return\"\"}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!=\"undefined\"){if(typeof c==\"string\"){this.setString(c)}else{if(typeof c.str!=\"undefined\"){this.setString(c.str)}else{if(typeof c.hex!=\"undefined\"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(f){utc=f.getTime()+(f.getTimezoneOffset()*60000);var e=new Date(utc);return e};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o==\"utc\"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,\"\");r=r+\".\"+k}}return r+\"Z\"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join(\"0\")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!=\"undefined\"){if(typeof b.array!=\"undefined\"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT=\"01\";this.hTLV=\"0101ff\"};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT=\"02\";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!=\"undefined\"){if(typeof a.bigint!=\"undefined\"){this.setByBigInteger(a.bigint)}else{if(typeof a[\"int\"]!=\"undefined\"){this.setByInteger(a[\"int\"])}else{if(typeof a==\"number\"){this.setByInteger(a)}else{if(typeof a.hex!=\"undefined\"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!==\"undefined\"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex=\"00\"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT=\"03\";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=(l*2))){break}if(d>=200){break}g.push(b);c=b;d++}return g};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){throw\"checking tag doesn't match: \"+e.substr(d,2)+\"!=\"+i}}return d}f=c.shift();b=g.getChildIdx(e,d);return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getTLVbyList=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyList(d,c,b);if(a===undefined){throw\"can't find nthList object\"}if(f!==undefined){if(d.substr(a,2)!=f){throw\"checking tag doesn't match: \"+d.substr(a,2)+\"!=\"+f}}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a===undefined){throw\"can't find nthList object\"}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join(\"0\")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+\".\"+j.join(\".\")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+\"..(total \"+A.length/2+\"bytes)..\"+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=\"\"}var x=c.ommit_long_octet;if(e.substr(l,2)==\"01\"){var h=j(e,l);if(h==\"00\"){return g+\"BOOLEAN FALSE\\n\"}else{return g+\"BOOLEAN TRUE\\n\"}}if(e.substr(l,2)==\"02\"){var h=j(e,l);return g+\"INTEGER \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"03\"){var h=j(e,l);return g+\"BITSTRING \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"04\"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+\"OCTETSTRING, encapsulates\\n\";k=k+y(h,c,0,g+\" \");return k}else{return g+\"OCTETSTRING \"+q(h,x)+\"\\n\"}}if(e.substr(l,2)==\"05\"){return g+\"NULL\\n\"}if(e.substr(l,2)==\"06\"){var m=j(e,l);var a=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(a);var b=a.replace(/\\./g,\" \");if(o!=\"\"){return g+\"ObjectIdentifier \"+o+\" (\"+b+\")\\n\"}else{return g+\"ObjectIdentifier (\"+b+\")\\n\"}}if(e.substr(l,2)==\"0c\"){return g+\"UTF8String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"13\"){return g+\"PrintableString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"14\"){return g+\"TeletexString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"16\"){return g+\"IA5String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"17\"){return g+\"UTCTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"18\"){return g+\"GeneralizedTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"30\"){if(e.substr(l,4)==\"3000\"){return g+\"SEQUENCE {}\\n\"}var k=g+\"SEQUENCE\\n\";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)==\"06\"&&e.substr(d[d.length-1],2)==\"04\"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u0){var m=new f({array:this.extensionsArray});var k=new c({explicit:true,tag:\"a3\",obj:m});this.asn1Array.push(k)}var n=new f({array:this.asn1Array});this.hTLV=n.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension=function(d){KJUR.asn1.x509.Extension.superclass.constructor.call(this);var f=null,a=KJUR,e=a.asn1,h=e.DERObjectIdentifier,i=e.DEROctetString,b=e.DERBitString,g=e.DERBoolean,c=e.DERSequence;this.getEncodedHex=function(){var m=new h({oid:this.oid});var l=new i({hex:this.getExtnValueHex()});var k=new Array();k.push(m);if(this.critical){k.push(new g())}k.push(l);var j=new c({array:k});return j.getEncodedHex()};this.critical=false;if(d!==undefined){if(d.critical!==undefined){this.critical=d.critical}}};YAHOO.lang.extend(KJUR.asn1.x509.Extension,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension.appendByNameToArray=function(e,c,b){var g=e.toLowerCase(),f=KJUR.asn1.x509;if(g==\"basicconstraints\"){var d=new f.BasicConstraints(c);b.push(d)}else{if(g==\"keyusage\"){var d=new f.KeyUsage(c);b.push(d)}else{if(g==\"crldistributionpoints\"){var d=new f.CRLDistributionPoints(c);b.push(d)}else{if(g==\"extkeyusage\"){var d=new f.ExtKeyUsage(c);b.push(d)}else{if(g==\"authoritykeyidentifier\"){var d=new f.AuthorityKeyIdentifier(c);b.push(d)}else{if(g==\"authorityinfoaccess\"){var d=new f.AuthorityInfoAccess(c);b.push(d)}else{if(g==\"subjectaltname\"){var d=new f.SubjectAltName(c);b.push(d)}else{if(g==\"issueraltname\"){var d=new f.IssuerAltName(c);b.push(d)}else{throw\"unsupported extension name: \"+e}}}}}}}}};KJUR.asn1.x509.KeyUsage=function(f){KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this,f);var a=X509.KEYUSAGE_NAME;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.15\";if(f!==undefined){if(f.bin!==undefined){this.asn1ExtnValue=new KJUR.asn1.DERBitString(f)}if(f.names!==undefined&&f.names.length!==undefined){var e=f.names;var d=\"000000000\";for(var c=0;c-1){e.push(new KJUR.asn1.DERInteger({\"int\":this.pathLen}))}var d=new KJUR.asn1.DERSequence({array:e});this.asn1ExtnValue=d;return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.19\";this.cA=false;this.pathLen=-1;if(c!==undefined){if(c.cA!==undefined){this.cA=c.cA}if(c.pathLen!==undefined){this.pathLen=c.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){this.asn1ExtnValue=new a.DERSequence({array:e})};this.setByOneURI=function(h){var e=new c.GeneralNames([{uri:h}]);var g=new c.DistributionPointName(e);var f=new c.DistributionPoint({dpobj:g});this.setByDPArray([f])};this.oid=\"2.5.29.31\";if(d!==undefined){if(d.array!==undefined){this.setByDPArray(d.array)}else{if(d.uri!==undefined){this.setByOneURI(d.uri)}}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLDistributionPoints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.ExtKeyUsage=function(c){KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,c);var b=KJUR,a=b.asn1;this.setPurposeArray=function(d){this.asn1ExtnValue=new a.DERSequence();for(var e=0;e0){var h=new b({array:this.aRevokedCert});this.asn1Array.push(h)}var i=new b({array:this.asn1Array});this.hTLV=i.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize=function(){this.asn1Version=null;this.asn1SignatureAlg=null;this.asn1Issuer=null;this.asn1ThisUpdate=null;this.asn1NextUpdate=null;this.aRevokedCert=new Array()};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertList,KJUR.asn1.ASN1Object);KJUR.asn1.x509.CRLEntry=function(e){KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);var d=null,c=null,b=KJUR,a=b.asn1;this.setCertSerial=function(f){this.sn=new a.DERInteger(f)};this.setRevocationDate=function(f){this.time=new a.x509.Time(f)};this.getEncodedHex=function(){var f=new a.DERSequence({array:[this.sn,this.time]});this.TLV=f.getEncodedHex();return this.TLV};if(e!==undefined){if(e.time!==undefined){this.setRevocationDate(e.time)}if(e.sn!==undefined){this.setCertSerial(e.sn)}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLEntry,KJUR.asn1.ASN1Object);KJUR.asn1.x509.X500Name=function(f){KJUR.asn1.x509.X500Name.superclass.constructor.call(this);this.asn1Array=new Array();var d=KJUR,c=d.asn1,e=c.x509,b=pemtohex;this.setByString=function(g){var k=g.split(\"/\");k.shift();var j=[];for(var l=0;l0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+\",\"+h).replace(/\\\\,/g,\",\");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)===\"\\\\\"){e=true}}b=b.map(function(a){return a.replace(\"/\",\"\\\\/\")});b.reverse();return\"/\"+b.join(\"/\")};KJUR.asn1.x509.RDN=function(a){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=new Array();this.addByString=function(b){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:b}))};this.addByMultiValuedString=function(d){var b=KJUR.asn1.x509.RDN.parseString(d);for(var c=0;c0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+\"+\"+k).replace(/\\\\\\+/g,\"+\");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)===\"\\\\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/\"$/)){var d=(e+\"+\"+k).replace(/^([^=]+)=\"(.*)\"$/,\"$1=$2\");b.push(d);l=false}else{b.push(e+\"+\"+k)}}else{b.push(k)}if(k.match(/^[^=]+=\"/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(d){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var f=null,e=null,a=\"utf8\",c=KJUR,b=c.asn1;this.setByString=function(h){var g=h.match(/^([^=]+)=(.+)$/);if(g){this.setByAttrTypeAndValueStr(g[1],g[2])}else{throw\"malformed attrTypeAndValueStr: \"+h}};this.setByAttrTypeAndValueStr=function(i,h){this.typeObj=KJUR.asn1.x509.OID.atype2obj(i);var g=a;if(i==\"C\"){g=\"prn\"}this.valueObj=this.getValueObj(g,h)};this.getValueObj=function(h,g){if(h==\"utf8\"){return new b.DERUTF8String({str:g})}if(h==\"prn\"){return new b.DERPrintableString({str:g})}if(h==\"tel\"){return new b.DERTeletexString({str:g})}if(h==\"ia5\"){return new b.DERIA5String({str:g})}throw\"unsupported directory string type: type=\"+h+\" value=\"+g};this.getEncodedHex=function(){var g=new b.DERSequence({array:[this.typeObj,this.valueObj]});this.TLV=g.getEncodedHex();return this.TLV};if(d!==undefined){if(d.str!==undefined){this.setByString(d.str)}}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw\"algId and/or subjPubKey not set\"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{\"int\":{bigint:q.n}},{\"int\":{\"int\":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:\"rsaEncryption\"});this.asn1SubjPKey=new b({hex:\"00\"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:\"ecPublicKey\",asn1params:r});this.asn1SubjPKey=new b({hex:\"00\"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{\"int\":{bigint:q.p}},{\"int\":{bigint:q.q}},{\"int\":{bigint:q.g}}]});this.asn1AlgId=new o({name:\"dsa\",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:\"00\"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type==\"utc\"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type==\"utc\"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type=\"utc\";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type=\"utc\"}if(f.str.match(/^[0-9]{14}Z$/)){this.type=\"gen\"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(d){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw\"algorithm not specified\"}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var e=[this.asn1Alg];if(this.asn1Params!==null){e.push(this.asn1Params)}var f=new a.DERSequence({array:e});this.hTLV=f.getEncodedHex();return this.hTLV};if(d!==undefined){if(d.name!==undefined){this.nameAlg=d.name}if(d.asn1params!==undefined){this.asn1Params=d.asn1params}if(d.paramempty!==undefined){this.paramEmpty=d.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){var c=this.nameAlg.toLowerCase();if(c.substr(-7,7)!==\"withdsa\"&&c.substr(-9,9)!==\"withecdsa\"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:\"81\",dns:\"82\",dn:\"a4\",uri:\"86\",ip:\"87\"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type=\"rfc822\";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type=\"dns\";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type=\"uri\";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({str:p.dn})}if(p.ldapdn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certissuer param not cert\"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certsubj param not cert\"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type=\"ip\";this.explicit=false;var q=p.ip;var s;var n=\"malformed IP address\";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex(\"[\"+q.split(\".\").join(\",\")+\"]\");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw\"unsupported type in params=\"+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){r=new b({obj:this.dUnsignedAttrs,tag:\"a1\",explicit:false})}var q=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,o,this.dSigAlg,this.dSig,];if(r!=null){q.push(r)}var p=new h.DERSequence({array:q});this.hTLV=p.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.SignerInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.EncapsulatedContentInfo=function(g){var c=KJUR,b=c.asn1,e=b.DERTaggedObject,a=b.DERSequence,h=b.DERObjectIdentifier,d=b.DEROctetString,f=b.cms;f.EncapsulatedContentInfo.superclass.constructor.call(this);this.dEContentType=new h({name:\"data\"});this.dEContent=null;this.isDetached=false;this.eContentValueHex=null;this.setContentType=function(i){if(i.match(/^[0-2][.][0-9.]+$/)){this.dEContentType=new h({oid:i})}else{this.dEContentType=new h({name:i})}};this.setContentValue=function(i){if(i!==undefined){if(typeof i.hex==\"string\"){this.eContentValueHex=i.hex}else{if(typeof i.str==\"string\"){this.eContentValueHex=utf8tohex(i.str)}}}};this.setContentValueHex=function(i){this.eContentValueHex=i};this.setContentValueStr=function(i){this.eContentValueHex=utf8tohex(i)};this.getEncodedHex=function(){if(typeof this.eContentValueHex!=\"string\"){throw\"eContentValue not yet set\"}var k=new d({hex:this.eContentValueHex});this.dEContent=new e({obj:k,tag:\"a0\",explicit:true});var i=[this.dEContentType];if(!this.isDetached){i.push(this.dEContent)}var j=new a({array:i});this.hTLV=j.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.EncapsulatedContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.ContentInfo=function(f){var c=KJUR,b=c.asn1,d=b.DERTaggedObject,a=b.DERSequence,e=b.x509;KJUR.asn1.cms.ContentInfo.superclass.constructor.call(this);this.dContentType=null;this.dContent=null;this.setContentType=function(g){if(typeof g==\"string\"){this.dContentType=e.OID.name2obj(g)}};this.getEncodedHex=function(){var h=new d({obj:this.dContent,tag:\"a0\",explicit:true});var g=new a({array:[this.dContentType,h]});this.hTLV=g.getEncodedHex();return this.hTLV};if(f!==undefined){if(f.type){this.setContentType(f.type)}if(f.obj&&f.obj instanceof b.ASN1Object){this.dContent=f.obj}}};YAHOO.lang.extend(KJUR.asn1.cms.ContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.SignedData=function(e){var a=KJUR,h=a.asn1,j=h.ASN1Object,g=h.DERInteger,m=h.DERSet,f=h.DERSequence,b=h.DERTaggedObject,l=h.cms,i=l.EncapsulatedContentInfo,d=l.SignerInfo,n=l.ContentInfo,c=h.x509,k=c.AlgorithmIdentifier;KJUR.asn1.cms.SignedData.superclass.constructor.call(this);this.dCMSVersion=new g({\"int\":1});this.dDigestAlgs=null;this.digestAlgNameList=[];this.dEncapContentInfo=new i();this.dCerts=null;this.certificateList=[];this.crlList=[];this.signerInfoList=[new d()];this.addCertificatesByPEM=function(p){var q=pemtohex(p);var r=new j();r.hTLV=q;this.certificateList.push(r)};this.getEncodedHex=function(){if(typeof this.hTLV==\"string\"){return this.hTLV}if(this.dDigestAlgs==null){var u=[];for(var t=0;t0){var v=new m({array:this.certificateList});this.dCerts=new b({obj:v,tag:\"a0\",explicit:false})}}if(this.dCerts!=null){p.push(this.dCerts)}var r=new m({array:this.signerInfoList});p.push(r);var q=new f({array:p});this.hTLV=q.getEncodedHex();return this.hTLV};this.getContentInfo=function(){this.getEncodedHex();var o=new n({type:\"signed-data\",obj:this});return o};this.getContentInfoEncodedHex=function(){var o=this.getContentInfo();var p=o.getEncodedHex();return p};this.getPEM=function(){return hextopem(this.getContentInfoEncodedHex(),\"CMS\")}};YAHOO.lang.extend(KJUR.asn1.cms.SignedData,KJUR.asn1.ASN1Object);KJUR.asn1.cms.CMSUtil=new function(){};KJUR.asn1.cms.CMSUtil.newSignedData=function(d){var b=KJUR,j=b.asn1,q=j.cms,f=q.SignerInfo,n=q.SignedData,o=q.SigningTime,a=q.SigningCertificate,p=q.SigningCertificateV2,c=j.cades,e=c.SignaturePolicyIdentifier;var m=new n();m.dEncapContentInfo.setContentValue(d.content);if(typeof d.certs==\"object\"){for(var h=0;h0){var s=new f({array:this.extensionsArray});var r=new m({array:[s]});var q=new f({array:[new k({oid:\"1.2.840.113549.1.9.14\"}),r]});var p=new c({explicit:true,tag:\"a0\",obj:q});this.asn1Array.push(p)}else{var p=new c({explicit:false,tag:\"a0\",obj:new j()});this.asn1Array.push(p)}var t=new f({array:this.asn1Array});this.hTLV=t.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CSRUtil=new function(){};KJUR.asn1.csr.CSRUtil.newCSRPEM=function(h){var c=KEYUTIL,b=KJUR.asn1.csr;if(h.subject===undefined){throw\"parameter subject undefined\"}if(h.sbjpubkey===undefined){throw\"parameter sbjpubkey undefined\"}if(h.sigalg===undefined){throw\"parameter sigalg undefined\"}if(h.sbjprvkey===undefined){throw\"parameter sbjpubkey undefined\"}var d=new b.CertificationRequestInfo();d.setSubjectByParam(h.subject);d.setSubjectPublicKeyByGetKey(h.sbjpubkey);if(h.ext!==undefined&&h.ext.length!==undefined){for(var e=0;ef.length){f=c[d]}}e=e.replace(f,\"::\");return e.slice(1,-1)}function hextoip(b){var d=\"malformed hex value\";if(!b.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){throw d}if(b.length==8){var c;try{c=parseInt(b.substr(0,2),16)+\".\"+parseInt(b.substr(2,2),16)+\".\"+parseInt(b.substr(4,2),16)+\".\"+parseInt(b.substr(6,2),16);return c}catch(a){throw d}}else{if(b.length==32){return hextoipv6(b)}else{return b}}}function iptohex(f){var j=\"malformed IP address\";f=f.toLowerCase(f);if(f.match(/^[0-9.]+$/)){var b=f.split(\".\");if(b.length!==4){throw j}var g=\"\";try{for(var e=0;e<4;e++){var h=parseInt(b[e]);g+=(\"0\"+h.toString(16)).slice(-2)}return g}catch(c){throw j}}else{if(f.match(/^[0-9a-f:]+$/)&&f.indexOf(\":\")!==-1){return ipv6tohex(f)}else{throw j}}}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b=\"\";for(var c=0;c\"7\"){return\"00\"+a}return a}function intarystrtohex(b){b=b.replace(/^\\s*\\[\\s*/,\"\");b=b.replace(/\\s*\\]\\s*$/,\"\");b=b.replace(/\\s*/g,\"\");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;bd){throw\"key is too short for SigAlg: keylen=\"+j+\",\"+a}var b=\"0001\";var k=\"00\"+c;var g=\"\";var l=d-b.length-k.length;for(var f=0;f=0;--p){q=q.twice2D();q.z=BigInteger.ONE;if(o.testBit(p)){if(n.testBit(p)){q=q.add2D(t)}else{q=q.add2D(s)}}else{if(n.testBit(p)){q=q.add2D(r)}}}return q}this.getBigRandom=function(i){return new BigInteger(i.bitLength(),a).mod(i.subtract(BigInteger.ONE)).add(BigInteger.ONE)};this.setNamedCurve=function(i){this.ecparams=KJUR.crypto.ECParameterDB.getByName(i);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=i};this.setPrivateKeyHex=function(i){this.isPrivate=true;this.prvKeyHex=i};this.setPublicKeyHex=function(i){this.isPublic=true;this.pubKeyHex=i};this.getPublicKeyXYHex=function(){var k=this.pubKeyHex;if(k.substr(0,2)!==\"04\"){throw\"this method supports uncompressed format(04) only\"}var j=this.ecparams.keylen/4;if(k.length!==2+j*2){throw\"malformed public key hex length\"}var i={};i.x=k.substr(2,j);i.y=k.substr(2+j);return i};this.getShortNISTPCurveName=function(){var i=this.curveName;if(i===\"secp256r1\"||i===\"NIST P-256\"||i===\"P-256\"||i===\"prime256v1\"){return\"P-256\"}if(i===\"secp384r1\"||i===\"NIST P-384\"||i===\"P-384\"){return\"P-384\"}return null};this.generateKeyPairHex=function(){var k=this.ecparams.n;var n=this.getBigRandom(k);var l=this.ecparams.G.multiply(n);var q=l.getX().toBigInteger();var o=l.getY().toBigInteger();var i=this.ecparams.keylen/4;var m=(\"0000000000\"+n.toString(16)).slice(-i);var r=(\"0000000000\"+q.toString(16)).slice(-i);var p=(\"0000000000\"+o.toString(16)).slice(-i);var j=\"04\"+r+p;this.setPrivateKeyHex(m);this.setPublicKeyHex(j);return{ecprvhex:m,ecpubhex:j}};this.signWithMessageHash=function(i){return this.signHex(i,this.prvKeyHex)};this.signHex=function(o,j){var t=new BigInteger(j,16);var l=this.ecparams.n;var q=new BigInteger(o,16);do{var m=this.getBigRandom(l);var u=this.ecparams.G;var p=u.multiply(m);var i=p.getX().toBigInteger().mod(l)}while(i.compareTo(BigInteger.ZERO)<=0);var v=m.modInverse(l).multiply(q.add(t.multiply(i))).mod(l);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(i,v)};this.sign=function(m,u){var q=u;var j=this.ecparams.n;var p=BigInteger.fromByteArrayUnsigned(m);do{var l=this.getBigRandom(j);var t=this.ecparams.G;var o=t.multiply(l);var i=o.getX().toBigInteger().mod(j)}while(i.compareTo(BigInteger.ZERO)<=0);var v=l.modInverse(j).multiply(p.add(q.multiply(i))).mod(j);return this.serializeSig(i,v)};this.verifyWithMessageHash=function(j,i){return this.verifyHex(j,i,this.pubKeyHex)};this.verifyHex=function(m,i,p){var l,j;var o=KJUR.crypto.ECDSA.parseSigHex(i);l=o.r;j=o.s;var k;k=ECPointFp.decodeFromHex(this.ecparams.curve,p);var n=new BigInteger(m,16);return this.verifyRaw(n,l,j,k)};this.verify=function(o,p,j){var l,i;if(Bitcoin.Util.isArray(p)){var n=this.parseSig(p);l=n.r;i=n.s}else{if(\"object\"===typeof p&&p.r&&p.s){l=p.r;i=p.s}else{throw\"Invalid value for signature\"}}var k;if(j instanceof ECPointFp){k=j}else{if(Bitcoin.Util.isArray(j)){k=ECPointFp.decodeFrom(this.ecparams.curve,j)}else{throw\"Invalid format for pubkey value, must be byte array or ECPointFp\"}}var m=BigInteger.fromByteArrayUnsigned(o);return this.verifyRaw(m,l,i,k)};this.verifyRaw=function(o,i,w,m){var l=this.ecparams.n;var u=this.ecparams.G;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(l)>=0){return false}if(w.compareTo(BigInteger.ONE)<0||w.compareTo(l)>=0){return false}var p=w.modInverse(l);var k=o.multiply(p).mod(l);var j=i.multiply(p).mod(l);var q=u.multiply(k).add(m.multiply(j));var t=q.getX().toBigInteger().mod(l);return t.equals(i)};this.serializeSig=function(k,j){var l=k.toByteArraySigned();var i=j.toByteArraySigned();var m=[];m.push(2);m.push(l.length);m=m.concat(l);m.push(2);m.push(i.length);m=m.concat(i);m.unshift(m.length);m.unshift(48);return m};this.parseSig=function(n){var m;if(n[0]!=48){throw new Error(\"Signature not a valid DERSequence\")}m=2;if(n[m]!=2){throw new Error(\"First element in signature must be a DERInteger\")}var l=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];if(n[m]!=2){throw new Error(\"Second element in signature must be a DERInteger\")}var i=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];var k=BigInteger.fromByteArrayUnsigned(l);var j=BigInteger.fromByteArrayUnsigned(i);return{r:k,s:j}};this.parseSigCompact=function(m){if(m.length!==65){throw\"Signature has the wrong length\"}var j=m[0]-27;if(j<0||j>7){throw\"Invalid signature type\"}var o=this.ecparams.n;var l=BigInteger.fromByteArrayUnsigned(m.slice(1,33)).mod(o);var k=BigInteger.fromByteArrayUnsigned(m.slice(33,65)).mod(o);return{r:l,s:k,i:j}};this.readPKCS5PrvKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var i,k,o;try{i=p(l,0,[2,0],\"06\");k=p(l,0,[1],\"04\");try{o=p(l,0,[3,0],\"03\").substr(2)}catch(j){}}catch(j){throw\"malformed PKCS#1/5 plain ECC private key\"}this.curveName=m(i);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o);this.setPrivateKeyHex(k);this.isPublic=false};this.readPKCS8PrvKeyHex=function(l){var q=ASN1HEX;var i=KJUR.crypto.ECDSA.getName;var n=q.getVbyList;if(q.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var j,p,m,k;try{j=n(l,0,[1,0],\"06\");p=n(l,0,[1,1],\"06\");m=n(l,0,[2,0,1],\"04\");try{k=n(l,0,[2,0,2,0],\"03\").substr(2)}catch(o){}}catch(o){throw\"malformed PKCS#8 plain ECC private key\"}this.curveName=i(p);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(k);this.setPrivateKeyHex(m);this.isPublic=false};this.readPKCS8PubKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var k,i,o;try{k=p(l,0,[0,0],\"06\");i=p(l,0,[0,1],\"06\");o=p(l,0,[1],\"03\").substr(2)}catch(j){throw\"malformed PKCS#8 ECC public key\"}this.curveName=m(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o)};this.readCertPubKeyHex=function(k,p){if(p!==5){p=6}var m=ASN1HEX;var l=KJUR.crypto.ECDSA.getName;var o=m.getVbyList;if(m.isASN1HEX(k)===false){throw\"not ASN.1 hex string\"}var i,n;try{i=o(k,0,[0,p,0,1],\"06\");n=o(k,0,[0,p,1],\"03\").substr(2)}catch(j){throw\"malformed X.509 certificate ECC public key\"}this.curveName=l(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(n)};if(h!==undefined){if(h.curve!==undefined){this.curveName=h.curve}}if(this.curveName===undefined){this.curveName=e}this.setNamedCurve(this.curveName);if(h!==undefined){if(h.prv!==undefined){this.setPrivateKeyHex(h.prv)}if(h.pub!==undefined){this.setPublicKeyHex(h.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX;var i=j.getChildIdx;var g=j.getV;if(f.substr(0,2)!=\"30\"){throw\"signature is not a ASN.1 sequence\"}var h=i(f,0);if(h.length!=2){throw\"number of signature ASN.1 sequence elements seem wrong\"}var e=h[0];var d=h[1];if(f.substr(e,2)!=\"02\"){throw\"1st item of sequene of signature is not ASN.1 integer\"}if(f.substr(d,2)!=\"02\"){throw\"2nd item of sequene of signature is not ASN.1 integer\"}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(c){var d=KJUR.crypto.ECDSA.parseSigHexInHexRS(c);var b=d.r;var a=d.s;if(b.substr(0,2)==\"00\"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)==\"00\"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b=\"00\"+b}if((a.length%32)==30){a=\"00\"+a}if(b.length%32!=0){throw\"unknown ECDSA sig r length error\"}if(a.length%32!=0){throw\"unknown ECDSA sig s length error\"}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if((((a.length/2)*8)%(16*8))!=0){throw\"unknown ECDSA concatinated r-s sig length error\"}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.getEncodedHex()};KJUR.crypto.ECDSA.getName=function(a){if(a===\"2a8648ce3d030107\"){return\"secp256r1\"}if(a===\"2b8104000a\"){return\"secp256k1\"}if(a===\"2b81040022\"){return\"secp384r1\"}if(\"|secp256r1|NIST P-256|P-256|prime256v1|\".indexOf(a)!==-1){return\"secp256r1\"}if(\"|secp256k1|\".indexOf(a)!==-1){return\"secp256k1\"}if(\"|secp384r1|NIST P-384|P-384|\".indexOf(a)!==-1){return\"secp384r1\"}return null};\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.crypto==\"undefined\"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!=\"undefined\"){d=c[e]}if(typeof b[d]!=\"undefined\"){return b[d]}throw\"unregistered EC curve name: \"+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex(\"04\"+f+k);b[A][\"name\"]=A;b[A][\"keylen\"]=l;b[A][\"curve\"]=r;b[A][\"G\"]=q;b[A][\"n\"]=t;b[A][\"h\"]=w;b[A][\"oid\"]=d;b[A][\"info\"]=x;for(var v=0;v1){g=new BigInteger(i,16)}else{g=null}h=new BigInteger(j,16);this.setPrivate(c,a,e,g,h)};this.setPublic=function(c,b,a,d){this.isPublic=true;this.p=c;this.q=b;this.g=a;this.y=d;this.x=null};this.setPublicHex=function(f,e,d,g){var b,a,h,c;b=new BigInteger(f,16);a=new BigInteger(e,16);h=new BigInteger(d,16);c=new BigInteger(g,16);this.setPublic(b,a,h,c)};this.signWithMessageHash=function(d){var c=this.p;var b=this.q;var f=this.g;var i=this.y;var j=this.x;var e=KJUR.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),b.subtract(BigInteger.ONE));var l=d.substr(0,b.bitLength()/4);var h=new BigInteger(l,16);var a=(f.modPow(e,c)).mod(b);var n=(e.modInverse(b).multiply(h.add(j.multiply(a)))).mod(b);var m=KJUR.asn1.ASN1Util.jsonToASN1HEX({seq:[{\"int\":{bigint:a}},{\"int\":{bigint:n}}]});return m};this.verifyWithMessageHash=function(h,f){var d=this.p;var b=this.q;var j=this.g;var l=this.y;var i=this.parseASN1Signature(f);var a=i[0];var t=i[1];var o=h.substr(0,b.bitLength()/4);var k=new BigInteger(o,16);if(BigInteger.ZERO.compareTo(a)>0||a.compareTo(b)>0){throw\"invalid DSA signature\"}if(BigInteger.ZERO.compareTo(t)>=0||t.compareTo(b)>0){throw\"invalid DSA signature\"}var m=t.modInverse(b);var e=k.multiply(m).mod(b);var c=a.multiply(m).mod(b);var n=j.modPow(e,d).multiply(l.modPow(c,d)).mod(d).mod(b);return n.compareTo(a)==0};this.parseASN1Signature=function(a){try{var d=new BigInteger(ASN1HEX.getVbyList(a,0,[0],\"02\"),16);var c=new BigInteger(ASN1HEX.getVbyList(a,0,[1],\"02\"),16);return[d,c]}catch(b){throw\"malformed ASN.1 DSA signature\"}};this.readPKCS5PrvKeyHex=function(c){var b,a,f,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[1],\"02\");a=d(c,0,[2],\"02\");f=d(c,0,[3],\"02\");g=d(c,0,[4],\"02\");i=d(c,0,[5],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed PKCS#1/5 plain DSA private key\"}this.setPrivateHex(b,a,f,g,i)};this.readPKCS8PrvKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[1,1,0],\"02\");c=i(d,0,[1,1,1],\"02\");b=i(d,0,[1,1,2],\"02\");g=i(d,0,[2,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 plain DSA private key\"}this.setPrivateHex(f,c,b,null,g)};this.readPKCS8PubKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[0,1,0],\"02\");c=i(d,0,[0,1,1],\"02\");b=i(d,0,[0,1,2],\"02\");g=i(d,0,[1,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 DSA public key\"}this.setPublicHex(f,c,b,g)};this.readCertPubKeyHex=function(c,f){if(f!==5){f=6}var b,a,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[0,f,0,1,0],\"02\");a=d(c,0,[0,f,0,1,1],\"02\");g=d(c,0,[0,f,0,1,2],\"02\");i=d(c,0,[0,f,1,0],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed X.509 certificate DSA public key\"}this.setPublicHex(b,a,g,i)}};\nvar KEYUTIL=function(){var d=function(p,r,q){return k(CryptoJS.AES,p,r,q)};var e=function(p,r,q){return k(CryptoJS.TripleDES,p,r,q)};var a=function(p,r,q){return k(CryptoJS.DES,p,r,q)};var k=function(s,x,u,q){var r=CryptoJS.enc.Hex.parse(x);var w=CryptoJS.enc.Hex.parse(u);var p=CryptoJS.enc.Hex.parse(q);var t={};t.key=w;t.iv=p;t.ciphertext=r;var v=s.decrypt(t,w,{iv:p});return CryptoJS.enc.Hex.stringify(v)};var l=function(p,r,q){return g(CryptoJS.AES,p,r,q)};var o=function(p,r,q){return g(CryptoJS.TripleDES,p,r,q)};var f=function(p,r,q){return g(CryptoJS.DES,p,r,q)};var g=function(t,y,v,q){var s=CryptoJS.enc.Hex.parse(y);var x=CryptoJS.enc.Hex.parse(v);var p=CryptoJS.enc.Hex.parse(q);var w=t.encrypt(s,x,{iv:p});var r=CryptoJS.enc.Hex.parse(w.toString());var u=CryptoJS.enc.Base64.stringify(r);return u};var i={\"AES-256-CBC\":{proc:d,eproc:l,keylen:32,ivlen:16},\"AES-192-CBC\":{proc:d,eproc:l,keylen:24,ivlen:16},\"AES-128-CBC\":{proc:d,eproc:l,keylen:16,ivlen:16},\"DES-EDE3-CBC\":{proc:e,eproc:o,keylen:24,ivlen:8},\"DES-CBC\":{proc:a,eproc:f,keylen:8,ivlen:8}};var c=function(p){return i[p][\"proc\"]};var m=function(p){var r=CryptoJS.lib.WordArray.random(p);var q=CryptoJS.enc.Hex.stringify(r);return q};var n=function(v){var w={};var q=v.match(new RegExp(\"DEK-Info: ([^,]+),([0-9A-Fa-f]+)\",\"m\"));if(q){w.cipher=q[1];w.ivsalt=q[2]}var p=v.match(new RegExp(\"-----BEGIN ([A-Z]+) PRIVATE KEY-----\"));if(p){w.type=p[1]}var u=-1;var x=0;if(v.indexOf(\"\\r\\n\\r\\n\")!=-1){u=v.indexOf(\"\\r\\n\\r\\n\");x=2}if(v.indexOf(\"\\n\\n\")!=-1){u=v.indexOf(\"\\n\\n\");x=1}var t=v.indexOf(\"-----END\");if(u!=-1&&t!=-1){var r=v.substring(u+x*2,t-x);r=r.replace(/\\s+/g,\"\");w.data=r}return w};var j=function(q,y,p){var v=p.substring(0,16);var t=CryptoJS.enc.Hex.parse(v);var r=CryptoJS.enc.Utf8.parse(y);var u=i[q][\"keylen\"]+i[q][\"ivlen\"];var x=\"\";var w=null;for(;;){var s=CryptoJS.algo.MD5.create();if(w!=null){s.update(w)}s.update(r);s.update(t);w=s.finalize();x=x+CryptoJS.enc.Hex.stringify(w);if(x.length>=u*2){break}}var z={};z.keyhex=x.substr(0,i[q][\"keylen\"]*2);z.ivhex=x.substr(i[q][\"keylen\"]*2,i[q][\"ivlen\"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v][\"proc\"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s][\"eproc\"];var t=r(p,q,u);return t};return{version:\"1.0.0\",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p=\"\";if(typeof t==\"undefined\"||t==null){t=\"AES-256-CBC\"}if(typeof i[t]==\"undefined\"){throw\"KEYUTIL unsupported algorithm: \"+t}if(typeof r==\"undefined\"||r==null){var v=i[t][\"ivlen\"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,\"$1\\r\\n\");var p=\"-----BEGIN \"+x+\" PRIVATE KEY-----\\r\\n\";p+=\"Proc-Type: 4,ENCRYPTED\\r\\n\";p+=\"DEK-Info: \"+t+\",\"+r+\"\\r\\n\";p+=\"\\r\\n\";p+=q;p+=\"\\r\\n-----END \"+x+\" PRIVATE KEY-----\\r\\n\";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw\"malformed format: SEQUENCE(0).items != 2: \"+r.length}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0).items != 2: \"+A.length}if(w(y,A[0])!=\"2a864886f70d01050d\"){throw\"this only supports pkcs5PBES2\"}var p=z(y,A[1]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0.1).items != 2: \"+p.length}var q=z(y,p[1]);if(q.length!=2){throw\"malformed format: SEQUENCE(0.0.1.1).items != 2: \"+q.length}if(w(y,q[0])!=\"2a864886f70d0307\"){throw\"this only supports TripleDES\"}t.encryptionSchemeAlg=\"TripleDES\";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw\"malformed format: SEQUENCE(0.0.1.0).items != 2: \"+s.length}if(w(y,s[0])!=\"2a864886f70d01050c\"){throw\"this only supports pkcs5PBKDF2\"}var x=z(y,s[1]);if(x.length<2){throw\"malformed format: SEQUENCE(0.0.1.0.1).items < 2: \"+x.length}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw\"malformed format pbkdf2Iter: \"+u}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,\"ENCRYPTED PRIVATE KEY\");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!=\"30\"){throw\"malformed plain PKCS8 private key(code:001)\"}var r=u(s,0);if(r.length!=3){throw\"malformed plain PKCS8 private key(code:002)\"}if(s.substr(r[1],2)!=\"30\"){throw\"malformed PKCS8 private key(code:003)\"}var p=u(s,r[1]);if(p.length!=2){throw\"malformed PKCS8 private key(code:004)\"}if(s.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 private key(code:005)\"}q.algoid=t(s,p[0]);if(s.substr(p[1],2)==\"06\"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!=\"04\"){throw\"malformed PKCS8 private key(code:006)\"}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,\"PRIVATE KEY\");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid==\"2a864886f70d010101\"){r=new RSAKey()}else{if(q.algoid==\"2a8648ce380401\"){r=new KJUR.crypto.DSA()}else{if(q.algoid==\"2a8648ce3d0201\"){r=new KJUR.crypto.ECDSA()}else{throw\"unsupported private key algorithm\"}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],\"06\");if(r===\"2a864886f70d010101\"){p=new RSAKey()}else{if(r===\"2a8648ce380401\"){p=new KJUR.crypto.DSA()}else{if(r===\"2a8648ce3d0201\"){p=new KJUR.crypto.ECDSA()}else{throw\"unsupported PKCS#8 public key hex\"}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!=\"30\"){throw\"malformed RSA key(code:001)\"}var q=t(r,0);if(q.length!=2){throw\"malformed RSA key(code:002)\"}if(r.substr(q[0],2)!=\"02\"){throw\"malformed RSA key(code:003)\"}p.n=s(r,q[0]);if(r.substr(q[1],2)!=\"02\"){throw\"malformed RSA key(code:004)\"}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw\"outer DERSequence shall have 2 elements: \"+r.length}var w=r[0];if(t.substr(w,2)!=\"30\"){throw\"malformed PKCS8 public key(code:001)\"}var p=u(t,w);if(p.length!=2){throw\"malformed PKCS8 public key(code:002)\"}if(t.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 public key(code:003)\"}q.algoid=s(t,p[0]);if(t.substr(p[1],2)==\"06\"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)==\"30\"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],\"02\");q.algparam.q=v.getVbyList(t,p[1],[1],\"02\");q.algparam.g=v.getVbyList(t,p[1],[2],\"02\")}}if(t.substr(r[1],2)!=\"03\"){throw\"malformed PKCS8 public key(code:004)\"}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!=\"undefined\"&&l instanceof w){return l}if(typeof i!=\"undefined\"&&l instanceof i){return l}if(typeof C!=\"undefined\"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;j.setPublicKeyHex(u);return j}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;var b=(\"0000000000\"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n===\"pkcs5prv\"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)===\"04\"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw\"unsupported PKCS#1/5 hexadecimal key\"}}}return P}if(n===\"pkcs8prv\"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n===\"pkcs8pub\"){return F._getKeyFromPublicPKCS8Hex(l)}if(n===\"x509pub\"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf(\"-END CERTIFICATE-\",0)!=-1||l.indexOf(\"-END X509 CERTIFICATE-\",0)!=-1||l.indexOf(\"-END TRUSTED CERTIFICATE-\",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf(\"-END PUBLIC KEY-\")!=-1){var O=pemtohex(l,\"PUBLIC KEY\");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var m=M(l,\"RSA PRIVATE KEY\");return F.getKey(m,null,\"pkcs5prv\")}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var I=M(l,\"DSA PRIVATE KEY\");var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END PRIVATE KEY-\")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf(\"-END EC PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],\"04\");var f=d(I,0,[2,0],\"06\");var A=d(I,0,[3,0],\"03\").substr(2);var e=\"\";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw\"undefined OID(hex) in KJUR.crypto.OID: \"+f}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END ENCRYPTED PRIVATE KEY-\")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw\"not supported argument\"};KEYUTIL.generateKeypair=function(a,c){if(a==\"RSA\"){var b=c;var h=new RSAKey();h.generate(b,\"10001\");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a==\"EC\"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw\"unknown algorithm: \"+a}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.n}},{\"int\":s.e},{\"int\":{bigint:s.d}},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.dmp1}},{\"int\":{bigint:s.dmq1}},{\"int\":{bigint:s.coeff}}]});return G}function B(G){var s=l({seq:[{\"int\":1},{octstr:{hex:G.prvKeyHex}},{tag:[\"a0\",true,{oid:{name:G.curveName}}]},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+G.pubKeyHex}}]}]});return s}function x(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.g}},{\"int\":{bigint:s.y}},{\"int\":{bigint:s.x}}]});return G}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D==\"PKCS8PUB\")){var E=new C(b);var w=E.getEncodedHex();return hextopem(w,\"PUBLIC KEY\")}if(D==\"PKCS1PRV\"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();return hextopem(w,\"RSA PRIVATE KEY\")}if(D==\"PKCS1PRV\"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.getEncodedHex();var h=B(b);var t=h.getEncodedHex();var p=\"\";p+=hextopem(v,\"EC PARAMETERS\");p+=hextopem(t,\"EC PRIVATE KEY\");return p}if(D==\"PKCS1PRV\"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();return hextopem(w,\"DSA PRIVATE KEY\")}if(D==\"PKCS5PRV\"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"RSA\",w,y,m,j)}if(D==\"PKCS5PRV\"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"EC\",w,y,m,j)}if(D==\"PKCS5PRV\"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"DSA\",w,y,m,j)}var o=function(G,s){var I=c(G,s);var H=new l({seq:[{seq:[{oid:{name:\"pkcs5PBES2\"}},{seq:[{seq:[{oid:{name:\"pkcs5PBKDF2\"}},{seq:[{octstr:{hex:I.pbkdf2Salt}},{\"int\":I.pbkdf2Iter}]}]},{seq:[{oid:{name:\"des-EDE3-CBC\"}},{octstr:{hex:I.encryptionSchemeIV}}]}]}]},{octstr:{hex:I.ciphertext}}]});return H.getEncodedHex()};var c=function(N,O){var H=100;var M=CryptoJS.lib.WordArray.random(8);var L=\"DES-EDE3-CBC\";var s=CryptoJS.lib.WordArray.random(8);var I=CryptoJS.PBKDF2(O,M,{keySize:192/32,iterations:H});var J=CryptoJS.enc.Hex.parse(N);var K=CryptoJS.TripleDES.encrypt(J,I,{iv:s})+\"\";var G={};G.ciphertext=K;G.pbkdf2Salt=CryptoJS.enc.Hex.stringify(M);G.pbkdf2Iter=H;G.encryptionSchemeAlg=L;G.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return G};if(D==\"PKCS8PRV\"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"rsaEncryption\"}},{\"null\":true}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var g=new l({seq:[{\"int\":1},{octstr:{hex:b.prvKeyHex}},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+b.pubKeyHex}}]}]});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"ecPublicKey\"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"dsa\"}},{seq:[{\"int\":{bigint:b.p}},{\"int\":{bigint:b.q}},{\"int\":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}throw\"unsupported object nor format\"};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,\"CERTIFICATE REQUEST\");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,\"pkcs8pub\");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!=\"30\"){throw\"malformed CSR(code:001)\"}var e=f(g,0);if(e.length<1){throw\"malformed CSR(code:002)\"}if(g.substr(e[0],2)!=\"30\"){throw\"malformed CSR(code:003)\"}var a=f(g,e[0]);if(a.length<3){throw\"malformed CSR(code:004)\"}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getJWKFromKey=function(d){var b={};if(d instanceof RSAKey&&d.isPrivate){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));b.d=hextob64u(d.d.toString(16));b.p=hextob64u(d.p.toString(16));b.q=hextob64u(d.q.toString(16));b.dp=hextob64u(d.dmp1.toString(16));b.dq=hextob64u(d.dmq1.toString(16));b.qi=hextob64u(d.coeff.toString(16));return b}else{if(d instanceof RSAKey&&d.isPublic){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPrivate){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);b.d=hextob64u(d.prvKeyHex);return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPublic){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);return b}}}}throw\"not supported key object\"};\nRSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,j,l,b,a,f,d,k;var m=ASN1HEX;var g=m.getVbyList;if(m.isASN1HEX(e)===false){throw\"not ASN.1 hex string\"}try{c=g(e,0,[2,0,1],\"02\");j=g(e,0,[2,0,2],\"02\");l=g(e,0,[2,0,3],\"02\");b=g(e,0,[2,0,4],\"02\");a=g(e,0,[2,0,5],\"02\");f=g(e,0,[2,0,6],\"02\");d=g(e,0,[2,0,7],\"02\");k=g(e,0,[2,0,8],\"02\")}catch(i){throw\"malformed PKCS#8 plain RSA private key\"}this.setPrivateEx(c,j,l,b,a,f,d,k)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw\"keyHex is not ASN.1 hex string\"}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!==\"02\"||c.substr(a[1],2)!==\"02\"){throw\"wrong hex for PKCS#5 public key\"}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw\"not ASN.1 hex string\"}if(c.getTLVbyList(b,0,[0,0])!==\"06092a864886f70d010101\"){throw\"not PKCS8 RSA public key\"}var a=c.getTLVbyList(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)};\nvar _RE_HEXDECONLY=new RegExp(\"\");_RE_HEXDECONLY.compile(\"[^0-9a-f]\",\"gi\");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c=\"\";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw\"invalid salt length\"}}}if(c<(g+k+2)){throw\"data too long\"}var f=\"\";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dthis.n.bitLength()){return 0}var i=this.doPublic(b);var e=i.toString(16).replace(/^1f+00/,\"\");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(k){return KJUR.crypto.Util.hashString(k,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){a=a.replace(_RE_HEXDECONLY,\"\");a=a.replace(/[ \\n]+/g,\"\");var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,\"\");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){var k=new BigInteger(s,16);if(k.bitLength()>this.n.bitLength()){return false}var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw\"invalid salt length\"}}}if(m<(h+c+2)){throw\"data too long\"}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw\"bits beyond keysize not zero\"}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q0){var b=\":\"+n.join(\":\")+\":\";if(b.indexOf(\":\"+k+\":\")==-1){throw\"algorithm '\"+k+\"' not accepted in the list\"}}if(k!=\"none\"&&B===null){throw\"key shall be specified to verify.\"}if(typeof B==\"string\"&&B.indexOf(\"-----BEGIN \")!=-1){B=KEYUTIL.getKey(B)}if(z==\"RS\"||z==\"PS\"){if(!(B instanceof m)){throw\"key shall be a RSAKey obj for RS* and PS* algs\"}}if(z==\"ES\"){if(!(B instanceof p)){throw\"key shall be a ECDSA obj for ES* algs\"}}if(k==\"none\"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw\"unsupported alg name: \"+k}else{u=t.jwsalg2sigalg[k]}if(u==\"none\"){throw\"not supported\"}else{if(u.substr(0,4)==\"Hmac\"){var o=null;if(B===undefined){throw\"hexadecimal key shall be specified for HMAC\"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf(\"withECDSA\")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(\".\");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw\"malformed sJWS: wrong number of '.' splitted elements\"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null,\" \");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null,\" \")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;var k=e.split(\".\");var c=k[0];var i=k[1];var q=c+\".\"+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw\"acceptField.alg shall be specified\"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss===\"object\"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub===\"object\"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud===\"object\"){if(typeof g.aud==\"string\"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud==\"object\"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt===\"number\"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!==\"number\"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp==\"number\"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw\"addSignature failed: \"+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw\"malformed header\"}if(typeof g.payload===\"string\"){this.sPayload=g.payload}else{throw\"malformed signatures\"}if(g.signatures.length>0){this.aSignatures=g.signatures}else{throw\"malformed signatures\"}}catch(e){throw\"malformed JWS-JS JSON object: \"+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}};\nexports.SecureRandom = SecureRandom;\nexports.rng_seed_time = rng_seed_time;\n\nexports.BigInteger = BigInteger;\nexports.RSAKey = RSAKey;\nexports.ECDSA = KJUR.crypto.ECDSA;\nexports.DSA = KJUR.crypto.DSA;\nexports.Signature = KJUR.crypto.Signature;\nexports.MessageDigest = KJUR.crypto.MessageDigest;\nexports.Mac = KJUR.crypto.Mac;\nexports.Cipher = KJUR.crypto.Cipher;\nexports.KEYUTIL = KEYUTIL;\nexports.ASN1HEX = ASN1HEX;\nexports.X509 = X509;\nexports.CryptoJS = CryptoJS;\n\n// ext/base64.js\nexports.b64tohex = b64tohex;\nexports.b64toBA = b64toBA;\n\n// base64x.js\nexports.stoBA = stoBA;\nexports.BAtos = BAtos;\nexports.BAtohex = BAtohex;\nexports.stohex = stohex;\nexports.stob64 = stob64;\nexports.stob64u = stob64u;\nexports.b64utos = b64utos;\nexports.b64tob64u = b64tob64u;\nexports.b64utob64 = b64utob64;\nexports.hex2b64 = hex2b64;\nexports.hextob64u = hextob64u;\nexports.b64utohex = b64utohex;\nexports.utf8tob64u = utf8tob64u;\nexports.b64utoutf8 = b64utoutf8;\nexports.utf8tob64 = utf8tob64;\nexports.b64toutf8 = b64toutf8;\nexports.utf8tohex = utf8tohex;\nexports.hextoutf8 = hextoutf8;\nexports.hextorstr = hextorstr;\nexports.rstrtohex = rstrtohex;\nexports.hextob64 = hextob64;\nexports.hextob64nl = hextob64nl;\nexports.b64nltohex = b64nltohex;\nexports.hextopem = hextopem;\nexports.pemtohex = pemtohex;\nexports.hextoArrayBuffer = hextoArrayBuffer;\nexports.ArrayBuffertohex = ArrayBuffertohex;\nexports.zulutomsec = zulutomsec;\nexports.zulutosec = zulutosec;\nexports.zulutodate = zulutodate;\nexports.datetozulu = datetozulu;\nexports.uricmptohex = uricmptohex;\nexports.hextouricmp = hextouricmp;\nexports.ipv6tohex = ipv6tohex;\nexports.hextoipv6 = hextoipv6;\nexports.hextoip = hextoip;\nexports.iptohex = iptohex;\nexports.encodeURIComponentAll = encodeURIComponentAll;\nexports.newline_toUnix = newline_toUnix;\nexports.newline_toDos = newline_toDos;\nexports.hextoposhex = hextoposhex;\nexports.intarystrtohex = intarystrtohex;\nexports.strdiffidx = strdiffidx;\n\n// name spaces\nexports.KJUR = KJUR;\nexports.crypto = KJUR.crypto;\nexports.asn1 = KJUR.asn1;\nexports.jws = KJUR.jws;\nexports.lang = KJUR.lang;\n\n\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://AppID/./node_modules/jsrsasign/lib/jsrsasign.js?"); + +/***/ }), + +/***/ "./node_modules/node-fetch/browser.js": +/*!********************************************!*\ + !*** ./node_modules/node-fetch/browser.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n// ref: https://github.com/tc39/proposal-global\nvar getGlobal = function () {\n\t// the only reliable means to get the global object is\n\t// `Function('return this')()`\n\t// However, this causes CSP violations in Chrome apps.\n\tif (typeof self !== 'undefined') { return self; }\n\tif (typeof window !== 'undefined') { return window; }\n\tif (typeof global !== 'undefined') { return global; }\n\tthrow new Error('unable to locate global object');\n}\n\nvar global = getGlobal();\n\nmodule.exports = exports = global.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = global.fetch.bind(global);\n\nexports.Headers = global.Headers;\nexports.Request = global.Request;\nexports.Response = global.Response;\n\n//# sourceURL=webpack://AppID/./node_modules/node-fetch/browser.js?"); + +/***/ }), + +/***/ "./node_modules/webpack/buildin/global.js": +/*!***********************************!*\ + !*** (webpack)/buildin/global.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://AppID/(webpack)/buildin/global.js?"); + +/***/ }), + +/***/ "./package.json": +/*!**********************!*\ + !*** ./package.json ***! + \**********************/ +/*! exports provided: name, version, description, scripts, repository, main, nyc, dependencies, devDependencies, default */ +/***/ (function(module) { + +eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"ibmcloud-appid-js\\\",\\\"version\\\":\\\"0.0.2\\\",\\\"description\\\":\\\"IBM Cloud App ID SDK for Single Page Applications\\\",\\\"scripts\\\":{\\\"build\\\":\\\"webpack --mode=development\\\",\\\"test\\\":\\\"mocha\\\",\\\"coverage\\\":\\\"nyc --reporter=lcov mocha\\\",\\\"docs\\\":\\\"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json\\\"},\\\"repository\\\":{\\\"type\\\":\\\"git\\\",\\\"url\\\":\\\"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git\\\"},\\\"main\\\":\\\"dist/appid.umd.min.js\\\",\\\"nyc\\\":{\\\"all\\\":true,\\\"include\\\":[\\\"src/*.js\\\"],\\\"exclude\\\":[\\\"**/PopupController.js\\\",\\\"**/IFrameController.js\\\",\\\"**/OpenIDConfigurationResource.js\\\",\\\"**/constants.js\\\"]},\\\"dependencies\\\":{\\\"jsrsasign\\\":\\\"^8.0.12\\\"},\\\"devDependencies\\\":{\\\"node-fetch\\\":\\\"^2.6.0\\\",\\\"@babel/cli\\\":\\\"^7.0.0\\\",\\\"@babel/core\\\":\\\"^7.5.5\\\",\\\"@babel/plugin-transform-runtime\\\":\\\"^7.5.5\\\",\\\"@babel/preset-env\\\":\\\"^7.5.5\\\",\\\"babel-cli\\\":\\\"^7.0.0-beta.3\\\",\\\"chai\\\":\\\"^4.2.0\\\",\\\"coveralls\\\":\\\"^3.0.6\\\",\\\"gulp-babel\\\":\\\"^8.0.0\\\",\\\"mocha\\\":\\\"^6.2.0\\\",\\\"nyc\\\":\\\"^14.1.1\\\",\\\"webpack\\\":\\\"^4.39.1\\\",\\\"webpack-cli\\\":\\\"^3.3.6\\\",\\\"docdash\\\":\\\"^1.1.1\\\",\\\"jsdoc\\\":\\\"^3.6.3\\\"}}\");\n\n//# sourceURL=webpack://AppID/./package.json?"); + +/***/ }), + +/***/ "./src/IFrameController.js": +/*!*********************************!*\ + !*** ./src/IFrameController.js ***! + \*********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const IFrameError = __webpack_require__(/*! ./errors/IFrameError */ \"./src/errors/IFrameError.js\");\n\nclass IFrameController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t}\n\n\topen(url) {\n\t\tthis.iFrame = this.window.document.createElement('iframe');\n\t\tthis.iFrame.src = url;\n\t\tthis.iFrame.width = 0;\n\t\tthis.iFrame.height = 0;\n\t\tthis.window.document.body.appendChild(this.iFrame);\n\t}\n\n\tremove() {\n\t\twindow.document.body.removeChild(this.iFrame);\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\treject(new IFrameError('Silent sign-in timed out'));\n\t\t\t}, 5 * 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tclearInterval(timer);\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = IFrameController;\n\n\n//# sourceURL=webpack://AppID/./src/IFrameController.js?"); + +/***/ }), + +/***/ "./src/OpenIDConfigurationResource.js": +/*!********************************************!*\ + !*** ./src/OpenIDConfigurationResource.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const packagejson = __webpack_require__(/*! ../package.json */ \"./package.json\");\n\nclass OpenIdConfigurationResource {\n\tasync init({discoveryEndpoint, requestHandler}){\n\t\tthis.openIdConfig = await requestHandler(discoveryEndpoint);\n\t\tconst headers = { 'x-filter-type': `spa:v${packagejson.version}` };\n\t\tthis.publicKeys = requestHandler(this.getJwksEndpoint(), { headers: headers });\n\t}\n\n\tgetAuthorizationEndpoint() {\n\t\treturn this.openIdConfig.authorization_endpoint;\n\t}\n\n\tgetUserInfoEndpoint() {\n\t\treturn this.openIdConfig.userinfo_endpoint;\n\t}\n\n\tgetJwksEndpoint() {\n\t\treturn this.openIdConfig.jwks_uri;\n\t}\n\n\tgetTokenEndpoint() {\n\t\treturn this.openIdConfig.token_endpoint;\n\t}\n\n\tgetIssuer() {\n\t\treturn this.openIdConfig.issuer;\n\t}\n\n\tasync getPublicKeys() {\n\t\treturn await this.publicKeys;\n\t}\n}\nmodule.exports = OpenIdConfigurationResource;\n\n\n\n//# sourceURL=webpack://AppID/./src/OpenIDConfigurationResource.js?"); + +/***/ }), + +/***/ "./src/PopupController.js": +/*!********************************!*\ + !*** ./src/PopupController.js ***! + \********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const PopupError = __webpack_require__(/*! ./errors/PopupError */ \"./src/errors/PopupError.js\");\n\nclass PopupController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t};\n\n\tinit(popupConfig){\n\t\tthis.popupConfig = popupConfig;\n\t}\n\n\topen() {\n\t\tconst h = this.popupConfig.height;\n\t\tconst w = this.popupConfig.width;\n\t\tconst left = (window.screen.width - w) / 2;\n\t\tconst top = (window.screen.height - h) / 2;\n\t\tthis.popup = this.window.open('', 'popup', `left=${left},top=${top},width=${w},height=${h},resizable,scrollbars=yes,status=1`);\n\t\tif (!this.popup) {\n\t\t\tthrow new PopupError('Unable to open popup')\n\t\t}\n\t};\n\n\tnavigate(url) {\n\t\tthis.popup.location.href = url;\n\t};\n\n\tclose() {\n\t\tthis.popup.close();\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\tif(this.popup.closed) {\n\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\treject(new PopupError('Popup closed'));\n\t\t\t\t}\n\t\t\t}, 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = PopupController;\n\n\n//# sourceURL=webpack://AppID/./src/PopupController.js?"); + +/***/ }), + +/***/ "./src/RequestHandler.js": +/*!*******************************!*\ + !*** ./src/RequestHandler.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t}\n\t\t\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tif (text !== '') {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); + +/***/ }), + +/***/ "./src/TokenValidator.js": +/*!*******************************!*\ + !*** ./src/TokenValidator.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg:[constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif (decoded.payloadObj.nonce && decoded.payloadObj.nonce !== nonce) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor(let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); + +/***/ }), + +/***/ "./src/constants.js": +/*!**************************!*\ + !*** ./src/constants.js ***! + \**************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN_PAYLOAD: 'Expect id token payload object to have identities field',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN_PAYLOAD: 'Missing id token payload',\n\tMISSING_TOKENS: 'Missing tokens object',\n\tMISSING_ACCESS_TOKEN: 'Missing access token string',\n\tMISSING_ID_TOKEN: 'Missing access token string',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tGENERATE_CODE: '/cloud_directory/generate_code',\n\tCHANGE_DETAILS: '/cloud_directory/change_details',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); + +/***/ }), + +/***/ "./src/errors/AppIDError.js": +/*!**********************************!*\ + !*** ./src/errors/AppIDError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class AppIDError extends Error {}\nmodule.exports = AppIDError;\n\n//# sourceURL=webpack://AppID/./src/errors/AppIDError.js?"); + +/***/ }), + +/***/ "./src/errors/IFrameError.js": +/*!***********************************!*\ + !*** ./src/errors/IFrameError.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class IFrameError extends Error {}\nmodule.exports = IFrameError;\n\n//# sourceURL=webpack://AppID/./src/errors/IFrameError.js?"); + +/***/ }), + +/***/ "./src/errors/OAuthError.js": +/*!**********************************!*\ + !*** ./src/errors/OAuthError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class OAuthError extends Error {\n\t// See https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for the possible error messages\n\tconstructor({error, description}) {\n\t\tsuper(description || error);\n\t\tthis.error = error;\n\t\tthis.description = description;\n\t}\n}\nmodule.exports = OAuthError;\n\n//# sourceURL=webpack://AppID/./src/errors/OAuthError.js?"); + +/***/ }), + +/***/ "./src/errors/PopupError.js": +/*!**********************************!*\ + !*** ./src/errors/PopupError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class PopupError extends Error {}\nmodule.exports = PopupError;\n\n//# sourceURL=webpack://AppID/./src/errors/PopupError.js?"); + +/***/ }), + +/***/ "./src/errors/RequestError.js": +/*!************************************!*\ + !*** ./src/errors/RequestError.js ***! + \************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class RequestError extends Error {\n\tconstructor(description, status, originError) {\n\t\tsuper(description);\n\t\tthis.status = status;\n\t\tthis.originError = originError;\n\t}\n}\nmodule.exports = RequestError;\n\n//# sourceURL=webpack://AppID/./src/errors/RequestError.js?"); + +/***/ }), + +/***/ "./src/errors/TokenError.js": +/*!**********************************!*\ + !*** ./src/errors/TokenError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class TokenError extends Error {}\nmodule.exports = TokenError;\n\n//# sourceURL=webpack://AppID/./src/errors/TokenError.js?"); + +/***/ }), + +/***/ "./src/index.js": +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in will attempt to authenticate the user in a hidden iframe.\n\t * You will need to enable Cloud Directory SSO.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * @param {string} idTokenPayload The id token payload.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token payload\"\n\t * @example\n\t * let tokens = await appID.changePassword(idTokenPayload);\n\t */\n\tasync changePassword(idTokenPayload) {\n\t\tthis._validateInitalize();\n\t\tlet userId;\n\n\t\tif (!idTokenPayload) {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN_PAYLOAD);\n\t\t}\n\t\tif (typeof idTokenPayload === 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN_PAYLOAD);\n\t\t}\n\t\tif (idTokenPayload.identities && idTokenPayload.identities[0] && idTokenPayload.identities[0].id) {\n\t\t\tif (idTokenPayload.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = idTokenPayload.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN_PAYLOAD);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change details widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {Object} tokens App ID tokens\n\t * @returns {Promise}\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @throws {AppIDError} \"Missing access token string\"\n\t * @throws {AppIDError} \"Missing tokens object\"\n\t * @example\n\t * let tokens = {accessToken, idToken}\n\t * let newTokens = await appID.changeDetails(tokens);\n\t */\n\tasync changeDetails(tokens) {\n\t\tif (!tokens) {\n\t\t\tthrow new AppIDError(constants.MISSING_TOKENS);\n\t\t}\n\n\t\tif (!tokens.accessToken && typeof tokens.accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ACCESS_TOKEN);\n\t\t}\n\n\t\tif (!tokens.idToken && typeof tokens.idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tconst generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE;\n\t\tconst changeDetailsCode = await this.request(generateCodeUrl, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + tokens.accessToken + ' ' + tokens.idToken\n\t\t\t}\n\t\t});\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS;\n\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint,\n\t\t\tchangeDetailsCode\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); + +/***/ }), + +/***/ "./src/utils.js": +/*!**********************!*\ + !*** ./src/utils.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId, changeDetailsCode}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tif (changeDetailsCode) {\n\t\t\tauthParams.code = changeDetailsCode;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint, changeDetailsCode}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint, changeDetailsCode});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); + +/***/ }) + +/******/ }); +}); \ No newline at end of file diff --git a/src/TokenValidator.js b/src/TokenValidator.js index 865b78a..d9a4872 100644 --- a/src/TokenValidator.js +++ b/src/TokenValidator.js @@ -46,9 +46,10 @@ class TokenValidator { if (!decoded.payloadObj.aud.includes(clientId)) { throw new TokenError(constants.INVALID_AUDIENCE); } - - if (decoded.payloadObj.nonce && decoded.payloadObj.nonce !== nonce) { - throw new TokenError(constants.INVALID_NONCE); + if (nonce) { + if (decoded.payloadObj.nonce && decoded.payloadObj.nonce !== nonce) { + throw new TokenError(constants.INVALID_NONCE); + } } return decoded.payloadObj; diff --git a/src/index.js b/src/index.js index bebebb5..4ca84d9 100644 --- a/src/index.js +++ b/src/index.js @@ -169,6 +169,7 @@ class AppID { /** * This method will open a popup to the change password widget for Cloud Directory users. + * You must enable users to manage their account from your app in Cloud Directory settings. * @param {string} idTokenPayload The id token payload. * @returns {Promise} The tokens of the authenticated user. * @throws {AppIDError} "Expect id token payload object to have identities field" @@ -217,7 +218,7 @@ class AppID { * let tokens = {accessToken, idToken} * let newTokens = await appID.changeDetails(tokens); */ - async changeDetails(tokens) { + async changeDetails({accessToken, idToken}) { if (!tokens) { throw new AppIDError(constants.MISSING_TOKENS); } From de433f6ebfb694932e5da7cc580d1cf69df0bd24 Mon Sep 17 00:00:00 2001 From: Joyce Huang Date: Mon, 28 Oct 2019 15:04:08 -0500 Subject: [PATCH 4/9] change signature --- dist/appid.min.js | 385 ++++++++++++++++++++++++++++++++++------ dist/appid.umd.min.js | 395 ++++++++++++++++++++++++++++++++++++------ src/TokenValidator.js | 5 +- src/constants.js | 2 +- src/index.js | 10 +- src/utils.js | 3 +- 6 files changed, 688 insertions(+), 112 deletions(-) diff --git a/dist/appid.min.js b/dist/appid.min.js index 75ab3f3..2bf2d1e 100644 --- a/dist/appid.min.js +++ b/dist/appid.min.js @@ -1,50 +1,335 @@ -var AppID=function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=5)}([function(t,e,i){(function(t){var i={userAgent:!1},n={}; -/*! -Copyright (c) 2011, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.9.0 -*/ -if(void 0===r)var r={};r.lang={extend:function(t,e,n){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),n){var s;for(s in n)t.prototype[s]=n[s];var o=function(){},a=["toString","valueOf"];try{/MSIE/.test(i.userAgent)&&(o=function(t,e){for(s=0;s>>2]>>>24-s%4*8&255;e[n+s>>>2]|=o<<24-(n+s)%4*8}else for(s=0;s>>2]=i[s>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=s.ceil(e/4)},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i>>2]>>>24-r%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new u.init(i,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,i=t.sigBytes,n=[],r=0;r>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new u.init(i,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},g=a.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,n=e.sigBytes,r=this.blockSize,o=n/(4*r),a=(o=t?s.ceil(o):s.max((0|o)-this._minBufferSize,0))*r,h=s.min(4*a,n);if(a){for(var c=0;c>>2]}},e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:h,padding:c}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(h=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?n.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=n.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:i})}},e.SerializableCipher=i.extend({cfg:i.extend({format:h}),encrypt:function(t,e,i,n){n=this.cfg.extend(n);var r=t.createEncryptor(i,n);return e=r.finalize(e),r=r.cfg,l.create({ciphertext:e,key:i,iv:r.iv,algorithm:t,mode:r.mode,padding:r.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(i,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,i,r){return r||(r=n.random(8)),t=o.create({keySize:e+i}).compute(t,r),i=n.create(t.words.slice(e),4*i),t.sigBytes=4*e,l.create({key:t,iv:i,salt:r})}},g=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:d}),encrypt:function(t,e,i,n){return i=(n=this.cfg.extend(n)).kdf.execute(i,t.keySize,t.ivSize),n.iv=i.iv,(t=f.encrypt.call(this,t,e,i.key,n)).mixIn(i),t},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),i=n.kdf.execute(i,t.keySize,t.ivSize,e.salt),n.iv=i.iv,f.decrypt.call(this,t,e,i.key,n)}})}(),function(){for(var t=y,e=t.lib.BlockCipher,i=t.algo,n=[],r=[],s=[],o=[],a=[],h=[],u=[],c=[],l=[],f=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var p=0,v=0;for(g=0;256>g;g++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;n[p]=m,r[m]=p;var S=d[p],F=d[S],w=d[F],E=257*d[m]^16843008*m;s[p]=E<<24|E>>>8,o[p]=E<<16|E>>>16,a[p]=E<<8|E>>>24,h[p]=E,E=16843009*w^65537*F^257*S^16843008*p,u[m]=E<<24|E>>>8,c[m]=E<<16|E>>>16,l[m]=E<<8|E>>>24,f[m]=E,p?(p=S^d[d[d[w^S]]],v^=d[d[v]]):p=v=1}var x=[0,1,2,4,8,16,32,64,128,27,54];i=i.AES=e.extend({_doReset:function(){for(var t=(i=this._key).words,e=i.sigBytes/4,i=4*((this._nRounds=e+6)+1),r=this._keySchedule=[],s=0;s>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o]):(o=n[(o=o<<8|o>>>24)>>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o],o^=x[s/e|0]<<24),r[s]=r[s-e]^o}for(t=this._invKeySchedule=[],e=0;ee||4>=s?o:u[n[o>>>24]]^c[n[o>>>16&255]]^l[n[o>>>8&255]]^f[n[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,o,a,h,n)},decryptBlock:function(t,e){var i=t[e+1];t[e+1]=t[e+3],t[e+3]=i,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,r),i=t[e+1],t[e+1]=t[e+3],t[e+3]=i},_doCryptBlock:function(t,e,i,n,r,s,o,a){for(var h=this._nRounds,u=t[e]^i[0],c=t[e+1]^i[1],l=t[e+2]^i[2],f=t[e+3]^i[3],d=4,g=1;g>>24]^r[c>>>16&255]^s[l>>>8&255]^o[255&f]^i[d++],y=n[c>>>24]^r[l>>>16&255]^s[f>>>8&255]^o[255&u]^i[d++],v=n[l>>>24]^r[f>>>16&255]^s[u>>>8&255]^o[255&c]^i[d++];f=n[f>>>24]^r[u>>>16&255]^s[c>>>8&255]^o[255&l]^i[d++],u=p,c=y,l=v}p=(a[u>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&f])^i[d++],y=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[f>>>8&255]<<8|a[255&u])^i[d++],v=(a[l>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[255&c])^i[d++],f=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^i[d++],t[e]=p,t[e+1]=y,t[e+2]=v,t[e+3]=f},keySize:8});t.AES=e._createHelper(i)}(),function(){function t(t,e){var i=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=i,this._lBlock^=i<>>t^this._lBlock)&e;this._lBlock^=i,this._rBlock^=i<i;i++){var n=o[i]-1;e[i]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;16>n;n++){var r=t[n]=[],s=h[n];for(i=0;24>i;i++)r[i/6|0]|=e[(a[i]-1+s)%28]<<31-i%6,r[4+(i/6|0)]|=e[28+(a[i+24]-1+s)%28]<<31-i%6;for(r[0]=r[0]<<1|r[0]>>>31,i=1;7>i;i++)r[i]>>>=4*(i-1)+3;r[7]=r[7]<<5|r[7]>>>27}for(e=this._invSubKeys=[],i=0;16>i;i++)e[i]=t[15-i]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(i,n,r){this._lBlock=i[n],this._rBlock=i[n+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var o=r[s],a=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^o[f])&c[f])>>>0];this._lBlock=h,this._rBlock=a^l}r=this._lBlock,this._lBlock=this._rBlock,this._rBlock=r,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),i[n]=this._lBlock,i[n+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});i.DES=r._createHelper(l),s=s.TripleDES=r.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(n.create(t.slice(0,2))),this._des2=l.createEncryptor(n.create(t.slice(2,4))),this._des3=l.createEncryptor(n.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),i.TripleDES=r._createHelper(s)}(),function(){var t=y,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,i=t.sigBytes,n=this._map;t.clamp(),t=[];for(var r=0;r>>2]>>>24-r%4*8&255)<<16|(e[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|e[r+2>>>2]>>>24-(r+2)%4*8&255,o=0;4>o&&r+.75*o>>6*(3-o)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var i=t.length,n=this._map;(r=n.charAt(64))&&(-1!=(r=t.indexOf(r))&&(i=r));for(var r=[],s=0,o=0;o>>6-o%4*2;r[s>>>2]|=(a|h)<<24-s%4*8,s++}return e.create(r,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,i,n,r,s,o){return((t=t+(e&i|~e&n)+r+o)<>>32-s)+e}function i(t,e,i,n,r,s,o){return((t=t+(e&n|i&~n)+r+o)<>>32-s)+e}function n(t,e,i,n,r,s,o){return((t=t+(e^i^n)+r+o)<>>32-s)+e}function r(t,e,i,n,r,s,o){return((t=t+(i^(e|~n))+r+o)<>>32-s)+e}for(var s=y,o=(h=s.lib).WordArray,a=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var o=0;16>o;o++){var a=t[h=s+o];t[h]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var h=t[s+0],c=(a=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],d=t[s+5],g=t[s+6],p=t[s+7],y=t[s+8],v=t[s+9],m=t[s+10],S=t[s+11],F=t[s+12],w=t[s+13],E=t[s+14],x=t[s+15],b=e(b=o[0],C=o[1],I=o[2],A=o[3],h,7,u[0]),A=e(A,b,C,I,a,12,u[1]),I=e(I,A,b,C,c,17,u[2]),C=e(C,I,A,b,l,22,u[3]);b=e(b,C,I,A,f,7,u[4]),A=e(A,b,C,I,d,12,u[5]),I=e(I,A,b,C,g,17,u[6]),C=e(C,I,A,b,p,22,u[7]),b=e(b,C,I,A,y,7,u[8]),A=e(A,b,C,I,v,12,u[9]),I=e(I,A,b,C,m,17,u[10]),C=e(C,I,A,b,S,22,u[11]),b=e(b,C,I,A,F,7,u[12]),A=e(A,b,C,I,w,12,u[13]),I=e(I,A,b,C,E,17,u[14]),b=i(b,C=e(C,I,A,b,x,22,u[15]),I,A,a,5,u[16]),A=i(A,b,C,I,g,9,u[17]),I=i(I,A,b,C,S,14,u[18]),C=i(C,I,A,b,h,20,u[19]),b=i(b,C,I,A,d,5,u[20]),A=i(A,b,C,I,m,9,u[21]),I=i(I,A,b,C,x,14,u[22]),C=i(C,I,A,b,f,20,u[23]),b=i(b,C,I,A,v,5,u[24]),A=i(A,b,C,I,E,9,u[25]),I=i(I,A,b,C,l,14,u[26]),C=i(C,I,A,b,y,20,u[27]),b=i(b,C,I,A,w,5,u[28]),A=i(A,b,C,I,c,9,u[29]),I=i(I,A,b,C,p,14,u[30]),b=n(b,C=i(C,I,A,b,F,20,u[31]),I,A,d,4,u[32]),A=n(A,b,C,I,y,11,u[33]),I=n(I,A,b,C,S,16,u[34]),C=n(C,I,A,b,E,23,u[35]),b=n(b,C,I,A,a,4,u[36]),A=n(A,b,C,I,f,11,u[37]),I=n(I,A,b,C,p,16,u[38]),C=n(C,I,A,b,m,23,u[39]),b=n(b,C,I,A,w,4,u[40]),A=n(A,b,C,I,h,11,u[41]),I=n(I,A,b,C,l,16,u[42]),C=n(C,I,A,b,g,23,u[43]),b=n(b,C,I,A,v,4,u[44]),A=n(A,b,C,I,F,11,u[45]),I=n(I,A,b,C,x,16,u[46]),b=r(b,C=n(C,I,A,b,c,23,u[47]),I,A,h,6,u[48]),A=r(A,b,C,I,p,10,u[49]),I=r(I,A,b,C,E,15,u[50]),C=r(C,I,A,b,d,21,u[51]),b=r(b,C,I,A,F,6,u[52]),A=r(A,b,C,I,l,10,u[53]),I=r(I,A,b,C,m,15,u[54]),C=r(C,I,A,b,a,21,u[55]),b=r(b,C,I,A,y,6,u[56]),A=r(A,b,C,I,x,10,u[57]),I=r(I,A,b,C,g,15,u[58]),C=r(C,I,A,b,w,21,u[59]),b=r(b,C,I,A,f,6,u[60]),A=r(A,b,C,I,S,10,u[61]),I=r(I,A,b,C,c,15,u[62]),C=r(C,I,A,b,v,21,u[63]);o[0]=o[0]+b|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+A|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;i[r>>>5]|=128<<24-r%32;var s=t.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(i.length+1),this._process(),i=(e=this._hash).words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=a._createHelper(h),s.HmacMD5=a._createHmacHelper(h)}(Math),function(){var t=y,e=(r=t.lib).WordArray,i=r.Hasher,n=[],r=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=this._hash.words,r=i[0],s=i[1],o=i[2],a=i[3],h=i[4],u=0;80>u;u++){if(16>u)n[u]=0|t[e+u];else{var c=n[u-3]^n[u-8]^n[u-14]^n[u-16];n[u]=c<<1|c>>>31}c=(r<<5|r>>>27)+h+n[u],c=20>u?c+(1518500249+(s&o|~s&a)):40>u?c+(1859775393+(s^o^a)):60>u?c+((s&o|s&a|o&a)-1894007588):c+((s^o^a)-899497514),h=a,a=o,o=s<<30|s>>>2,s=r,r=c}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+o|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(i/4294967296),e[15+(n+64>>>9<<4)]=i,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=i._createHelper(r),t.HmacSHA1=i._createHmacHelper(r)}(),function(t){for(var e=y,i=(r=e.lib).WordArray,n=r.Hasher,r=e.algo,s=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=a(t.pow(h,.5))),o[u]=a(t.pow(h,1/3)),u++),h++}var d=[];r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(t,e){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],a=i[3],h=i[4],u=i[5],c=i[6],l=i[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var g=d[f-15],p=d[f-2];d[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[f-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[f-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+o[f]+d[f],p=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&r^n&s^r&s),l=c,c=u,u=h,h=a+g|0,a=s,s=r,r=n,n=g+p|0}i[0]=i[0]+n|0,i[1]=i[1]+r|0,i[2]=i[2]+s|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0,i[5]=i[5]+u|0,i[6]=i[6]+c|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return i[r>>>5]|=128<<24-r%32,i[14+(r+64>>>9<<4)]=t.floor(n/4294967296),i[15+(r+64>>>9<<4)]=n,e.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(r),e.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var t=y,e=t.lib.WordArray,i=(n=t.algo).SHA256,n=n.SHA224=i.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=i._createHelper(n),t.HmacSHA224=i._createHmacHelper(n)}(),function(){function t(){return n.create.apply(n,arguments)}for(var e=y,i=e.lib.Hasher,n=(s=e.x64).Word,r=s.WordArray,s=e.algo,o=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],a=[],h=0;80>h;h++)a[h]=t();s=s.SHA512=i.extend({_doReset:function(){this._hash=new r.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var i=(l=this._hash.words)[0],n=l[1],r=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=i.high,d=i.low,g=n.high,p=n.low,y=r.high,v=r.low,m=s.high,S=s.low,F=h.high,w=h.low,E=u.high,x=u.low,b=c.high,A=c.low,I=l.high,C=l.low,D=f,T=d,P=g,R=p,H=y,B=v,N=m,O=S,j=F,V=w,L=E,_=x,K=b,k=A,M=I,U=C,q=0;80>q;q++){var z=a[q];if(16>q)var G=z.high=0|t[e+2*q],Y=z.low=0|t[e+2*q+1];else{G=((Y=(G=a[q-15]).high)>>>1|(J=G.low)<<31)^(Y>>>8|J<<24)^Y>>>7;var J=(J>>>1|Y<<31)^(J>>>8|Y<<24)^(J>>>7|Y<<25),W=((Y=(W=a[q-2]).high)>>>19|(X=W.low)<<13)^(Y<<3|X>>>29)^Y>>>6,X=(X>>>19|Y<<13)^(X<<3|Y>>>29)^(X>>>6|Y<<26),Z=(Y=a[q-7]).high,$=(Q=a[q-16]).high,Q=Q.low;G=(G=(G=G+Z+((Y=J+Y.low)>>>0>>0?1:0))+W+((Y=Y+X)>>>0>>0?1:0))+$+((Y=Y+Q)>>>0>>0?1:0);z.high=G,z.low=Y}Z=j&L^~j&K,Q=V&_^~V&k,z=D&P^D&H^P&H;var tt=T&R^T&B^R&B,et=(J=(D>>>28|T<<4)^(D<<30|T>>>2)^(D<<25|T>>>7),W=(T>>>28|D<<4)^(T<<30|D>>>2)^(T<<25|D>>>7),(X=o[q]).high),it=X.low;$=M+((j>>>14|V<<18)^(j>>>18|V<<14)^(j<<23|V>>>9))+((X=U+((V>>>14|j<<18)^(V>>>18|j<<14)^(V<<23|j>>>9)))>>>0>>0?1:0),M=K,U=k,K=L,k=_,L=j,_=V,j=N+($=($=($=$+Z+((X=X+Q)>>>0>>0?1:0))+et+((X=X+it)>>>0>>0?1:0))+G+((X=X+Y)>>>0>>0?1:0))+((V=O+X|0)>>>0>>0?1:0)|0,N=H,O=B,H=P,B=R,P=D,R=T,D=$+(z=J+z+((Y=W+tt)>>>0>>0?1:0))+((T=X+Y|0)>>>0>>0?1:0)|0}d=i.low=d+T,i.high=f+D+(d>>>0>>0?1:0),p=n.low=p+R,n.high=g+P+(p>>>0>>0?1:0),v=r.low=v+B,r.high=y+H+(v>>>0>>0?1:0),S=s.low=S+O,s.high=m+N+(S>>>0>>0?1:0),w=h.low=w+V,h.high=F+j+(w>>>0>>0?1:0),x=u.low=x+_,u.high=E+L+(x>>>0<_>>>0?1:0),A=c.low=A+k,c.high=b+K+(A>>>0>>0?1:0),C=l.low=C+U,l.high=I+M+(C>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(i/4294967296),e[31+(n+128>>>10<<5)]=i,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=i._createHelper(s),e.HmacSHA512=i._createHmacHelper(s)}(),function(){var t=y,e=(r=t.x64).Word,i=r.WordArray,n=(r=t.algo).SHA512,r=r.SHA384=n.extend({_doReset:function(){this._hash=new i.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(r),t.HmacSHA384=n._createHmacHelper(r)}(),function(){var t=y,e=(n=t.lib).WordArray,i=n.Hasher,n=t.algo,r=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),o=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);n=n.RIPEMD160=i.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=0;16>i;i++){var n=t[F=e+i];t[F]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var c,l,f,d,g,p,y,v,m,S,F=this._hash.words,w=(n=h.words,u.words),E=r.words,x=s.words,b=o.words,A=a.words;p=c=F[0],y=l=F[1],v=f=F[2],m=d=F[3],S=g=F[4];var I;for(i=0;80>i;i+=1)I=c+t[e+E[i]]|0,I=16>i?I+((l^f^d)+n[0]):32>i?I+((l&f|~l&d)+n[1]):48>i?I+(((l|~f)^d)+n[2]):64>i?I+((l&d|f&~d)+n[3]):I+((l^(f|~d))+n[4]),I=(I=(I|=0)<>>32-b[i])+g|0,c=g,g=d,d=f<<10|f>>>22,f=l,l=I,I=p+t[e+x[i]]|0,I=16>i?I+((y^(v|~m))+w[0]):32>i?I+((y&m|v&~m)+w[1]):48>i?I+(((y|~v)^m)+w[2]):64>i?I+((y&v|~y&m)+w[3]):I+((y^v^m)+w[4]),I=(I=(I|=0)<>>32-A[i])+S|0,p=S,S=m,m=v<<10|v>>>22,v=y,y=I;I=F[1]+f+m|0,F[1]=F[2]+d+S|0,F[2]=F[3]+g+p|0,F[3]=F[4]+c+y|0,F[4]=F[0]+l+v|0,F[0]=I},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,i=0;5>i;i++)n=e[i],e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(n),t.HmacRIPEMD160=i._createHmacHelper(n)}(Math),function(){var t=y,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,i){t=this._hasher=new t.init,"string"==typeof i&&(i=e.parse(i));var n=t.blockSize,r=4*n;i.sigBytes>r&&(i=t.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),o=this._iKey=i.clone(),a=s.words,h=o.words,u=0;u>6)+m.charAt(63&i);if(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),n+=m.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),n+=m.charAt(i>>2)+m.charAt((3&i)<<4)),S)for(;(3&n.length)>0;)n+=S;return n}function w(t){var e,i,n,r="",s=0;for(e=0;e>2),i=3&n,s=1):1==s?(r+=T(i<<2|n>>4),i=15&n,s=2):2==s?(r+=T(i),r+=T(n>>2),i=3&n,s=3):(r+=T(i<<2|n>>4),r+=T(15&n),s=0));return 1==s&&(r+=T(i<<2)),r}function E(t){var e,i=w(t),n=new Array;for(e=0;2*e>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;r=((h=o*h+((32767&c)<<15)+i[n]+(1073741823&r))>>>30)+(c>>>15)+a*u+(r>>>30),i[n++]=1073741823&h}return r},v=30):"Netscape"!=i.appName?(x.prototype.am=function(t,e,i,n,r,s){for(;--s>=0;){var o=e*this[t++]+i[n]+r;r=Math.floor(o/67108864),i[n++]=67108863&o}return r},v=26):(x.prototype.am=function(t,e,i,n,r,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;r=((h=o*h+((16383&c)<<14)+i[n]+r)>>28)+(c>>14)+a*u,i[n++]=268435455&h}return r},v=28),x.prototype.DB=v,x.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function B(t){this.m=t}function N(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function K(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function k(){}function M(t){return t}function U(t){this.r2=b(),this.q3=b(),x.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}B.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},B.prototype.revert=function(t){return t},B.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},B.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},B.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},N.prototype.convert=function(t){var e=b();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(x.ZERO)>0&&this.m.subTo(e,e),e},N.prototype.revert=function(t){var e=b();return t.copyTo(e),this.reduce(e),e},N.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},N.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},N.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},x.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},x.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},x.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,r=!1,s=0;--n>=0;){var o=8==i?255&t[n]:P(t,n);o<0?"-"==t.charAt(n)&&(r=!0):(r=!1,0==s?this[this.t++]=o:s+i>this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},x.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},x.prototype.drShiftTo=function(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>r|a,a=(this[i]&s)<=0;--i)e[i]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},x.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,r=this.DB-n,s=(1<>n;for(var o=i+1;o>n;n>0&&(e[this.t-i-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},x.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),r=i.t;for(e.t=r+n.t;--r>=0;)e[r]=0;for(r=0;r=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},x.prototype.divRemTo=function(t,e,i){var n=t.abs();if(!(n.t<=0)){var r=this.abs();if(r.t0?(n.lShiftTo(h,s),r.lShiftTo(h,i)):(n.copyTo(s),r.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<1?s[u-2]>>this.F2:0),f=this.FV/l,d=(1<=0&&(i[i.t++]=1,i.subTo(v,i)),x.ONE.dlShiftTo(u,v),v.subTo(s,s);s.t=0;){var m=i[--p]==c?this.DM:Math.floor(i[p]*f+(i[p-1]+g)*d);if((i[p]+=s.am(0,m,i,y,0,u))0&&i.rShiftTo(h,i),o<0&&x.ZERO.subTo(i,i)}}},x.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},x.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},x.prototype.exp=function(t,e){if(t>4294967295||t<1)return x.ONE;var i=b(),n=b(),r=e.convert(this),s=H(t)-1;for(r.copyTo(i);--s>=0;)if(e.sqrTo(i,n),(t&1<0)e.mulTo(n,r,i);else{var o=i;i=n,n=o}return e.revert(i)},x.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<0)for(a>a)>0&&(r=!0,s=T(i));o>=0;)a>(a+=this.DB-e)):(i=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),i>0&&(r=!0),r&&(s+=T(i));return r?s:"0"},x.prototype.negate=function(){var t=b();return x.ZERO.subTo(this,t),t},x.prototype.abs=function(){return this.s<0?this.negate():this},x.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},x.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+H(this[this.t-1]^this.s&this.DM)},x.prototype.mod=function(t){var e=b();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(x.ZERO)>0&&t.subTo(e,e),e},x.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new B(e):new N(e),this.exp(t,i)},x.ZERO=R(0),x.ONE=R(1),k.prototype.convert=M,k.prototype.revert=M,k.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},k.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=b();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var q=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],z=(1<<26)/q[q.length-1]; -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function G(){this.i=0,this.j=0,this.S=new Array}x.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},x.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),n=R(i),r=b(),s=b(),o="";for(this.divRemTo(n,r,s);r.signum()>0;)o=(i+s.intValue()).toString(t).substr(1)+o,r.divRemTo(n,r,s);return s.intValue().toString(t)+o},x.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),r=!1,s=0,o=0,a=0;a=i&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),r&&x.ZERO.subTo(this,this)},x.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(x.ONE.shiftLeft(t-1),j,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(x.ONE.shiftLeft(t-1),this);else{var n=new Array,r=7&t;n.length=1+(t>>3),e.nextBytes(n),r>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},x.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},x.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},x.prototype.multiplyLowerTo=function(t,e,i){var n,r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r=0;)i[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},x.prototype.millerRabin=function(t){var e=this.subtract(x.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var n=e.shiftRight(i);(t=t+1>>1)>q.length&&(t=q.length);for(var r=b(),s=0;s>24},x.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},x.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},x.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,r=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[r++]=i|this.s<=0;)n<8?(i=(this[t]&(1<>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(e[r++]=i);return e},x.prototype.equals=function(t){return 0==this.compareTo(t)},x.prototype.min=function(t){return this.compareTo(t)<0?this:t},x.prototype.max=function(t){return this.compareTo(t)>0?this:t},x.prototype.and=function(t){var e=b();return this.bitwiseTo(t,O,e),e},x.prototype.or=function(t){var e=b();return this.bitwiseTo(t,j,e),e},x.prototype.xor=function(t){var e=b();return this.bitwiseTo(t,V,e),e},x.prototype.andNot=function(t){var e=b();return this.bitwiseTo(t,L,e),e},x.prototype.not=function(){for(var t=b(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var c=b();for(n.sqrTo(o[1],c);a<=u;)o[a]=b(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,d=t.t-1,g=!0,p=b();for(r=H(t[d])-1;d>=0;){for(r>=h?l=t[d]>>r-h&u:(l=(t[d]&(1<0&&(l|=t[d-1]>>this.DB+r-h)),a=i;0==(1&l);)l>>=1,--a;if((r-=a)<0&&(r+=this.DB,--d),g)o[l].copyTo(s),g=!1;else{for(;a>1;)n.sqrTo(s,p),n.sqrTo(p,s),a-=2;a>0?n.sqrTo(s,p):(f=s,s=p,p=f),n.mulTo(p,o[l],s)}for(;d>=0&&0==(t[d]&1<=0?(i.subTo(n,i),e&&r.subTo(o,r),s.subTo(a,s)):(n.subTo(i,n),e&&o.subTo(r,o),a.subTo(s,a))}return 0!=n.compareTo(x.ONE)?x.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},x.prototype.pow=function(t){return this.exp(t,new k)},x.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var r=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(r0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(r=e.getLowestSetBit())>0&&e.rShiftTo(r,e),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},x.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=q[q.length-1]){for(e=0;e>8&255,J[W++]^=t>>16&255,J[W++]^=t>>24&255,W>=X&&(W-=X)}((new Date).getTime())}if(null==J){var $;if(J=new Array,W=0,void 0!==n&&(void 0!==n.crypto||void 0!==n.msCrypto)){var Q=n.crypto||n.msCrypto;if(Q.getRandomValues){var tt=new Uint8Array(32);for(Q.getRandomValues(tt),$=0;$<32;++$)J[W++]=tt[$]}else if("Netscape"==i.appName&&i.appVersion<"5"){var et=n.crypto.random(32);for($=0;$>>8,J[W++]=255&$;W=0,Z()}function it(){if(null==Y){for(Z(),(Y=new G).init(J),W=0;W>24,(16711680&r)>>16,(65280&r)>>8,255&r]))),r+=1;return n}function ot(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function at(t,e,i){for(var n="",r=0;n.length>24,(16711680&r)>>16,(65280&r)>>8,255&r])),r+=1;return n} -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function ht(t,e){this.x=e,this.q=t}function ut(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?x.ONE:n,this.zinv=null}function ct(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new ut(this,null,null)}nt.prototype.nextBytes=function(t){var e;for(e=0;e0&&e.length>0))throw"Invalid RSA public key";this.n=rt(t,16),this.e=parseInt(e,16)}},ot.prototype.encrypt=function(t){var e=function(t,e){if(e=0&&e>0;){var r=t.charCodeAt(n--);r<128?i[--e]=r:r>127&&r<2048?(i[--e]=63&r|128,i[--e]=r>>6|192):(i[--e]=63&r|128,i[--e]=r>>6&63|128,i[--e]=r>>12|224)}i[--e]=0;for(var s=new nt,o=new Array;e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new x(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var n=i.toString(16);return 0==(1&n.length)?n:"0"+n},ot.prototype.encryptOAEP=function(t,e,i){var n=function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;if(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t.length+2*n+2>e)throw"Message too long for RSA";var a,h="";for(a=0;a>3,e,i);if(null==n)return null;var r=this.doPublic(n);if(null==r)return null;var s=r.toString(16);return 0==(1&s.length)?s:"0"+s},ot.prototype.type="RSA",ot.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},ot.prototype.setPrivate=function(t,e,i){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=i;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16)}},ot.prototype.setPrivateEx=function(t,e,i,n,r,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16),this.p=rt(n,16),this.q=rt(r,16),this.dmp1=rt(s,16),this.dmq1=rt(o,16),this.coeff=rt(a,16)},ot.prototype.generate=function(t,e){var i=new nt,n=t>>1;this.e=parseInt(e,16);for(var r=new x(e,16);;){for(;this.p=new x(t-n,1,i),0!=this.p.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.p.isProbablePrime(10););for(;this.q=new x(n,1,i),0!=this.q.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(x.ONE),a=this.q.subtract(x.ONE),h=o.multiply(a);if(0==h.gcd(r).compareTo(x.ONE)){this.n=this.p.multiply(this.q),this.d=r.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},ot.prototype.decrypt=function(t){var e=rt(t,16),i=this.doPrivate(e);return null==i?null: -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function(t,e){for(var i=t.toByteArray(),n=0;n=i.length)return null;for(var r="";++n191&&s<224?(r+=String.fromCharCode((31&s)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&s)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},ot.prototype.decryptOAEP=function(t,e,i){var n=rt(t,16),r=this.doPrivate(n);return null==r?null:function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;for(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t=t.toByteArray(),a=0;a>3,e,i)},ht.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ht.prototype.toBigInteger=function(){return this.x},ht.prototype.negate=function(){return new ht(this.q,this.x.negate().mod(this.q))},ht.prototype.add=function(t){return new ht(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ht.prototype.subtract=function(t){return new ht(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ht.prototype.multiply=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ht.prototype.square=function(){return new ht(this.q,this.x.square().mod(this.q))},ht.prototype.divide=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ut.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO))},ut.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(x.ZERO)&&!this.y.toBigInteger().equals(x.ZERO)},ut.prototype.negate=function(){return new ut(this.curve,this.x,this.y.negate(),this.z)},ut.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),i=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(x.ZERO.equals(i))return x.ZERO.equals(e)?this.twice():this.curve.getInfinity();var n=new x("3"),r=this.x.toBigInteger(),s=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),i.square()),a=o.multiply(i),h=r.multiply(o),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(a).multiply(i).mod(this.curve.q),l=h.multiply(n).multiply(e).subtract(s.multiply(a)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),f=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},ut.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new x("3"),e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=i.multiply(this.z),r=n.multiply(i).mod(this.curve.q),s=this.curve.a.toBigInteger(),o=e.square().multiply(t);x.ZERO.equals(s)||(o=o.add(this.z.square().multiply(s)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(r)).shiftLeft(1).multiply(n).mod(this.curve.q),h=o.multiply(t).multiply(e).subtract(r.shiftLeft(1)).shiftLeft(2).multiply(r).subtract(o.square().multiply(o)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),u)},ut.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add(o?this:r))}return s},ut.prototype.multiplyTwo=function(t,e,i){var n;n=t.bitLength()>i.bitLength()?t.bitLength()-1:i.bitLength()-1;for(var r=this.curve.getInfinity(),s=this.add(e);n>=0;)r=r.twice(),t.testBit(n)?r=i.testBit(n)?r.add(s):r.add(this):i.testBit(n)&&(r=r.add(e)),--n;return r},ct.prototype.getQ=function(){return this.q},ct.prototype.getA=function(){return this.a},ct.prototype.getB=function(){return this.b},ct.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ct.prototype.getInfinity=function(){return this.infinity},ct.prototype.fromBigInteger=function(t){return new ht(this.q,t)},ct.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,i=t.substr(2,e),n=t.substr(e+2,e);return new ut(this,this.fromBigInteger(new x(i,16)),this.fromBigInteger(new x(n,16)));default:return null}}, -/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib - */ -ht.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ut.prototype.getEncoded=function(t){var e=function(t,e){var i=t.toByteArrayUnsigned();if(ei.length;)i.unshift(0);return i},i=this.getX().toBigInteger(),n=this.getY().toBigInteger(),r=e(i,32);return t?n.isEven()?r.unshift(2):r.unshift(3):(r.unshift(4),r=r.concat(e(n,32))),r},ut.decodeFrom=function(t,e){e[0];var i=e.length-1,n=e.slice(1,1+i/2),r=e.slice(1+i/2,1+i);n.unshift(0),r.unshift(0);var s=new x(n),o=new x(r);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.decodeFromHex=function(t,e){e.substr(0,2);var i=e.length-2,n=e.substr(2,i/2),r=e.substr(2+i/2,i/2),s=new x(n,16),o=new x(r,16);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),i=t.y.subtract(this.y).divide(e),n=i.square().subtract(this.x).subtract(t.x),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(x.valueOf(2)),e=this.curve.fromBigInteger(x.valueOf(3)),i=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=i.square().subtract(this.x.multiply(t)),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add2D(o?this:r))}return s},ut.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),i=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),r=this.curve.getQ(),s=e.multiply(e).mod(r),o=t.multiply(t).multiply(t).add(i.multiply(t)).add(n).mod(r);return s.equals(o)},ut.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ut.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),i=this.getY().toBigInteger();if(e.compareTo(x.ONE)<0||e.compareTo(t.subtract(x.ONE))>0)throw new Error("x coordinate out of bounds");if(i.compareTo(x.ONE)<0||i.compareTo(t.subtract(x.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0}; -/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval - */ -var lt=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),i={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,n){return e?i[e]:String.fromCharCode(parseInt(n,16))}var r=new String(""),s=(Object,Array,Object.hasOwnProperty);return function(i,o){var a,h,u=i.match(t),c=u[0],l=!1;"{"===c?a={}:"["===c?a=[]:(a=[],l=!0);for(var f=[a],d=1-l,g=u.length;d=0;)delete i[n[h]]}return o.call(t,e,i)};a=y({"":a},"")}return a}}();void 0!==ft&&ft||(ft={}),void 0!==ft.asn1&&ft.asn1||(ft.asn1={}),ft.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},ft.asn1.DERAbstractString=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=bt(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},r.lang.extend(ft.asn1.DERAbstractString,ft.asn1.ASN1Object),ft.asn1.DERAbstractTime=function(t){ft.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var n=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var h=n(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=St(t)},this.setByDateValue=function(t,e,i,n,r,s){var o=new Date(Date.UTC(t,e-1,i,n,r,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},r.lang.extend(ft.asn1.DERAbstractTime,ft.asn1.ASN1Object),ft.asn1.DERAbstractStructured=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},r.lang.extend(ft.asn1.DERAbstractStructured,ft.asn1.ASN1Object),ft.asn1.DERBoolean=function(){ft.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},r.lang.extend(ft.asn1.DERBoolean,ft.asn1.ASN1Object),ft.asn1.DERInteger=function(t){ft.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ft.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},r.lang.extend(ft.asn1.DERInteger,ft.asn1.ASN1Object),ft.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ft.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}ft.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7r.length&&(r=n[i]);return(t=t.replace(r,"::")).slice(1,-1)}function _t(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?Lt(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function Kt(t){for(var e=encodeURIComponent(t),i="",n=0;n"7"?"00"+t:t}function Mt(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,i){var n=parseInt(t);if(n<0||255=2*s)break;if(a>=200)break;n.push(h),o=h,a++}return n},pt.getNthChildIdx=function(t,e,i){return pt.getChildIdx(t,e)[i]},pt.getIdxbyList=function(t,e,i,n){var r,s,o=pt;if(0==i.length){if(void 0!==n&&t.substr(e,2)!==n)throw"checking tag doesn't match: "+t.substr(e,2)+"!="+n;return e}return r=i.shift(),s=o.getChildIdx(t,e),o.getIdxbyList(t,s[r],i,n)},pt.getTLVbyList=function(t,e,i,n){var r=pt,s=r.getIdxbyList(t,e,i);if(void 0===s)throw"can't find nthList object";if(void 0!==n&&t.substr(s,2)!=n)throw"checking tag doesn't match: "+t.substr(s,2)+"!="+n;return r.getTLV(t,s)},pt.getVbyList=function(t,e,i,n,r){var s,o,a=pt;if(void 0===(s=a.getIdxbyList(t,e,i,n)))throw"can't find nthList object";return o=a.getV(t,s),!0===r&&(o=o.substr(2)),o},pt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},i=[],n=t.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var s=t.substr(2),o=[],a=0;a0&&(c=c+"."+h.join(".")),c},pt.dump=function(t,e,i,n){var r=pt,s=r.getV,o=r.dump,a=r.getChildIdx,h=t;t instanceof ft.asn1.ASN1Object&&(h=t.getEncodedHex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var c=e.ommit_long_octet;if("01"==h.substr(i,2))return"00"==(l=s(h,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==h.substr(i,2))return n+"INTEGER "+u(l=s(h,i),c)+"\n";if("03"==h.substr(i,2))return n+"BITSTRING "+u(l=s(h,i),c)+"\n";if("04"==h.substr(i,2)){var l=s(h,i);if(r.isASN1HEX(l)){var f=n+"OCTETSTRING, encapsulates\n";return f+=o(l,e,0,n+" ")}return n+"OCTETSTRING "+u(l,c)+"\n"}if("05"==h.substr(i,2))return n+"NULL\n";if("06"==h.substr(i,2)){var d=s(h,i),g=ft.asn1.ASN1Util.oidHexToInt(d),p=ft.asn1.x509.OID.oid2name(g),y=g.replace(/\./g," ");return""!=p?n+"ObjectIdentifier "+p+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0c"==h.substr(i,2))return n+"UTF8String '"+At(s(h,i))+"'\n";if("13"==h.substr(i,2))return n+"PrintableString '"+At(s(h,i))+"'\n";if("14"==h.substr(i,2))return n+"TeletexString '"+At(s(h,i))+"'\n";if("16"==h.substr(i,2))return n+"IA5String '"+At(s(h,i))+"'\n";if("17"==h.substr(i,2))return n+"UTCTime "+At(s(h,i))+"\n";if("18"==h.substr(i,2))return n+"GeneralizedTime "+At(s(h,i))+"\n";if("30"==h.substr(i,2)){if("3000"==h.substr(i,4))return n+"SEQUENCE {}\n";f=n+"SEQUENCE\n";var v=e;if((2==(F=a(h,i)).length||3==F.length)&&"06"==h.substr(F[0],2)&&"04"==h.substr(F[F.length-1],2)){p=r.oidname(s(h,F[0]));var m=JSON.parse(JSON.stringify(e));m.x509ExtName=p,v=m}for(var S=0;S0){var e=new i({array:this.extensionsArray}),n=new r({explicit:!0,tag:"a3",obj:e});this.asn1Array.push(n)}var s=new i({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertificate,ft.asn1.ASN1Object),ft.asn1.x509.Extension=function(t){ft.asn1.x509.Extension.superclass.constructor.call(this);var e=ft.asn1,i=e.DERObjectIdentifier,n=e.DEROctetString,r=(e.DERBitString,e.DERBoolean),s=e.DERSequence;this.getEncodedHex=function(){var t=new i({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new r),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},r.lang.extend(ft.asn1.x509.Extension,ft.asn1.ASN1Object),ft.asn1.x509.Extension.appendByNameToArray=function(t,e,i){var n=t.toLowerCase(),r=ft.asn1.x509;if("basicconstraints"==n){var s=new r.BasicConstraints(e);i.push(s)}else if("keyusage"==n){s=new r.KeyUsage(e);i.push(s)}else if("crldistributionpoints"==n){s=new r.CRLDistributionPoints(e);i.push(s)}else if("extkeyusage"==n){s=new r.ExtKeyUsage(e);i.push(s)}else if("authoritykeyidentifier"==n){s=new r.AuthorityKeyIdentifier(e);i.push(s)}else if("authorityinfoaccess"==n){s=new r.AuthorityInfoAccess(e);i.push(s)}else if("subjectaltname"==n){s=new r.SubjectAltName(e);i.push(s)}else{if("issueraltname"!=n)throw"unsupported extension name: "+t;s=new r.IssuerAltName(e);i.push(s)}},ft.asn1.x509.KeyUsage=function(t){ft.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Jt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new ft.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var i=t.names,n="000000000",r=0;r-1&&t.push(new ft.asn1.DERInteger({int:this.pathLen}));var e=new ft.asn1.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},r.lang.extend(ft.asn1.x509.BasicConstraints,ft.asn1.x509.Extension),ft.asn1.x509.CRLDistributionPoints=function(t){ft.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ft.asn1,i=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){this.asn1ExtnValue=new e.DERSequence({array:t})},this.setByOneURI=function(t){var e=new i.GeneralNames([{uri:t}]),n=new i.DistributionPointName(e),r=new i.DistributionPoint({dpobj:n});this.setByDPArray([r])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},r.lang.extend(ft.asn1.x509.CRLDistributionPoints,ft.asn1.x509.Extension),ft.asn1.x509.ExtKeyUsage=function(t){ft.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=ft.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var i=0;i0){var t=new i({array:this.aRevokedCert});this.asn1Array.push(t)}var e=new i({array:this.asn1Array});return this.hTLV=e.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize=function(){this.asn1Version=null,this.asn1SignatureAlg=null,this.asn1Issuer=null,this.asn1ThisUpdate=null,this.asn1NextUpdate=null,this.aRevokedCert=new Array},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertList,ft.asn1.ASN1Object),ft.asn1.x509.CRLEntry=function(t){ft.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=ft.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},r.lang.extend(ft.asn1.x509.CRLEntry,ft.asn1.ASN1Object),ft.asn1.x509.X500Name=function(t){ft.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=new Array;var e=ft.asn1,i=e.x509,n=Ht;if(this.setByString=function(t){var e=t.split("/");e.shift();for(var n=[],r=0;r0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},ft.asn1.x509.RDN=function(t){ft.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=new Array,this.addByString=function(t){this.asn1Array.push(new ft.asn1.x509.AttributeTypeAndValue({str:t}))},this.addByMultiValuedString=function(t){for(var e=ft.asn1.x509.RDN.parseString(t),i=0;i0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var a=!1,h=[];for(r=0;n.length>0;r++){s=n.shift();if(!0===a){var u=h.pop();if(s.match(/"$/)){o=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(o),a=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(a=!0)}return h},ft.asn1.x509.AttributeTypeAndValue=function(t){ft.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var e=ft.asn1;this.setByString=function(t){var e=t.match(/^([^=]+)=(.+)$/);if(!e)throw"malformed attrTypeAndValueStr: "+t;this.setByAttrTypeAndValueStr(e[1],e[2])},this.setByAttrTypeAndValueStr=function(t,e){this.typeObj=ft.asn1.x509.OID.atype2obj(t);var i="utf8";"C"==t&&(i="prn"),this.valueObj=this.getValueObj(i,e)},this.getValueObj=function(t,i){if("utf8"==t)return new e.DERUTF8String({str:i});if("prn"==t)return new e.DERPrintableString({str:i});if("tel"==t)return new e.DERTeletexString({str:i});if("ia5"==t)return new e.DERIA5String({str:i});throw"unsupported directory string type: type="+t+" value="+i},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.typeObj,this.valueObj]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&void 0!==t.str&&this.setByString(t.str)},r.lang.extend(ft.asn1.x509.AttributeTypeAndValue,ft.asn1.ASN1Object),ft.asn1.x509.SubjectPublicKeyInfo=function(t){ft.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ft,i=e.asn1,n=i.DERInteger,r=i.DERBitString,s=i.DERObjectIdentifier,o=i.DERSequence,a=i.ASN1Util.newObject,h=i.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof ot){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+e})}}catch(t){}try{if(t instanceof ft.crypto.ECDSA){var i=new s({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ft.crypto.DSA){i=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new h({name:"dsa",asn1params:i});var o=new n({bigint:t.y});this.asn1SubjPKey=new r({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},r.lang.extend(ft.asn1.x509.SubjectPublicKeyInfo,ft.asn1.ASN1Object),ft.asn1.x509.Time=function(t){ft.asn1.x509.Time.superclass.constructor.call(this);var e=ft.asn1,i=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},r.lang.extend(ft.asn1.x509.Time,ft.asn1.ASN1Object),ft.asn1.x509.AlgorithmIdentifier=function(t){ft.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ft.asn1;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw"algorithm not specified";null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var t=[this.asn1Alg];null!==this.asn1Params&&t.push(this.asn1Params);var i=new e.DERSequence({array:t});return this.hTLV=i.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},r.lang.extend(ft.asn1.x509.AlgorithmIdentifier,ft.asn1.ASN1Object),ft.asn1.x509.GeneralName=function(t){ft.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=ft.asn1,n=(i.DERSequence,i.DEROctetString),r=i.DERIA5String,s=i.DERTaggedObject,o=i.ASN1Object,a=i.x509.X500Name,h=Ht;this.explicit=!1,this.setByParam=function(t){var i=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",i=new r({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",i=new r({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",i=new r({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,i=new a({str:t.dn})),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var u=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certissuer param not cert";(f=new Jt).hex=u;var c=f.getIssuerHex();(i=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;u=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certsubj param not cert";(f=new Jt).hex=u;c=f.getSubjectHex();(i=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,g=t.ip,p="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(d=Mt("["+g.split(".").join(",")+"]")).length)throw p}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=Vt(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw p;d=g}i=new n({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},r.lang.extend(ft.asn1.x509.GeneralName,ft.asn1.ASN1Object),ft.asn1.x509.GeneralNames=function(t){ft.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ft.asn1;this.setByParamArray=function(t){for(var i=0;i0&&(e=new n({obj:this.dUnsignedAttrs,tag:"a1",explicit:!1}));var r=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,t,this.dSigAlg,this.dSig];null!=e&&r.push(e);var o=new i.DERSequence({array:r});return this.hTLV=o.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.SignerInfo,ft.asn1.ASN1Object),ft.asn1.cms.EncapsulatedContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.dEContentType=new r({name:"data"}),this.dEContent=null,this.isDetached=!1,this.eContentValueHex=null,this.setContentType=function(t){t.match(/^[0-2][.][0-9.]+$/)?this.dEContentType=new r({oid:t}):this.dEContentType=new r({name:t})},this.setContentValue=function(t){void 0!==t&&("string"==typeof t.hex?this.eContentValueHex=t.hex:"string"==typeof t.str&&(this.eContentValueHex=bt(t.str)))},this.setContentValueHex=function(t){this.eContentValueHex=t},this.setContentValueStr=function(t){this.eContentValueHex=bt(t)},this.getEncodedHex=function(){if("string"!=typeof this.eContentValueHex)throw"eContentValue not yet set";var t=new s({hex:this.eContentValueHex});this.dEContent=new i({obj:t,tag:"a0",explicit:!0});var e=[this.dEContentType];this.isDetached||e.push(this.dEContent);var r=new n({array:e});return this.hTLV=r.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.EncapsulatedContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.ContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.x509;ft.asn1.cms.ContentInfo.superclass.constructor.call(this),this.dContentType=null,this.dContent=null,this.setContentType=function(t){"string"==typeof t&&(this.dContentType=r.OID.name2obj(t))},this.getEncodedHex=function(){var t=new i({obj:this.dContent,tag:"a0",explicit:!0}),e=new n({array:[this.dContentType,t]});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t&&(t.type&&this.setContentType(t.type),t.obj&&t.obj instanceof e.ASN1Object&&(this.dContent=t.obj))},r.lang.extend(ft.asn1.cms.ContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.SignedData=function(t){var e=ft.asn1,i=e.ASN1Object,n=e.DERInteger,r=e.DERSet,s=e.DERSequence,o=e.DERTaggedObject,a=e.cms,h=a.EncapsulatedContentInfo,u=a.SignerInfo,c=a.ContentInfo,l=e.x509.AlgorithmIdentifier;ft.asn1.cms.SignedData.superclass.constructor.call(this),this.dCMSVersion=new n({int:1}),this.dDigestAlgs=null,this.digestAlgNameList=[],this.dEncapContentInfo=new h,this.dCerts=null,this.certificateList=[],this.crlList=[],this.signerInfoList=[new u],this.addCertificatesByPEM=function(t){var e=Ht(t),n=new i;n.hTLV=e,this.certificateList.push(n)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(null==this.dDigestAlgs){for(var t=[],e=0;e0){var h=new r({array:this.certificateList});this.dCerts=new o({obj:h,tag:"a0",explicit:!1})}null!=this.dCerts&&a.push(this.dCerts);var u=new r({array:this.signerInfoList});a.push(u);var c=new s({array:a});return this.hTLV=c.getEncodedHex(),this.hTLV},this.getContentInfo=function(){return this.getEncodedHex(),new c({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},this.getPEM=function(){return Rt(this.getContentInfoEncodedHex(),"CMS")}},r.lang.extend(ft.asn1.cms.SignedData,ft.asn1.ASN1Object),ft.asn1.cms.CMSUtil=new function(){},ft.asn1.cms.CMSUtil.newSignedData=function(t){var e=ft.asn1,i=e.cms,n=i.SignerInfo,r=i.SignedData,s=i.SigningTime,o=i.SigningCertificate,a=i.SigningCertificateV2,h=e.cades.SignaturePolicyIdentifier,u=new r;if(u.dEncapContentInfo.setContentValue(t.content),"object"==typeof t.certs)for(var c=0;c0){var t=new n({array:this.extensionsArray}),e=new r({array:[t]}),i=new n({array:[new a({oid:"1.2.840.113549.1.9.14"}),e]}),h=new o({explicit:!0,tag:"a0",obj:i});this.asn1Array.push(h)}else{h=new o({explicit:!1,tag:"a0",obj:new s});this.asn1Array.push(h)}var u=new n({array:this.asn1Array});return this.hTLV=u.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.csr.CertificationRequestInfo,ft.asn1.ASN1Object),ft.asn1.csr.CSRUtil=new function(){},ft.asn1.csr.CSRUtil.newCSRPEM=function(t){var e=Ut,i=ft.asn1.csr;if(void 0===t.subject)throw"parameter subject undefined";if(void 0===t.sbjpubkey)throw"parameter sbjpubkey undefined";if(void 0===t.sigalg)throw"parameter sigalg undefined";if(void 0===t.sbjprvkey)throw"parameter sbjpubkey undefined";var n=new i.CertificationRequestInfo;if(n.setSubjectByParam(t.subject),n.setSubjectPublicKeyByGetKey(t.sbjpubkey),void 0!==t.ext&&void 0!==t.ext.length)for(var r=0;rr)throw"key is too short for SigAlg: keylen="+i+","+e;for(var s="0001",o="00"+n,a="",h=r-s.length-o.length,u=0;u=0)return!1;if(i.compareTo(x.ONE)<0||i.compareTo(r)>=0)return!1;var o=i.modInverse(r),a=t.multiply(o).mod(r),h=e.multiply(o).mod(r);return s.multiply(a).add(n.multiply(h)).getX().toBigInteger().mod(r).equals(e)},this.serializeSig=function(t,e){var i=t.toByteArraySigned(),n=e.toByteArraySigned(),r=[];return r.push(2),r.push(i.length),(r=r.concat(i)).push(2),r.push(n.length),(r=r.concat(n)).unshift(r.length),r.unshift(48),r},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:x.fromByteArrayUnsigned(i),s:x.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:x.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:x.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[2,0],"06"),i=o(t,0,[1],"04");try{n=o(t,0,[3,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#1/5 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{o(t,0,[1,0],"06"),e=o(t,0,[1,1],"06"),i=o(t,0,[2,0,1],"04");try{n=o(t,0,[2,0,2,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#8 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){var e,i,n=pt,r=ft.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{s(t,0,[0,0],"06"),e=s(t,0,[0,1],"06"),i=s(t,0,[1],"03").substr(2)}catch(t){throw"malformed PKCS#8 ECC public key"}if(this.curveName=r(e),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,e){5!==e&&(e=6);var i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{i=o(t,0,[0,e,0,1],"06"),n=o(t,0,[0,e,1],"03").substr(2)}catch(t){throw"malformed X.509 certificate ECC public key"}if(this.curveName=s(i),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ft.crypto.ECDSA.parseSigHex=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new x(e.r,16),s:new x(e.s,16)}},ft.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=pt,i=e.getChildIdx,n=e.getV;if("30"!=t.substr(0,2))throw"signature is not a ASN.1 sequence";var r=i(t,0);if(2!=r.length)throw"number of signature ASN.1 sequence elements seem wrong";var s=r[0],o=r[1];if("02"!=t.substr(s,2))throw"1st item of sequene of signature is not ASN.1 integer";if("02"!=t.substr(o,2))throw"2nd item of sequene of signature is not ASN.1 integer";return{r:n(t,s),s:n(t,o)}},ft.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t),i=e.r,n=e.s;if("00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),i.length%32==30&&(i="00"+i),n.length%32==30&&(n="00"+n),i.length%32!=0)throw"unknown ECDSA sig r length error";if(n.length%32!=0)throw"unknown ECDSA sig s length error";return i+n},ft.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var e=t.substr(0,t.length/2),i=t.substr(t.length/2);return ft.crypto.ECDSA.hexRSSigToASN1Sig(e,i)},ft.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var i=new x(t,16),n=new x(e,16);return ft.crypto.ECDSA.biRSSigToASN1Sig(i,n)},ft.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var i=ft.asn1,n=new i.DERInteger({bigint:t}),r=new i.DERInteger({bigint:e});return new i.DERSequence({array:[n,r]}).getEncodedHex()},ft.crypto.ECDSA.getName=function(t){return"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040022"===t?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":null},void 0!==ft&&ft||(ft={}),void 0!==ft.crypto&&ft.crypto||(ft.crypto={}),ft.crypto.ECParameterDB=new function(){var t={},e={};function i(t){return new x(t,16)}this.getByName=function(i){var n=i;if(void 0!==e[n]&&(n=e[i]),void 0!==t[n])return t[n];throw"unregistered EC curve name: "+n},this.regist=function(n,r,s,o,a,h,u,c,l,f,d,g){t[n]={};var p=i(s),y=i(o),v=i(a),m=i(h),S=i(u),F=new ct(p,y,v),w=F.decodePointHex("04"+c+l);t[n].name=n,t[n].keylen=r,t[n].curve=F,t[n].G=w,t[n].n=m,t[n].h=S,t[n].oid=d,t[n].info=g;for(var E=0;E1?new x(n,16):null,u=new x(r,16),this.setPrivate(s,o,a,h,u)},this.setPublic=function(t,e,i,n){this.isPublic=!0,this.p=t,this.q=e,this.g=i,this.y=n,this.x=null},this.setPublicHex=function(t,e,i,n){var r,s,o,a;r=new x(t,16),s=new x(e,16),o=new x(i,16),a=new x(n,16),this.setPublic(r,s,o,a)},this.signWithMessageHash=function(t){var e=this.p,i=this.q,n=this.g,r=(this.y,this.x),s=ft.crypto.Util.getRandomBigIntegerMinToMax(x.ONE.add(x.ONE),i.subtract(x.ONE)),o=new x(t.substr(0,i.bitLength()/4),16),a=n.modPow(s,e).mod(i),h=s.modInverse(i).multiply(o.add(r.multiply(a))).mod(i);return ft.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:a}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var i=this.p,n=this.q,r=this.g,s=this.y,o=this.parseASN1Signature(e),a=o[0],h=o[1],u=new x(t.substr(0,n.bitLength()/4),16);if(x.ZERO.compareTo(a)>0||a.compareTo(n)>0)throw"invalid DSA signature";if(x.ZERO.compareTo(h)>=0||h.compareTo(n)>0)throw"invalid DSA signature";var c=h.modInverse(n),l=u.multiply(c).mod(n),f=a.multiply(c).mod(n);return 0==r.modPow(l,i).multiply(s.modPow(f,i)).mod(i).mod(n).compareTo(a)},this.parseASN1Signature=function(t){try{return[new x(pt.getVbyList(t,0,[0],"02"),16),new x(pt.getVbyList(t,0,[1],"02"),16)]}catch(t){throw"malformed ASN.1 DSA signature"}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r,s,o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{e=a(t,0,[1],"02"),i=a(t,0,[2],"02"),n=a(t,0,[3],"02"),r=a(t,0,[4],"02"),s=a(t,0,[5],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#1/5 plain DSA private key"}this.setPrivateHex(e,i,n,r,s)},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[1,1,0],"02"),i=o(t,0,[1,1,1],"02"),n=o(t,0,[1,1,2],"02"),r=o(t,0,[2,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 plain DSA private key"}this.setPrivateHex(e,i,n,null,r)},this.readPKCS8PubKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[0,1,0],"02"),i=o(t,0,[0,1,1],"02"),n=o(t,0,[0,1,2],"02"),r=o(t,0,[1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 DSA public key"}this.setPublicHex(e,i,n,r)},this.readCertPubKeyHex=function(t,e){var i,n,r,s;5!==e&&(e=6);var o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{i=a(t,0,[0,e,0,1,0],"02"),n=a(t,0,[0,e,0,1,1],"02"),r=a(t,0,[0,e,0,1,2],"02"),s=a(t,0,[0,e,1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed X.509 certificate DSA public key"}this.setPublicHex(i,n,r,s)}};var Ut=function(){var t=function(t,i,n){return e(y.AES,t,i,n)},e=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=r;var h=t.decrypt(a,s,{iv:o});return y.enc.Hex.stringify(h)},i=function(t,e,i){return n(y.AES,t,e,i)},n=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a=t.encrypt(r,s,{iv:o}),h=y.enc.Hex.parse(a.toString());return y.enc.Base64.stringify(h)},r={"AES-256-CBC":{proc:t,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,i,n){return e(y.TripleDES,t,i,n)},eproc:function(t,e,i){return n(y.TripleDES,t,e,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,i,n){return e(y.DES,t,i,n)},eproc:function(t,e,i){return n(y.DES,t,e,i)},keylen:8,ivlen:8}},s=function(t){var e={},i=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(e.cipher=i[1],e.ivsalt=i[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var r=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(r=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(r=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=r&&-1!=o){var a=t.substring(r+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,i){for(var n=i.substring(0,16),s=y.enc.Hex.parse(n),o=y.enc.Utf8.parse(e),a=r[t].keylen+r[t].ivlen,h="",u=null;;){var c=y.algo.MD5.create();if(null!=u&&c.update(u),c.update(o),c.update(s),u=c.finalize(),(h+=y.enc.Hex.stringify(u)).length>=2*a)break}var l={};return l.keyhex=h.substr(0,2*r[t].keylen),l.ivhex=h.substr(2*r[t].keylen,2*r[t].ivlen),l},a=function(t,e,i,n){var s=y.enc.Base64.parse(t),o=y.enc.Hex.stringify(s);return(0,r[e].proc)(o,i,n)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,i){return o(t,e,i)},decryptKeyB64:function(t,e,i,n){return a(t,e,i,n)},getDecryptedKeyHex:function(t,e){var i=s(t),n=(i.type,i.cipher),r=i.ivsalt,h=i.data,u=o(n,e,r).keyhex;return a(h,n,u,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,i,n,s){var a="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===r[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==s&&null!=s||(s=function(t){var e=y.lib.WordArray.random(t);return y.enc.Hex.stringify(e)}(r[n].ivlen).toUpperCase());var h=function(t,e,i,n){return(0,r[e].eproc)(t,i,n)}(e,n,o(n,i,s).keyhex,s);a="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+n+","+s+"\r\n",a+="\r\n",a+=h.replace(/(.{64})/g,"$1\r\n"),a+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={},s=i(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;r.ciphertext=n(t,s[1]);var o=i(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=i(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var h=i(t,a[1]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length;if("2a864886f70d0307"!=n(t,h[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(t,h[1]);var u=i(t,a[0]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length;if("2a864886f70d01050c"!=n(t,u[0]))throw"this only supports pkcs5PBKDF2";var c=i(t,u[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;r.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{r.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return r},getPBKDF2KeyHexFromParam:function(t,e){var i=y.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,r=y.PBKDF2(e,i,{keySize:6,iterations:n});return y.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var i=Ht(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=Ut.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=y.enc.Hex.parse(n.ciphertext);var o=y.enc.Hex.parse(r),a=y.enc.Hex.parse(n.encryptionSchemeIV),h=y.TripleDES.decrypt(s,o,{iv:a});return y.enc.Hex.stringify(h)},getKeyFromEncryptedPKCS8PEM:function(t,e){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var s=i(t,0);if(3!=s.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(s[1],2))throw"malformed PKCS8 private key(code:003)";var o=i(t,s[1]);if(2!=o.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(o[0],2))throw"malformed PKCS8 private key(code:005)";if(r.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(r.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw"malformed PKCS8 private key(code:006)";return r.keyidx=e.getVidx(t,s[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Ht(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,i=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==i.algoid)e=new ot;else if("2a8648ce380401"==i.algoid)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";e=new ft.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,i=pt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===i)e=new ot;else if("2a8648ce380401"===i)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";e=new ft.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=i(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(r.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return r.e=n(t,s[1]),r},parsePublicPKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null},s=i(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=i(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?r.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(r.algparam={},r.algparam.p=e.getVbyList(t,a[1],[0],"02"),r.algparam.q=e.getVbyList(t,a[1],[1],"02"),r.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(t,s[1]).substr(2),r}}}();Ut.getKey=function(t,e,i){var n=(y=pt).getChildIdx,r=(y.getV,y.getVbyList),s=ft.crypto,o=s.ECDSA,a=s.DSA,h=ot,u=Ht,c=Ut;if(void 0!==h&&t instanceof h)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(t.n,t.e),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(D=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(D=new h).setPrivate(t.n,t.e,t.d),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(D=new a).setPublic(t.p,t.q,t.g,t.y),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(D=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(xt(t.n),xt(t.e)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(D=new h).setPrivateEx(xt(t.n),xt(t.e),xt(t.d),xt(t.p),xt(t.q),xt(t.dp),xt(t.dq),xt(t.qi)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(D=new h).setPrivate(xt(t.n),xt(t.e),xt(t.d)),D;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);return C.setPublicKeyHex(f),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);var d=("0000000000"+xt(t.d)).slice(-l);return C.setPublicKeyHex(f),C.setPrivateKeyHex(d),C}if("pkcs5prv"===i){var g,p=t,y=pt;if(9===(g=n(p,0)).length)(D=new h).readPKCS5PrvKeyHex(p);else if(6===g.length)(D=new a).readPKCS5PrvKeyHex(p);else{if(!(g.length>2&&"04"===p.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(D=new o).readPKCS5PrvKeyHex(p)}return D}if("pkcs8prv"===i)return D=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===i)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===i)return Jt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Jt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=Ht(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=u(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=r(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),F=r(R,0,[2],"02"),w=r(R,0,[3],"02"),E=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(w,16),new x(E,16),new x(b,16)),D}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var A=c.getDecryptedKeyHex(t,e),I=new ot;return I.readPKCS5PrvKeyHex(A),I}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var C,D=r(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),T=r(R,0,[2,0],"06"),P=r(R,0,[3,0],"03").substr(2);if(void 0===ft.crypto.OID.oidhex2name[T])throw"undefined OID(hex) in KJUR.crypto.OID: "+T;return(C=new o({curve:ft.crypto.OID.oidhex2name[T]})).setPublicKeyHex(P),C.setPrivateKeyHex(D),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;S=r(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),F=r(R,0,[2],"02"),w=r(R,0,[3],"02"),E=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(w,16),new x(E,16),new x(b,16)),D}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw"not supported argument"},Ut.generateKeypair=function(t,e){if("RSA"==t){var i=e;(o=new ot).generate(i,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new ot,r=o.n.toString(16),s=o.e.toString(16);return n.setPublic(r,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,h=e,u=new ft.crypto.ECDSA({curve:h}).generateKeyPairHex();return(o=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),o.setPrivateKeyHex(u.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Ut.getPEM=function(t,e,i,n,r,s){var o=ft,a=o.asn1,h=a.DERObjectIdentifier,u=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,f=o.crypto,d=f.DSA,g=f.ECDSA,p=ot;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function S(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==p&&t instanceof p||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Rt(x=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=v(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===i||null==i)&&1==t.isPrivate){var F=new h({name:t.curveName}).getEncodedHex(),w=m(t).getEncodedHex(),E="";return E+=Rt(F,"EC PARAMETERS"),E+=Rt(w,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=S(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==i&&null!=i&&1==t.isPrivate){var x=v(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==i&&null!=i&&1==t.isPrivate){x=m(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==i&&null!=i&&1==t.isPrivate){x=S(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",x,i,n,s)}var b=function(t,e){var i=A(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},A=function(t,e){var i=y.lib.WordArray.random(8),n=y.lib.WordArray.random(8),r=y.PBKDF2(e,i,{keySize:6,iterations:100}),s=y.enc.Hex.parse(t),o=y.TripleDES.encrypt(s,r,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=y.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=y.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=p&&t instanceof p&&1==t.isPrivate){var I=v(t).getEncodedHex();x=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){I=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){I=new u({bigint:t.x}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}throw"unsupported object nor format"},Ut.getKeyFromCSRPEM=function(t){var e=Ht(t,"CERTIFICATE REQUEST");return Ut.getKeyFromCSRHex(e)},Ut.getKeyFromCSRHex=function(t){var e=Ut.parseCSRHex(t);return Ut.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Ut.parseCSRHex=function(t){var e=pt,i=e.getChildIdx,n=e.getTLV,r={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=i(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=i(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(s,a[2]),r},Ut.getJWKFromKey=function(t){var e={};if(t instanceof ot&&t.isPrivate)return e.kty="RSA",e.n=Et(t.n.toString(16)),e.e=Et(t.e.toString(16)),e.d=Et(t.d.toString(16)),e.p=Et(t.p.toString(16)),e.q=Et(t.q.toString(16)),e.dp=Et(t.dmp1.toString(16)),e.dq=Et(t.dmq1.toString(16)),e.qi=Et(t.coeff.toString(16)),e;if(t instanceof ot&&t.isPublic)return e.kty="RSA",e.n=Et(t.n.toString(16)),e.e=Et(t.e.toString(16)),e;if(t instanceof ft.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=Et(i.x),e.y=Et(i.y),e.d=Et(t.prvKeyHex),e}if(t instanceof ft.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=Et(i.x),e.y=Et(i.y),e}throw"not supported key object"},ot.getPosArrayOfChildrenFromHex=function(t){return pt.getChildIdx(t,0)},ot.getHexValueArrayOfChildrenFromHex=function(t){var e,i=pt.getV,n=i(t,(e=ot.getPosArrayOfChildrenFromHex(t))[0]),r=i(t,e[1]),s=i(t,e[2]),o=i(t,e[3]),a=i(t,e[4]),h=i(t,e[5]),u=i(t,e[6]),c=i(t,e[7]),l=i(t,e[8]);return(e=new Array).push(n,r,s,o,a,h,u,c,l),e},ot.prototype.readPrivateKeyFromPEMString=function(t){var e=Ht(t),i=ot.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},ot.prototype.readPKCS5PrvKeyHex=function(t){var e=ot.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},ot.prototype.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s,o,a,h,u=pt,c=u.getVbyList;if(!1===u.isASN1HEX(t))throw"not ASN.1 hex string";try{e=c(t,0,[2,0,1],"02"),i=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),r=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw"malformed PKCS#8 plain RSA private key"}this.setPrivateEx(e,i,n,r,s,o,a,h)},ot.prototype.readPKCS5PubKeyHex=function(t){var e=pt,i=e.getV;if(!1===e.isASN1HEX(t))throw"keyHex is not ASN.1 hex string";var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw"wrong hex for PKCS#5 public key";var r=i(t,n[0]),s=i(t,n[1]);this.setPublic(r,s)},ot.prototype.readPKCS8PubKeyHex=function(t){var e=pt;if(!1===e.isASN1HEX(t))throw"not ASN.1 hex string";if("06092a864886f70d010101"!==e.getTLVbyList(t,0,[0,0]))throw"not PKCS8 RSA public key";var i=e.getTLVbyList(t,0,[1,0]);this.readPKCS5PubKeyHex(i)},ot.prototype.readCertPubKeyHex=function(t,e){var i,n;(i=new Jt).readCertHex(t),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var qt=new RegExp("");function zt(t,e){for(var i="",n=e/4-t.length,r=0;r>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function Yt(t){for(var e in ft.crypto.Util.DIGESTINFOHEAD){var i=ft.crypto.Util.DIGESTINFOHEAD[e],n=i.length;if(t.substring(0,n)==i)return[e,t.substring(n)]}return[]}function Jt(){var t=pt,e=t.getChildIdx,i=t.getV,n=t.getTLV,r=t.getVbyList,s=t.getTLVbyList,o=t.getIdxbyList,a=t.getVidx,h=t.oidname,u=Jt,c=Ht;this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){return null===this.hex||0!==this.version?this.version:"a003020102"!==s(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return r(this.hex,0,[0,1+this.foffset],"02")},this.getSignatureAlgorithmField=function(){return h(r(this.hex,0,[0,2+this.foffset,0],"06"))},this.getIssuerHex=function(){return s(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return u.hex2dn(this.getIssuerHex())},this.getSubjectHex=function(){return s(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return u.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=r(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=r(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return t.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return o(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return o(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Ut.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){return h(r(this.hex,0,[1,0],"06"))},this.getSignatureValueHex=function(){return r(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmName(),i=this.getSignatureValueHex(),n=s(this.hex,0,[0],"30"),r=new ft.crypto.Signature({alg:e});return r.init(t),r.updateHex(n),r.verify(i)},this.parseExt=function(){if(3!==this.version)return-1;var i=o(this.hex,0,[0,7,0],"30"),n=e(this.hex,i);this.aExtInfo=new Array;for(var s=0;s0&&(u=new Array(i),(new nt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=It(h(Ct("\0\0\0\0\0\0\0\0"+r+u))),l=[];for(n=0;n>8*a-o&255;for(g[0]&=~p,n=0;nthis.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;var r=n[0];return n[1]==function(t){return ft.crypto.Util.hashString(t,r)}(t)},ot.prototype.verifyWithMessageHash=function(t,e){var i=rt(e=(e=e.replace(qt,"")).replace(/[ \n]+/g,""),16);if(i.bitLength()>this.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;n[0];return n[1]==t},ot.prototype.verifyPSS=function(t,e,i,n){var r,s=(r=Ct(t),ft.crypto.Util.hashHex(r,i));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(s,e,i,n)},ot.prototype.verifyWithMessageHashPSS=function(t,e,i,n){var r=new x(e,16);if(r.bitLength()>this.n.bitLength())return!1;var s,o=function(t){return ft.crypto.Util.hashHex(t,i)},a=It(t),h=a.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===n||void 0===n)n=h;else if(-2===n)n=c-h-2;else if(n<-2)throw"invalid salt length";if(c>8*c-u&255;if(0!=(f.charCodeAt(0)&g))throw"bits beyond keysize not zero";var p=Gt(d,f.length,o),y=[];for(s=0;s0)&&-1==(":"+i.join(":")+":").indexOf(":"+p+":"))throw"algorithm '"+p+"' not accepted in the list";if("none"!=p&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Ut.getKey(e)),!("RS"!=y&&"PS"!=y||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==y&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===s.jwsalg2sigalg[g.alg])throw"unsupported alg name: "+p;if("none"==(v=s.jwsalg2sigalg[p]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var S,F=null;try{F=h.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(F)}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(d)},ft.jws.JWS.parse=function(t){var e,i,n,r=t.split("."),s={};if(2!=r.length&&3!=r.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=r[0],i=r[1],3==r.length&&(n=r[2]),s.headerObj=ft.jws.JWS.readSafeJSONString(gt(e)),s.payloadObj=ft.jws.JWS.readSafeJSONString(gt(i)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=gt(i):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==n&&(s.sigHex=xt(n)),s},ft.jws.JWS.verifyJWT=function(t,e,i){var n=ft.jws,r=n.JWS,s=r.readSafeJSONString,o=r.inArray,a=r.includedArray,h=t.split("."),u=h[0],c=h[1],l=(xt(h[2]),s(gt(u))),f=s(gt(c));if(void 0===l.alg)return!1;if(void 0===i.alg)throw"acceptField.alg shall be specified";if(!o(l.alg,i.alg))return!1;if(void 0!==f.iss&&"object"==typeof i.iss&&!o(f.iss,i.iss))return!1;if(void 0!==f.sub&&"object"==typeof i.sub&&!o(f.sub,i.sub))return!1;if(void 0!==f.aud&&"object"==typeof i.aud)if("string"==typeof f.aud){if(!o(f.aud,i.aud))return!1}else if("object"==typeof f.aud&&!a(f.aud,i.aud))return!1;var d=n.IntDate.getNow();return void 0!==i.verifyAt&&"number"==typeof i.verifyAt&&(d=i.verifyAt),void 0!==i.gracePeriod&&"number"==typeof i.gracePeriod||(i.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+i.gracePeriodr&&this.aHeader.pop(),this.aSignature.length>r&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignatures=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},e.SecureRandom=nt,e.rng_seed_time=Z,e.BigInteger=x,e.RSAKey=ot,e.ECDSA=ft.crypto.ECDSA,e.DSA=ft.crypto.DSA,e.Signature=ft.crypto.Signature,e.MessageDigest=ft.crypto.MessageDigest,e.Mac=ft.crypto.Mac,e.Cipher=ft.crypto.Cipher,e.KEYUTIL=Ut,e.ASN1HEX=pt,e.X509=Jt,e.CryptoJS=y,e.b64tohex=w,e.b64toBA=E,e.stoBA=yt,e.BAtos=vt,e.BAtohex=mt,e.stohex=St,e.stob64=function(t){return F(St(t))},e.stob64u=function(t){return Ft(F(St(t)))},e.b64utos=function(t){return vt(E(wt(t)))},e.b64tob64u=Ft,e.b64utob64=wt,e.hex2b64=F,e.hextob64u=Et,e.b64utohex=xt,e.utf8tob64u=dt,e.b64utoutf8=gt,e.utf8tob64=function(t){return F(Ot(Kt(t)))},e.b64toutf8=function(t){return decodeURIComponent(jt(w(t)))},e.utf8tohex=bt,e.hextoutf8=At,e.hextorstr=It,e.rstrtohex=Ct,e.hextob64=Dt,e.hextob64nl=Tt,e.b64nltohex=Pt,e.hextopem=Rt,e.pemtohex=Ht,e.hextoArrayBuffer=function(t){if(t.length%2!=0)throw"input is not even length";if(null==t.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var e=new ArrayBuffer(t.length/2),i=new DataView(e),n=0;ne.length&&(i=e.length);for(var n=0;n300)throw new r(`Failed to fetch ${t}. Response=${s}`,i.status);try{return JSON.parse(s)}catch(e){throw new r(`Invalid response while trying to fetch ${t}. Response=${s}`,i.status,e)}}}},function(t,e,i){const n=i(1),r=i(15);t.exports=class{constructor({jwt:t=i(0)}={}){this.jwt=t}decodeAndValidate({token:t,publicKeys:e,issuer:i,clientId:s,nonce:o}){const a=Math.floor(Date.now()/1e3),h=t.split(".");if(3!==h.length)throw new r(`Invalid JWT token. Got only ${h.length} parts.`);const u=this.jwt.KJUR.jws.JWS.parse(t);if(!u.headerObj)throw new r(n.INVALID_TOKEN);const c=u.headerObj.kid,l=this.getPublicKey(e.keys,c),f=this.jwt.KEYUTIL.getKey(l);if(!this.jwt.KJUR.jws.JWS.verify(t,f,{alg:[n.TOKEN_ALG]}))throw new r(n.INVALID_SIGNATURE);if(u.payloadObj.exp - * @license MIT - */ -var n=i(9),r=i(10),s=i(11);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return A(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function A(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return w(this,t,e,i);case"latin1":case"binary":return E(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function N(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||B(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);B(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);B(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(8))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(17);t.exports=class{constructor({w:t=window}={}){this.window=t}init(t){this.popupConfig=t}open(){const t=this.popupConfig.height,e=this.popupConfig.width,i=(window.screen.width-e)/2,r=(window.screen.height-t)/2;if(this.popup=this.window.open("","popup",`left=${i},top=${r},width=${e},height=${t},resizable,scrollbars=yes,status=1`),!this.popup)throw new n("Unable to open popup")}navigate(t){this.popup.location.href=t}close(){this.popup.close()}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(21);t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t);const i={"x-filter-type":`spa:v${n.version}`};this.publicKeys=e(this.getJwksEndpoint(),{headers:i})}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}},function(t){t.exports=JSON.parse('{"name":"ibmcloud-appid-js","version":"0.3.0","description":"IBM Cloud App ID SDK for Single Page Applications","scripts":{"build":"webpack","test":"mocha","coverage":"nyc --reporter=lcov mocha","docs":"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git"},"main":"dist/appid.umd.min.js","nyc":{"all":true,"include":["src/*.js"],"exclude":["**/PopupController.js","**/IFrameController.js","**/OpenIDConfigurationResource.js","**/constants.js"]},"dependencies":{"jsrsasign":"^8.0.12"},"devDependencies":{"node-fetch":"^2.6.0","@babel/cli":"^7.0.0","@babel/core":"^7.5.5","@babel/plugin-transform-runtime":"^7.5.5","@babel/preset-env":"^7.5.5","babel-cli":"^7.0.0-beta.3","chai":"^4.2.0","coveralls":"^3.0.6","gulp-babel":"^8.0.0","mocha":"^6.2.0","nyc":"^14.1.1","webpack":"^4.39.1","webpack-cli":"^3.3.6","docdash":"^1.1.1","jsdoc":"^3.6.3"}}')}]); \ No newline at end of file +var AppID = +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./node_modules/base64-js/index.js": +/*!*****************************************!*\ + !*** ./node_modules/base64-js/index.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/base64-js/index.js?"); + +/***/ }), + +/***/ "./node_modules/buffer/index.js": +/*!**************************************!*\ + !*** ./node_modules/buffer/index.js ***! + \**************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("/* WEBPACK VAR INJECTION */(function(global) {/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n\n\nvar base64 = __webpack_require__(/*! base64-js */ \"./node_modules/base64-js/index.js\")\nvar ieee754 = __webpack_require__(/*! ieee754 */ \"./node_modules/ieee754/index.js\")\nvar isArray = __webpack_require__(/*! isarray */ \"./node_modules/isarray/index.js\")\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://AppID/./node_modules/buffer/index.js?"); + +/***/ }), + +/***/ "./node_modules/ieee754/index.js": +/*!***************************************!*\ + !*** ./node_modules/ieee754/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/ieee754/index.js?"); + +/***/ }), + +/***/ "./node_modules/isarray/index.js": +/*!***************************************!*\ + !*** ./node_modules/isarray/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n\n\n//# sourceURL=webpack://AppID/./node_modules/isarray/index.js?"); + +/***/ }), + +/***/ "./node_modules/jsrsasign/lib/jsrsasign.js": +/*!*************************************************!*\ + !*** ./node_modules/jsrsasign/lib/jsrsasign.js ***! + \*************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\nvar navigator = {};\nnavigator.userAgent = false;\n\nvar window = {};\n/*\n * jsrsasign(all) 8.0.12 (2018-04-22) (c) 2010-2018 Kenji Urushima | kjur.github.com/jsrsasign/license\n */\n\n/*!\nCopyright (c) 2011, Yahoo! Inc. All rights reserved.\nCode licensed under the BSD License:\nhttp://developer.yahoo.com/yui/license.html\nversion: 2.9.0\n*/\nif(YAHOO===undefined){var YAHOO={}}YAHOO.lang={extend:function(g,h,f){if(!h||!g){throw new Error(\"YAHOO.lang.extend failed, please check that all dependencies are included.\")}var d=function(){};d.prototype=h.prototype;g.prototype=new d();g.prototype.constructor=g;g.superclass=h.prototype;if(h.prototype.constructor==Object.prototype.constructor){h.prototype.constructor=h}if(f){var b;for(b in f){g.prototype[b]=f[b]}var e=function(){},c=[\"toString\",\"valueOf\"];try{if(/MSIE/.test(navigator.userAgent)){e=function(j,i){for(b=0;b>>2]>>>(24-(r%4)*8))&255;q[(n+r)>>>2]|=o<<(24-((n+r)%4)*8)}}else{for(var r=0;r>>2]=p[r>>>2]}}this.sigBytes+=s;return this},clamp:function(){var o=this.words;var n=this.sigBytes;o[n>>>2]&=4294967295<<(32-(n%4)*8);o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);n.words=this.words.slice(0);return n},random:function(p){var o=[];for(var n=0;n>>2]>>>(24-(n%4)*8))&255;q.push((s>>>4).toString(16));q.push((s&15).toString(16))}return q.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>3]|=parseInt(p.substr(o,2),16)<<(24-(o%8)*4)}return new l.init(q,n/2)}};var d=m.Latin1={stringify:function(q){var r=q.words;var p=q.sigBytes;var n=[];for(var o=0;o>>2]>>>(24-(o%4)*8))&255;n.push(String.fromCharCode(s))}return n.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>2]|=(p.charCodeAt(o)&255)<<(24-(o%4)*8)}return new l.init(q,n)}};var c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error(\"Malformed UTF-8 data\")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}};var i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init();this._nDataBytes=0},_append:function(n){if(typeof n==\"string\"){n=c.parse(n)}this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data;var x=q.words;var n=q.sigBytes;var t=this.blockSize;var v=t*4;var u=n/v;if(w){u=e.ceil(u)}else{u=e.max((u|0)-this._minBufferSize,0)}var s=u*t;var r=e.min(s*4,n);if(s){for(var p=0;p>>2]&255}};f.BlockCipher=n.extend({cfg:n.cfg.extend({mode:m,padding:h}),reset:function(){n.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;\nthis._mode=c.call(a,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var p=f.CipherParams=k.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(g.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;\nreturn(a?l.create([1398893684,1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=l.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return p.create({ciphertext:a,salt:c})}},j=f.SerializableCipher=k.extend({cfg:k.extend({format:m}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return p.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,\nblockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return\"string\"==typeof a?b.parse(a,this):a}}),g=(g.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=l.random(8));a=v.create({keySize:b+c}).compute(a,d);c=l.create(a.words.slice(b),4*c);a.sigBytes=4*b;return p.create({key:a,iv:c,salt:d})}},s=f.PasswordBasedCipher=j.extend({cfg:j.cfg.extend({kdf:g}),encrypt:function(a,\nb,c,d){d=this.cfg.extend(d);c=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=c.iv;a=j.encrypt.call(this,a,b,c.key,d);a.mixIn(c);return a},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=c.iv;return j.decrypt.call(this,a,b,c.key,d)}})}();\n\n/*\nCryptoJS v3.1.2 aes.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){for(var q=CryptoJS,x=q.lib.BlockCipher,r=q.algo,j=[],y=[],z=[],A=[],B=[],C=[],s=[],u=[],v=[],w=[],g=[],k=0;256>k;k++)g[k]=128>k?k<<1:k<<1^283;for(var n=0,l=0,k=0;256>k;k++){var f=l^l<<1^l<<2^l<<3^l<<4,f=f>>>8^f&255^99;j[n]=f;y[f]=n;var t=g[n],D=g[t],E=g[D],b=257*g[f]^16843008*f;z[n]=b<<24|b>>>8;A[n]=b<<16|b>>>16;B[n]=b<<8|b>>>24;C[n]=b;b=16843009*E^65537*D^257*t^16843008*n;s[f]=b<<24|b>>>8;u[f]=b<<16|b>>>16;v[f]=b<<8|b>>>24;w[f]=b;n?(n=t^g[g[g[E^t]]],l^=g[g[l]]):n=l=1}var F=[0,1,2,4,8,\n16,32,64,128,27,54],r=r.AES=x.extend({_doReset:function(){for(var c=this._key,e=c.words,a=c.sigBytes/4,c=4*((this._nRounds=a+6)+1),b=this._keySchedule=[],h=0;h>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255]):(d=d<<8|d>>>24,d=j[d>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255],d^=F[h/a|0]<<24);b[h]=b[h-a]^d}e=this._invKeySchedule=[];for(a=0;aa||4>=h?d:s[j[d>>>24]]^u[j[d>>>16&255]]^v[j[d>>>\n8&255]]^w[j[d&255]]},encryptBlock:function(c,e){this._doCryptBlock(c,e,this._keySchedule,z,A,B,C,j)},decryptBlock:function(c,e){var a=c[e+1];c[e+1]=c[e+3];c[e+3]=a;this._doCryptBlock(c,e,this._invKeySchedule,s,u,v,w,y);a=c[e+1];c[e+1]=c[e+3];c[e+3]=a},_doCryptBlock:function(c,e,a,b,h,d,j,m){for(var n=this._nRounds,f=c[e]^a[0],g=c[e+1]^a[1],k=c[e+2]^a[2],p=c[e+3]^a[3],l=4,t=1;t>>24]^h[g>>>16&255]^d[k>>>8&255]^j[p&255]^a[l++],r=b[g>>>24]^h[k>>>16&255]^d[p>>>8&255]^j[f&255]^a[l++],s=\nb[k>>>24]^h[p>>>16&255]^d[f>>>8&255]^j[g&255]^a[l++],p=b[p>>>24]^h[f>>>16&255]^d[g>>>8&255]^j[k&255]^a[l++],f=q,g=r,k=s;q=(m[f>>>24]<<24|m[g>>>16&255]<<16|m[k>>>8&255]<<8|m[p&255])^a[l++];r=(m[g>>>24]<<24|m[k>>>16&255]<<16|m[p>>>8&255]<<8|m[f&255])^a[l++];s=(m[k>>>24]<<24|m[p>>>16&255]<<16|m[f>>>8&255]<<8|m[g&255])^a[l++];p=(m[p>>>24]<<24|m[f>>>16&255]<<16|m[g>>>8&255]<<8|m[k&255])^a[l++];c[e]=q;c[e+1]=r;c[e+2]=s;c[e+3]=p},keySize:8});q.AES=x._createHelper(r)})();\n\n/*\nCryptoJS v3.1.2 tripledes-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function j(b,c){var a=(this._lBlock>>>b^this._rBlock)&c;this._rBlock^=a;this._lBlock^=a<>>b^this._lBlock)&c;this._lBlock^=a;this._rBlock^=a<a;a++){var f=q[a]-1;c[a]=b[f>>>5]>>>31-f%32&1}b=this._subKeys=[];for(f=0;16>f;f++){for(var d=b[f]=[],e=r[f],a=0;24>a;a++)d[a/6|0]|=c[(p[a]-1+e)%28]<<31-a%6,d[4+(a/6|0)]|=c[28+(p[a+24]-1+e)%28]<<31-a%6;d[0]=d[0]<<1|d[0]>>>31;for(a=1;7>a;a++)d[a]>>>=\n4*(a-1)+3;d[7]=d[7]<<5|d[7]>>>27}c=this._invSubKeys=[];for(a=0;16>a;a++)c[a]=b[15-a]},encryptBlock:function(b,c){this._doCryptBlock(b,c,this._subKeys)},decryptBlock:function(b,c){this._doCryptBlock(b,c,this._invSubKeys)},_doCryptBlock:function(b,c,a){this._lBlock=b[c];this._rBlock=b[c+1];j.call(this,4,252645135);j.call(this,16,65535);l.call(this,2,858993459);l.call(this,8,16711935);j.call(this,1,1431655765);for(var f=0;16>f;f++){for(var d=a[f],e=this._lBlock,h=this._rBlock,g=0,k=0;8>k;k++)g|=s[k][((h^\nd[k])&t[k])>>>0];this._lBlock=h;this._rBlock=e^g}a=this._lBlock;this._lBlock=this._rBlock;this._rBlock=a;j.call(this,1,1431655765);l.call(this,8,16711935);l.call(this,2,858993459);j.call(this,16,65535);j.call(this,4,252645135);b[c]=this._lBlock;b[c+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});h.DES=e._createHelper(m);g=g.TripleDES=e.extend({_doReset:function(){var b=this._key.words;this._des1=m.createEncryptor(n.create(b.slice(0,2)));this._des2=m.createEncryptor(n.create(b.slice(2,4)));this._des3=\nm.createEncryptor(n.create(b.slice(4,6)))},encryptBlock:function(b,c){this._des1.encryptBlock(b,c);this._des2.decryptBlock(b,c);this._des3.encryptBlock(b,c)},decryptBlock:function(b,c){this._des3.decryptBlock(b,c);this._des2.encryptBlock(b,c);this._des1.decryptBlock(b,c)},keySize:6,ivSize:2,blockSize:2});h.TripleDES=e._createHelper(g)})();\n\n/*\nCryptoJS v3.1.2 enc-base64.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join(\"\")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d<\ne;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\"}})();\n\n/*\nCryptoJS v3.1.2 md5.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(E){function h(a,f,g,j,p,h,k){a=a+(f&g|~f&j)+p+k;return(a<>>32-h)+f}function k(a,f,g,j,p,h,k){a=a+(f&j|g&~j)+p+k;return(a<>>32-h)+f}function l(a,f,g,j,h,k,l){a=a+(f^g^j)+h+l;return(a<>>32-k)+f}function n(a,f,g,j,h,k,l){a=a+(g^(f|~j))+h+l;return(a<>>32-k)+f}for(var r=CryptoJS,q=r.lib,F=q.WordArray,s=q.Hasher,q=r.algo,a=[],t=0;64>t;t++)a[t]=4294967296*E.abs(E.sin(t+1))|0;q=q.MD5=s.extend({_doReset:function(){this._hash=new F.init([1732584193,4023233417,2562383102,271733878])},\n_doProcessBlock:function(m,f){for(var g=0;16>g;g++){var j=f+g,p=m[j];m[j]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360}var g=this._hash.words,j=m[f+0],p=m[f+1],q=m[f+2],r=m[f+3],s=m[f+4],t=m[f+5],u=m[f+6],v=m[f+7],w=m[f+8],x=m[f+9],y=m[f+10],z=m[f+11],A=m[f+12],B=m[f+13],C=m[f+14],D=m[f+15],b=g[0],c=g[1],d=g[2],e=g[3],b=h(b,c,d,e,j,7,a[0]),e=h(e,b,c,d,p,12,a[1]),d=h(d,e,b,c,q,17,a[2]),c=h(c,d,e,b,r,22,a[3]),b=h(b,c,d,e,s,7,a[4]),e=h(e,b,c,d,t,12,a[5]),d=h(d,e,b,c,u,17,a[6]),c=h(c,d,e,b,v,22,a[7]),\nb=h(b,c,d,e,w,7,a[8]),e=h(e,b,c,d,x,12,a[9]),d=h(d,e,b,c,y,17,a[10]),c=h(c,d,e,b,z,22,a[11]),b=h(b,c,d,e,A,7,a[12]),e=h(e,b,c,d,B,12,a[13]),d=h(d,e,b,c,C,17,a[14]),c=h(c,d,e,b,D,22,a[15]),b=k(b,c,d,e,p,5,a[16]),e=k(e,b,c,d,u,9,a[17]),d=k(d,e,b,c,z,14,a[18]),c=k(c,d,e,b,j,20,a[19]),b=k(b,c,d,e,t,5,a[20]),e=k(e,b,c,d,y,9,a[21]),d=k(d,e,b,c,D,14,a[22]),c=k(c,d,e,b,s,20,a[23]),b=k(b,c,d,e,x,5,a[24]),e=k(e,b,c,d,C,9,a[25]),d=k(d,e,b,c,r,14,a[26]),c=k(c,d,e,b,w,20,a[27]),b=k(b,c,d,e,B,5,a[28]),e=k(e,b,\nc,d,q,9,a[29]),d=k(d,e,b,c,v,14,a[30]),c=k(c,d,e,b,A,20,a[31]),b=l(b,c,d,e,t,4,a[32]),e=l(e,b,c,d,w,11,a[33]),d=l(d,e,b,c,z,16,a[34]),c=l(c,d,e,b,C,23,a[35]),b=l(b,c,d,e,p,4,a[36]),e=l(e,b,c,d,s,11,a[37]),d=l(d,e,b,c,v,16,a[38]),c=l(c,d,e,b,y,23,a[39]),b=l(b,c,d,e,B,4,a[40]),e=l(e,b,c,d,j,11,a[41]),d=l(d,e,b,c,r,16,a[42]),c=l(c,d,e,b,u,23,a[43]),b=l(b,c,d,e,x,4,a[44]),e=l(e,b,c,d,A,11,a[45]),d=l(d,e,b,c,D,16,a[46]),c=l(c,d,e,b,q,23,a[47]),b=n(b,c,d,e,j,6,a[48]),e=n(e,b,c,d,v,10,a[49]),d=n(d,e,b,c,\nC,15,a[50]),c=n(c,d,e,b,t,21,a[51]),b=n(b,c,d,e,A,6,a[52]),e=n(e,b,c,d,r,10,a[53]),d=n(d,e,b,c,y,15,a[54]),c=n(c,d,e,b,p,21,a[55]),b=n(b,c,d,e,w,6,a[56]),e=n(e,b,c,d,D,10,a[57]),d=n(d,e,b,c,u,15,a[58]),c=n(c,d,e,b,B,21,a[59]),b=n(b,c,d,e,s,6,a[60]),e=n(e,b,c,d,z,10,a[61]),d=n(d,e,b,c,q,15,a[62]),c=n(c,d,e,b,x,21,a[63]);g[0]=g[0]+b|0;g[1]=g[1]+c|0;g[2]=g[2]+d|0;g[3]=g[3]+e|0},_doFinalize:function(){var a=this._data,f=a.words,g=8*this._nDataBytes,j=8*a.sigBytes;f[j>>>5]|=128<<24-j%32;var h=E.floor(g/\n4294967296);f[(j+64>>>9<<4)+15]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;f[(j+64>>>9<<4)+14]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360;a.sigBytes=4*(f.length+1);this._process();a=this._hash;f=a.words;for(g=0;4>g;g++)j=f[g],f[g]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=s.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=s._createHelper(q);r.HmacMD5=s._createHmacHelper(q)})(Math);\n\n/*\nCryptoJS v3.1.2 sha1-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var k=CryptoJS,b=k.lib,m=b.WordArray,l=b.Hasher,d=[],b=k.algo.SHA1=l.extend({_doReset:function(){this._hash=new m.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(n,p){for(var a=this._hash.words,e=a[0],f=a[1],h=a[2],j=a[3],b=a[4],c=0;80>c;c++){if(16>c)d[c]=n[p+c]|0;else{var g=d[c-3]^d[c-8]^d[c-14]^d[c-16];d[c]=g<<1|g>>>31}g=(e<<5|e>>>27)+b+d[c];g=20>c?g+((f&h|~f&j)+1518500249):40>c?g+((f^h^j)+1859775393):60>c?g+((f&h|f&j|h&j)-1894007588):g+((f^h^\nj)-899497514);b=j;j=h;h=f<<30|f>>>2;f=e;e=g}a[0]=a[0]+e|0;a[1]=a[1]+f|0;a[2]=a[2]+h|0;a[3]=a[3]+j|0;a[4]=a[4]+b|0},_doFinalize:function(){var b=this._data,d=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=Math.floor(a/4294967296);d[(e+64>>>9<<4)+15]=a;b.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var b=l.clone.call(this);b._hash=this._hash.clone();return b}});k.SHA1=l._createHelper(b);k.HmacSHA1=l._createHmacHelper(b)})();\n\n/*\nCryptoJS v3.1.2 sha256-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(k){for(var g=CryptoJS,h=g.lib,v=h.WordArray,j=h.Hasher,h=g.algo,s=[],t=[],u=function(q){return 4294967296*(q-(q|0))|0},l=2,b=0;64>b;){var d;a:{d=l;for(var w=k.sqrt(d),r=2;r<=w;r++)if(!(d%r)){d=!1;break a}d=!0}d&&(8>b&&(s[b]=u(k.pow(l,0.5))),t[b]=u(k.pow(l,1/3)),b++);l++}var n=[],h=h.SHA256=j.extend({_doReset:function(){this._hash=new v.init(s.slice(0))},_doProcessBlock:function(q,h){for(var a=this._hash.words,c=a[0],d=a[1],b=a[2],k=a[3],f=a[4],g=a[5],j=a[6],l=a[7],e=0;64>e;e++){if(16>e)n[e]=\nq[h+e]|0;else{var m=n[e-15],p=n[e-2];n[e]=((m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3)+n[e-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[e-16]}m=l+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&g^~f&j)+t[e]+n[e];p=((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&d^c&b^d&b);l=j;j=g;g=f;f=k+m|0;k=b;b=d;d=c;c=m+p|0}a[0]=a[0]+c|0;a[1]=a[1]+d|0;a[2]=a[2]+b|0;a[3]=a[3]+k|0;a[4]=a[4]+f|0;a[5]=a[5]+g|0;a[6]=a[6]+j|0;a[7]=a[7]+l|0},_doFinalize:function(){var d=this._data,b=d.words,a=8*this._nDataBytes,c=8*d.sigBytes;\nb[c>>>5]|=128<<24-c%32;b[(c+64>>>9<<4)+14]=k.floor(a/4294967296);b[(c+64>>>9<<4)+15]=a;d.sigBytes=4*b.length;this._process();return this._hash},clone:function(){var b=j.clone.call(this);b._hash=this._hash.clone();return b}});g.SHA256=j._createHelper(h);g.HmacSHA256=j._createHmacHelper(h)})(Math);\n\n/*\nCryptoJS v3.1.2 sha224-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var b=CryptoJS,d=b.lib.WordArray,a=b.algo,c=a.SHA256,a=a.SHA224=c.extend({_doReset:function(){this._hash=new d.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var a=c._doFinalize.call(this);a.sigBytes-=4;return a}});b.SHA224=c._createHelper(a);b.HmacSHA224=c._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 sha512-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function a(){return d.create.apply(d,arguments)}for(var n=CryptoJS,r=n.lib.Hasher,e=n.x64,d=e.Word,T=e.WordArray,e=n.algo,ea=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),\na(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,\n2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),\na(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,\n3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],w=0;80>w;w++)v[w]=a();e=e.SHA512=r.extend({_doReset:function(){this._hash=new T.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(a,d){for(var f=this._hash.words,\nF=f[0],e=f[1],n=f[2],r=f[3],G=f[4],H=f[5],I=f[6],f=f[7],w=F.high,J=F.low,X=e.high,K=e.low,Y=n.high,L=n.low,Z=r.high,M=r.low,$=G.high,N=G.low,aa=H.high,O=H.low,ba=I.high,P=I.low,ca=f.high,Q=f.low,k=w,g=J,z=X,x=K,A=Y,y=L,U=Z,B=M,l=$,h=N,R=aa,C=O,S=ba,D=P,V=ca,E=Q,m=0;80>m;m++){var s=v[m];if(16>m)var j=s.high=a[d+2*m]|0,b=s.low=a[d+2*m+1]|0;else{var j=v[m-15],b=j.high,p=j.low,j=(b>>>1|p<<31)^(b>>>8|p<<24)^b>>>7,p=(p>>>1|b<<31)^(p>>>8|b<<24)^(p>>>7|b<<25),u=v[m-2],b=u.high,c=u.low,u=(b>>>19|c<<13)^(b<<\n3|c>>>29)^b>>>6,c=(c>>>19|b<<13)^(c<<3|b>>>29)^(c>>>6|b<<26),b=v[m-7],W=b.high,t=v[m-16],q=t.high,t=t.low,b=p+b.low,j=j+W+(b>>>0

>>0?1:0),b=b+c,j=j+u+(b>>>0>>0?1:0),b=b+t,j=j+q+(b>>>0>>0?1:0);s.high=j;s.low=b}var W=l&R^~l&S,t=h&C^~h&D,s=k&z^k&A^z&A,T=g&x^g&y^x&y,p=(k>>>28|g<<4)^(k<<30|g>>>2)^(k<<25|g>>>7),u=(g>>>28|k<<4)^(g<<30|k>>>2)^(g<<25|k>>>7),c=ea[m],fa=c.high,da=c.low,c=E+((h>>>14|l<<18)^(h>>>18|l<<14)^(h<<23|l>>>9)),q=V+((l>>>14|h<<18)^(l>>>18|h<<14)^(l<<23|h>>>9))+(c>>>0>>0?1:\n0),c=c+t,q=q+W+(c>>>0>>0?1:0),c=c+da,q=q+fa+(c>>>0>>0?1:0),c=c+b,q=q+j+(c>>>0>>0?1:0),b=u+T,s=p+s+(b>>>0>>0?1:0),V=S,E=D,S=R,D=C,R=l,C=h,h=B+c|0,l=U+q+(h>>>0>>0?1:0)|0,U=A,B=y,A=z,y=x,z=k,x=g,g=c+b|0,k=q+s+(g>>>0>>0?1:0)|0}J=F.low=J+g;F.high=w+k+(J>>>0>>0?1:0);K=e.low=K+x;e.high=X+z+(K>>>0>>0?1:0);L=n.low=L+y;n.high=Y+A+(L>>>0>>0?1:0);M=r.low=M+B;r.high=Z+U+(M>>>0>>0?1:0);N=G.low=N+h;G.high=$+l+(N>>>0>>0?1:0);O=H.low=O+C;H.high=aa+R+(O>>>0>>0?1:0);P=I.low=P+D;\nI.high=ba+S+(P>>>0>>0?1:0);Q=f.low=Q+E;f.high=ca+V+(Q>>>0>>0?1:0)},_doFinalize:function(){var a=this._data,d=a.words,f=8*this._nDataBytes,e=8*a.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+128>>>10<<5)+30]=Math.floor(f/4294967296);d[(e+128>>>10<<5)+31]=f;a.sigBytes=4*d.length;this._process();return this._hash.toX32()},clone:function(){var a=r.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});n.SHA512=r._createHelper(e);n.HmacSHA512=r._createHmacHelper(e)})();\n\n/*\nCryptoJS v3.1.2 sha384-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,a=c.x64,b=a.Word,e=a.WordArray,a=c.algo,d=a.SHA512,a=a.SHA384=d.extend({_doReset:function(){this._hash=new e.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var a=d._doFinalize.call(this);a.sigBytes-=16;return a}});c.SHA384=\nd._createHelper(a);c.HmacSHA384=d._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 ripemd160-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n/*\n\n(c) 2012 by Cedric Mesnil. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n(function(){var q=CryptoJS,d=q.lib,n=d.WordArray,p=d.Hasher,d=q.algo,x=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),y=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),z=n.create([11,14,15,12,\n5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),A=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),B=n.create([0,1518500249,1859775393,2400959708,2840853838]),C=n.create([1352829926,1548603684,1836072691,\n2053994217,0]),d=d.RIPEMD160=p.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,v){for(var b=0;16>b;b++){var c=v+b,f=e[c];e[c]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360}var c=this._hash.words,f=B.words,d=C.words,n=x.words,q=y.words,p=z.words,w=A.words,t,g,h,j,r,u,k,l,m,s;u=t=c[0];k=g=c[1];l=h=c[2];m=j=c[3];s=r=c[4];for(var a,b=0;80>b;b+=1)a=t+e[v+n[b]]|0,a=16>b?a+((g^h^j)+f[0]):32>b?a+((g&h|~g&j)+f[1]):48>b?\na+(((g|~h)^j)+f[2]):64>b?a+((g&j|h&~j)+f[3]):a+((g^(h|~j))+f[4]),a|=0,a=a<>>32-p[b],a=a+r|0,t=r,r=j,j=h<<10|h>>>22,h=g,g=a,a=u+e[v+q[b]]|0,a=16>b?a+((k^(l|~m))+d[0]):32>b?a+((k&m|l&~m)+d[1]):48>b?a+(((k|~l)^m)+d[2]):64>b?a+((k&l|~k&m)+d[3]):a+((k^l^m)+d[4]),a|=0,a=a<>>32-w[b],a=a+s|0,u=s,s=m,m=l<<10|l>>>22,l=k,k=a;a=c[1]+h+m|0;c[1]=c[2]+j+s|0;c[2]=c[3]+r+u|0;c[3]=c[4]+t+k|0;c[4]=c[0]+g+l|0;c[0]=a},_doFinalize:function(){var e=this._data,d=e.words,b=8*this._nDataBytes,c=8*e.sigBytes;\nd[c>>>5]|=128<<24-c%32;d[(c+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;e.sigBytes=4*(d.length+1);this._process();e=this._hash;d=e.words;for(b=0;5>b;b++)c=d[b],d[b]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return e},clone:function(){var d=p.clone.call(this);d._hash=this._hash.clone();return d}});q.RIPEMD160=p._createHelper(d);q.HmacRIPEMD160=p._createHmacHelper(d)})(Math);\n\n/*\nCryptoJS v3.1.2 hmac.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,k=c.enc.Utf8;c.algo.HMAC=c.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;\"string\"==typeof b&&(b=k.parse(b));var c=a.blockSize,e=4*c;b.sigBytes>e&&(b=a.finalize(b));b.clamp();for(var f=this._oKey=b.clone(),g=this._iKey=b.clone(),h=f.words,j=g.words,d=0;d>6)+b64map.charAt(e&63)}if(b+1==d.length){e=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(e<<2)}else{if(b+2==d.length){e=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(e>>2)+b64map.charAt((e&3)<<4)}}if(b64pad){while((a.length&3)>0){a+=b64pad}}return a}function b64tohex(f){var d=\"\";var e;var b=0;var c;var a;for(e=0;e>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(e){var d=b64tohex(e);var c;var b=new Array();for(c=0;2*c=0){var d=a*this[f++]+b[e]+h;h=Math.floor(d/67108864);b[e++]=d&67108863}return h}function am2(f,q,r,e,o,a){var k=q&32767,p=q>>15;while(--a>=0){var d=this[f]&32767;var g=this[f++]>>15;var b=p*d+g*k;d=k*d+((b&32767)<<15)+r[e]+(o&1073741823);o=(d>>>30)+(b>>>15)+p*g+(o>>>30);r[e++]=d&1073741823}return o}function am3(f,q,r,e,o,a){var k=q&16383,p=q>>14;while(--a>=0){var d=this[f]&16383;var g=this[f++]>>14;var b=p*d+g*k;d=k*d+((b&16383)<<14)+r[e]+o;o=(d>>28)+(b>>14)+p*g;r[e++]=d&268435455}return o}if(j_lm&&(navigator.appName==\"Microsoft Internet Explorer\")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator.appName!=\"Netscape\")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=((1<=0;--a){b[a]=this[a]}b.t=this.t;b.s=this.s}function bnpFromInt(a){this.t=1;this.s=(a<0)?-1:0;if(a>0){this[0]=a}else{if(a<-1){this[0]=a+this.DV}else{this.t=0}}}function nbv(a){var b=nbi();b.fromInt(a);return b}function bnpFromString(h,c){var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==256){e=8}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{this.fromRadix(h,c);return}}}}}}this.t=0;this.s=0;var g=h.length,d=false,f=0;while(--g>=0){var a=(e==8)?h[g]&255:intAt(h,g);if(a<0){if(h.charAt(g)==\"-\"){d=true}continue}d=false;if(f==0){this[this.t++]=a}else{if(f+e>this.DB){this[this.t-1]|=(a&((1<<(this.DB-f))-1))<>(this.DB-f))}else{this[this.t-1]|=a<=this.DB){f-=this.DB}}if(e==8&&(h[0]&128)!=0){this.s=-1;if(f>0){this[this.t-1]|=((1<<(this.DB-f))-1)<0&&this[this.t-1]==a){--this.t}}function bnToString(c){if(this.s<0){return\"-\"+this.negate().toString(c)}var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{return this.toRadix(c)}}}}}var g=(1<0){if(j>j)>0){a=true;h=int2char(l)}while(f>=0){if(j>(j+=this.DB-e)}else{l=(this[f]>>(j-=e))&g;if(j<=0){j+=this.DB;--f}}if(l>0){a=true}if(a){h+=int2char(l)}}}return a?h:\"0\"}function bnNegate(){var a=nbi();BigInteger.ZERO.subTo(this,a);return a}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(b){var d=this.s-b.s;if(d!=0){return d}var c=this.t;d=c-b.t;if(d!=0){return(this.s<0)?-d:d}while(--c>=0){if((d=this[c]-b[c])!=0){return d}}return 0}function nbits(a){var c=1,b;if((b=a>>>16)!=0){a=b;c+=16}if((b=a>>8)!=0){a=b;c+=8}if((b=a>>4)!=0){a=b;c+=4}if((b=a>>2)!=0){a=b;c+=2}if((b=a>>1)!=0){a=b;c+=1}return c}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(c,b){var a;for(a=this.t-1;a>=0;--a){b[a+c]=this[a]}for(a=c-1;a>=0;--a){b[a]=0}b.t=this.t+c;b.s=this.s}function bnpDRShiftTo(c,b){for(var a=c;a=0;--d){e[d+f+1]=(this[d]>>a)|h;h=(this[d]&g)<=0;--d){e[d]=0}e[f]=h;e.t=this.t+f+1;e.s=this.s;e.clamp()}function bnpRShiftTo(g,d){d.s=this.s;var e=Math.floor(g/this.DB);if(e>=this.t){d.t=0;return}var b=g%this.DB;var a=this.DB-b;var f=(1<>b;for(var c=e+1;c>b}if(b>0){d[this.t-e-1]|=(this.s&f)<>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g-=d.s}f.s=(g<0)?-1:0;if(g<-1){f[e++]=this.DV+g}else{if(g>0){f[e++]=g}}f.t=e;f.clamp()}function bnpMultiplyTo(c,e){var b=this.abs(),f=c.abs();var d=b.t;e.t=d+f.t;while(--d>=0){e[d]=0}for(d=0;d=0){d[b]=0}for(b=0;b=a.DV){d[b+a.t]-=a.DV;d[b+a.t+1]=1}}if(d.t>0){d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)}d.s=0;d.clamp()}function bnpDivRemTo(n,h,g){var w=n.abs();if(w.t<=0){return}var k=this.abs();if(k.t0){w.lShiftTo(v,d);k.lShiftTo(v,g)}else{w.copyTo(d);k.copyTo(g)}var p=d.t;var b=d[p-1];if(b==0){return}var o=b*(1<1)?d[p-2]>>this.F2:0);var A=this.FV/o,z=(1<=0){g[g.t++]=1;g.subTo(f,g)}BigInteger.ONE.dlShiftTo(p,f);f.subTo(d,d);while(d.t=0){var c=(g[--u]==b)?this.DM:Math.floor(g[u]*A+(g[u-1]+x)*z);if((g[u]+=d.am(0,c,g,s,0,p))0){g.rShiftTo(v,g)}if(a<0){BigInteger.ZERO.subTo(g,g)}}function bnMod(b){var c=nbi();this.abs().divRemTo(b,null,c);if(this.s<0&&c.compareTo(BigInteger.ZERO)>0){b.subTo(c,c)}return c}function Classic(a){this.m=a}function cConvert(a){if(a.s<0||a.compareTo(this.m)>=0){return a.mod(this.m)}else{return a}}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var a=this[0];if((a&1)==0){return 0}var b=a&3;b=(b*(2-(a&15)*b))&15;b=(b*(2-(a&255)*b))&255;b=(b*(2-(((a&65535)*b)&65535)))&65535;b=(b*(2-a*b%this.DV))%this.DV;return(b>0)?this.DV-b:-b}function Montgomery(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(a.DB-15))-1;this.mt2=2*a.t}function montConvert(a){var b=nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);if(a.s<0&&b.compareTo(BigInteger.ZERO)>0){this.m.subTo(b,b)}return b}function montRevert(a){var b=nbi();a.copyTo(b);this.reduce(b);return b}function montReduce(a){while(a.t<=this.mt2){a[a.t++]=0}for(var c=0;c>15)*this.mpl)&this.um)<<15))&a.DM;b=c+this.m.t;a[b]+=this.m.am(0,d,a,c,0,this.m.t);while(a[b]>=a.DV){a[b]-=a.DV;a[++b]++}}a.clamp();a.drShiftTo(this.m.t,a);if(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(h,j){if(h>4294967295||h<1){return BigInteger.ONE}var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;d.copyTo(f);while(--c>=0){j.sqrTo(f,a);if((h&(1<0){j.mulTo(a,d,f)}else{var b=f;f=a;a=b}}return j.revert(f)}function bnModPowInt(b,a){var c;if(b<256||a.isEven()){c=new Classic(a)}else{c=new Montgomery(a)}return this.exp(b,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction bnClone(){var a=nbi();this.copyTo(a);return a}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this[0]}else{if(this.t==0){return 0}}}return((this[1]&((1<<(32-this.DB))-1))<>24}function bnShortValue(){return(this.t==0)?this.s:(this[0]<<16)>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this[0]<=0)){return 0}else{return 1}}}function bnpToRadix(c){if(c==null){c=10}if(this.signum()==0||c<2||c>36){return\"0\"}var f=this.chunkSize(c);var e=Math.pow(c,f);var i=nbv(e),j=nbi(),h=nbi(),g=\"\";this.divRemTo(i,j,h);while(j.signum()>0){g=(e+h.intValue()).toString(c).substr(1)+g;j.divRemTo(i,j,h)}return h.intValue().toString(c)+g}function bnpFromRadix(m,h){this.fromInt(0);if(h==null){h=10}var f=this.chunkSize(h);var g=Math.pow(h,f),e=false,a=0,l=0;for(var c=0;c=f){this.dMultiply(g);this.dAddOffset(l,0);a=0;l=0}}if(a>0){this.dMultiply(Math.pow(h,a));this.dAddOffset(l,0)}if(e){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(f,e,h){if(\"number\"==typeof e){if(f<2){this.fromInt(1)}else{this.fromNumber(f,h);if(!this.testBit(f-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(f-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(e)){this.dAddOffset(2,0);if(this.bitLength()>f){this.subTo(BigInteger.ONE.shiftLeft(f-1),this)}}}}else{var d=new Array(),g=f&7;d.length=(f>>3)+1;e.nextBytes(d);if(g>0){d[0]&=((1<0){if(e>e)!=(this.s&this.DM)>>e){c[a++]=f|(this.s<<(this.DB-e))}while(b>=0){if(e<8){f=(this[b]&((1<>(e+=this.DB-8)}else{f=(this[b]>>(e-=8))&255;if(e<=0){e+=this.DB;--b}}if((f&128)!=0){f|=-256}if(a==0&&(this.s&128)!=(f&128)){++a}if(a>0||f!=this.s){c[a++]=f}}}return c}function bnEquals(b){return(this.compareTo(b)==0)}function bnMin(b){return(this.compareTo(b)<0)?this:b}function bnMax(b){return(this.compareTo(b)>0)?this:b}function bnpBitwiseTo(c,h,e){var d,g,b=Math.min(c.t,this.t);for(d=0;d>=16;b+=16}if((a&255)==0){a>>=8;b+=8}if((a&15)==0){a>>=4;b+=4}if((a&3)==0){a>>=2;b+=2}if((a&1)==0){++b}return b}function bnGetLowestSetBit(){for(var a=0;a=this.t){return(this.s!=0)}return((this[a]&(1<<(b%this.DB)))!=0)}function bnpChangeBit(c,b){var a=BigInteger.ONE.shiftLeft(c);this.bitwiseTo(a,b,a);return a}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(d,f){var e=0,g=0,b=Math.min(d.t,this.t);while(e>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g+=d.s}f.s=(g<0)?-1:0;if(g>0){f[e++]=g}else{if(g<-1){f[e++]=this.DV+g}}f.t=e;f.clamp()}function bnAdd(b){var c=nbi();this.addTo(b,c);return c}function bnSubtract(b){var c=nbi();this.subTo(b,c);return c}function bnMultiply(b){var c=nbi();this.multiplyTo(b,c);return c}function bnSquare(){var a=nbi();this.squareTo(a);return a}function bnDivide(b){var c=nbi();this.divRemTo(b,c,null);return c}function bnRemainder(b){var c=nbi();this.divRemTo(b,null,c);return c}function bnDivideAndRemainder(b){var d=nbi(),c=nbi();this.divRemTo(b,d,c);return new Array(d,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(b,a){if(b==0){return}while(this.t<=a){this[this.t++]=0}this[a]+=b;while(this[a]>=this.DV){this[a]-=this.DV;if(++a>=this.t){this[this.t++]=0}++this[a]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,c,b){a.multiplyTo(c,b)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp())}function bnpMultiplyLowerTo(b,f,e){var d=Math.min(this.t+b.t,f);e.s=0;e.t=d;while(d>0){e[--d]=0}var c;for(c=e.t-this.t;d=0){d[c]=0}for(c=Math.max(e-this.t,0);c2*this.m.t){return a.mod(this.m)}else{if(a.compareTo(this.m)<0){return a}else{var b=nbi();a.copyTo(b);this.reduce(b);return b}}}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1){a.t=this.m.t+1;a.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0){a.dAddOffset(1,this.m.t+1)}a.subTo(this.r2,a);while(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(q,f){var o=q.bitLength(),h,b=nbv(1),v;if(o<=0){return b}else{if(o<18){h=1}else{if(o<48){h=3}else{if(o<144){h=4}else{if(o<768){h=5}else{h=6}}}}}if(o<8){v=new Classic(f)}else{if(f.isEven()){v=new Barrett(f)}else{v=new Montgomery(f)}}var p=new Array(),d=3,s=h-1,a=(1<1){var A=nbi();v.sqrTo(p[1],A);while(d<=a){p[d]=nbi();v.mulTo(A,p[d-2],p[d]);d+=2}}var l=q.t-1,x,u=true,c=nbi(),y;o=nbits(q[l])-1;while(l>=0){if(o>=s){x=(q[l]>>(o-s))&a}else{x=(q[l]&((1<<(o+1))-1))<<(s-o);if(l>0){x|=q[l-1]>>(this.DB+o-s)}}d=h;while((x&1)==0){x>>=1;--d}if((o-=d)<0){o+=this.DB;--l}if(u){p[x].copyTo(b);u=false}else{while(d>1){v.sqrTo(b,c);v.sqrTo(c,b);d-=2}if(d>0){v.sqrTo(b,c)}else{y=b;b=c;c=y}v.mulTo(c,p[x],b)}while(l>=0&&(q[l]&(1<0){b.rShiftTo(f,b);h.rShiftTo(f,h)}while(b.signum()>0){if((d=b.getLowestSetBit())>0){b.rShiftTo(d,b)}if((d=h.getLowestSetBit())>0){h.rShiftTo(d,h)}if(b.compareTo(h)>=0){b.subTo(h,b);b.rShiftTo(1,b)}else{h.subTo(b,h);h.rShiftTo(1,h)}}if(f>0){h.lShiftTo(f,h)}return h}function bnpModInt(e){if(e<=0){return 0}var c=this.DV%e,b=(this.s<0)?e-1:0;if(this.t>0){if(c==0){b=this[0]%e}else{for(var a=this.t-1;a>=0;--a){b=(c*b+this[a])%e}}}return b}function bnModInverse(f){var j=f.isEven();if((this.isEven()&&j)||f.signum()==0){return BigInteger.ZERO}var i=f.clone(),h=this.clone();var g=nbv(1),e=nbv(0),l=nbv(0),k=nbv(1);while(i.signum()!=0){while(i.isEven()){i.rShiftTo(1,i);if(j){if(!g.isEven()||!e.isEven()){g.addTo(this,g);e.subTo(f,e)}g.rShiftTo(1,g)}else{if(!e.isEven()){e.subTo(f,e)}}e.rShiftTo(1,e)}while(h.isEven()){h.rShiftTo(1,h);if(j){if(!l.isEven()||!k.isEven()){l.addTo(this,l);k.subTo(f,k)}l.rShiftTo(1,l)}else{if(!k.isEven()){k.subTo(f,k)}}k.rShiftTo(1,k)}if(i.compareTo(h)>=0){i.subTo(h,i);if(j){g.subTo(l,g)}e.subTo(k,e)}else{h.subTo(i,h);if(j){l.subTo(g,l)}k.subTo(e,k)}}if(h.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(k.compareTo(f)>=0){return k.subtract(f)}if(k.signum()<0){k.addTo(f,k)}else{return k}if(k.signum()<0){return k.add(f)}else{return k}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(e){var d,b=this.abs();if(b.t==1&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d>1;if(f>lowprimes.length){f=lowprimes.length}var b=nbi();for(var e=0;e>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(window!==undefined&&(window.crypto!==undefined||window.msCrypto!==undefined)){var crypto=window.crypto||window.msCrypto;if(crypto.getRandomValues){var ua=new Uint8Array(32);crypto.getRandomValues(ua);for(t=0;t<32;++t){rng_pool[rng_pptr++]=ua[t]}}else{if(navigator.appName==\"Netscape\"&&navigator.appVersion<\"5\"){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr=0&&h>0){var f=e.charCodeAt(d--);if(f<128){g[--h]=f}else{if((f>127)&&(f<2048)){g[--h]=(f&63)|128;g[--h]=(f>>6)|192}else{g[--h]=(f&63)|128;g[--h]=((f>>6)&63)|128;g[--h]=(f>>12)|224}}}g[--h]=0;var b=new SecureRandom();var a=new Array();while(h>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}g[--h]=a[0]}g[--h]=2;g[--h]=0;return new BigInteger(g)}function oaep_mgf1_arr(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255])));d+=1}return b}function oaep_pad(q,a,f,l){var c=KJUR.crypto.MessageDigest;var o=KJUR.crypto.Util;var b=null;if(!f){f=\"sha1\"}if(typeof f===\"string\"){b=c.getCanonicalAlgName(f);l=c.getHashLength(b);f=function(i){return hextorstr(o.hashHex(rstrtohex(i),b))}}if(q.length+2*l+2>a){throw\"Message too long for RSA\"}var k=\"\",e;for(e=0;e0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{throw\"Invalid RSA public key\"}}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var e=this.doPublic(a);if(e==null){return null}var b=e.toString(16);if((b.length&1)==0){return b}else{return\"0\"+b}}function RSAEncryptOAEP(f,e,b){var a=oaep_pad(f,(this.n.bitLength()+7)>>3,e,b);if(a==null){return null}var g=this.doPublic(a);if(g==null){return null}var d=g.toString(16);if((d.length&1)==0){return d}else{return\"0\"+d}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;RSAKey.prototype.encryptOAEP=RSAEncryptOAEP;RSAKey.prototype.type=\"RSA\";\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction pkcs1unpad2(g,j){var a=g.toByteArray();var f=0;while(f=a.length){return null}}var e=\"\";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}function oaep_unpad(o,b,g,p){var e=KJUR.crypto.MessageDigest;var r=KJUR.crypto.Util;var c=null;if(!g){g=\"sha1\"}if(typeof g===\"string\"){c=e.getCanonicalAlgName(g);p=e.getHashLength(c);g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}}o=o.toByteArray();var h;for(h=0;h0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{throw\"Invalid RSA private key\"}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;this.isPublic=false;if(g==null){throw\"RSASetPrivateEx N == null\"}if(d==null){throw\"RSASetPrivateEx E == null\"}if(g.length==0){throw\"RSASetPrivateEx N.length == 0\"}if(d.length==0){throw\"RSASetPrivateEx E.length == 0\"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{throw\"Invalid RSA private key in RSASetPrivateEx\"}}function RSAGenerate(b,i){var a=new SecureRandom();var f=b>>1;this.e=parseInt(i,16);var c=new BigInteger(i,16);for(;;){for(;;){this.p=new BigInteger(b-f,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(f,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var h=this.p;this.p=this.q;this.q=h}var g=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var e=g.multiply(d);if(e.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(e);this.dmp1=this.d.mod(g);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=true}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}function RSADecryptOAEP(e,d,b){var f=parseBigInt(e,16);var a=this.doPrivate(f);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,d,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP;\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction ECFieldElementFp(b,a){this.x=a;this.q=b}function feFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.x.equals(a.x))}function feFpToBigInteger(){return this.x}function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))}function feFpAdd(a){return new ECFieldElementFp(this.q,this.x.add(a.toBigInteger()).mod(this.q))}function feFpSubtract(a){return new ECFieldElementFp(this.q,this.x.subtract(a.toBigInteger()).mod(this.q))}function feFpMultiply(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger()).mod(this.q))}function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))}function feFpDivide(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger().modInverse(this.q)).mod(this.q))}ECFieldElementFp.prototype.equals=feFpEquals;ECFieldElementFp.prototype.toBigInteger=feFpToBigInteger;ECFieldElementFp.prototype.negate=feFpNegate;ECFieldElementFp.prototype.add=feFpAdd;ECFieldElementFp.prototype.subtract=feFpSubtract;ECFieldElementFp.prototype.multiply=feFpMultiply;ECFieldElementFp.prototype.square=feFpSquare;ECFieldElementFp.prototype.divide=feFpDivide;function ECPointFp(c,a,d,b){this.curve=c;this.x=a;this.y=d;if(b==null){this.z=BigInteger.ONE}else{this.z=b}this.zinv=null}function pointFpGetX(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpGetY(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpEquals(a){if(a==this){return true}if(this.isInfinity()){return a.isInfinity()}if(a.isInfinity()){return this.isInfinity()}var c,b;c=a.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(a.z)).mod(this.curve.q);if(!c.equals(BigInteger.ZERO)){return false}b=a.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(a.z)).mod(this.curve.q);return b.equals(BigInteger.ZERO)}function pointFpIsInfinity(){if((this.x==null)&&(this.y==null)){return true}return this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)}function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)}function pointFpAdd(l){if(this.isInfinity()){return l}if(l.isInfinity()){return this}var p=l.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(l.z)).mod(this.curve.q);var o=l.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(l.z)).mod(this.curve.q);if(BigInteger.ZERO.equals(o)){if(BigInteger.ZERO.equals(p)){return this.twice()}return this.curve.getInfinity()}var j=new BigInteger(\"3\");var e=this.x.toBigInteger();var n=this.y.toBigInteger();var c=l.x.toBigInteger();var k=l.y.toBigInteger();var m=o.square();var i=m.multiply(o);var d=e.multiply(m);var g=p.square().multiply(this.z);var a=g.subtract(d.shiftLeft(1)).multiply(l.z).subtract(i).multiply(o).mod(this.curve.q);var h=d.multiply(j).multiply(p).subtract(n.multiply(i)).subtract(g.multiply(p)).multiply(l.z).add(p.multiply(i)).mod(this.curve.q);var f=i.multiply(this.z).multiply(l.z).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),f)}function pointFpTwice(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var g=new BigInteger(\"3\");var c=this.x.toBigInteger();var h=this.y.toBigInteger();var e=h.multiply(this.z);var j=e.multiply(h).mod(this.curve.q);var i=this.curve.a.toBigInteger();var k=c.square().multiply(g);if(!BigInteger.ZERO.equals(i)){k=k.add(this.z.square().multiply(i))}k=k.mod(this.curve.q);var b=k.square().subtract(c.shiftLeft(3).multiply(j)).shiftLeft(1).multiply(e).mod(this.curve.q);var f=k.multiply(g).multiply(c).subtract(j.shiftLeft(1)).shiftLeft(2).multiply(j).subtract(k.square().multiply(k)).mod(this.curve.q);var d=e.square().multiply(e).shiftLeft(3).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(b),this.curve.fromBigInteger(f),d)}function pointFpMultiply(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add(a?this:l)}}return d}function pointFpMultiplyTwo(c,a,b){var d;if(c.bitLength()>b.bitLength()){d=c.bitLength()-1}else{d=b.bitLength()-1}var f=this.curve.getInfinity();var e=this.add(a);while(d>=0){f=f.twice();if(c.testBit(d)){if(b.testBit(d)){f=f.add(e)}else{f=f.add(this)}}else{if(b.testBit(d)){f=f.add(a)}}--d}return f}ECPointFp.prototype.getX=pointFpGetX;ECPointFp.prototype.getY=pointFpGetY;ECPointFp.prototype.equals=pointFpEquals;ECPointFp.prototype.isInfinity=pointFpIsInfinity;ECPointFp.prototype.negate=pointFpNegate;ECPointFp.prototype.add=pointFpAdd;ECPointFp.prototype.twice=pointFpTwice;ECPointFp.prototype.multiply=pointFpMultiply;ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo;function ECCurveFp(e,d,c){this.q=e;this.a=this.fromBigInteger(d);this.b=this.fromBigInteger(c);this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b))}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)}function curveFpDecodePointHex(d){switch(parseInt(d.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var a=(d.length-2)/2;var c=d.substr(2,a);var b=d.substr(a+2,a);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(b,16)));default:return null}}ECCurveFp.prototype.getQ=curveFpGetQ;ECCurveFp.prototype.getA=curveFpGetA;ECCurveFp.prototype.getB=curveFpGetB;ECCurveFp.prototype.equals=curveFpEquals;ECCurveFp.prototype.getInfinity=curveFpGetInfinity;ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger;ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex;\n/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib\n */\nECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};ECPointFp.prototype.getEncoded=function(c){var d=function(h,f){var g=h.toByteArrayUnsigned();if(fg.length){g.unshift(0)}}return g};var a=this.getX().toBigInteger();var e=this.getY().toBigInteger();var b=d(a,32);if(c){if(e.isEven()){b.unshift(2)}else{b.unshift(3)}}else{b.unshift(4);b=b.concat(d(e,32))}return b};ECPointFp.decodeFrom=function(g,c){var f=c[0];var e=c.length-1;var d=c.slice(1,1+e/2);var b=c.slice(1+e/2,1+e);d.unshift(0);b.unshift(0);var a=new BigInteger(d);var h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.decodeFromHex=function(g,c){var f=c.substr(0,2);var e=c.length-2;var d=c.substr(2,e/2);var b=c.substr(2+e/2,e/2);var a=new BigInteger(d,16);var h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.prototype.add2D=function(c){if(this.isInfinity()){return c}if(c.isInfinity()){return this}if(this.x.equals(c.x)){if(this.y.equals(c.y)){return this.twice()}return this.curve.getInfinity()}var g=c.x.subtract(this.x);var e=c.y.subtract(this.y);var a=e.divide(g);var d=a.square().subtract(this.x).subtract(c.x);var f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var b=this.curve.fromBigInteger(BigInteger.valueOf(2));var e=this.curve.fromBigInteger(BigInteger.valueOf(3));var a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b));var c=a.square().subtract(this.x.multiply(b));var d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)};ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add2D(a?this:l)}}return d};ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger();var i=this.getY().toBigInteger();var f=this.curve.getA().toBigInteger();var c=this.curve.getB().toBigInteger();var h=this.curve.getQ();var e=i.multiply(i).mod(h);var g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)};ECPointFp.prototype.toString=function(){return\"(\"+this.getX().toBigInteger().toString()+\",\"+this.getY().toBigInteger().toString()+\")\"};ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity()){throw new Error(\"Point is at infinity.\")}var a=this.getX().toBigInteger();var b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"x coordinate out of bounds\")}if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"y coordinate out of bounds\")}if(!this.isOnCurve()){throw new Error(\"Point is not on the curve.\")}if(this.multiply(c).isInfinity()){throw new Error(\"Point is not a scalar multiple of G.\")}return true};\n/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval\n */\nvar jsonParse=(function(){var e=\"(?:-?\\\\b(?:0|[1-9][0-9]*)(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\\\b)\";var j='(?:[^\\\\0-\\\\x08\\\\x0a-\\\\x1f\"\\\\\\\\]|\\\\\\\\(?:[\"/\\\\\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:\"'+j+'*\")';var d=new RegExp(\"(?:false|true|null|[\\\\{\\\\}\\\\[\\\\]]|\"+e+\"|\"+i+\")\",\"g\");var k=new RegExp(\"\\\\\\\\(?:([^u])|u(.{4}))\",\"g\");var g={'\"':'\"',\"/\":\"/\",\"\\\\\":\"\\\\\",b:\"\\b\",f:\"\\f\",n:\"\\n\",r:\"\\r\",t:\"\\t\"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String(\"\");var a=\"\\\\\";var f={\"{\":Object,\"[\":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if(\"{\"===v){x={}}else{if(\"[\"===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({\"\":x},\"\")}return x}})();\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.asn1==\"undefined\"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b=\"0\"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!=\"-\"){if(f.length%2==1){f=\"0\"+f}else{if(!f.match(/^[0-7]/)){f=\"00\"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g=\"\";for(var d=0;d15){throw\"ASN.1 length too long to represent by 8x: n = \"+i.toString(16)}var f=128+g;return f.toString(16)+h}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return\"\"}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!=\"undefined\"){if(typeof c==\"string\"){this.setString(c)}else{if(typeof c.str!=\"undefined\"){this.setString(c.str)}else{if(typeof c.hex!=\"undefined\"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(f){utc=f.getTime()+(f.getTimezoneOffset()*60000);var e=new Date(utc);return e};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o==\"utc\"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,\"\");r=r+\".\"+k}}return r+\"Z\"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join(\"0\")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!=\"undefined\"){if(typeof b.array!=\"undefined\"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT=\"01\";this.hTLV=\"0101ff\"};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT=\"02\";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!=\"undefined\"){if(typeof a.bigint!=\"undefined\"){this.setByBigInteger(a.bigint)}else{if(typeof a[\"int\"]!=\"undefined\"){this.setByInteger(a[\"int\"])}else{if(typeof a==\"number\"){this.setByInteger(a)}else{if(typeof a.hex!=\"undefined\"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!==\"undefined\"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex=\"00\"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT=\"03\";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=(l*2))){break}if(d>=200){break}g.push(b);c=b;d++}return g};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){throw\"checking tag doesn't match: \"+e.substr(d,2)+\"!=\"+i}}return d}f=c.shift();b=g.getChildIdx(e,d);return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getTLVbyList=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyList(d,c,b);if(a===undefined){throw\"can't find nthList object\"}if(f!==undefined){if(d.substr(a,2)!=f){throw\"checking tag doesn't match: \"+d.substr(a,2)+\"!=\"+f}}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a===undefined){throw\"can't find nthList object\"}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join(\"0\")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+\".\"+j.join(\".\")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+\"..(total \"+A.length/2+\"bytes)..\"+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=\"\"}var x=c.ommit_long_octet;if(e.substr(l,2)==\"01\"){var h=j(e,l);if(h==\"00\"){return g+\"BOOLEAN FALSE\\n\"}else{return g+\"BOOLEAN TRUE\\n\"}}if(e.substr(l,2)==\"02\"){var h=j(e,l);return g+\"INTEGER \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"03\"){var h=j(e,l);return g+\"BITSTRING \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"04\"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+\"OCTETSTRING, encapsulates\\n\";k=k+y(h,c,0,g+\" \");return k}else{return g+\"OCTETSTRING \"+q(h,x)+\"\\n\"}}if(e.substr(l,2)==\"05\"){return g+\"NULL\\n\"}if(e.substr(l,2)==\"06\"){var m=j(e,l);var a=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(a);var b=a.replace(/\\./g,\" \");if(o!=\"\"){return g+\"ObjectIdentifier \"+o+\" (\"+b+\")\\n\"}else{return g+\"ObjectIdentifier (\"+b+\")\\n\"}}if(e.substr(l,2)==\"0c\"){return g+\"UTF8String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"13\"){return g+\"PrintableString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"14\"){return g+\"TeletexString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"16\"){return g+\"IA5String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"17\"){return g+\"UTCTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"18\"){return g+\"GeneralizedTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"30\"){if(e.substr(l,4)==\"3000\"){return g+\"SEQUENCE {}\\n\"}var k=g+\"SEQUENCE\\n\";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)==\"06\"&&e.substr(d[d.length-1],2)==\"04\"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u0){var m=new f({array:this.extensionsArray});var k=new c({explicit:true,tag:\"a3\",obj:m});this.asn1Array.push(k)}var n=new f({array:this.asn1Array});this.hTLV=n.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension=function(d){KJUR.asn1.x509.Extension.superclass.constructor.call(this);var f=null,a=KJUR,e=a.asn1,h=e.DERObjectIdentifier,i=e.DEROctetString,b=e.DERBitString,g=e.DERBoolean,c=e.DERSequence;this.getEncodedHex=function(){var m=new h({oid:this.oid});var l=new i({hex:this.getExtnValueHex()});var k=new Array();k.push(m);if(this.critical){k.push(new g())}k.push(l);var j=new c({array:k});return j.getEncodedHex()};this.critical=false;if(d!==undefined){if(d.critical!==undefined){this.critical=d.critical}}};YAHOO.lang.extend(KJUR.asn1.x509.Extension,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension.appendByNameToArray=function(e,c,b){var g=e.toLowerCase(),f=KJUR.asn1.x509;if(g==\"basicconstraints\"){var d=new f.BasicConstraints(c);b.push(d)}else{if(g==\"keyusage\"){var d=new f.KeyUsage(c);b.push(d)}else{if(g==\"crldistributionpoints\"){var d=new f.CRLDistributionPoints(c);b.push(d)}else{if(g==\"extkeyusage\"){var d=new f.ExtKeyUsage(c);b.push(d)}else{if(g==\"authoritykeyidentifier\"){var d=new f.AuthorityKeyIdentifier(c);b.push(d)}else{if(g==\"authorityinfoaccess\"){var d=new f.AuthorityInfoAccess(c);b.push(d)}else{if(g==\"subjectaltname\"){var d=new f.SubjectAltName(c);b.push(d)}else{if(g==\"issueraltname\"){var d=new f.IssuerAltName(c);b.push(d)}else{throw\"unsupported extension name: \"+e}}}}}}}}};KJUR.asn1.x509.KeyUsage=function(f){KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this,f);var a=X509.KEYUSAGE_NAME;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.15\";if(f!==undefined){if(f.bin!==undefined){this.asn1ExtnValue=new KJUR.asn1.DERBitString(f)}if(f.names!==undefined&&f.names.length!==undefined){var e=f.names;var d=\"000000000\";for(var c=0;c-1){e.push(new KJUR.asn1.DERInteger({\"int\":this.pathLen}))}var d=new KJUR.asn1.DERSequence({array:e});this.asn1ExtnValue=d;return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.19\";this.cA=false;this.pathLen=-1;if(c!==undefined){if(c.cA!==undefined){this.cA=c.cA}if(c.pathLen!==undefined){this.pathLen=c.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){this.asn1ExtnValue=new a.DERSequence({array:e})};this.setByOneURI=function(h){var e=new c.GeneralNames([{uri:h}]);var g=new c.DistributionPointName(e);var f=new c.DistributionPoint({dpobj:g});this.setByDPArray([f])};this.oid=\"2.5.29.31\";if(d!==undefined){if(d.array!==undefined){this.setByDPArray(d.array)}else{if(d.uri!==undefined){this.setByOneURI(d.uri)}}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLDistributionPoints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.ExtKeyUsage=function(c){KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,c);var b=KJUR,a=b.asn1;this.setPurposeArray=function(d){this.asn1ExtnValue=new a.DERSequence();for(var e=0;e0){var h=new b({array:this.aRevokedCert});this.asn1Array.push(h)}var i=new b({array:this.asn1Array});this.hTLV=i.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize=function(){this.asn1Version=null;this.asn1SignatureAlg=null;this.asn1Issuer=null;this.asn1ThisUpdate=null;this.asn1NextUpdate=null;this.aRevokedCert=new Array()};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertList,KJUR.asn1.ASN1Object);KJUR.asn1.x509.CRLEntry=function(e){KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);var d=null,c=null,b=KJUR,a=b.asn1;this.setCertSerial=function(f){this.sn=new a.DERInteger(f)};this.setRevocationDate=function(f){this.time=new a.x509.Time(f)};this.getEncodedHex=function(){var f=new a.DERSequence({array:[this.sn,this.time]});this.TLV=f.getEncodedHex();return this.TLV};if(e!==undefined){if(e.time!==undefined){this.setRevocationDate(e.time)}if(e.sn!==undefined){this.setCertSerial(e.sn)}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLEntry,KJUR.asn1.ASN1Object);KJUR.asn1.x509.X500Name=function(f){KJUR.asn1.x509.X500Name.superclass.constructor.call(this);this.asn1Array=new Array();var d=KJUR,c=d.asn1,e=c.x509,b=pemtohex;this.setByString=function(g){var k=g.split(\"/\");k.shift();var j=[];for(var l=0;l0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+\",\"+h).replace(/\\\\,/g,\",\");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)===\"\\\\\"){e=true}}b=b.map(function(a){return a.replace(\"/\",\"\\\\/\")});b.reverse();return\"/\"+b.join(\"/\")};KJUR.asn1.x509.RDN=function(a){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=new Array();this.addByString=function(b){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:b}))};this.addByMultiValuedString=function(d){var b=KJUR.asn1.x509.RDN.parseString(d);for(var c=0;c0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+\"+\"+k).replace(/\\\\\\+/g,\"+\");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)===\"\\\\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/\"$/)){var d=(e+\"+\"+k).replace(/^([^=]+)=\"(.*)\"$/,\"$1=$2\");b.push(d);l=false}else{b.push(e+\"+\"+k)}}else{b.push(k)}if(k.match(/^[^=]+=\"/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(d){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var f=null,e=null,a=\"utf8\",c=KJUR,b=c.asn1;this.setByString=function(h){var g=h.match(/^([^=]+)=(.+)$/);if(g){this.setByAttrTypeAndValueStr(g[1],g[2])}else{throw\"malformed attrTypeAndValueStr: \"+h}};this.setByAttrTypeAndValueStr=function(i,h){this.typeObj=KJUR.asn1.x509.OID.atype2obj(i);var g=a;if(i==\"C\"){g=\"prn\"}this.valueObj=this.getValueObj(g,h)};this.getValueObj=function(h,g){if(h==\"utf8\"){return new b.DERUTF8String({str:g})}if(h==\"prn\"){return new b.DERPrintableString({str:g})}if(h==\"tel\"){return new b.DERTeletexString({str:g})}if(h==\"ia5\"){return new b.DERIA5String({str:g})}throw\"unsupported directory string type: type=\"+h+\" value=\"+g};this.getEncodedHex=function(){var g=new b.DERSequence({array:[this.typeObj,this.valueObj]});this.TLV=g.getEncodedHex();return this.TLV};if(d!==undefined){if(d.str!==undefined){this.setByString(d.str)}}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw\"algId and/or subjPubKey not set\"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{\"int\":{bigint:q.n}},{\"int\":{\"int\":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:\"rsaEncryption\"});this.asn1SubjPKey=new b({hex:\"00\"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:\"ecPublicKey\",asn1params:r});this.asn1SubjPKey=new b({hex:\"00\"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{\"int\":{bigint:q.p}},{\"int\":{bigint:q.q}},{\"int\":{bigint:q.g}}]});this.asn1AlgId=new o({name:\"dsa\",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:\"00\"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type==\"utc\"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type==\"utc\"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type=\"utc\";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type=\"utc\"}if(f.str.match(/^[0-9]{14}Z$/)){this.type=\"gen\"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(d){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw\"algorithm not specified\"}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var e=[this.asn1Alg];if(this.asn1Params!==null){e.push(this.asn1Params)}var f=new a.DERSequence({array:e});this.hTLV=f.getEncodedHex();return this.hTLV};if(d!==undefined){if(d.name!==undefined){this.nameAlg=d.name}if(d.asn1params!==undefined){this.asn1Params=d.asn1params}if(d.paramempty!==undefined){this.paramEmpty=d.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){var c=this.nameAlg.toLowerCase();if(c.substr(-7,7)!==\"withdsa\"&&c.substr(-9,9)!==\"withecdsa\"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:\"81\",dns:\"82\",dn:\"a4\",uri:\"86\",ip:\"87\"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type=\"rfc822\";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type=\"dns\";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type=\"uri\";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({str:p.dn})}if(p.ldapdn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certissuer param not cert\"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certsubj param not cert\"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type=\"ip\";this.explicit=false;var q=p.ip;var s;var n=\"malformed IP address\";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex(\"[\"+q.split(\".\").join(\",\")+\"]\");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw\"unsupported type in params=\"+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){r=new b({obj:this.dUnsignedAttrs,tag:\"a1\",explicit:false})}var q=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,o,this.dSigAlg,this.dSig,];if(r!=null){q.push(r)}var p=new h.DERSequence({array:q});this.hTLV=p.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.SignerInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.EncapsulatedContentInfo=function(g){var c=KJUR,b=c.asn1,e=b.DERTaggedObject,a=b.DERSequence,h=b.DERObjectIdentifier,d=b.DEROctetString,f=b.cms;f.EncapsulatedContentInfo.superclass.constructor.call(this);this.dEContentType=new h({name:\"data\"});this.dEContent=null;this.isDetached=false;this.eContentValueHex=null;this.setContentType=function(i){if(i.match(/^[0-2][.][0-9.]+$/)){this.dEContentType=new h({oid:i})}else{this.dEContentType=new h({name:i})}};this.setContentValue=function(i){if(i!==undefined){if(typeof i.hex==\"string\"){this.eContentValueHex=i.hex}else{if(typeof i.str==\"string\"){this.eContentValueHex=utf8tohex(i.str)}}}};this.setContentValueHex=function(i){this.eContentValueHex=i};this.setContentValueStr=function(i){this.eContentValueHex=utf8tohex(i)};this.getEncodedHex=function(){if(typeof this.eContentValueHex!=\"string\"){throw\"eContentValue not yet set\"}var k=new d({hex:this.eContentValueHex});this.dEContent=new e({obj:k,tag:\"a0\",explicit:true});var i=[this.dEContentType];if(!this.isDetached){i.push(this.dEContent)}var j=new a({array:i});this.hTLV=j.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.EncapsulatedContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.ContentInfo=function(f){var c=KJUR,b=c.asn1,d=b.DERTaggedObject,a=b.DERSequence,e=b.x509;KJUR.asn1.cms.ContentInfo.superclass.constructor.call(this);this.dContentType=null;this.dContent=null;this.setContentType=function(g){if(typeof g==\"string\"){this.dContentType=e.OID.name2obj(g)}};this.getEncodedHex=function(){var h=new d({obj:this.dContent,tag:\"a0\",explicit:true});var g=new a({array:[this.dContentType,h]});this.hTLV=g.getEncodedHex();return this.hTLV};if(f!==undefined){if(f.type){this.setContentType(f.type)}if(f.obj&&f.obj instanceof b.ASN1Object){this.dContent=f.obj}}};YAHOO.lang.extend(KJUR.asn1.cms.ContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.SignedData=function(e){var a=KJUR,h=a.asn1,j=h.ASN1Object,g=h.DERInteger,m=h.DERSet,f=h.DERSequence,b=h.DERTaggedObject,l=h.cms,i=l.EncapsulatedContentInfo,d=l.SignerInfo,n=l.ContentInfo,c=h.x509,k=c.AlgorithmIdentifier;KJUR.asn1.cms.SignedData.superclass.constructor.call(this);this.dCMSVersion=new g({\"int\":1});this.dDigestAlgs=null;this.digestAlgNameList=[];this.dEncapContentInfo=new i();this.dCerts=null;this.certificateList=[];this.crlList=[];this.signerInfoList=[new d()];this.addCertificatesByPEM=function(p){var q=pemtohex(p);var r=new j();r.hTLV=q;this.certificateList.push(r)};this.getEncodedHex=function(){if(typeof this.hTLV==\"string\"){return this.hTLV}if(this.dDigestAlgs==null){var u=[];for(var t=0;t0){var v=new m({array:this.certificateList});this.dCerts=new b({obj:v,tag:\"a0\",explicit:false})}}if(this.dCerts!=null){p.push(this.dCerts)}var r=new m({array:this.signerInfoList});p.push(r);var q=new f({array:p});this.hTLV=q.getEncodedHex();return this.hTLV};this.getContentInfo=function(){this.getEncodedHex();var o=new n({type:\"signed-data\",obj:this});return o};this.getContentInfoEncodedHex=function(){var o=this.getContentInfo();var p=o.getEncodedHex();return p};this.getPEM=function(){return hextopem(this.getContentInfoEncodedHex(),\"CMS\")}};YAHOO.lang.extend(KJUR.asn1.cms.SignedData,KJUR.asn1.ASN1Object);KJUR.asn1.cms.CMSUtil=new function(){};KJUR.asn1.cms.CMSUtil.newSignedData=function(d){var b=KJUR,j=b.asn1,q=j.cms,f=q.SignerInfo,n=q.SignedData,o=q.SigningTime,a=q.SigningCertificate,p=q.SigningCertificateV2,c=j.cades,e=c.SignaturePolicyIdentifier;var m=new n();m.dEncapContentInfo.setContentValue(d.content);if(typeof d.certs==\"object\"){for(var h=0;h0){var s=new f({array:this.extensionsArray});var r=new m({array:[s]});var q=new f({array:[new k({oid:\"1.2.840.113549.1.9.14\"}),r]});var p=new c({explicit:true,tag:\"a0\",obj:q});this.asn1Array.push(p)}else{var p=new c({explicit:false,tag:\"a0\",obj:new j()});this.asn1Array.push(p)}var t=new f({array:this.asn1Array});this.hTLV=t.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CSRUtil=new function(){};KJUR.asn1.csr.CSRUtil.newCSRPEM=function(h){var c=KEYUTIL,b=KJUR.asn1.csr;if(h.subject===undefined){throw\"parameter subject undefined\"}if(h.sbjpubkey===undefined){throw\"parameter sbjpubkey undefined\"}if(h.sigalg===undefined){throw\"parameter sigalg undefined\"}if(h.sbjprvkey===undefined){throw\"parameter sbjpubkey undefined\"}var d=new b.CertificationRequestInfo();d.setSubjectByParam(h.subject);d.setSubjectPublicKeyByGetKey(h.sbjpubkey);if(h.ext!==undefined&&h.ext.length!==undefined){for(var e=0;ef.length){f=c[d]}}e=e.replace(f,\"::\");return e.slice(1,-1)}function hextoip(b){var d=\"malformed hex value\";if(!b.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){throw d}if(b.length==8){var c;try{c=parseInt(b.substr(0,2),16)+\".\"+parseInt(b.substr(2,2),16)+\".\"+parseInt(b.substr(4,2),16)+\".\"+parseInt(b.substr(6,2),16);return c}catch(a){throw d}}else{if(b.length==32){return hextoipv6(b)}else{return b}}}function iptohex(f){var j=\"malformed IP address\";f=f.toLowerCase(f);if(f.match(/^[0-9.]+$/)){var b=f.split(\".\");if(b.length!==4){throw j}var g=\"\";try{for(var e=0;e<4;e++){var h=parseInt(b[e]);g+=(\"0\"+h.toString(16)).slice(-2)}return g}catch(c){throw j}}else{if(f.match(/^[0-9a-f:]+$/)&&f.indexOf(\":\")!==-1){return ipv6tohex(f)}else{throw j}}}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b=\"\";for(var c=0;c\"7\"){return\"00\"+a}return a}function intarystrtohex(b){b=b.replace(/^\\s*\\[\\s*/,\"\");b=b.replace(/\\s*\\]\\s*$/,\"\");b=b.replace(/\\s*/g,\"\");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;bd){throw\"key is too short for SigAlg: keylen=\"+j+\",\"+a}var b=\"0001\";var k=\"00\"+c;var g=\"\";var l=d-b.length-k.length;for(var f=0;f=0;--p){q=q.twice2D();q.z=BigInteger.ONE;if(o.testBit(p)){if(n.testBit(p)){q=q.add2D(t)}else{q=q.add2D(s)}}else{if(n.testBit(p)){q=q.add2D(r)}}}return q}this.getBigRandom=function(i){return new BigInteger(i.bitLength(),a).mod(i.subtract(BigInteger.ONE)).add(BigInteger.ONE)};this.setNamedCurve=function(i){this.ecparams=KJUR.crypto.ECParameterDB.getByName(i);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=i};this.setPrivateKeyHex=function(i){this.isPrivate=true;this.prvKeyHex=i};this.setPublicKeyHex=function(i){this.isPublic=true;this.pubKeyHex=i};this.getPublicKeyXYHex=function(){var k=this.pubKeyHex;if(k.substr(0,2)!==\"04\"){throw\"this method supports uncompressed format(04) only\"}var j=this.ecparams.keylen/4;if(k.length!==2+j*2){throw\"malformed public key hex length\"}var i={};i.x=k.substr(2,j);i.y=k.substr(2+j);return i};this.getShortNISTPCurveName=function(){var i=this.curveName;if(i===\"secp256r1\"||i===\"NIST P-256\"||i===\"P-256\"||i===\"prime256v1\"){return\"P-256\"}if(i===\"secp384r1\"||i===\"NIST P-384\"||i===\"P-384\"){return\"P-384\"}return null};this.generateKeyPairHex=function(){var k=this.ecparams.n;var n=this.getBigRandom(k);var l=this.ecparams.G.multiply(n);var q=l.getX().toBigInteger();var o=l.getY().toBigInteger();var i=this.ecparams.keylen/4;var m=(\"0000000000\"+n.toString(16)).slice(-i);var r=(\"0000000000\"+q.toString(16)).slice(-i);var p=(\"0000000000\"+o.toString(16)).slice(-i);var j=\"04\"+r+p;this.setPrivateKeyHex(m);this.setPublicKeyHex(j);return{ecprvhex:m,ecpubhex:j}};this.signWithMessageHash=function(i){return this.signHex(i,this.prvKeyHex)};this.signHex=function(o,j){var t=new BigInteger(j,16);var l=this.ecparams.n;var q=new BigInteger(o,16);do{var m=this.getBigRandom(l);var u=this.ecparams.G;var p=u.multiply(m);var i=p.getX().toBigInteger().mod(l)}while(i.compareTo(BigInteger.ZERO)<=0);var v=m.modInverse(l).multiply(q.add(t.multiply(i))).mod(l);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(i,v)};this.sign=function(m,u){var q=u;var j=this.ecparams.n;var p=BigInteger.fromByteArrayUnsigned(m);do{var l=this.getBigRandom(j);var t=this.ecparams.G;var o=t.multiply(l);var i=o.getX().toBigInteger().mod(j)}while(i.compareTo(BigInteger.ZERO)<=0);var v=l.modInverse(j).multiply(p.add(q.multiply(i))).mod(j);return this.serializeSig(i,v)};this.verifyWithMessageHash=function(j,i){return this.verifyHex(j,i,this.pubKeyHex)};this.verifyHex=function(m,i,p){var l,j;var o=KJUR.crypto.ECDSA.parseSigHex(i);l=o.r;j=o.s;var k;k=ECPointFp.decodeFromHex(this.ecparams.curve,p);var n=new BigInteger(m,16);return this.verifyRaw(n,l,j,k)};this.verify=function(o,p,j){var l,i;if(Bitcoin.Util.isArray(p)){var n=this.parseSig(p);l=n.r;i=n.s}else{if(\"object\"===typeof p&&p.r&&p.s){l=p.r;i=p.s}else{throw\"Invalid value for signature\"}}var k;if(j instanceof ECPointFp){k=j}else{if(Bitcoin.Util.isArray(j)){k=ECPointFp.decodeFrom(this.ecparams.curve,j)}else{throw\"Invalid format for pubkey value, must be byte array or ECPointFp\"}}var m=BigInteger.fromByteArrayUnsigned(o);return this.verifyRaw(m,l,i,k)};this.verifyRaw=function(o,i,w,m){var l=this.ecparams.n;var u=this.ecparams.G;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(l)>=0){return false}if(w.compareTo(BigInteger.ONE)<0||w.compareTo(l)>=0){return false}var p=w.modInverse(l);var k=o.multiply(p).mod(l);var j=i.multiply(p).mod(l);var q=u.multiply(k).add(m.multiply(j));var t=q.getX().toBigInteger().mod(l);return t.equals(i)};this.serializeSig=function(k,j){var l=k.toByteArraySigned();var i=j.toByteArraySigned();var m=[];m.push(2);m.push(l.length);m=m.concat(l);m.push(2);m.push(i.length);m=m.concat(i);m.unshift(m.length);m.unshift(48);return m};this.parseSig=function(n){var m;if(n[0]!=48){throw new Error(\"Signature not a valid DERSequence\")}m=2;if(n[m]!=2){throw new Error(\"First element in signature must be a DERInteger\")}var l=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];if(n[m]!=2){throw new Error(\"Second element in signature must be a DERInteger\")}var i=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];var k=BigInteger.fromByteArrayUnsigned(l);var j=BigInteger.fromByteArrayUnsigned(i);return{r:k,s:j}};this.parseSigCompact=function(m){if(m.length!==65){throw\"Signature has the wrong length\"}var j=m[0]-27;if(j<0||j>7){throw\"Invalid signature type\"}var o=this.ecparams.n;var l=BigInteger.fromByteArrayUnsigned(m.slice(1,33)).mod(o);var k=BigInteger.fromByteArrayUnsigned(m.slice(33,65)).mod(o);return{r:l,s:k,i:j}};this.readPKCS5PrvKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var i,k,o;try{i=p(l,0,[2,0],\"06\");k=p(l,0,[1],\"04\");try{o=p(l,0,[3,0],\"03\").substr(2)}catch(j){}}catch(j){throw\"malformed PKCS#1/5 plain ECC private key\"}this.curveName=m(i);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o);this.setPrivateKeyHex(k);this.isPublic=false};this.readPKCS8PrvKeyHex=function(l){var q=ASN1HEX;var i=KJUR.crypto.ECDSA.getName;var n=q.getVbyList;if(q.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var j,p,m,k;try{j=n(l,0,[1,0],\"06\");p=n(l,0,[1,1],\"06\");m=n(l,0,[2,0,1],\"04\");try{k=n(l,0,[2,0,2,0],\"03\").substr(2)}catch(o){}}catch(o){throw\"malformed PKCS#8 plain ECC private key\"}this.curveName=i(p);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(k);this.setPrivateKeyHex(m);this.isPublic=false};this.readPKCS8PubKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var k,i,o;try{k=p(l,0,[0,0],\"06\");i=p(l,0,[0,1],\"06\");o=p(l,0,[1],\"03\").substr(2)}catch(j){throw\"malformed PKCS#8 ECC public key\"}this.curveName=m(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o)};this.readCertPubKeyHex=function(k,p){if(p!==5){p=6}var m=ASN1HEX;var l=KJUR.crypto.ECDSA.getName;var o=m.getVbyList;if(m.isASN1HEX(k)===false){throw\"not ASN.1 hex string\"}var i,n;try{i=o(k,0,[0,p,0,1],\"06\");n=o(k,0,[0,p,1],\"03\").substr(2)}catch(j){throw\"malformed X.509 certificate ECC public key\"}this.curveName=l(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(n)};if(h!==undefined){if(h.curve!==undefined){this.curveName=h.curve}}if(this.curveName===undefined){this.curveName=e}this.setNamedCurve(this.curveName);if(h!==undefined){if(h.prv!==undefined){this.setPrivateKeyHex(h.prv)}if(h.pub!==undefined){this.setPublicKeyHex(h.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX;var i=j.getChildIdx;var g=j.getV;if(f.substr(0,2)!=\"30\"){throw\"signature is not a ASN.1 sequence\"}var h=i(f,0);if(h.length!=2){throw\"number of signature ASN.1 sequence elements seem wrong\"}var e=h[0];var d=h[1];if(f.substr(e,2)!=\"02\"){throw\"1st item of sequene of signature is not ASN.1 integer\"}if(f.substr(d,2)!=\"02\"){throw\"2nd item of sequene of signature is not ASN.1 integer\"}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(c){var d=KJUR.crypto.ECDSA.parseSigHexInHexRS(c);var b=d.r;var a=d.s;if(b.substr(0,2)==\"00\"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)==\"00\"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b=\"00\"+b}if((a.length%32)==30){a=\"00\"+a}if(b.length%32!=0){throw\"unknown ECDSA sig r length error\"}if(a.length%32!=0){throw\"unknown ECDSA sig s length error\"}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if((((a.length/2)*8)%(16*8))!=0){throw\"unknown ECDSA concatinated r-s sig length error\"}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.getEncodedHex()};KJUR.crypto.ECDSA.getName=function(a){if(a===\"2a8648ce3d030107\"){return\"secp256r1\"}if(a===\"2b8104000a\"){return\"secp256k1\"}if(a===\"2b81040022\"){return\"secp384r1\"}if(\"|secp256r1|NIST P-256|P-256|prime256v1|\".indexOf(a)!==-1){return\"secp256r1\"}if(\"|secp256k1|\".indexOf(a)!==-1){return\"secp256k1\"}if(\"|secp384r1|NIST P-384|P-384|\".indexOf(a)!==-1){return\"secp384r1\"}return null};\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.crypto==\"undefined\"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!=\"undefined\"){d=c[e]}if(typeof b[d]!=\"undefined\"){return b[d]}throw\"unregistered EC curve name: \"+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex(\"04\"+f+k);b[A][\"name\"]=A;b[A][\"keylen\"]=l;b[A][\"curve\"]=r;b[A][\"G\"]=q;b[A][\"n\"]=t;b[A][\"h\"]=w;b[A][\"oid\"]=d;b[A][\"info\"]=x;for(var v=0;v1){g=new BigInteger(i,16)}else{g=null}h=new BigInteger(j,16);this.setPrivate(c,a,e,g,h)};this.setPublic=function(c,b,a,d){this.isPublic=true;this.p=c;this.q=b;this.g=a;this.y=d;this.x=null};this.setPublicHex=function(f,e,d,g){var b,a,h,c;b=new BigInteger(f,16);a=new BigInteger(e,16);h=new BigInteger(d,16);c=new BigInteger(g,16);this.setPublic(b,a,h,c)};this.signWithMessageHash=function(d){var c=this.p;var b=this.q;var f=this.g;var i=this.y;var j=this.x;var e=KJUR.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),b.subtract(BigInteger.ONE));var l=d.substr(0,b.bitLength()/4);var h=new BigInteger(l,16);var a=(f.modPow(e,c)).mod(b);var n=(e.modInverse(b).multiply(h.add(j.multiply(a)))).mod(b);var m=KJUR.asn1.ASN1Util.jsonToASN1HEX({seq:[{\"int\":{bigint:a}},{\"int\":{bigint:n}}]});return m};this.verifyWithMessageHash=function(h,f){var d=this.p;var b=this.q;var j=this.g;var l=this.y;var i=this.parseASN1Signature(f);var a=i[0];var t=i[1];var o=h.substr(0,b.bitLength()/4);var k=new BigInteger(o,16);if(BigInteger.ZERO.compareTo(a)>0||a.compareTo(b)>0){throw\"invalid DSA signature\"}if(BigInteger.ZERO.compareTo(t)>=0||t.compareTo(b)>0){throw\"invalid DSA signature\"}var m=t.modInverse(b);var e=k.multiply(m).mod(b);var c=a.multiply(m).mod(b);var n=j.modPow(e,d).multiply(l.modPow(c,d)).mod(d).mod(b);return n.compareTo(a)==0};this.parseASN1Signature=function(a){try{var d=new BigInteger(ASN1HEX.getVbyList(a,0,[0],\"02\"),16);var c=new BigInteger(ASN1HEX.getVbyList(a,0,[1],\"02\"),16);return[d,c]}catch(b){throw\"malformed ASN.1 DSA signature\"}};this.readPKCS5PrvKeyHex=function(c){var b,a,f,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[1],\"02\");a=d(c,0,[2],\"02\");f=d(c,0,[3],\"02\");g=d(c,0,[4],\"02\");i=d(c,0,[5],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed PKCS#1/5 plain DSA private key\"}this.setPrivateHex(b,a,f,g,i)};this.readPKCS8PrvKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[1,1,0],\"02\");c=i(d,0,[1,1,1],\"02\");b=i(d,0,[1,1,2],\"02\");g=i(d,0,[2,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 plain DSA private key\"}this.setPrivateHex(f,c,b,null,g)};this.readPKCS8PubKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[0,1,0],\"02\");c=i(d,0,[0,1,1],\"02\");b=i(d,0,[0,1,2],\"02\");g=i(d,0,[1,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 DSA public key\"}this.setPublicHex(f,c,b,g)};this.readCertPubKeyHex=function(c,f){if(f!==5){f=6}var b,a,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[0,f,0,1,0],\"02\");a=d(c,0,[0,f,0,1,1],\"02\");g=d(c,0,[0,f,0,1,2],\"02\");i=d(c,0,[0,f,1,0],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed X.509 certificate DSA public key\"}this.setPublicHex(b,a,g,i)}};\nvar KEYUTIL=function(){var d=function(p,r,q){return k(CryptoJS.AES,p,r,q)};var e=function(p,r,q){return k(CryptoJS.TripleDES,p,r,q)};var a=function(p,r,q){return k(CryptoJS.DES,p,r,q)};var k=function(s,x,u,q){var r=CryptoJS.enc.Hex.parse(x);var w=CryptoJS.enc.Hex.parse(u);var p=CryptoJS.enc.Hex.parse(q);var t={};t.key=w;t.iv=p;t.ciphertext=r;var v=s.decrypt(t,w,{iv:p});return CryptoJS.enc.Hex.stringify(v)};var l=function(p,r,q){return g(CryptoJS.AES,p,r,q)};var o=function(p,r,q){return g(CryptoJS.TripleDES,p,r,q)};var f=function(p,r,q){return g(CryptoJS.DES,p,r,q)};var g=function(t,y,v,q){var s=CryptoJS.enc.Hex.parse(y);var x=CryptoJS.enc.Hex.parse(v);var p=CryptoJS.enc.Hex.parse(q);var w=t.encrypt(s,x,{iv:p});var r=CryptoJS.enc.Hex.parse(w.toString());var u=CryptoJS.enc.Base64.stringify(r);return u};var i={\"AES-256-CBC\":{proc:d,eproc:l,keylen:32,ivlen:16},\"AES-192-CBC\":{proc:d,eproc:l,keylen:24,ivlen:16},\"AES-128-CBC\":{proc:d,eproc:l,keylen:16,ivlen:16},\"DES-EDE3-CBC\":{proc:e,eproc:o,keylen:24,ivlen:8},\"DES-CBC\":{proc:a,eproc:f,keylen:8,ivlen:8}};var c=function(p){return i[p][\"proc\"]};var m=function(p){var r=CryptoJS.lib.WordArray.random(p);var q=CryptoJS.enc.Hex.stringify(r);return q};var n=function(v){var w={};var q=v.match(new RegExp(\"DEK-Info: ([^,]+),([0-9A-Fa-f]+)\",\"m\"));if(q){w.cipher=q[1];w.ivsalt=q[2]}var p=v.match(new RegExp(\"-----BEGIN ([A-Z]+) PRIVATE KEY-----\"));if(p){w.type=p[1]}var u=-1;var x=0;if(v.indexOf(\"\\r\\n\\r\\n\")!=-1){u=v.indexOf(\"\\r\\n\\r\\n\");x=2}if(v.indexOf(\"\\n\\n\")!=-1){u=v.indexOf(\"\\n\\n\");x=1}var t=v.indexOf(\"-----END\");if(u!=-1&&t!=-1){var r=v.substring(u+x*2,t-x);r=r.replace(/\\s+/g,\"\");w.data=r}return w};var j=function(q,y,p){var v=p.substring(0,16);var t=CryptoJS.enc.Hex.parse(v);var r=CryptoJS.enc.Utf8.parse(y);var u=i[q][\"keylen\"]+i[q][\"ivlen\"];var x=\"\";var w=null;for(;;){var s=CryptoJS.algo.MD5.create();if(w!=null){s.update(w)}s.update(r);s.update(t);w=s.finalize();x=x+CryptoJS.enc.Hex.stringify(w);if(x.length>=u*2){break}}var z={};z.keyhex=x.substr(0,i[q][\"keylen\"]*2);z.ivhex=x.substr(i[q][\"keylen\"]*2,i[q][\"ivlen\"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v][\"proc\"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s][\"eproc\"];var t=r(p,q,u);return t};return{version:\"1.0.0\",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p=\"\";if(typeof t==\"undefined\"||t==null){t=\"AES-256-CBC\"}if(typeof i[t]==\"undefined\"){throw\"KEYUTIL unsupported algorithm: \"+t}if(typeof r==\"undefined\"||r==null){var v=i[t][\"ivlen\"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,\"$1\\r\\n\");var p=\"-----BEGIN \"+x+\" PRIVATE KEY-----\\r\\n\";p+=\"Proc-Type: 4,ENCRYPTED\\r\\n\";p+=\"DEK-Info: \"+t+\",\"+r+\"\\r\\n\";p+=\"\\r\\n\";p+=q;p+=\"\\r\\n-----END \"+x+\" PRIVATE KEY-----\\r\\n\";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw\"malformed format: SEQUENCE(0).items != 2: \"+r.length}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0).items != 2: \"+A.length}if(w(y,A[0])!=\"2a864886f70d01050d\"){throw\"this only supports pkcs5PBES2\"}var p=z(y,A[1]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0.1).items != 2: \"+p.length}var q=z(y,p[1]);if(q.length!=2){throw\"malformed format: SEQUENCE(0.0.1.1).items != 2: \"+q.length}if(w(y,q[0])!=\"2a864886f70d0307\"){throw\"this only supports TripleDES\"}t.encryptionSchemeAlg=\"TripleDES\";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw\"malformed format: SEQUENCE(0.0.1.0).items != 2: \"+s.length}if(w(y,s[0])!=\"2a864886f70d01050c\"){throw\"this only supports pkcs5PBKDF2\"}var x=z(y,s[1]);if(x.length<2){throw\"malformed format: SEQUENCE(0.0.1.0.1).items < 2: \"+x.length}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw\"malformed format pbkdf2Iter: \"+u}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,\"ENCRYPTED PRIVATE KEY\");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!=\"30\"){throw\"malformed plain PKCS8 private key(code:001)\"}var r=u(s,0);if(r.length!=3){throw\"malformed plain PKCS8 private key(code:002)\"}if(s.substr(r[1],2)!=\"30\"){throw\"malformed PKCS8 private key(code:003)\"}var p=u(s,r[1]);if(p.length!=2){throw\"malformed PKCS8 private key(code:004)\"}if(s.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 private key(code:005)\"}q.algoid=t(s,p[0]);if(s.substr(p[1],2)==\"06\"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!=\"04\"){throw\"malformed PKCS8 private key(code:006)\"}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,\"PRIVATE KEY\");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid==\"2a864886f70d010101\"){r=new RSAKey()}else{if(q.algoid==\"2a8648ce380401\"){r=new KJUR.crypto.DSA()}else{if(q.algoid==\"2a8648ce3d0201\"){r=new KJUR.crypto.ECDSA()}else{throw\"unsupported private key algorithm\"}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],\"06\");if(r===\"2a864886f70d010101\"){p=new RSAKey()}else{if(r===\"2a8648ce380401\"){p=new KJUR.crypto.DSA()}else{if(r===\"2a8648ce3d0201\"){p=new KJUR.crypto.ECDSA()}else{throw\"unsupported PKCS#8 public key hex\"}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!=\"30\"){throw\"malformed RSA key(code:001)\"}var q=t(r,0);if(q.length!=2){throw\"malformed RSA key(code:002)\"}if(r.substr(q[0],2)!=\"02\"){throw\"malformed RSA key(code:003)\"}p.n=s(r,q[0]);if(r.substr(q[1],2)!=\"02\"){throw\"malformed RSA key(code:004)\"}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw\"outer DERSequence shall have 2 elements: \"+r.length}var w=r[0];if(t.substr(w,2)!=\"30\"){throw\"malformed PKCS8 public key(code:001)\"}var p=u(t,w);if(p.length!=2){throw\"malformed PKCS8 public key(code:002)\"}if(t.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 public key(code:003)\"}q.algoid=s(t,p[0]);if(t.substr(p[1],2)==\"06\"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)==\"30\"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],\"02\");q.algparam.q=v.getVbyList(t,p[1],[1],\"02\");q.algparam.g=v.getVbyList(t,p[1],[2],\"02\")}}if(t.substr(r[1],2)!=\"03\"){throw\"malformed PKCS8 public key(code:004)\"}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!=\"undefined\"&&l instanceof w){return l}if(typeof i!=\"undefined\"&&l instanceof i){return l}if(typeof C!=\"undefined\"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;j.setPublicKeyHex(u);return j}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;var b=(\"0000000000\"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n===\"pkcs5prv\"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)===\"04\"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw\"unsupported PKCS#1/5 hexadecimal key\"}}}return P}if(n===\"pkcs8prv\"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n===\"pkcs8pub\"){return F._getKeyFromPublicPKCS8Hex(l)}if(n===\"x509pub\"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf(\"-END CERTIFICATE-\",0)!=-1||l.indexOf(\"-END X509 CERTIFICATE-\",0)!=-1||l.indexOf(\"-END TRUSTED CERTIFICATE-\",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf(\"-END PUBLIC KEY-\")!=-1){var O=pemtohex(l,\"PUBLIC KEY\");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var m=M(l,\"RSA PRIVATE KEY\");return F.getKey(m,null,\"pkcs5prv\")}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var I=M(l,\"DSA PRIVATE KEY\");var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END PRIVATE KEY-\")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf(\"-END EC PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],\"04\");var f=d(I,0,[2,0],\"06\");var A=d(I,0,[3,0],\"03\").substr(2);var e=\"\";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw\"undefined OID(hex) in KJUR.crypto.OID: \"+f}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END ENCRYPTED PRIVATE KEY-\")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw\"not supported argument\"};KEYUTIL.generateKeypair=function(a,c){if(a==\"RSA\"){var b=c;var h=new RSAKey();h.generate(b,\"10001\");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a==\"EC\"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw\"unknown algorithm: \"+a}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.n}},{\"int\":s.e},{\"int\":{bigint:s.d}},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.dmp1}},{\"int\":{bigint:s.dmq1}},{\"int\":{bigint:s.coeff}}]});return G}function B(G){var s=l({seq:[{\"int\":1},{octstr:{hex:G.prvKeyHex}},{tag:[\"a0\",true,{oid:{name:G.curveName}}]},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+G.pubKeyHex}}]}]});return s}function x(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.g}},{\"int\":{bigint:s.y}},{\"int\":{bigint:s.x}}]});return G}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D==\"PKCS8PUB\")){var E=new C(b);var w=E.getEncodedHex();return hextopem(w,\"PUBLIC KEY\")}if(D==\"PKCS1PRV\"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();return hextopem(w,\"RSA PRIVATE KEY\")}if(D==\"PKCS1PRV\"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.getEncodedHex();var h=B(b);var t=h.getEncodedHex();var p=\"\";p+=hextopem(v,\"EC PARAMETERS\");p+=hextopem(t,\"EC PRIVATE KEY\");return p}if(D==\"PKCS1PRV\"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();return hextopem(w,\"DSA PRIVATE KEY\")}if(D==\"PKCS5PRV\"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"RSA\",w,y,m,j)}if(D==\"PKCS5PRV\"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"EC\",w,y,m,j)}if(D==\"PKCS5PRV\"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"DSA\",w,y,m,j)}var o=function(G,s){var I=c(G,s);var H=new l({seq:[{seq:[{oid:{name:\"pkcs5PBES2\"}},{seq:[{seq:[{oid:{name:\"pkcs5PBKDF2\"}},{seq:[{octstr:{hex:I.pbkdf2Salt}},{\"int\":I.pbkdf2Iter}]}]},{seq:[{oid:{name:\"des-EDE3-CBC\"}},{octstr:{hex:I.encryptionSchemeIV}}]}]}]},{octstr:{hex:I.ciphertext}}]});return H.getEncodedHex()};var c=function(N,O){var H=100;var M=CryptoJS.lib.WordArray.random(8);var L=\"DES-EDE3-CBC\";var s=CryptoJS.lib.WordArray.random(8);var I=CryptoJS.PBKDF2(O,M,{keySize:192/32,iterations:H});var J=CryptoJS.enc.Hex.parse(N);var K=CryptoJS.TripleDES.encrypt(J,I,{iv:s})+\"\";var G={};G.ciphertext=K;G.pbkdf2Salt=CryptoJS.enc.Hex.stringify(M);G.pbkdf2Iter=H;G.encryptionSchemeAlg=L;G.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return G};if(D==\"PKCS8PRV\"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"rsaEncryption\"}},{\"null\":true}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var g=new l({seq:[{\"int\":1},{octstr:{hex:b.prvKeyHex}},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+b.pubKeyHex}}]}]});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"ecPublicKey\"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"dsa\"}},{seq:[{\"int\":{bigint:b.p}},{\"int\":{bigint:b.q}},{\"int\":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}throw\"unsupported object nor format\"};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,\"CERTIFICATE REQUEST\");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,\"pkcs8pub\");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!=\"30\"){throw\"malformed CSR(code:001)\"}var e=f(g,0);if(e.length<1){throw\"malformed CSR(code:002)\"}if(g.substr(e[0],2)!=\"30\"){throw\"malformed CSR(code:003)\"}var a=f(g,e[0]);if(a.length<3){throw\"malformed CSR(code:004)\"}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getJWKFromKey=function(d){var b={};if(d instanceof RSAKey&&d.isPrivate){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));b.d=hextob64u(d.d.toString(16));b.p=hextob64u(d.p.toString(16));b.q=hextob64u(d.q.toString(16));b.dp=hextob64u(d.dmp1.toString(16));b.dq=hextob64u(d.dmq1.toString(16));b.qi=hextob64u(d.coeff.toString(16));return b}else{if(d instanceof RSAKey&&d.isPublic){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPrivate){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);b.d=hextob64u(d.prvKeyHex);return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPublic){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);return b}}}}throw\"not supported key object\"};\nRSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,j,l,b,a,f,d,k;var m=ASN1HEX;var g=m.getVbyList;if(m.isASN1HEX(e)===false){throw\"not ASN.1 hex string\"}try{c=g(e,0,[2,0,1],\"02\");j=g(e,0,[2,0,2],\"02\");l=g(e,0,[2,0,3],\"02\");b=g(e,0,[2,0,4],\"02\");a=g(e,0,[2,0,5],\"02\");f=g(e,0,[2,0,6],\"02\");d=g(e,0,[2,0,7],\"02\");k=g(e,0,[2,0,8],\"02\")}catch(i){throw\"malformed PKCS#8 plain RSA private key\"}this.setPrivateEx(c,j,l,b,a,f,d,k)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw\"keyHex is not ASN.1 hex string\"}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!==\"02\"||c.substr(a[1],2)!==\"02\"){throw\"wrong hex for PKCS#5 public key\"}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw\"not ASN.1 hex string\"}if(c.getTLVbyList(b,0,[0,0])!==\"06092a864886f70d010101\"){throw\"not PKCS8 RSA public key\"}var a=c.getTLVbyList(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)};\nvar _RE_HEXDECONLY=new RegExp(\"\");_RE_HEXDECONLY.compile(\"[^0-9a-f]\",\"gi\");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c=\"\";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw\"invalid salt length\"}}}if(c<(g+k+2)){throw\"data too long\"}var f=\"\";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dthis.n.bitLength()){return 0}var i=this.doPublic(b);var e=i.toString(16).replace(/^1f+00/,\"\");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(k){return KJUR.crypto.Util.hashString(k,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){a=a.replace(_RE_HEXDECONLY,\"\");a=a.replace(/[ \\n]+/g,\"\");var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,\"\");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){var k=new BigInteger(s,16);if(k.bitLength()>this.n.bitLength()){return false}var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw\"invalid salt length\"}}}if(m<(h+c+2)){throw\"data too long\"}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw\"bits beyond keysize not zero\"}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q0){var b=\":\"+n.join(\":\")+\":\";if(b.indexOf(\":\"+k+\":\")==-1){throw\"algorithm '\"+k+\"' not accepted in the list\"}}if(k!=\"none\"&&B===null){throw\"key shall be specified to verify.\"}if(typeof B==\"string\"&&B.indexOf(\"-----BEGIN \")!=-1){B=KEYUTIL.getKey(B)}if(z==\"RS\"||z==\"PS\"){if(!(B instanceof m)){throw\"key shall be a RSAKey obj for RS* and PS* algs\"}}if(z==\"ES\"){if(!(B instanceof p)){throw\"key shall be a ECDSA obj for ES* algs\"}}if(k==\"none\"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw\"unsupported alg name: \"+k}else{u=t.jwsalg2sigalg[k]}if(u==\"none\"){throw\"not supported\"}else{if(u.substr(0,4)==\"Hmac\"){var o=null;if(B===undefined){throw\"hexadecimal key shall be specified for HMAC\"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf(\"withECDSA\")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(\".\");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw\"malformed sJWS: wrong number of '.' splitted elements\"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null,\" \");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null,\" \")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;var k=e.split(\".\");var c=k[0];var i=k[1];var q=c+\".\"+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw\"acceptField.alg shall be specified\"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss===\"object\"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub===\"object\"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud===\"object\"){if(typeof g.aud==\"string\"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud==\"object\"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt===\"number\"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!==\"number\"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp==\"number\"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw\"addSignature failed: \"+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw\"malformed header\"}if(typeof g.payload===\"string\"){this.sPayload=g.payload}else{throw\"malformed signatures\"}if(g.signatures.length>0){this.aSignatures=g.signatures}else{throw\"malformed signatures\"}}catch(e){throw\"malformed JWS-JS JSON object: \"+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}};\nexports.SecureRandom = SecureRandom;\nexports.rng_seed_time = rng_seed_time;\n\nexports.BigInteger = BigInteger;\nexports.RSAKey = RSAKey;\nexports.ECDSA = KJUR.crypto.ECDSA;\nexports.DSA = KJUR.crypto.DSA;\nexports.Signature = KJUR.crypto.Signature;\nexports.MessageDigest = KJUR.crypto.MessageDigest;\nexports.Mac = KJUR.crypto.Mac;\nexports.Cipher = KJUR.crypto.Cipher;\nexports.KEYUTIL = KEYUTIL;\nexports.ASN1HEX = ASN1HEX;\nexports.X509 = X509;\nexports.CryptoJS = CryptoJS;\n\n// ext/base64.js\nexports.b64tohex = b64tohex;\nexports.b64toBA = b64toBA;\n\n// base64x.js\nexports.stoBA = stoBA;\nexports.BAtos = BAtos;\nexports.BAtohex = BAtohex;\nexports.stohex = stohex;\nexports.stob64 = stob64;\nexports.stob64u = stob64u;\nexports.b64utos = b64utos;\nexports.b64tob64u = b64tob64u;\nexports.b64utob64 = b64utob64;\nexports.hex2b64 = hex2b64;\nexports.hextob64u = hextob64u;\nexports.b64utohex = b64utohex;\nexports.utf8tob64u = utf8tob64u;\nexports.b64utoutf8 = b64utoutf8;\nexports.utf8tob64 = utf8tob64;\nexports.b64toutf8 = b64toutf8;\nexports.utf8tohex = utf8tohex;\nexports.hextoutf8 = hextoutf8;\nexports.hextorstr = hextorstr;\nexports.rstrtohex = rstrtohex;\nexports.hextob64 = hextob64;\nexports.hextob64nl = hextob64nl;\nexports.b64nltohex = b64nltohex;\nexports.hextopem = hextopem;\nexports.pemtohex = pemtohex;\nexports.hextoArrayBuffer = hextoArrayBuffer;\nexports.ArrayBuffertohex = ArrayBuffertohex;\nexports.zulutomsec = zulutomsec;\nexports.zulutosec = zulutosec;\nexports.zulutodate = zulutodate;\nexports.datetozulu = datetozulu;\nexports.uricmptohex = uricmptohex;\nexports.hextouricmp = hextouricmp;\nexports.ipv6tohex = ipv6tohex;\nexports.hextoipv6 = hextoipv6;\nexports.hextoip = hextoip;\nexports.iptohex = iptohex;\nexports.encodeURIComponentAll = encodeURIComponentAll;\nexports.newline_toUnix = newline_toUnix;\nexports.newline_toDos = newline_toDos;\nexports.hextoposhex = hextoposhex;\nexports.intarystrtohex = intarystrtohex;\nexports.strdiffidx = strdiffidx;\n\n// name spaces\nexports.KJUR = KJUR;\nexports.crypto = KJUR.crypto;\nexports.asn1 = KJUR.asn1;\nexports.jws = KJUR.jws;\nexports.lang = KJUR.lang;\n\n\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://AppID/./node_modules/jsrsasign/lib/jsrsasign.js?"); + +/***/ }), + +/***/ "./node_modules/node-fetch/browser.js": +/*!********************************************!*\ + !*** ./node_modules/node-fetch/browser.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n// ref: https://github.com/tc39/proposal-global\nvar getGlobal = function () {\n\t// the only reliable means to get the global object is\n\t// `Function('return this')()`\n\t// However, this causes CSP violations in Chrome apps.\n\tif (typeof self !== 'undefined') { return self; }\n\tif (typeof window !== 'undefined') { return window; }\n\tif (typeof global !== 'undefined') { return global; }\n\tthrow new Error('unable to locate global object');\n}\n\nvar global = getGlobal();\n\nmodule.exports = exports = global.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = global.fetch.bind(global);\n\nexports.Headers = global.Headers;\nexports.Request = global.Request;\nexports.Response = global.Response;\n\n//# sourceURL=webpack://AppID/./node_modules/node-fetch/browser.js?"); + +/***/ }), + +/***/ "./node_modules/webpack/buildin/global.js": +/*!***********************************!*\ + !*** (webpack)/buildin/global.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://AppID/(webpack)/buildin/global.js?"); + +/***/ }), + +/***/ "./package.json": +/*!**********************!*\ + !*** ./package.json ***! + \**********************/ +/*! exports provided: name, version, description, scripts, repository, main, nyc, dependencies, devDependencies, default */ +/***/ (function(module) { + +eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"ibmcloud-appid-js\\\",\\\"version\\\":\\\"0.3.0\\\",\\\"description\\\":\\\"IBM Cloud App ID SDK for Single Page Applications\\\",\\\"scripts\\\":{\\\"build\\\":\\\"webpack --mode=development\\\",\\\"test\\\":\\\"mocha\\\",\\\"coverage\\\":\\\"nyc --reporter=lcov mocha\\\",\\\"docs\\\":\\\"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json\\\"},\\\"repository\\\":{\\\"type\\\":\\\"git\\\",\\\"url\\\":\\\"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git\\\"},\\\"main\\\":\\\"dist/appid.umd.min.js\\\",\\\"nyc\\\":{\\\"all\\\":true,\\\"include\\\":[\\\"src/*.js\\\"],\\\"exclude\\\":[\\\"**/PopupController.js\\\",\\\"**/IFrameController.js\\\",\\\"**/OpenIDConfigurationResource.js\\\",\\\"**/constants.js\\\"]},\\\"dependencies\\\":{\\\"jsrsasign\\\":\\\"^8.0.12\\\"},\\\"devDependencies\\\":{\\\"node-fetch\\\":\\\"^2.6.0\\\",\\\"@babel/cli\\\":\\\"^7.0.0\\\",\\\"@babel/core\\\":\\\"^7.5.5\\\",\\\"@babel/plugin-transform-runtime\\\":\\\"^7.5.5\\\",\\\"@babel/preset-env\\\":\\\"^7.5.5\\\",\\\"babel-cli\\\":\\\"^7.0.0-beta.3\\\",\\\"chai\\\":\\\"^4.2.0\\\",\\\"coveralls\\\":\\\"^3.0.6\\\",\\\"gulp-babel\\\":\\\"^8.0.0\\\",\\\"mocha\\\":\\\"^6.2.0\\\",\\\"nyc\\\":\\\"^14.1.1\\\",\\\"webpack\\\":\\\"^4.39.1\\\",\\\"webpack-cli\\\":\\\"^3.3.6\\\",\\\"docdash\\\":\\\"^1.1.1\\\",\\\"jsdoc\\\":\\\"^3.6.3\\\"}}\");\n\n//# sourceURL=webpack://AppID/./package.json?"); + +/***/ }), + +/***/ "./src/IFrameController.js": +/*!*********************************!*\ + !*** ./src/IFrameController.js ***! + \*********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const IFrameError = __webpack_require__(/*! ./errors/IFrameError */ \"./src/errors/IFrameError.js\");\n\nclass IFrameController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t}\n\n\topen(url) {\n\t\tthis.iFrame = this.window.document.createElement('iframe');\n\t\tthis.iFrame.src = url;\n\t\tthis.iFrame.width = 0;\n\t\tthis.iFrame.height = 0;\n\t\tthis.window.document.body.appendChild(this.iFrame);\n\t}\n\n\tremove() {\n\t\twindow.document.body.removeChild(this.iFrame);\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\treject(new IFrameError('Silent sign-in timed out'));\n\t\t\t}, 5 * 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tclearInterval(timer);\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = IFrameController;\n\n\n//# sourceURL=webpack://AppID/./src/IFrameController.js?"); + +/***/ }), + +/***/ "./src/OpenIDConfigurationResource.js": +/*!********************************************!*\ + !*** ./src/OpenIDConfigurationResource.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const packagejson = __webpack_require__(/*! ../package.json */ \"./package.json\");\n\nclass OpenIdConfigurationResource {\n\tasync init({discoveryEndpoint, requestHandler}){\n\t\tthis.openIdConfig = await requestHandler(discoveryEndpoint);\n\t\tconst headers = { 'x-filter-type': `spa:v${packagejson.version}` };\n\t\tthis.publicKeys = requestHandler(this.getJwksEndpoint(), { headers: headers });\n\t}\n\n\tgetAuthorizationEndpoint() {\n\t\treturn this.openIdConfig.authorization_endpoint;\n\t}\n\n\tgetUserInfoEndpoint() {\n\t\treturn this.openIdConfig.userinfo_endpoint;\n\t}\n\n\tgetJwksEndpoint() {\n\t\treturn this.openIdConfig.jwks_uri;\n\t}\n\n\tgetTokenEndpoint() {\n\t\treturn this.openIdConfig.token_endpoint;\n\t}\n\n\tgetIssuer() {\n\t\treturn this.openIdConfig.issuer;\n\t}\n\n\tasync getPublicKeys() {\n\t\treturn await this.publicKeys;\n\t}\n}\nmodule.exports = OpenIdConfigurationResource;\n\n\n\n//# sourceURL=webpack://AppID/./src/OpenIDConfigurationResource.js?"); + +/***/ }), + +/***/ "./src/PopupController.js": +/*!********************************!*\ + !*** ./src/PopupController.js ***! + \********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const PopupError = __webpack_require__(/*! ./errors/PopupError */ \"./src/errors/PopupError.js\");\n\nclass PopupController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t};\n\n\tinit(popupConfig){\n\t\tthis.popupConfig = popupConfig;\n\t}\n\n\topen() {\n\t\tconst h = this.popupConfig.height;\n\t\tconst w = this.popupConfig.width;\n\t\tconst left = (window.screen.width - w) / 2;\n\t\tconst top = (window.screen.height - h) / 2;\n\t\tthis.popup = this.window.open('', 'popup', `left=${left},top=${top},width=${w},height=${h},resizable,scrollbars=yes,status=1`);\n\t\tif (!this.popup) {\n\t\t\tthrow new PopupError('Unable to open popup')\n\t\t}\n\t};\n\n\tnavigate(url) {\n\t\tthis.popup.location.href = url;\n\t};\n\n\tclose() {\n\t\tthis.popup.close();\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\tif(this.popup.closed) {\n\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\treject(new PopupError('Popup closed'));\n\t\t\t\t}\n\t\t\t}, 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = PopupController;\n\n\n//# sourceURL=webpack://AppID/./src/PopupController.js?"); + +/***/ }), + +/***/ "./src/RequestHandler.js": +/*!*******************************!*\ + !*** ./src/RequestHandler.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t}\n\t\t\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tif (text !== '') {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); + +/***/ }), + +/***/ "./src/TokenValidator.js": +/*!*******************************!*\ + !*** ./src/TokenValidator.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg: [constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif ((nonce && !decoded.payloadObj.nonce) || (decoded.payloadObj.nonce !== nonce)) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\n\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); + +/***/ }), + +/***/ "./src/constants.js": +/*!**************************!*\ + !*** ./src/constants.js ***! + \**************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN: 'Invalid id token',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN: 'Missing id token string',\n\tMISSING_ID_TOKEN_PAYLOAD: 'Missing id token payload',\n\tMISSING_TOKENS: 'Missing tokens',\n\tMISSING_ACCESS_TOKEN: 'Missing access token string',\n\tMISSING_ID_TOKEN: 'Missing access token string',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tGENERATE_CODE: '/cloud_directory/generate_code',\n\tCHANGE_DETAILS: '/cloud_directory/change_details',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); + +/***/ }), + +/***/ "./src/errors/AppIDError.js": +/*!**********************************!*\ + !*** ./src/errors/AppIDError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class AppIDError extends Error {}\nmodule.exports = AppIDError;\n\n//# sourceURL=webpack://AppID/./src/errors/AppIDError.js?"); + +/***/ }), + +/***/ "./src/errors/IFrameError.js": +/*!***********************************!*\ + !*** ./src/errors/IFrameError.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class IFrameError extends Error {}\nmodule.exports = IFrameError;\n\n//# sourceURL=webpack://AppID/./src/errors/IFrameError.js?"); + +/***/ }), + +/***/ "./src/errors/OAuthError.js": +/*!**********************************!*\ + !*** ./src/errors/OAuthError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class OAuthError extends Error {\n\t// See https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for the possible error messages\n\tconstructor({error, description}) {\n\t\tsuper(description || error);\n\t\tthis.error = error;\n\t\tthis.description = description;\n\t}\n}\nmodule.exports = OAuthError;\n\n//# sourceURL=webpack://AppID/./src/errors/OAuthError.js?"); + +/***/ }), + +/***/ "./src/errors/PopupError.js": +/*!**********************************!*\ + !*** ./src/errors/PopupError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class PopupError extends Error {}\nmodule.exports = PopupError;\n\n//# sourceURL=webpack://AppID/./src/errors/PopupError.js?"); + +/***/ }), + +/***/ "./src/errors/RequestError.js": +/*!************************************!*\ + !*** ./src/errors/RequestError.js ***! + \************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class RequestError extends Error {\n\tconstructor(description, status, originError) {\n\t\tsuper(description);\n\t\tthis.status = status;\n\t\tthis.originError = originError;\n\t}\n}\nmodule.exports = RequestError;\n\n//# sourceURL=webpack://AppID/./src/errors/RequestError.js?"); + +/***/ }), + +/***/ "./src/errors/TokenError.js": +/*!**********************************!*\ + !*** ./src/errors/TokenError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class TokenError extends Error {}\nmodule.exports = TokenError;\n\n//# sourceURL=webpack://AppID/./src/errors/TokenError.js?"); + +/***/ }), + +/***/ "./src/index.js": +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\")\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in allows you to automatically obtain new tokens for a user without the user having to re-authenticate using a popup.\n\t * This will attempt to authenticate the user in a hidden iframe.\n\t * You will need to [enable Cloud Directory SSO]{@link https://cloud.ibm.com/docs/services/appid?topic=appid-single-page#spa-silent-login}.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {string} idToken A JWT.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @example\n\t * let tokens = await appID.changePassword(idToken);\n\t */\n\tasync changePassword(idToken) {\n\t\tthis._validateInitalize();\n\n\t\tif (!idToken || typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tlet userId;\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\t\tlet decodedToken = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: idToken,\n\t\t\tpublicKeys,\n\t\t\tissuer: this.openIdConfigResource.getIssuer(),\n\t\t\tclientId: this.clientId\n\t\t});\n\n\t\tif (decodedToken.identities && decodedToken.identities[0] && decodedToken.identities[0].id) {\n\t\t\tif (decodedToken.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = decodedToken.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn await this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change details widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {Object} tokens App ID tokens\n\t * @returns {Promise}\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @throws {AppIDError} \"Missing access token string\"\n\t * @throws {AppIDError} \"Missing tokens object\"\n\t * @example\n\t * let tokens = {accessToken, idToken}\n\t * let newTokens = await appID.changeDetails(tokens);\n\t */\n\tasync changeDetails({accessToken, idToken}) {\n\t\tif (!accessToken && typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ACCESS_TOKEN);\n\t\t}\n\n\t\tif (!idToken && typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tconst generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE;\n\t\tconst changeDetailsCode = await this.request(generateCodeUrl, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken + ' ' + idToken\n\t\t\t}\n\t\t});\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS;\n\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint,\n\t\t\tchangeDetailsCode\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); + +/***/ }), + +/***/ "./src/utils.js": +/*!**********************!*\ + !*** ./src/utils.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId, changeDetailsCode}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tif (changeDetailsCode) {\n\t\t\tauthParams.code = changeDetailsCode;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint, changeDetailsCode}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint, changeDetailsCode});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); + +/***/ }) + +/******/ }); \ No newline at end of file diff --git a/dist/appid.umd.min.js b/dist/appid.umd.min.js index a646072..f237524 100644 --- a/dist/appid.umd.min.js +++ b/dist/appid.umd.min.js @@ -1,50 +1,345 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.AppID=e():t.AppID=e()}(window,(function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=5)}([function(t,e,i){(function(t){var i={userAgent:!1},n={}; -/*! -Copyright (c) 2011, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.9.0 -*/ -if(void 0===r)var r={};r.lang={extend:function(t,e,n){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),n){var s;for(s in n)t.prototype[s]=n[s];var o=function(){},a=["toString","valueOf"];try{/MSIE/.test(i.userAgent)&&(o=function(t,e){for(s=0;s>>2]>>>24-s%4*8&255;e[n+s>>>2]|=o<<24-(n+s)%4*8}else for(s=0;s>>2]=i[s>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=s.ceil(e/4)},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i>>2]>>>24-r%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new u.init(i,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,i=t.sigBytes,n=[],r=0;r>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new u.init(i,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},g=a.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,n=e.sigBytes,r=this.blockSize,o=n/(4*r),a=(o=t?s.ceil(o):s.max((0|o)-this._minBufferSize,0))*r,h=s.min(4*a,n);if(a){for(var c=0;c>>2]}},e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:h,padding:c}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(h=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?n.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=n.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:i})}},e.SerializableCipher=i.extend({cfg:i.extend({format:h}),encrypt:function(t,e,i,n){n=this.cfg.extend(n);var r=t.createEncryptor(i,n);return e=r.finalize(e),r=r.cfg,l.create({ciphertext:e,key:i,iv:r.iv,algorithm:t,mode:r.mode,padding:r.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(i,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,i,r){return r||(r=n.random(8)),t=o.create({keySize:e+i}).compute(t,r),i=n.create(t.words.slice(e),4*i),t.sigBytes=4*e,l.create({key:t,iv:i,salt:r})}},g=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:d}),encrypt:function(t,e,i,n){return i=(n=this.cfg.extend(n)).kdf.execute(i,t.keySize,t.ivSize),n.iv=i.iv,(t=f.encrypt.call(this,t,e,i.key,n)).mixIn(i),t},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),i=n.kdf.execute(i,t.keySize,t.ivSize,e.salt),n.iv=i.iv,f.decrypt.call(this,t,e,i.key,n)}})}(),function(){for(var t=y,e=t.lib.BlockCipher,i=t.algo,n=[],r=[],s=[],o=[],a=[],h=[],u=[],c=[],l=[],f=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var p=0,v=0;for(g=0;256>g;g++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;n[p]=m,r[m]=p;var S=d[p],F=d[S],w=d[F],E=257*d[m]^16843008*m;s[p]=E<<24|E>>>8,o[p]=E<<16|E>>>16,a[p]=E<<8|E>>>24,h[p]=E,E=16843009*w^65537*F^257*S^16843008*p,u[m]=E<<24|E>>>8,c[m]=E<<16|E>>>16,l[m]=E<<8|E>>>24,f[m]=E,p?(p=S^d[d[d[w^S]]],v^=d[d[v]]):p=v=1}var x=[0,1,2,4,8,16,32,64,128,27,54];i=i.AES=e.extend({_doReset:function(){for(var t=(i=this._key).words,e=i.sigBytes/4,i=4*((this._nRounds=e+6)+1),r=this._keySchedule=[],s=0;s>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o]):(o=n[(o=o<<8|o>>>24)>>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o],o^=x[s/e|0]<<24),r[s]=r[s-e]^o}for(t=this._invKeySchedule=[],e=0;ee||4>=s?o:u[n[o>>>24]]^c[n[o>>>16&255]]^l[n[o>>>8&255]]^f[n[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,o,a,h,n)},decryptBlock:function(t,e){var i=t[e+1];t[e+1]=t[e+3],t[e+3]=i,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,r),i=t[e+1],t[e+1]=t[e+3],t[e+3]=i},_doCryptBlock:function(t,e,i,n,r,s,o,a){for(var h=this._nRounds,u=t[e]^i[0],c=t[e+1]^i[1],l=t[e+2]^i[2],f=t[e+3]^i[3],d=4,g=1;g>>24]^r[c>>>16&255]^s[l>>>8&255]^o[255&f]^i[d++],y=n[c>>>24]^r[l>>>16&255]^s[f>>>8&255]^o[255&u]^i[d++],v=n[l>>>24]^r[f>>>16&255]^s[u>>>8&255]^o[255&c]^i[d++];f=n[f>>>24]^r[u>>>16&255]^s[c>>>8&255]^o[255&l]^i[d++],u=p,c=y,l=v}p=(a[u>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&f])^i[d++],y=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[f>>>8&255]<<8|a[255&u])^i[d++],v=(a[l>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[255&c])^i[d++],f=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^i[d++],t[e]=p,t[e+1]=y,t[e+2]=v,t[e+3]=f},keySize:8});t.AES=e._createHelper(i)}(),function(){function t(t,e){var i=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=i,this._lBlock^=i<>>t^this._lBlock)&e;this._lBlock^=i,this._rBlock^=i<i;i++){var n=o[i]-1;e[i]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;16>n;n++){var r=t[n]=[],s=h[n];for(i=0;24>i;i++)r[i/6|0]|=e[(a[i]-1+s)%28]<<31-i%6,r[4+(i/6|0)]|=e[28+(a[i+24]-1+s)%28]<<31-i%6;for(r[0]=r[0]<<1|r[0]>>>31,i=1;7>i;i++)r[i]>>>=4*(i-1)+3;r[7]=r[7]<<5|r[7]>>>27}for(e=this._invSubKeys=[],i=0;16>i;i++)e[i]=t[15-i]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(i,n,r){this._lBlock=i[n],this._rBlock=i[n+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var o=r[s],a=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^o[f])&c[f])>>>0];this._lBlock=h,this._rBlock=a^l}r=this._lBlock,this._lBlock=this._rBlock,this._rBlock=r,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),i[n]=this._lBlock,i[n+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});i.DES=r._createHelper(l),s=s.TripleDES=r.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(n.create(t.slice(0,2))),this._des2=l.createEncryptor(n.create(t.slice(2,4))),this._des3=l.createEncryptor(n.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),i.TripleDES=r._createHelper(s)}(),function(){var t=y,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,i=t.sigBytes,n=this._map;t.clamp(),t=[];for(var r=0;r>>2]>>>24-r%4*8&255)<<16|(e[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|e[r+2>>>2]>>>24-(r+2)%4*8&255,o=0;4>o&&r+.75*o>>6*(3-o)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var i=t.length,n=this._map;(r=n.charAt(64))&&(-1!=(r=t.indexOf(r))&&(i=r));for(var r=[],s=0,o=0;o>>6-o%4*2;r[s>>>2]|=(a|h)<<24-s%4*8,s++}return e.create(r,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,i,n,r,s,o){return((t=t+(e&i|~e&n)+r+o)<>>32-s)+e}function i(t,e,i,n,r,s,o){return((t=t+(e&n|i&~n)+r+o)<>>32-s)+e}function n(t,e,i,n,r,s,o){return((t=t+(e^i^n)+r+o)<>>32-s)+e}function r(t,e,i,n,r,s,o){return((t=t+(i^(e|~n))+r+o)<>>32-s)+e}for(var s=y,o=(h=s.lib).WordArray,a=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var o=0;16>o;o++){var a=t[h=s+o];t[h]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var h=t[s+0],c=(a=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],d=t[s+5],g=t[s+6],p=t[s+7],y=t[s+8],v=t[s+9],m=t[s+10],S=t[s+11],F=t[s+12],w=t[s+13],E=t[s+14],x=t[s+15],b=e(b=o[0],C=o[1],I=o[2],A=o[3],h,7,u[0]),A=e(A,b,C,I,a,12,u[1]),I=e(I,A,b,C,c,17,u[2]),C=e(C,I,A,b,l,22,u[3]);b=e(b,C,I,A,f,7,u[4]),A=e(A,b,C,I,d,12,u[5]),I=e(I,A,b,C,g,17,u[6]),C=e(C,I,A,b,p,22,u[7]),b=e(b,C,I,A,y,7,u[8]),A=e(A,b,C,I,v,12,u[9]),I=e(I,A,b,C,m,17,u[10]),C=e(C,I,A,b,S,22,u[11]),b=e(b,C,I,A,F,7,u[12]),A=e(A,b,C,I,w,12,u[13]),I=e(I,A,b,C,E,17,u[14]),b=i(b,C=e(C,I,A,b,x,22,u[15]),I,A,a,5,u[16]),A=i(A,b,C,I,g,9,u[17]),I=i(I,A,b,C,S,14,u[18]),C=i(C,I,A,b,h,20,u[19]),b=i(b,C,I,A,d,5,u[20]),A=i(A,b,C,I,m,9,u[21]),I=i(I,A,b,C,x,14,u[22]),C=i(C,I,A,b,f,20,u[23]),b=i(b,C,I,A,v,5,u[24]),A=i(A,b,C,I,E,9,u[25]),I=i(I,A,b,C,l,14,u[26]),C=i(C,I,A,b,y,20,u[27]),b=i(b,C,I,A,w,5,u[28]),A=i(A,b,C,I,c,9,u[29]),I=i(I,A,b,C,p,14,u[30]),b=n(b,C=i(C,I,A,b,F,20,u[31]),I,A,d,4,u[32]),A=n(A,b,C,I,y,11,u[33]),I=n(I,A,b,C,S,16,u[34]),C=n(C,I,A,b,E,23,u[35]),b=n(b,C,I,A,a,4,u[36]),A=n(A,b,C,I,f,11,u[37]),I=n(I,A,b,C,p,16,u[38]),C=n(C,I,A,b,m,23,u[39]),b=n(b,C,I,A,w,4,u[40]),A=n(A,b,C,I,h,11,u[41]),I=n(I,A,b,C,l,16,u[42]),C=n(C,I,A,b,g,23,u[43]),b=n(b,C,I,A,v,4,u[44]),A=n(A,b,C,I,F,11,u[45]),I=n(I,A,b,C,x,16,u[46]),b=r(b,C=n(C,I,A,b,c,23,u[47]),I,A,h,6,u[48]),A=r(A,b,C,I,p,10,u[49]),I=r(I,A,b,C,E,15,u[50]),C=r(C,I,A,b,d,21,u[51]),b=r(b,C,I,A,F,6,u[52]),A=r(A,b,C,I,l,10,u[53]),I=r(I,A,b,C,m,15,u[54]),C=r(C,I,A,b,a,21,u[55]),b=r(b,C,I,A,y,6,u[56]),A=r(A,b,C,I,x,10,u[57]),I=r(I,A,b,C,g,15,u[58]),C=r(C,I,A,b,w,21,u[59]),b=r(b,C,I,A,f,6,u[60]),A=r(A,b,C,I,S,10,u[61]),I=r(I,A,b,C,c,15,u[62]),C=r(C,I,A,b,v,21,u[63]);o[0]=o[0]+b|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+A|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;i[r>>>5]|=128<<24-r%32;var s=t.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(i.length+1),this._process(),i=(e=this._hash).words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=a._createHelper(h),s.HmacMD5=a._createHmacHelper(h)}(Math),function(){var t=y,e=(r=t.lib).WordArray,i=r.Hasher,n=[],r=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=this._hash.words,r=i[0],s=i[1],o=i[2],a=i[3],h=i[4],u=0;80>u;u++){if(16>u)n[u]=0|t[e+u];else{var c=n[u-3]^n[u-8]^n[u-14]^n[u-16];n[u]=c<<1|c>>>31}c=(r<<5|r>>>27)+h+n[u],c=20>u?c+(1518500249+(s&o|~s&a)):40>u?c+(1859775393+(s^o^a)):60>u?c+((s&o|s&a|o&a)-1894007588):c+((s^o^a)-899497514),h=a,a=o,o=s<<30|s>>>2,s=r,r=c}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+o|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(i/4294967296),e[15+(n+64>>>9<<4)]=i,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=i._createHelper(r),t.HmacSHA1=i._createHmacHelper(r)}(),function(t){for(var e=y,i=(r=e.lib).WordArray,n=r.Hasher,r=e.algo,s=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=a(t.pow(h,.5))),o[u]=a(t.pow(h,1/3)),u++),h++}var d=[];r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(t,e){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],a=i[3],h=i[4],u=i[5],c=i[6],l=i[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var g=d[f-15],p=d[f-2];d[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[f-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[f-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+o[f]+d[f],p=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&r^n&s^r&s),l=c,c=u,u=h,h=a+g|0,a=s,s=r,r=n,n=g+p|0}i[0]=i[0]+n|0,i[1]=i[1]+r|0,i[2]=i[2]+s|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0,i[5]=i[5]+u|0,i[6]=i[6]+c|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return i[r>>>5]|=128<<24-r%32,i[14+(r+64>>>9<<4)]=t.floor(n/4294967296),i[15+(r+64>>>9<<4)]=n,e.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(r),e.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var t=y,e=t.lib.WordArray,i=(n=t.algo).SHA256,n=n.SHA224=i.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=i._createHelper(n),t.HmacSHA224=i._createHmacHelper(n)}(),function(){function t(){return n.create.apply(n,arguments)}for(var e=y,i=e.lib.Hasher,n=(s=e.x64).Word,r=s.WordArray,s=e.algo,o=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],a=[],h=0;80>h;h++)a[h]=t();s=s.SHA512=i.extend({_doReset:function(){this._hash=new r.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var i=(l=this._hash.words)[0],n=l[1],r=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=i.high,d=i.low,g=n.high,p=n.low,y=r.high,v=r.low,m=s.high,S=s.low,F=h.high,w=h.low,E=u.high,x=u.low,b=c.high,A=c.low,I=l.high,C=l.low,D=f,T=d,P=g,R=p,H=y,B=v,N=m,O=S,j=F,V=w,L=E,_=x,K=b,k=A,M=I,U=C,q=0;80>q;q++){var z=a[q];if(16>q)var G=z.high=0|t[e+2*q],Y=z.low=0|t[e+2*q+1];else{G=((Y=(G=a[q-15]).high)>>>1|(J=G.low)<<31)^(Y>>>8|J<<24)^Y>>>7;var J=(J>>>1|Y<<31)^(J>>>8|Y<<24)^(J>>>7|Y<<25),W=((Y=(W=a[q-2]).high)>>>19|(X=W.low)<<13)^(Y<<3|X>>>29)^Y>>>6,X=(X>>>19|Y<<13)^(X<<3|Y>>>29)^(X>>>6|Y<<26),Z=(Y=a[q-7]).high,$=(Q=a[q-16]).high,Q=Q.low;G=(G=(G=G+Z+((Y=J+Y.low)>>>0>>0?1:0))+W+((Y=Y+X)>>>0>>0?1:0))+$+((Y=Y+Q)>>>0>>0?1:0);z.high=G,z.low=Y}Z=j&L^~j&K,Q=V&_^~V&k,z=D&P^D&H^P&H;var tt=T&R^T&B^R&B,et=(J=(D>>>28|T<<4)^(D<<30|T>>>2)^(D<<25|T>>>7),W=(T>>>28|D<<4)^(T<<30|D>>>2)^(T<<25|D>>>7),(X=o[q]).high),it=X.low;$=M+((j>>>14|V<<18)^(j>>>18|V<<14)^(j<<23|V>>>9))+((X=U+((V>>>14|j<<18)^(V>>>18|j<<14)^(V<<23|j>>>9)))>>>0>>0?1:0),M=K,U=k,K=L,k=_,L=j,_=V,j=N+($=($=($=$+Z+((X=X+Q)>>>0>>0?1:0))+et+((X=X+it)>>>0>>0?1:0))+G+((X=X+Y)>>>0>>0?1:0))+((V=O+X|0)>>>0>>0?1:0)|0,N=H,O=B,H=P,B=R,P=D,R=T,D=$+(z=J+z+((Y=W+tt)>>>0>>0?1:0))+((T=X+Y|0)>>>0>>0?1:0)|0}d=i.low=d+T,i.high=f+D+(d>>>0>>0?1:0),p=n.low=p+R,n.high=g+P+(p>>>0>>0?1:0),v=r.low=v+B,r.high=y+H+(v>>>0>>0?1:0),S=s.low=S+O,s.high=m+N+(S>>>0>>0?1:0),w=h.low=w+V,h.high=F+j+(w>>>0>>0?1:0),x=u.low=x+_,u.high=E+L+(x>>>0<_>>>0?1:0),A=c.low=A+k,c.high=b+K+(A>>>0>>0?1:0),C=l.low=C+U,l.high=I+M+(C>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(i/4294967296),e[31+(n+128>>>10<<5)]=i,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=i._createHelper(s),e.HmacSHA512=i._createHmacHelper(s)}(),function(){var t=y,e=(r=t.x64).Word,i=r.WordArray,n=(r=t.algo).SHA512,r=r.SHA384=n.extend({_doReset:function(){this._hash=new i.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(r),t.HmacSHA384=n._createHmacHelper(r)}(),function(){var t=y,e=(n=t.lib).WordArray,i=n.Hasher,n=t.algo,r=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),o=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);n=n.RIPEMD160=i.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=0;16>i;i++){var n=t[F=e+i];t[F]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var c,l,f,d,g,p,y,v,m,S,F=this._hash.words,w=(n=h.words,u.words),E=r.words,x=s.words,b=o.words,A=a.words;p=c=F[0],y=l=F[1],v=f=F[2],m=d=F[3],S=g=F[4];var I;for(i=0;80>i;i+=1)I=c+t[e+E[i]]|0,I=16>i?I+((l^f^d)+n[0]):32>i?I+((l&f|~l&d)+n[1]):48>i?I+(((l|~f)^d)+n[2]):64>i?I+((l&d|f&~d)+n[3]):I+((l^(f|~d))+n[4]),I=(I=(I|=0)<>>32-b[i])+g|0,c=g,g=d,d=f<<10|f>>>22,f=l,l=I,I=p+t[e+x[i]]|0,I=16>i?I+((y^(v|~m))+w[0]):32>i?I+((y&m|v&~m)+w[1]):48>i?I+(((y|~v)^m)+w[2]):64>i?I+((y&v|~y&m)+w[3]):I+((y^v^m)+w[4]),I=(I=(I|=0)<>>32-A[i])+S|0,p=S,S=m,m=v<<10|v>>>22,v=y,y=I;I=F[1]+f+m|0,F[1]=F[2]+d+S|0,F[2]=F[3]+g+p|0,F[3]=F[4]+c+y|0,F[4]=F[0]+l+v|0,F[0]=I},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,i=0;5>i;i++)n=e[i],e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(n),t.HmacRIPEMD160=i._createHmacHelper(n)}(Math),function(){var t=y,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,i){t=this._hasher=new t.init,"string"==typeof i&&(i=e.parse(i));var n=t.blockSize,r=4*n;i.sigBytes>r&&(i=t.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),o=this._iKey=i.clone(),a=s.words,h=o.words,u=0;u>6)+m.charAt(63&i);if(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),n+=m.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),n+=m.charAt(i>>2)+m.charAt((3&i)<<4)),S)for(;(3&n.length)>0;)n+=S;return n}function w(t){var e,i,n,r="",s=0;for(e=0;e>2),i=3&n,s=1):1==s?(r+=T(i<<2|n>>4),i=15&n,s=2):2==s?(r+=T(i),r+=T(n>>2),i=3&n,s=3):(r+=T(i<<2|n>>4),r+=T(15&n),s=0));return 1==s&&(r+=T(i<<2)),r}function E(t){var e,i=w(t),n=new Array;for(e=0;2*e>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;r=((h=o*h+((32767&c)<<15)+i[n]+(1073741823&r))>>>30)+(c>>>15)+a*u+(r>>>30),i[n++]=1073741823&h}return r},v=30):"Netscape"!=i.appName?(x.prototype.am=function(t,e,i,n,r,s){for(;--s>=0;){var o=e*this[t++]+i[n]+r;r=Math.floor(o/67108864),i[n++]=67108863&o}return r},v=26):(x.prototype.am=function(t,e,i,n,r,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;r=((h=o*h+((16383&c)<<14)+i[n]+r)>>28)+(c>>14)+a*u,i[n++]=268435455&h}return r},v=28),x.prototype.DB=v,x.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function B(t){this.m=t}function N(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function K(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function k(){}function M(t){return t}function U(t){this.r2=b(),this.q3=b(),x.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}B.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},B.prototype.revert=function(t){return t},B.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},B.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},B.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},N.prototype.convert=function(t){var e=b();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(x.ZERO)>0&&this.m.subTo(e,e),e},N.prototype.revert=function(t){var e=b();return t.copyTo(e),this.reduce(e),e},N.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},N.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},N.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},x.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},x.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},x.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,r=!1,s=0;--n>=0;){var o=8==i?255&t[n]:P(t,n);o<0?"-"==t.charAt(n)&&(r=!0):(r=!1,0==s?this[this.t++]=o:s+i>this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},x.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},x.prototype.drShiftTo=function(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>r|a,a=(this[i]&s)<=0;--i)e[i]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},x.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,r=this.DB-n,s=(1<>n;for(var o=i+1;o>n;n>0&&(e[this.t-i-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},x.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),r=i.t;for(e.t=r+n.t;--r>=0;)e[r]=0;for(r=0;r=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},x.prototype.divRemTo=function(t,e,i){var n=t.abs();if(!(n.t<=0)){var r=this.abs();if(r.t0?(n.lShiftTo(h,s),r.lShiftTo(h,i)):(n.copyTo(s),r.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<1?s[u-2]>>this.F2:0),f=this.FV/l,d=(1<=0&&(i[i.t++]=1,i.subTo(v,i)),x.ONE.dlShiftTo(u,v),v.subTo(s,s);s.t=0;){var m=i[--p]==c?this.DM:Math.floor(i[p]*f+(i[p-1]+g)*d);if((i[p]+=s.am(0,m,i,y,0,u))0&&i.rShiftTo(h,i),o<0&&x.ZERO.subTo(i,i)}}},x.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},x.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},x.prototype.exp=function(t,e){if(t>4294967295||t<1)return x.ONE;var i=b(),n=b(),r=e.convert(this),s=H(t)-1;for(r.copyTo(i);--s>=0;)if(e.sqrTo(i,n),(t&1<0)e.mulTo(n,r,i);else{var o=i;i=n,n=o}return e.revert(i)},x.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<0)for(a>a)>0&&(r=!0,s=T(i));o>=0;)a>(a+=this.DB-e)):(i=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),i>0&&(r=!0),r&&(s+=T(i));return r?s:"0"},x.prototype.negate=function(){var t=b();return x.ZERO.subTo(this,t),t},x.prototype.abs=function(){return this.s<0?this.negate():this},x.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},x.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+H(this[this.t-1]^this.s&this.DM)},x.prototype.mod=function(t){var e=b();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(x.ZERO)>0&&t.subTo(e,e),e},x.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new B(e):new N(e),this.exp(t,i)},x.ZERO=R(0),x.ONE=R(1),k.prototype.convert=M,k.prototype.revert=M,k.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},k.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=b();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var q=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],z=(1<<26)/q[q.length-1]; -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function G(){this.i=0,this.j=0,this.S=new Array}x.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},x.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),n=R(i),r=b(),s=b(),o="";for(this.divRemTo(n,r,s);r.signum()>0;)o=(i+s.intValue()).toString(t).substr(1)+o,r.divRemTo(n,r,s);return s.intValue().toString(t)+o},x.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),r=!1,s=0,o=0,a=0;a=i&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),r&&x.ZERO.subTo(this,this)},x.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(x.ONE.shiftLeft(t-1),j,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(x.ONE.shiftLeft(t-1),this);else{var n=new Array,r=7&t;n.length=1+(t>>3),e.nextBytes(n),r>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},x.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},x.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},x.prototype.multiplyLowerTo=function(t,e,i){var n,r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r=0;)i[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},x.prototype.millerRabin=function(t){var e=this.subtract(x.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var n=e.shiftRight(i);(t=t+1>>1)>q.length&&(t=q.length);for(var r=b(),s=0;s>24},x.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},x.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},x.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,r=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[r++]=i|this.s<=0;)n<8?(i=(this[t]&(1<>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(e[r++]=i);return e},x.prototype.equals=function(t){return 0==this.compareTo(t)},x.prototype.min=function(t){return this.compareTo(t)<0?this:t},x.prototype.max=function(t){return this.compareTo(t)>0?this:t},x.prototype.and=function(t){var e=b();return this.bitwiseTo(t,O,e),e},x.prototype.or=function(t){var e=b();return this.bitwiseTo(t,j,e),e},x.prototype.xor=function(t){var e=b();return this.bitwiseTo(t,V,e),e},x.prototype.andNot=function(t){var e=b();return this.bitwiseTo(t,L,e),e},x.prototype.not=function(){for(var t=b(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var c=b();for(n.sqrTo(o[1],c);a<=u;)o[a]=b(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,d=t.t-1,g=!0,p=b();for(r=H(t[d])-1;d>=0;){for(r>=h?l=t[d]>>r-h&u:(l=(t[d]&(1<0&&(l|=t[d-1]>>this.DB+r-h)),a=i;0==(1&l);)l>>=1,--a;if((r-=a)<0&&(r+=this.DB,--d),g)o[l].copyTo(s),g=!1;else{for(;a>1;)n.sqrTo(s,p),n.sqrTo(p,s),a-=2;a>0?n.sqrTo(s,p):(f=s,s=p,p=f),n.mulTo(p,o[l],s)}for(;d>=0&&0==(t[d]&1<=0?(i.subTo(n,i),e&&r.subTo(o,r),s.subTo(a,s)):(n.subTo(i,n),e&&o.subTo(r,o),a.subTo(s,a))}return 0!=n.compareTo(x.ONE)?x.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},x.prototype.pow=function(t){return this.exp(t,new k)},x.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var r=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(r0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(r=e.getLowestSetBit())>0&&e.rShiftTo(r,e),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},x.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=q[q.length-1]){for(e=0;e>8&255,J[W++]^=t>>16&255,J[W++]^=t>>24&255,W>=X&&(W-=X)}((new Date).getTime())}if(null==J){var $;if(J=new Array,W=0,void 0!==n&&(void 0!==n.crypto||void 0!==n.msCrypto)){var Q=n.crypto||n.msCrypto;if(Q.getRandomValues){var tt=new Uint8Array(32);for(Q.getRandomValues(tt),$=0;$<32;++$)J[W++]=tt[$]}else if("Netscape"==i.appName&&i.appVersion<"5"){var et=n.crypto.random(32);for($=0;$>>8,J[W++]=255&$;W=0,Z()}function it(){if(null==Y){for(Z(),(Y=new G).init(J),W=0;W>24,(16711680&r)>>16,(65280&r)>>8,255&r]))),r+=1;return n}function ot(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function at(t,e,i){for(var n="",r=0;n.length>24,(16711680&r)>>16,(65280&r)>>8,255&r])),r+=1;return n} -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function ht(t,e){this.x=e,this.q=t}function ut(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?x.ONE:n,this.zinv=null}function ct(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new ut(this,null,null)}nt.prototype.nextBytes=function(t){var e;for(e=0;e0&&e.length>0))throw"Invalid RSA public key";this.n=rt(t,16),this.e=parseInt(e,16)}},ot.prototype.encrypt=function(t){var e=function(t,e){if(e=0&&e>0;){var r=t.charCodeAt(n--);r<128?i[--e]=r:r>127&&r<2048?(i[--e]=63&r|128,i[--e]=r>>6|192):(i[--e]=63&r|128,i[--e]=r>>6&63|128,i[--e]=r>>12|224)}i[--e]=0;for(var s=new nt,o=new Array;e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new x(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var n=i.toString(16);return 0==(1&n.length)?n:"0"+n},ot.prototype.encryptOAEP=function(t,e,i){var n=function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;if(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t.length+2*n+2>e)throw"Message too long for RSA";var a,h="";for(a=0;a>3,e,i);if(null==n)return null;var r=this.doPublic(n);if(null==r)return null;var s=r.toString(16);return 0==(1&s.length)?s:"0"+s},ot.prototype.type="RSA",ot.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},ot.prototype.setPrivate=function(t,e,i){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=i;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16)}},ot.prototype.setPrivateEx=function(t,e,i,n,r,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16),this.p=rt(n,16),this.q=rt(r,16),this.dmp1=rt(s,16),this.dmq1=rt(o,16),this.coeff=rt(a,16)},ot.prototype.generate=function(t,e){var i=new nt,n=t>>1;this.e=parseInt(e,16);for(var r=new x(e,16);;){for(;this.p=new x(t-n,1,i),0!=this.p.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.p.isProbablePrime(10););for(;this.q=new x(n,1,i),0!=this.q.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(x.ONE),a=this.q.subtract(x.ONE),h=o.multiply(a);if(0==h.gcd(r).compareTo(x.ONE)){this.n=this.p.multiply(this.q),this.d=r.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},ot.prototype.decrypt=function(t){var e=rt(t,16),i=this.doPrivate(e);return null==i?null: -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function(t,e){for(var i=t.toByteArray(),n=0;n=i.length)return null;for(var r="";++n191&&s<224?(r+=String.fromCharCode((31&s)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&s)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},ot.prototype.decryptOAEP=function(t,e,i){var n=rt(t,16),r=this.doPrivate(n);return null==r?null:function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;for(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t=t.toByteArray(),a=0;a>3,e,i)},ht.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ht.prototype.toBigInteger=function(){return this.x},ht.prototype.negate=function(){return new ht(this.q,this.x.negate().mod(this.q))},ht.prototype.add=function(t){return new ht(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ht.prototype.subtract=function(t){return new ht(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ht.prototype.multiply=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ht.prototype.square=function(){return new ht(this.q,this.x.square().mod(this.q))},ht.prototype.divide=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ut.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO))},ut.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(x.ZERO)&&!this.y.toBigInteger().equals(x.ZERO)},ut.prototype.negate=function(){return new ut(this.curve,this.x,this.y.negate(),this.z)},ut.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),i=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(x.ZERO.equals(i))return x.ZERO.equals(e)?this.twice():this.curve.getInfinity();var n=new x("3"),r=this.x.toBigInteger(),s=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),i.square()),a=o.multiply(i),h=r.multiply(o),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(a).multiply(i).mod(this.curve.q),l=h.multiply(n).multiply(e).subtract(s.multiply(a)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),f=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},ut.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new x("3"),e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=i.multiply(this.z),r=n.multiply(i).mod(this.curve.q),s=this.curve.a.toBigInteger(),o=e.square().multiply(t);x.ZERO.equals(s)||(o=o.add(this.z.square().multiply(s)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(r)).shiftLeft(1).multiply(n).mod(this.curve.q),h=o.multiply(t).multiply(e).subtract(r.shiftLeft(1)).shiftLeft(2).multiply(r).subtract(o.square().multiply(o)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),u)},ut.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add(o?this:r))}return s},ut.prototype.multiplyTwo=function(t,e,i){var n;n=t.bitLength()>i.bitLength()?t.bitLength()-1:i.bitLength()-1;for(var r=this.curve.getInfinity(),s=this.add(e);n>=0;)r=r.twice(),t.testBit(n)?r=i.testBit(n)?r.add(s):r.add(this):i.testBit(n)&&(r=r.add(e)),--n;return r},ct.prototype.getQ=function(){return this.q},ct.prototype.getA=function(){return this.a},ct.prototype.getB=function(){return this.b},ct.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ct.prototype.getInfinity=function(){return this.infinity},ct.prototype.fromBigInteger=function(t){return new ht(this.q,t)},ct.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,i=t.substr(2,e),n=t.substr(e+2,e);return new ut(this,this.fromBigInteger(new x(i,16)),this.fromBigInteger(new x(n,16)));default:return null}}, -/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib - */ -ht.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ut.prototype.getEncoded=function(t){var e=function(t,e){var i=t.toByteArrayUnsigned();if(ei.length;)i.unshift(0);return i},i=this.getX().toBigInteger(),n=this.getY().toBigInteger(),r=e(i,32);return t?n.isEven()?r.unshift(2):r.unshift(3):(r.unshift(4),r=r.concat(e(n,32))),r},ut.decodeFrom=function(t,e){e[0];var i=e.length-1,n=e.slice(1,1+i/2),r=e.slice(1+i/2,1+i);n.unshift(0),r.unshift(0);var s=new x(n),o=new x(r);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.decodeFromHex=function(t,e){e.substr(0,2);var i=e.length-2,n=e.substr(2,i/2),r=e.substr(2+i/2,i/2),s=new x(n,16),o=new x(r,16);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),i=t.y.subtract(this.y).divide(e),n=i.square().subtract(this.x).subtract(t.x),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(x.valueOf(2)),e=this.curve.fromBigInteger(x.valueOf(3)),i=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=i.square().subtract(this.x.multiply(t)),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add2D(o?this:r))}return s},ut.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),i=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),r=this.curve.getQ(),s=e.multiply(e).mod(r),o=t.multiply(t).multiply(t).add(i.multiply(t)).add(n).mod(r);return s.equals(o)},ut.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ut.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),i=this.getY().toBigInteger();if(e.compareTo(x.ONE)<0||e.compareTo(t.subtract(x.ONE))>0)throw new Error("x coordinate out of bounds");if(i.compareTo(x.ONE)<0||i.compareTo(t.subtract(x.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0}; -/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval - */ -var lt=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),i={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,n){return e?i[e]:String.fromCharCode(parseInt(n,16))}var r=new String(""),s=(Object,Array,Object.hasOwnProperty);return function(i,o){var a,h,u=i.match(t),c=u[0],l=!1;"{"===c?a={}:"["===c?a=[]:(a=[],l=!0);for(var f=[a],d=1-l,g=u.length;d=0;)delete i[n[h]]}return o.call(t,e,i)};a=y({"":a},"")}return a}}();void 0!==ft&&ft||(ft={}),void 0!==ft.asn1&&ft.asn1||(ft.asn1={}),ft.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},ft.asn1.DERAbstractString=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=bt(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},r.lang.extend(ft.asn1.DERAbstractString,ft.asn1.ASN1Object),ft.asn1.DERAbstractTime=function(t){ft.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var n=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var h=n(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=St(t)},this.setByDateValue=function(t,e,i,n,r,s){var o=new Date(Date.UTC(t,e-1,i,n,r,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},r.lang.extend(ft.asn1.DERAbstractTime,ft.asn1.ASN1Object),ft.asn1.DERAbstractStructured=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},r.lang.extend(ft.asn1.DERAbstractStructured,ft.asn1.ASN1Object),ft.asn1.DERBoolean=function(){ft.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},r.lang.extend(ft.asn1.DERBoolean,ft.asn1.ASN1Object),ft.asn1.DERInteger=function(t){ft.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ft.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},r.lang.extend(ft.asn1.DERInteger,ft.asn1.ASN1Object),ft.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ft.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}ft.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7r.length&&(r=n[i]);return(t=t.replace(r,"::")).slice(1,-1)}function _t(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?Lt(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function Kt(t){for(var e=encodeURIComponent(t),i="",n=0;n"7"?"00"+t:t}function Mt(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,i){var n=parseInt(t);if(n<0||255=2*s)break;if(a>=200)break;n.push(h),o=h,a++}return n},pt.getNthChildIdx=function(t,e,i){return pt.getChildIdx(t,e)[i]},pt.getIdxbyList=function(t,e,i,n){var r,s,o=pt;if(0==i.length){if(void 0!==n&&t.substr(e,2)!==n)throw"checking tag doesn't match: "+t.substr(e,2)+"!="+n;return e}return r=i.shift(),s=o.getChildIdx(t,e),o.getIdxbyList(t,s[r],i,n)},pt.getTLVbyList=function(t,e,i,n){var r=pt,s=r.getIdxbyList(t,e,i);if(void 0===s)throw"can't find nthList object";if(void 0!==n&&t.substr(s,2)!=n)throw"checking tag doesn't match: "+t.substr(s,2)+"!="+n;return r.getTLV(t,s)},pt.getVbyList=function(t,e,i,n,r){var s,o,a=pt;if(void 0===(s=a.getIdxbyList(t,e,i,n)))throw"can't find nthList object";return o=a.getV(t,s),!0===r&&(o=o.substr(2)),o},pt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},i=[],n=t.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var s=t.substr(2),o=[],a=0;a0&&(c=c+"."+h.join(".")),c},pt.dump=function(t,e,i,n){var r=pt,s=r.getV,o=r.dump,a=r.getChildIdx,h=t;t instanceof ft.asn1.ASN1Object&&(h=t.getEncodedHex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var c=e.ommit_long_octet;if("01"==h.substr(i,2))return"00"==(l=s(h,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==h.substr(i,2))return n+"INTEGER "+u(l=s(h,i),c)+"\n";if("03"==h.substr(i,2))return n+"BITSTRING "+u(l=s(h,i),c)+"\n";if("04"==h.substr(i,2)){var l=s(h,i);if(r.isASN1HEX(l)){var f=n+"OCTETSTRING, encapsulates\n";return f+=o(l,e,0,n+" ")}return n+"OCTETSTRING "+u(l,c)+"\n"}if("05"==h.substr(i,2))return n+"NULL\n";if("06"==h.substr(i,2)){var d=s(h,i),g=ft.asn1.ASN1Util.oidHexToInt(d),p=ft.asn1.x509.OID.oid2name(g),y=g.replace(/\./g," ");return""!=p?n+"ObjectIdentifier "+p+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0c"==h.substr(i,2))return n+"UTF8String '"+At(s(h,i))+"'\n";if("13"==h.substr(i,2))return n+"PrintableString '"+At(s(h,i))+"'\n";if("14"==h.substr(i,2))return n+"TeletexString '"+At(s(h,i))+"'\n";if("16"==h.substr(i,2))return n+"IA5String '"+At(s(h,i))+"'\n";if("17"==h.substr(i,2))return n+"UTCTime "+At(s(h,i))+"\n";if("18"==h.substr(i,2))return n+"GeneralizedTime "+At(s(h,i))+"\n";if("30"==h.substr(i,2)){if("3000"==h.substr(i,4))return n+"SEQUENCE {}\n";f=n+"SEQUENCE\n";var v=e;if((2==(F=a(h,i)).length||3==F.length)&&"06"==h.substr(F[0],2)&&"04"==h.substr(F[F.length-1],2)){p=r.oidname(s(h,F[0]));var m=JSON.parse(JSON.stringify(e));m.x509ExtName=p,v=m}for(var S=0;S0){var e=new i({array:this.extensionsArray}),n=new r({explicit:!0,tag:"a3",obj:e});this.asn1Array.push(n)}var s=new i({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertificate,ft.asn1.ASN1Object),ft.asn1.x509.Extension=function(t){ft.asn1.x509.Extension.superclass.constructor.call(this);var e=ft.asn1,i=e.DERObjectIdentifier,n=e.DEROctetString,r=(e.DERBitString,e.DERBoolean),s=e.DERSequence;this.getEncodedHex=function(){var t=new i({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new r),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},r.lang.extend(ft.asn1.x509.Extension,ft.asn1.ASN1Object),ft.asn1.x509.Extension.appendByNameToArray=function(t,e,i){var n=t.toLowerCase(),r=ft.asn1.x509;if("basicconstraints"==n){var s=new r.BasicConstraints(e);i.push(s)}else if("keyusage"==n){s=new r.KeyUsage(e);i.push(s)}else if("crldistributionpoints"==n){s=new r.CRLDistributionPoints(e);i.push(s)}else if("extkeyusage"==n){s=new r.ExtKeyUsage(e);i.push(s)}else if("authoritykeyidentifier"==n){s=new r.AuthorityKeyIdentifier(e);i.push(s)}else if("authorityinfoaccess"==n){s=new r.AuthorityInfoAccess(e);i.push(s)}else if("subjectaltname"==n){s=new r.SubjectAltName(e);i.push(s)}else{if("issueraltname"!=n)throw"unsupported extension name: "+t;s=new r.IssuerAltName(e);i.push(s)}},ft.asn1.x509.KeyUsage=function(t){ft.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Jt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new ft.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var i=t.names,n="000000000",r=0;r-1&&t.push(new ft.asn1.DERInteger({int:this.pathLen}));var e=new ft.asn1.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},r.lang.extend(ft.asn1.x509.BasicConstraints,ft.asn1.x509.Extension),ft.asn1.x509.CRLDistributionPoints=function(t){ft.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ft.asn1,i=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){this.asn1ExtnValue=new e.DERSequence({array:t})},this.setByOneURI=function(t){var e=new i.GeneralNames([{uri:t}]),n=new i.DistributionPointName(e),r=new i.DistributionPoint({dpobj:n});this.setByDPArray([r])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},r.lang.extend(ft.asn1.x509.CRLDistributionPoints,ft.asn1.x509.Extension),ft.asn1.x509.ExtKeyUsage=function(t){ft.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=ft.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var i=0;i0){var t=new i({array:this.aRevokedCert});this.asn1Array.push(t)}var e=new i({array:this.asn1Array});return this.hTLV=e.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize=function(){this.asn1Version=null,this.asn1SignatureAlg=null,this.asn1Issuer=null,this.asn1ThisUpdate=null,this.asn1NextUpdate=null,this.aRevokedCert=new Array},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertList,ft.asn1.ASN1Object),ft.asn1.x509.CRLEntry=function(t){ft.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=ft.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},r.lang.extend(ft.asn1.x509.CRLEntry,ft.asn1.ASN1Object),ft.asn1.x509.X500Name=function(t){ft.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=new Array;var e=ft.asn1,i=e.x509,n=Ht;if(this.setByString=function(t){var e=t.split("/");e.shift();for(var n=[],r=0;r0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},ft.asn1.x509.RDN=function(t){ft.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=new Array,this.addByString=function(t){this.asn1Array.push(new ft.asn1.x509.AttributeTypeAndValue({str:t}))},this.addByMultiValuedString=function(t){for(var e=ft.asn1.x509.RDN.parseString(t),i=0;i0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var a=!1,h=[];for(r=0;n.length>0;r++){s=n.shift();if(!0===a){var u=h.pop();if(s.match(/"$/)){o=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(o),a=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(a=!0)}return h},ft.asn1.x509.AttributeTypeAndValue=function(t){ft.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var e=ft.asn1;this.setByString=function(t){var e=t.match(/^([^=]+)=(.+)$/);if(!e)throw"malformed attrTypeAndValueStr: "+t;this.setByAttrTypeAndValueStr(e[1],e[2])},this.setByAttrTypeAndValueStr=function(t,e){this.typeObj=ft.asn1.x509.OID.atype2obj(t);var i="utf8";"C"==t&&(i="prn"),this.valueObj=this.getValueObj(i,e)},this.getValueObj=function(t,i){if("utf8"==t)return new e.DERUTF8String({str:i});if("prn"==t)return new e.DERPrintableString({str:i});if("tel"==t)return new e.DERTeletexString({str:i});if("ia5"==t)return new e.DERIA5String({str:i});throw"unsupported directory string type: type="+t+" value="+i},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.typeObj,this.valueObj]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&void 0!==t.str&&this.setByString(t.str)},r.lang.extend(ft.asn1.x509.AttributeTypeAndValue,ft.asn1.ASN1Object),ft.asn1.x509.SubjectPublicKeyInfo=function(t){ft.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ft,i=e.asn1,n=i.DERInteger,r=i.DERBitString,s=i.DERObjectIdentifier,o=i.DERSequence,a=i.ASN1Util.newObject,h=i.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof ot){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+e})}}catch(t){}try{if(t instanceof ft.crypto.ECDSA){var i=new s({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ft.crypto.DSA){i=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new h({name:"dsa",asn1params:i});var o=new n({bigint:t.y});this.asn1SubjPKey=new r({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},r.lang.extend(ft.asn1.x509.SubjectPublicKeyInfo,ft.asn1.ASN1Object),ft.asn1.x509.Time=function(t){ft.asn1.x509.Time.superclass.constructor.call(this);var e=ft.asn1,i=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},r.lang.extend(ft.asn1.x509.Time,ft.asn1.ASN1Object),ft.asn1.x509.AlgorithmIdentifier=function(t){ft.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ft.asn1;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw"algorithm not specified";null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var t=[this.asn1Alg];null!==this.asn1Params&&t.push(this.asn1Params);var i=new e.DERSequence({array:t});return this.hTLV=i.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},r.lang.extend(ft.asn1.x509.AlgorithmIdentifier,ft.asn1.ASN1Object),ft.asn1.x509.GeneralName=function(t){ft.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=ft.asn1,n=(i.DERSequence,i.DEROctetString),r=i.DERIA5String,s=i.DERTaggedObject,o=i.ASN1Object,a=i.x509.X500Name,h=Ht;this.explicit=!1,this.setByParam=function(t){var i=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",i=new r({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",i=new r({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",i=new r({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,i=new a({str:t.dn})),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var u=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certissuer param not cert";(f=new Jt).hex=u;var c=f.getIssuerHex();(i=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;u=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certsubj param not cert";(f=new Jt).hex=u;c=f.getSubjectHex();(i=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,g=t.ip,p="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(d=Mt("["+g.split(".").join(",")+"]")).length)throw p}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=Vt(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw p;d=g}i=new n({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},r.lang.extend(ft.asn1.x509.GeneralName,ft.asn1.ASN1Object),ft.asn1.x509.GeneralNames=function(t){ft.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ft.asn1;this.setByParamArray=function(t){for(var i=0;i0&&(e=new n({obj:this.dUnsignedAttrs,tag:"a1",explicit:!1}));var r=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,t,this.dSigAlg,this.dSig];null!=e&&r.push(e);var o=new i.DERSequence({array:r});return this.hTLV=o.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.SignerInfo,ft.asn1.ASN1Object),ft.asn1.cms.EncapsulatedContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.dEContentType=new r({name:"data"}),this.dEContent=null,this.isDetached=!1,this.eContentValueHex=null,this.setContentType=function(t){t.match(/^[0-2][.][0-9.]+$/)?this.dEContentType=new r({oid:t}):this.dEContentType=new r({name:t})},this.setContentValue=function(t){void 0!==t&&("string"==typeof t.hex?this.eContentValueHex=t.hex:"string"==typeof t.str&&(this.eContentValueHex=bt(t.str)))},this.setContentValueHex=function(t){this.eContentValueHex=t},this.setContentValueStr=function(t){this.eContentValueHex=bt(t)},this.getEncodedHex=function(){if("string"!=typeof this.eContentValueHex)throw"eContentValue not yet set";var t=new s({hex:this.eContentValueHex});this.dEContent=new i({obj:t,tag:"a0",explicit:!0});var e=[this.dEContentType];this.isDetached||e.push(this.dEContent);var r=new n({array:e});return this.hTLV=r.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.EncapsulatedContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.ContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.x509;ft.asn1.cms.ContentInfo.superclass.constructor.call(this),this.dContentType=null,this.dContent=null,this.setContentType=function(t){"string"==typeof t&&(this.dContentType=r.OID.name2obj(t))},this.getEncodedHex=function(){var t=new i({obj:this.dContent,tag:"a0",explicit:!0}),e=new n({array:[this.dContentType,t]});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t&&(t.type&&this.setContentType(t.type),t.obj&&t.obj instanceof e.ASN1Object&&(this.dContent=t.obj))},r.lang.extend(ft.asn1.cms.ContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.SignedData=function(t){var e=ft.asn1,i=e.ASN1Object,n=e.DERInteger,r=e.DERSet,s=e.DERSequence,o=e.DERTaggedObject,a=e.cms,h=a.EncapsulatedContentInfo,u=a.SignerInfo,c=a.ContentInfo,l=e.x509.AlgorithmIdentifier;ft.asn1.cms.SignedData.superclass.constructor.call(this),this.dCMSVersion=new n({int:1}),this.dDigestAlgs=null,this.digestAlgNameList=[],this.dEncapContentInfo=new h,this.dCerts=null,this.certificateList=[],this.crlList=[],this.signerInfoList=[new u],this.addCertificatesByPEM=function(t){var e=Ht(t),n=new i;n.hTLV=e,this.certificateList.push(n)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(null==this.dDigestAlgs){for(var t=[],e=0;e0){var h=new r({array:this.certificateList});this.dCerts=new o({obj:h,tag:"a0",explicit:!1})}null!=this.dCerts&&a.push(this.dCerts);var u=new r({array:this.signerInfoList});a.push(u);var c=new s({array:a});return this.hTLV=c.getEncodedHex(),this.hTLV},this.getContentInfo=function(){return this.getEncodedHex(),new c({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},this.getPEM=function(){return Rt(this.getContentInfoEncodedHex(),"CMS")}},r.lang.extend(ft.asn1.cms.SignedData,ft.asn1.ASN1Object),ft.asn1.cms.CMSUtil=new function(){},ft.asn1.cms.CMSUtil.newSignedData=function(t){var e=ft.asn1,i=e.cms,n=i.SignerInfo,r=i.SignedData,s=i.SigningTime,o=i.SigningCertificate,a=i.SigningCertificateV2,h=e.cades.SignaturePolicyIdentifier,u=new r;if(u.dEncapContentInfo.setContentValue(t.content),"object"==typeof t.certs)for(var c=0;c0){var t=new n({array:this.extensionsArray}),e=new r({array:[t]}),i=new n({array:[new a({oid:"1.2.840.113549.1.9.14"}),e]}),h=new o({explicit:!0,tag:"a0",obj:i});this.asn1Array.push(h)}else{h=new o({explicit:!1,tag:"a0",obj:new s});this.asn1Array.push(h)}var u=new n({array:this.asn1Array});return this.hTLV=u.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.csr.CertificationRequestInfo,ft.asn1.ASN1Object),ft.asn1.csr.CSRUtil=new function(){},ft.asn1.csr.CSRUtil.newCSRPEM=function(t){var e=Ut,i=ft.asn1.csr;if(void 0===t.subject)throw"parameter subject undefined";if(void 0===t.sbjpubkey)throw"parameter sbjpubkey undefined";if(void 0===t.sigalg)throw"parameter sigalg undefined";if(void 0===t.sbjprvkey)throw"parameter sbjpubkey undefined";var n=new i.CertificationRequestInfo;if(n.setSubjectByParam(t.subject),n.setSubjectPublicKeyByGetKey(t.sbjpubkey),void 0!==t.ext&&void 0!==t.ext.length)for(var r=0;rr)throw"key is too short for SigAlg: keylen="+i+","+e;for(var s="0001",o="00"+n,a="",h=r-s.length-o.length,u=0;u=0)return!1;if(i.compareTo(x.ONE)<0||i.compareTo(r)>=0)return!1;var o=i.modInverse(r),a=t.multiply(o).mod(r),h=e.multiply(o).mod(r);return s.multiply(a).add(n.multiply(h)).getX().toBigInteger().mod(r).equals(e)},this.serializeSig=function(t,e){var i=t.toByteArraySigned(),n=e.toByteArraySigned(),r=[];return r.push(2),r.push(i.length),(r=r.concat(i)).push(2),r.push(n.length),(r=r.concat(n)).unshift(r.length),r.unshift(48),r},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:x.fromByteArrayUnsigned(i),s:x.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:x.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:x.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[2,0],"06"),i=o(t,0,[1],"04");try{n=o(t,0,[3,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#1/5 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{o(t,0,[1,0],"06"),e=o(t,0,[1,1],"06"),i=o(t,0,[2,0,1],"04");try{n=o(t,0,[2,0,2,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#8 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){var e,i,n=pt,r=ft.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{s(t,0,[0,0],"06"),e=s(t,0,[0,1],"06"),i=s(t,0,[1],"03").substr(2)}catch(t){throw"malformed PKCS#8 ECC public key"}if(this.curveName=r(e),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,e){5!==e&&(e=6);var i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{i=o(t,0,[0,e,0,1],"06"),n=o(t,0,[0,e,1],"03").substr(2)}catch(t){throw"malformed X.509 certificate ECC public key"}if(this.curveName=s(i),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ft.crypto.ECDSA.parseSigHex=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new x(e.r,16),s:new x(e.s,16)}},ft.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=pt,i=e.getChildIdx,n=e.getV;if("30"!=t.substr(0,2))throw"signature is not a ASN.1 sequence";var r=i(t,0);if(2!=r.length)throw"number of signature ASN.1 sequence elements seem wrong";var s=r[0],o=r[1];if("02"!=t.substr(s,2))throw"1st item of sequene of signature is not ASN.1 integer";if("02"!=t.substr(o,2))throw"2nd item of sequene of signature is not ASN.1 integer";return{r:n(t,s),s:n(t,o)}},ft.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t),i=e.r,n=e.s;if("00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),i.length%32==30&&(i="00"+i),n.length%32==30&&(n="00"+n),i.length%32!=0)throw"unknown ECDSA sig r length error";if(n.length%32!=0)throw"unknown ECDSA sig s length error";return i+n},ft.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var e=t.substr(0,t.length/2),i=t.substr(t.length/2);return ft.crypto.ECDSA.hexRSSigToASN1Sig(e,i)},ft.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var i=new x(t,16),n=new x(e,16);return ft.crypto.ECDSA.biRSSigToASN1Sig(i,n)},ft.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var i=ft.asn1,n=new i.DERInteger({bigint:t}),r=new i.DERInteger({bigint:e});return new i.DERSequence({array:[n,r]}).getEncodedHex()},ft.crypto.ECDSA.getName=function(t){return"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040022"===t?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":null},void 0!==ft&&ft||(ft={}),void 0!==ft.crypto&&ft.crypto||(ft.crypto={}),ft.crypto.ECParameterDB=new function(){var t={},e={};function i(t){return new x(t,16)}this.getByName=function(i){var n=i;if(void 0!==e[n]&&(n=e[i]),void 0!==t[n])return t[n];throw"unregistered EC curve name: "+n},this.regist=function(n,r,s,o,a,h,u,c,l,f,d,g){t[n]={};var p=i(s),y=i(o),v=i(a),m=i(h),S=i(u),F=new ct(p,y,v),w=F.decodePointHex("04"+c+l);t[n].name=n,t[n].keylen=r,t[n].curve=F,t[n].G=w,t[n].n=m,t[n].h=S,t[n].oid=d,t[n].info=g;for(var E=0;E1?new x(n,16):null,u=new x(r,16),this.setPrivate(s,o,a,h,u)},this.setPublic=function(t,e,i,n){this.isPublic=!0,this.p=t,this.q=e,this.g=i,this.y=n,this.x=null},this.setPublicHex=function(t,e,i,n){var r,s,o,a;r=new x(t,16),s=new x(e,16),o=new x(i,16),a=new x(n,16),this.setPublic(r,s,o,a)},this.signWithMessageHash=function(t){var e=this.p,i=this.q,n=this.g,r=(this.y,this.x),s=ft.crypto.Util.getRandomBigIntegerMinToMax(x.ONE.add(x.ONE),i.subtract(x.ONE)),o=new x(t.substr(0,i.bitLength()/4),16),a=n.modPow(s,e).mod(i),h=s.modInverse(i).multiply(o.add(r.multiply(a))).mod(i);return ft.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:a}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var i=this.p,n=this.q,r=this.g,s=this.y,o=this.parseASN1Signature(e),a=o[0],h=o[1],u=new x(t.substr(0,n.bitLength()/4),16);if(x.ZERO.compareTo(a)>0||a.compareTo(n)>0)throw"invalid DSA signature";if(x.ZERO.compareTo(h)>=0||h.compareTo(n)>0)throw"invalid DSA signature";var c=h.modInverse(n),l=u.multiply(c).mod(n),f=a.multiply(c).mod(n);return 0==r.modPow(l,i).multiply(s.modPow(f,i)).mod(i).mod(n).compareTo(a)},this.parseASN1Signature=function(t){try{return[new x(pt.getVbyList(t,0,[0],"02"),16),new x(pt.getVbyList(t,0,[1],"02"),16)]}catch(t){throw"malformed ASN.1 DSA signature"}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r,s,o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{e=a(t,0,[1],"02"),i=a(t,0,[2],"02"),n=a(t,0,[3],"02"),r=a(t,0,[4],"02"),s=a(t,0,[5],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#1/5 plain DSA private key"}this.setPrivateHex(e,i,n,r,s)},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[1,1,0],"02"),i=o(t,0,[1,1,1],"02"),n=o(t,0,[1,1,2],"02"),r=o(t,0,[2,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 plain DSA private key"}this.setPrivateHex(e,i,n,null,r)},this.readPKCS8PubKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[0,1,0],"02"),i=o(t,0,[0,1,1],"02"),n=o(t,0,[0,1,2],"02"),r=o(t,0,[1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 DSA public key"}this.setPublicHex(e,i,n,r)},this.readCertPubKeyHex=function(t,e){var i,n,r,s;5!==e&&(e=6);var o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{i=a(t,0,[0,e,0,1,0],"02"),n=a(t,0,[0,e,0,1,1],"02"),r=a(t,0,[0,e,0,1,2],"02"),s=a(t,0,[0,e,1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed X.509 certificate DSA public key"}this.setPublicHex(i,n,r,s)}};var Ut=function(){var t=function(t,i,n){return e(y.AES,t,i,n)},e=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=r;var h=t.decrypt(a,s,{iv:o});return y.enc.Hex.stringify(h)},i=function(t,e,i){return n(y.AES,t,e,i)},n=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a=t.encrypt(r,s,{iv:o}),h=y.enc.Hex.parse(a.toString());return y.enc.Base64.stringify(h)},r={"AES-256-CBC":{proc:t,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,i,n){return e(y.TripleDES,t,i,n)},eproc:function(t,e,i){return n(y.TripleDES,t,e,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,i,n){return e(y.DES,t,i,n)},eproc:function(t,e,i){return n(y.DES,t,e,i)},keylen:8,ivlen:8}},s=function(t){var e={},i=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(e.cipher=i[1],e.ivsalt=i[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var r=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(r=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(r=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=r&&-1!=o){var a=t.substring(r+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,i){for(var n=i.substring(0,16),s=y.enc.Hex.parse(n),o=y.enc.Utf8.parse(e),a=r[t].keylen+r[t].ivlen,h="",u=null;;){var c=y.algo.MD5.create();if(null!=u&&c.update(u),c.update(o),c.update(s),u=c.finalize(),(h+=y.enc.Hex.stringify(u)).length>=2*a)break}var l={};return l.keyhex=h.substr(0,2*r[t].keylen),l.ivhex=h.substr(2*r[t].keylen,2*r[t].ivlen),l},a=function(t,e,i,n){var s=y.enc.Base64.parse(t),o=y.enc.Hex.stringify(s);return(0,r[e].proc)(o,i,n)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,i){return o(t,e,i)},decryptKeyB64:function(t,e,i,n){return a(t,e,i,n)},getDecryptedKeyHex:function(t,e){var i=s(t),n=(i.type,i.cipher),r=i.ivsalt,h=i.data,u=o(n,e,r).keyhex;return a(h,n,u,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,i,n,s){var a="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===r[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==s&&null!=s||(s=function(t){var e=y.lib.WordArray.random(t);return y.enc.Hex.stringify(e)}(r[n].ivlen).toUpperCase());var h=function(t,e,i,n){return(0,r[e].eproc)(t,i,n)}(e,n,o(n,i,s).keyhex,s);a="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+n+","+s+"\r\n",a+="\r\n",a+=h.replace(/(.{64})/g,"$1\r\n"),a+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={},s=i(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;r.ciphertext=n(t,s[1]);var o=i(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=i(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var h=i(t,a[1]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length;if("2a864886f70d0307"!=n(t,h[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(t,h[1]);var u=i(t,a[0]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length;if("2a864886f70d01050c"!=n(t,u[0]))throw"this only supports pkcs5PBKDF2";var c=i(t,u[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;r.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{r.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return r},getPBKDF2KeyHexFromParam:function(t,e){var i=y.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,r=y.PBKDF2(e,i,{keySize:6,iterations:n});return y.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var i=Ht(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=Ut.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=y.enc.Hex.parse(n.ciphertext);var o=y.enc.Hex.parse(r),a=y.enc.Hex.parse(n.encryptionSchemeIV),h=y.TripleDES.decrypt(s,o,{iv:a});return y.enc.Hex.stringify(h)},getKeyFromEncryptedPKCS8PEM:function(t,e){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var s=i(t,0);if(3!=s.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(s[1],2))throw"malformed PKCS8 private key(code:003)";var o=i(t,s[1]);if(2!=o.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(o[0],2))throw"malformed PKCS8 private key(code:005)";if(r.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(r.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw"malformed PKCS8 private key(code:006)";return r.keyidx=e.getVidx(t,s[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Ht(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,i=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==i.algoid)e=new ot;else if("2a8648ce380401"==i.algoid)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";e=new ft.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,i=pt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===i)e=new ot;else if("2a8648ce380401"===i)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";e=new ft.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=i(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(r.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return r.e=n(t,s[1]),r},parsePublicPKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null},s=i(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=i(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?r.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(r.algparam={},r.algparam.p=e.getVbyList(t,a[1],[0],"02"),r.algparam.q=e.getVbyList(t,a[1],[1],"02"),r.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(t,s[1]).substr(2),r}}}();Ut.getKey=function(t,e,i){var n=(y=pt).getChildIdx,r=(y.getV,y.getVbyList),s=ft.crypto,o=s.ECDSA,a=s.DSA,h=ot,u=Ht,c=Ut;if(void 0!==h&&t instanceof h)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(t.n,t.e),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(D=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(D=new h).setPrivate(t.n,t.e,t.d),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(D=new a).setPublic(t.p,t.q,t.g,t.y),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(D=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(xt(t.n),xt(t.e)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(D=new h).setPrivateEx(xt(t.n),xt(t.e),xt(t.d),xt(t.p),xt(t.q),xt(t.dp),xt(t.dq),xt(t.qi)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(D=new h).setPrivate(xt(t.n),xt(t.e),xt(t.d)),D;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);return C.setPublicKeyHex(f),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);var d=("0000000000"+xt(t.d)).slice(-l);return C.setPublicKeyHex(f),C.setPrivateKeyHex(d),C}if("pkcs5prv"===i){var g,p=t,y=pt;if(9===(g=n(p,0)).length)(D=new h).readPKCS5PrvKeyHex(p);else if(6===g.length)(D=new a).readPKCS5PrvKeyHex(p);else{if(!(g.length>2&&"04"===p.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(D=new o).readPKCS5PrvKeyHex(p)}return D}if("pkcs8prv"===i)return D=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===i)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===i)return Jt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Jt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=Ht(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=u(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=r(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),F=r(R,0,[2],"02"),w=r(R,0,[3],"02"),E=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(w,16),new x(E,16),new x(b,16)),D}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var A=c.getDecryptedKeyHex(t,e),I=new ot;return I.readPKCS5PrvKeyHex(A),I}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var C,D=r(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),T=r(R,0,[2,0],"06"),P=r(R,0,[3,0],"03").substr(2);if(void 0===ft.crypto.OID.oidhex2name[T])throw"undefined OID(hex) in KJUR.crypto.OID: "+T;return(C=new o({curve:ft.crypto.OID.oidhex2name[T]})).setPublicKeyHex(P),C.setPrivateKeyHex(D),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;S=r(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),F=r(R,0,[2],"02"),w=r(R,0,[3],"02"),E=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(w,16),new x(E,16),new x(b,16)),D}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw"not supported argument"},Ut.generateKeypair=function(t,e){if("RSA"==t){var i=e;(o=new ot).generate(i,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new ot,r=o.n.toString(16),s=o.e.toString(16);return n.setPublic(r,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,h=e,u=new ft.crypto.ECDSA({curve:h}).generateKeyPairHex();return(o=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),o.setPrivateKeyHex(u.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Ut.getPEM=function(t,e,i,n,r,s){var o=ft,a=o.asn1,h=a.DERObjectIdentifier,u=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,f=o.crypto,d=f.DSA,g=f.ECDSA,p=ot;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function S(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==p&&t instanceof p||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Rt(x=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=v(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===i||null==i)&&1==t.isPrivate){var F=new h({name:t.curveName}).getEncodedHex(),w=m(t).getEncodedHex(),E="";return E+=Rt(F,"EC PARAMETERS"),E+=Rt(w,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=S(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==i&&null!=i&&1==t.isPrivate){var x=v(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==i&&null!=i&&1==t.isPrivate){x=m(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==i&&null!=i&&1==t.isPrivate){x=S(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",x,i,n,s)}var b=function(t,e){var i=A(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},A=function(t,e){var i=y.lib.WordArray.random(8),n=y.lib.WordArray.random(8),r=y.PBKDF2(e,i,{keySize:6,iterations:100}),s=y.enc.Hex.parse(t),o=y.TripleDES.encrypt(s,r,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=y.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=y.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=p&&t instanceof p&&1==t.isPrivate){var I=v(t).getEncodedHex();x=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){I=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){I=new u({bigint:t.x}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}throw"unsupported object nor format"},Ut.getKeyFromCSRPEM=function(t){var e=Ht(t,"CERTIFICATE REQUEST");return Ut.getKeyFromCSRHex(e)},Ut.getKeyFromCSRHex=function(t){var e=Ut.parseCSRHex(t);return Ut.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Ut.parseCSRHex=function(t){var e=pt,i=e.getChildIdx,n=e.getTLV,r={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=i(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=i(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(s,a[2]),r},Ut.getJWKFromKey=function(t){var e={};if(t instanceof ot&&t.isPrivate)return e.kty="RSA",e.n=Et(t.n.toString(16)),e.e=Et(t.e.toString(16)),e.d=Et(t.d.toString(16)),e.p=Et(t.p.toString(16)),e.q=Et(t.q.toString(16)),e.dp=Et(t.dmp1.toString(16)),e.dq=Et(t.dmq1.toString(16)),e.qi=Et(t.coeff.toString(16)),e;if(t instanceof ot&&t.isPublic)return e.kty="RSA",e.n=Et(t.n.toString(16)),e.e=Et(t.e.toString(16)),e;if(t instanceof ft.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=Et(i.x),e.y=Et(i.y),e.d=Et(t.prvKeyHex),e}if(t instanceof ft.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=Et(i.x),e.y=Et(i.y),e}throw"not supported key object"},ot.getPosArrayOfChildrenFromHex=function(t){return pt.getChildIdx(t,0)},ot.getHexValueArrayOfChildrenFromHex=function(t){var e,i=pt.getV,n=i(t,(e=ot.getPosArrayOfChildrenFromHex(t))[0]),r=i(t,e[1]),s=i(t,e[2]),o=i(t,e[3]),a=i(t,e[4]),h=i(t,e[5]),u=i(t,e[6]),c=i(t,e[7]),l=i(t,e[8]);return(e=new Array).push(n,r,s,o,a,h,u,c,l),e},ot.prototype.readPrivateKeyFromPEMString=function(t){var e=Ht(t),i=ot.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},ot.prototype.readPKCS5PrvKeyHex=function(t){var e=ot.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},ot.prototype.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s,o,a,h,u=pt,c=u.getVbyList;if(!1===u.isASN1HEX(t))throw"not ASN.1 hex string";try{e=c(t,0,[2,0,1],"02"),i=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),r=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw"malformed PKCS#8 plain RSA private key"}this.setPrivateEx(e,i,n,r,s,o,a,h)},ot.prototype.readPKCS5PubKeyHex=function(t){var e=pt,i=e.getV;if(!1===e.isASN1HEX(t))throw"keyHex is not ASN.1 hex string";var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw"wrong hex for PKCS#5 public key";var r=i(t,n[0]),s=i(t,n[1]);this.setPublic(r,s)},ot.prototype.readPKCS8PubKeyHex=function(t){var e=pt;if(!1===e.isASN1HEX(t))throw"not ASN.1 hex string";if("06092a864886f70d010101"!==e.getTLVbyList(t,0,[0,0]))throw"not PKCS8 RSA public key";var i=e.getTLVbyList(t,0,[1,0]);this.readPKCS5PubKeyHex(i)},ot.prototype.readCertPubKeyHex=function(t,e){var i,n;(i=new Jt).readCertHex(t),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var qt=new RegExp("");function zt(t,e){for(var i="",n=e/4-t.length,r=0;r>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function Yt(t){for(var e in ft.crypto.Util.DIGESTINFOHEAD){var i=ft.crypto.Util.DIGESTINFOHEAD[e],n=i.length;if(t.substring(0,n)==i)return[e,t.substring(n)]}return[]}function Jt(){var t=pt,e=t.getChildIdx,i=t.getV,n=t.getTLV,r=t.getVbyList,s=t.getTLVbyList,o=t.getIdxbyList,a=t.getVidx,h=t.oidname,u=Jt,c=Ht;this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){return null===this.hex||0!==this.version?this.version:"a003020102"!==s(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return r(this.hex,0,[0,1+this.foffset],"02")},this.getSignatureAlgorithmField=function(){return h(r(this.hex,0,[0,2+this.foffset,0],"06"))},this.getIssuerHex=function(){return s(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return u.hex2dn(this.getIssuerHex())},this.getSubjectHex=function(){return s(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return u.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=r(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=r(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return t.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return o(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return o(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Ut.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){return h(r(this.hex,0,[1,0],"06"))},this.getSignatureValueHex=function(){return r(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmName(),i=this.getSignatureValueHex(),n=s(this.hex,0,[0],"30"),r=new ft.crypto.Signature({alg:e});return r.init(t),r.updateHex(n),r.verify(i)},this.parseExt=function(){if(3!==this.version)return-1;var i=o(this.hex,0,[0,7,0],"30"),n=e(this.hex,i);this.aExtInfo=new Array;for(var s=0;s0&&(u=new Array(i),(new nt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=It(h(Ct("\0\0\0\0\0\0\0\0"+r+u))),l=[];for(n=0;n>8*a-o&255;for(g[0]&=~p,n=0;nthis.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;var r=n[0];return n[1]==function(t){return ft.crypto.Util.hashString(t,r)}(t)},ot.prototype.verifyWithMessageHash=function(t,e){var i=rt(e=(e=e.replace(qt,"")).replace(/[ \n]+/g,""),16);if(i.bitLength()>this.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;n[0];return n[1]==t},ot.prototype.verifyPSS=function(t,e,i,n){var r,s=(r=Ct(t),ft.crypto.Util.hashHex(r,i));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(s,e,i,n)},ot.prototype.verifyWithMessageHashPSS=function(t,e,i,n){var r=new x(e,16);if(r.bitLength()>this.n.bitLength())return!1;var s,o=function(t){return ft.crypto.Util.hashHex(t,i)},a=It(t),h=a.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===n||void 0===n)n=h;else if(-2===n)n=c-h-2;else if(n<-2)throw"invalid salt length";if(c>8*c-u&255;if(0!=(f.charCodeAt(0)&g))throw"bits beyond keysize not zero";var p=Gt(d,f.length,o),y=[];for(s=0;s0)&&-1==(":"+i.join(":")+":").indexOf(":"+p+":"))throw"algorithm '"+p+"' not accepted in the list";if("none"!=p&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Ut.getKey(e)),!("RS"!=y&&"PS"!=y||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==y&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===s.jwsalg2sigalg[g.alg])throw"unsupported alg name: "+p;if("none"==(v=s.jwsalg2sigalg[p]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var S,F=null;try{F=h.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(F)}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(d)},ft.jws.JWS.parse=function(t){var e,i,n,r=t.split("."),s={};if(2!=r.length&&3!=r.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=r[0],i=r[1],3==r.length&&(n=r[2]),s.headerObj=ft.jws.JWS.readSafeJSONString(gt(e)),s.payloadObj=ft.jws.JWS.readSafeJSONString(gt(i)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=gt(i):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==n&&(s.sigHex=xt(n)),s},ft.jws.JWS.verifyJWT=function(t,e,i){var n=ft.jws,r=n.JWS,s=r.readSafeJSONString,o=r.inArray,a=r.includedArray,h=t.split("."),u=h[0],c=h[1],l=(xt(h[2]),s(gt(u))),f=s(gt(c));if(void 0===l.alg)return!1;if(void 0===i.alg)throw"acceptField.alg shall be specified";if(!o(l.alg,i.alg))return!1;if(void 0!==f.iss&&"object"==typeof i.iss&&!o(f.iss,i.iss))return!1;if(void 0!==f.sub&&"object"==typeof i.sub&&!o(f.sub,i.sub))return!1;if(void 0!==f.aud&&"object"==typeof i.aud)if("string"==typeof f.aud){if(!o(f.aud,i.aud))return!1}else if("object"==typeof f.aud&&!a(f.aud,i.aud))return!1;var d=n.IntDate.getNow();return void 0!==i.verifyAt&&"number"==typeof i.verifyAt&&(d=i.verifyAt),void 0!==i.gracePeriod&&"number"==typeof i.gracePeriod||(i.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+i.gracePeriodr&&this.aHeader.pop(),this.aSignature.length>r&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignatures=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},e.SecureRandom=nt,e.rng_seed_time=Z,e.BigInteger=x,e.RSAKey=ot,e.ECDSA=ft.crypto.ECDSA,e.DSA=ft.crypto.DSA,e.Signature=ft.crypto.Signature,e.MessageDigest=ft.crypto.MessageDigest,e.Mac=ft.crypto.Mac,e.Cipher=ft.crypto.Cipher,e.KEYUTIL=Ut,e.ASN1HEX=pt,e.X509=Jt,e.CryptoJS=y,e.b64tohex=w,e.b64toBA=E,e.stoBA=yt,e.BAtos=vt,e.BAtohex=mt,e.stohex=St,e.stob64=function(t){return F(St(t))},e.stob64u=function(t){return Ft(F(St(t)))},e.b64utos=function(t){return vt(E(wt(t)))},e.b64tob64u=Ft,e.b64utob64=wt,e.hex2b64=F,e.hextob64u=Et,e.b64utohex=xt,e.utf8tob64u=dt,e.b64utoutf8=gt,e.utf8tob64=function(t){return F(Ot(Kt(t)))},e.b64toutf8=function(t){return decodeURIComponent(jt(w(t)))},e.utf8tohex=bt,e.hextoutf8=At,e.hextorstr=It,e.rstrtohex=Ct,e.hextob64=Dt,e.hextob64nl=Tt,e.b64nltohex=Pt,e.hextopem=Rt,e.pemtohex=Ht,e.hextoArrayBuffer=function(t){if(t.length%2!=0)throw"input is not even length";if(null==t.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var e=new ArrayBuffer(t.length/2),i=new DataView(e),n=0;ne.length&&(i=e.length);for(var n=0;n300)throw new r(`Failed to fetch ${t}. Response=${s}`,i.status);try{return JSON.parse(s)}catch(e){throw new r(`Invalid response while trying to fetch ${t}. Response=${s}`,i.status,e)}}}},function(t,e,i){const n=i(1),r=i(15);t.exports=class{constructor({jwt:t=i(0)}={}){this.jwt=t}decodeAndValidate({token:t,publicKeys:e,issuer:i,clientId:s,nonce:o}){const a=Math.floor(Date.now()/1e3),h=t.split(".");if(3!==h.length)throw new r(`Invalid JWT token. Got only ${h.length} parts.`);const u=this.jwt.KJUR.jws.JWS.parse(t);if(!u.headerObj)throw new r(n.INVALID_TOKEN);const c=u.headerObj.kid,l=this.getPublicKey(e.keys,c),f=this.jwt.KEYUTIL.getKey(l);if(!this.jwt.KJUR.jws.JWS.verify(t,f,{alg:[n.TOKEN_ALG]}))throw new r(n.INVALID_SIGNATURE);if(u.payloadObj.exp - * @license MIT - */ -var n=i(9),r=i(10),s=i(11);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return A(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function A(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return w(this,t,e,i);case"latin1":case"binary":return E(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function N(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||B(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);B(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);B(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(8))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(17);t.exports=class{constructor({w:t=window}={}){this.window=t}init(t){this.popupConfig=t}open(){const t=this.popupConfig.height,e=this.popupConfig.width,i=(window.screen.width-e)/2,r=(window.screen.height-t)/2;if(this.popup=this.window.open("","popup",`left=${i},top=${r},width=${e},height=${t},resizable,scrollbars=yes,status=1`),!this.popup)throw new n("Unable to open popup")}navigate(t){this.popup.location.href=t}close(){this.popup.close()}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(21);t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t);const i={"x-filter-type":`spa:v${n.version}`};this.publicKeys=e(this.getJwksEndpoint(),{headers:i})}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}},function(t){t.exports=JSON.parse('{"name":"ibmcloud-appid-js","version":"0.3.0","description":"IBM Cloud App ID SDK for Single Page Applications","scripts":{"build":"webpack","test":"mocha","coverage":"nyc --reporter=lcov mocha","docs":"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git"},"main":"dist/appid.umd.min.js","nyc":{"all":true,"include":["src/*.js"],"exclude":["**/PopupController.js","**/IFrameController.js","**/OpenIDConfigurationResource.js","**/constants.js"]},"dependencies":{"jsrsasign":"^8.0.12"},"devDependencies":{"node-fetch":"^2.6.0","@babel/cli":"^7.0.0","@babel/core":"^7.5.5","@babel/plugin-transform-runtime":"^7.5.5","@babel/preset-env":"^7.5.5","babel-cli":"^7.0.0-beta.3","chai":"^4.2.0","coveralls":"^3.0.6","gulp-babel":"^8.0.0","mocha":"^6.2.0","nyc":"^14.1.1","webpack":"^4.39.1","webpack-cli":"^3.3.6","docdash":"^1.1.1","jsdoc":"^3.6.3"}}')}])})); \ No newline at end of file +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["AppID"] = factory(); + else + root["AppID"] = factory(); +})(window, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./node_modules/base64-js/index.js": +/*!*****************************************!*\ + !*** ./node_modules/base64-js/index.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/base64-js/index.js?"); + +/***/ }), + +/***/ "./node_modules/buffer/index.js": +/*!**************************************!*\ + !*** ./node_modules/buffer/index.js ***! + \**************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("/* WEBPACK VAR INJECTION */(function(global) {/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n\n\nvar base64 = __webpack_require__(/*! base64-js */ \"./node_modules/base64-js/index.js\")\nvar ieee754 = __webpack_require__(/*! ieee754 */ \"./node_modules/ieee754/index.js\")\nvar isArray = __webpack_require__(/*! isarray */ \"./node_modules/isarray/index.js\")\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://AppID/./node_modules/buffer/index.js?"); + +/***/ }), + +/***/ "./node_modules/ieee754/index.js": +/*!***************************************!*\ + !*** ./node_modules/ieee754/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/ieee754/index.js?"); + +/***/ }), + +/***/ "./node_modules/isarray/index.js": +/*!***************************************!*\ + !*** ./node_modules/isarray/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n\n\n//# sourceURL=webpack://AppID/./node_modules/isarray/index.js?"); + +/***/ }), + +/***/ "./node_modules/jsrsasign/lib/jsrsasign.js": +/*!*************************************************!*\ + !*** ./node_modules/jsrsasign/lib/jsrsasign.js ***! + \*************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\nvar navigator = {};\nnavigator.userAgent = false;\n\nvar window = {};\n/*\n * jsrsasign(all) 8.0.12 (2018-04-22) (c) 2010-2018 Kenji Urushima | kjur.github.com/jsrsasign/license\n */\n\n/*!\nCopyright (c) 2011, Yahoo! Inc. All rights reserved.\nCode licensed under the BSD License:\nhttp://developer.yahoo.com/yui/license.html\nversion: 2.9.0\n*/\nif(YAHOO===undefined){var YAHOO={}}YAHOO.lang={extend:function(g,h,f){if(!h||!g){throw new Error(\"YAHOO.lang.extend failed, please check that all dependencies are included.\")}var d=function(){};d.prototype=h.prototype;g.prototype=new d();g.prototype.constructor=g;g.superclass=h.prototype;if(h.prototype.constructor==Object.prototype.constructor){h.prototype.constructor=h}if(f){var b;for(b in f){g.prototype[b]=f[b]}var e=function(){},c=[\"toString\",\"valueOf\"];try{if(/MSIE/.test(navigator.userAgent)){e=function(j,i){for(b=0;b>>2]>>>(24-(r%4)*8))&255;q[(n+r)>>>2]|=o<<(24-((n+r)%4)*8)}}else{for(var r=0;r>>2]=p[r>>>2]}}this.sigBytes+=s;return this},clamp:function(){var o=this.words;var n=this.sigBytes;o[n>>>2]&=4294967295<<(32-(n%4)*8);o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);n.words=this.words.slice(0);return n},random:function(p){var o=[];for(var n=0;n>>2]>>>(24-(n%4)*8))&255;q.push((s>>>4).toString(16));q.push((s&15).toString(16))}return q.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>3]|=parseInt(p.substr(o,2),16)<<(24-(o%8)*4)}return new l.init(q,n/2)}};var d=m.Latin1={stringify:function(q){var r=q.words;var p=q.sigBytes;var n=[];for(var o=0;o>>2]>>>(24-(o%4)*8))&255;n.push(String.fromCharCode(s))}return n.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>2]|=(p.charCodeAt(o)&255)<<(24-(o%4)*8)}return new l.init(q,n)}};var c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error(\"Malformed UTF-8 data\")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}};var i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init();this._nDataBytes=0},_append:function(n){if(typeof n==\"string\"){n=c.parse(n)}this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data;var x=q.words;var n=q.sigBytes;var t=this.blockSize;var v=t*4;var u=n/v;if(w){u=e.ceil(u)}else{u=e.max((u|0)-this._minBufferSize,0)}var s=u*t;var r=e.min(s*4,n);if(s){for(var p=0;p>>2]&255}};f.BlockCipher=n.extend({cfg:n.cfg.extend({mode:m,padding:h}),reset:function(){n.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;\nthis._mode=c.call(a,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var p=f.CipherParams=k.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(g.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;\nreturn(a?l.create([1398893684,1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=l.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return p.create({ciphertext:a,salt:c})}},j=f.SerializableCipher=k.extend({cfg:k.extend({format:m}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return p.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,\nblockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return\"string\"==typeof a?b.parse(a,this):a}}),g=(g.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=l.random(8));a=v.create({keySize:b+c}).compute(a,d);c=l.create(a.words.slice(b),4*c);a.sigBytes=4*b;return p.create({key:a,iv:c,salt:d})}},s=f.PasswordBasedCipher=j.extend({cfg:j.cfg.extend({kdf:g}),encrypt:function(a,\nb,c,d){d=this.cfg.extend(d);c=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=c.iv;a=j.encrypt.call(this,a,b,c.key,d);a.mixIn(c);return a},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=c.iv;return j.decrypt.call(this,a,b,c.key,d)}})}();\n\n/*\nCryptoJS v3.1.2 aes.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){for(var q=CryptoJS,x=q.lib.BlockCipher,r=q.algo,j=[],y=[],z=[],A=[],B=[],C=[],s=[],u=[],v=[],w=[],g=[],k=0;256>k;k++)g[k]=128>k?k<<1:k<<1^283;for(var n=0,l=0,k=0;256>k;k++){var f=l^l<<1^l<<2^l<<3^l<<4,f=f>>>8^f&255^99;j[n]=f;y[f]=n;var t=g[n],D=g[t],E=g[D],b=257*g[f]^16843008*f;z[n]=b<<24|b>>>8;A[n]=b<<16|b>>>16;B[n]=b<<8|b>>>24;C[n]=b;b=16843009*E^65537*D^257*t^16843008*n;s[f]=b<<24|b>>>8;u[f]=b<<16|b>>>16;v[f]=b<<8|b>>>24;w[f]=b;n?(n=t^g[g[g[E^t]]],l^=g[g[l]]):n=l=1}var F=[0,1,2,4,8,\n16,32,64,128,27,54],r=r.AES=x.extend({_doReset:function(){for(var c=this._key,e=c.words,a=c.sigBytes/4,c=4*((this._nRounds=a+6)+1),b=this._keySchedule=[],h=0;h>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255]):(d=d<<8|d>>>24,d=j[d>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255],d^=F[h/a|0]<<24);b[h]=b[h-a]^d}e=this._invKeySchedule=[];for(a=0;aa||4>=h?d:s[j[d>>>24]]^u[j[d>>>16&255]]^v[j[d>>>\n8&255]]^w[j[d&255]]},encryptBlock:function(c,e){this._doCryptBlock(c,e,this._keySchedule,z,A,B,C,j)},decryptBlock:function(c,e){var a=c[e+1];c[e+1]=c[e+3];c[e+3]=a;this._doCryptBlock(c,e,this._invKeySchedule,s,u,v,w,y);a=c[e+1];c[e+1]=c[e+3];c[e+3]=a},_doCryptBlock:function(c,e,a,b,h,d,j,m){for(var n=this._nRounds,f=c[e]^a[0],g=c[e+1]^a[1],k=c[e+2]^a[2],p=c[e+3]^a[3],l=4,t=1;t>>24]^h[g>>>16&255]^d[k>>>8&255]^j[p&255]^a[l++],r=b[g>>>24]^h[k>>>16&255]^d[p>>>8&255]^j[f&255]^a[l++],s=\nb[k>>>24]^h[p>>>16&255]^d[f>>>8&255]^j[g&255]^a[l++],p=b[p>>>24]^h[f>>>16&255]^d[g>>>8&255]^j[k&255]^a[l++],f=q,g=r,k=s;q=(m[f>>>24]<<24|m[g>>>16&255]<<16|m[k>>>8&255]<<8|m[p&255])^a[l++];r=(m[g>>>24]<<24|m[k>>>16&255]<<16|m[p>>>8&255]<<8|m[f&255])^a[l++];s=(m[k>>>24]<<24|m[p>>>16&255]<<16|m[f>>>8&255]<<8|m[g&255])^a[l++];p=(m[p>>>24]<<24|m[f>>>16&255]<<16|m[g>>>8&255]<<8|m[k&255])^a[l++];c[e]=q;c[e+1]=r;c[e+2]=s;c[e+3]=p},keySize:8});q.AES=x._createHelper(r)})();\n\n/*\nCryptoJS v3.1.2 tripledes-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function j(b,c){var a=(this._lBlock>>>b^this._rBlock)&c;this._rBlock^=a;this._lBlock^=a<>>b^this._lBlock)&c;this._lBlock^=a;this._rBlock^=a<a;a++){var f=q[a]-1;c[a]=b[f>>>5]>>>31-f%32&1}b=this._subKeys=[];for(f=0;16>f;f++){for(var d=b[f]=[],e=r[f],a=0;24>a;a++)d[a/6|0]|=c[(p[a]-1+e)%28]<<31-a%6,d[4+(a/6|0)]|=c[28+(p[a+24]-1+e)%28]<<31-a%6;d[0]=d[0]<<1|d[0]>>>31;for(a=1;7>a;a++)d[a]>>>=\n4*(a-1)+3;d[7]=d[7]<<5|d[7]>>>27}c=this._invSubKeys=[];for(a=0;16>a;a++)c[a]=b[15-a]},encryptBlock:function(b,c){this._doCryptBlock(b,c,this._subKeys)},decryptBlock:function(b,c){this._doCryptBlock(b,c,this._invSubKeys)},_doCryptBlock:function(b,c,a){this._lBlock=b[c];this._rBlock=b[c+1];j.call(this,4,252645135);j.call(this,16,65535);l.call(this,2,858993459);l.call(this,8,16711935);j.call(this,1,1431655765);for(var f=0;16>f;f++){for(var d=a[f],e=this._lBlock,h=this._rBlock,g=0,k=0;8>k;k++)g|=s[k][((h^\nd[k])&t[k])>>>0];this._lBlock=h;this._rBlock=e^g}a=this._lBlock;this._lBlock=this._rBlock;this._rBlock=a;j.call(this,1,1431655765);l.call(this,8,16711935);l.call(this,2,858993459);j.call(this,16,65535);j.call(this,4,252645135);b[c]=this._lBlock;b[c+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});h.DES=e._createHelper(m);g=g.TripleDES=e.extend({_doReset:function(){var b=this._key.words;this._des1=m.createEncryptor(n.create(b.slice(0,2)));this._des2=m.createEncryptor(n.create(b.slice(2,4)));this._des3=\nm.createEncryptor(n.create(b.slice(4,6)))},encryptBlock:function(b,c){this._des1.encryptBlock(b,c);this._des2.decryptBlock(b,c);this._des3.encryptBlock(b,c)},decryptBlock:function(b,c){this._des3.decryptBlock(b,c);this._des2.encryptBlock(b,c);this._des1.decryptBlock(b,c)},keySize:6,ivSize:2,blockSize:2});h.TripleDES=e._createHelper(g)})();\n\n/*\nCryptoJS v3.1.2 enc-base64.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join(\"\")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d<\ne;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\"}})();\n\n/*\nCryptoJS v3.1.2 md5.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(E){function h(a,f,g,j,p,h,k){a=a+(f&g|~f&j)+p+k;return(a<>>32-h)+f}function k(a,f,g,j,p,h,k){a=a+(f&j|g&~j)+p+k;return(a<>>32-h)+f}function l(a,f,g,j,h,k,l){a=a+(f^g^j)+h+l;return(a<>>32-k)+f}function n(a,f,g,j,h,k,l){a=a+(g^(f|~j))+h+l;return(a<>>32-k)+f}for(var r=CryptoJS,q=r.lib,F=q.WordArray,s=q.Hasher,q=r.algo,a=[],t=0;64>t;t++)a[t]=4294967296*E.abs(E.sin(t+1))|0;q=q.MD5=s.extend({_doReset:function(){this._hash=new F.init([1732584193,4023233417,2562383102,271733878])},\n_doProcessBlock:function(m,f){for(var g=0;16>g;g++){var j=f+g,p=m[j];m[j]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360}var g=this._hash.words,j=m[f+0],p=m[f+1],q=m[f+2],r=m[f+3],s=m[f+4],t=m[f+5],u=m[f+6],v=m[f+7],w=m[f+8],x=m[f+9],y=m[f+10],z=m[f+11],A=m[f+12],B=m[f+13],C=m[f+14],D=m[f+15],b=g[0],c=g[1],d=g[2],e=g[3],b=h(b,c,d,e,j,7,a[0]),e=h(e,b,c,d,p,12,a[1]),d=h(d,e,b,c,q,17,a[2]),c=h(c,d,e,b,r,22,a[3]),b=h(b,c,d,e,s,7,a[4]),e=h(e,b,c,d,t,12,a[5]),d=h(d,e,b,c,u,17,a[6]),c=h(c,d,e,b,v,22,a[7]),\nb=h(b,c,d,e,w,7,a[8]),e=h(e,b,c,d,x,12,a[9]),d=h(d,e,b,c,y,17,a[10]),c=h(c,d,e,b,z,22,a[11]),b=h(b,c,d,e,A,7,a[12]),e=h(e,b,c,d,B,12,a[13]),d=h(d,e,b,c,C,17,a[14]),c=h(c,d,e,b,D,22,a[15]),b=k(b,c,d,e,p,5,a[16]),e=k(e,b,c,d,u,9,a[17]),d=k(d,e,b,c,z,14,a[18]),c=k(c,d,e,b,j,20,a[19]),b=k(b,c,d,e,t,5,a[20]),e=k(e,b,c,d,y,9,a[21]),d=k(d,e,b,c,D,14,a[22]),c=k(c,d,e,b,s,20,a[23]),b=k(b,c,d,e,x,5,a[24]),e=k(e,b,c,d,C,9,a[25]),d=k(d,e,b,c,r,14,a[26]),c=k(c,d,e,b,w,20,a[27]),b=k(b,c,d,e,B,5,a[28]),e=k(e,b,\nc,d,q,9,a[29]),d=k(d,e,b,c,v,14,a[30]),c=k(c,d,e,b,A,20,a[31]),b=l(b,c,d,e,t,4,a[32]),e=l(e,b,c,d,w,11,a[33]),d=l(d,e,b,c,z,16,a[34]),c=l(c,d,e,b,C,23,a[35]),b=l(b,c,d,e,p,4,a[36]),e=l(e,b,c,d,s,11,a[37]),d=l(d,e,b,c,v,16,a[38]),c=l(c,d,e,b,y,23,a[39]),b=l(b,c,d,e,B,4,a[40]),e=l(e,b,c,d,j,11,a[41]),d=l(d,e,b,c,r,16,a[42]),c=l(c,d,e,b,u,23,a[43]),b=l(b,c,d,e,x,4,a[44]),e=l(e,b,c,d,A,11,a[45]),d=l(d,e,b,c,D,16,a[46]),c=l(c,d,e,b,q,23,a[47]),b=n(b,c,d,e,j,6,a[48]),e=n(e,b,c,d,v,10,a[49]),d=n(d,e,b,c,\nC,15,a[50]),c=n(c,d,e,b,t,21,a[51]),b=n(b,c,d,e,A,6,a[52]),e=n(e,b,c,d,r,10,a[53]),d=n(d,e,b,c,y,15,a[54]),c=n(c,d,e,b,p,21,a[55]),b=n(b,c,d,e,w,6,a[56]),e=n(e,b,c,d,D,10,a[57]),d=n(d,e,b,c,u,15,a[58]),c=n(c,d,e,b,B,21,a[59]),b=n(b,c,d,e,s,6,a[60]),e=n(e,b,c,d,z,10,a[61]),d=n(d,e,b,c,q,15,a[62]),c=n(c,d,e,b,x,21,a[63]);g[0]=g[0]+b|0;g[1]=g[1]+c|0;g[2]=g[2]+d|0;g[3]=g[3]+e|0},_doFinalize:function(){var a=this._data,f=a.words,g=8*this._nDataBytes,j=8*a.sigBytes;f[j>>>5]|=128<<24-j%32;var h=E.floor(g/\n4294967296);f[(j+64>>>9<<4)+15]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;f[(j+64>>>9<<4)+14]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360;a.sigBytes=4*(f.length+1);this._process();a=this._hash;f=a.words;for(g=0;4>g;g++)j=f[g],f[g]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=s.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=s._createHelper(q);r.HmacMD5=s._createHmacHelper(q)})(Math);\n\n/*\nCryptoJS v3.1.2 sha1-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var k=CryptoJS,b=k.lib,m=b.WordArray,l=b.Hasher,d=[],b=k.algo.SHA1=l.extend({_doReset:function(){this._hash=new m.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(n,p){for(var a=this._hash.words,e=a[0],f=a[1],h=a[2],j=a[3],b=a[4],c=0;80>c;c++){if(16>c)d[c]=n[p+c]|0;else{var g=d[c-3]^d[c-8]^d[c-14]^d[c-16];d[c]=g<<1|g>>>31}g=(e<<5|e>>>27)+b+d[c];g=20>c?g+((f&h|~f&j)+1518500249):40>c?g+((f^h^j)+1859775393):60>c?g+((f&h|f&j|h&j)-1894007588):g+((f^h^\nj)-899497514);b=j;j=h;h=f<<30|f>>>2;f=e;e=g}a[0]=a[0]+e|0;a[1]=a[1]+f|0;a[2]=a[2]+h|0;a[3]=a[3]+j|0;a[4]=a[4]+b|0},_doFinalize:function(){var b=this._data,d=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=Math.floor(a/4294967296);d[(e+64>>>9<<4)+15]=a;b.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var b=l.clone.call(this);b._hash=this._hash.clone();return b}});k.SHA1=l._createHelper(b);k.HmacSHA1=l._createHmacHelper(b)})();\n\n/*\nCryptoJS v3.1.2 sha256-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(k){for(var g=CryptoJS,h=g.lib,v=h.WordArray,j=h.Hasher,h=g.algo,s=[],t=[],u=function(q){return 4294967296*(q-(q|0))|0},l=2,b=0;64>b;){var d;a:{d=l;for(var w=k.sqrt(d),r=2;r<=w;r++)if(!(d%r)){d=!1;break a}d=!0}d&&(8>b&&(s[b]=u(k.pow(l,0.5))),t[b]=u(k.pow(l,1/3)),b++);l++}var n=[],h=h.SHA256=j.extend({_doReset:function(){this._hash=new v.init(s.slice(0))},_doProcessBlock:function(q,h){for(var a=this._hash.words,c=a[0],d=a[1],b=a[2],k=a[3],f=a[4],g=a[5],j=a[6],l=a[7],e=0;64>e;e++){if(16>e)n[e]=\nq[h+e]|0;else{var m=n[e-15],p=n[e-2];n[e]=((m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3)+n[e-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[e-16]}m=l+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&g^~f&j)+t[e]+n[e];p=((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&d^c&b^d&b);l=j;j=g;g=f;f=k+m|0;k=b;b=d;d=c;c=m+p|0}a[0]=a[0]+c|0;a[1]=a[1]+d|0;a[2]=a[2]+b|0;a[3]=a[3]+k|0;a[4]=a[4]+f|0;a[5]=a[5]+g|0;a[6]=a[6]+j|0;a[7]=a[7]+l|0},_doFinalize:function(){var d=this._data,b=d.words,a=8*this._nDataBytes,c=8*d.sigBytes;\nb[c>>>5]|=128<<24-c%32;b[(c+64>>>9<<4)+14]=k.floor(a/4294967296);b[(c+64>>>9<<4)+15]=a;d.sigBytes=4*b.length;this._process();return this._hash},clone:function(){var b=j.clone.call(this);b._hash=this._hash.clone();return b}});g.SHA256=j._createHelper(h);g.HmacSHA256=j._createHmacHelper(h)})(Math);\n\n/*\nCryptoJS v3.1.2 sha224-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var b=CryptoJS,d=b.lib.WordArray,a=b.algo,c=a.SHA256,a=a.SHA224=c.extend({_doReset:function(){this._hash=new d.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var a=c._doFinalize.call(this);a.sigBytes-=4;return a}});b.SHA224=c._createHelper(a);b.HmacSHA224=c._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 sha512-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function a(){return d.create.apply(d,arguments)}for(var n=CryptoJS,r=n.lib.Hasher,e=n.x64,d=e.Word,T=e.WordArray,e=n.algo,ea=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),\na(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,\n2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),\na(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,\n3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],w=0;80>w;w++)v[w]=a();e=e.SHA512=r.extend({_doReset:function(){this._hash=new T.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(a,d){for(var f=this._hash.words,\nF=f[0],e=f[1],n=f[2],r=f[3],G=f[4],H=f[5],I=f[6],f=f[7],w=F.high,J=F.low,X=e.high,K=e.low,Y=n.high,L=n.low,Z=r.high,M=r.low,$=G.high,N=G.low,aa=H.high,O=H.low,ba=I.high,P=I.low,ca=f.high,Q=f.low,k=w,g=J,z=X,x=K,A=Y,y=L,U=Z,B=M,l=$,h=N,R=aa,C=O,S=ba,D=P,V=ca,E=Q,m=0;80>m;m++){var s=v[m];if(16>m)var j=s.high=a[d+2*m]|0,b=s.low=a[d+2*m+1]|0;else{var j=v[m-15],b=j.high,p=j.low,j=(b>>>1|p<<31)^(b>>>8|p<<24)^b>>>7,p=(p>>>1|b<<31)^(p>>>8|b<<24)^(p>>>7|b<<25),u=v[m-2],b=u.high,c=u.low,u=(b>>>19|c<<13)^(b<<\n3|c>>>29)^b>>>6,c=(c>>>19|b<<13)^(c<<3|b>>>29)^(c>>>6|b<<26),b=v[m-7],W=b.high,t=v[m-16],q=t.high,t=t.low,b=p+b.low,j=j+W+(b>>>0

>>0?1:0),b=b+c,j=j+u+(b>>>0>>0?1:0),b=b+t,j=j+q+(b>>>0>>0?1:0);s.high=j;s.low=b}var W=l&R^~l&S,t=h&C^~h&D,s=k&z^k&A^z&A,T=g&x^g&y^x&y,p=(k>>>28|g<<4)^(k<<30|g>>>2)^(k<<25|g>>>7),u=(g>>>28|k<<4)^(g<<30|k>>>2)^(g<<25|k>>>7),c=ea[m],fa=c.high,da=c.low,c=E+((h>>>14|l<<18)^(h>>>18|l<<14)^(h<<23|l>>>9)),q=V+((l>>>14|h<<18)^(l>>>18|h<<14)^(l<<23|h>>>9))+(c>>>0>>0?1:\n0),c=c+t,q=q+W+(c>>>0>>0?1:0),c=c+da,q=q+fa+(c>>>0>>0?1:0),c=c+b,q=q+j+(c>>>0>>0?1:0),b=u+T,s=p+s+(b>>>0>>0?1:0),V=S,E=D,S=R,D=C,R=l,C=h,h=B+c|0,l=U+q+(h>>>0>>0?1:0)|0,U=A,B=y,A=z,y=x,z=k,x=g,g=c+b|0,k=q+s+(g>>>0>>0?1:0)|0}J=F.low=J+g;F.high=w+k+(J>>>0>>0?1:0);K=e.low=K+x;e.high=X+z+(K>>>0>>0?1:0);L=n.low=L+y;n.high=Y+A+(L>>>0>>0?1:0);M=r.low=M+B;r.high=Z+U+(M>>>0>>0?1:0);N=G.low=N+h;G.high=$+l+(N>>>0>>0?1:0);O=H.low=O+C;H.high=aa+R+(O>>>0>>0?1:0);P=I.low=P+D;\nI.high=ba+S+(P>>>0>>0?1:0);Q=f.low=Q+E;f.high=ca+V+(Q>>>0>>0?1:0)},_doFinalize:function(){var a=this._data,d=a.words,f=8*this._nDataBytes,e=8*a.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+128>>>10<<5)+30]=Math.floor(f/4294967296);d[(e+128>>>10<<5)+31]=f;a.sigBytes=4*d.length;this._process();return this._hash.toX32()},clone:function(){var a=r.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});n.SHA512=r._createHelper(e);n.HmacSHA512=r._createHmacHelper(e)})();\n\n/*\nCryptoJS v3.1.2 sha384-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,a=c.x64,b=a.Word,e=a.WordArray,a=c.algo,d=a.SHA512,a=a.SHA384=d.extend({_doReset:function(){this._hash=new e.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var a=d._doFinalize.call(this);a.sigBytes-=16;return a}});c.SHA384=\nd._createHelper(a);c.HmacSHA384=d._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 ripemd160-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n/*\n\n(c) 2012 by Cedric Mesnil. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n(function(){var q=CryptoJS,d=q.lib,n=d.WordArray,p=d.Hasher,d=q.algo,x=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),y=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),z=n.create([11,14,15,12,\n5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),A=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),B=n.create([0,1518500249,1859775393,2400959708,2840853838]),C=n.create([1352829926,1548603684,1836072691,\n2053994217,0]),d=d.RIPEMD160=p.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,v){for(var b=0;16>b;b++){var c=v+b,f=e[c];e[c]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360}var c=this._hash.words,f=B.words,d=C.words,n=x.words,q=y.words,p=z.words,w=A.words,t,g,h,j,r,u,k,l,m,s;u=t=c[0];k=g=c[1];l=h=c[2];m=j=c[3];s=r=c[4];for(var a,b=0;80>b;b+=1)a=t+e[v+n[b]]|0,a=16>b?a+((g^h^j)+f[0]):32>b?a+((g&h|~g&j)+f[1]):48>b?\na+(((g|~h)^j)+f[2]):64>b?a+((g&j|h&~j)+f[3]):a+((g^(h|~j))+f[4]),a|=0,a=a<>>32-p[b],a=a+r|0,t=r,r=j,j=h<<10|h>>>22,h=g,g=a,a=u+e[v+q[b]]|0,a=16>b?a+((k^(l|~m))+d[0]):32>b?a+((k&m|l&~m)+d[1]):48>b?a+(((k|~l)^m)+d[2]):64>b?a+((k&l|~k&m)+d[3]):a+((k^l^m)+d[4]),a|=0,a=a<>>32-w[b],a=a+s|0,u=s,s=m,m=l<<10|l>>>22,l=k,k=a;a=c[1]+h+m|0;c[1]=c[2]+j+s|0;c[2]=c[3]+r+u|0;c[3]=c[4]+t+k|0;c[4]=c[0]+g+l|0;c[0]=a},_doFinalize:function(){var e=this._data,d=e.words,b=8*this._nDataBytes,c=8*e.sigBytes;\nd[c>>>5]|=128<<24-c%32;d[(c+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;e.sigBytes=4*(d.length+1);this._process();e=this._hash;d=e.words;for(b=0;5>b;b++)c=d[b],d[b]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return e},clone:function(){var d=p.clone.call(this);d._hash=this._hash.clone();return d}});q.RIPEMD160=p._createHelper(d);q.HmacRIPEMD160=p._createHmacHelper(d)})(Math);\n\n/*\nCryptoJS v3.1.2 hmac.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,k=c.enc.Utf8;c.algo.HMAC=c.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;\"string\"==typeof b&&(b=k.parse(b));var c=a.blockSize,e=4*c;b.sigBytes>e&&(b=a.finalize(b));b.clamp();for(var f=this._oKey=b.clone(),g=this._iKey=b.clone(),h=f.words,j=g.words,d=0;d>6)+b64map.charAt(e&63)}if(b+1==d.length){e=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(e<<2)}else{if(b+2==d.length){e=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(e>>2)+b64map.charAt((e&3)<<4)}}if(b64pad){while((a.length&3)>0){a+=b64pad}}return a}function b64tohex(f){var d=\"\";var e;var b=0;var c;var a;for(e=0;e>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(e){var d=b64tohex(e);var c;var b=new Array();for(c=0;2*c=0){var d=a*this[f++]+b[e]+h;h=Math.floor(d/67108864);b[e++]=d&67108863}return h}function am2(f,q,r,e,o,a){var k=q&32767,p=q>>15;while(--a>=0){var d=this[f]&32767;var g=this[f++]>>15;var b=p*d+g*k;d=k*d+((b&32767)<<15)+r[e]+(o&1073741823);o=(d>>>30)+(b>>>15)+p*g+(o>>>30);r[e++]=d&1073741823}return o}function am3(f,q,r,e,o,a){var k=q&16383,p=q>>14;while(--a>=0){var d=this[f]&16383;var g=this[f++]>>14;var b=p*d+g*k;d=k*d+((b&16383)<<14)+r[e]+o;o=(d>>28)+(b>>14)+p*g;r[e++]=d&268435455}return o}if(j_lm&&(navigator.appName==\"Microsoft Internet Explorer\")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator.appName!=\"Netscape\")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=((1<=0;--a){b[a]=this[a]}b.t=this.t;b.s=this.s}function bnpFromInt(a){this.t=1;this.s=(a<0)?-1:0;if(a>0){this[0]=a}else{if(a<-1){this[0]=a+this.DV}else{this.t=0}}}function nbv(a){var b=nbi();b.fromInt(a);return b}function bnpFromString(h,c){var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==256){e=8}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{this.fromRadix(h,c);return}}}}}}this.t=0;this.s=0;var g=h.length,d=false,f=0;while(--g>=0){var a=(e==8)?h[g]&255:intAt(h,g);if(a<0){if(h.charAt(g)==\"-\"){d=true}continue}d=false;if(f==0){this[this.t++]=a}else{if(f+e>this.DB){this[this.t-1]|=(a&((1<<(this.DB-f))-1))<>(this.DB-f))}else{this[this.t-1]|=a<=this.DB){f-=this.DB}}if(e==8&&(h[0]&128)!=0){this.s=-1;if(f>0){this[this.t-1]|=((1<<(this.DB-f))-1)<0&&this[this.t-1]==a){--this.t}}function bnToString(c){if(this.s<0){return\"-\"+this.negate().toString(c)}var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{return this.toRadix(c)}}}}}var g=(1<0){if(j>j)>0){a=true;h=int2char(l)}while(f>=0){if(j>(j+=this.DB-e)}else{l=(this[f]>>(j-=e))&g;if(j<=0){j+=this.DB;--f}}if(l>0){a=true}if(a){h+=int2char(l)}}}return a?h:\"0\"}function bnNegate(){var a=nbi();BigInteger.ZERO.subTo(this,a);return a}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(b){var d=this.s-b.s;if(d!=0){return d}var c=this.t;d=c-b.t;if(d!=0){return(this.s<0)?-d:d}while(--c>=0){if((d=this[c]-b[c])!=0){return d}}return 0}function nbits(a){var c=1,b;if((b=a>>>16)!=0){a=b;c+=16}if((b=a>>8)!=0){a=b;c+=8}if((b=a>>4)!=0){a=b;c+=4}if((b=a>>2)!=0){a=b;c+=2}if((b=a>>1)!=0){a=b;c+=1}return c}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(c,b){var a;for(a=this.t-1;a>=0;--a){b[a+c]=this[a]}for(a=c-1;a>=0;--a){b[a]=0}b.t=this.t+c;b.s=this.s}function bnpDRShiftTo(c,b){for(var a=c;a=0;--d){e[d+f+1]=(this[d]>>a)|h;h=(this[d]&g)<=0;--d){e[d]=0}e[f]=h;e.t=this.t+f+1;e.s=this.s;e.clamp()}function bnpRShiftTo(g,d){d.s=this.s;var e=Math.floor(g/this.DB);if(e>=this.t){d.t=0;return}var b=g%this.DB;var a=this.DB-b;var f=(1<>b;for(var c=e+1;c>b}if(b>0){d[this.t-e-1]|=(this.s&f)<>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g-=d.s}f.s=(g<0)?-1:0;if(g<-1){f[e++]=this.DV+g}else{if(g>0){f[e++]=g}}f.t=e;f.clamp()}function bnpMultiplyTo(c,e){var b=this.abs(),f=c.abs();var d=b.t;e.t=d+f.t;while(--d>=0){e[d]=0}for(d=0;d=0){d[b]=0}for(b=0;b=a.DV){d[b+a.t]-=a.DV;d[b+a.t+1]=1}}if(d.t>0){d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)}d.s=0;d.clamp()}function bnpDivRemTo(n,h,g){var w=n.abs();if(w.t<=0){return}var k=this.abs();if(k.t0){w.lShiftTo(v,d);k.lShiftTo(v,g)}else{w.copyTo(d);k.copyTo(g)}var p=d.t;var b=d[p-1];if(b==0){return}var o=b*(1<1)?d[p-2]>>this.F2:0);var A=this.FV/o,z=(1<=0){g[g.t++]=1;g.subTo(f,g)}BigInteger.ONE.dlShiftTo(p,f);f.subTo(d,d);while(d.t=0){var c=(g[--u]==b)?this.DM:Math.floor(g[u]*A+(g[u-1]+x)*z);if((g[u]+=d.am(0,c,g,s,0,p))0){g.rShiftTo(v,g)}if(a<0){BigInteger.ZERO.subTo(g,g)}}function bnMod(b){var c=nbi();this.abs().divRemTo(b,null,c);if(this.s<0&&c.compareTo(BigInteger.ZERO)>0){b.subTo(c,c)}return c}function Classic(a){this.m=a}function cConvert(a){if(a.s<0||a.compareTo(this.m)>=0){return a.mod(this.m)}else{return a}}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var a=this[0];if((a&1)==0){return 0}var b=a&3;b=(b*(2-(a&15)*b))&15;b=(b*(2-(a&255)*b))&255;b=(b*(2-(((a&65535)*b)&65535)))&65535;b=(b*(2-a*b%this.DV))%this.DV;return(b>0)?this.DV-b:-b}function Montgomery(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(a.DB-15))-1;this.mt2=2*a.t}function montConvert(a){var b=nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);if(a.s<0&&b.compareTo(BigInteger.ZERO)>0){this.m.subTo(b,b)}return b}function montRevert(a){var b=nbi();a.copyTo(b);this.reduce(b);return b}function montReduce(a){while(a.t<=this.mt2){a[a.t++]=0}for(var c=0;c>15)*this.mpl)&this.um)<<15))&a.DM;b=c+this.m.t;a[b]+=this.m.am(0,d,a,c,0,this.m.t);while(a[b]>=a.DV){a[b]-=a.DV;a[++b]++}}a.clamp();a.drShiftTo(this.m.t,a);if(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(h,j){if(h>4294967295||h<1){return BigInteger.ONE}var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;d.copyTo(f);while(--c>=0){j.sqrTo(f,a);if((h&(1<0){j.mulTo(a,d,f)}else{var b=f;f=a;a=b}}return j.revert(f)}function bnModPowInt(b,a){var c;if(b<256||a.isEven()){c=new Classic(a)}else{c=new Montgomery(a)}return this.exp(b,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction bnClone(){var a=nbi();this.copyTo(a);return a}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this[0]}else{if(this.t==0){return 0}}}return((this[1]&((1<<(32-this.DB))-1))<>24}function bnShortValue(){return(this.t==0)?this.s:(this[0]<<16)>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this[0]<=0)){return 0}else{return 1}}}function bnpToRadix(c){if(c==null){c=10}if(this.signum()==0||c<2||c>36){return\"0\"}var f=this.chunkSize(c);var e=Math.pow(c,f);var i=nbv(e),j=nbi(),h=nbi(),g=\"\";this.divRemTo(i,j,h);while(j.signum()>0){g=(e+h.intValue()).toString(c).substr(1)+g;j.divRemTo(i,j,h)}return h.intValue().toString(c)+g}function bnpFromRadix(m,h){this.fromInt(0);if(h==null){h=10}var f=this.chunkSize(h);var g=Math.pow(h,f),e=false,a=0,l=0;for(var c=0;c=f){this.dMultiply(g);this.dAddOffset(l,0);a=0;l=0}}if(a>0){this.dMultiply(Math.pow(h,a));this.dAddOffset(l,0)}if(e){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(f,e,h){if(\"number\"==typeof e){if(f<2){this.fromInt(1)}else{this.fromNumber(f,h);if(!this.testBit(f-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(f-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(e)){this.dAddOffset(2,0);if(this.bitLength()>f){this.subTo(BigInteger.ONE.shiftLeft(f-1),this)}}}}else{var d=new Array(),g=f&7;d.length=(f>>3)+1;e.nextBytes(d);if(g>0){d[0]&=((1<0){if(e>e)!=(this.s&this.DM)>>e){c[a++]=f|(this.s<<(this.DB-e))}while(b>=0){if(e<8){f=(this[b]&((1<>(e+=this.DB-8)}else{f=(this[b]>>(e-=8))&255;if(e<=0){e+=this.DB;--b}}if((f&128)!=0){f|=-256}if(a==0&&(this.s&128)!=(f&128)){++a}if(a>0||f!=this.s){c[a++]=f}}}return c}function bnEquals(b){return(this.compareTo(b)==0)}function bnMin(b){return(this.compareTo(b)<0)?this:b}function bnMax(b){return(this.compareTo(b)>0)?this:b}function bnpBitwiseTo(c,h,e){var d,g,b=Math.min(c.t,this.t);for(d=0;d>=16;b+=16}if((a&255)==0){a>>=8;b+=8}if((a&15)==0){a>>=4;b+=4}if((a&3)==0){a>>=2;b+=2}if((a&1)==0){++b}return b}function bnGetLowestSetBit(){for(var a=0;a=this.t){return(this.s!=0)}return((this[a]&(1<<(b%this.DB)))!=0)}function bnpChangeBit(c,b){var a=BigInteger.ONE.shiftLeft(c);this.bitwiseTo(a,b,a);return a}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(d,f){var e=0,g=0,b=Math.min(d.t,this.t);while(e>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g+=d.s}f.s=(g<0)?-1:0;if(g>0){f[e++]=g}else{if(g<-1){f[e++]=this.DV+g}}f.t=e;f.clamp()}function bnAdd(b){var c=nbi();this.addTo(b,c);return c}function bnSubtract(b){var c=nbi();this.subTo(b,c);return c}function bnMultiply(b){var c=nbi();this.multiplyTo(b,c);return c}function bnSquare(){var a=nbi();this.squareTo(a);return a}function bnDivide(b){var c=nbi();this.divRemTo(b,c,null);return c}function bnRemainder(b){var c=nbi();this.divRemTo(b,null,c);return c}function bnDivideAndRemainder(b){var d=nbi(),c=nbi();this.divRemTo(b,d,c);return new Array(d,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(b,a){if(b==0){return}while(this.t<=a){this[this.t++]=0}this[a]+=b;while(this[a]>=this.DV){this[a]-=this.DV;if(++a>=this.t){this[this.t++]=0}++this[a]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,c,b){a.multiplyTo(c,b)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp())}function bnpMultiplyLowerTo(b,f,e){var d=Math.min(this.t+b.t,f);e.s=0;e.t=d;while(d>0){e[--d]=0}var c;for(c=e.t-this.t;d=0){d[c]=0}for(c=Math.max(e-this.t,0);c2*this.m.t){return a.mod(this.m)}else{if(a.compareTo(this.m)<0){return a}else{var b=nbi();a.copyTo(b);this.reduce(b);return b}}}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1){a.t=this.m.t+1;a.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0){a.dAddOffset(1,this.m.t+1)}a.subTo(this.r2,a);while(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(q,f){var o=q.bitLength(),h,b=nbv(1),v;if(o<=0){return b}else{if(o<18){h=1}else{if(o<48){h=3}else{if(o<144){h=4}else{if(o<768){h=5}else{h=6}}}}}if(o<8){v=new Classic(f)}else{if(f.isEven()){v=new Barrett(f)}else{v=new Montgomery(f)}}var p=new Array(),d=3,s=h-1,a=(1<1){var A=nbi();v.sqrTo(p[1],A);while(d<=a){p[d]=nbi();v.mulTo(A,p[d-2],p[d]);d+=2}}var l=q.t-1,x,u=true,c=nbi(),y;o=nbits(q[l])-1;while(l>=0){if(o>=s){x=(q[l]>>(o-s))&a}else{x=(q[l]&((1<<(o+1))-1))<<(s-o);if(l>0){x|=q[l-1]>>(this.DB+o-s)}}d=h;while((x&1)==0){x>>=1;--d}if((o-=d)<0){o+=this.DB;--l}if(u){p[x].copyTo(b);u=false}else{while(d>1){v.sqrTo(b,c);v.sqrTo(c,b);d-=2}if(d>0){v.sqrTo(b,c)}else{y=b;b=c;c=y}v.mulTo(c,p[x],b)}while(l>=0&&(q[l]&(1<0){b.rShiftTo(f,b);h.rShiftTo(f,h)}while(b.signum()>0){if((d=b.getLowestSetBit())>0){b.rShiftTo(d,b)}if((d=h.getLowestSetBit())>0){h.rShiftTo(d,h)}if(b.compareTo(h)>=0){b.subTo(h,b);b.rShiftTo(1,b)}else{h.subTo(b,h);h.rShiftTo(1,h)}}if(f>0){h.lShiftTo(f,h)}return h}function bnpModInt(e){if(e<=0){return 0}var c=this.DV%e,b=(this.s<0)?e-1:0;if(this.t>0){if(c==0){b=this[0]%e}else{for(var a=this.t-1;a>=0;--a){b=(c*b+this[a])%e}}}return b}function bnModInverse(f){var j=f.isEven();if((this.isEven()&&j)||f.signum()==0){return BigInteger.ZERO}var i=f.clone(),h=this.clone();var g=nbv(1),e=nbv(0),l=nbv(0),k=nbv(1);while(i.signum()!=0){while(i.isEven()){i.rShiftTo(1,i);if(j){if(!g.isEven()||!e.isEven()){g.addTo(this,g);e.subTo(f,e)}g.rShiftTo(1,g)}else{if(!e.isEven()){e.subTo(f,e)}}e.rShiftTo(1,e)}while(h.isEven()){h.rShiftTo(1,h);if(j){if(!l.isEven()||!k.isEven()){l.addTo(this,l);k.subTo(f,k)}l.rShiftTo(1,l)}else{if(!k.isEven()){k.subTo(f,k)}}k.rShiftTo(1,k)}if(i.compareTo(h)>=0){i.subTo(h,i);if(j){g.subTo(l,g)}e.subTo(k,e)}else{h.subTo(i,h);if(j){l.subTo(g,l)}k.subTo(e,k)}}if(h.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(k.compareTo(f)>=0){return k.subtract(f)}if(k.signum()<0){k.addTo(f,k)}else{return k}if(k.signum()<0){return k.add(f)}else{return k}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(e){var d,b=this.abs();if(b.t==1&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d>1;if(f>lowprimes.length){f=lowprimes.length}var b=nbi();for(var e=0;e>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(window!==undefined&&(window.crypto!==undefined||window.msCrypto!==undefined)){var crypto=window.crypto||window.msCrypto;if(crypto.getRandomValues){var ua=new Uint8Array(32);crypto.getRandomValues(ua);for(t=0;t<32;++t){rng_pool[rng_pptr++]=ua[t]}}else{if(navigator.appName==\"Netscape\"&&navigator.appVersion<\"5\"){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr=0&&h>0){var f=e.charCodeAt(d--);if(f<128){g[--h]=f}else{if((f>127)&&(f<2048)){g[--h]=(f&63)|128;g[--h]=(f>>6)|192}else{g[--h]=(f&63)|128;g[--h]=((f>>6)&63)|128;g[--h]=(f>>12)|224}}}g[--h]=0;var b=new SecureRandom();var a=new Array();while(h>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}g[--h]=a[0]}g[--h]=2;g[--h]=0;return new BigInteger(g)}function oaep_mgf1_arr(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255])));d+=1}return b}function oaep_pad(q,a,f,l){var c=KJUR.crypto.MessageDigest;var o=KJUR.crypto.Util;var b=null;if(!f){f=\"sha1\"}if(typeof f===\"string\"){b=c.getCanonicalAlgName(f);l=c.getHashLength(b);f=function(i){return hextorstr(o.hashHex(rstrtohex(i),b))}}if(q.length+2*l+2>a){throw\"Message too long for RSA\"}var k=\"\",e;for(e=0;e0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{throw\"Invalid RSA public key\"}}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var e=this.doPublic(a);if(e==null){return null}var b=e.toString(16);if((b.length&1)==0){return b}else{return\"0\"+b}}function RSAEncryptOAEP(f,e,b){var a=oaep_pad(f,(this.n.bitLength()+7)>>3,e,b);if(a==null){return null}var g=this.doPublic(a);if(g==null){return null}var d=g.toString(16);if((d.length&1)==0){return d}else{return\"0\"+d}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;RSAKey.prototype.encryptOAEP=RSAEncryptOAEP;RSAKey.prototype.type=\"RSA\";\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction pkcs1unpad2(g,j){var a=g.toByteArray();var f=0;while(f=a.length){return null}}var e=\"\";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}function oaep_unpad(o,b,g,p){var e=KJUR.crypto.MessageDigest;var r=KJUR.crypto.Util;var c=null;if(!g){g=\"sha1\"}if(typeof g===\"string\"){c=e.getCanonicalAlgName(g);p=e.getHashLength(c);g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}}o=o.toByteArray();var h;for(h=0;h0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{throw\"Invalid RSA private key\"}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;this.isPublic=false;if(g==null){throw\"RSASetPrivateEx N == null\"}if(d==null){throw\"RSASetPrivateEx E == null\"}if(g.length==0){throw\"RSASetPrivateEx N.length == 0\"}if(d.length==0){throw\"RSASetPrivateEx E.length == 0\"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{throw\"Invalid RSA private key in RSASetPrivateEx\"}}function RSAGenerate(b,i){var a=new SecureRandom();var f=b>>1;this.e=parseInt(i,16);var c=new BigInteger(i,16);for(;;){for(;;){this.p=new BigInteger(b-f,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(f,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var h=this.p;this.p=this.q;this.q=h}var g=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var e=g.multiply(d);if(e.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(e);this.dmp1=this.d.mod(g);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=true}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}function RSADecryptOAEP(e,d,b){var f=parseBigInt(e,16);var a=this.doPrivate(f);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,d,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP;\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction ECFieldElementFp(b,a){this.x=a;this.q=b}function feFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.x.equals(a.x))}function feFpToBigInteger(){return this.x}function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))}function feFpAdd(a){return new ECFieldElementFp(this.q,this.x.add(a.toBigInteger()).mod(this.q))}function feFpSubtract(a){return new ECFieldElementFp(this.q,this.x.subtract(a.toBigInteger()).mod(this.q))}function feFpMultiply(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger()).mod(this.q))}function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))}function feFpDivide(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger().modInverse(this.q)).mod(this.q))}ECFieldElementFp.prototype.equals=feFpEquals;ECFieldElementFp.prototype.toBigInteger=feFpToBigInteger;ECFieldElementFp.prototype.negate=feFpNegate;ECFieldElementFp.prototype.add=feFpAdd;ECFieldElementFp.prototype.subtract=feFpSubtract;ECFieldElementFp.prototype.multiply=feFpMultiply;ECFieldElementFp.prototype.square=feFpSquare;ECFieldElementFp.prototype.divide=feFpDivide;function ECPointFp(c,a,d,b){this.curve=c;this.x=a;this.y=d;if(b==null){this.z=BigInteger.ONE}else{this.z=b}this.zinv=null}function pointFpGetX(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpGetY(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpEquals(a){if(a==this){return true}if(this.isInfinity()){return a.isInfinity()}if(a.isInfinity()){return this.isInfinity()}var c,b;c=a.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(a.z)).mod(this.curve.q);if(!c.equals(BigInteger.ZERO)){return false}b=a.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(a.z)).mod(this.curve.q);return b.equals(BigInteger.ZERO)}function pointFpIsInfinity(){if((this.x==null)&&(this.y==null)){return true}return this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)}function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)}function pointFpAdd(l){if(this.isInfinity()){return l}if(l.isInfinity()){return this}var p=l.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(l.z)).mod(this.curve.q);var o=l.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(l.z)).mod(this.curve.q);if(BigInteger.ZERO.equals(o)){if(BigInteger.ZERO.equals(p)){return this.twice()}return this.curve.getInfinity()}var j=new BigInteger(\"3\");var e=this.x.toBigInteger();var n=this.y.toBigInteger();var c=l.x.toBigInteger();var k=l.y.toBigInteger();var m=o.square();var i=m.multiply(o);var d=e.multiply(m);var g=p.square().multiply(this.z);var a=g.subtract(d.shiftLeft(1)).multiply(l.z).subtract(i).multiply(o).mod(this.curve.q);var h=d.multiply(j).multiply(p).subtract(n.multiply(i)).subtract(g.multiply(p)).multiply(l.z).add(p.multiply(i)).mod(this.curve.q);var f=i.multiply(this.z).multiply(l.z).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),f)}function pointFpTwice(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var g=new BigInteger(\"3\");var c=this.x.toBigInteger();var h=this.y.toBigInteger();var e=h.multiply(this.z);var j=e.multiply(h).mod(this.curve.q);var i=this.curve.a.toBigInteger();var k=c.square().multiply(g);if(!BigInteger.ZERO.equals(i)){k=k.add(this.z.square().multiply(i))}k=k.mod(this.curve.q);var b=k.square().subtract(c.shiftLeft(3).multiply(j)).shiftLeft(1).multiply(e).mod(this.curve.q);var f=k.multiply(g).multiply(c).subtract(j.shiftLeft(1)).shiftLeft(2).multiply(j).subtract(k.square().multiply(k)).mod(this.curve.q);var d=e.square().multiply(e).shiftLeft(3).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(b),this.curve.fromBigInteger(f),d)}function pointFpMultiply(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add(a?this:l)}}return d}function pointFpMultiplyTwo(c,a,b){var d;if(c.bitLength()>b.bitLength()){d=c.bitLength()-1}else{d=b.bitLength()-1}var f=this.curve.getInfinity();var e=this.add(a);while(d>=0){f=f.twice();if(c.testBit(d)){if(b.testBit(d)){f=f.add(e)}else{f=f.add(this)}}else{if(b.testBit(d)){f=f.add(a)}}--d}return f}ECPointFp.prototype.getX=pointFpGetX;ECPointFp.prototype.getY=pointFpGetY;ECPointFp.prototype.equals=pointFpEquals;ECPointFp.prototype.isInfinity=pointFpIsInfinity;ECPointFp.prototype.negate=pointFpNegate;ECPointFp.prototype.add=pointFpAdd;ECPointFp.prototype.twice=pointFpTwice;ECPointFp.prototype.multiply=pointFpMultiply;ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo;function ECCurveFp(e,d,c){this.q=e;this.a=this.fromBigInteger(d);this.b=this.fromBigInteger(c);this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b))}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)}function curveFpDecodePointHex(d){switch(parseInt(d.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var a=(d.length-2)/2;var c=d.substr(2,a);var b=d.substr(a+2,a);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(b,16)));default:return null}}ECCurveFp.prototype.getQ=curveFpGetQ;ECCurveFp.prototype.getA=curveFpGetA;ECCurveFp.prototype.getB=curveFpGetB;ECCurveFp.prototype.equals=curveFpEquals;ECCurveFp.prototype.getInfinity=curveFpGetInfinity;ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger;ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex;\n/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib\n */\nECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};ECPointFp.prototype.getEncoded=function(c){var d=function(h,f){var g=h.toByteArrayUnsigned();if(fg.length){g.unshift(0)}}return g};var a=this.getX().toBigInteger();var e=this.getY().toBigInteger();var b=d(a,32);if(c){if(e.isEven()){b.unshift(2)}else{b.unshift(3)}}else{b.unshift(4);b=b.concat(d(e,32))}return b};ECPointFp.decodeFrom=function(g,c){var f=c[0];var e=c.length-1;var d=c.slice(1,1+e/2);var b=c.slice(1+e/2,1+e);d.unshift(0);b.unshift(0);var a=new BigInteger(d);var h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.decodeFromHex=function(g,c){var f=c.substr(0,2);var e=c.length-2;var d=c.substr(2,e/2);var b=c.substr(2+e/2,e/2);var a=new BigInteger(d,16);var h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.prototype.add2D=function(c){if(this.isInfinity()){return c}if(c.isInfinity()){return this}if(this.x.equals(c.x)){if(this.y.equals(c.y)){return this.twice()}return this.curve.getInfinity()}var g=c.x.subtract(this.x);var e=c.y.subtract(this.y);var a=e.divide(g);var d=a.square().subtract(this.x).subtract(c.x);var f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var b=this.curve.fromBigInteger(BigInteger.valueOf(2));var e=this.curve.fromBigInteger(BigInteger.valueOf(3));var a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b));var c=a.square().subtract(this.x.multiply(b));var d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)};ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add2D(a?this:l)}}return d};ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger();var i=this.getY().toBigInteger();var f=this.curve.getA().toBigInteger();var c=this.curve.getB().toBigInteger();var h=this.curve.getQ();var e=i.multiply(i).mod(h);var g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)};ECPointFp.prototype.toString=function(){return\"(\"+this.getX().toBigInteger().toString()+\",\"+this.getY().toBigInteger().toString()+\")\"};ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity()){throw new Error(\"Point is at infinity.\")}var a=this.getX().toBigInteger();var b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"x coordinate out of bounds\")}if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"y coordinate out of bounds\")}if(!this.isOnCurve()){throw new Error(\"Point is not on the curve.\")}if(this.multiply(c).isInfinity()){throw new Error(\"Point is not a scalar multiple of G.\")}return true};\n/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval\n */\nvar jsonParse=(function(){var e=\"(?:-?\\\\b(?:0|[1-9][0-9]*)(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\\\b)\";var j='(?:[^\\\\0-\\\\x08\\\\x0a-\\\\x1f\"\\\\\\\\]|\\\\\\\\(?:[\"/\\\\\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:\"'+j+'*\")';var d=new RegExp(\"(?:false|true|null|[\\\\{\\\\}\\\\[\\\\]]|\"+e+\"|\"+i+\")\",\"g\");var k=new RegExp(\"\\\\\\\\(?:([^u])|u(.{4}))\",\"g\");var g={'\"':'\"',\"/\":\"/\",\"\\\\\":\"\\\\\",b:\"\\b\",f:\"\\f\",n:\"\\n\",r:\"\\r\",t:\"\\t\"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String(\"\");var a=\"\\\\\";var f={\"{\":Object,\"[\":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if(\"{\"===v){x={}}else{if(\"[\"===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({\"\":x},\"\")}return x}})();\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.asn1==\"undefined\"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b=\"0\"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!=\"-\"){if(f.length%2==1){f=\"0\"+f}else{if(!f.match(/^[0-7]/)){f=\"00\"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g=\"\";for(var d=0;d15){throw\"ASN.1 length too long to represent by 8x: n = \"+i.toString(16)}var f=128+g;return f.toString(16)+h}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return\"\"}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!=\"undefined\"){if(typeof c==\"string\"){this.setString(c)}else{if(typeof c.str!=\"undefined\"){this.setString(c.str)}else{if(typeof c.hex!=\"undefined\"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(f){utc=f.getTime()+(f.getTimezoneOffset()*60000);var e=new Date(utc);return e};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o==\"utc\"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,\"\");r=r+\".\"+k}}return r+\"Z\"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join(\"0\")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!=\"undefined\"){if(typeof b.array!=\"undefined\"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT=\"01\";this.hTLV=\"0101ff\"};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT=\"02\";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!=\"undefined\"){if(typeof a.bigint!=\"undefined\"){this.setByBigInteger(a.bigint)}else{if(typeof a[\"int\"]!=\"undefined\"){this.setByInteger(a[\"int\"])}else{if(typeof a==\"number\"){this.setByInteger(a)}else{if(typeof a.hex!=\"undefined\"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!==\"undefined\"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex=\"00\"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT=\"03\";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=(l*2))){break}if(d>=200){break}g.push(b);c=b;d++}return g};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){throw\"checking tag doesn't match: \"+e.substr(d,2)+\"!=\"+i}}return d}f=c.shift();b=g.getChildIdx(e,d);return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getTLVbyList=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyList(d,c,b);if(a===undefined){throw\"can't find nthList object\"}if(f!==undefined){if(d.substr(a,2)!=f){throw\"checking tag doesn't match: \"+d.substr(a,2)+\"!=\"+f}}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a===undefined){throw\"can't find nthList object\"}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join(\"0\")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+\".\"+j.join(\".\")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+\"..(total \"+A.length/2+\"bytes)..\"+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=\"\"}var x=c.ommit_long_octet;if(e.substr(l,2)==\"01\"){var h=j(e,l);if(h==\"00\"){return g+\"BOOLEAN FALSE\\n\"}else{return g+\"BOOLEAN TRUE\\n\"}}if(e.substr(l,2)==\"02\"){var h=j(e,l);return g+\"INTEGER \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"03\"){var h=j(e,l);return g+\"BITSTRING \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"04\"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+\"OCTETSTRING, encapsulates\\n\";k=k+y(h,c,0,g+\" \");return k}else{return g+\"OCTETSTRING \"+q(h,x)+\"\\n\"}}if(e.substr(l,2)==\"05\"){return g+\"NULL\\n\"}if(e.substr(l,2)==\"06\"){var m=j(e,l);var a=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(a);var b=a.replace(/\\./g,\" \");if(o!=\"\"){return g+\"ObjectIdentifier \"+o+\" (\"+b+\")\\n\"}else{return g+\"ObjectIdentifier (\"+b+\")\\n\"}}if(e.substr(l,2)==\"0c\"){return g+\"UTF8String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"13\"){return g+\"PrintableString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"14\"){return g+\"TeletexString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"16\"){return g+\"IA5String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"17\"){return g+\"UTCTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"18\"){return g+\"GeneralizedTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"30\"){if(e.substr(l,4)==\"3000\"){return g+\"SEQUENCE {}\\n\"}var k=g+\"SEQUENCE\\n\";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)==\"06\"&&e.substr(d[d.length-1],2)==\"04\"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u0){var m=new f({array:this.extensionsArray});var k=new c({explicit:true,tag:\"a3\",obj:m});this.asn1Array.push(k)}var n=new f({array:this.asn1Array});this.hTLV=n.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension=function(d){KJUR.asn1.x509.Extension.superclass.constructor.call(this);var f=null,a=KJUR,e=a.asn1,h=e.DERObjectIdentifier,i=e.DEROctetString,b=e.DERBitString,g=e.DERBoolean,c=e.DERSequence;this.getEncodedHex=function(){var m=new h({oid:this.oid});var l=new i({hex:this.getExtnValueHex()});var k=new Array();k.push(m);if(this.critical){k.push(new g())}k.push(l);var j=new c({array:k});return j.getEncodedHex()};this.critical=false;if(d!==undefined){if(d.critical!==undefined){this.critical=d.critical}}};YAHOO.lang.extend(KJUR.asn1.x509.Extension,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension.appendByNameToArray=function(e,c,b){var g=e.toLowerCase(),f=KJUR.asn1.x509;if(g==\"basicconstraints\"){var d=new f.BasicConstraints(c);b.push(d)}else{if(g==\"keyusage\"){var d=new f.KeyUsage(c);b.push(d)}else{if(g==\"crldistributionpoints\"){var d=new f.CRLDistributionPoints(c);b.push(d)}else{if(g==\"extkeyusage\"){var d=new f.ExtKeyUsage(c);b.push(d)}else{if(g==\"authoritykeyidentifier\"){var d=new f.AuthorityKeyIdentifier(c);b.push(d)}else{if(g==\"authorityinfoaccess\"){var d=new f.AuthorityInfoAccess(c);b.push(d)}else{if(g==\"subjectaltname\"){var d=new f.SubjectAltName(c);b.push(d)}else{if(g==\"issueraltname\"){var d=new f.IssuerAltName(c);b.push(d)}else{throw\"unsupported extension name: \"+e}}}}}}}}};KJUR.asn1.x509.KeyUsage=function(f){KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this,f);var a=X509.KEYUSAGE_NAME;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.15\";if(f!==undefined){if(f.bin!==undefined){this.asn1ExtnValue=new KJUR.asn1.DERBitString(f)}if(f.names!==undefined&&f.names.length!==undefined){var e=f.names;var d=\"000000000\";for(var c=0;c-1){e.push(new KJUR.asn1.DERInteger({\"int\":this.pathLen}))}var d=new KJUR.asn1.DERSequence({array:e});this.asn1ExtnValue=d;return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.19\";this.cA=false;this.pathLen=-1;if(c!==undefined){if(c.cA!==undefined){this.cA=c.cA}if(c.pathLen!==undefined){this.pathLen=c.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){this.asn1ExtnValue=new a.DERSequence({array:e})};this.setByOneURI=function(h){var e=new c.GeneralNames([{uri:h}]);var g=new c.DistributionPointName(e);var f=new c.DistributionPoint({dpobj:g});this.setByDPArray([f])};this.oid=\"2.5.29.31\";if(d!==undefined){if(d.array!==undefined){this.setByDPArray(d.array)}else{if(d.uri!==undefined){this.setByOneURI(d.uri)}}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLDistributionPoints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.ExtKeyUsage=function(c){KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,c);var b=KJUR,a=b.asn1;this.setPurposeArray=function(d){this.asn1ExtnValue=new a.DERSequence();for(var e=0;e0){var h=new b({array:this.aRevokedCert});this.asn1Array.push(h)}var i=new b({array:this.asn1Array});this.hTLV=i.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize=function(){this.asn1Version=null;this.asn1SignatureAlg=null;this.asn1Issuer=null;this.asn1ThisUpdate=null;this.asn1NextUpdate=null;this.aRevokedCert=new Array()};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertList,KJUR.asn1.ASN1Object);KJUR.asn1.x509.CRLEntry=function(e){KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);var d=null,c=null,b=KJUR,a=b.asn1;this.setCertSerial=function(f){this.sn=new a.DERInteger(f)};this.setRevocationDate=function(f){this.time=new a.x509.Time(f)};this.getEncodedHex=function(){var f=new a.DERSequence({array:[this.sn,this.time]});this.TLV=f.getEncodedHex();return this.TLV};if(e!==undefined){if(e.time!==undefined){this.setRevocationDate(e.time)}if(e.sn!==undefined){this.setCertSerial(e.sn)}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLEntry,KJUR.asn1.ASN1Object);KJUR.asn1.x509.X500Name=function(f){KJUR.asn1.x509.X500Name.superclass.constructor.call(this);this.asn1Array=new Array();var d=KJUR,c=d.asn1,e=c.x509,b=pemtohex;this.setByString=function(g){var k=g.split(\"/\");k.shift();var j=[];for(var l=0;l0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+\",\"+h).replace(/\\\\,/g,\",\");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)===\"\\\\\"){e=true}}b=b.map(function(a){return a.replace(\"/\",\"\\\\/\")});b.reverse();return\"/\"+b.join(\"/\")};KJUR.asn1.x509.RDN=function(a){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=new Array();this.addByString=function(b){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:b}))};this.addByMultiValuedString=function(d){var b=KJUR.asn1.x509.RDN.parseString(d);for(var c=0;c0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+\"+\"+k).replace(/\\\\\\+/g,\"+\");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)===\"\\\\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/\"$/)){var d=(e+\"+\"+k).replace(/^([^=]+)=\"(.*)\"$/,\"$1=$2\");b.push(d);l=false}else{b.push(e+\"+\"+k)}}else{b.push(k)}if(k.match(/^[^=]+=\"/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(d){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var f=null,e=null,a=\"utf8\",c=KJUR,b=c.asn1;this.setByString=function(h){var g=h.match(/^([^=]+)=(.+)$/);if(g){this.setByAttrTypeAndValueStr(g[1],g[2])}else{throw\"malformed attrTypeAndValueStr: \"+h}};this.setByAttrTypeAndValueStr=function(i,h){this.typeObj=KJUR.asn1.x509.OID.atype2obj(i);var g=a;if(i==\"C\"){g=\"prn\"}this.valueObj=this.getValueObj(g,h)};this.getValueObj=function(h,g){if(h==\"utf8\"){return new b.DERUTF8String({str:g})}if(h==\"prn\"){return new b.DERPrintableString({str:g})}if(h==\"tel\"){return new b.DERTeletexString({str:g})}if(h==\"ia5\"){return new b.DERIA5String({str:g})}throw\"unsupported directory string type: type=\"+h+\" value=\"+g};this.getEncodedHex=function(){var g=new b.DERSequence({array:[this.typeObj,this.valueObj]});this.TLV=g.getEncodedHex();return this.TLV};if(d!==undefined){if(d.str!==undefined){this.setByString(d.str)}}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw\"algId and/or subjPubKey not set\"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{\"int\":{bigint:q.n}},{\"int\":{\"int\":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:\"rsaEncryption\"});this.asn1SubjPKey=new b({hex:\"00\"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:\"ecPublicKey\",asn1params:r});this.asn1SubjPKey=new b({hex:\"00\"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{\"int\":{bigint:q.p}},{\"int\":{bigint:q.q}},{\"int\":{bigint:q.g}}]});this.asn1AlgId=new o({name:\"dsa\",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:\"00\"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type==\"utc\"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type==\"utc\"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type=\"utc\";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type=\"utc\"}if(f.str.match(/^[0-9]{14}Z$/)){this.type=\"gen\"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(d){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw\"algorithm not specified\"}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var e=[this.asn1Alg];if(this.asn1Params!==null){e.push(this.asn1Params)}var f=new a.DERSequence({array:e});this.hTLV=f.getEncodedHex();return this.hTLV};if(d!==undefined){if(d.name!==undefined){this.nameAlg=d.name}if(d.asn1params!==undefined){this.asn1Params=d.asn1params}if(d.paramempty!==undefined){this.paramEmpty=d.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){var c=this.nameAlg.toLowerCase();if(c.substr(-7,7)!==\"withdsa\"&&c.substr(-9,9)!==\"withecdsa\"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:\"81\",dns:\"82\",dn:\"a4\",uri:\"86\",ip:\"87\"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type=\"rfc822\";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type=\"dns\";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type=\"uri\";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({str:p.dn})}if(p.ldapdn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certissuer param not cert\"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certsubj param not cert\"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type=\"ip\";this.explicit=false;var q=p.ip;var s;var n=\"malformed IP address\";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex(\"[\"+q.split(\".\").join(\",\")+\"]\");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw\"unsupported type in params=\"+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){r=new b({obj:this.dUnsignedAttrs,tag:\"a1\",explicit:false})}var q=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,o,this.dSigAlg,this.dSig,];if(r!=null){q.push(r)}var p=new h.DERSequence({array:q});this.hTLV=p.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.SignerInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.EncapsulatedContentInfo=function(g){var c=KJUR,b=c.asn1,e=b.DERTaggedObject,a=b.DERSequence,h=b.DERObjectIdentifier,d=b.DEROctetString,f=b.cms;f.EncapsulatedContentInfo.superclass.constructor.call(this);this.dEContentType=new h({name:\"data\"});this.dEContent=null;this.isDetached=false;this.eContentValueHex=null;this.setContentType=function(i){if(i.match(/^[0-2][.][0-9.]+$/)){this.dEContentType=new h({oid:i})}else{this.dEContentType=new h({name:i})}};this.setContentValue=function(i){if(i!==undefined){if(typeof i.hex==\"string\"){this.eContentValueHex=i.hex}else{if(typeof i.str==\"string\"){this.eContentValueHex=utf8tohex(i.str)}}}};this.setContentValueHex=function(i){this.eContentValueHex=i};this.setContentValueStr=function(i){this.eContentValueHex=utf8tohex(i)};this.getEncodedHex=function(){if(typeof this.eContentValueHex!=\"string\"){throw\"eContentValue not yet set\"}var k=new d({hex:this.eContentValueHex});this.dEContent=new e({obj:k,tag:\"a0\",explicit:true});var i=[this.dEContentType];if(!this.isDetached){i.push(this.dEContent)}var j=new a({array:i});this.hTLV=j.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.EncapsulatedContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.ContentInfo=function(f){var c=KJUR,b=c.asn1,d=b.DERTaggedObject,a=b.DERSequence,e=b.x509;KJUR.asn1.cms.ContentInfo.superclass.constructor.call(this);this.dContentType=null;this.dContent=null;this.setContentType=function(g){if(typeof g==\"string\"){this.dContentType=e.OID.name2obj(g)}};this.getEncodedHex=function(){var h=new d({obj:this.dContent,tag:\"a0\",explicit:true});var g=new a({array:[this.dContentType,h]});this.hTLV=g.getEncodedHex();return this.hTLV};if(f!==undefined){if(f.type){this.setContentType(f.type)}if(f.obj&&f.obj instanceof b.ASN1Object){this.dContent=f.obj}}};YAHOO.lang.extend(KJUR.asn1.cms.ContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.SignedData=function(e){var a=KJUR,h=a.asn1,j=h.ASN1Object,g=h.DERInteger,m=h.DERSet,f=h.DERSequence,b=h.DERTaggedObject,l=h.cms,i=l.EncapsulatedContentInfo,d=l.SignerInfo,n=l.ContentInfo,c=h.x509,k=c.AlgorithmIdentifier;KJUR.asn1.cms.SignedData.superclass.constructor.call(this);this.dCMSVersion=new g({\"int\":1});this.dDigestAlgs=null;this.digestAlgNameList=[];this.dEncapContentInfo=new i();this.dCerts=null;this.certificateList=[];this.crlList=[];this.signerInfoList=[new d()];this.addCertificatesByPEM=function(p){var q=pemtohex(p);var r=new j();r.hTLV=q;this.certificateList.push(r)};this.getEncodedHex=function(){if(typeof this.hTLV==\"string\"){return this.hTLV}if(this.dDigestAlgs==null){var u=[];for(var t=0;t0){var v=new m({array:this.certificateList});this.dCerts=new b({obj:v,tag:\"a0\",explicit:false})}}if(this.dCerts!=null){p.push(this.dCerts)}var r=new m({array:this.signerInfoList});p.push(r);var q=new f({array:p});this.hTLV=q.getEncodedHex();return this.hTLV};this.getContentInfo=function(){this.getEncodedHex();var o=new n({type:\"signed-data\",obj:this});return o};this.getContentInfoEncodedHex=function(){var o=this.getContentInfo();var p=o.getEncodedHex();return p};this.getPEM=function(){return hextopem(this.getContentInfoEncodedHex(),\"CMS\")}};YAHOO.lang.extend(KJUR.asn1.cms.SignedData,KJUR.asn1.ASN1Object);KJUR.asn1.cms.CMSUtil=new function(){};KJUR.asn1.cms.CMSUtil.newSignedData=function(d){var b=KJUR,j=b.asn1,q=j.cms,f=q.SignerInfo,n=q.SignedData,o=q.SigningTime,a=q.SigningCertificate,p=q.SigningCertificateV2,c=j.cades,e=c.SignaturePolicyIdentifier;var m=new n();m.dEncapContentInfo.setContentValue(d.content);if(typeof d.certs==\"object\"){for(var h=0;h0){var s=new f({array:this.extensionsArray});var r=new m({array:[s]});var q=new f({array:[new k({oid:\"1.2.840.113549.1.9.14\"}),r]});var p=new c({explicit:true,tag:\"a0\",obj:q});this.asn1Array.push(p)}else{var p=new c({explicit:false,tag:\"a0\",obj:new j()});this.asn1Array.push(p)}var t=new f({array:this.asn1Array});this.hTLV=t.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CSRUtil=new function(){};KJUR.asn1.csr.CSRUtil.newCSRPEM=function(h){var c=KEYUTIL,b=KJUR.asn1.csr;if(h.subject===undefined){throw\"parameter subject undefined\"}if(h.sbjpubkey===undefined){throw\"parameter sbjpubkey undefined\"}if(h.sigalg===undefined){throw\"parameter sigalg undefined\"}if(h.sbjprvkey===undefined){throw\"parameter sbjpubkey undefined\"}var d=new b.CertificationRequestInfo();d.setSubjectByParam(h.subject);d.setSubjectPublicKeyByGetKey(h.sbjpubkey);if(h.ext!==undefined&&h.ext.length!==undefined){for(var e=0;ef.length){f=c[d]}}e=e.replace(f,\"::\");return e.slice(1,-1)}function hextoip(b){var d=\"malformed hex value\";if(!b.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){throw d}if(b.length==8){var c;try{c=parseInt(b.substr(0,2),16)+\".\"+parseInt(b.substr(2,2),16)+\".\"+parseInt(b.substr(4,2),16)+\".\"+parseInt(b.substr(6,2),16);return c}catch(a){throw d}}else{if(b.length==32){return hextoipv6(b)}else{return b}}}function iptohex(f){var j=\"malformed IP address\";f=f.toLowerCase(f);if(f.match(/^[0-9.]+$/)){var b=f.split(\".\");if(b.length!==4){throw j}var g=\"\";try{for(var e=0;e<4;e++){var h=parseInt(b[e]);g+=(\"0\"+h.toString(16)).slice(-2)}return g}catch(c){throw j}}else{if(f.match(/^[0-9a-f:]+$/)&&f.indexOf(\":\")!==-1){return ipv6tohex(f)}else{throw j}}}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b=\"\";for(var c=0;c\"7\"){return\"00\"+a}return a}function intarystrtohex(b){b=b.replace(/^\\s*\\[\\s*/,\"\");b=b.replace(/\\s*\\]\\s*$/,\"\");b=b.replace(/\\s*/g,\"\");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;bd){throw\"key is too short for SigAlg: keylen=\"+j+\",\"+a}var b=\"0001\";var k=\"00\"+c;var g=\"\";var l=d-b.length-k.length;for(var f=0;f=0;--p){q=q.twice2D();q.z=BigInteger.ONE;if(o.testBit(p)){if(n.testBit(p)){q=q.add2D(t)}else{q=q.add2D(s)}}else{if(n.testBit(p)){q=q.add2D(r)}}}return q}this.getBigRandom=function(i){return new BigInteger(i.bitLength(),a).mod(i.subtract(BigInteger.ONE)).add(BigInteger.ONE)};this.setNamedCurve=function(i){this.ecparams=KJUR.crypto.ECParameterDB.getByName(i);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=i};this.setPrivateKeyHex=function(i){this.isPrivate=true;this.prvKeyHex=i};this.setPublicKeyHex=function(i){this.isPublic=true;this.pubKeyHex=i};this.getPublicKeyXYHex=function(){var k=this.pubKeyHex;if(k.substr(0,2)!==\"04\"){throw\"this method supports uncompressed format(04) only\"}var j=this.ecparams.keylen/4;if(k.length!==2+j*2){throw\"malformed public key hex length\"}var i={};i.x=k.substr(2,j);i.y=k.substr(2+j);return i};this.getShortNISTPCurveName=function(){var i=this.curveName;if(i===\"secp256r1\"||i===\"NIST P-256\"||i===\"P-256\"||i===\"prime256v1\"){return\"P-256\"}if(i===\"secp384r1\"||i===\"NIST P-384\"||i===\"P-384\"){return\"P-384\"}return null};this.generateKeyPairHex=function(){var k=this.ecparams.n;var n=this.getBigRandom(k);var l=this.ecparams.G.multiply(n);var q=l.getX().toBigInteger();var o=l.getY().toBigInteger();var i=this.ecparams.keylen/4;var m=(\"0000000000\"+n.toString(16)).slice(-i);var r=(\"0000000000\"+q.toString(16)).slice(-i);var p=(\"0000000000\"+o.toString(16)).slice(-i);var j=\"04\"+r+p;this.setPrivateKeyHex(m);this.setPublicKeyHex(j);return{ecprvhex:m,ecpubhex:j}};this.signWithMessageHash=function(i){return this.signHex(i,this.prvKeyHex)};this.signHex=function(o,j){var t=new BigInteger(j,16);var l=this.ecparams.n;var q=new BigInteger(o,16);do{var m=this.getBigRandom(l);var u=this.ecparams.G;var p=u.multiply(m);var i=p.getX().toBigInteger().mod(l)}while(i.compareTo(BigInteger.ZERO)<=0);var v=m.modInverse(l).multiply(q.add(t.multiply(i))).mod(l);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(i,v)};this.sign=function(m,u){var q=u;var j=this.ecparams.n;var p=BigInteger.fromByteArrayUnsigned(m);do{var l=this.getBigRandom(j);var t=this.ecparams.G;var o=t.multiply(l);var i=o.getX().toBigInteger().mod(j)}while(i.compareTo(BigInteger.ZERO)<=0);var v=l.modInverse(j).multiply(p.add(q.multiply(i))).mod(j);return this.serializeSig(i,v)};this.verifyWithMessageHash=function(j,i){return this.verifyHex(j,i,this.pubKeyHex)};this.verifyHex=function(m,i,p){var l,j;var o=KJUR.crypto.ECDSA.parseSigHex(i);l=o.r;j=o.s;var k;k=ECPointFp.decodeFromHex(this.ecparams.curve,p);var n=new BigInteger(m,16);return this.verifyRaw(n,l,j,k)};this.verify=function(o,p,j){var l,i;if(Bitcoin.Util.isArray(p)){var n=this.parseSig(p);l=n.r;i=n.s}else{if(\"object\"===typeof p&&p.r&&p.s){l=p.r;i=p.s}else{throw\"Invalid value for signature\"}}var k;if(j instanceof ECPointFp){k=j}else{if(Bitcoin.Util.isArray(j)){k=ECPointFp.decodeFrom(this.ecparams.curve,j)}else{throw\"Invalid format for pubkey value, must be byte array or ECPointFp\"}}var m=BigInteger.fromByteArrayUnsigned(o);return this.verifyRaw(m,l,i,k)};this.verifyRaw=function(o,i,w,m){var l=this.ecparams.n;var u=this.ecparams.G;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(l)>=0){return false}if(w.compareTo(BigInteger.ONE)<0||w.compareTo(l)>=0){return false}var p=w.modInverse(l);var k=o.multiply(p).mod(l);var j=i.multiply(p).mod(l);var q=u.multiply(k).add(m.multiply(j));var t=q.getX().toBigInteger().mod(l);return t.equals(i)};this.serializeSig=function(k,j){var l=k.toByteArraySigned();var i=j.toByteArraySigned();var m=[];m.push(2);m.push(l.length);m=m.concat(l);m.push(2);m.push(i.length);m=m.concat(i);m.unshift(m.length);m.unshift(48);return m};this.parseSig=function(n){var m;if(n[0]!=48){throw new Error(\"Signature not a valid DERSequence\")}m=2;if(n[m]!=2){throw new Error(\"First element in signature must be a DERInteger\")}var l=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];if(n[m]!=2){throw new Error(\"Second element in signature must be a DERInteger\")}var i=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];var k=BigInteger.fromByteArrayUnsigned(l);var j=BigInteger.fromByteArrayUnsigned(i);return{r:k,s:j}};this.parseSigCompact=function(m){if(m.length!==65){throw\"Signature has the wrong length\"}var j=m[0]-27;if(j<0||j>7){throw\"Invalid signature type\"}var o=this.ecparams.n;var l=BigInteger.fromByteArrayUnsigned(m.slice(1,33)).mod(o);var k=BigInteger.fromByteArrayUnsigned(m.slice(33,65)).mod(o);return{r:l,s:k,i:j}};this.readPKCS5PrvKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var i,k,o;try{i=p(l,0,[2,0],\"06\");k=p(l,0,[1],\"04\");try{o=p(l,0,[3,0],\"03\").substr(2)}catch(j){}}catch(j){throw\"malformed PKCS#1/5 plain ECC private key\"}this.curveName=m(i);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o);this.setPrivateKeyHex(k);this.isPublic=false};this.readPKCS8PrvKeyHex=function(l){var q=ASN1HEX;var i=KJUR.crypto.ECDSA.getName;var n=q.getVbyList;if(q.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var j,p,m,k;try{j=n(l,0,[1,0],\"06\");p=n(l,0,[1,1],\"06\");m=n(l,0,[2,0,1],\"04\");try{k=n(l,0,[2,0,2,0],\"03\").substr(2)}catch(o){}}catch(o){throw\"malformed PKCS#8 plain ECC private key\"}this.curveName=i(p);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(k);this.setPrivateKeyHex(m);this.isPublic=false};this.readPKCS8PubKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var k,i,o;try{k=p(l,0,[0,0],\"06\");i=p(l,0,[0,1],\"06\");o=p(l,0,[1],\"03\").substr(2)}catch(j){throw\"malformed PKCS#8 ECC public key\"}this.curveName=m(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o)};this.readCertPubKeyHex=function(k,p){if(p!==5){p=6}var m=ASN1HEX;var l=KJUR.crypto.ECDSA.getName;var o=m.getVbyList;if(m.isASN1HEX(k)===false){throw\"not ASN.1 hex string\"}var i,n;try{i=o(k,0,[0,p,0,1],\"06\");n=o(k,0,[0,p,1],\"03\").substr(2)}catch(j){throw\"malformed X.509 certificate ECC public key\"}this.curveName=l(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(n)};if(h!==undefined){if(h.curve!==undefined){this.curveName=h.curve}}if(this.curveName===undefined){this.curveName=e}this.setNamedCurve(this.curveName);if(h!==undefined){if(h.prv!==undefined){this.setPrivateKeyHex(h.prv)}if(h.pub!==undefined){this.setPublicKeyHex(h.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX;var i=j.getChildIdx;var g=j.getV;if(f.substr(0,2)!=\"30\"){throw\"signature is not a ASN.1 sequence\"}var h=i(f,0);if(h.length!=2){throw\"number of signature ASN.1 sequence elements seem wrong\"}var e=h[0];var d=h[1];if(f.substr(e,2)!=\"02\"){throw\"1st item of sequene of signature is not ASN.1 integer\"}if(f.substr(d,2)!=\"02\"){throw\"2nd item of sequene of signature is not ASN.1 integer\"}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(c){var d=KJUR.crypto.ECDSA.parseSigHexInHexRS(c);var b=d.r;var a=d.s;if(b.substr(0,2)==\"00\"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)==\"00\"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b=\"00\"+b}if((a.length%32)==30){a=\"00\"+a}if(b.length%32!=0){throw\"unknown ECDSA sig r length error\"}if(a.length%32!=0){throw\"unknown ECDSA sig s length error\"}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if((((a.length/2)*8)%(16*8))!=0){throw\"unknown ECDSA concatinated r-s sig length error\"}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.getEncodedHex()};KJUR.crypto.ECDSA.getName=function(a){if(a===\"2a8648ce3d030107\"){return\"secp256r1\"}if(a===\"2b8104000a\"){return\"secp256k1\"}if(a===\"2b81040022\"){return\"secp384r1\"}if(\"|secp256r1|NIST P-256|P-256|prime256v1|\".indexOf(a)!==-1){return\"secp256r1\"}if(\"|secp256k1|\".indexOf(a)!==-1){return\"secp256k1\"}if(\"|secp384r1|NIST P-384|P-384|\".indexOf(a)!==-1){return\"secp384r1\"}return null};\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.crypto==\"undefined\"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!=\"undefined\"){d=c[e]}if(typeof b[d]!=\"undefined\"){return b[d]}throw\"unregistered EC curve name: \"+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex(\"04\"+f+k);b[A][\"name\"]=A;b[A][\"keylen\"]=l;b[A][\"curve\"]=r;b[A][\"G\"]=q;b[A][\"n\"]=t;b[A][\"h\"]=w;b[A][\"oid\"]=d;b[A][\"info\"]=x;for(var v=0;v1){g=new BigInteger(i,16)}else{g=null}h=new BigInteger(j,16);this.setPrivate(c,a,e,g,h)};this.setPublic=function(c,b,a,d){this.isPublic=true;this.p=c;this.q=b;this.g=a;this.y=d;this.x=null};this.setPublicHex=function(f,e,d,g){var b,a,h,c;b=new BigInteger(f,16);a=new BigInteger(e,16);h=new BigInteger(d,16);c=new BigInteger(g,16);this.setPublic(b,a,h,c)};this.signWithMessageHash=function(d){var c=this.p;var b=this.q;var f=this.g;var i=this.y;var j=this.x;var e=KJUR.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),b.subtract(BigInteger.ONE));var l=d.substr(0,b.bitLength()/4);var h=new BigInteger(l,16);var a=(f.modPow(e,c)).mod(b);var n=(e.modInverse(b).multiply(h.add(j.multiply(a)))).mod(b);var m=KJUR.asn1.ASN1Util.jsonToASN1HEX({seq:[{\"int\":{bigint:a}},{\"int\":{bigint:n}}]});return m};this.verifyWithMessageHash=function(h,f){var d=this.p;var b=this.q;var j=this.g;var l=this.y;var i=this.parseASN1Signature(f);var a=i[0];var t=i[1];var o=h.substr(0,b.bitLength()/4);var k=new BigInteger(o,16);if(BigInteger.ZERO.compareTo(a)>0||a.compareTo(b)>0){throw\"invalid DSA signature\"}if(BigInteger.ZERO.compareTo(t)>=0||t.compareTo(b)>0){throw\"invalid DSA signature\"}var m=t.modInverse(b);var e=k.multiply(m).mod(b);var c=a.multiply(m).mod(b);var n=j.modPow(e,d).multiply(l.modPow(c,d)).mod(d).mod(b);return n.compareTo(a)==0};this.parseASN1Signature=function(a){try{var d=new BigInteger(ASN1HEX.getVbyList(a,0,[0],\"02\"),16);var c=new BigInteger(ASN1HEX.getVbyList(a,0,[1],\"02\"),16);return[d,c]}catch(b){throw\"malformed ASN.1 DSA signature\"}};this.readPKCS5PrvKeyHex=function(c){var b,a,f,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[1],\"02\");a=d(c,0,[2],\"02\");f=d(c,0,[3],\"02\");g=d(c,0,[4],\"02\");i=d(c,0,[5],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed PKCS#1/5 plain DSA private key\"}this.setPrivateHex(b,a,f,g,i)};this.readPKCS8PrvKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[1,1,0],\"02\");c=i(d,0,[1,1,1],\"02\");b=i(d,0,[1,1,2],\"02\");g=i(d,0,[2,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 plain DSA private key\"}this.setPrivateHex(f,c,b,null,g)};this.readPKCS8PubKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[0,1,0],\"02\");c=i(d,0,[0,1,1],\"02\");b=i(d,0,[0,1,2],\"02\");g=i(d,0,[1,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 DSA public key\"}this.setPublicHex(f,c,b,g)};this.readCertPubKeyHex=function(c,f){if(f!==5){f=6}var b,a,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[0,f,0,1,0],\"02\");a=d(c,0,[0,f,0,1,1],\"02\");g=d(c,0,[0,f,0,1,2],\"02\");i=d(c,0,[0,f,1,0],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed X.509 certificate DSA public key\"}this.setPublicHex(b,a,g,i)}};\nvar KEYUTIL=function(){var d=function(p,r,q){return k(CryptoJS.AES,p,r,q)};var e=function(p,r,q){return k(CryptoJS.TripleDES,p,r,q)};var a=function(p,r,q){return k(CryptoJS.DES,p,r,q)};var k=function(s,x,u,q){var r=CryptoJS.enc.Hex.parse(x);var w=CryptoJS.enc.Hex.parse(u);var p=CryptoJS.enc.Hex.parse(q);var t={};t.key=w;t.iv=p;t.ciphertext=r;var v=s.decrypt(t,w,{iv:p});return CryptoJS.enc.Hex.stringify(v)};var l=function(p,r,q){return g(CryptoJS.AES,p,r,q)};var o=function(p,r,q){return g(CryptoJS.TripleDES,p,r,q)};var f=function(p,r,q){return g(CryptoJS.DES,p,r,q)};var g=function(t,y,v,q){var s=CryptoJS.enc.Hex.parse(y);var x=CryptoJS.enc.Hex.parse(v);var p=CryptoJS.enc.Hex.parse(q);var w=t.encrypt(s,x,{iv:p});var r=CryptoJS.enc.Hex.parse(w.toString());var u=CryptoJS.enc.Base64.stringify(r);return u};var i={\"AES-256-CBC\":{proc:d,eproc:l,keylen:32,ivlen:16},\"AES-192-CBC\":{proc:d,eproc:l,keylen:24,ivlen:16},\"AES-128-CBC\":{proc:d,eproc:l,keylen:16,ivlen:16},\"DES-EDE3-CBC\":{proc:e,eproc:o,keylen:24,ivlen:8},\"DES-CBC\":{proc:a,eproc:f,keylen:8,ivlen:8}};var c=function(p){return i[p][\"proc\"]};var m=function(p){var r=CryptoJS.lib.WordArray.random(p);var q=CryptoJS.enc.Hex.stringify(r);return q};var n=function(v){var w={};var q=v.match(new RegExp(\"DEK-Info: ([^,]+),([0-9A-Fa-f]+)\",\"m\"));if(q){w.cipher=q[1];w.ivsalt=q[2]}var p=v.match(new RegExp(\"-----BEGIN ([A-Z]+) PRIVATE KEY-----\"));if(p){w.type=p[1]}var u=-1;var x=0;if(v.indexOf(\"\\r\\n\\r\\n\")!=-1){u=v.indexOf(\"\\r\\n\\r\\n\");x=2}if(v.indexOf(\"\\n\\n\")!=-1){u=v.indexOf(\"\\n\\n\");x=1}var t=v.indexOf(\"-----END\");if(u!=-1&&t!=-1){var r=v.substring(u+x*2,t-x);r=r.replace(/\\s+/g,\"\");w.data=r}return w};var j=function(q,y,p){var v=p.substring(0,16);var t=CryptoJS.enc.Hex.parse(v);var r=CryptoJS.enc.Utf8.parse(y);var u=i[q][\"keylen\"]+i[q][\"ivlen\"];var x=\"\";var w=null;for(;;){var s=CryptoJS.algo.MD5.create();if(w!=null){s.update(w)}s.update(r);s.update(t);w=s.finalize();x=x+CryptoJS.enc.Hex.stringify(w);if(x.length>=u*2){break}}var z={};z.keyhex=x.substr(0,i[q][\"keylen\"]*2);z.ivhex=x.substr(i[q][\"keylen\"]*2,i[q][\"ivlen\"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v][\"proc\"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s][\"eproc\"];var t=r(p,q,u);return t};return{version:\"1.0.0\",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p=\"\";if(typeof t==\"undefined\"||t==null){t=\"AES-256-CBC\"}if(typeof i[t]==\"undefined\"){throw\"KEYUTIL unsupported algorithm: \"+t}if(typeof r==\"undefined\"||r==null){var v=i[t][\"ivlen\"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,\"$1\\r\\n\");var p=\"-----BEGIN \"+x+\" PRIVATE KEY-----\\r\\n\";p+=\"Proc-Type: 4,ENCRYPTED\\r\\n\";p+=\"DEK-Info: \"+t+\",\"+r+\"\\r\\n\";p+=\"\\r\\n\";p+=q;p+=\"\\r\\n-----END \"+x+\" PRIVATE KEY-----\\r\\n\";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw\"malformed format: SEQUENCE(0).items != 2: \"+r.length}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0).items != 2: \"+A.length}if(w(y,A[0])!=\"2a864886f70d01050d\"){throw\"this only supports pkcs5PBES2\"}var p=z(y,A[1]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0.1).items != 2: \"+p.length}var q=z(y,p[1]);if(q.length!=2){throw\"malformed format: SEQUENCE(0.0.1.1).items != 2: \"+q.length}if(w(y,q[0])!=\"2a864886f70d0307\"){throw\"this only supports TripleDES\"}t.encryptionSchemeAlg=\"TripleDES\";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw\"malformed format: SEQUENCE(0.0.1.0).items != 2: \"+s.length}if(w(y,s[0])!=\"2a864886f70d01050c\"){throw\"this only supports pkcs5PBKDF2\"}var x=z(y,s[1]);if(x.length<2){throw\"malformed format: SEQUENCE(0.0.1.0.1).items < 2: \"+x.length}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw\"malformed format pbkdf2Iter: \"+u}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,\"ENCRYPTED PRIVATE KEY\");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!=\"30\"){throw\"malformed plain PKCS8 private key(code:001)\"}var r=u(s,0);if(r.length!=3){throw\"malformed plain PKCS8 private key(code:002)\"}if(s.substr(r[1],2)!=\"30\"){throw\"malformed PKCS8 private key(code:003)\"}var p=u(s,r[1]);if(p.length!=2){throw\"malformed PKCS8 private key(code:004)\"}if(s.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 private key(code:005)\"}q.algoid=t(s,p[0]);if(s.substr(p[1],2)==\"06\"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!=\"04\"){throw\"malformed PKCS8 private key(code:006)\"}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,\"PRIVATE KEY\");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid==\"2a864886f70d010101\"){r=new RSAKey()}else{if(q.algoid==\"2a8648ce380401\"){r=new KJUR.crypto.DSA()}else{if(q.algoid==\"2a8648ce3d0201\"){r=new KJUR.crypto.ECDSA()}else{throw\"unsupported private key algorithm\"}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],\"06\");if(r===\"2a864886f70d010101\"){p=new RSAKey()}else{if(r===\"2a8648ce380401\"){p=new KJUR.crypto.DSA()}else{if(r===\"2a8648ce3d0201\"){p=new KJUR.crypto.ECDSA()}else{throw\"unsupported PKCS#8 public key hex\"}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!=\"30\"){throw\"malformed RSA key(code:001)\"}var q=t(r,0);if(q.length!=2){throw\"malformed RSA key(code:002)\"}if(r.substr(q[0],2)!=\"02\"){throw\"malformed RSA key(code:003)\"}p.n=s(r,q[0]);if(r.substr(q[1],2)!=\"02\"){throw\"malformed RSA key(code:004)\"}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw\"outer DERSequence shall have 2 elements: \"+r.length}var w=r[0];if(t.substr(w,2)!=\"30\"){throw\"malformed PKCS8 public key(code:001)\"}var p=u(t,w);if(p.length!=2){throw\"malformed PKCS8 public key(code:002)\"}if(t.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 public key(code:003)\"}q.algoid=s(t,p[0]);if(t.substr(p[1],2)==\"06\"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)==\"30\"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],\"02\");q.algparam.q=v.getVbyList(t,p[1],[1],\"02\");q.algparam.g=v.getVbyList(t,p[1],[2],\"02\")}}if(t.substr(r[1],2)!=\"03\"){throw\"malformed PKCS8 public key(code:004)\"}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!=\"undefined\"&&l instanceof w){return l}if(typeof i!=\"undefined\"&&l instanceof i){return l}if(typeof C!=\"undefined\"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;j.setPublicKeyHex(u);return j}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;var b=(\"0000000000\"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n===\"pkcs5prv\"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)===\"04\"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw\"unsupported PKCS#1/5 hexadecimal key\"}}}return P}if(n===\"pkcs8prv\"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n===\"pkcs8pub\"){return F._getKeyFromPublicPKCS8Hex(l)}if(n===\"x509pub\"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf(\"-END CERTIFICATE-\",0)!=-1||l.indexOf(\"-END X509 CERTIFICATE-\",0)!=-1||l.indexOf(\"-END TRUSTED CERTIFICATE-\",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf(\"-END PUBLIC KEY-\")!=-1){var O=pemtohex(l,\"PUBLIC KEY\");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var m=M(l,\"RSA PRIVATE KEY\");return F.getKey(m,null,\"pkcs5prv\")}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var I=M(l,\"DSA PRIVATE KEY\");var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END PRIVATE KEY-\")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf(\"-END EC PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],\"04\");var f=d(I,0,[2,0],\"06\");var A=d(I,0,[3,0],\"03\").substr(2);var e=\"\";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw\"undefined OID(hex) in KJUR.crypto.OID: \"+f}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END ENCRYPTED PRIVATE KEY-\")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw\"not supported argument\"};KEYUTIL.generateKeypair=function(a,c){if(a==\"RSA\"){var b=c;var h=new RSAKey();h.generate(b,\"10001\");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a==\"EC\"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw\"unknown algorithm: \"+a}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.n}},{\"int\":s.e},{\"int\":{bigint:s.d}},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.dmp1}},{\"int\":{bigint:s.dmq1}},{\"int\":{bigint:s.coeff}}]});return G}function B(G){var s=l({seq:[{\"int\":1},{octstr:{hex:G.prvKeyHex}},{tag:[\"a0\",true,{oid:{name:G.curveName}}]},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+G.pubKeyHex}}]}]});return s}function x(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.g}},{\"int\":{bigint:s.y}},{\"int\":{bigint:s.x}}]});return G}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D==\"PKCS8PUB\")){var E=new C(b);var w=E.getEncodedHex();return hextopem(w,\"PUBLIC KEY\")}if(D==\"PKCS1PRV\"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();return hextopem(w,\"RSA PRIVATE KEY\")}if(D==\"PKCS1PRV\"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.getEncodedHex();var h=B(b);var t=h.getEncodedHex();var p=\"\";p+=hextopem(v,\"EC PARAMETERS\");p+=hextopem(t,\"EC PRIVATE KEY\");return p}if(D==\"PKCS1PRV\"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();return hextopem(w,\"DSA PRIVATE KEY\")}if(D==\"PKCS5PRV\"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"RSA\",w,y,m,j)}if(D==\"PKCS5PRV\"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"EC\",w,y,m,j)}if(D==\"PKCS5PRV\"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"DSA\",w,y,m,j)}var o=function(G,s){var I=c(G,s);var H=new l({seq:[{seq:[{oid:{name:\"pkcs5PBES2\"}},{seq:[{seq:[{oid:{name:\"pkcs5PBKDF2\"}},{seq:[{octstr:{hex:I.pbkdf2Salt}},{\"int\":I.pbkdf2Iter}]}]},{seq:[{oid:{name:\"des-EDE3-CBC\"}},{octstr:{hex:I.encryptionSchemeIV}}]}]}]},{octstr:{hex:I.ciphertext}}]});return H.getEncodedHex()};var c=function(N,O){var H=100;var M=CryptoJS.lib.WordArray.random(8);var L=\"DES-EDE3-CBC\";var s=CryptoJS.lib.WordArray.random(8);var I=CryptoJS.PBKDF2(O,M,{keySize:192/32,iterations:H});var J=CryptoJS.enc.Hex.parse(N);var K=CryptoJS.TripleDES.encrypt(J,I,{iv:s})+\"\";var G={};G.ciphertext=K;G.pbkdf2Salt=CryptoJS.enc.Hex.stringify(M);G.pbkdf2Iter=H;G.encryptionSchemeAlg=L;G.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return G};if(D==\"PKCS8PRV\"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"rsaEncryption\"}},{\"null\":true}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var g=new l({seq:[{\"int\":1},{octstr:{hex:b.prvKeyHex}},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+b.pubKeyHex}}]}]});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"ecPublicKey\"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"dsa\"}},{seq:[{\"int\":{bigint:b.p}},{\"int\":{bigint:b.q}},{\"int\":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}throw\"unsupported object nor format\"};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,\"CERTIFICATE REQUEST\");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,\"pkcs8pub\");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!=\"30\"){throw\"malformed CSR(code:001)\"}var e=f(g,0);if(e.length<1){throw\"malformed CSR(code:002)\"}if(g.substr(e[0],2)!=\"30\"){throw\"malformed CSR(code:003)\"}var a=f(g,e[0]);if(a.length<3){throw\"malformed CSR(code:004)\"}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getJWKFromKey=function(d){var b={};if(d instanceof RSAKey&&d.isPrivate){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));b.d=hextob64u(d.d.toString(16));b.p=hextob64u(d.p.toString(16));b.q=hextob64u(d.q.toString(16));b.dp=hextob64u(d.dmp1.toString(16));b.dq=hextob64u(d.dmq1.toString(16));b.qi=hextob64u(d.coeff.toString(16));return b}else{if(d instanceof RSAKey&&d.isPublic){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPrivate){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);b.d=hextob64u(d.prvKeyHex);return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPublic){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);return b}}}}throw\"not supported key object\"};\nRSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,j,l,b,a,f,d,k;var m=ASN1HEX;var g=m.getVbyList;if(m.isASN1HEX(e)===false){throw\"not ASN.1 hex string\"}try{c=g(e,0,[2,0,1],\"02\");j=g(e,0,[2,0,2],\"02\");l=g(e,0,[2,0,3],\"02\");b=g(e,0,[2,0,4],\"02\");a=g(e,0,[2,0,5],\"02\");f=g(e,0,[2,0,6],\"02\");d=g(e,0,[2,0,7],\"02\");k=g(e,0,[2,0,8],\"02\")}catch(i){throw\"malformed PKCS#8 plain RSA private key\"}this.setPrivateEx(c,j,l,b,a,f,d,k)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw\"keyHex is not ASN.1 hex string\"}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!==\"02\"||c.substr(a[1],2)!==\"02\"){throw\"wrong hex for PKCS#5 public key\"}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw\"not ASN.1 hex string\"}if(c.getTLVbyList(b,0,[0,0])!==\"06092a864886f70d010101\"){throw\"not PKCS8 RSA public key\"}var a=c.getTLVbyList(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)};\nvar _RE_HEXDECONLY=new RegExp(\"\");_RE_HEXDECONLY.compile(\"[^0-9a-f]\",\"gi\");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c=\"\";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw\"invalid salt length\"}}}if(c<(g+k+2)){throw\"data too long\"}var f=\"\";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dthis.n.bitLength()){return 0}var i=this.doPublic(b);var e=i.toString(16).replace(/^1f+00/,\"\");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(k){return KJUR.crypto.Util.hashString(k,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){a=a.replace(_RE_HEXDECONLY,\"\");a=a.replace(/[ \\n]+/g,\"\");var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,\"\");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){var k=new BigInteger(s,16);if(k.bitLength()>this.n.bitLength()){return false}var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw\"invalid salt length\"}}}if(m<(h+c+2)){throw\"data too long\"}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw\"bits beyond keysize not zero\"}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q0){var b=\":\"+n.join(\":\")+\":\";if(b.indexOf(\":\"+k+\":\")==-1){throw\"algorithm '\"+k+\"' not accepted in the list\"}}if(k!=\"none\"&&B===null){throw\"key shall be specified to verify.\"}if(typeof B==\"string\"&&B.indexOf(\"-----BEGIN \")!=-1){B=KEYUTIL.getKey(B)}if(z==\"RS\"||z==\"PS\"){if(!(B instanceof m)){throw\"key shall be a RSAKey obj for RS* and PS* algs\"}}if(z==\"ES\"){if(!(B instanceof p)){throw\"key shall be a ECDSA obj for ES* algs\"}}if(k==\"none\"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw\"unsupported alg name: \"+k}else{u=t.jwsalg2sigalg[k]}if(u==\"none\"){throw\"not supported\"}else{if(u.substr(0,4)==\"Hmac\"){var o=null;if(B===undefined){throw\"hexadecimal key shall be specified for HMAC\"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf(\"withECDSA\")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(\".\");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw\"malformed sJWS: wrong number of '.' splitted elements\"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null,\" \");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null,\" \")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;var k=e.split(\".\");var c=k[0];var i=k[1];var q=c+\".\"+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw\"acceptField.alg shall be specified\"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss===\"object\"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub===\"object\"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud===\"object\"){if(typeof g.aud==\"string\"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud==\"object\"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt===\"number\"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!==\"number\"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp==\"number\"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw\"addSignature failed: \"+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw\"malformed header\"}if(typeof g.payload===\"string\"){this.sPayload=g.payload}else{throw\"malformed signatures\"}if(g.signatures.length>0){this.aSignatures=g.signatures}else{throw\"malformed signatures\"}}catch(e){throw\"malformed JWS-JS JSON object: \"+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}};\nexports.SecureRandom = SecureRandom;\nexports.rng_seed_time = rng_seed_time;\n\nexports.BigInteger = BigInteger;\nexports.RSAKey = RSAKey;\nexports.ECDSA = KJUR.crypto.ECDSA;\nexports.DSA = KJUR.crypto.DSA;\nexports.Signature = KJUR.crypto.Signature;\nexports.MessageDigest = KJUR.crypto.MessageDigest;\nexports.Mac = KJUR.crypto.Mac;\nexports.Cipher = KJUR.crypto.Cipher;\nexports.KEYUTIL = KEYUTIL;\nexports.ASN1HEX = ASN1HEX;\nexports.X509 = X509;\nexports.CryptoJS = CryptoJS;\n\n// ext/base64.js\nexports.b64tohex = b64tohex;\nexports.b64toBA = b64toBA;\n\n// base64x.js\nexports.stoBA = stoBA;\nexports.BAtos = BAtos;\nexports.BAtohex = BAtohex;\nexports.stohex = stohex;\nexports.stob64 = stob64;\nexports.stob64u = stob64u;\nexports.b64utos = b64utos;\nexports.b64tob64u = b64tob64u;\nexports.b64utob64 = b64utob64;\nexports.hex2b64 = hex2b64;\nexports.hextob64u = hextob64u;\nexports.b64utohex = b64utohex;\nexports.utf8tob64u = utf8tob64u;\nexports.b64utoutf8 = b64utoutf8;\nexports.utf8tob64 = utf8tob64;\nexports.b64toutf8 = b64toutf8;\nexports.utf8tohex = utf8tohex;\nexports.hextoutf8 = hextoutf8;\nexports.hextorstr = hextorstr;\nexports.rstrtohex = rstrtohex;\nexports.hextob64 = hextob64;\nexports.hextob64nl = hextob64nl;\nexports.b64nltohex = b64nltohex;\nexports.hextopem = hextopem;\nexports.pemtohex = pemtohex;\nexports.hextoArrayBuffer = hextoArrayBuffer;\nexports.ArrayBuffertohex = ArrayBuffertohex;\nexports.zulutomsec = zulutomsec;\nexports.zulutosec = zulutosec;\nexports.zulutodate = zulutodate;\nexports.datetozulu = datetozulu;\nexports.uricmptohex = uricmptohex;\nexports.hextouricmp = hextouricmp;\nexports.ipv6tohex = ipv6tohex;\nexports.hextoipv6 = hextoipv6;\nexports.hextoip = hextoip;\nexports.iptohex = iptohex;\nexports.encodeURIComponentAll = encodeURIComponentAll;\nexports.newline_toUnix = newline_toUnix;\nexports.newline_toDos = newline_toDos;\nexports.hextoposhex = hextoposhex;\nexports.intarystrtohex = intarystrtohex;\nexports.strdiffidx = strdiffidx;\n\n// name spaces\nexports.KJUR = KJUR;\nexports.crypto = KJUR.crypto;\nexports.asn1 = KJUR.asn1;\nexports.jws = KJUR.jws;\nexports.lang = KJUR.lang;\n\n\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://AppID/./node_modules/jsrsasign/lib/jsrsasign.js?"); + +/***/ }), + +/***/ "./node_modules/node-fetch/browser.js": +/*!********************************************!*\ + !*** ./node_modules/node-fetch/browser.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n// ref: https://github.com/tc39/proposal-global\nvar getGlobal = function () {\n\t// the only reliable means to get the global object is\n\t// `Function('return this')()`\n\t// However, this causes CSP violations in Chrome apps.\n\tif (typeof self !== 'undefined') { return self; }\n\tif (typeof window !== 'undefined') { return window; }\n\tif (typeof global !== 'undefined') { return global; }\n\tthrow new Error('unable to locate global object');\n}\n\nvar global = getGlobal();\n\nmodule.exports = exports = global.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = global.fetch.bind(global);\n\nexports.Headers = global.Headers;\nexports.Request = global.Request;\nexports.Response = global.Response;\n\n//# sourceURL=webpack://AppID/./node_modules/node-fetch/browser.js?"); + +/***/ }), + +/***/ "./node_modules/webpack/buildin/global.js": +/*!***********************************!*\ + !*** (webpack)/buildin/global.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://AppID/(webpack)/buildin/global.js?"); + +/***/ }), + +/***/ "./package.json": +/*!**********************!*\ + !*** ./package.json ***! + \**********************/ +/*! exports provided: name, version, description, scripts, repository, main, nyc, dependencies, devDependencies, default */ +/***/ (function(module) { + +eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"ibmcloud-appid-js\\\",\\\"version\\\":\\\"0.3.0\\\",\\\"description\\\":\\\"IBM Cloud App ID SDK for Single Page Applications\\\",\\\"scripts\\\":{\\\"build\\\":\\\"webpack --mode=development\\\",\\\"test\\\":\\\"mocha\\\",\\\"coverage\\\":\\\"nyc --reporter=lcov mocha\\\",\\\"docs\\\":\\\"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json\\\"},\\\"repository\\\":{\\\"type\\\":\\\"git\\\",\\\"url\\\":\\\"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git\\\"},\\\"main\\\":\\\"dist/appid.umd.min.js\\\",\\\"nyc\\\":{\\\"all\\\":true,\\\"include\\\":[\\\"src/*.js\\\"],\\\"exclude\\\":[\\\"**/PopupController.js\\\",\\\"**/IFrameController.js\\\",\\\"**/OpenIDConfigurationResource.js\\\",\\\"**/constants.js\\\"]},\\\"dependencies\\\":{\\\"jsrsasign\\\":\\\"^8.0.12\\\"},\\\"devDependencies\\\":{\\\"node-fetch\\\":\\\"^2.6.0\\\",\\\"@babel/cli\\\":\\\"^7.0.0\\\",\\\"@babel/core\\\":\\\"^7.5.5\\\",\\\"@babel/plugin-transform-runtime\\\":\\\"^7.5.5\\\",\\\"@babel/preset-env\\\":\\\"^7.5.5\\\",\\\"babel-cli\\\":\\\"^7.0.0-beta.3\\\",\\\"chai\\\":\\\"^4.2.0\\\",\\\"coveralls\\\":\\\"^3.0.6\\\",\\\"gulp-babel\\\":\\\"^8.0.0\\\",\\\"mocha\\\":\\\"^6.2.0\\\",\\\"nyc\\\":\\\"^14.1.1\\\",\\\"webpack\\\":\\\"^4.39.1\\\",\\\"webpack-cli\\\":\\\"^3.3.6\\\",\\\"docdash\\\":\\\"^1.1.1\\\",\\\"jsdoc\\\":\\\"^3.6.3\\\"}}\");\n\n//# sourceURL=webpack://AppID/./package.json?"); + +/***/ }), + +/***/ "./src/IFrameController.js": +/*!*********************************!*\ + !*** ./src/IFrameController.js ***! + \*********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const IFrameError = __webpack_require__(/*! ./errors/IFrameError */ \"./src/errors/IFrameError.js\");\n\nclass IFrameController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t}\n\n\topen(url) {\n\t\tthis.iFrame = this.window.document.createElement('iframe');\n\t\tthis.iFrame.src = url;\n\t\tthis.iFrame.width = 0;\n\t\tthis.iFrame.height = 0;\n\t\tthis.window.document.body.appendChild(this.iFrame);\n\t}\n\n\tremove() {\n\t\twindow.document.body.removeChild(this.iFrame);\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\treject(new IFrameError('Silent sign-in timed out'));\n\t\t\t}, 5 * 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tclearInterval(timer);\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = IFrameController;\n\n\n//# sourceURL=webpack://AppID/./src/IFrameController.js?"); + +/***/ }), + +/***/ "./src/OpenIDConfigurationResource.js": +/*!********************************************!*\ + !*** ./src/OpenIDConfigurationResource.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const packagejson = __webpack_require__(/*! ../package.json */ \"./package.json\");\n\nclass OpenIdConfigurationResource {\n\tasync init({discoveryEndpoint, requestHandler}){\n\t\tthis.openIdConfig = await requestHandler(discoveryEndpoint);\n\t\tconst headers = { 'x-filter-type': `spa:v${packagejson.version}` };\n\t\tthis.publicKeys = requestHandler(this.getJwksEndpoint(), { headers: headers });\n\t}\n\n\tgetAuthorizationEndpoint() {\n\t\treturn this.openIdConfig.authorization_endpoint;\n\t}\n\n\tgetUserInfoEndpoint() {\n\t\treturn this.openIdConfig.userinfo_endpoint;\n\t}\n\n\tgetJwksEndpoint() {\n\t\treturn this.openIdConfig.jwks_uri;\n\t}\n\n\tgetTokenEndpoint() {\n\t\treturn this.openIdConfig.token_endpoint;\n\t}\n\n\tgetIssuer() {\n\t\treturn this.openIdConfig.issuer;\n\t}\n\n\tasync getPublicKeys() {\n\t\treturn await this.publicKeys;\n\t}\n}\nmodule.exports = OpenIdConfigurationResource;\n\n\n\n//# sourceURL=webpack://AppID/./src/OpenIDConfigurationResource.js?"); + +/***/ }), + +/***/ "./src/PopupController.js": +/*!********************************!*\ + !*** ./src/PopupController.js ***! + \********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const PopupError = __webpack_require__(/*! ./errors/PopupError */ \"./src/errors/PopupError.js\");\n\nclass PopupController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t};\n\n\tinit(popupConfig){\n\t\tthis.popupConfig = popupConfig;\n\t}\n\n\topen() {\n\t\tconst h = this.popupConfig.height;\n\t\tconst w = this.popupConfig.width;\n\t\tconst left = (window.screen.width - w) / 2;\n\t\tconst top = (window.screen.height - h) / 2;\n\t\tthis.popup = this.window.open('', 'popup', `left=${left},top=${top},width=${w},height=${h},resizable,scrollbars=yes,status=1`);\n\t\tif (!this.popup) {\n\t\t\tthrow new PopupError('Unable to open popup')\n\t\t}\n\t};\n\n\tnavigate(url) {\n\t\tthis.popup.location.href = url;\n\t};\n\n\tclose() {\n\t\tthis.popup.close();\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\tif(this.popup.closed) {\n\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\treject(new PopupError('Popup closed'));\n\t\t\t\t}\n\t\t\t}, 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = PopupController;\n\n\n//# sourceURL=webpack://AppID/./src/PopupController.js?"); + +/***/ }), + +/***/ "./src/RequestHandler.js": +/*!*******************************!*\ + !*** ./src/RequestHandler.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t}\n\t\t\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tif (text !== '') {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); + +/***/ }), + +/***/ "./src/TokenValidator.js": +/*!*******************************!*\ + !*** ./src/TokenValidator.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg: [constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif ((nonce && !decoded.payloadObj.nonce) || (decoded.payloadObj.nonce !== nonce)) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\n\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); + +/***/ }), + +/***/ "./src/constants.js": +/*!**************************!*\ + !*** ./src/constants.js ***! + \**************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN: 'Invalid id token',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN: 'Missing id token string',\n\tMISSING_ID_TOKEN_PAYLOAD: 'Missing id token payload',\n\tMISSING_TOKENS: 'Missing tokens',\n\tMISSING_ACCESS_TOKEN: 'Missing access token string',\n\tMISSING_ID_TOKEN: 'Missing access token string',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tGENERATE_CODE: '/cloud_directory/generate_code',\n\tCHANGE_DETAILS: '/cloud_directory/change_details',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); + +/***/ }), + +/***/ "./src/errors/AppIDError.js": +/*!**********************************!*\ + !*** ./src/errors/AppIDError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class AppIDError extends Error {}\nmodule.exports = AppIDError;\n\n//# sourceURL=webpack://AppID/./src/errors/AppIDError.js?"); + +/***/ }), + +/***/ "./src/errors/IFrameError.js": +/*!***********************************!*\ + !*** ./src/errors/IFrameError.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class IFrameError extends Error {}\nmodule.exports = IFrameError;\n\n//# sourceURL=webpack://AppID/./src/errors/IFrameError.js?"); + +/***/ }), + +/***/ "./src/errors/OAuthError.js": +/*!**********************************!*\ + !*** ./src/errors/OAuthError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class OAuthError extends Error {\n\t// See https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for the possible error messages\n\tconstructor({error, description}) {\n\t\tsuper(description || error);\n\t\tthis.error = error;\n\t\tthis.description = description;\n\t}\n}\nmodule.exports = OAuthError;\n\n//# sourceURL=webpack://AppID/./src/errors/OAuthError.js?"); + +/***/ }), + +/***/ "./src/errors/PopupError.js": +/*!**********************************!*\ + !*** ./src/errors/PopupError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class PopupError extends Error {}\nmodule.exports = PopupError;\n\n//# sourceURL=webpack://AppID/./src/errors/PopupError.js?"); + +/***/ }), + +/***/ "./src/errors/RequestError.js": +/*!************************************!*\ + !*** ./src/errors/RequestError.js ***! + \************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class RequestError extends Error {\n\tconstructor(description, status, originError) {\n\t\tsuper(description);\n\t\tthis.status = status;\n\t\tthis.originError = originError;\n\t}\n}\nmodule.exports = RequestError;\n\n//# sourceURL=webpack://AppID/./src/errors/RequestError.js?"); + +/***/ }), + +/***/ "./src/errors/TokenError.js": +/*!**********************************!*\ + !*** ./src/errors/TokenError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class TokenError extends Error {}\nmodule.exports = TokenError;\n\n//# sourceURL=webpack://AppID/./src/errors/TokenError.js?"); + +/***/ }), + +/***/ "./src/index.js": +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\")\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in allows you to automatically obtain new tokens for a user without the user having to re-authenticate using a popup.\n\t * This will attempt to authenticate the user in a hidden iframe.\n\t * You will need to [enable Cloud Directory SSO]{@link https://cloud.ibm.com/docs/services/appid?topic=appid-single-page#spa-silent-login}.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {string} idToken A JWT.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @example\n\t * let tokens = await appID.changePassword(idToken);\n\t */\n\tasync changePassword(idToken) {\n\t\tthis._validateInitalize();\n\n\t\tif (!idToken || typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tlet userId;\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\t\tlet decodedToken = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: idToken,\n\t\t\tpublicKeys,\n\t\t\tissuer: this.openIdConfigResource.getIssuer(),\n\t\t\tclientId: this.clientId\n\t\t});\n\n\t\tif (decodedToken.identities && decodedToken.identities[0] && decodedToken.identities[0].id) {\n\t\t\tif (decodedToken.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = decodedToken.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn await this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change details widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {Object} tokens App ID tokens\n\t * @returns {Promise}\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @throws {AppIDError} \"Missing access token string\"\n\t * @throws {AppIDError} \"Missing tokens object\"\n\t * @example\n\t * let tokens = {accessToken, idToken}\n\t * let newTokens = await appID.changeDetails(tokens);\n\t */\n\tasync changeDetails({accessToken, idToken}) {\n\t\tif (!accessToken && typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ACCESS_TOKEN);\n\t\t}\n\n\t\tif (!idToken && typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tconst generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE;\n\t\tconst changeDetailsCode = await this.request(generateCodeUrl, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken + ' ' + idToken\n\t\t\t}\n\t\t});\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS;\n\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint,\n\t\t\tchangeDetailsCode\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); + +/***/ }), + +/***/ "./src/utils.js": +/*!**********************!*\ + !*** ./src/utils.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId, changeDetailsCode}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tif (changeDetailsCode) {\n\t\t\tauthParams.code = changeDetailsCode;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint, changeDetailsCode}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint, changeDetailsCode});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); + +/***/ }) + +/******/ }); +}); \ No newline at end of file diff --git a/src/TokenValidator.js b/src/TokenValidator.js index f97779b..99bb654 100644 --- a/src/TokenValidator.js +++ b/src/TokenValidator.js @@ -22,7 +22,7 @@ class TokenValidator { const publicKey = this.getPublicKey(publicKeys.keys, kid); const myKey = this.jwt.KEYUTIL.getKey(publicKey); - const isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg:[constants.TOKEN_ALG]}); + const isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg: [constants.TOKEN_ALG]}); if (!isValid) { throw new TokenError(constants.INVALID_SIGNATURE); } @@ -56,7 +56,7 @@ class TokenValidator { getPublicKey(keys, kid) { let publicKey; - for(let i = 0; i < keys.length; i++) { + for (let i = 0; i < keys.length; i++) { if (keys[i].kid === kid) { publicKey = keys[i]; } @@ -68,4 +68,5 @@ class TokenValidator { return publicKey; } } + module.exports = TokenValidator; diff --git a/src/constants.js b/src/constants.js index 9deeeb9..bcd651e 100644 --- a/src/constants.js +++ b/src/constants.js @@ -17,7 +17,7 @@ module.exports = { MISSING_CLIENT_ID: 'Missing client ID', MISSING_ID_TOKEN: 'Missing id token string', MISSING_ID_TOKEN_PAYLOAD: 'Missing id token payload', - MISSING_TOKENS: 'Missing tokens object', + MISSING_TOKENS: 'Missing tokens', MISSING_ACCESS_TOKEN: 'Missing access token string', MISSING_ID_TOKEN: 'Missing access token string', INVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint', diff --git a/src/index.js b/src/index.js index a8d2ead..2fea68c 100644 --- a/src/index.js +++ b/src/index.js @@ -229,22 +229,18 @@ class AppID { * let newTokens = await appID.changeDetails(tokens); */ async changeDetails({accessToken, idToken}) { - if (!tokens) { - throw new AppIDError(constants.MISSING_TOKENS); - } - - if (!tokens.accessToken && typeof tokens.accessToken !== 'string') { + if (!accessToken && typeof accessToken !== 'string') { throw new AppIDError(constants.MISSING_ACCESS_TOKEN); } - if (!tokens.idToken && typeof tokens.idToken !== 'string') { + if (!idToken && typeof idToken !== 'string') { throw new AppIDError(constants.MISSING_ID_TOKEN); } const generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE; const changeDetailsCode = await this.request(generateCodeUrl, { headers: { - 'Authorization': 'Bearer ' + tokens.accessToken + ' ' + tokens.idToken + 'Authorization': 'Bearer ' + accessToken + ' ' + idToken } }); const endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS; diff --git a/src/utils.js b/src/utils.js index fdc1656..fe8158d 100644 --- a/src/utils.js +++ b/src/utils.js @@ -139,8 +139,7 @@ class Utils { token: tokens.access_token, publicKeys, issuer, - clientId, - nonce + clientId }); const idTokenPayload = this.tokenValidator.decodeAndValidate({ From 24b3817dfc9a2296c47b62268cb49430e8645275 Mon Sep 17 00:00:00 2001 From: Joyce Huang Date: Mon, 28 Oct 2019 15:27:00 -0500 Subject: [PATCH 5/9] update token validation --- dist/appid.min.js | 385 +++++++++++++++++++++++++++++++----- dist/appid.umd.min.js | 395 ++++++++++++++++++++++++++++++++----- src/TokenValidator.js | 2 +- src/utils.js | 3 +- test/tokenValidatorTest.js | 7 + 5 files changed, 689 insertions(+), 103 deletions(-) diff --git a/dist/appid.min.js b/dist/appid.min.js index 75ab3f3..d7459c8 100644 --- a/dist/appid.min.js +++ b/dist/appid.min.js @@ -1,50 +1,335 @@ -var AppID=function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=5)}([function(t,e,i){(function(t){var i={userAgent:!1},n={}; -/*! -Copyright (c) 2011, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.9.0 -*/ -if(void 0===r)var r={};r.lang={extend:function(t,e,n){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),n){var s;for(s in n)t.prototype[s]=n[s];var o=function(){},a=["toString","valueOf"];try{/MSIE/.test(i.userAgent)&&(o=function(t,e){for(s=0;s>>2]>>>24-s%4*8&255;e[n+s>>>2]|=o<<24-(n+s)%4*8}else for(s=0;s>>2]=i[s>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=s.ceil(e/4)},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i>>2]>>>24-r%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new u.init(i,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,i=t.sigBytes,n=[],r=0;r>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new u.init(i,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},g=a.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,n=e.sigBytes,r=this.blockSize,o=n/(4*r),a=(o=t?s.ceil(o):s.max((0|o)-this._minBufferSize,0))*r,h=s.min(4*a,n);if(a){for(var c=0;c>>2]}},e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:h,padding:c}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(h=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?n.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=n.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:i})}},e.SerializableCipher=i.extend({cfg:i.extend({format:h}),encrypt:function(t,e,i,n){n=this.cfg.extend(n);var r=t.createEncryptor(i,n);return e=r.finalize(e),r=r.cfg,l.create({ciphertext:e,key:i,iv:r.iv,algorithm:t,mode:r.mode,padding:r.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(i,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,i,r){return r||(r=n.random(8)),t=o.create({keySize:e+i}).compute(t,r),i=n.create(t.words.slice(e),4*i),t.sigBytes=4*e,l.create({key:t,iv:i,salt:r})}},g=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:d}),encrypt:function(t,e,i,n){return i=(n=this.cfg.extend(n)).kdf.execute(i,t.keySize,t.ivSize),n.iv=i.iv,(t=f.encrypt.call(this,t,e,i.key,n)).mixIn(i),t},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),i=n.kdf.execute(i,t.keySize,t.ivSize,e.salt),n.iv=i.iv,f.decrypt.call(this,t,e,i.key,n)}})}(),function(){for(var t=y,e=t.lib.BlockCipher,i=t.algo,n=[],r=[],s=[],o=[],a=[],h=[],u=[],c=[],l=[],f=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var p=0,v=0;for(g=0;256>g;g++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;n[p]=m,r[m]=p;var S=d[p],F=d[S],w=d[F],E=257*d[m]^16843008*m;s[p]=E<<24|E>>>8,o[p]=E<<16|E>>>16,a[p]=E<<8|E>>>24,h[p]=E,E=16843009*w^65537*F^257*S^16843008*p,u[m]=E<<24|E>>>8,c[m]=E<<16|E>>>16,l[m]=E<<8|E>>>24,f[m]=E,p?(p=S^d[d[d[w^S]]],v^=d[d[v]]):p=v=1}var x=[0,1,2,4,8,16,32,64,128,27,54];i=i.AES=e.extend({_doReset:function(){for(var t=(i=this._key).words,e=i.sigBytes/4,i=4*((this._nRounds=e+6)+1),r=this._keySchedule=[],s=0;s>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o]):(o=n[(o=o<<8|o>>>24)>>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o],o^=x[s/e|0]<<24),r[s]=r[s-e]^o}for(t=this._invKeySchedule=[],e=0;ee||4>=s?o:u[n[o>>>24]]^c[n[o>>>16&255]]^l[n[o>>>8&255]]^f[n[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,o,a,h,n)},decryptBlock:function(t,e){var i=t[e+1];t[e+1]=t[e+3],t[e+3]=i,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,r),i=t[e+1],t[e+1]=t[e+3],t[e+3]=i},_doCryptBlock:function(t,e,i,n,r,s,o,a){for(var h=this._nRounds,u=t[e]^i[0],c=t[e+1]^i[1],l=t[e+2]^i[2],f=t[e+3]^i[3],d=4,g=1;g>>24]^r[c>>>16&255]^s[l>>>8&255]^o[255&f]^i[d++],y=n[c>>>24]^r[l>>>16&255]^s[f>>>8&255]^o[255&u]^i[d++],v=n[l>>>24]^r[f>>>16&255]^s[u>>>8&255]^o[255&c]^i[d++];f=n[f>>>24]^r[u>>>16&255]^s[c>>>8&255]^o[255&l]^i[d++],u=p,c=y,l=v}p=(a[u>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&f])^i[d++],y=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[f>>>8&255]<<8|a[255&u])^i[d++],v=(a[l>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[255&c])^i[d++],f=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^i[d++],t[e]=p,t[e+1]=y,t[e+2]=v,t[e+3]=f},keySize:8});t.AES=e._createHelper(i)}(),function(){function t(t,e){var i=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=i,this._lBlock^=i<>>t^this._lBlock)&e;this._lBlock^=i,this._rBlock^=i<i;i++){var n=o[i]-1;e[i]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;16>n;n++){var r=t[n]=[],s=h[n];for(i=0;24>i;i++)r[i/6|0]|=e[(a[i]-1+s)%28]<<31-i%6,r[4+(i/6|0)]|=e[28+(a[i+24]-1+s)%28]<<31-i%6;for(r[0]=r[0]<<1|r[0]>>>31,i=1;7>i;i++)r[i]>>>=4*(i-1)+3;r[7]=r[7]<<5|r[7]>>>27}for(e=this._invSubKeys=[],i=0;16>i;i++)e[i]=t[15-i]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(i,n,r){this._lBlock=i[n],this._rBlock=i[n+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var o=r[s],a=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^o[f])&c[f])>>>0];this._lBlock=h,this._rBlock=a^l}r=this._lBlock,this._lBlock=this._rBlock,this._rBlock=r,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),i[n]=this._lBlock,i[n+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});i.DES=r._createHelper(l),s=s.TripleDES=r.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(n.create(t.slice(0,2))),this._des2=l.createEncryptor(n.create(t.slice(2,4))),this._des3=l.createEncryptor(n.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),i.TripleDES=r._createHelper(s)}(),function(){var t=y,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,i=t.sigBytes,n=this._map;t.clamp(),t=[];for(var r=0;r>>2]>>>24-r%4*8&255)<<16|(e[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|e[r+2>>>2]>>>24-(r+2)%4*8&255,o=0;4>o&&r+.75*o>>6*(3-o)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var i=t.length,n=this._map;(r=n.charAt(64))&&(-1!=(r=t.indexOf(r))&&(i=r));for(var r=[],s=0,o=0;o>>6-o%4*2;r[s>>>2]|=(a|h)<<24-s%4*8,s++}return e.create(r,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,i,n,r,s,o){return((t=t+(e&i|~e&n)+r+o)<>>32-s)+e}function i(t,e,i,n,r,s,o){return((t=t+(e&n|i&~n)+r+o)<>>32-s)+e}function n(t,e,i,n,r,s,o){return((t=t+(e^i^n)+r+o)<>>32-s)+e}function r(t,e,i,n,r,s,o){return((t=t+(i^(e|~n))+r+o)<>>32-s)+e}for(var s=y,o=(h=s.lib).WordArray,a=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var o=0;16>o;o++){var a=t[h=s+o];t[h]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var h=t[s+0],c=(a=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],d=t[s+5],g=t[s+6],p=t[s+7],y=t[s+8],v=t[s+9],m=t[s+10],S=t[s+11],F=t[s+12],w=t[s+13],E=t[s+14],x=t[s+15],b=e(b=o[0],C=o[1],I=o[2],A=o[3],h,7,u[0]),A=e(A,b,C,I,a,12,u[1]),I=e(I,A,b,C,c,17,u[2]),C=e(C,I,A,b,l,22,u[3]);b=e(b,C,I,A,f,7,u[4]),A=e(A,b,C,I,d,12,u[5]),I=e(I,A,b,C,g,17,u[6]),C=e(C,I,A,b,p,22,u[7]),b=e(b,C,I,A,y,7,u[8]),A=e(A,b,C,I,v,12,u[9]),I=e(I,A,b,C,m,17,u[10]),C=e(C,I,A,b,S,22,u[11]),b=e(b,C,I,A,F,7,u[12]),A=e(A,b,C,I,w,12,u[13]),I=e(I,A,b,C,E,17,u[14]),b=i(b,C=e(C,I,A,b,x,22,u[15]),I,A,a,5,u[16]),A=i(A,b,C,I,g,9,u[17]),I=i(I,A,b,C,S,14,u[18]),C=i(C,I,A,b,h,20,u[19]),b=i(b,C,I,A,d,5,u[20]),A=i(A,b,C,I,m,9,u[21]),I=i(I,A,b,C,x,14,u[22]),C=i(C,I,A,b,f,20,u[23]),b=i(b,C,I,A,v,5,u[24]),A=i(A,b,C,I,E,9,u[25]),I=i(I,A,b,C,l,14,u[26]),C=i(C,I,A,b,y,20,u[27]),b=i(b,C,I,A,w,5,u[28]),A=i(A,b,C,I,c,9,u[29]),I=i(I,A,b,C,p,14,u[30]),b=n(b,C=i(C,I,A,b,F,20,u[31]),I,A,d,4,u[32]),A=n(A,b,C,I,y,11,u[33]),I=n(I,A,b,C,S,16,u[34]),C=n(C,I,A,b,E,23,u[35]),b=n(b,C,I,A,a,4,u[36]),A=n(A,b,C,I,f,11,u[37]),I=n(I,A,b,C,p,16,u[38]),C=n(C,I,A,b,m,23,u[39]),b=n(b,C,I,A,w,4,u[40]),A=n(A,b,C,I,h,11,u[41]),I=n(I,A,b,C,l,16,u[42]),C=n(C,I,A,b,g,23,u[43]),b=n(b,C,I,A,v,4,u[44]),A=n(A,b,C,I,F,11,u[45]),I=n(I,A,b,C,x,16,u[46]),b=r(b,C=n(C,I,A,b,c,23,u[47]),I,A,h,6,u[48]),A=r(A,b,C,I,p,10,u[49]),I=r(I,A,b,C,E,15,u[50]),C=r(C,I,A,b,d,21,u[51]),b=r(b,C,I,A,F,6,u[52]),A=r(A,b,C,I,l,10,u[53]),I=r(I,A,b,C,m,15,u[54]),C=r(C,I,A,b,a,21,u[55]),b=r(b,C,I,A,y,6,u[56]),A=r(A,b,C,I,x,10,u[57]),I=r(I,A,b,C,g,15,u[58]),C=r(C,I,A,b,w,21,u[59]),b=r(b,C,I,A,f,6,u[60]),A=r(A,b,C,I,S,10,u[61]),I=r(I,A,b,C,c,15,u[62]),C=r(C,I,A,b,v,21,u[63]);o[0]=o[0]+b|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+A|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;i[r>>>5]|=128<<24-r%32;var s=t.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(i.length+1),this._process(),i=(e=this._hash).words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=a._createHelper(h),s.HmacMD5=a._createHmacHelper(h)}(Math),function(){var t=y,e=(r=t.lib).WordArray,i=r.Hasher,n=[],r=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=this._hash.words,r=i[0],s=i[1],o=i[2],a=i[3],h=i[4],u=0;80>u;u++){if(16>u)n[u]=0|t[e+u];else{var c=n[u-3]^n[u-8]^n[u-14]^n[u-16];n[u]=c<<1|c>>>31}c=(r<<5|r>>>27)+h+n[u],c=20>u?c+(1518500249+(s&o|~s&a)):40>u?c+(1859775393+(s^o^a)):60>u?c+((s&o|s&a|o&a)-1894007588):c+((s^o^a)-899497514),h=a,a=o,o=s<<30|s>>>2,s=r,r=c}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+o|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(i/4294967296),e[15+(n+64>>>9<<4)]=i,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=i._createHelper(r),t.HmacSHA1=i._createHmacHelper(r)}(),function(t){for(var e=y,i=(r=e.lib).WordArray,n=r.Hasher,r=e.algo,s=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=a(t.pow(h,.5))),o[u]=a(t.pow(h,1/3)),u++),h++}var d=[];r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(t,e){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],a=i[3],h=i[4],u=i[5],c=i[6],l=i[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var g=d[f-15],p=d[f-2];d[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[f-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[f-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+o[f]+d[f],p=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&r^n&s^r&s),l=c,c=u,u=h,h=a+g|0,a=s,s=r,r=n,n=g+p|0}i[0]=i[0]+n|0,i[1]=i[1]+r|0,i[2]=i[2]+s|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0,i[5]=i[5]+u|0,i[6]=i[6]+c|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return i[r>>>5]|=128<<24-r%32,i[14+(r+64>>>9<<4)]=t.floor(n/4294967296),i[15+(r+64>>>9<<4)]=n,e.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(r),e.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var t=y,e=t.lib.WordArray,i=(n=t.algo).SHA256,n=n.SHA224=i.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=i._createHelper(n),t.HmacSHA224=i._createHmacHelper(n)}(),function(){function t(){return n.create.apply(n,arguments)}for(var e=y,i=e.lib.Hasher,n=(s=e.x64).Word,r=s.WordArray,s=e.algo,o=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],a=[],h=0;80>h;h++)a[h]=t();s=s.SHA512=i.extend({_doReset:function(){this._hash=new r.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var i=(l=this._hash.words)[0],n=l[1],r=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=i.high,d=i.low,g=n.high,p=n.low,y=r.high,v=r.low,m=s.high,S=s.low,F=h.high,w=h.low,E=u.high,x=u.low,b=c.high,A=c.low,I=l.high,C=l.low,D=f,T=d,P=g,R=p,H=y,B=v,N=m,O=S,j=F,V=w,L=E,_=x,K=b,k=A,M=I,U=C,q=0;80>q;q++){var z=a[q];if(16>q)var G=z.high=0|t[e+2*q],Y=z.low=0|t[e+2*q+1];else{G=((Y=(G=a[q-15]).high)>>>1|(J=G.low)<<31)^(Y>>>8|J<<24)^Y>>>7;var J=(J>>>1|Y<<31)^(J>>>8|Y<<24)^(J>>>7|Y<<25),W=((Y=(W=a[q-2]).high)>>>19|(X=W.low)<<13)^(Y<<3|X>>>29)^Y>>>6,X=(X>>>19|Y<<13)^(X<<3|Y>>>29)^(X>>>6|Y<<26),Z=(Y=a[q-7]).high,$=(Q=a[q-16]).high,Q=Q.low;G=(G=(G=G+Z+((Y=J+Y.low)>>>0>>0?1:0))+W+((Y=Y+X)>>>0>>0?1:0))+$+((Y=Y+Q)>>>0>>0?1:0);z.high=G,z.low=Y}Z=j&L^~j&K,Q=V&_^~V&k,z=D&P^D&H^P&H;var tt=T&R^T&B^R&B,et=(J=(D>>>28|T<<4)^(D<<30|T>>>2)^(D<<25|T>>>7),W=(T>>>28|D<<4)^(T<<30|D>>>2)^(T<<25|D>>>7),(X=o[q]).high),it=X.low;$=M+((j>>>14|V<<18)^(j>>>18|V<<14)^(j<<23|V>>>9))+((X=U+((V>>>14|j<<18)^(V>>>18|j<<14)^(V<<23|j>>>9)))>>>0>>0?1:0),M=K,U=k,K=L,k=_,L=j,_=V,j=N+($=($=($=$+Z+((X=X+Q)>>>0>>0?1:0))+et+((X=X+it)>>>0>>0?1:0))+G+((X=X+Y)>>>0>>0?1:0))+((V=O+X|0)>>>0>>0?1:0)|0,N=H,O=B,H=P,B=R,P=D,R=T,D=$+(z=J+z+((Y=W+tt)>>>0>>0?1:0))+((T=X+Y|0)>>>0>>0?1:0)|0}d=i.low=d+T,i.high=f+D+(d>>>0>>0?1:0),p=n.low=p+R,n.high=g+P+(p>>>0>>0?1:0),v=r.low=v+B,r.high=y+H+(v>>>0>>0?1:0),S=s.low=S+O,s.high=m+N+(S>>>0>>0?1:0),w=h.low=w+V,h.high=F+j+(w>>>0>>0?1:0),x=u.low=x+_,u.high=E+L+(x>>>0<_>>>0?1:0),A=c.low=A+k,c.high=b+K+(A>>>0>>0?1:0),C=l.low=C+U,l.high=I+M+(C>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(i/4294967296),e[31+(n+128>>>10<<5)]=i,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=i._createHelper(s),e.HmacSHA512=i._createHmacHelper(s)}(),function(){var t=y,e=(r=t.x64).Word,i=r.WordArray,n=(r=t.algo).SHA512,r=r.SHA384=n.extend({_doReset:function(){this._hash=new i.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(r),t.HmacSHA384=n._createHmacHelper(r)}(),function(){var t=y,e=(n=t.lib).WordArray,i=n.Hasher,n=t.algo,r=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),o=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);n=n.RIPEMD160=i.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=0;16>i;i++){var n=t[F=e+i];t[F]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var c,l,f,d,g,p,y,v,m,S,F=this._hash.words,w=(n=h.words,u.words),E=r.words,x=s.words,b=o.words,A=a.words;p=c=F[0],y=l=F[1],v=f=F[2],m=d=F[3],S=g=F[4];var I;for(i=0;80>i;i+=1)I=c+t[e+E[i]]|0,I=16>i?I+((l^f^d)+n[0]):32>i?I+((l&f|~l&d)+n[1]):48>i?I+(((l|~f)^d)+n[2]):64>i?I+((l&d|f&~d)+n[3]):I+((l^(f|~d))+n[4]),I=(I=(I|=0)<>>32-b[i])+g|0,c=g,g=d,d=f<<10|f>>>22,f=l,l=I,I=p+t[e+x[i]]|0,I=16>i?I+((y^(v|~m))+w[0]):32>i?I+((y&m|v&~m)+w[1]):48>i?I+(((y|~v)^m)+w[2]):64>i?I+((y&v|~y&m)+w[3]):I+((y^v^m)+w[4]),I=(I=(I|=0)<>>32-A[i])+S|0,p=S,S=m,m=v<<10|v>>>22,v=y,y=I;I=F[1]+f+m|0,F[1]=F[2]+d+S|0,F[2]=F[3]+g+p|0,F[3]=F[4]+c+y|0,F[4]=F[0]+l+v|0,F[0]=I},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,i=0;5>i;i++)n=e[i],e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(n),t.HmacRIPEMD160=i._createHmacHelper(n)}(Math),function(){var t=y,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,i){t=this._hasher=new t.init,"string"==typeof i&&(i=e.parse(i));var n=t.blockSize,r=4*n;i.sigBytes>r&&(i=t.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),o=this._iKey=i.clone(),a=s.words,h=o.words,u=0;u>6)+m.charAt(63&i);if(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),n+=m.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),n+=m.charAt(i>>2)+m.charAt((3&i)<<4)),S)for(;(3&n.length)>0;)n+=S;return n}function w(t){var e,i,n,r="",s=0;for(e=0;e>2),i=3&n,s=1):1==s?(r+=T(i<<2|n>>4),i=15&n,s=2):2==s?(r+=T(i),r+=T(n>>2),i=3&n,s=3):(r+=T(i<<2|n>>4),r+=T(15&n),s=0));return 1==s&&(r+=T(i<<2)),r}function E(t){var e,i=w(t),n=new Array;for(e=0;2*e>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;r=((h=o*h+((32767&c)<<15)+i[n]+(1073741823&r))>>>30)+(c>>>15)+a*u+(r>>>30),i[n++]=1073741823&h}return r},v=30):"Netscape"!=i.appName?(x.prototype.am=function(t,e,i,n,r,s){for(;--s>=0;){var o=e*this[t++]+i[n]+r;r=Math.floor(o/67108864),i[n++]=67108863&o}return r},v=26):(x.prototype.am=function(t,e,i,n,r,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;r=((h=o*h+((16383&c)<<14)+i[n]+r)>>28)+(c>>14)+a*u,i[n++]=268435455&h}return r},v=28),x.prototype.DB=v,x.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function B(t){this.m=t}function N(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function K(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function k(){}function M(t){return t}function U(t){this.r2=b(),this.q3=b(),x.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}B.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},B.prototype.revert=function(t){return t},B.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},B.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},B.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},N.prototype.convert=function(t){var e=b();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(x.ZERO)>0&&this.m.subTo(e,e),e},N.prototype.revert=function(t){var e=b();return t.copyTo(e),this.reduce(e),e},N.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},N.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},N.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},x.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},x.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},x.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,r=!1,s=0;--n>=0;){var o=8==i?255&t[n]:P(t,n);o<0?"-"==t.charAt(n)&&(r=!0):(r=!1,0==s?this[this.t++]=o:s+i>this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},x.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},x.prototype.drShiftTo=function(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>r|a,a=(this[i]&s)<=0;--i)e[i]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},x.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,r=this.DB-n,s=(1<>n;for(var o=i+1;o>n;n>0&&(e[this.t-i-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},x.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),r=i.t;for(e.t=r+n.t;--r>=0;)e[r]=0;for(r=0;r=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},x.prototype.divRemTo=function(t,e,i){var n=t.abs();if(!(n.t<=0)){var r=this.abs();if(r.t0?(n.lShiftTo(h,s),r.lShiftTo(h,i)):(n.copyTo(s),r.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<1?s[u-2]>>this.F2:0),f=this.FV/l,d=(1<=0&&(i[i.t++]=1,i.subTo(v,i)),x.ONE.dlShiftTo(u,v),v.subTo(s,s);s.t=0;){var m=i[--p]==c?this.DM:Math.floor(i[p]*f+(i[p-1]+g)*d);if((i[p]+=s.am(0,m,i,y,0,u))0&&i.rShiftTo(h,i),o<0&&x.ZERO.subTo(i,i)}}},x.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},x.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},x.prototype.exp=function(t,e){if(t>4294967295||t<1)return x.ONE;var i=b(),n=b(),r=e.convert(this),s=H(t)-1;for(r.copyTo(i);--s>=0;)if(e.sqrTo(i,n),(t&1<0)e.mulTo(n,r,i);else{var o=i;i=n,n=o}return e.revert(i)},x.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<0)for(a>a)>0&&(r=!0,s=T(i));o>=0;)a>(a+=this.DB-e)):(i=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),i>0&&(r=!0),r&&(s+=T(i));return r?s:"0"},x.prototype.negate=function(){var t=b();return x.ZERO.subTo(this,t),t},x.prototype.abs=function(){return this.s<0?this.negate():this},x.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},x.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+H(this[this.t-1]^this.s&this.DM)},x.prototype.mod=function(t){var e=b();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(x.ZERO)>0&&t.subTo(e,e),e},x.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new B(e):new N(e),this.exp(t,i)},x.ZERO=R(0),x.ONE=R(1),k.prototype.convert=M,k.prototype.revert=M,k.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},k.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=b();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var q=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],z=(1<<26)/q[q.length-1]; -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function G(){this.i=0,this.j=0,this.S=new Array}x.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},x.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),n=R(i),r=b(),s=b(),o="";for(this.divRemTo(n,r,s);r.signum()>0;)o=(i+s.intValue()).toString(t).substr(1)+o,r.divRemTo(n,r,s);return s.intValue().toString(t)+o},x.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),r=!1,s=0,o=0,a=0;a=i&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),r&&x.ZERO.subTo(this,this)},x.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(x.ONE.shiftLeft(t-1),j,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(x.ONE.shiftLeft(t-1),this);else{var n=new Array,r=7&t;n.length=1+(t>>3),e.nextBytes(n),r>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},x.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},x.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},x.prototype.multiplyLowerTo=function(t,e,i){var n,r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r=0;)i[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},x.prototype.millerRabin=function(t){var e=this.subtract(x.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var n=e.shiftRight(i);(t=t+1>>1)>q.length&&(t=q.length);for(var r=b(),s=0;s>24},x.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},x.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},x.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,r=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[r++]=i|this.s<=0;)n<8?(i=(this[t]&(1<>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(e[r++]=i);return e},x.prototype.equals=function(t){return 0==this.compareTo(t)},x.prototype.min=function(t){return this.compareTo(t)<0?this:t},x.prototype.max=function(t){return this.compareTo(t)>0?this:t},x.prototype.and=function(t){var e=b();return this.bitwiseTo(t,O,e),e},x.prototype.or=function(t){var e=b();return this.bitwiseTo(t,j,e),e},x.prototype.xor=function(t){var e=b();return this.bitwiseTo(t,V,e),e},x.prototype.andNot=function(t){var e=b();return this.bitwiseTo(t,L,e),e},x.prototype.not=function(){for(var t=b(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var c=b();for(n.sqrTo(o[1],c);a<=u;)o[a]=b(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,d=t.t-1,g=!0,p=b();for(r=H(t[d])-1;d>=0;){for(r>=h?l=t[d]>>r-h&u:(l=(t[d]&(1<0&&(l|=t[d-1]>>this.DB+r-h)),a=i;0==(1&l);)l>>=1,--a;if((r-=a)<0&&(r+=this.DB,--d),g)o[l].copyTo(s),g=!1;else{for(;a>1;)n.sqrTo(s,p),n.sqrTo(p,s),a-=2;a>0?n.sqrTo(s,p):(f=s,s=p,p=f),n.mulTo(p,o[l],s)}for(;d>=0&&0==(t[d]&1<=0?(i.subTo(n,i),e&&r.subTo(o,r),s.subTo(a,s)):(n.subTo(i,n),e&&o.subTo(r,o),a.subTo(s,a))}return 0!=n.compareTo(x.ONE)?x.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},x.prototype.pow=function(t){return this.exp(t,new k)},x.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var r=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(r0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(r=e.getLowestSetBit())>0&&e.rShiftTo(r,e),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},x.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=q[q.length-1]){for(e=0;e>8&255,J[W++]^=t>>16&255,J[W++]^=t>>24&255,W>=X&&(W-=X)}((new Date).getTime())}if(null==J){var $;if(J=new Array,W=0,void 0!==n&&(void 0!==n.crypto||void 0!==n.msCrypto)){var Q=n.crypto||n.msCrypto;if(Q.getRandomValues){var tt=new Uint8Array(32);for(Q.getRandomValues(tt),$=0;$<32;++$)J[W++]=tt[$]}else if("Netscape"==i.appName&&i.appVersion<"5"){var et=n.crypto.random(32);for($=0;$>>8,J[W++]=255&$;W=0,Z()}function it(){if(null==Y){for(Z(),(Y=new G).init(J),W=0;W>24,(16711680&r)>>16,(65280&r)>>8,255&r]))),r+=1;return n}function ot(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function at(t,e,i){for(var n="",r=0;n.length>24,(16711680&r)>>16,(65280&r)>>8,255&r])),r+=1;return n} -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function ht(t,e){this.x=e,this.q=t}function ut(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?x.ONE:n,this.zinv=null}function ct(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new ut(this,null,null)}nt.prototype.nextBytes=function(t){var e;for(e=0;e0&&e.length>0))throw"Invalid RSA public key";this.n=rt(t,16),this.e=parseInt(e,16)}},ot.prototype.encrypt=function(t){var e=function(t,e){if(e=0&&e>0;){var r=t.charCodeAt(n--);r<128?i[--e]=r:r>127&&r<2048?(i[--e]=63&r|128,i[--e]=r>>6|192):(i[--e]=63&r|128,i[--e]=r>>6&63|128,i[--e]=r>>12|224)}i[--e]=0;for(var s=new nt,o=new Array;e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new x(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var n=i.toString(16);return 0==(1&n.length)?n:"0"+n},ot.prototype.encryptOAEP=function(t,e,i){var n=function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;if(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t.length+2*n+2>e)throw"Message too long for RSA";var a,h="";for(a=0;a>3,e,i);if(null==n)return null;var r=this.doPublic(n);if(null==r)return null;var s=r.toString(16);return 0==(1&s.length)?s:"0"+s},ot.prototype.type="RSA",ot.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},ot.prototype.setPrivate=function(t,e,i){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=i;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16)}},ot.prototype.setPrivateEx=function(t,e,i,n,r,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16),this.p=rt(n,16),this.q=rt(r,16),this.dmp1=rt(s,16),this.dmq1=rt(o,16),this.coeff=rt(a,16)},ot.prototype.generate=function(t,e){var i=new nt,n=t>>1;this.e=parseInt(e,16);for(var r=new x(e,16);;){for(;this.p=new x(t-n,1,i),0!=this.p.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.p.isProbablePrime(10););for(;this.q=new x(n,1,i),0!=this.q.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(x.ONE),a=this.q.subtract(x.ONE),h=o.multiply(a);if(0==h.gcd(r).compareTo(x.ONE)){this.n=this.p.multiply(this.q),this.d=r.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},ot.prototype.decrypt=function(t){var e=rt(t,16),i=this.doPrivate(e);return null==i?null: -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function(t,e){for(var i=t.toByteArray(),n=0;n=i.length)return null;for(var r="";++n191&&s<224?(r+=String.fromCharCode((31&s)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&s)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},ot.prototype.decryptOAEP=function(t,e,i){var n=rt(t,16),r=this.doPrivate(n);return null==r?null:function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;for(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t=t.toByteArray(),a=0;a>3,e,i)},ht.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ht.prototype.toBigInteger=function(){return this.x},ht.prototype.negate=function(){return new ht(this.q,this.x.negate().mod(this.q))},ht.prototype.add=function(t){return new ht(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ht.prototype.subtract=function(t){return new ht(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ht.prototype.multiply=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ht.prototype.square=function(){return new ht(this.q,this.x.square().mod(this.q))},ht.prototype.divide=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ut.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO))},ut.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(x.ZERO)&&!this.y.toBigInteger().equals(x.ZERO)},ut.prototype.negate=function(){return new ut(this.curve,this.x,this.y.negate(),this.z)},ut.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),i=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(x.ZERO.equals(i))return x.ZERO.equals(e)?this.twice():this.curve.getInfinity();var n=new x("3"),r=this.x.toBigInteger(),s=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),i.square()),a=o.multiply(i),h=r.multiply(o),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(a).multiply(i).mod(this.curve.q),l=h.multiply(n).multiply(e).subtract(s.multiply(a)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),f=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},ut.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new x("3"),e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=i.multiply(this.z),r=n.multiply(i).mod(this.curve.q),s=this.curve.a.toBigInteger(),o=e.square().multiply(t);x.ZERO.equals(s)||(o=o.add(this.z.square().multiply(s)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(r)).shiftLeft(1).multiply(n).mod(this.curve.q),h=o.multiply(t).multiply(e).subtract(r.shiftLeft(1)).shiftLeft(2).multiply(r).subtract(o.square().multiply(o)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),u)},ut.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add(o?this:r))}return s},ut.prototype.multiplyTwo=function(t,e,i){var n;n=t.bitLength()>i.bitLength()?t.bitLength()-1:i.bitLength()-1;for(var r=this.curve.getInfinity(),s=this.add(e);n>=0;)r=r.twice(),t.testBit(n)?r=i.testBit(n)?r.add(s):r.add(this):i.testBit(n)&&(r=r.add(e)),--n;return r},ct.prototype.getQ=function(){return this.q},ct.prototype.getA=function(){return this.a},ct.prototype.getB=function(){return this.b},ct.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ct.prototype.getInfinity=function(){return this.infinity},ct.prototype.fromBigInteger=function(t){return new ht(this.q,t)},ct.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,i=t.substr(2,e),n=t.substr(e+2,e);return new ut(this,this.fromBigInteger(new x(i,16)),this.fromBigInteger(new x(n,16)));default:return null}}, -/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib - */ -ht.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ut.prototype.getEncoded=function(t){var e=function(t,e){var i=t.toByteArrayUnsigned();if(ei.length;)i.unshift(0);return i},i=this.getX().toBigInteger(),n=this.getY().toBigInteger(),r=e(i,32);return t?n.isEven()?r.unshift(2):r.unshift(3):(r.unshift(4),r=r.concat(e(n,32))),r},ut.decodeFrom=function(t,e){e[0];var i=e.length-1,n=e.slice(1,1+i/2),r=e.slice(1+i/2,1+i);n.unshift(0),r.unshift(0);var s=new x(n),o=new x(r);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.decodeFromHex=function(t,e){e.substr(0,2);var i=e.length-2,n=e.substr(2,i/2),r=e.substr(2+i/2,i/2),s=new x(n,16),o=new x(r,16);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),i=t.y.subtract(this.y).divide(e),n=i.square().subtract(this.x).subtract(t.x),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(x.valueOf(2)),e=this.curve.fromBigInteger(x.valueOf(3)),i=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=i.square().subtract(this.x.multiply(t)),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add2D(o?this:r))}return s},ut.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),i=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),r=this.curve.getQ(),s=e.multiply(e).mod(r),o=t.multiply(t).multiply(t).add(i.multiply(t)).add(n).mod(r);return s.equals(o)},ut.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ut.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),i=this.getY().toBigInteger();if(e.compareTo(x.ONE)<0||e.compareTo(t.subtract(x.ONE))>0)throw new Error("x coordinate out of bounds");if(i.compareTo(x.ONE)<0||i.compareTo(t.subtract(x.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0}; -/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval - */ -var lt=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),i={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,n){return e?i[e]:String.fromCharCode(parseInt(n,16))}var r=new String(""),s=(Object,Array,Object.hasOwnProperty);return function(i,o){var a,h,u=i.match(t),c=u[0],l=!1;"{"===c?a={}:"["===c?a=[]:(a=[],l=!0);for(var f=[a],d=1-l,g=u.length;d=0;)delete i[n[h]]}return o.call(t,e,i)};a=y({"":a},"")}return a}}();void 0!==ft&&ft||(ft={}),void 0!==ft.asn1&&ft.asn1||(ft.asn1={}),ft.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},ft.asn1.DERAbstractString=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=bt(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},r.lang.extend(ft.asn1.DERAbstractString,ft.asn1.ASN1Object),ft.asn1.DERAbstractTime=function(t){ft.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var n=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var h=n(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=St(t)},this.setByDateValue=function(t,e,i,n,r,s){var o=new Date(Date.UTC(t,e-1,i,n,r,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},r.lang.extend(ft.asn1.DERAbstractTime,ft.asn1.ASN1Object),ft.asn1.DERAbstractStructured=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},r.lang.extend(ft.asn1.DERAbstractStructured,ft.asn1.ASN1Object),ft.asn1.DERBoolean=function(){ft.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},r.lang.extend(ft.asn1.DERBoolean,ft.asn1.ASN1Object),ft.asn1.DERInteger=function(t){ft.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ft.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},r.lang.extend(ft.asn1.DERInteger,ft.asn1.ASN1Object),ft.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ft.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}ft.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7r.length&&(r=n[i]);return(t=t.replace(r,"::")).slice(1,-1)}function _t(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?Lt(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function Kt(t){for(var e=encodeURIComponent(t),i="",n=0;n"7"?"00"+t:t}function Mt(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,i){var n=parseInt(t);if(n<0||255=2*s)break;if(a>=200)break;n.push(h),o=h,a++}return n},pt.getNthChildIdx=function(t,e,i){return pt.getChildIdx(t,e)[i]},pt.getIdxbyList=function(t,e,i,n){var r,s,o=pt;if(0==i.length){if(void 0!==n&&t.substr(e,2)!==n)throw"checking tag doesn't match: "+t.substr(e,2)+"!="+n;return e}return r=i.shift(),s=o.getChildIdx(t,e),o.getIdxbyList(t,s[r],i,n)},pt.getTLVbyList=function(t,e,i,n){var r=pt,s=r.getIdxbyList(t,e,i);if(void 0===s)throw"can't find nthList object";if(void 0!==n&&t.substr(s,2)!=n)throw"checking tag doesn't match: "+t.substr(s,2)+"!="+n;return r.getTLV(t,s)},pt.getVbyList=function(t,e,i,n,r){var s,o,a=pt;if(void 0===(s=a.getIdxbyList(t,e,i,n)))throw"can't find nthList object";return o=a.getV(t,s),!0===r&&(o=o.substr(2)),o},pt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},i=[],n=t.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var s=t.substr(2),o=[],a=0;a0&&(c=c+"."+h.join(".")),c},pt.dump=function(t,e,i,n){var r=pt,s=r.getV,o=r.dump,a=r.getChildIdx,h=t;t instanceof ft.asn1.ASN1Object&&(h=t.getEncodedHex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var c=e.ommit_long_octet;if("01"==h.substr(i,2))return"00"==(l=s(h,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==h.substr(i,2))return n+"INTEGER "+u(l=s(h,i),c)+"\n";if("03"==h.substr(i,2))return n+"BITSTRING "+u(l=s(h,i),c)+"\n";if("04"==h.substr(i,2)){var l=s(h,i);if(r.isASN1HEX(l)){var f=n+"OCTETSTRING, encapsulates\n";return f+=o(l,e,0,n+" ")}return n+"OCTETSTRING "+u(l,c)+"\n"}if("05"==h.substr(i,2))return n+"NULL\n";if("06"==h.substr(i,2)){var d=s(h,i),g=ft.asn1.ASN1Util.oidHexToInt(d),p=ft.asn1.x509.OID.oid2name(g),y=g.replace(/\./g," ");return""!=p?n+"ObjectIdentifier "+p+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0c"==h.substr(i,2))return n+"UTF8String '"+At(s(h,i))+"'\n";if("13"==h.substr(i,2))return n+"PrintableString '"+At(s(h,i))+"'\n";if("14"==h.substr(i,2))return n+"TeletexString '"+At(s(h,i))+"'\n";if("16"==h.substr(i,2))return n+"IA5String '"+At(s(h,i))+"'\n";if("17"==h.substr(i,2))return n+"UTCTime "+At(s(h,i))+"\n";if("18"==h.substr(i,2))return n+"GeneralizedTime "+At(s(h,i))+"\n";if("30"==h.substr(i,2)){if("3000"==h.substr(i,4))return n+"SEQUENCE {}\n";f=n+"SEQUENCE\n";var v=e;if((2==(F=a(h,i)).length||3==F.length)&&"06"==h.substr(F[0],2)&&"04"==h.substr(F[F.length-1],2)){p=r.oidname(s(h,F[0]));var m=JSON.parse(JSON.stringify(e));m.x509ExtName=p,v=m}for(var S=0;S0){var e=new i({array:this.extensionsArray}),n=new r({explicit:!0,tag:"a3",obj:e});this.asn1Array.push(n)}var s=new i({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertificate,ft.asn1.ASN1Object),ft.asn1.x509.Extension=function(t){ft.asn1.x509.Extension.superclass.constructor.call(this);var e=ft.asn1,i=e.DERObjectIdentifier,n=e.DEROctetString,r=(e.DERBitString,e.DERBoolean),s=e.DERSequence;this.getEncodedHex=function(){var t=new i({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new r),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},r.lang.extend(ft.asn1.x509.Extension,ft.asn1.ASN1Object),ft.asn1.x509.Extension.appendByNameToArray=function(t,e,i){var n=t.toLowerCase(),r=ft.asn1.x509;if("basicconstraints"==n){var s=new r.BasicConstraints(e);i.push(s)}else if("keyusage"==n){s=new r.KeyUsage(e);i.push(s)}else if("crldistributionpoints"==n){s=new r.CRLDistributionPoints(e);i.push(s)}else if("extkeyusage"==n){s=new r.ExtKeyUsage(e);i.push(s)}else if("authoritykeyidentifier"==n){s=new r.AuthorityKeyIdentifier(e);i.push(s)}else if("authorityinfoaccess"==n){s=new r.AuthorityInfoAccess(e);i.push(s)}else if("subjectaltname"==n){s=new r.SubjectAltName(e);i.push(s)}else{if("issueraltname"!=n)throw"unsupported extension name: "+t;s=new r.IssuerAltName(e);i.push(s)}},ft.asn1.x509.KeyUsage=function(t){ft.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Jt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new ft.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var i=t.names,n="000000000",r=0;r-1&&t.push(new ft.asn1.DERInteger({int:this.pathLen}));var e=new ft.asn1.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},r.lang.extend(ft.asn1.x509.BasicConstraints,ft.asn1.x509.Extension),ft.asn1.x509.CRLDistributionPoints=function(t){ft.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ft.asn1,i=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){this.asn1ExtnValue=new e.DERSequence({array:t})},this.setByOneURI=function(t){var e=new i.GeneralNames([{uri:t}]),n=new i.DistributionPointName(e),r=new i.DistributionPoint({dpobj:n});this.setByDPArray([r])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},r.lang.extend(ft.asn1.x509.CRLDistributionPoints,ft.asn1.x509.Extension),ft.asn1.x509.ExtKeyUsage=function(t){ft.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=ft.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var i=0;i0){var t=new i({array:this.aRevokedCert});this.asn1Array.push(t)}var e=new i({array:this.asn1Array});return this.hTLV=e.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize=function(){this.asn1Version=null,this.asn1SignatureAlg=null,this.asn1Issuer=null,this.asn1ThisUpdate=null,this.asn1NextUpdate=null,this.aRevokedCert=new Array},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertList,ft.asn1.ASN1Object),ft.asn1.x509.CRLEntry=function(t){ft.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=ft.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},r.lang.extend(ft.asn1.x509.CRLEntry,ft.asn1.ASN1Object),ft.asn1.x509.X500Name=function(t){ft.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=new Array;var e=ft.asn1,i=e.x509,n=Ht;if(this.setByString=function(t){var e=t.split("/");e.shift();for(var n=[],r=0;r0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},ft.asn1.x509.RDN=function(t){ft.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=new Array,this.addByString=function(t){this.asn1Array.push(new ft.asn1.x509.AttributeTypeAndValue({str:t}))},this.addByMultiValuedString=function(t){for(var e=ft.asn1.x509.RDN.parseString(t),i=0;i0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var a=!1,h=[];for(r=0;n.length>0;r++){s=n.shift();if(!0===a){var u=h.pop();if(s.match(/"$/)){o=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(o),a=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(a=!0)}return h},ft.asn1.x509.AttributeTypeAndValue=function(t){ft.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var e=ft.asn1;this.setByString=function(t){var e=t.match(/^([^=]+)=(.+)$/);if(!e)throw"malformed attrTypeAndValueStr: "+t;this.setByAttrTypeAndValueStr(e[1],e[2])},this.setByAttrTypeAndValueStr=function(t,e){this.typeObj=ft.asn1.x509.OID.atype2obj(t);var i="utf8";"C"==t&&(i="prn"),this.valueObj=this.getValueObj(i,e)},this.getValueObj=function(t,i){if("utf8"==t)return new e.DERUTF8String({str:i});if("prn"==t)return new e.DERPrintableString({str:i});if("tel"==t)return new e.DERTeletexString({str:i});if("ia5"==t)return new e.DERIA5String({str:i});throw"unsupported directory string type: type="+t+" value="+i},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.typeObj,this.valueObj]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&void 0!==t.str&&this.setByString(t.str)},r.lang.extend(ft.asn1.x509.AttributeTypeAndValue,ft.asn1.ASN1Object),ft.asn1.x509.SubjectPublicKeyInfo=function(t){ft.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ft,i=e.asn1,n=i.DERInteger,r=i.DERBitString,s=i.DERObjectIdentifier,o=i.DERSequence,a=i.ASN1Util.newObject,h=i.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof ot){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+e})}}catch(t){}try{if(t instanceof ft.crypto.ECDSA){var i=new s({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ft.crypto.DSA){i=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new h({name:"dsa",asn1params:i});var o=new n({bigint:t.y});this.asn1SubjPKey=new r({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},r.lang.extend(ft.asn1.x509.SubjectPublicKeyInfo,ft.asn1.ASN1Object),ft.asn1.x509.Time=function(t){ft.asn1.x509.Time.superclass.constructor.call(this);var e=ft.asn1,i=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},r.lang.extend(ft.asn1.x509.Time,ft.asn1.ASN1Object),ft.asn1.x509.AlgorithmIdentifier=function(t){ft.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ft.asn1;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw"algorithm not specified";null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var t=[this.asn1Alg];null!==this.asn1Params&&t.push(this.asn1Params);var i=new e.DERSequence({array:t});return this.hTLV=i.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},r.lang.extend(ft.asn1.x509.AlgorithmIdentifier,ft.asn1.ASN1Object),ft.asn1.x509.GeneralName=function(t){ft.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=ft.asn1,n=(i.DERSequence,i.DEROctetString),r=i.DERIA5String,s=i.DERTaggedObject,o=i.ASN1Object,a=i.x509.X500Name,h=Ht;this.explicit=!1,this.setByParam=function(t){var i=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",i=new r({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",i=new r({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",i=new r({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,i=new a({str:t.dn})),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var u=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certissuer param not cert";(f=new Jt).hex=u;var c=f.getIssuerHex();(i=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;u=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certsubj param not cert";(f=new Jt).hex=u;c=f.getSubjectHex();(i=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,g=t.ip,p="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(d=Mt("["+g.split(".").join(",")+"]")).length)throw p}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=Vt(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw p;d=g}i=new n({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},r.lang.extend(ft.asn1.x509.GeneralName,ft.asn1.ASN1Object),ft.asn1.x509.GeneralNames=function(t){ft.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ft.asn1;this.setByParamArray=function(t){for(var i=0;i0&&(e=new n({obj:this.dUnsignedAttrs,tag:"a1",explicit:!1}));var r=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,t,this.dSigAlg,this.dSig];null!=e&&r.push(e);var o=new i.DERSequence({array:r});return this.hTLV=o.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.SignerInfo,ft.asn1.ASN1Object),ft.asn1.cms.EncapsulatedContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.dEContentType=new r({name:"data"}),this.dEContent=null,this.isDetached=!1,this.eContentValueHex=null,this.setContentType=function(t){t.match(/^[0-2][.][0-9.]+$/)?this.dEContentType=new r({oid:t}):this.dEContentType=new r({name:t})},this.setContentValue=function(t){void 0!==t&&("string"==typeof t.hex?this.eContentValueHex=t.hex:"string"==typeof t.str&&(this.eContentValueHex=bt(t.str)))},this.setContentValueHex=function(t){this.eContentValueHex=t},this.setContentValueStr=function(t){this.eContentValueHex=bt(t)},this.getEncodedHex=function(){if("string"!=typeof this.eContentValueHex)throw"eContentValue not yet set";var t=new s({hex:this.eContentValueHex});this.dEContent=new i({obj:t,tag:"a0",explicit:!0});var e=[this.dEContentType];this.isDetached||e.push(this.dEContent);var r=new n({array:e});return this.hTLV=r.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.EncapsulatedContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.ContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.x509;ft.asn1.cms.ContentInfo.superclass.constructor.call(this),this.dContentType=null,this.dContent=null,this.setContentType=function(t){"string"==typeof t&&(this.dContentType=r.OID.name2obj(t))},this.getEncodedHex=function(){var t=new i({obj:this.dContent,tag:"a0",explicit:!0}),e=new n({array:[this.dContentType,t]});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t&&(t.type&&this.setContentType(t.type),t.obj&&t.obj instanceof e.ASN1Object&&(this.dContent=t.obj))},r.lang.extend(ft.asn1.cms.ContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.SignedData=function(t){var e=ft.asn1,i=e.ASN1Object,n=e.DERInteger,r=e.DERSet,s=e.DERSequence,o=e.DERTaggedObject,a=e.cms,h=a.EncapsulatedContentInfo,u=a.SignerInfo,c=a.ContentInfo,l=e.x509.AlgorithmIdentifier;ft.asn1.cms.SignedData.superclass.constructor.call(this),this.dCMSVersion=new n({int:1}),this.dDigestAlgs=null,this.digestAlgNameList=[],this.dEncapContentInfo=new h,this.dCerts=null,this.certificateList=[],this.crlList=[],this.signerInfoList=[new u],this.addCertificatesByPEM=function(t){var e=Ht(t),n=new i;n.hTLV=e,this.certificateList.push(n)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(null==this.dDigestAlgs){for(var t=[],e=0;e0){var h=new r({array:this.certificateList});this.dCerts=new o({obj:h,tag:"a0",explicit:!1})}null!=this.dCerts&&a.push(this.dCerts);var u=new r({array:this.signerInfoList});a.push(u);var c=new s({array:a});return this.hTLV=c.getEncodedHex(),this.hTLV},this.getContentInfo=function(){return this.getEncodedHex(),new c({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},this.getPEM=function(){return Rt(this.getContentInfoEncodedHex(),"CMS")}},r.lang.extend(ft.asn1.cms.SignedData,ft.asn1.ASN1Object),ft.asn1.cms.CMSUtil=new function(){},ft.asn1.cms.CMSUtil.newSignedData=function(t){var e=ft.asn1,i=e.cms,n=i.SignerInfo,r=i.SignedData,s=i.SigningTime,o=i.SigningCertificate,a=i.SigningCertificateV2,h=e.cades.SignaturePolicyIdentifier,u=new r;if(u.dEncapContentInfo.setContentValue(t.content),"object"==typeof t.certs)for(var c=0;c0){var t=new n({array:this.extensionsArray}),e=new r({array:[t]}),i=new n({array:[new a({oid:"1.2.840.113549.1.9.14"}),e]}),h=new o({explicit:!0,tag:"a0",obj:i});this.asn1Array.push(h)}else{h=new o({explicit:!1,tag:"a0",obj:new s});this.asn1Array.push(h)}var u=new n({array:this.asn1Array});return this.hTLV=u.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.csr.CertificationRequestInfo,ft.asn1.ASN1Object),ft.asn1.csr.CSRUtil=new function(){},ft.asn1.csr.CSRUtil.newCSRPEM=function(t){var e=Ut,i=ft.asn1.csr;if(void 0===t.subject)throw"parameter subject undefined";if(void 0===t.sbjpubkey)throw"parameter sbjpubkey undefined";if(void 0===t.sigalg)throw"parameter sigalg undefined";if(void 0===t.sbjprvkey)throw"parameter sbjpubkey undefined";var n=new i.CertificationRequestInfo;if(n.setSubjectByParam(t.subject),n.setSubjectPublicKeyByGetKey(t.sbjpubkey),void 0!==t.ext&&void 0!==t.ext.length)for(var r=0;rr)throw"key is too short for SigAlg: keylen="+i+","+e;for(var s="0001",o="00"+n,a="",h=r-s.length-o.length,u=0;u=0)return!1;if(i.compareTo(x.ONE)<0||i.compareTo(r)>=0)return!1;var o=i.modInverse(r),a=t.multiply(o).mod(r),h=e.multiply(o).mod(r);return s.multiply(a).add(n.multiply(h)).getX().toBigInteger().mod(r).equals(e)},this.serializeSig=function(t,e){var i=t.toByteArraySigned(),n=e.toByteArraySigned(),r=[];return r.push(2),r.push(i.length),(r=r.concat(i)).push(2),r.push(n.length),(r=r.concat(n)).unshift(r.length),r.unshift(48),r},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:x.fromByteArrayUnsigned(i),s:x.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:x.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:x.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[2,0],"06"),i=o(t,0,[1],"04");try{n=o(t,0,[3,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#1/5 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{o(t,0,[1,0],"06"),e=o(t,0,[1,1],"06"),i=o(t,0,[2,0,1],"04");try{n=o(t,0,[2,0,2,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#8 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){var e,i,n=pt,r=ft.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{s(t,0,[0,0],"06"),e=s(t,0,[0,1],"06"),i=s(t,0,[1],"03").substr(2)}catch(t){throw"malformed PKCS#8 ECC public key"}if(this.curveName=r(e),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,e){5!==e&&(e=6);var i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{i=o(t,0,[0,e,0,1],"06"),n=o(t,0,[0,e,1],"03").substr(2)}catch(t){throw"malformed X.509 certificate ECC public key"}if(this.curveName=s(i),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ft.crypto.ECDSA.parseSigHex=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new x(e.r,16),s:new x(e.s,16)}},ft.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=pt,i=e.getChildIdx,n=e.getV;if("30"!=t.substr(0,2))throw"signature is not a ASN.1 sequence";var r=i(t,0);if(2!=r.length)throw"number of signature ASN.1 sequence elements seem wrong";var s=r[0],o=r[1];if("02"!=t.substr(s,2))throw"1st item of sequene of signature is not ASN.1 integer";if("02"!=t.substr(o,2))throw"2nd item of sequene of signature is not ASN.1 integer";return{r:n(t,s),s:n(t,o)}},ft.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t),i=e.r,n=e.s;if("00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),i.length%32==30&&(i="00"+i),n.length%32==30&&(n="00"+n),i.length%32!=0)throw"unknown ECDSA sig r length error";if(n.length%32!=0)throw"unknown ECDSA sig s length error";return i+n},ft.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var e=t.substr(0,t.length/2),i=t.substr(t.length/2);return ft.crypto.ECDSA.hexRSSigToASN1Sig(e,i)},ft.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var i=new x(t,16),n=new x(e,16);return ft.crypto.ECDSA.biRSSigToASN1Sig(i,n)},ft.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var i=ft.asn1,n=new i.DERInteger({bigint:t}),r=new i.DERInteger({bigint:e});return new i.DERSequence({array:[n,r]}).getEncodedHex()},ft.crypto.ECDSA.getName=function(t){return"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040022"===t?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":null},void 0!==ft&&ft||(ft={}),void 0!==ft.crypto&&ft.crypto||(ft.crypto={}),ft.crypto.ECParameterDB=new function(){var t={},e={};function i(t){return new x(t,16)}this.getByName=function(i){var n=i;if(void 0!==e[n]&&(n=e[i]),void 0!==t[n])return t[n];throw"unregistered EC curve name: "+n},this.regist=function(n,r,s,o,a,h,u,c,l,f,d,g){t[n]={};var p=i(s),y=i(o),v=i(a),m=i(h),S=i(u),F=new ct(p,y,v),w=F.decodePointHex("04"+c+l);t[n].name=n,t[n].keylen=r,t[n].curve=F,t[n].G=w,t[n].n=m,t[n].h=S,t[n].oid=d,t[n].info=g;for(var E=0;E1?new x(n,16):null,u=new x(r,16),this.setPrivate(s,o,a,h,u)},this.setPublic=function(t,e,i,n){this.isPublic=!0,this.p=t,this.q=e,this.g=i,this.y=n,this.x=null},this.setPublicHex=function(t,e,i,n){var r,s,o,a;r=new x(t,16),s=new x(e,16),o=new x(i,16),a=new x(n,16),this.setPublic(r,s,o,a)},this.signWithMessageHash=function(t){var e=this.p,i=this.q,n=this.g,r=(this.y,this.x),s=ft.crypto.Util.getRandomBigIntegerMinToMax(x.ONE.add(x.ONE),i.subtract(x.ONE)),o=new x(t.substr(0,i.bitLength()/4),16),a=n.modPow(s,e).mod(i),h=s.modInverse(i).multiply(o.add(r.multiply(a))).mod(i);return ft.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:a}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var i=this.p,n=this.q,r=this.g,s=this.y,o=this.parseASN1Signature(e),a=o[0],h=o[1],u=new x(t.substr(0,n.bitLength()/4),16);if(x.ZERO.compareTo(a)>0||a.compareTo(n)>0)throw"invalid DSA signature";if(x.ZERO.compareTo(h)>=0||h.compareTo(n)>0)throw"invalid DSA signature";var c=h.modInverse(n),l=u.multiply(c).mod(n),f=a.multiply(c).mod(n);return 0==r.modPow(l,i).multiply(s.modPow(f,i)).mod(i).mod(n).compareTo(a)},this.parseASN1Signature=function(t){try{return[new x(pt.getVbyList(t,0,[0],"02"),16),new x(pt.getVbyList(t,0,[1],"02"),16)]}catch(t){throw"malformed ASN.1 DSA signature"}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r,s,o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{e=a(t,0,[1],"02"),i=a(t,0,[2],"02"),n=a(t,0,[3],"02"),r=a(t,0,[4],"02"),s=a(t,0,[5],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#1/5 plain DSA private key"}this.setPrivateHex(e,i,n,r,s)},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[1,1,0],"02"),i=o(t,0,[1,1,1],"02"),n=o(t,0,[1,1,2],"02"),r=o(t,0,[2,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 plain DSA private key"}this.setPrivateHex(e,i,n,null,r)},this.readPKCS8PubKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[0,1,0],"02"),i=o(t,0,[0,1,1],"02"),n=o(t,0,[0,1,2],"02"),r=o(t,0,[1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 DSA public key"}this.setPublicHex(e,i,n,r)},this.readCertPubKeyHex=function(t,e){var i,n,r,s;5!==e&&(e=6);var o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{i=a(t,0,[0,e,0,1,0],"02"),n=a(t,0,[0,e,0,1,1],"02"),r=a(t,0,[0,e,0,1,2],"02"),s=a(t,0,[0,e,1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed X.509 certificate DSA public key"}this.setPublicHex(i,n,r,s)}};var Ut=function(){var t=function(t,i,n){return e(y.AES,t,i,n)},e=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=r;var h=t.decrypt(a,s,{iv:o});return y.enc.Hex.stringify(h)},i=function(t,e,i){return n(y.AES,t,e,i)},n=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a=t.encrypt(r,s,{iv:o}),h=y.enc.Hex.parse(a.toString());return y.enc.Base64.stringify(h)},r={"AES-256-CBC":{proc:t,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,i,n){return e(y.TripleDES,t,i,n)},eproc:function(t,e,i){return n(y.TripleDES,t,e,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,i,n){return e(y.DES,t,i,n)},eproc:function(t,e,i){return n(y.DES,t,e,i)},keylen:8,ivlen:8}},s=function(t){var e={},i=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(e.cipher=i[1],e.ivsalt=i[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var r=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(r=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(r=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=r&&-1!=o){var a=t.substring(r+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,i){for(var n=i.substring(0,16),s=y.enc.Hex.parse(n),o=y.enc.Utf8.parse(e),a=r[t].keylen+r[t].ivlen,h="",u=null;;){var c=y.algo.MD5.create();if(null!=u&&c.update(u),c.update(o),c.update(s),u=c.finalize(),(h+=y.enc.Hex.stringify(u)).length>=2*a)break}var l={};return l.keyhex=h.substr(0,2*r[t].keylen),l.ivhex=h.substr(2*r[t].keylen,2*r[t].ivlen),l},a=function(t,e,i,n){var s=y.enc.Base64.parse(t),o=y.enc.Hex.stringify(s);return(0,r[e].proc)(o,i,n)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,i){return o(t,e,i)},decryptKeyB64:function(t,e,i,n){return a(t,e,i,n)},getDecryptedKeyHex:function(t,e){var i=s(t),n=(i.type,i.cipher),r=i.ivsalt,h=i.data,u=o(n,e,r).keyhex;return a(h,n,u,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,i,n,s){var a="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===r[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==s&&null!=s||(s=function(t){var e=y.lib.WordArray.random(t);return y.enc.Hex.stringify(e)}(r[n].ivlen).toUpperCase());var h=function(t,e,i,n){return(0,r[e].eproc)(t,i,n)}(e,n,o(n,i,s).keyhex,s);a="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+n+","+s+"\r\n",a+="\r\n",a+=h.replace(/(.{64})/g,"$1\r\n"),a+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={},s=i(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;r.ciphertext=n(t,s[1]);var o=i(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=i(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var h=i(t,a[1]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length;if("2a864886f70d0307"!=n(t,h[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(t,h[1]);var u=i(t,a[0]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length;if("2a864886f70d01050c"!=n(t,u[0]))throw"this only supports pkcs5PBKDF2";var c=i(t,u[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;r.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{r.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return r},getPBKDF2KeyHexFromParam:function(t,e){var i=y.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,r=y.PBKDF2(e,i,{keySize:6,iterations:n});return y.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var i=Ht(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=Ut.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=y.enc.Hex.parse(n.ciphertext);var o=y.enc.Hex.parse(r),a=y.enc.Hex.parse(n.encryptionSchemeIV),h=y.TripleDES.decrypt(s,o,{iv:a});return y.enc.Hex.stringify(h)},getKeyFromEncryptedPKCS8PEM:function(t,e){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var s=i(t,0);if(3!=s.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(s[1],2))throw"malformed PKCS8 private key(code:003)";var o=i(t,s[1]);if(2!=o.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(o[0],2))throw"malformed PKCS8 private key(code:005)";if(r.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(r.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw"malformed PKCS8 private key(code:006)";return r.keyidx=e.getVidx(t,s[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Ht(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,i=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==i.algoid)e=new ot;else if("2a8648ce380401"==i.algoid)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";e=new ft.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,i=pt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===i)e=new ot;else if("2a8648ce380401"===i)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";e=new ft.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=i(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(r.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return r.e=n(t,s[1]),r},parsePublicPKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null},s=i(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=i(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?r.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(r.algparam={},r.algparam.p=e.getVbyList(t,a[1],[0],"02"),r.algparam.q=e.getVbyList(t,a[1],[1],"02"),r.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(t,s[1]).substr(2),r}}}();Ut.getKey=function(t,e,i){var n=(y=pt).getChildIdx,r=(y.getV,y.getVbyList),s=ft.crypto,o=s.ECDSA,a=s.DSA,h=ot,u=Ht,c=Ut;if(void 0!==h&&t instanceof h)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(t.n,t.e),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(D=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(D=new h).setPrivate(t.n,t.e,t.d),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(D=new a).setPublic(t.p,t.q,t.g,t.y),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(D=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(xt(t.n),xt(t.e)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(D=new h).setPrivateEx(xt(t.n),xt(t.e),xt(t.d),xt(t.p),xt(t.q),xt(t.dp),xt(t.dq),xt(t.qi)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(D=new h).setPrivate(xt(t.n),xt(t.e),xt(t.d)),D;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);return C.setPublicKeyHex(f),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);var d=("0000000000"+xt(t.d)).slice(-l);return C.setPublicKeyHex(f),C.setPrivateKeyHex(d),C}if("pkcs5prv"===i){var g,p=t,y=pt;if(9===(g=n(p,0)).length)(D=new h).readPKCS5PrvKeyHex(p);else if(6===g.length)(D=new a).readPKCS5PrvKeyHex(p);else{if(!(g.length>2&&"04"===p.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(D=new o).readPKCS5PrvKeyHex(p)}return D}if("pkcs8prv"===i)return D=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===i)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===i)return Jt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Jt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=Ht(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=u(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=r(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),F=r(R,0,[2],"02"),w=r(R,0,[3],"02"),E=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(w,16),new x(E,16),new x(b,16)),D}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var A=c.getDecryptedKeyHex(t,e),I=new ot;return I.readPKCS5PrvKeyHex(A),I}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var C,D=r(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),T=r(R,0,[2,0],"06"),P=r(R,0,[3,0],"03").substr(2);if(void 0===ft.crypto.OID.oidhex2name[T])throw"undefined OID(hex) in KJUR.crypto.OID: "+T;return(C=new o({curve:ft.crypto.OID.oidhex2name[T]})).setPublicKeyHex(P),C.setPrivateKeyHex(D),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;S=r(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),F=r(R,0,[2],"02"),w=r(R,0,[3],"02"),E=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(w,16),new x(E,16),new x(b,16)),D}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw"not supported argument"},Ut.generateKeypair=function(t,e){if("RSA"==t){var i=e;(o=new ot).generate(i,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new ot,r=o.n.toString(16),s=o.e.toString(16);return n.setPublic(r,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,h=e,u=new ft.crypto.ECDSA({curve:h}).generateKeyPairHex();return(o=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),o.setPrivateKeyHex(u.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Ut.getPEM=function(t,e,i,n,r,s){var o=ft,a=o.asn1,h=a.DERObjectIdentifier,u=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,f=o.crypto,d=f.DSA,g=f.ECDSA,p=ot;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function S(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==p&&t instanceof p||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Rt(x=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=v(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===i||null==i)&&1==t.isPrivate){var F=new h({name:t.curveName}).getEncodedHex(),w=m(t).getEncodedHex(),E="";return E+=Rt(F,"EC PARAMETERS"),E+=Rt(w,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=S(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==i&&null!=i&&1==t.isPrivate){var x=v(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==i&&null!=i&&1==t.isPrivate){x=m(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==i&&null!=i&&1==t.isPrivate){x=S(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",x,i,n,s)}var b=function(t,e){var i=A(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},A=function(t,e){var i=y.lib.WordArray.random(8),n=y.lib.WordArray.random(8),r=y.PBKDF2(e,i,{keySize:6,iterations:100}),s=y.enc.Hex.parse(t),o=y.TripleDES.encrypt(s,r,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=y.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=y.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=p&&t instanceof p&&1==t.isPrivate){var I=v(t).getEncodedHex();x=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){I=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){I=new u({bigint:t.x}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}throw"unsupported object nor format"},Ut.getKeyFromCSRPEM=function(t){var e=Ht(t,"CERTIFICATE REQUEST");return Ut.getKeyFromCSRHex(e)},Ut.getKeyFromCSRHex=function(t){var e=Ut.parseCSRHex(t);return Ut.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Ut.parseCSRHex=function(t){var e=pt,i=e.getChildIdx,n=e.getTLV,r={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=i(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=i(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(s,a[2]),r},Ut.getJWKFromKey=function(t){var e={};if(t instanceof ot&&t.isPrivate)return e.kty="RSA",e.n=Et(t.n.toString(16)),e.e=Et(t.e.toString(16)),e.d=Et(t.d.toString(16)),e.p=Et(t.p.toString(16)),e.q=Et(t.q.toString(16)),e.dp=Et(t.dmp1.toString(16)),e.dq=Et(t.dmq1.toString(16)),e.qi=Et(t.coeff.toString(16)),e;if(t instanceof ot&&t.isPublic)return e.kty="RSA",e.n=Et(t.n.toString(16)),e.e=Et(t.e.toString(16)),e;if(t instanceof ft.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=Et(i.x),e.y=Et(i.y),e.d=Et(t.prvKeyHex),e}if(t instanceof ft.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=Et(i.x),e.y=Et(i.y),e}throw"not supported key object"},ot.getPosArrayOfChildrenFromHex=function(t){return pt.getChildIdx(t,0)},ot.getHexValueArrayOfChildrenFromHex=function(t){var e,i=pt.getV,n=i(t,(e=ot.getPosArrayOfChildrenFromHex(t))[0]),r=i(t,e[1]),s=i(t,e[2]),o=i(t,e[3]),a=i(t,e[4]),h=i(t,e[5]),u=i(t,e[6]),c=i(t,e[7]),l=i(t,e[8]);return(e=new Array).push(n,r,s,o,a,h,u,c,l),e},ot.prototype.readPrivateKeyFromPEMString=function(t){var e=Ht(t),i=ot.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},ot.prototype.readPKCS5PrvKeyHex=function(t){var e=ot.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},ot.prototype.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s,o,a,h,u=pt,c=u.getVbyList;if(!1===u.isASN1HEX(t))throw"not ASN.1 hex string";try{e=c(t,0,[2,0,1],"02"),i=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),r=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw"malformed PKCS#8 plain RSA private key"}this.setPrivateEx(e,i,n,r,s,o,a,h)},ot.prototype.readPKCS5PubKeyHex=function(t){var e=pt,i=e.getV;if(!1===e.isASN1HEX(t))throw"keyHex is not ASN.1 hex string";var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw"wrong hex for PKCS#5 public key";var r=i(t,n[0]),s=i(t,n[1]);this.setPublic(r,s)},ot.prototype.readPKCS8PubKeyHex=function(t){var e=pt;if(!1===e.isASN1HEX(t))throw"not ASN.1 hex string";if("06092a864886f70d010101"!==e.getTLVbyList(t,0,[0,0]))throw"not PKCS8 RSA public key";var i=e.getTLVbyList(t,0,[1,0]);this.readPKCS5PubKeyHex(i)},ot.prototype.readCertPubKeyHex=function(t,e){var i,n;(i=new Jt).readCertHex(t),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var qt=new RegExp("");function zt(t,e){for(var i="",n=e/4-t.length,r=0;r>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function Yt(t){for(var e in ft.crypto.Util.DIGESTINFOHEAD){var i=ft.crypto.Util.DIGESTINFOHEAD[e],n=i.length;if(t.substring(0,n)==i)return[e,t.substring(n)]}return[]}function Jt(){var t=pt,e=t.getChildIdx,i=t.getV,n=t.getTLV,r=t.getVbyList,s=t.getTLVbyList,o=t.getIdxbyList,a=t.getVidx,h=t.oidname,u=Jt,c=Ht;this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){return null===this.hex||0!==this.version?this.version:"a003020102"!==s(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return r(this.hex,0,[0,1+this.foffset],"02")},this.getSignatureAlgorithmField=function(){return h(r(this.hex,0,[0,2+this.foffset,0],"06"))},this.getIssuerHex=function(){return s(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return u.hex2dn(this.getIssuerHex())},this.getSubjectHex=function(){return s(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return u.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=r(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=r(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return t.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return o(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return o(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Ut.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){return h(r(this.hex,0,[1,0],"06"))},this.getSignatureValueHex=function(){return r(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmName(),i=this.getSignatureValueHex(),n=s(this.hex,0,[0],"30"),r=new ft.crypto.Signature({alg:e});return r.init(t),r.updateHex(n),r.verify(i)},this.parseExt=function(){if(3!==this.version)return-1;var i=o(this.hex,0,[0,7,0],"30"),n=e(this.hex,i);this.aExtInfo=new Array;for(var s=0;s0&&(u=new Array(i),(new nt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=It(h(Ct("\0\0\0\0\0\0\0\0"+r+u))),l=[];for(n=0;n>8*a-o&255;for(g[0]&=~p,n=0;nthis.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;var r=n[0];return n[1]==function(t){return ft.crypto.Util.hashString(t,r)}(t)},ot.prototype.verifyWithMessageHash=function(t,e){var i=rt(e=(e=e.replace(qt,"")).replace(/[ \n]+/g,""),16);if(i.bitLength()>this.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;n[0];return n[1]==t},ot.prototype.verifyPSS=function(t,e,i,n){var r,s=(r=Ct(t),ft.crypto.Util.hashHex(r,i));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(s,e,i,n)},ot.prototype.verifyWithMessageHashPSS=function(t,e,i,n){var r=new x(e,16);if(r.bitLength()>this.n.bitLength())return!1;var s,o=function(t){return ft.crypto.Util.hashHex(t,i)},a=It(t),h=a.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===n||void 0===n)n=h;else if(-2===n)n=c-h-2;else if(n<-2)throw"invalid salt length";if(c>8*c-u&255;if(0!=(f.charCodeAt(0)&g))throw"bits beyond keysize not zero";var p=Gt(d,f.length,o),y=[];for(s=0;s0)&&-1==(":"+i.join(":")+":").indexOf(":"+p+":"))throw"algorithm '"+p+"' not accepted in the list";if("none"!=p&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Ut.getKey(e)),!("RS"!=y&&"PS"!=y||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==y&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===s.jwsalg2sigalg[g.alg])throw"unsupported alg name: "+p;if("none"==(v=s.jwsalg2sigalg[p]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var S,F=null;try{F=h.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(F)}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(d)},ft.jws.JWS.parse=function(t){var e,i,n,r=t.split("."),s={};if(2!=r.length&&3!=r.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=r[0],i=r[1],3==r.length&&(n=r[2]),s.headerObj=ft.jws.JWS.readSafeJSONString(gt(e)),s.payloadObj=ft.jws.JWS.readSafeJSONString(gt(i)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=gt(i):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==n&&(s.sigHex=xt(n)),s},ft.jws.JWS.verifyJWT=function(t,e,i){var n=ft.jws,r=n.JWS,s=r.readSafeJSONString,o=r.inArray,a=r.includedArray,h=t.split("."),u=h[0],c=h[1],l=(xt(h[2]),s(gt(u))),f=s(gt(c));if(void 0===l.alg)return!1;if(void 0===i.alg)throw"acceptField.alg shall be specified";if(!o(l.alg,i.alg))return!1;if(void 0!==f.iss&&"object"==typeof i.iss&&!o(f.iss,i.iss))return!1;if(void 0!==f.sub&&"object"==typeof i.sub&&!o(f.sub,i.sub))return!1;if(void 0!==f.aud&&"object"==typeof i.aud)if("string"==typeof f.aud){if(!o(f.aud,i.aud))return!1}else if("object"==typeof f.aud&&!a(f.aud,i.aud))return!1;var d=n.IntDate.getNow();return void 0!==i.verifyAt&&"number"==typeof i.verifyAt&&(d=i.verifyAt),void 0!==i.gracePeriod&&"number"==typeof i.gracePeriod||(i.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+i.gracePeriodr&&this.aHeader.pop(),this.aSignature.length>r&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignatures=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},e.SecureRandom=nt,e.rng_seed_time=Z,e.BigInteger=x,e.RSAKey=ot,e.ECDSA=ft.crypto.ECDSA,e.DSA=ft.crypto.DSA,e.Signature=ft.crypto.Signature,e.MessageDigest=ft.crypto.MessageDigest,e.Mac=ft.crypto.Mac,e.Cipher=ft.crypto.Cipher,e.KEYUTIL=Ut,e.ASN1HEX=pt,e.X509=Jt,e.CryptoJS=y,e.b64tohex=w,e.b64toBA=E,e.stoBA=yt,e.BAtos=vt,e.BAtohex=mt,e.stohex=St,e.stob64=function(t){return F(St(t))},e.stob64u=function(t){return Ft(F(St(t)))},e.b64utos=function(t){return vt(E(wt(t)))},e.b64tob64u=Ft,e.b64utob64=wt,e.hex2b64=F,e.hextob64u=Et,e.b64utohex=xt,e.utf8tob64u=dt,e.b64utoutf8=gt,e.utf8tob64=function(t){return F(Ot(Kt(t)))},e.b64toutf8=function(t){return decodeURIComponent(jt(w(t)))},e.utf8tohex=bt,e.hextoutf8=At,e.hextorstr=It,e.rstrtohex=Ct,e.hextob64=Dt,e.hextob64nl=Tt,e.b64nltohex=Pt,e.hextopem=Rt,e.pemtohex=Ht,e.hextoArrayBuffer=function(t){if(t.length%2!=0)throw"input is not even length";if(null==t.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var e=new ArrayBuffer(t.length/2),i=new DataView(e),n=0;ne.length&&(i=e.length);for(var n=0;n300)throw new r(`Failed to fetch ${t}. Response=${s}`,i.status);try{return JSON.parse(s)}catch(e){throw new r(`Invalid response while trying to fetch ${t}. Response=${s}`,i.status,e)}}}},function(t,e,i){const n=i(1),r=i(15);t.exports=class{constructor({jwt:t=i(0)}={}){this.jwt=t}decodeAndValidate({token:t,publicKeys:e,issuer:i,clientId:s,nonce:o}){const a=Math.floor(Date.now()/1e3),h=t.split(".");if(3!==h.length)throw new r(`Invalid JWT token. Got only ${h.length} parts.`);const u=this.jwt.KJUR.jws.JWS.parse(t);if(!u.headerObj)throw new r(n.INVALID_TOKEN);const c=u.headerObj.kid,l=this.getPublicKey(e.keys,c),f=this.jwt.KEYUTIL.getKey(l);if(!this.jwt.KJUR.jws.JWS.verify(t,f,{alg:[n.TOKEN_ALG]}))throw new r(n.INVALID_SIGNATURE);if(u.payloadObj.exp - * @license MIT - */ -var n=i(9),r=i(10),s=i(11);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return A(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function A(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return w(this,t,e,i);case"latin1":case"binary":return E(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function N(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||B(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);B(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);B(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(8))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(17);t.exports=class{constructor({w:t=window}={}){this.window=t}init(t){this.popupConfig=t}open(){const t=this.popupConfig.height,e=this.popupConfig.width,i=(window.screen.width-e)/2,r=(window.screen.height-t)/2;if(this.popup=this.window.open("","popup",`left=${i},top=${r},width=${e},height=${t},resizable,scrollbars=yes,status=1`),!this.popup)throw new n("Unable to open popup")}navigate(t){this.popup.location.href=t}close(){this.popup.close()}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(21);t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t);const i={"x-filter-type":`spa:v${n.version}`};this.publicKeys=e(this.getJwksEndpoint(),{headers:i})}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}},function(t){t.exports=JSON.parse('{"name":"ibmcloud-appid-js","version":"0.3.0","description":"IBM Cloud App ID SDK for Single Page Applications","scripts":{"build":"webpack","test":"mocha","coverage":"nyc --reporter=lcov mocha","docs":"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git"},"main":"dist/appid.umd.min.js","nyc":{"all":true,"include":["src/*.js"],"exclude":["**/PopupController.js","**/IFrameController.js","**/OpenIDConfigurationResource.js","**/constants.js"]},"dependencies":{"jsrsasign":"^8.0.12"},"devDependencies":{"node-fetch":"^2.6.0","@babel/cli":"^7.0.0","@babel/core":"^7.5.5","@babel/plugin-transform-runtime":"^7.5.5","@babel/preset-env":"^7.5.5","babel-cli":"^7.0.0-beta.3","chai":"^4.2.0","coveralls":"^3.0.6","gulp-babel":"^8.0.0","mocha":"^6.2.0","nyc":"^14.1.1","webpack":"^4.39.1","webpack-cli":"^3.3.6","docdash":"^1.1.1","jsdoc":"^3.6.3"}}')}]); \ No newline at end of file +var AppID = +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./node_modules/base64-js/index.js": +/*!*****************************************!*\ + !*** ./node_modules/base64-js/index.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/base64-js/index.js?"); + +/***/ }), + +/***/ "./node_modules/buffer/index.js": +/*!**************************************!*\ + !*** ./node_modules/buffer/index.js ***! + \**************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("/* WEBPACK VAR INJECTION */(function(global) {/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n\n\nvar base64 = __webpack_require__(/*! base64-js */ \"./node_modules/base64-js/index.js\")\nvar ieee754 = __webpack_require__(/*! ieee754 */ \"./node_modules/ieee754/index.js\")\nvar isArray = __webpack_require__(/*! isarray */ \"./node_modules/isarray/index.js\")\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://AppID/./node_modules/buffer/index.js?"); + +/***/ }), + +/***/ "./node_modules/ieee754/index.js": +/*!***************************************!*\ + !*** ./node_modules/ieee754/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/ieee754/index.js?"); + +/***/ }), + +/***/ "./node_modules/isarray/index.js": +/*!***************************************!*\ + !*** ./node_modules/isarray/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n\n\n//# sourceURL=webpack://AppID/./node_modules/isarray/index.js?"); + +/***/ }), + +/***/ "./node_modules/jsrsasign/lib/jsrsasign.js": +/*!*************************************************!*\ + !*** ./node_modules/jsrsasign/lib/jsrsasign.js ***! + \*************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\nvar navigator = {};\nnavigator.userAgent = false;\n\nvar window = {};\n/*\n * jsrsasign(all) 8.0.12 (2018-04-22) (c) 2010-2018 Kenji Urushima | kjur.github.com/jsrsasign/license\n */\n\n/*!\nCopyright (c) 2011, Yahoo! Inc. All rights reserved.\nCode licensed under the BSD License:\nhttp://developer.yahoo.com/yui/license.html\nversion: 2.9.0\n*/\nif(YAHOO===undefined){var YAHOO={}}YAHOO.lang={extend:function(g,h,f){if(!h||!g){throw new Error(\"YAHOO.lang.extend failed, please check that all dependencies are included.\")}var d=function(){};d.prototype=h.prototype;g.prototype=new d();g.prototype.constructor=g;g.superclass=h.prototype;if(h.prototype.constructor==Object.prototype.constructor){h.prototype.constructor=h}if(f){var b;for(b in f){g.prototype[b]=f[b]}var e=function(){},c=[\"toString\",\"valueOf\"];try{if(/MSIE/.test(navigator.userAgent)){e=function(j,i){for(b=0;b>>2]>>>(24-(r%4)*8))&255;q[(n+r)>>>2]|=o<<(24-((n+r)%4)*8)}}else{for(var r=0;r>>2]=p[r>>>2]}}this.sigBytes+=s;return this},clamp:function(){var o=this.words;var n=this.sigBytes;o[n>>>2]&=4294967295<<(32-(n%4)*8);o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);n.words=this.words.slice(0);return n},random:function(p){var o=[];for(var n=0;n>>2]>>>(24-(n%4)*8))&255;q.push((s>>>4).toString(16));q.push((s&15).toString(16))}return q.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>3]|=parseInt(p.substr(o,2),16)<<(24-(o%8)*4)}return new l.init(q,n/2)}};var d=m.Latin1={stringify:function(q){var r=q.words;var p=q.sigBytes;var n=[];for(var o=0;o>>2]>>>(24-(o%4)*8))&255;n.push(String.fromCharCode(s))}return n.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>2]|=(p.charCodeAt(o)&255)<<(24-(o%4)*8)}return new l.init(q,n)}};var c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error(\"Malformed UTF-8 data\")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}};var i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init();this._nDataBytes=0},_append:function(n){if(typeof n==\"string\"){n=c.parse(n)}this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data;var x=q.words;var n=q.sigBytes;var t=this.blockSize;var v=t*4;var u=n/v;if(w){u=e.ceil(u)}else{u=e.max((u|0)-this._minBufferSize,0)}var s=u*t;var r=e.min(s*4,n);if(s){for(var p=0;p>>2]&255}};f.BlockCipher=n.extend({cfg:n.cfg.extend({mode:m,padding:h}),reset:function(){n.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;\nthis._mode=c.call(a,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var p=f.CipherParams=k.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(g.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;\nreturn(a?l.create([1398893684,1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=l.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return p.create({ciphertext:a,salt:c})}},j=f.SerializableCipher=k.extend({cfg:k.extend({format:m}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return p.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,\nblockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return\"string\"==typeof a?b.parse(a,this):a}}),g=(g.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=l.random(8));a=v.create({keySize:b+c}).compute(a,d);c=l.create(a.words.slice(b),4*c);a.sigBytes=4*b;return p.create({key:a,iv:c,salt:d})}},s=f.PasswordBasedCipher=j.extend({cfg:j.cfg.extend({kdf:g}),encrypt:function(a,\nb,c,d){d=this.cfg.extend(d);c=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=c.iv;a=j.encrypt.call(this,a,b,c.key,d);a.mixIn(c);return a},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=c.iv;return j.decrypt.call(this,a,b,c.key,d)}})}();\n\n/*\nCryptoJS v3.1.2 aes.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){for(var q=CryptoJS,x=q.lib.BlockCipher,r=q.algo,j=[],y=[],z=[],A=[],B=[],C=[],s=[],u=[],v=[],w=[],g=[],k=0;256>k;k++)g[k]=128>k?k<<1:k<<1^283;for(var n=0,l=0,k=0;256>k;k++){var f=l^l<<1^l<<2^l<<3^l<<4,f=f>>>8^f&255^99;j[n]=f;y[f]=n;var t=g[n],D=g[t],E=g[D],b=257*g[f]^16843008*f;z[n]=b<<24|b>>>8;A[n]=b<<16|b>>>16;B[n]=b<<8|b>>>24;C[n]=b;b=16843009*E^65537*D^257*t^16843008*n;s[f]=b<<24|b>>>8;u[f]=b<<16|b>>>16;v[f]=b<<8|b>>>24;w[f]=b;n?(n=t^g[g[g[E^t]]],l^=g[g[l]]):n=l=1}var F=[0,1,2,4,8,\n16,32,64,128,27,54],r=r.AES=x.extend({_doReset:function(){for(var c=this._key,e=c.words,a=c.sigBytes/4,c=4*((this._nRounds=a+6)+1),b=this._keySchedule=[],h=0;h>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255]):(d=d<<8|d>>>24,d=j[d>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255],d^=F[h/a|0]<<24);b[h]=b[h-a]^d}e=this._invKeySchedule=[];for(a=0;aa||4>=h?d:s[j[d>>>24]]^u[j[d>>>16&255]]^v[j[d>>>\n8&255]]^w[j[d&255]]},encryptBlock:function(c,e){this._doCryptBlock(c,e,this._keySchedule,z,A,B,C,j)},decryptBlock:function(c,e){var a=c[e+1];c[e+1]=c[e+3];c[e+3]=a;this._doCryptBlock(c,e,this._invKeySchedule,s,u,v,w,y);a=c[e+1];c[e+1]=c[e+3];c[e+3]=a},_doCryptBlock:function(c,e,a,b,h,d,j,m){for(var n=this._nRounds,f=c[e]^a[0],g=c[e+1]^a[1],k=c[e+2]^a[2],p=c[e+3]^a[3],l=4,t=1;t>>24]^h[g>>>16&255]^d[k>>>8&255]^j[p&255]^a[l++],r=b[g>>>24]^h[k>>>16&255]^d[p>>>8&255]^j[f&255]^a[l++],s=\nb[k>>>24]^h[p>>>16&255]^d[f>>>8&255]^j[g&255]^a[l++],p=b[p>>>24]^h[f>>>16&255]^d[g>>>8&255]^j[k&255]^a[l++],f=q,g=r,k=s;q=(m[f>>>24]<<24|m[g>>>16&255]<<16|m[k>>>8&255]<<8|m[p&255])^a[l++];r=(m[g>>>24]<<24|m[k>>>16&255]<<16|m[p>>>8&255]<<8|m[f&255])^a[l++];s=(m[k>>>24]<<24|m[p>>>16&255]<<16|m[f>>>8&255]<<8|m[g&255])^a[l++];p=(m[p>>>24]<<24|m[f>>>16&255]<<16|m[g>>>8&255]<<8|m[k&255])^a[l++];c[e]=q;c[e+1]=r;c[e+2]=s;c[e+3]=p},keySize:8});q.AES=x._createHelper(r)})();\n\n/*\nCryptoJS v3.1.2 tripledes-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function j(b,c){var a=(this._lBlock>>>b^this._rBlock)&c;this._rBlock^=a;this._lBlock^=a<>>b^this._lBlock)&c;this._lBlock^=a;this._rBlock^=a<a;a++){var f=q[a]-1;c[a]=b[f>>>5]>>>31-f%32&1}b=this._subKeys=[];for(f=0;16>f;f++){for(var d=b[f]=[],e=r[f],a=0;24>a;a++)d[a/6|0]|=c[(p[a]-1+e)%28]<<31-a%6,d[4+(a/6|0)]|=c[28+(p[a+24]-1+e)%28]<<31-a%6;d[0]=d[0]<<1|d[0]>>>31;for(a=1;7>a;a++)d[a]>>>=\n4*(a-1)+3;d[7]=d[7]<<5|d[7]>>>27}c=this._invSubKeys=[];for(a=0;16>a;a++)c[a]=b[15-a]},encryptBlock:function(b,c){this._doCryptBlock(b,c,this._subKeys)},decryptBlock:function(b,c){this._doCryptBlock(b,c,this._invSubKeys)},_doCryptBlock:function(b,c,a){this._lBlock=b[c];this._rBlock=b[c+1];j.call(this,4,252645135);j.call(this,16,65535);l.call(this,2,858993459);l.call(this,8,16711935);j.call(this,1,1431655765);for(var f=0;16>f;f++){for(var d=a[f],e=this._lBlock,h=this._rBlock,g=0,k=0;8>k;k++)g|=s[k][((h^\nd[k])&t[k])>>>0];this._lBlock=h;this._rBlock=e^g}a=this._lBlock;this._lBlock=this._rBlock;this._rBlock=a;j.call(this,1,1431655765);l.call(this,8,16711935);l.call(this,2,858993459);j.call(this,16,65535);j.call(this,4,252645135);b[c]=this._lBlock;b[c+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});h.DES=e._createHelper(m);g=g.TripleDES=e.extend({_doReset:function(){var b=this._key.words;this._des1=m.createEncryptor(n.create(b.slice(0,2)));this._des2=m.createEncryptor(n.create(b.slice(2,4)));this._des3=\nm.createEncryptor(n.create(b.slice(4,6)))},encryptBlock:function(b,c){this._des1.encryptBlock(b,c);this._des2.decryptBlock(b,c);this._des3.encryptBlock(b,c)},decryptBlock:function(b,c){this._des3.decryptBlock(b,c);this._des2.encryptBlock(b,c);this._des1.decryptBlock(b,c)},keySize:6,ivSize:2,blockSize:2});h.TripleDES=e._createHelper(g)})();\n\n/*\nCryptoJS v3.1.2 enc-base64.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join(\"\")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d<\ne;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\"}})();\n\n/*\nCryptoJS v3.1.2 md5.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(E){function h(a,f,g,j,p,h,k){a=a+(f&g|~f&j)+p+k;return(a<>>32-h)+f}function k(a,f,g,j,p,h,k){a=a+(f&j|g&~j)+p+k;return(a<>>32-h)+f}function l(a,f,g,j,h,k,l){a=a+(f^g^j)+h+l;return(a<>>32-k)+f}function n(a,f,g,j,h,k,l){a=a+(g^(f|~j))+h+l;return(a<>>32-k)+f}for(var r=CryptoJS,q=r.lib,F=q.WordArray,s=q.Hasher,q=r.algo,a=[],t=0;64>t;t++)a[t]=4294967296*E.abs(E.sin(t+1))|0;q=q.MD5=s.extend({_doReset:function(){this._hash=new F.init([1732584193,4023233417,2562383102,271733878])},\n_doProcessBlock:function(m,f){for(var g=0;16>g;g++){var j=f+g,p=m[j];m[j]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360}var g=this._hash.words,j=m[f+0],p=m[f+1],q=m[f+2],r=m[f+3],s=m[f+4],t=m[f+5],u=m[f+6],v=m[f+7],w=m[f+8],x=m[f+9],y=m[f+10],z=m[f+11],A=m[f+12],B=m[f+13],C=m[f+14],D=m[f+15],b=g[0],c=g[1],d=g[2],e=g[3],b=h(b,c,d,e,j,7,a[0]),e=h(e,b,c,d,p,12,a[1]),d=h(d,e,b,c,q,17,a[2]),c=h(c,d,e,b,r,22,a[3]),b=h(b,c,d,e,s,7,a[4]),e=h(e,b,c,d,t,12,a[5]),d=h(d,e,b,c,u,17,a[6]),c=h(c,d,e,b,v,22,a[7]),\nb=h(b,c,d,e,w,7,a[8]),e=h(e,b,c,d,x,12,a[9]),d=h(d,e,b,c,y,17,a[10]),c=h(c,d,e,b,z,22,a[11]),b=h(b,c,d,e,A,7,a[12]),e=h(e,b,c,d,B,12,a[13]),d=h(d,e,b,c,C,17,a[14]),c=h(c,d,e,b,D,22,a[15]),b=k(b,c,d,e,p,5,a[16]),e=k(e,b,c,d,u,9,a[17]),d=k(d,e,b,c,z,14,a[18]),c=k(c,d,e,b,j,20,a[19]),b=k(b,c,d,e,t,5,a[20]),e=k(e,b,c,d,y,9,a[21]),d=k(d,e,b,c,D,14,a[22]),c=k(c,d,e,b,s,20,a[23]),b=k(b,c,d,e,x,5,a[24]),e=k(e,b,c,d,C,9,a[25]),d=k(d,e,b,c,r,14,a[26]),c=k(c,d,e,b,w,20,a[27]),b=k(b,c,d,e,B,5,a[28]),e=k(e,b,\nc,d,q,9,a[29]),d=k(d,e,b,c,v,14,a[30]),c=k(c,d,e,b,A,20,a[31]),b=l(b,c,d,e,t,4,a[32]),e=l(e,b,c,d,w,11,a[33]),d=l(d,e,b,c,z,16,a[34]),c=l(c,d,e,b,C,23,a[35]),b=l(b,c,d,e,p,4,a[36]),e=l(e,b,c,d,s,11,a[37]),d=l(d,e,b,c,v,16,a[38]),c=l(c,d,e,b,y,23,a[39]),b=l(b,c,d,e,B,4,a[40]),e=l(e,b,c,d,j,11,a[41]),d=l(d,e,b,c,r,16,a[42]),c=l(c,d,e,b,u,23,a[43]),b=l(b,c,d,e,x,4,a[44]),e=l(e,b,c,d,A,11,a[45]),d=l(d,e,b,c,D,16,a[46]),c=l(c,d,e,b,q,23,a[47]),b=n(b,c,d,e,j,6,a[48]),e=n(e,b,c,d,v,10,a[49]),d=n(d,e,b,c,\nC,15,a[50]),c=n(c,d,e,b,t,21,a[51]),b=n(b,c,d,e,A,6,a[52]),e=n(e,b,c,d,r,10,a[53]),d=n(d,e,b,c,y,15,a[54]),c=n(c,d,e,b,p,21,a[55]),b=n(b,c,d,e,w,6,a[56]),e=n(e,b,c,d,D,10,a[57]),d=n(d,e,b,c,u,15,a[58]),c=n(c,d,e,b,B,21,a[59]),b=n(b,c,d,e,s,6,a[60]),e=n(e,b,c,d,z,10,a[61]),d=n(d,e,b,c,q,15,a[62]),c=n(c,d,e,b,x,21,a[63]);g[0]=g[0]+b|0;g[1]=g[1]+c|0;g[2]=g[2]+d|0;g[3]=g[3]+e|0},_doFinalize:function(){var a=this._data,f=a.words,g=8*this._nDataBytes,j=8*a.sigBytes;f[j>>>5]|=128<<24-j%32;var h=E.floor(g/\n4294967296);f[(j+64>>>9<<4)+15]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;f[(j+64>>>9<<4)+14]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360;a.sigBytes=4*(f.length+1);this._process();a=this._hash;f=a.words;for(g=0;4>g;g++)j=f[g],f[g]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=s.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=s._createHelper(q);r.HmacMD5=s._createHmacHelper(q)})(Math);\n\n/*\nCryptoJS v3.1.2 sha1-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var k=CryptoJS,b=k.lib,m=b.WordArray,l=b.Hasher,d=[],b=k.algo.SHA1=l.extend({_doReset:function(){this._hash=new m.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(n,p){for(var a=this._hash.words,e=a[0],f=a[1],h=a[2],j=a[3],b=a[4],c=0;80>c;c++){if(16>c)d[c]=n[p+c]|0;else{var g=d[c-3]^d[c-8]^d[c-14]^d[c-16];d[c]=g<<1|g>>>31}g=(e<<5|e>>>27)+b+d[c];g=20>c?g+((f&h|~f&j)+1518500249):40>c?g+((f^h^j)+1859775393):60>c?g+((f&h|f&j|h&j)-1894007588):g+((f^h^\nj)-899497514);b=j;j=h;h=f<<30|f>>>2;f=e;e=g}a[0]=a[0]+e|0;a[1]=a[1]+f|0;a[2]=a[2]+h|0;a[3]=a[3]+j|0;a[4]=a[4]+b|0},_doFinalize:function(){var b=this._data,d=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=Math.floor(a/4294967296);d[(e+64>>>9<<4)+15]=a;b.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var b=l.clone.call(this);b._hash=this._hash.clone();return b}});k.SHA1=l._createHelper(b);k.HmacSHA1=l._createHmacHelper(b)})();\n\n/*\nCryptoJS v3.1.2 sha256-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(k){for(var g=CryptoJS,h=g.lib,v=h.WordArray,j=h.Hasher,h=g.algo,s=[],t=[],u=function(q){return 4294967296*(q-(q|0))|0},l=2,b=0;64>b;){var d;a:{d=l;for(var w=k.sqrt(d),r=2;r<=w;r++)if(!(d%r)){d=!1;break a}d=!0}d&&(8>b&&(s[b]=u(k.pow(l,0.5))),t[b]=u(k.pow(l,1/3)),b++);l++}var n=[],h=h.SHA256=j.extend({_doReset:function(){this._hash=new v.init(s.slice(0))},_doProcessBlock:function(q,h){for(var a=this._hash.words,c=a[0],d=a[1],b=a[2],k=a[3],f=a[4],g=a[5],j=a[6],l=a[7],e=0;64>e;e++){if(16>e)n[e]=\nq[h+e]|0;else{var m=n[e-15],p=n[e-2];n[e]=((m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3)+n[e-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[e-16]}m=l+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&g^~f&j)+t[e]+n[e];p=((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&d^c&b^d&b);l=j;j=g;g=f;f=k+m|0;k=b;b=d;d=c;c=m+p|0}a[0]=a[0]+c|0;a[1]=a[1]+d|0;a[2]=a[2]+b|0;a[3]=a[3]+k|0;a[4]=a[4]+f|0;a[5]=a[5]+g|0;a[6]=a[6]+j|0;a[7]=a[7]+l|0},_doFinalize:function(){var d=this._data,b=d.words,a=8*this._nDataBytes,c=8*d.sigBytes;\nb[c>>>5]|=128<<24-c%32;b[(c+64>>>9<<4)+14]=k.floor(a/4294967296);b[(c+64>>>9<<4)+15]=a;d.sigBytes=4*b.length;this._process();return this._hash},clone:function(){var b=j.clone.call(this);b._hash=this._hash.clone();return b}});g.SHA256=j._createHelper(h);g.HmacSHA256=j._createHmacHelper(h)})(Math);\n\n/*\nCryptoJS v3.1.2 sha224-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var b=CryptoJS,d=b.lib.WordArray,a=b.algo,c=a.SHA256,a=a.SHA224=c.extend({_doReset:function(){this._hash=new d.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var a=c._doFinalize.call(this);a.sigBytes-=4;return a}});b.SHA224=c._createHelper(a);b.HmacSHA224=c._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 sha512-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function a(){return d.create.apply(d,arguments)}for(var n=CryptoJS,r=n.lib.Hasher,e=n.x64,d=e.Word,T=e.WordArray,e=n.algo,ea=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),\na(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,\n2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),\na(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,\n3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],w=0;80>w;w++)v[w]=a();e=e.SHA512=r.extend({_doReset:function(){this._hash=new T.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(a,d){for(var f=this._hash.words,\nF=f[0],e=f[1],n=f[2],r=f[3],G=f[4],H=f[5],I=f[6],f=f[7],w=F.high,J=F.low,X=e.high,K=e.low,Y=n.high,L=n.low,Z=r.high,M=r.low,$=G.high,N=G.low,aa=H.high,O=H.low,ba=I.high,P=I.low,ca=f.high,Q=f.low,k=w,g=J,z=X,x=K,A=Y,y=L,U=Z,B=M,l=$,h=N,R=aa,C=O,S=ba,D=P,V=ca,E=Q,m=0;80>m;m++){var s=v[m];if(16>m)var j=s.high=a[d+2*m]|0,b=s.low=a[d+2*m+1]|0;else{var j=v[m-15],b=j.high,p=j.low,j=(b>>>1|p<<31)^(b>>>8|p<<24)^b>>>7,p=(p>>>1|b<<31)^(p>>>8|b<<24)^(p>>>7|b<<25),u=v[m-2],b=u.high,c=u.low,u=(b>>>19|c<<13)^(b<<\n3|c>>>29)^b>>>6,c=(c>>>19|b<<13)^(c<<3|b>>>29)^(c>>>6|b<<26),b=v[m-7],W=b.high,t=v[m-16],q=t.high,t=t.low,b=p+b.low,j=j+W+(b>>>0

>>0?1:0),b=b+c,j=j+u+(b>>>0>>0?1:0),b=b+t,j=j+q+(b>>>0>>0?1:0);s.high=j;s.low=b}var W=l&R^~l&S,t=h&C^~h&D,s=k&z^k&A^z&A,T=g&x^g&y^x&y,p=(k>>>28|g<<4)^(k<<30|g>>>2)^(k<<25|g>>>7),u=(g>>>28|k<<4)^(g<<30|k>>>2)^(g<<25|k>>>7),c=ea[m],fa=c.high,da=c.low,c=E+((h>>>14|l<<18)^(h>>>18|l<<14)^(h<<23|l>>>9)),q=V+((l>>>14|h<<18)^(l>>>18|h<<14)^(l<<23|h>>>9))+(c>>>0>>0?1:\n0),c=c+t,q=q+W+(c>>>0>>0?1:0),c=c+da,q=q+fa+(c>>>0>>0?1:0),c=c+b,q=q+j+(c>>>0>>0?1:0),b=u+T,s=p+s+(b>>>0>>0?1:0),V=S,E=D,S=R,D=C,R=l,C=h,h=B+c|0,l=U+q+(h>>>0>>0?1:0)|0,U=A,B=y,A=z,y=x,z=k,x=g,g=c+b|0,k=q+s+(g>>>0>>0?1:0)|0}J=F.low=J+g;F.high=w+k+(J>>>0>>0?1:0);K=e.low=K+x;e.high=X+z+(K>>>0>>0?1:0);L=n.low=L+y;n.high=Y+A+(L>>>0>>0?1:0);M=r.low=M+B;r.high=Z+U+(M>>>0>>0?1:0);N=G.low=N+h;G.high=$+l+(N>>>0>>0?1:0);O=H.low=O+C;H.high=aa+R+(O>>>0>>0?1:0);P=I.low=P+D;\nI.high=ba+S+(P>>>0>>0?1:0);Q=f.low=Q+E;f.high=ca+V+(Q>>>0>>0?1:0)},_doFinalize:function(){var a=this._data,d=a.words,f=8*this._nDataBytes,e=8*a.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+128>>>10<<5)+30]=Math.floor(f/4294967296);d[(e+128>>>10<<5)+31]=f;a.sigBytes=4*d.length;this._process();return this._hash.toX32()},clone:function(){var a=r.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});n.SHA512=r._createHelper(e);n.HmacSHA512=r._createHmacHelper(e)})();\n\n/*\nCryptoJS v3.1.2 sha384-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,a=c.x64,b=a.Word,e=a.WordArray,a=c.algo,d=a.SHA512,a=a.SHA384=d.extend({_doReset:function(){this._hash=new e.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var a=d._doFinalize.call(this);a.sigBytes-=16;return a}});c.SHA384=\nd._createHelper(a);c.HmacSHA384=d._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 ripemd160-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n/*\n\n(c) 2012 by Cedric Mesnil. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n(function(){var q=CryptoJS,d=q.lib,n=d.WordArray,p=d.Hasher,d=q.algo,x=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),y=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),z=n.create([11,14,15,12,\n5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),A=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),B=n.create([0,1518500249,1859775393,2400959708,2840853838]),C=n.create([1352829926,1548603684,1836072691,\n2053994217,0]),d=d.RIPEMD160=p.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,v){for(var b=0;16>b;b++){var c=v+b,f=e[c];e[c]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360}var c=this._hash.words,f=B.words,d=C.words,n=x.words,q=y.words,p=z.words,w=A.words,t,g,h,j,r,u,k,l,m,s;u=t=c[0];k=g=c[1];l=h=c[2];m=j=c[3];s=r=c[4];for(var a,b=0;80>b;b+=1)a=t+e[v+n[b]]|0,a=16>b?a+((g^h^j)+f[0]):32>b?a+((g&h|~g&j)+f[1]):48>b?\na+(((g|~h)^j)+f[2]):64>b?a+((g&j|h&~j)+f[3]):a+((g^(h|~j))+f[4]),a|=0,a=a<>>32-p[b],a=a+r|0,t=r,r=j,j=h<<10|h>>>22,h=g,g=a,a=u+e[v+q[b]]|0,a=16>b?a+((k^(l|~m))+d[0]):32>b?a+((k&m|l&~m)+d[1]):48>b?a+(((k|~l)^m)+d[2]):64>b?a+((k&l|~k&m)+d[3]):a+((k^l^m)+d[4]),a|=0,a=a<>>32-w[b],a=a+s|0,u=s,s=m,m=l<<10|l>>>22,l=k,k=a;a=c[1]+h+m|0;c[1]=c[2]+j+s|0;c[2]=c[3]+r+u|0;c[3]=c[4]+t+k|0;c[4]=c[0]+g+l|0;c[0]=a},_doFinalize:function(){var e=this._data,d=e.words,b=8*this._nDataBytes,c=8*e.sigBytes;\nd[c>>>5]|=128<<24-c%32;d[(c+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;e.sigBytes=4*(d.length+1);this._process();e=this._hash;d=e.words;for(b=0;5>b;b++)c=d[b],d[b]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return e},clone:function(){var d=p.clone.call(this);d._hash=this._hash.clone();return d}});q.RIPEMD160=p._createHelper(d);q.HmacRIPEMD160=p._createHmacHelper(d)})(Math);\n\n/*\nCryptoJS v3.1.2 hmac.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,k=c.enc.Utf8;c.algo.HMAC=c.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;\"string\"==typeof b&&(b=k.parse(b));var c=a.blockSize,e=4*c;b.sigBytes>e&&(b=a.finalize(b));b.clamp();for(var f=this._oKey=b.clone(),g=this._iKey=b.clone(),h=f.words,j=g.words,d=0;d>6)+b64map.charAt(e&63)}if(b+1==d.length){e=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(e<<2)}else{if(b+2==d.length){e=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(e>>2)+b64map.charAt((e&3)<<4)}}if(b64pad){while((a.length&3)>0){a+=b64pad}}return a}function b64tohex(f){var d=\"\";var e;var b=0;var c;var a;for(e=0;e>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(e){var d=b64tohex(e);var c;var b=new Array();for(c=0;2*c=0){var d=a*this[f++]+b[e]+h;h=Math.floor(d/67108864);b[e++]=d&67108863}return h}function am2(f,q,r,e,o,a){var k=q&32767,p=q>>15;while(--a>=0){var d=this[f]&32767;var g=this[f++]>>15;var b=p*d+g*k;d=k*d+((b&32767)<<15)+r[e]+(o&1073741823);o=(d>>>30)+(b>>>15)+p*g+(o>>>30);r[e++]=d&1073741823}return o}function am3(f,q,r,e,o,a){var k=q&16383,p=q>>14;while(--a>=0){var d=this[f]&16383;var g=this[f++]>>14;var b=p*d+g*k;d=k*d+((b&16383)<<14)+r[e]+o;o=(d>>28)+(b>>14)+p*g;r[e++]=d&268435455}return o}if(j_lm&&(navigator.appName==\"Microsoft Internet Explorer\")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator.appName!=\"Netscape\")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=((1<=0;--a){b[a]=this[a]}b.t=this.t;b.s=this.s}function bnpFromInt(a){this.t=1;this.s=(a<0)?-1:0;if(a>0){this[0]=a}else{if(a<-1){this[0]=a+this.DV}else{this.t=0}}}function nbv(a){var b=nbi();b.fromInt(a);return b}function bnpFromString(h,c){var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==256){e=8}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{this.fromRadix(h,c);return}}}}}}this.t=0;this.s=0;var g=h.length,d=false,f=0;while(--g>=0){var a=(e==8)?h[g]&255:intAt(h,g);if(a<0){if(h.charAt(g)==\"-\"){d=true}continue}d=false;if(f==0){this[this.t++]=a}else{if(f+e>this.DB){this[this.t-1]|=(a&((1<<(this.DB-f))-1))<>(this.DB-f))}else{this[this.t-1]|=a<=this.DB){f-=this.DB}}if(e==8&&(h[0]&128)!=0){this.s=-1;if(f>0){this[this.t-1]|=((1<<(this.DB-f))-1)<0&&this[this.t-1]==a){--this.t}}function bnToString(c){if(this.s<0){return\"-\"+this.negate().toString(c)}var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{return this.toRadix(c)}}}}}var g=(1<0){if(j>j)>0){a=true;h=int2char(l)}while(f>=0){if(j>(j+=this.DB-e)}else{l=(this[f]>>(j-=e))&g;if(j<=0){j+=this.DB;--f}}if(l>0){a=true}if(a){h+=int2char(l)}}}return a?h:\"0\"}function bnNegate(){var a=nbi();BigInteger.ZERO.subTo(this,a);return a}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(b){var d=this.s-b.s;if(d!=0){return d}var c=this.t;d=c-b.t;if(d!=0){return(this.s<0)?-d:d}while(--c>=0){if((d=this[c]-b[c])!=0){return d}}return 0}function nbits(a){var c=1,b;if((b=a>>>16)!=0){a=b;c+=16}if((b=a>>8)!=0){a=b;c+=8}if((b=a>>4)!=0){a=b;c+=4}if((b=a>>2)!=0){a=b;c+=2}if((b=a>>1)!=0){a=b;c+=1}return c}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(c,b){var a;for(a=this.t-1;a>=0;--a){b[a+c]=this[a]}for(a=c-1;a>=0;--a){b[a]=0}b.t=this.t+c;b.s=this.s}function bnpDRShiftTo(c,b){for(var a=c;a=0;--d){e[d+f+1]=(this[d]>>a)|h;h=(this[d]&g)<=0;--d){e[d]=0}e[f]=h;e.t=this.t+f+1;e.s=this.s;e.clamp()}function bnpRShiftTo(g,d){d.s=this.s;var e=Math.floor(g/this.DB);if(e>=this.t){d.t=0;return}var b=g%this.DB;var a=this.DB-b;var f=(1<>b;for(var c=e+1;c>b}if(b>0){d[this.t-e-1]|=(this.s&f)<>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g-=d.s}f.s=(g<0)?-1:0;if(g<-1){f[e++]=this.DV+g}else{if(g>0){f[e++]=g}}f.t=e;f.clamp()}function bnpMultiplyTo(c,e){var b=this.abs(),f=c.abs();var d=b.t;e.t=d+f.t;while(--d>=0){e[d]=0}for(d=0;d=0){d[b]=0}for(b=0;b=a.DV){d[b+a.t]-=a.DV;d[b+a.t+1]=1}}if(d.t>0){d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)}d.s=0;d.clamp()}function bnpDivRemTo(n,h,g){var w=n.abs();if(w.t<=0){return}var k=this.abs();if(k.t0){w.lShiftTo(v,d);k.lShiftTo(v,g)}else{w.copyTo(d);k.copyTo(g)}var p=d.t;var b=d[p-1];if(b==0){return}var o=b*(1<1)?d[p-2]>>this.F2:0);var A=this.FV/o,z=(1<=0){g[g.t++]=1;g.subTo(f,g)}BigInteger.ONE.dlShiftTo(p,f);f.subTo(d,d);while(d.t=0){var c=(g[--u]==b)?this.DM:Math.floor(g[u]*A+(g[u-1]+x)*z);if((g[u]+=d.am(0,c,g,s,0,p))0){g.rShiftTo(v,g)}if(a<0){BigInteger.ZERO.subTo(g,g)}}function bnMod(b){var c=nbi();this.abs().divRemTo(b,null,c);if(this.s<0&&c.compareTo(BigInteger.ZERO)>0){b.subTo(c,c)}return c}function Classic(a){this.m=a}function cConvert(a){if(a.s<0||a.compareTo(this.m)>=0){return a.mod(this.m)}else{return a}}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var a=this[0];if((a&1)==0){return 0}var b=a&3;b=(b*(2-(a&15)*b))&15;b=(b*(2-(a&255)*b))&255;b=(b*(2-(((a&65535)*b)&65535)))&65535;b=(b*(2-a*b%this.DV))%this.DV;return(b>0)?this.DV-b:-b}function Montgomery(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(a.DB-15))-1;this.mt2=2*a.t}function montConvert(a){var b=nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);if(a.s<0&&b.compareTo(BigInteger.ZERO)>0){this.m.subTo(b,b)}return b}function montRevert(a){var b=nbi();a.copyTo(b);this.reduce(b);return b}function montReduce(a){while(a.t<=this.mt2){a[a.t++]=0}for(var c=0;c>15)*this.mpl)&this.um)<<15))&a.DM;b=c+this.m.t;a[b]+=this.m.am(0,d,a,c,0,this.m.t);while(a[b]>=a.DV){a[b]-=a.DV;a[++b]++}}a.clamp();a.drShiftTo(this.m.t,a);if(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(h,j){if(h>4294967295||h<1){return BigInteger.ONE}var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;d.copyTo(f);while(--c>=0){j.sqrTo(f,a);if((h&(1<0){j.mulTo(a,d,f)}else{var b=f;f=a;a=b}}return j.revert(f)}function bnModPowInt(b,a){var c;if(b<256||a.isEven()){c=new Classic(a)}else{c=new Montgomery(a)}return this.exp(b,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction bnClone(){var a=nbi();this.copyTo(a);return a}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this[0]}else{if(this.t==0){return 0}}}return((this[1]&((1<<(32-this.DB))-1))<>24}function bnShortValue(){return(this.t==0)?this.s:(this[0]<<16)>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this[0]<=0)){return 0}else{return 1}}}function bnpToRadix(c){if(c==null){c=10}if(this.signum()==0||c<2||c>36){return\"0\"}var f=this.chunkSize(c);var e=Math.pow(c,f);var i=nbv(e),j=nbi(),h=nbi(),g=\"\";this.divRemTo(i,j,h);while(j.signum()>0){g=(e+h.intValue()).toString(c).substr(1)+g;j.divRemTo(i,j,h)}return h.intValue().toString(c)+g}function bnpFromRadix(m,h){this.fromInt(0);if(h==null){h=10}var f=this.chunkSize(h);var g=Math.pow(h,f),e=false,a=0,l=0;for(var c=0;c=f){this.dMultiply(g);this.dAddOffset(l,0);a=0;l=0}}if(a>0){this.dMultiply(Math.pow(h,a));this.dAddOffset(l,0)}if(e){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(f,e,h){if(\"number\"==typeof e){if(f<2){this.fromInt(1)}else{this.fromNumber(f,h);if(!this.testBit(f-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(f-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(e)){this.dAddOffset(2,0);if(this.bitLength()>f){this.subTo(BigInteger.ONE.shiftLeft(f-1),this)}}}}else{var d=new Array(),g=f&7;d.length=(f>>3)+1;e.nextBytes(d);if(g>0){d[0]&=((1<0){if(e>e)!=(this.s&this.DM)>>e){c[a++]=f|(this.s<<(this.DB-e))}while(b>=0){if(e<8){f=(this[b]&((1<>(e+=this.DB-8)}else{f=(this[b]>>(e-=8))&255;if(e<=0){e+=this.DB;--b}}if((f&128)!=0){f|=-256}if(a==0&&(this.s&128)!=(f&128)){++a}if(a>0||f!=this.s){c[a++]=f}}}return c}function bnEquals(b){return(this.compareTo(b)==0)}function bnMin(b){return(this.compareTo(b)<0)?this:b}function bnMax(b){return(this.compareTo(b)>0)?this:b}function bnpBitwiseTo(c,h,e){var d,g,b=Math.min(c.t,this.t);for(d=0;d>=16;b+=16}if((a&255)==0){a>>=8;b+=8}if((a&15)==0){a>>=4;b+=4}if((a&3)==0){a>>=2;b+=2}if((a&1)==0){++b}return b}function bnGetLowestSetBit(){for(var a=0;a=this.t){return(this.s!=0)}return((this[a]&(1<<(b%this.DB)))!=0)}function bnpChangeBit(c,b){var a=BigInteger.ONE.shiftLeft(c);this.bitwiseTo(a,b,a);return a}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(d,f){var e=0,g=0,b=Math.min(d.t,this.t);while(e>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g+=d.s}f.s=(g<0)?-1:0;if(g>0){f[e++]=g}else{if(g<-1){f[e++]=this.DV+g}}f.t=e;f.clamp()}function bnAdd(b){var c=nbi();this.addTo(b,c);return c}function bnSubtract(b){var c=nbi();this.subTo(b,c);return c}function bnMultiply(b){var c=nbi();this.multiplyTo(b,c);return c}function bnSquare(){var a=nbi();this.squareTo(a);return a}function bnDivide(b){var c=nbi();this.divRemTo(b,c,null);return c}function bnRemainder(b){var c=nbi();this.divRemTo(b,null,c);return c}function bnDivideAndRemainder(b){var d=nbi(),c=nbi();this.divRemTo(b,d,c);return new Array(d,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(b,a){if(b==0){return}while(this.t<=a){this[this.t++]=0}this[a]+=b;while(this[a]>=this.DV){this[a]-=this.DV;if(++a>=this.t){this[this.t++]=0}++this[a]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,c,b){a.multiplyTo(c,b)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp())}function bnpMultiplyLowerTo(b,f,e){var d=Math.min(this.t+b.t,f);e.s=0;e.t=d;while(d>0){e[--d]=0}var c;for(c=e.t-this.t;d=0){d[c]=0}for(c=Math.max(e-this.t,0);c2*this.m.t){return a.mod(this.m)}else{if(a.compareTo(this.m)<0){return a}else{var b=nbi();a.copyTo(b);this.reduce(b);return b}}}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1){a.t=this.m.t+1;a.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0){a.dAddOffset(1,this.m.t+1)}a.subTo(this.r2,a);while(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(q,f){var o=q.bitLength(),h,b=nbv(1),v;if(o<=0){return b}else{if(o<18){h=1}else{if(o<48){h=3}else{if(o<144){h=4}else{if(o<768){h=5}else{h=6}}}}}if(o<8){v=new Classic(f)}else{if(f.isEven()){v=new Barrett(f)}else{v=new Montgomery(f)}}var p=new Array(),d=3,s=h-1,a=(1<1){var A=nbi();v.sqrTo(p[1],A);while(d<=a){p[d]=nbi();v.mulTo(A,p[d-2],p[d]);d+=2}}var l=q.t-1,x,u=true,c=nbi(),y;o=nbits(q[l])-1;while(l>=0){if(o>=s){x=(q[l]>>(o-s))&a}else{x=(q[l]&((1<<(o+1))-1))<<(s-o);if(l>0){x|=q[l-1]>>(this.DB+o-s)}}d=h;while((x&1)==0){x>>=1;--d}if((o-=d)<0){o+=this.DB;--l}if(u){p[x].copyTo(b);u=false}else{while(d>1){v.sqrTo(b,c);v.sqrTo(c,b);d-=2}if(d>0){v.sqrTo(b,c)}else{y=b;b=c;c=y}v.mulTo(c,p[x],b)}while(l>=0&&(q[l]&(1<0){b.rShiftTo(f,b);h.rShiftTo(f,h)}while(b.signum()>0){if((d=b.getLowestSetBit())>0){b.rShiftTo(d,b)}if((d=h.getLowestSetBit())>0){h.rShiftTo(d,h)}if(b.compareTo(h)>=0){b.subTo(h,b);b.rShiftTo(1,b)}else{h.subTo(b,h);h.rShiftTo(1,h)}}if(f>0){h.lShiftTo(f,h)}return h}function bnpModInt(e){if(e<=0){return 0}var c=this.DV%e,b=(this.s<0)?e-1:0;if(this.t>0){if(c==0){b=this[0]%e}else{for(var a=this.t-1;a>=0;--a){b=(c*b+this[a])%e}}}return b}function bnModInverse(f){var j=f.isEven();if((this.isEven()&&j)||f.signum()==0){return BigInteger.ZERO}var i=f.clone(),h=this.clone();var g=nbv(1),e=nbv(0),l=nbv(0),k=nbv(1);while(i.signum()!=0){while(i.isEven()){i.rShiftTo(1,i);if(j){if(!g.isEven()||!e.isEven()){g.addTo(this,g);e.subTo(f,e)}g.rShiftTo(1,g)}else{if(!e.isEven()){e.subTo(f,e)}}e.rShiftTo(1,e)}while(h.isEven()){h.rShiftTo(1,h);if(j){if(!l.isEven()||!k.isEven()){l.addTo(this,l);k.subTo(f,k)}l.rShiftTo(1,l)}else{if(!k.isEven()){k.subTo(f,k)}}k.rShiftTo(1,k)}if(i.compareTo(h)>=0){i.subTo(h,i);if(j){g.subTo(l,g)}e.subTo(k,e)}else{h.subTo(i,h);if(j){l.subTo(g,l)}k.subTo(e,k)}}if(h.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(k.compareTo(f)>=0){return k.subtract(f)}if(k.signum()<0){k.addTo(f,k)}else{return k}if(k.signum()<0){return k.add(f)}else{return k}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(e){var d,b=this.abs();if(b.t==1&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d>1;if(f>lowprimes.length){f=lowprimes.length}var b=nbi();for(var e=0;e>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(window!==undefined&&(window.crypto!==undefined||window.msCrypto!==undefined)){var crypto=window.crypto||window.msCrypto;if(crypto.getRandomValues){var ua=new Uint8Array(32);crypto.getRandomValues(ua);for(t=0;t<32;++t){rng_pool[rng_pptr++]=ua[t]}}else{if(navigator.appName==\"Netscape\"&&navigator.appVersion<\"5\"){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr=0&&h>0){var f=e.charCodeAt(d--);if(f<128){g[--h]=f}else{if((f>127)&&(f<2048)){g[--h]=(f&63)|128;g[--h]=(f>>6)|192}else{g[--h]=(f&63)|128;g[--h]=((f>>6)&63)|128;g[--h]=(f>>12)|224}}}g[--h]=0;var b=new SecureRandom();var a=new Array();while(h>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}g[--h]=a[0]}g[--h]=2;g[--h]=0;return new BigInteger(g)}function oaep_mgf1_arr(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255])));d+=1}return b}function oaep_pad(q,a,f,l){var c=KJUR.crypto.MessageDigest;var o=KJUR.crypto.Util;var b=null;if(!f){f=\"sha1\"}if(typeof f===\"string\"){b=c.getCanonicalAlgName(f);l=c.getHashLength(b);f=function(i){return hextorstr(o.hashHex(rstrtohex(i),b))}}if(q.length+2*l+2>a){throw\"Message too long for RSA\"}var k=\"\",e;for(e=0;e0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{throw\"Invalid RSA public key\"}}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var e=this.doPublic(a);if(e==null){return null}var b=e.toString(16);if((b.length&1)==0){return b}else{return\"0\"+b}}function RSAEncryptOAEP(f,e,b){var a=oaep_pad(f,(this.n.bitLength()+7)>>3,e,b);if(a==null){return null}var g=this.doPublic(a);if(g==null){return null}var d=g.toString(16);if((d.length&1)==0){return d}else{return\"0\"+d}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;RSAKey.prototype.encryptOAEP=RSAEncryptOAEP;RSAKey.prototype.type=\"RSA\";\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction pkcs1unpad2(g,j){var a=g.toByteArray();var f=0;while(f=a.length){return null}}var e=\"\";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}function oaep_unpad(o,b,g,p){var e=KJUR.crypto.MessageDigest;var r=KJUR.crypto.Util;var c=null;if(!g){g=\"sha1\"}if(typeof g===\"string\"){c=e.getCanonicalAlgName(g);p=e.getHashLength(c);g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}}o=o.toByteArray();var h;for(h=0;h0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{throw\"Invalid RSA private key\"}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;this.isPublic=false;if(g==null){throw\"RSASetPrivateEx N == null\"}if(d==null){throw\"RSASetPrivateEx E == null\"}if(g.length==0){throw\"RSASetPrivateEx N.length == 0\"}if(d.length==0){throw\"RSASetPrivateEx E.length == 0\"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{throw\"Invalid RSA private key in RSASetPrivateEx\"}}function RSAGenerate(b,i){var a=new SecureRandom();var f=b>>1;this.e=parseInt(i,16);var c=new BigInteger(i,16);for(;;){for(;;){this.p=new BigInteger(b-f,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(f,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var h=this.p;this.p=this.q;this.q=h}var g=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var e=g.multiply(d);if(e.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(e);this.dmp1=this.d.mod(g);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=true}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}function RSADecryptOAEP(e,d,b){var f=parseBigInt(e,16);var a=this.doPrivate(f);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,d,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP;\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction ECFieldElementFp(b,a){this.x=a;this.q=b}function feFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.x.equals(a.x))}function feFpToBigInteger(){return this.x}function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))}function feFpAdd(a){return new ECFieldElementFp(this.q,this.x.add(a.toBigInteger()).mod(this.q))}function feFpSubtract(a){return new ECFieldElementFp(this.q,this.x.subtract(a.toBigInteger()).mod(this.q))}function feFpMultiply(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger()).mod(this.q))}function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))}function feFpDivide(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger().modInverse(this.q)).mod(this.q))}ECFieldElementFp.prototype.equals=feFpEquals;ECFieldElementFp.prototype.toBigInteger=feFpToBigInteger;ECFieldElementFp.prototype.negate=feFpNegate;ECFieldElementFp.prototype.add=feFpAdd;ECFieldElementFp.prototype.subtract=feFpSubtract;ECFieldElementFp.prototype.multiply=feFpMultiply;ECFieldElementFp.prototype.square=feFpSquare;ECFieldElementFp.prototype.divide=feFpDivide;function ECPointFp(c,a,d,b){this.curve=c;this.x=a;this.y=d;if(b==null){this.z=BigInteger.ONE}else{this.z=b}this.zinv=null}function pointFpGetX(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpGetY(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpEquals(a){if(a==this){return true}if(this.isInfinity()){return a.isInfinity()}if(a.isInfinity()){return this.isInfinity()}var c,b;c=a.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(a.z)).mod(this.curve.q);if(!c.equals(BigInteger.ZERO)){return false}b=a.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(a.z)).mod(this.curve.q);return b.equals(BigInteger.ZERO)}function pointFpIsInfinity(){if((this.x==null)&&(this.y==null)){return true}return this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)}function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)}function pointFpAdd(l){if(this.isInfinity()){return l}if(l.isInfinity()){return this}var p=l.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(l.z)).mod(this.curve.q);var o=l.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(l.z)).mod(this.curve.q);if(BigInteger.ZERO.equals(o)){if(BigInteger.ZERO.equals(p)){return this.twice()}return this.curve.getInfinity()}var j=new BigInteger(\"3\");var e=this.x.toBigInteger();var n=this.y.toBigInteger();var c=l.x.toBigInteger();var k=l.y.toBigInteger();var m=o.square();var i=m.multiply(o);var d=e.multiply(m);var g=p.square().multiply(this.z);var a=g.subtract(d.shiftLeft(1)).multiply(l.z).subtract(i).multiply(o).mod(this.curve.q);var h=d.multiply(j).multiply(p).subtract(n.multiply(i)).subtract(g.multiply(p)).multiply(l.z).add(p.multiply(i)).mod(this.curve.q);var f=i.multiply(this.z).multiply(l.z).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),f)}function pointFpTwice(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var g=new BigInteger(\"3\");var c=this.x.toBigInteger();var h=this.y.toBigInteger();var e=h.multiply(this.z);var j=e.multiply(h).mod(this.curve.q);var i=this.curve.a.toBigInteger();var k=c.square().multiply(g);if(!BigInteger.ZERO.equals(i)){k=k.add(this.z.square().multiply(i))}k=k.mod(this.curve.q);var b=k.square().subtract(c.shiftLeft(3).multiply(j)).shiftLeft(1).multiply(e).mod(this.curve.q);var f=k.multiply(g).multiply(c).subtract(j.shiftLeft(1)).shiftLeft(2).multiply(j).subtract(k.square().multiply(k)).mod(this.curve.q);var d=e.square().multiply(e).shiftLeft(3).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(b),this.curve.fromBigInteger(f),d)}function pointFpMultiply(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add(a?this:l)}}return d}function pointFpMultiplyTwo(c,a,b){var d;if(c.bitLength()>b.bitLength()){d=c.bitLength()-1}else{d=b.bitLength()-1}var f=this.curve.getInfinity();var e=this.add(a);while(d>=0){f=f.twice();if(c.testBit(d)){if(b.testBit(d)){f=f.add(e)}else{f=f.add(this)}}else{if(b.testBit(d)){f=f.add(a)}}--d}return f}ECPointFp.prototype.getX=pointFpGetX;ECPointFp.prototype.getY=pointFpGetY;ECPointFp.prototype.equals=pointFpEquals;ECPointFp.prototype.isInfinity=pointFpIsInfinity;ECPointFp.prototype.negate=pointFpNegate;ECPointFp.prototype.add=pointFpAdd;ECPointFp.prototype.twice=pointFpTwice;ECPointFp.prototype.multiply=pointFpMultiply;ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo;function ECCurveFp(e,d,c){this.q=e;this.a=this.fromBigInteger(d);this.b=this.fromBigInteger(c);this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b))}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)}function curveFpDecodePointHex(d){switch(parseInt(d.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var a=(d.length-2)/2;var c=d.substr(2,a);var b=d.substr(a+2,a);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(b,16)));default:return null}}ECCurveFp.prototype.getQ=curveFpGetQ;ECCurveFp.prototype.getA=curveFpGetA;ECCurveFp.prototype.getB=curveFpGetB;ECCurveFp.prototype.equals=curveFpEquals;ECCurveFp.prototype.getInfinity=curveFpGetInfinity;ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger;ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex;\n/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib\n */\nECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};ECPointFp.prototype.getEncoded=function(c){var d=function(h,f){var g=h.toByteArrayUnsigned();if(fg.length){g.unshift(0)}}return g};var a=this.getX().toBigInteger();var e=this.getY().toBigInteger();var b=d(a,32);if(c){if(e.isEven()){b.unshift(2)}else{b.unshift(3)}}else{b.unshift(4);b=b.concat(d(e,32))}return b};ECPointFp.decodeFrom=function(g,c){var f=c[0];var e=c.length-1;var d=c.slice(1,1+e/2);var b=c.slice(1+e/2,1+e);d.unshift(0);b.unshift(0);var a=new BigInteger(d);var h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.decodeFromHex=function(g,c){var f=c.substr(0,2);var e=c.length-2;var d=c.substr(2,e/2);var b=c.substr(2+e/2,e/2);var a=new BigInteger(d,16);var h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.prototype.add2D=function(c){if(this.isInfinity()){return c}if(c.isInfinity()){return this}if(this.x.equals(c.x)){if(this.y.equals(c.y)){return this.twice()}return this.curve.getInfinity()}var g=c.x.subtract(this.x);var e=c.y.subtract(this.y);var a=e.divide(g);var d=a.square().subtract(this.x).subtract(c.x);var f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var b=this.curve.fromBigInteger(BigInteger.valueOf(2));var e=this.curve.fromBigInteger(BigInteger.valueOf(3));var a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b));var c=a.square().subtract(this.x.multiply(b));var d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)};ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add2D(a?this:l)}}return d};ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger();var i=this.getY().toBigInteger();var f=this.curve.getA().toBigInteger();var c=this.curve.getB().toBigInteger();var h=this.curve.getQ();var e=i.multiply(i).mod(h);var g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)};ECPointFp.prototype.toString=function(){return\"(\"+this.getX().toBigInteger().toString()+\",\"+this.getY().toBigInteger().toString()+\")\"};ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity()){throw new Error(\"Point is at infinity.\")}var a=this.getX().toBigInteger();var b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"x coordinate out of bounds\")}if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"y coordinate out of bounds\")}if(!this.isOnCurve()){throw new Error(\"Point is not on the curve.\")}if(this.multiply(c).isInfinity()){throw new Error(\"Point is not a scalar multiple of G.\")}return true};\n/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval\n */\nvar jsonParse=(function(){var e=\"(?:-?\\\\b(?:0|[1-9][0-9]*)(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\\\b)\";var j='(?:[^\\\\0-\\\\x08\\\\x0a-\\\\x1f\"\\\\\\\\]|\\\\\\\\(?:[\"/\\\\\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:\"'+j+'*\")';var d=new RegExp(\"(?:false|true|null|[\\\\{\\\\}\\\\[\\\\]]|\"+e+\"|\"+i+\")\",\"g\");var k=new RegExp(\"\\\\\\\\(?:([^u])|u(.{4}))\",\"g\");var g={'\"':'\"',\"/\":\"/\",\"\\\\\":\"\\\\\",b:\"\\b\",f:\"\\f\",n:\"\\n\",r:\"\\r\",t:\"\\t\"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String(\"\");var a=\"\\\\\";var f={\"{\":Object,\"[\":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if(\"{\"===v){x={}}else{if(\"[\"===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({\"\":x},\"\")}return x}})();\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.asn1==\"undefined\"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b=\"0\"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!=\"-\"){if(f.length%2==1){f=\"0\"+f}else{if(!f.match(/^[0-7]/)){f=\"00\"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g=\"\";for(var d=0;d15){throw\"ASN.1 length too long to represent by 8x: n = \"+i.toString(16)}var f=128+g;return f.toString(16)+h}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return\"\"}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!=\"undefined\"){if(typeof c==\"string\"){this.setString(c)}else{if(typeof c.str!=\"undefined\"){this.setString(c.str)}else{if(typeof c.hex!=\"undefined\"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(f){utc=f.getTime()+(f.getTimezoneOffset()*60000);var e=new Date(utc);return e};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o==\"utc\"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,\"\");r=r+\".\"+k}}return r+\"Z\"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join(\"0\")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!=\"undefined\"){if(typeof b.array!=\"undefined\"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT=\"01\";this.hTLV=\"0101ff\"};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT=\"02\";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!=\"undefined\"){if(typeof a.bigint!=\"undefined\"){this.setByBigInteger(a.bigint)}else{if(typeof a[\"int\"]!=\"undefined\"){this.setByInteger(a[\"int\"])}else{if(typeof a==\"number\"){this.setByInteger(a)}else{if(typeof a.hex!=\"undefined\"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!==\"undefined\"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex=\"00\"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT=\"03\";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=(l*2))){break}if(d>=200){break}g.push(b);c=b;d++}return g};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){throw\"checking tag doesn't match: \"+e.substr(d,2)+\"!=\"+i}}return d}f=c.shift();b=g.getChildIdx(e,d);return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getTLVbyList=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyList(d,c,b);if(a===undefined){throw\"can't find nthList object\"}if(f!==undefined){if(d.substr(a,2)!=f){throw\"checking tag doesn't match: \"+d.substr(a,2)+\"!=\"+f}}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a===undefined){throw\"can't find nthList object\"}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join(\"0\")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+\".\"+j.join(\".\")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+\"..(total \"+A.length/2+\"bytes)..\"+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=\"\"}var x=c.ommit_long_octet;if(e.substr(l,2)==\"01\"){var h=j(e,l);if(h==\"00\"){return g+\"BOOLEAN FALSE\\n\"}else{return g+\"BOOLEAN TRUE\\n\"}}if(e.substr(l,2)==\"02\"){var h=j(e,l);return g+\"INTEGER \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"03\"){var h=j(e,l);return g+\"BITSTRING \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"04\"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+\"OCTETSTRING, encapsulates\\n\";k=k+y(h,c,0,g+\" \");return k}else{return g+\"OCTETSTRING \"+q(h,x)+\"\\n\"}}if(e.substr(l,2)==\"05\"){return g+\"NULL\\n\"}if(e.substr(l,2)==\"06\"){var m=j(e,l);var a=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(a);var b=a.replace(/\\./g,\" \");if(o!=\"\"){return g+\"ObjectIdentifier \"+o+\" (\"+b+\")\\n\"}else{return g+\"ObjectIdentifier (\"+b+\")\\n\"}}if(e.substr(l,2)==\"0c\"){return g+\"UTF8String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"13\"){return g+\"PrintableString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"14\"){return g+\"TeletexString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"16\"){return g+\"IA5String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"17\"){return g+\"UTCTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"18\"){return g+\"GeneralizedTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"30\"){if(e.substr(l,4)==\"3000\"){return g+\"SEQUENCE {}\\n\"}var k=g+\"SEQUENCE\\n\";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)==\"06\"&&e.substr(d[d.length-1],2)==\"04\"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u0){var m=new f({array:this.extensionsArray});var k=new c({explicit:true,tag:\"a3\",obj:m});this.asn1Array.push(k)}var n=new f({array:this.asn1Array});this.hTLV=n.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension=function(d){KJUR.asn1.x509.Extension.superclass.constructor.call(this);var f=null,a=KJUR,e=a.asn1,h=e.DERObjectIdentifier,i=e.DEROctetString,b=e.DERBitString,g=e.DERBoolean,c=e.DERSequence;this.getEncodedHex=function(){var m=new h({oid:this.oid});var l=new i({hex:this.getExtnValueHex()});var k=new Array();k.push(m);if(this.critical){k.push(new g())}k.push(l);var j=new c({array:k});return j.getEncodedHex()};this.critical=false;if(d!==undefined){if(d.critical!==undefined){this.critical=d.critical}}};YAHOO.lang.extend(KJUR.asn1.x509.Extension,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension.appendByNameToArray=function(e,c,b){var g=e.toLowerCase(),f=KJUR.asn1.x509;if(g==\"basicconstraints\"){var d=new f.BasicConstraints(c);b.push(d)}else{if(g==\"keyusage\"){var d=new f.KeyUsage(c);b.push(d)}else{if(g==\"crldistributionpoints\"){var d=new f.CRLDistributionPoints(c);b.push(d)}else{if(g==\"extkeyusage\"){var d=new f.ExtKeyUsage(c);b.push(d)}else{if(g==\"authoritykeyidentifier\"){var d=new f.AuthorityKeyIdentifier(c);b.push(d)}else{if(g==\"authorityinfoaccess\"){var d=new f.AuthorityInfoAccess(c);b.push(d)}else{if(g==\"subjectaltname\"){var d=new f.SubjectAltName(c);b.push(d)}else{if(g==\"issueraltname\"){var d=new f.IssuerAltName(c);b.push(d)}else{throw\"unsupported extension name: \"+e}}}}}}}}};KJUR.asn1.x509.KeyUsage=function(f){KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this,f);var a=X509.KEYUSAGE_NAME;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.15\";if(f!==undefined){if(f.bin!==undefined){this.asn1ExtnValue=new KJUR.asn1.DERBitString(f)}if(f.names!==undefined&&f.names.length!==undefined){var e=f.names;var d=\"000000000\";for(var c=0;c-1){e.push(new KJUR.asn1.DERInteger({\"int\":this.pathLen}))}var d=new KJUR.asn1.DERSequence({array:e});this.asn1ExtnValue=d;return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.19\";this.cA=false;this.pathLen=-1;if(c!==undefined){if(c.cA!==undefined){this.cA=c.cA}if(c.pathLen!==undefined){this.pathLen=c.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){this.asn1ExtnValue=new a.DERSequence({array:e})};this.setByOneURI=function(h){var e=new c.GeneralNames([{uri:h}]);var g=new c.DistributionPointName(e);var f=new c.DistributionPoint({dpobj:g});this.setByDPArray([f])};this.oid=\"2.5.29.31\";if(d!==undefined){if(d.array!==undefined){this.setByDPArray(d.array)}else{if(d.uri!==undefined){this.setByOneURI(d.uri)}}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLDistributionPoints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.ExtKeyUsage=function(c){KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,c);var b=KJUR,a=b.asn1;this.setPurposeArray=function(d){this.asn1ExtnValue=new a.DERSequence();for(var e=0;e0){var h=new b({array:this.aRevokedCert});this.asn1Array.push(h)}var i=new b({array:this.asn1Array});this.hTLV=i.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize=function(){this.asn1Version=null;this.asn1SignatureAlg=null;this.asn1Issuer=null;this.asn1ThisUpdate=null;this.asn1NextUpdate=null;this.aRevokedCert=new Array()};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertList,KJUR.asn1.ASN1Object);KJUR.asn1.x509.CRLEntry=function(e){KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);var d=null,c=null,b=KJUR,a=b.asn1;this.setCertSerial=function(f){this.sn=new a.DERInteger(f)};this.setRevocationDate=function(f){this.time=new a.x509.Time(f)};this.getEncodedHex=function(){var f=new a.DERSequence({array:[this.sn,this.time]});this.TLV=f.getEncodedHex();return this.TLV};if(e!==undefined){if(e.time!==undefined){this.setRevocationDate(e.time)}if(e.sn!==undefined){this.setCertSerial(e.sn)}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLEntry,KJUR.asn1.ASN1Object);KJUR.asn1.x509.X500Name=function(f){KJUR.asn1.x509.X500Name.superclass.constructor.call(this);this.asn1Array=new Array();var d=KJUR,c=d.asn1,e=c.x509,b=pemtohex;this.setByString=function(g){var k=g.split(\"/\");k.shift();var j=[];for(var l=0;l0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+\",\"+h).replace(/\\\\,/g,\",\");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)===\"\\\\\"){e=true}}b=b.map(function(a){return a.replace(\"/\",\"\\\\/\")});b.reverse();return\"/\"+b.join(\"/\")};KJUR.asn1.x509.RDN=function(a){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=new Array();this.addByString=function(b){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:b}))};this.addByMultiValuedString=function(d){var b=KJUR.asn1.x509.RDN.parseString(d);for(var c=0;c0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+\"+\"+k).replace(/\\\\\\+/g,\"+\");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)===\"\\\\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/\"$/)){var d=(e+\"+\"+k).replace(/^([^=]+)=\"(.*)\"$/,\"$1=$2\");b.push(d);l=false}else{b.push(e+\"+\"+k)}}else{b.push(k)}if(k.match(/^[^=]+=\"/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(d){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var f=null,e=null,a=\"utf8\",c=KJUR,b=c.asn1;this.setByString=function(h){var g=h.match(/^([^=]+)=(.+)$/);if(g){this.setByAttrTypeAndValueStr(g[1],g[2])}else{throw\"malformed attrTypeAndValueStr: \"+h}};this.setByAttrTypeAndValueStr=function(i,h){this.typeObj=KJUR.asn1.x509.OID.atype2obj(i);var g=a;if(i==\"C\"){g=\"prn\"}this.valueObj=this.getValueObj(g,h)};this.getValueObj=function(h,g){if(h==\"utf8\"){return new b.DERUTF8String({str:g})}if(h==\"prn\"){return new b.DERPrintableString({str:g})}if(h==\"tel\"){return new b.DERTeletexString({str:g})}if(h==\"ia5\"){return new b.DERIA5String({str:g})}throw\"unsupported directory string type: type=\"+h+\" value=\"+g};this.getEncodedHex=function(){var g=new b.DERSequence({array:[this.typeObj,this.valueObj]});this.TLV=g.getEncodedHex();return this.TLV};if(d!==undefined){if(d.str!==undefined){this.setByString(d.str)}}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw\"algId and/or subjPubKey not set\"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{\"int\":{bigint:q.n}},{\"int\":{\"int\":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:\"rsaEncryption\"});this.asn1SubjPKey=new b({hex:\"00\"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:\"ecPublicKey\",asn1params:r});this.asn1SubjPKey=new b({hex:\"00\"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{\"int\":{bigint:q.p}},{\"int\":{bigint:q.q}},{\"int\":{bigint:q.g}}]});this.asn1AlgId=new o({name:\"dsa\",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:\"00\"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type==\"utc\"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type==\"utc\"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type=\"utc\";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type=\"utc\"}if(f.str.match(/^[0-9]{14}Z$/)){this.type=\"gen\"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(d){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw\"algorithm not specified\"}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var e=[this.asn1Alg];if(this.asn1Params!==null){e.push(this.asn1Params)}var f=new a.DERSequence({array:e});this.hTLV=f.getEncodedHex();return this.hTLV};if(d!==undefined){if(d.name!==undefined){this.nameAlg=d.name}if(d.asn1params!==undefined){this.asn1Params=d.asn1params}if(d.paramempty!==undefined){this.paramEmpty=d.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){var c=this.nameAlg.toLowerCase();if(c.substr(-7,7)!==\"withdsa\"&&c.substr(-9,9)!==\"withecdsa\"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:\"81\",dns:\"82\",dn:\"a4\",uri:\"86\",ip:\"87\"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type=\"rfc822\";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type=\"dns\";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type=\"uri\";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({str:p.dn})}if(p.ldapdn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certissuer param not cert\"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certsubj param not cert\"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type=\"ip\";this.explicit=false;var q=p.ip;var s;var n=\"malformed IP address\";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex(\"[\"+q.split(\".\").join(\",\")+\"]\");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw\"unsupported type in params=\"+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){r=new b({obj:this.dUnsignedAttrs,tag:\"a1\",explicit:false})}var q=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,o,this.dSigAlg,this.dSig,];if(r!=null){q.push(r)}var p=new h.DERSequence({array:q});this.hTLV=p.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.SignerInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.EncapsulatedContentInfo=function(g){var c=KJUR,b=c.asn1,e=b.DERTaggedObject,a=b.DERSequence,h=b.DERObjectIdentifier,d=b.DEROctetString,f=b.cms;f.EncapsulatedContentInfo.superclass.constructor.call(this);this.dEContentType=new h({name:\"data\"});this.dEContent=null;this.isDetached=false;this.eContentValueHex=null;this.setContentType=function(i){if(i.match(/^[0-2][.][0-9.]+$/)){this.dEContentType=new h({oid:i})}else{this.dEContentType=new h({name:i})}};this.setContentValue=function(i){if(i!==undefined){if(typeof i.hex==\"string\"){this.eContentValueHex=i.hex}else{if(typeof i.str==\"string\"){this.eContentValueHex=utf8tohex(i.str)}}}};this.setContentValueHex=function(i){this.eContentValueHex=i};this.setContentValueStr=function(i){this.eContentValueHex=utf8tohex(i)};this.getEncodedHex=function(){if(typeof this.eContentValueHex!=\"string\"){throw\"eContentValue not yet set\"}var k=new d({hex:this.eContentValueHex});this.dEContent=new e({obj:k,tag:\"a0\",explicit:true});var i=[this.dEContentType];if(!this.isDetached){i.push(this.dEContent)}var j=new a({array:i});this.hTLV=j.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.EncapsulatedContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.ContentInfo=function(f){var c=KJUR,b=c.asn1,d=b.DERTaggedObject,a=b.DERSequence,e=b.x509;KJUR.asn1.cms.ContentInfo.superclass.constructor.call(this);this.dContentType=null;this.dContent=null;this.setContentType=function(g){if(typeof g==\"string\"){this.dContentType=e.OID.name2obj(g)}};this.getEncodedHex=function(){var h=new d({obj:this.dContent,tag:\"a0\",explicit:true});var g=new a({array:[this.dContentType,h]});this.hTLV=g.getEncodedHex();return this.hTLV};if(f!==undefined){if(f.type){this.setContentType(f.type)}if(f.obj&&f.obj instanceof b.ASN1Object){this.dContent=f.obj}}};YAHOO.lang.extend(KJUR.asn1.cms.ContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.SignedData=function(e){var a=KJUR,h=a.asn1,j=h.ASN1Object,g=h.DERInteger,m=h.DERSet,f=h.DERSequence,b=h.DERTaggedObject,l=h.cms,i=l.EncapsulatedContentInfo,d=l.SignerInfo,n=l.ContentInfo,c=h.x509,k=c.AlgorithmIdentifier;KJUR.asn1.cms.SignedData.superclass.constructor.call(this);this.dCMSVersion=new g({\"int\":1});this.dDigestAlgs=null;this.digestAlgNameList=[];this.dEncapContentInfo=new i();this.dCerts=null;this.certificateList=[];this.crlList=[];this.signerInfoList=[new d()];this.addCertificatesByPEM=function(p){var q=pemtohex(p);var r=new j();r.hTLV=q;this.certificateList.push(r)};this.getEncodedHex=function(){if(typeof this.hTLV==\"string\"){return this.hTLV}if(this.dDigestAlgs==null){var u=[];for(var t=0;t0){var v=new m({array:this.certificateList});this.dCerts=new b({obj:v,tag:\"a0\",explicit:false})}}if(this.dCerts!=null){p.push(this.dCerts)}var r=new m({array:this.signerInfoList});p.push(r);var q=new f({array:p});this.hTLV=q.getEncodedHex();return this.hTLV};this.getContentInfo=function(){this.getEncodedHex();var o=new n({type:\"signed-data\",obj:this});return o};this.getContentInfoEncodedHex=function(){var o=this.getContentInfo();var p=o.getEncodedHex();return p};this.getPEM=function(){return hextopem(this.getContentInfoEncodedHex(),\"CMS\")}};YAHOO.lang.extend(KJUR.asn1.cms.SignedData,KJUR.asn1.ASN1Object);KJUR.asn1.cms.CMSUtil=new function(){};KJUR.asn1.cms.CMSUtil.newSignedData=function(d){var b=KJUR,j=b.asn1,q=j.cms,f=q.SignerInfo,n=q.SignedData,o=q.SigningTime,a=q.SigningCertificate,p=q.SigningCertificateV2,c=j.cades,e=c.SignaturePolicyIdentifier;var m=new n();m.dEncapContentInfo.setContentValue(d.content);if(typeof d.certs==\"object\"){for(var h=0;h0){var s=new f({array:this.extensionsArray});var r=new m({array:[s]});var q=new f({array:[new k({oid:\"1.2.840.113549.1.9.14\"}),r]});var p=new c({explicit:true,tag:\"a0\",obj:q});this.asn1Array.push(p)}else{var p=new c({explicit:false,tag:\"a0\",obj:new j()});this.asn1Array.push(p)}var t=new f({array:this.asn1Array});this.hTLV=t.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CSRUtil=new function(){};KJUR.asn1.csr.CSRUtil.newCSRPEM=function(h){var c=KEYUTIL,b=KJUR.asn1.csr;if(h.subject===undefined){throw\"parameter subject undefined\"}if(h.sbjpubkey===undefined){throw\"parameter sbjpubkey undefined\"}if(h.sigalg===undefined){throw\"parameter sigalg undefined\"}if(h.sbjprvkey===undefined){throw\"parameter sbjpubkey undefined\"}var d=new b.CertificationRequestInfo();d.setSubjectByParam(h.subject);d.setSubjectPublicKeyByGetKey(h.sbjpubkey);if(h.ext!==undefined&&h.ext.length!==undefined){for(var e=0;ef.length){f=c[d]}}e=e.replace(f,\"::\");return e.slice(1,-1)}function hextoip(b){var d=\"malformed hex value\";if(!b.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){throw d}if(b.length==8){var c;try{c=parseInt(b.substr(0,2),16)+\".\"+parseInt(b.substr(2,2),16)+\".\"+parseInt(b.substr(4,2),16)+\".\"+parseInt(b.substr(6,2),16);return c}catch(a){throw d}}else{if(b.length==32){return hextoipv6(b)}else{return b}}}function iptohex(f){var j=\"malformed IP address\";f=f.toLowerCase(f);if(f.match(/^[0-9.]+$/)){var b=f.split(\".\");if(b.length!==4){throw j}var g=\"\";try{for(var e=0;e<4;e++){var h=parseInt(b[e]);g+=(\"0\"+h.toString(16)).slice(-2)}return g}catch(c){throw j}}else{if(f.match(/^[0-9a-f:]+$/)&&f.indexOf(\":\")!==-1){return ipv6tohex(f)}else{throw j}}}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b=\"\";for(var c=0;c\"7\"){return\"00\"+a}return a}function intarystrtohex(b){b=b.replace(/^\\s*\\[\\s*/,\"\");b=b.replace(/\\s*\\]\\s*$/,\"\");b=b.replace(/\\s*/g,\"\");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;bd){throw\"key is too short for SigAlg: keylen=\"+j+\",\"+a}var b=\"0001\";var k=\"00\"+c;var g=\"\";var l=d-b.length-k.length;for(var f=0;f=0;--p){q=q.twice2D();q.z=BigInteger.ONE;if(o.testBit(p)){if(n.testBit(p)){q=q.add2D(t)}else{q=q.add2D(s)}}else{if(n.testBit(p)){q=q.add2D(r)}}}return q}this.getBigRandom=function(i){return new BigInteger(i.bitLength(),a).mod(i.subtract(BigInteger.ONE)).add(BigInteger.ONE)};this.setNamedCurve=function(i){this.ecparams=KJUR.crypto.ECParameterDB.getByName(i);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=i};this.setPrivateKeyHex=function(i){this.isPrivate=true;this.prvKeyHex=i};this.setPublicKeyHex=function(i){this.isPublic=true;this.pubKeyHex=i};this.getPublicKeyXYHex=function(){var k=this.pubKeyHex;if(k.substr(0,2)!==\"04\"){throw\"this method supports uncompressed format(04) only\"}var j=this.ecparams.keylen/4;if(k.length!==2+j*2){throw\"malformed public key hex length\"}var i={};i.x=k.substr(2,j);i.y=k.substr(2+j);return i};this.getShortNISTPCurveName=function(){var i=this.curveName;if(i===\"secp256r1\"||i===\"NIST P-256\"||i===\"P-256\"||i===\"prime256v1\"){return\"P-256\"}if(i===\"secp384r1\"||i===\"NIST P-384\"||i===\"P-384\"){return\"P-384\"}return null};this.generateKeyPairHex=function(){var k=this.ecparams.n;var n=this.getBigRandom(k);var l=this.ecparams.G.multiply(n);var q=l.getX().toBigInteger();var o=l.getY().toBigInteger();var i=this.ecparams.keylen/4;var m=(\"0000000000\"+n.toString(16)).slice(-i);var r=(\"0000000000\"+q.toString(16)).slice(-i);var p=(\"0000000000\"+o.toString(16)).slice(-i);var j=\"04\"+r+p;this.setPrivateKeyHex(m);this.setPublicKeyHex(j);return{ecprvhex:m,ecpubhex:j}};this.signWithMessageHash=function(i){return this.signHex(i,this.prvKeyHex)};this.signHex=function(o,j){var t=new BigInteger(j,16);var l=this.ecparams.n;var q=new BigInteger(o,16);do{var m=this.getBigRandom(l);var u=this.ecparams.G;var p=u.multiply(m);var i=p.getX().toBigInteger().mod(l)}while(i.compareTo(BigInteger.ZERO)<=0);var v=m.modInverse(l).multiply(q.add(t.multiply(i))).mod(l);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(i,v)};this.sign=function(m,u){var q=u;var j=this.ecparams.n;var p=BigInteger.fromByteArrayUnsigned(m);do{var l=this.getBigRandom(j);var t=this.ecparams.G;var o=t.multiply(l);var i=o.getX().toBigInteger().mod(j)}while(i.compareTo(BigInteger.ZERO)<=0);var v=l.modInverse(j).multiply(p.add(q.multiply(i))).mod(j);return this.serializeSig(i,v)};this.verifyWithMessageHash=function(j,i){return this.verifyHex(j,i,this.pubKeyHex)};this.verifyHex=function(m,i,p){var l,j;var o=KJUR.crypto.ECDSA.parseSigHex(i);l=o.r;j=o.s;var k;k=ECPointFp.decodeFromHex(this.ecparams.curve,p);var n=new BigInteger(m,16);return this.verifyRaw(n,l,j,k)};this.verify=function(o,p,j){var l,i;if(Bitcoin.Util.isArray(p)){var n=this.parseSig(p);l=n.r;i=n.s}else{if(\"object\"===typeof p&&p.r&&p.s){l=p.r;i=p.s}else{throw\"Invalid value for signature\"}}var k;if(j instanceof ECPointFp){k=j}else{if(Bitcoin.Util.isArray(j)){k=ECPointFp.decodeFrom(this.ecparams.curve,j)}else{throw\"Invalid format for pubkey value, must be byte array or ECPointFp\"}}var m=BigInteger.fromByteArrayUnsigned(o);return this.verifyRaw(m,l,i,k)};this.verifyRaw=function(o,i,w,m){var l=this.ecparams.n;var u=this.ecparams.G;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(l)>=0){return false}if(w.compareTo(BigInteger.ONE)<0||w.compareTo(l)>=0){return false}var p=w.modInverse(l);var k=o.multiply(p).mod(l);var j=i.multiply(p).mod(l);var q=u.multiply(k).add(m.multiply(j));var t=q.getX().toBigInteger().mod(l);return t.equals(i)};this.serializeSig=function(k,j){var l=k.toByteArraySigned();var i=j.toByteArraySigned();var m=[];m.push(2);m.push(l.length);m=m.concat(l);m.push(2);m.push(i.length);m=m.concat(i);m.unshift(m.length);m.unshift(48);return m};this.parseSig=function(n){var m;if(n[0]!=48){throw new Error(\"Signature not a valid DERSequence\")}m=2;if(n[m]!=2){throw new Error(\"First element in signature must be a DERInteger\")}var l=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];if(n[m]!=2){throw new Error(\"Second element in signature must be a DERInteger\")}var i=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];var k=BigInteger.fromByteArrayUnsigned(l);var j=BigInteger.fromByteArrayUnsigned(i);return{r:k,s:j}};this.parseSigCompact=function(m){if(m.length!==65){throw\"Signature has the wrong length\"}var j=m[0]-27;if(j<0||j>7){throw\"Invalid signature type\"}var o=this.ecparams.n;var l=BigInteger.fromByteArrayUnsigned(m.slice(1,33)).mod(o);var k=BigInteger.fromByteArrayUnsigned(m.slice(33,65)).mod(o);return{r:l,s:k,i:j}};this.readPKCS5PrvKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var i,k,o;try{i=p(l,0,[2,0],\"06\");k=p(l,0,[1],\"04\");try{o=p(l,0,[3,0],\"03\").substr(2)}catch(j){}}catch(j){throw\"malformed PKCS#1/5 plain ECC private key\"}this.curveName=m(i);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o);this.setPrivateKeyHex(k);this.isPublic=false};this.readPKCS8PrvKeyHex=function(l){var q=ASN1HEX;var i=KJUR.crypto.ECDSA.getName;var n=q.getVbyList;if(q.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var j,p,m,k;try{j=n(l,0,[1,0],\"06\");p=n(l,0,[1,1],\"06\");m=n(l,0,[2,0,1],\"04\");try{k=n(l,0,[2,0,2,0],\"03\").substr(2)}catch(o){}}catch(o){throw\"malformed PKCS#8 plain ECC private key\"}this.curveName=i(p);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(k);this.setPrivateKeyHex(m);this.isPublic=false};this.readPKCS8PubKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var k,i,o;try{k=p(l,0,[0,0],\"06\");i=p(l,0,[0,1],\"06\");o=p(l,0,[1],\"03\").substr(2)}catch(j){throw\"malformed PKCS#8 ECC public key\"}this.curveName=m(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o)};this.readCertPubKeyHex=function(k,p){if(p!==5){p=6}var m=ASN1HEX;var l=KJUR.crypto.ECDSA.getName;var o=m.getVbyList;if(m.isASN1HEX(k)===false){throw\"not ASN.1 hex string\"}var i,n;try{i=o(k,0,[0,p,0,1],\"06\");n=o(k,0,[0,p,1],\"03\").substr(2)}catch(j){throw\"malformed X.509 certificate ECC public key\"}this.curveName=l(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(n)};if(h!==undefined){if(h.curve!==undefined){this.curveName=h.curve}}if(this.curveName===undefined){this.curveName=e}this.setNamedCurve(this.curveName);if(h!==undefined){if(h.prv!==undefined){this.setPrivateKeyHex(h.prv)}if(h.pub!==undefined){this.setPublicKeyHex(h.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX;var i=j.getChildIdx;var g=j.getV;if(f.substr(0,2)!=\"30\"){throw\"signature is not a ASN.1 sequence\"}var h=i(f,0);if(h.length!=2){throw\"number of signature ASN.1 sequence elements seem wrong\"}var e=h[0];var d=h[1];if(f.substr(e,2)!=\"02\"){throw\"1st item of sequene of signature is not ASN.1 integer\"}if(f.substr(d,2)!=\"02\"){throw\"2nd item of sequene of signature is not ASN.1 integer\"}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(c){var d=KJUR.crypto.ECDSA.parseSigHexInHexRS(c);var b=d.r;var a=d.s;if(b.substr(0,2)==\"00\"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)==\"00\"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b=\"00\"+b}if((a.length%32)==30){a=\"00\"+a}if(b.length%32!=0){throw\"unknown ECDSA sig r length error\"}if(a.length%32!=0){throw\"unknown ECDSA sig s length error\"}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if((((a.length/2)*8)%(16*8))!=0){throw\"unknown ECDSA concatinated r-s sig length error\"}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.getEncodedHex()};KJUR.crypto.ECDSA.getName=function(a){if(a===\"2a8648ce3d030107\"){return\"secp256r1\"}if(a===\"2b8104000a\"){return\"secp256k1\"}if(a===\"2b81040022\"){return\"secp384r1\"}if(\"|secp256r1|NIST P-256|P-256|prime256v1|\".indexOf(a)!==-1){return\"secp256r1\"}if(\"|secp256k1|\".indexOf(a)!==-1){return\"secp256k1\"}if(\"|secp384r1|NIST P-384|P-384|\".indexOf(a)!==-1){return\"secp384r1\"}return null};\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.crypto==\"undefined\"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!=\"undefined\"){d=c[e]}if(typeof b[d]!=\"undefined\"){return b[d]}throw\"unregistered EC curve name: \"+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex(\"04\"+f+k);b[A][\"name\"]=A;b[A][\"keylen\"]=l;b[A][\"curve\"]=r;b[A][\"G\"]=q;b[A][\"n\"]=t;b[A][\"h\"]=w;b[A][\"oid\"]=d;b[A][\"info\"]=x;for(var v=0;v1){g=new BigInteger(i,16)}else{g=null}h=new BigInteger(j,16);this.setPrivate(c,a,e,g,h)};this.setPublic=function(c,b,a,d){this.isPublic=true;this.p=c;this.q=b;this.g=a;this.y=d;this.x=null};this.setPublicHex=function(f,e,d,g){var b,a,h,c;b=new BigInteger(f,16);a=new BigInteger(e,16);h=new BigInteger(d,16);c=new BigInteger(g,16);this.setPublic(b,a,h,c)};this.signWithMessageHash=function(d){var c=this.p;var b=this.q;var f=this.g;var i=this.y;var j=this.x;var e=KJUR.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),b.subtract(BigInteger.ONE));var l=d.substr(0,b.bitLength()/4);var h=new BigInteger(l,16);var a=(f.modPow(e,c)).mod(b);var n=(e.modInverse(b).multiply(h.add(j.multiply(a)))).mod(b);var m=KJUR.asn1.ASN1Util.jsonToASN1HEX({seq:[{\"int\":{bigint:a}},{\"int\":{bigint:n}}]});return m};this.verifyWithMessageHash=function(h,f){var d=this.p;var b=this.q;var j=this.g;var l=this.y;var i=this.parseASN1Signature(f);var a=i[0];var t=i[1];var o=h.substr(0,b.bitLength()/4);var k=new BigInteger(o,16);if(BigInteger.ZERO.compareTo(a)>0||a.compareTo(b)>0){throw\"invalid DSA signature\"}if(BigInteger.ZERO.compareTo(t)>=0||t.compareTo(b)>0){throw\"invalid DSA signature\"}var m=t.modInverse(b);var e=k.multiply(m).mod(b);var c=a.multiply(m).mod(b);var n=j.modPow(e,d).multiply(l.modPow(c,d)).mod(d).mod(b);return n.compareTo(a)==0};this.parseASN1Signature=function(a){try{var d=new BigInteger(ASN1HEX.getVbyList(a,0,[0],\"02\"),16);var c=new BigInteger(ASN1HEX.getVbyList(a,0,[1],\"02\"),16);return[d,c]}catch(b){throw\"malformed ASN.1 DSA signature\"}};this.readPKCS5PrvKeyHex=function(c){var b,a,f,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[1],\"02\");a=d(c,0,[2],\"02\");f=d(c,0,[3],\"02\");g=d(c,0,[4],\"02\");i=d(c,0,[5],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed PKCS#1/5 plain DSA private key\"}this.setPrivateHex(b,a,f,g,i)};this.readPKCS8PrvKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[1,1,0],\"02\");c=i(d,0,[1,1,1],\"02\");b=i(d,0,[1,1,2],\"02\");g=i(d,0,[2,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 plain DSA private key\"}this.setPrivateHex(f,c,b,null,g)};this.readPKCS8PubKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[0,1,0],\"02\");c=i(d,0,[0,1,1],\"02\");b=i(d,0,[0,1,2],\"02\");g=i(d,0,[1,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 DSA public key\"}this.setPublicHex(f,c,b,g)};this.readCertPubKeyHex=function(c,f){if(f!==5){f=6}var b,a,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[0,f,0,1,0],\"02\");a=d(c,0,[0,f,0,1,1],\"02\");g=d(c,0,[0,f,0,1,2],\"02\");i=d(c,0,[0,f,1,0],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed X.509 certificate DSA public key\"}this.setPublicHex(b,a,g,i)}};\nvar KEYUTIL=function(){var d=function(p,r,q){return k(CryptoJS.AES,p,r,q)};var e=function(p,r,q){return k(CryptoJS.TripleDES,p,r,q)};var a=function(p,r,q){return k(CryptoJS.DES,p,r,q)};var k=function(s,x,u,q){var r=CryptoJS.enc.Hex.parse(x);var w=CryptoJS.enc.Hex.parse(u);var p=CryptoJS.enc.Hex.parse(q);var t={};t.key=w;t.iv=p;t.ciphertext=r;var v=s.decrypt(t,w,{iv:p});return CryptoJS.enc.Hex.stringify(v)};var l=function(p,r,q){return g(CryptoJS.AES,p,r,q)};var o=function(p,r,q){return g(CryptoJS.TripleDES,p,r,q)};var f=function(p,r,q){return g(CryptoJS.DES,p,r,q)};var g=function(t,y,v,q){var s=CryptoJS.enc.Hex.parse(y);var x=CryptoJS.enc.Hex.parse(v);var p=CryptoJS.enc.Hex.parse(q);var w=t.encrypt(s,x,{iv:p});var r=CryptoJS.enc.Hex.parse(w.toString());var u=CryptoJS.enc.Base64.stringify(r);return u};var i={\"AES-256-CBC\":{proc:d,eproc:l,keylen:32,ivlen:16},\"AES-192-CBC\":{proc:d,eproc:l,keylen:24,ivlen:16},\"AES-128-CBC\":{proc:d,eproc:l,keylen:16,ivlen:16},\"DES-EDE3-CBC\":{proc:e,eproc:o,keylen:24,ivlen:8},\"DES-CBC\":{proc:a,eproc:f,keylen:8,ivlen:8}};var c=function(p){return i[p][\"proc\"]};var m=function(p){var r=CryptoJS.lib.WordArray.random(p);var q=CryptoJS.enc.Hex.stringify(r);return q};var n=function(v){var w={};var q=v.match(new RegExp(\"DEK-Info: ([^,]+),([0-9A-Fa-f]+)\",\"m\"));if(q){w.cipher=q[1];w.ivsalt=q[2]}var p=v.match(new RegExp(\"-----BEGIN ([A-Z]+) PRIVATE KEY-----\"));if(p){w.type=p[1]}var u=-1;var x=0;if(v.indexOf(\"\\r\\n\\r\\n\")!=-1){u=v.indexOf(\"\\r\\n\\r\\n\");x=2}if(v.indexOf(\"\\n\\n\")!=-1){u=v.indexOf(\"\\n\\n\");x=1}var t=v.indexOf(\"-----END\");if(u!=-1&&t!=-1){var r=v.substring(u+x*2,t-x);r=r.replace(/\\s+/g,\"\");w.data=r}return w};var j=function(q,y,p){var v=p.substring(0,16);var t=CryptoJS.enc.Hex.parse(v);var r=CryptoJS.enc.Utf8.parse(y);var u=i[q][\"keylen\"]+i[q][\"ivlen\"];var x=\"\";var w=null;for(;;){var s=CryptoJS.algo.MD5.create();if(w!=null){s.update(w)}s.update(r);s.update(t);w=s.finalize();x=x+CryptoJS.enc.Hex.stringify(w);if(x.length>=u*2){break}}var z={};z.keyhex=x.substr(0,i[q][\"keylen\"]*2);z.ivhex=x.substr(i[q][\"keylen\"]*2,i[q][\"ivlen\"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v][\"proc\"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s][\"eproc\"];var t=r(p,q,u);return t};return{version:\"1.0.0\",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p=\"\";if(typeof t==\"undefined\"||t==null){t=\"AES-256-CBC\"}if(typeof i[t]==\"undefined\"){throw\"KEYUTIL unsupported algorithm: \"+t}if(typeof r==\"undefined\"||r==null){var v=i[t][\"ivlen\"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,\"$1\\r\\n\");var p=\"-----BEGIN \"+x+\" PRIVATE KEY-----\\r\\n\";p+=\"Proc-Type: 4,ENCRYPTED\\r\\n\";p+=\"DEK-Info: \"+t+\",\"+r+\"\\r\\n\";p+=\"\\r\\n\";p+=q;p+=\"\\r\\n-----END \"+x+\" PRIVATE KEY-----\\r\\n\";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw\"malformed format: SEQUENCE(0).items != 2: \"+r.length}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0).items != 2: \"+A.length}if(w(y,A[0])!=\"2a864886f70d01050d\"){throw\"this only supports pkcs5PBES2\"}var p=z(y,A[1]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0.1).items != 2: \"+p.length}var q=z(y,p[1]);if(q.length!=2){throw\"malformed format: SEQUENCE(0.0.1.1).items != 2: \"+q.length}if(w(y,q[0])!=\"2a864886f70d0307\"){throw\"this only supports TripleDES\"}t.encryptionSchemeAlg=\"TripleDES\";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw\"malformed format: SEQUENCE(0.0.1.0).items != 2: \"+s.length}if(w(y,s[0])!=\"2a864886f70d01050c\"){throw\"this only supports pkcs5PBKDF2\"}var x=z(y,s[1]);if(x.length<2){throw\"malformed format: SEQUENCE(0.0.1.0.1).items < 2: \"+x.length}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw\"malformed format pbkdf2Iter: \"+u}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,\"ENCRYPTED PRIVATE KEY\");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!=\"30\"){throw\"malformed plain PKCS8 private key(code:001)\"}var r=u(s,0);if(r.length!=3){throw\"malformed plain PKCS8 private key(code:002)\"}if(s.substr(r[1],2)!=\"30\"){throw\"malformed PKCS8 private key(code:003)\"}var p=u(s,r[1]);if(p.length!=2){throw\"malformed PKCS8 private key(code:004)\"}if(s.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 private key(code:005)\"}q.algoid=t(s,p[0]);if(s.substr(p[1],2)==\"06\"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!=\"04\"){throw\"malformed PKCS8 private key(code:006)\"}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,\"PRIVATE KEY\");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid==\"2a864886f70d010101\"){r=new RSAKey()}else{if(q.algoid==\"2a8648ce380401\"){r=new KJUR.crypto.DSA()}else{if(q.algoid==\"2a8648ce3d0201\"){r=new KJUR.crypto.ECDSA()}else{throw\"unsupported private key algorithm\"}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],\"06\");if(r===\"2a864886f70d010101\"){p=new RSAKey()}else{if(r===\"2a8648ce380401\"){p=new KJUR.crypto.DSA()}else{if(r===\"2a8648ce3d0201\"){p=new KJUR.crypto.ECDSA()}else{throw\"unsupported PKCS#8 public key hex\"}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!=\"30\"){throw\"malformed RSA key(code:001)\"}var q=t(r,0);if(q.length!=2){throw\"malformed RSA key(code:002)\"}if(r.substr(q[0],2)!=\"02\"){throw\"malformed RSA key(code:003)\"}p.n=s(r,q[0]);if(r.substr(q[1],2)!=\"02\"){throw\"malformed RSA key(code:004)\"}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw\"outer DERSequence shall have 2 elements: \"+r.length}var w=r[0];if(t.substr(w,2)!=\"30\"){throw\"malformed PKCS8 public key(code:001)\"}var p=u(t,w);if(p.length!=2){throw\"malformed PKCS8 public key(code:002)\"}if(t.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 public key(code:003)\"}q.algoid=s(t,p[0]);if(t.substr(p[1],2)==\"06\"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)==\"30\"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],\"02\");q.algparam.q=v.getVbyList(t,p[1],[1],\"02\");q.algparam.g=v.getVbyList(t,p[1],[2],\"02\")}}if(t.substr(r[1],2)!=\"03\"){throw\"malformed PKCS8 public key(code:004)\"}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!=\"undefined\"&&l instanceof w){return l}if(typeof i!=\"undefined\"&&l instanceof i){return l}if(typeof C!=\"undefined\"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;j.setPublicKeyHex(u);return j}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;var b=(\"0000000000\"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n===\"pkcs5prv\"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)===\"04\"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw\"unsupported PKCS#1/5 hexadecimal key\"}}}return P}if(n===\"pkcs8prv\"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n===\"pkcs8pub\"){return F._getKeyFromPublicPKCS8Hex(l)}if(n===\"x509pub\"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf(\"-END CERTIFICATE-\",0)!=-1||l.indexOf(\"-END X509 CERTIFICATE-\",0)!=-1||l.indexOf(\"-END TRUSTED CERTIFICATE-\",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf(\"-END PUBLIC KEY-\")!=-1){var O=pemtohex(l,\"PUBLIC KEY\");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var m=M(l,\"RSA PRIVATE KEY\");return F.getKey(m,null,\"pkcs5prv\")}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var I=M(l,\"DSA PRIVATE KEY\");var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END PRIVATE KEY-\")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf(\"-END EC PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],\"04\");var f=d(I,0,[2,0],\"06\");var A=d(I,0,[3,0],\"03\").substr(2);var e=\"\";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw\"undefined OID(hex) in KJUR.crypto.OID: \"+f}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END ENCRYPTED PRIVATE KEY-\")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw\"not supported argument\"};KEYUTIL.generateKeypair=function(a,c){if(a==\"RSA\"){var b=c;var h=new RSAKey();h.generate(b,\"10001\");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a==\"EC\"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw\"unknown algorithm: \"+a}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.n}},{\"int\":s.e},{\"int\":{bigint:s.d}},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.dmp1}},{\"int\":{bigint:s.dmq1}},{\"int\":{bigint:s.coeff}}]});return G}function B(G){var s=l({seq:[{\"int\":1},{octstr:{hex:G.prvKeyHex}},{tag:[\"a0\",true,{oid:{name:G.curveName}}]},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+G.pubKeyHex}}]}]});return s}function x(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.g}},{\"int\":{bigint:s.y}},{\"int\":{bigint:s.x}}]});return G}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D==\"PKCS8PUB\")){var E=new C(b);var w=E.getEncodedHex();return hextopem(w,\"PUBLIC KEY\")}if(D==\"PKCS1PRV\"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();return hextopem(w,\"RSA PRIVATE KEY\")}if(D==\"PKCS1PRV\"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.getEncodedHex();var h=B(b);var t=h.getEncodedHex();var p=\"\";p+=hextopem(v,\"EC PARAMETERS\");p+=hextopem(t,\"EC PRIVATE KEY\");return p}if(D==\"PKCS1PRV\"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();return hextopem(w,\"DSA PRIVATE KEY\")}if(D==\"PKCS5PRV\"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"RSA\",w,y,m,j)}if(D==\"PKCS5PRV\"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"EC\",w,y,m,j)}if(D==\"PKCS5PRV\"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"DSA\",w,y,m,j)}var o=function(G,s){var I=c(G,s);var H=new l({seq:[{seq:[{oid:{name:\"pkcs5PBES2\"}},{seq:[{seq:[{oid:{name:\"pkcs5PBKDF2\"}},{seq:[{octstr:{hex:I.pbkdf2Salt}},{\"int\":I.pbkdf2Iter}]}]},{seq:[{oid:{name:\"des-EDE3-CBC\"}},{octstr:{hex:I.encryptionSchemeIV}}]}]}]},{octstr:{hex:I.ciphertext}}]});return H.getEncodedHex()};var c=function(N,O){var H=100;var M=CryptoJS.lib.WordArray.random(8);var L=\"DES-EDE3-CBC\";var s=CryptoJS.lib.WordArray.random(8);var I=CryptoJS.PBKDF2(O,M,{keySize:192/32,iterations:H});var J=CryptoJS.enc.Hex.parse(N);var K=CryptoJS.TripleDES.encrypt(J,I,{iv:s})+\"\";var G={};G.ciphertext=K;G.pbkdf2Salt=CryptoJS.enc.Hex.stringify(M);G.pbkdf2Iter=H;G.encryptionSchemeAlg=L;G.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return G};if(D==\"PKCS8PRV\"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"rsaEncryption\"}},{\"null\":true}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var g=new l({seq:[{\"int\":1},{octstr:{hex:b.prvKeyHex}},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+b.pubKeyHex}}]}]});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"ecPublicKey\"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"dsa\"}},{seq:[{\"int\":{bigint:b.p}},{\"int\":{bigint:b.q}},{\"int\":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}throw\"unsupported object nor format\"};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,\"CERTIFICATE REQUEST\");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,\"pkcs8pub\");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!=\"30\"){throw\"malformed CSR(code:001)\"}var e=f(g,0);if(e.length<1){throw\"malformed CSR(code:002)\"}if(g.substr(e[0],2)!=\"30\"){throw\"malformed CSR(code:003)\"}var a=f(g,e[0]);if(a.length<3){throw\"malformed CSR(code:004)\"}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getJWKFromKey=function(d){var b={};if(d instanceof RSAKey&&d.isPrivate){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));b.d=hextob64u(d.d.toString(16));b.p=hextob64u(d.p.toString(16));b.q=hextob64u(d.q.toString(16));b.dp=hextob64u(d.dmp1.toString(16));b.dq=hextob64u(d.dmq1.toString(16));b.qi=hextob64u(d.coeff.toString(16));return b}else{if(d instanceof RSAKey&&d.isPublic){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPrivate){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);b.d=hextob64u(d.prvKeyHex);return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPublic){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);return b}}}}throw\"not supported key object\"};\nRSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,j,l,b,a,f,d,k;var m=ASN1HEX;var g=m.getVbyList;if(m.isASN1HEX(e)===false){throw\"not ASN.1 hex string\"}try{c=g(e,0,[2,0,1],\"02\");j=g(e,0,[2,0,2],\"02\");l=g(e,0,[2,0,3],\"02\");b=g(e,0,[2,0,4],\"02\");a=g(e,0,[2,0,5],\"02\");f=g(e,0,[2,0,6],\"02\");d=g(e,0,[2,0,7],\"02\");k=g(e,0,[2,0,8],\"02\")}catch(i){throw\"malformed PKCS#8 plain RSA private key\"}this.setPrivateEx(c,j,l,b,a,f,d,k)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw\"keyHex is not ASN.1 hex string\"}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!==\"02\"||c.substr(a[1],2)!==\"02\"){throw\"wrong hex for PKCS#5 public key\"}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw\"not ASN.1 hex string\"}if(c.getTLVbyList(b,0,[0,0])!==\"06092a864886f70d010101\"){throw\"not PKCS8 RSA public key\"}var a=c.getTLVbyList(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)};\nvar _RE_HEXDECONLY=new RegExp(\"\");_RE_HEXDECONLY.compile(\"[^0-9a-f]\",\"gi\");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c=\"\";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw\"invalid salt length\"}}}if(c<(g+k+2)){throw\"data too long\"}var f=\"\";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dthis.n.bitLength()){return 0}var i=this.doPublic(b);var e=i.toString(16).replace(/^1f+00/,\"\");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(k){return KJUR.crypto.Util.hashString(k,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){a=a.replace(_RE_HEXDECONLY,\"\");a=a.replace(/[ \\n]+/g,\"\");var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,\"\");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){var k=new BigInteger(s,16);if(k.bitLength()>this.n.bitLength()){return false}var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw\"invalid salt length\"}}}if(m<(h+c+2)){throw\"data too long\"}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw\"bits beyond keysize not zero\"}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q0){var b=\":\"+n.join(\":\")+\":\";if(b.indexOf(\":\"+k+\":\")==-1){throw\"algorithm '\"+k+\"' not accepted in the list\"}}if(k!=\"none\"&&B===null){throw\"key shall be specified to verify.\"}if(typeof B==\"string\"&&B.indexOf(\"-----BEGIN \")!=-1){B=KEYUTIL.getKey(B)}if(z==\"RS\"||z==\"PS\"){if(!(B instanceof m)){throw\"key shall be a RSAKey obj for RS* and PS* algs\"}}if(z==\"ES\"){if(!(B instanceof p)){throw\"key shall be a ECDSA obj for ES* algs\"}}if(k==\"none\"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw\"unsupported alg name: \"+k}else{u=t.jwsalg2sigalg[k]}if(u==\"none\"){throw\"not supported\"}else{if(u.substr(0,4)==\"Hmac\"){var o=null;if(B===undefined){throw\"hexadecimal key shall be specified for HMAC\"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf(\"withECDSA\")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(\".\");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw\"malformed sJWS: wrong number of '.' splitted elements\"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null,\" \");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null,\" \")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;var k=e.split(\".\");var c=k[0];var i=k[1];var q=c+\".\"+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw\"acceptField.alg shall be specified\"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss===\"object\"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub===\"object\"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud===\"object\"){if(typeof g.aud==\"string\"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud==\"object\"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt===\"number\"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!==\"number\"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp==\"number\"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw\"addSignature failed: \"+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw\"malformed header\"}if(typeof g.payload===\"string\"){this.sPayload=g.payload}else{throw\"malformed signatures\"}if(g.signatures.length>0){this.aSignatures=g.signatures}else{throw\"malformed signatures\"}}catch(e){throw\"malformed JWS-JS JSON object: \"+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}};\nexports.SecureRandom = SecureRandom;\nexports.rng_seed_time = rng_seed_time;\n\nexports.BigInteger = BigInteger;\nexports.RSAKey = RSAKey;\nexports.ECDSA = KJUR.crypto.ECDSA;\nexports.DSA = KJUR.crypto.DSA;\nexports.Signature = KJUR.crypto.Signature;\nexports.MessageDigest = KJUR.crypto.MessageDigest;\nexports.Mac = KJUR.crypto.Mac;\nexports.Cipher = KJUR.crypto.Cipher;\nexports.KEYUTIL = KEYUTIL;\nexports.ASN1HEX = ASN1HEX;\nexports.X509 = X509;\nexports.CryptoJS = CryptoJS;\n\n// ext/base64.js\nexports.b64tohex = b64tohex;\nexports.b64toBA = b64toBA;\n\n// base64x.js\nexports.stoBA = stoBA;\nexports.BAtos = BAtos;\nexports.BAtohex = BAtohex;\nexports.stohex = stohex;\nexports.stob64 = stob64;\nexports.stob64u = stob64u;\nexports.b64utos = b64utos;\nexports.b64tob64u = b64tob64u;\nexports.b64utob64 = b64utob64;\nexports.hex2b64 = hex2b64;\nexports.hextob64u = hextob64u;\nexports.b64utohex = b64utohex;\nexports.utf8tob64u = utf8tob64u;\nexports.b64utoutf8 = b64utoutf8;\nexports.utf8tob64 = utf8tob64;\nexports.b64toutf8 = b64toutf8;\nexports.utf8tohex = utf8tohex;\nexports.hextoutf8 = hextoutf8;\nexports.hextorstr = hextorstr;\nexports.rstrtohex = rstrtohex;\nexports.hextob64 = hextob64;\nexports.hextob64nl = hextob64nl;\nexports.b64nltohex = b64nltohex;\nexports.hextopem = hextopem;\nexports.pemtohex = pemtohex;\nexports.hextoArrayBuffer = hextoArrayBuffer;\nexports.ArrayBuffertohex = ArrayBuffertohex;\nexports.zulutomsec = zulutomsec;\nexports.zulutosec = zulutosec;\nexports.zulutodate = zulutodate;\nexports.datetozulu = datetozulu;\nexports.uricmptohex = uricmptohex;\nexports.hextouricmp = hextouricmp;\nexports.ipv6tohex = ipv6tohex;\nexports.hextoipv6 = hextoipv6;\nexports.hextoip = hextoip;\nexports.iptohex = iptohex;\nexports.encodeURIComponentAll = encodeURIComponentAll;\nexports.newline_toUnix = newline_toUnix;\nexports.newline_toDos = newline_toDos;\nexports.hextoposhex = hextoposhex;\nexports.intarystrtohex = intarystrtohex;\nexports.strdiffidx = strdiffidx;\n\n// name spaces\nexports.KJUR = KJUR;\nexports.crypto = KJUR.crypto;\nexports.asn1 = KJUR.asn1;\nexports.jws = KJUR.jws;\nexports.lang = KJUR.lang;\n\n\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://AppID/./node_modules/jsrsasign/lib/jsrsasign.js?"); + +/***/ }), + +/***/ "./node_modules/node-fetch/browser.js": +/*!********************************************!*\ + !*** ./node_modules/node-fetch/browser.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n// ref: https://github.com/tc39/proposal-global\nvar getGlobal = function () {\n\t// the only reliable means to get the global object is\n\t// `Function('return this')()`\n\t// However, this causes CSP violations in Chrome apps.\n\tif (typeof self !== 'undefined') { return self; }\n\tif (typeof window !== 'undefined') { return window; }\n\tif (typeof global !== 'undefined') { return global; }\n\tthrow new Error('unable to locate global object');\n}\n\nvar global = getGlobal();\n\nmodule.exports = exports = global.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = global.fetch.bind(global);\n\nexports.Headers = global.Headers;\nexports.Request = global.Request;\nexports.Response = global.Response;\n\n//# sourceURL=webpack://AppID/./node_modules/node-fetch/browser.js?"); + +/***/ }), + +/***/ "./node_modules/webpack/buildin/global.js": +/*!***********************************!*\ + !*** (webpack)/buildin/global.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://AppID/(webpack)/buildin/global.js?"); + +/***/ }), + +/***/ "./package.json": +/*!**********************!*\ + !*** ./package.json ***! + \**********************/ +/*! exports provided: name, version, description, scripts, repository, main, nyc, dependencies, devDependencies, default */ +/***/ (function(module) { + +eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"ibmcloud-appid-js\\\",\\\"version\\\":\\\"0.3.0\\\",\\\"description\\\":\\\"IBM Cloud App ID SDK for Single Page Applications\\\",\\\"scripts\\\":{\\\"build\\\":\\\"webpack --mode=development\\\",\\\"test\\\":\\\"mocha\\\",\\\"coverage\\\":\\\"nyc --reporter=lcov mocha\\\",\\\"docs\\\":\\\"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json\\\"},\\\"repository\\\":{\\\"type\\\":\\\"git\\\",\\\"url\\\":\\\"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git\\\"},\\\"main\\\":\\\"dist/appid.umd.min.js\\\",\\\"nyc\\\":{\\\"all\\\":true,\\\"include\\\":[\\\"src/*.js\\\"],\\\"exclude\\\":[\\\"**/PopupController.js\\\",\\\"**/IFrameController.js\\\",\\\"**/OpenIDConfigurationResource.js\\\",\\\"**/constants.js\\\"]},\\\"dependencies\\\":{\\\"jsrsasign\\\":\\\"^8.0.12\\\"},\\\"devDependencies\\\":{\\\"node-fetch\\\":\\\"^2.6.0\\\",\\\"@babel/cli\\\":\\\"^7.0.0\\\",\\\"@babel/core\\\":\\\"^7.5.5\\\",\\\"@babel/plugin-transform-runtime\\\":\\\"^7.5.5\\\",\\\"@babel/preset-env\\\":\\\"^7.5.5\\\",\\\"babel-cli\\\":\\\"^7.0.0-beta.3\\\",\\\"chai\\\":\\\"^4.2.0\\\",\\\"coveralls\\\":\\\"^3.0.6\\\",\\\"gulp-babel\\\":\\\"^8.0.0\\\",\\\"mocha\\\":\\\"^6.2.0\\\",\\\"nyc\\\":\\\"^14.1.1\\\",\\\"webpack\\\":\\\"^4.39.1\\\",\\\"webpack-cli\\\":\\\"^3.3.6\\\",\\\"docdash\\\":\\\"^1.1.1\\\",\\\"jsdoc\\\":\\\"^3.6.3\\\"}}\");\n\n//# sourceURL=webpack://AppID/./package.json?"); + +/***/ }), + +/***/ "./src/IFrameController.js": +/*!*********************************!*\ + !*** ./src/IFrameController.js ***! + \*********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const IFrameError = __webpack_require__(/*! ./errors/IFrameError */ \"./src/errors/IFrameError.js\");\n\nclass IFrameController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t}\n\n\topen(url) {\n\t\tthis.iFrame = this.window.document.createElement('iframe');\n\t\tthis.iFrame.src = url;\n\t\tthis.iFrame.width = 0;\n\t\tthis.iFrame.height = 0;\n\t\tthis.window.document.body.appendChild(this.iFrame);\n\t}\n\n\tremove() {\n\t\twindow.document.body.removeChild(this.iFrame);\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\treject(new IFrameError('Silent sign-in timed out'));\n\t\t\t}, 5 * 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tclearInterval(timer);\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = IFrameController;\n\n\n//# sourceURL=webpack://AppID/./src/IFrameController.js?"); + +/***/ }), + +/***/ "./src/OpenIDConfigurationResource.js": +/*!********************************************!*\ + !*** ./src/OpenIDConfigurationResource.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const packagejson = __webpack_require__(/*! ../package.json */ \"./package.json\");\n\nclass OpenIdConfigurationResource {\n\tasync init({discoveryEndpoint, requestHandler}){\n\t\tthis.openIdConfig = await requestHandler(discoveryEndpoint);\n\t\tconst headers = { 'x-filter-type': `spa:v${packagejson.version}` };\n\t\tthis.publicKeys = requestHandler(this.getJwksEndpoint(), { headers: headers });\n\t}\n\n\tgetAuthorizationEndpoint() {\n\t\treturn this.openIdConfig.authorization_endpoint;\n\t}\n\n\tgetUserInfoEndpoint() {\n\t\treturn this.openIdConfig.userinfo_endpoint;\n\t}\n\n\tgetJwksEndpoint() {\n\t\treturn this.openIdConfig.jwks_uri;\n\t}\n\n\tgetTokenEndpoint() {\n\t\treturn this.openIdConfig.token_endpoint;\n\t}\n\n\tgetIssuer() {\n\t\treturn this.openIdConfig.issuer;\n\t}\n\n\tasync getPublicKeys() {\n\t\treturn await this.publicKeys;\n\t}\n}\nmodule.exports = OpenIdConfigurationResource;\n\n\n\n//# sourceURL=webpack://AppID/./src/OpenIDConfigurationResource.js?"); + +/***/ }), + +/***/ "./src/PopupController.js": +/*!********************************!*\ + !*** ./src/PopupController.js ***! + \********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const PopupError = __webpack_require__(/*! ./errors/PopupError */ \"./src/errors/PopupError.js\");\n\nclass PopupController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t};\n\n\tinit(popupConfig){\n\t\tthis.popupConfig = popupConfig;\n\t}\n\n\topen() {\n\t\tconst h = this.popupConfig.height;\n\t\tconst w = this.popupConfig.width;\n\t\tconst left = (window.screen.width - w) / 2;\n\t\tconst top = (window.screen.height - h) / 2;\n\t\tthis.popup = this.window.open('', 'popup', `left=${left},top=${top},width=${w},height=${h},resizable,scrollbars=yes,status=1`);\n\t\tif (!this.popup) {\n\t\t\tthrow new PopupError('Unable to open popup')\n\t\t}\n\t};\n\n\tnavigate(url) {\n\t\tthis.popup.location.href = url;\n\t};\n\n\tclose() {\n\t\tthis.popup.close();\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\tif(this.popup.closed) {\n\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\treject(new PopupError('Popup closed'));\n\t\t\t\t}\n\t\t\t}, 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = PopupController;\n\n\n//# sourceURL=webpack://AppID/./src/PopupController.js?"); + +/***/ }), + +/***/ "./src/RequestHandler.js": +/*!*******************************!*\ + !*** ./src/RequestHandler.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t}\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); + +/***/ }), + +/***/ "./src/TokenValidator.js": +/*!*******************************!*\ + !*** ./src/TokenValidator.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg:[constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif (nonce && (!decoded.payloadObj.nonce || decoded.payloadObj.nonce !== nonce)) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor(let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); + +/***/ }), + +/***/ "./src/constants.js": +/*!**************************!*\ + !*** ./src/constants.js ***! + \**************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN: 'Invalid id token',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN: 'Missing id token string',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); + +/***/ }), + +/***/ "./src/errors/AppIDError.js": +/*!**********************************!*\ + !*** ./src/errors/AppIDError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class AppIDError extends Error {}\nmodule.exports = AppIDError;\n\n//# sourceURL=webpack://AppID/./src/errors/AppIDError.js?"); + +/***/ }), + +/***/ "./src/errors/IFrameError.js": +/*!***********************************!*\ + !*** ./src/errors/IFrameError.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class IFrameError extends Error {}\nmodule.exports = IFrameError;\n\n//# sourceURL=webpack://AppID/./src/errors/IFrameError.js?"); + +/***/ }), + +/***/ "./src/errors/OAuthError.js": +/*!**********************************!*\ + !*** ./src/errors/OAuthError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class OAuthError extends Error {\n\t// See https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for the possible error messages\n\tconstructor({error, description}) {\n\t\tsuper(description || error);\n\t\tthis.error = error;\n\t\tthis.description = description;\n\t}\n}\nmodule.exports = OAuthError;\n\n//# sourceURL=webpack://AppID/./src/errors/OAuthError.js?"); + +/***/ }), + +/***/ "./src/errors/PopupError.js": +/*!**********************************!*\ + !*** ./src/errors/PopupError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class PopupError extends Error {}\nmodule.exports = PopupError;\n\n//# sourceURL=webpack://AppID/./src/errors/PopupError.js?"); + +/***/ }), + +/***/ "./src/errors/RequestError.js": +/*!************************************!*\ + !*** ./src/errors/RequestError.js ***! + \************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class RequestError extends Error {\n\tconstructor(description, status, originError) {\n\t\tsuper(description);\n\t\tthis.status = status;\n\t\tthis.originError = originError;\n\t}\n}\nmodule.exports = RequestError;\n\n//# sourceURL=webpack://AppID/./src/errors/RequestError.js?"); + +/***/ }), + +/***/ "./src/errors/TokenError.js": +/*!**********************************!*\ + !*** ./src/errors/TokenError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class TokenError extends Error {}\nmodule.exports = TokenError;\n\n//# sourceURL=webpack://AppID/./src/errors/TokenError.js?"); + +/***/ }), + +/***/ "./src/index.js": +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\")\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in allows you to automatically obtain new tokens for a user without the user having to re-authenticate using a popup.\n\t * This will attempt to authenticate the user in a hidden iframe.\n\t * You will need to [enable Cloud Directory SSO]{@link https://cloud.ibm.com/docs/services/appid?topic=appid-single-page#spa-silent-login}.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {string} idToken A JWT.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @example\n\t * let tokens = await appID.changePassword(idToken);\n\t */\n\tasync changePassword(idToken) {\n\t\tthis._validateInitalize();\n\n\t\tif (!idToken || typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tlet userId;\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\t\tlet decodedToken = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: idToken,\n\t\t\tpublicKeys,\n\t\t\tissuer: this.openIdConfigResource.getIssuer(),\n\t\t\tclientId: this.clientId\n\t\t});\n\n\t\tif (decodedToken.identities && decodedToken.identities[0] && decodedToken.identities[0].id) {\n\t\t\tif (decodedToken.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = decodedToken.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn await this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); + +/***/ }), + +/***/ "./src/utils.js": +/*!**********************!*\ + !*** ./src/utils.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); + +/***/ }) + +/******/ }); \ No newline at end of file diff --git a/dist/appid.umd.min.js b/dist/appid.umd.min.js index a646072..d831b76 100644 --- a/dist/appid.umd.min.js +++ b/dist/appid.umd.min.js @@ -1,50 +1,345 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.AppID=e():t.AppID=e()}(window,(function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=5)}([function(t,e,i){(function(t){var i={userAgent:!1},n={}; -/*! -Copyright (c) 2011, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.9.0 -*/ -if(void 0===r)var r={};r.lang={extend:function(t,e,n){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),n){var s;for(s in n)t.prototype[s]=n[s];var o=function(){},a=["toString","valueOf"];try{/MSIE/.test(i.userAgent)&&(o=function(t,e){for(s=0;s>>2]>>>24-s%4*8&255;e[n+s>>>2]|=o<<24-(n+s)%4*8}else for(s=0;s>>2]=i[s>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=s.ceil(e/4)},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i>>2]>>>24-r%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new u.init(i,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,i=t.sigBytes,n=[],r=0;r>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new u.init(i,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},g=a.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,n=e.sigBytes,r=this.blockSize,o=n/(4*r),a=(o=t?s.ceil(o):s.max((0|o)-this._minBufferSize,0))*r,h=s.min(4*a,n);if(a){for(var c=0;c>>2]}},e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:h,padding:c}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(h=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?n.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=n.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:i})}},e.SerializableCipher=i.extend({cfg:i.extend({format:h}),encrypt:function(t,e,i,n){n=this.cfg.extend(n);var r=t.createEncryptor(i,n);return e=r.finalize(e),r=r.cfg,l.create({ciphertext:e,key:i,iv:r.iv,algorithm:t,mode:r.mode,padding:r.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(i,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,i,r){return r||(r=n.random(8)),t=o.create({keySize:e+i}).compute(t,r),i=n.create(t.words.slice(e),4*i),t.sigBytes=4*e,l.create({key:t,iv:i,salt:r})}},g=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:d}),encrypt:function(t,e,i,n){return i=(n=this.cfg.extend(n)).kdf.execute(i,t.keySize,t.ivSize),n.iv=i.iv,(t=f.encrypt.call(this,t,e,i.key,n)).mixIn(i),t},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),i=n.kdf.execute(i,t.keySize,t.ivSize,e.salt),n.iv=i.iv,f.decrypt.call(this,t,e,i.key,n)}})}(),function(){for(var t=y,e=t.lib.BlockCipher,i=t.algo,n=[],r=[],s=[],o=[],a=[],h=[],u=[],c=[],l=[],f=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var p=0,v=0;for(g=0;256>g;g++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;n[p]=m,r[m]=p;var S=d[p],F=d[S],w=d[F],E=257*d[m]^16843008*m;s[p]=E<<24|E>>>8,o[p]=E<<16|E>>>16,a[p]=E<<8|E>>>24,h[p]=E,E=16843009*w^65537*F^257*S^16843008*p,u[m]=E<<24|E>>>8,c[m]=E<<16|E>>>16,l[m]=E<<8|E>>>24,f[m]=E,p?(p=S^d[d[d[w^S]]],v^=d[d[v]]):p=v=1}var x=[0,1,2,4,8,16,32,64,128,27,54];i=i.AES=e.extend({_doReset:function(){for(var t=(i=this._key).words,e=i.sigBytes/4,i=4*((this._nRounds=e+6)+1),r=this._keySchedule=[],s=0;s>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o]):(o=n[(o=o<<8|o>>>24)>>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o],o^=x[s/e|0]<<24),r[s]=r[s-e]^o}for(t=this._invKeySchedule=[],e=0;ee||4>=s?o:u[n[o>>>24]]^c[n[o>>>16&255]]^l[n[o>>>8&255]]^f[n[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,o,a,h,n)},decryptBlock:function(t,e){var i=t[e+1];t[e+1]=t[e+3],t[e+3]=i,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,r),i=t[e+1],t[e+1]=t[e+3],t[e+3]=i},_doCryptBlock:function(t,e,i,n,r,s,o,a){for(var h=this._nRounds,u=t[e]^i[0],c=t[e+1]^i[1],l=t[e+2]^i[2],f=t[e+3]^i[3],d=4,g=1;g>>24]^r[c>>>16&255]^s[l>>>8&255]^o[255&f]^i[d++],y=n[c>>>24]^r[l>>>16&255]^s[f>>>8&255]^o[255&u]^i[d++],v=n[l>>>24]^r[f>>>16&255]^s[u>>>8&255]^o[255&c]^i[d++];f=n[f>>>24]^r[u>>>16&255]^s[c>>>8&255]^o[255&l]^i[d++],u=p,c=y,l=v}p=(a[u>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&f])^i[d++],y=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[f>>>8&255]<<8|a[255&u])^i[d++],v=(a[l>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[255&c])^i[d++],f=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^i[d++],t[e]=p,t[e+1]=y,t[e+2]=v,t[e+3]=f},keySize:8});t.AES=e._createHelper(i)}(),function(){function t(t,e){var i=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=i,this._lBlock^=i<>>t^this._lBlock)&e;this._lBlock^=i,this._rBlock^=i<i;i++){var n=o[i]-1;e[i]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;16>n;n++){var r=t[n]=[],s=h[n];for(i=0;24>i;i++)r[i/6|0]|=e[(a[i]-1+s)%28]<<31-i%6,r[4+(i/6|0)]|=e[28+(a[i+24]-1+s)%28]<<31-i%6;for(r[0]=r[0]<<1|r[0]>>>31,i=1;7>i;i++)r[i]>>>=4*(i-1)+3;r[7]=r[7]<<5|r[7]>>>27}for(e=this._invSubKeys=[],i=0;16>i;i++)e[i]=t[15-i]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(i,n,r){this._lBlock=i[n],this._rBlock=i[n+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var o=r[s],a=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^o[f])&c[f])>>>0];this._lBlock=h,this._rBlock=a^l}r=this._lBlock,this._lBlock=this._rBlock,this._rBlock=r,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),i[n]=this._lBlock,i[n+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});i.DES=r._createHelper(l),s=s.TripleDES=r.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(n.create(t.slice(0,2))),this._des2=l.createEncryptor(n.create(t.slice(2,4))),this._des3=l.createEncryptor(n.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),i.TripleDES=r._createHelper(s)}(),function(){var t=y,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,i=t.sigBytes,n=this._map;t.clamp(),t=[];for(var r=0;r>>2]>>>24-r%4*8&255)<<16|(e[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|e[r+2>>>2]>>>24-(r+2)%4*8&255,o=0;4>o&&r+.75*o>>6*(3-o)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var i=t.length,n=this._map;(r=n.charAt(64))&&(-1!=(r=t.indexOf(r))&&(i=r));for(var r=[],s=0,o=0;o>>6-o%4*2;r[s>>>2]|=(a|h)<<24-s%4*8,s++}return e.create(r,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,i,n,r,s,o){return((t=t+(e&i|~e&n)+r+o)<>>32-s)+e}function i(t,e,i,n,r,s,o){return((t=t+(e&n|i&~n)+r+o)<>>32-s)+e}function n(t,e,i,n,r,s,o){return((t=t+(e^i^n)+r+o)<>>32-s)+e}function r(t,e,i,n,r,s,o){return((t=t+(i^(e|~n))+r+o)<>>32-s)+e}for(var s=y,o=(h=s.lib).WordArray,a=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var o=0;16>o;o++){var a=t[h=s+o];t[h]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var h=t[s+0],c=(a=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],d=t[s+5],g=t[s+6],p=t[s+7],y=t[s+8],v=t[s+9],m=t[s+10],S=t[s+11],F=t[s+12],w=t[s+13],E=t[s+14],x=t[s+15],b=e(b=o[0],C=o[1],I=o[2],A=o[3],h,7,u[0]),A=e(A,b,C,I,a,12,u[1]),I=e(I,A,b,C,c,17,u[2]),C=e(C,I,A,b,l,22,u[3]);b=e(b,C,I,A,f,7,u[4]),A=e(A,b,C,I,d,12,u[5]),I=e(I,A,b,C,g,17,u[6]),C=e(C,I,A,b,p,22,u[7]),b=e(b,C,I,A,y,7,u[8]),A=e(A,b,C,I,v,12,u[9]),I=e(I,A,b,C,m,17,u[10]),C=e(C,I,A,b,S,22,u[11]),b=e(b,C,I,A,F,7,u[12]),A=e(A,b,C,I,w,12,u[13]),I=e(I,A,b,C,E,17,u[14]),b=i(b,C=e(C,I,A,b,x,22,u[15]),I,A,a,5,u[16]),A=i(A,b,C,I,g,9,u[17]),I=i(I,A,b,C,S,14,u[18]),C=i(C,I,A,b,h,20,u[19]),b=i(b,C,I,A,d,5,u[20]),A=i(A,b,C,I,m,9,u[21]),I=i(I,A,b,C,x,14,u[22]),C=i(C,I,A,b,f,20,u[23]),b=i(b,C,I,A,v,5,u[24]),A=i(A,b,C,I,E,9,u[25]),I=i(I,A,b,C,l,14,u[26]),C=i(C,I,A,b,y,20,u[27]),b=i(b,C,I,A,w,5,u[28]),A=i(A,b,C,I,c,9,u[29]),I=i(I,A,b,C,p,14,u[30]),b=n(b,C=i(C,I,A,b,F,20,u[31]),I,A,d,4,u[32]),A=n(A,b,C,I,y,11,u[33]),I=n(I,A,b,C,S,16,u[34]),C=n(C,I,A,b,E,23,u[35]),b=n(b,C,I,A,a,4,u[36]),A=n(A,b,C,I,f,11,u[37]),I=n(I,A,b,C,p,16,u[38]),C=n(C,I,A,b,m,23,u[39]),b=n(b,C,I,A,w,4,u[40]),A=n(A,b,C,I,h,11,u[41]),I=n(I,A,b,C,l,16,u[42]),C=n(C,I,A,b,g,23,u[43]),b=n(b,C,I,A,v,4,u[44]),A=n(A,b,C,I,F,11,u[45]),I=n(I,A,b,C,x,16,u[46]),b=r(b,C=n(C,I,A,b,c,23,u[47]),I,A,h,6,u[48]),A=r(A,b,C,I,p,10,u[49]),I=r(I,A,b,C,E,15,u[50]),C=r(C,I,A,b,d,21,u[51]),b=r(b,C,I,A,F,6,u[52]),A=r(A,b,C,I,l,10,u[53]),I=r(I,A,b,C,m,15,u[54]),C=r(C,I,A,b,a,21,u[55]),b=r(b,C,I,A,y,6,u[56]),A=r(A,b,C,I,x,10,u[57]),I=r(I,A,b,C,g,15,u[58]),C=r(C,I,A,b,w,21,u[59]),b=r(b,C,I,A,f,6,u[60]),A=r(A,b,C,I,S,10,u[61]),I=r(I,A,b,C,c,15,u[62]),C=r(C,I,A,b,v,21,u[63]);o[0]=o[0]+b|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+A|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;i[r>>>5]|=128<<24-r%32;var s=t.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(i.length+1),this._process(),i=(e=this._hash).words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=a._createHelper(h),s.HmacMD5=a._createHmacHelper(h)}(Math),function(){var t=y,e=(r=t.lib).WordArray,i=r.Hasher,n=[],r=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=this._hash.words,r=i[0],s=i[1],o=i[2],a=i[3],h=i[4],u=0;80>u;u++){if(16>u)n[u]=0|t[e+u];else{var c=n[u-3]^n[u-8]^n[u-14]^n[u-16];n[u]=c<<1|c>>>31}c=(r<<5|r>>>27)+h+n[u],c=20>u?c+(1518500249+(s&o|~s&a)):40>u?c+(1859775393+(s^o^a)):60>u?c+((s&o|s&a|o&a)-1894007588):c+((s^o^a)-899497514),h=a,a=o,o=s<<30|s>>>2,s=r,r=c}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+o|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(i/4294967296),e[15+(n+64>>>9<<4)]=i,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=i._createHelper(r),t.HmacSHA1=i._createHmacHelper(r)}(),function(t){for(var e=y,i=(r=e.lib).WordArray,n=r.Hasher,r=e.algo,s=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=a(t.pow(h,.5))),o[u]=a(t.pow(h,1/3)),u++),h++}var d=[];r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(t,e){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],a=i[3],h=i[4],u=i[5],c=i[6],l=i[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var g=d[f-15],p=d[f-2];d[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[f-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[f-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+o[f]+d[f],p=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&r^n&s^r&s),l=c,c=u,u=h,h=a+g|0,a=s,s=r,r=n,n=g+p|0}i[0]=i[0]+n|0,i[1]=i[1]+r|0,i[2]=i[2]+s|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0,i[5]=i[5]+u|0,i[6]=i[6]+c|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return i[r>>>5]|=128<<24-r%32,i[14+(r+64>>>9<<4)]=t.floor(n/4294967296),i[15+(r+64>>>9<<4)]=n,e.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(r),e.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var t=y,e=t.lib.WordArray,i=(n=t.algo).SHA256,n=n.SHA224=i.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=i._createHelper(n),t.HmacSHA224=i._createHmacHelper(n)}(),function(){function t(){return n.create.apply(n,arguments)}for(var e=y,i=e.lib.Hasher,n=(s=e.x64).Word,r=s.WordArray,s=e.algo,o=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],a=[],h=0;80>h;h++)a[h]=t();s=s.SHA512=i.extend({_doReset:function(){this._hash=new r.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var i=(l=this._hash.words)[0],n=l[1],r=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=i.high,d=i.low,g=n.high,p=n.low,y=r.high,v=r.low,m=s.high,S=s.low,F=h.high,w=h.low,E=u.high,x=u.low,b=c.high,A=c.low,I=l.high,C=l.low,D=f,T=d,P=g,R=p,H=y,B=v,N=m,O=S,j=F,V=w,L=E,_=x,K=b,k=A,M=I,U=C,q=0;80>q;q++){var z=a[q];if(16>q)var G=z.high=0|t[e+2*q],Y=z.low=0|t[e+2*q+1];else{G=((Y=(G=a[q-15]).high)>>>1|(J=G.low)<<31)^(Y>>>8|J<<24)^Y>>>7;var J=(J>>>1|Y<<31)^(J>>>8|Y<<24)^(J>>>7|Y<<25),W=((Y=(W=a[q-2]).high)>>>19|(X=W.low)<<13)^(Y<<3|X>>>29)^Y>>>6,X=(X>>>19|Y<<13)^(X<<3|Y>>>29)^(X>>>6|Y<<26),Z=(Y=a[q-7]).high,$=(Q=a[q-16]).high,Q=Q.low;G=(G=(G=G+Z+((Y=J+Y.low)>>>0>>0?1:0))+W+((Y=Y+X)>>>0>>0?1:0))+$+((Y=Y+Q)>>>0>>0?1:0);z.high=G,z.low=Y}Z=j&L^~j&K,Q=V&_^~V&k,z=D&P^D&H^P&H;var tt=T&R^T&B^R&B,et=(J=(D>>>28|T<<4)^(D<<30|T>>>2)^(D<<25|T>>>7),W=(T>>>28|D<<4)^(T<<30|D>>>2)^(T<<25|D>>>7),(X=o[q]).high),it=X.low;$=M+((j>>>14|V<<18)^(j>>>18|V<<14)^(j<<23|V>>>9))+((X=U+((V>>>14|j<<18)^(V>>>18|j<<14)^(V<<23|j>>>9)))>>>0>>0?1:0),M=K,U=k,K=L,k=_,L=j,_=V,j=N+($=($=($=$+Z+((X=X+Q)>>>0>>0?1:0))+et+((X=X+it)>>>0>>0?1:0))+G+((X=X+Y)>>>0>>0?1:0))+((V=O+X|0)>>>0>>0?1:0)|0,N=H,O=B,H=P,B=R,P=D,R=T,D=$+(z=J+z+((Y=W+tt)>>>0>>0?1:0))+((T=X+Y|0)>>>0>>0?1:0)|0}d=i.low=d+T,i.high=f+D+(d>>>0>>0?1:0),p=n.low=p+R,n.high=g+P+(p>>>0>>0?1:0),v=r.low=v+B,r.high=y+H+(v>>>0>>0?1:0),S=s.low=S+O,s.high=m+N+(S>>>0>>0?1:0),w=h.low=w+V,h.high=F+j+(w>>>0>>0?1:0),x=u.low=x+_,u.high=E+L+(x>>>0<_>>>0?1:0),A=c.low=A+k,c.high=b+K+(A>>>0>>0?1:0),C=l.low=C+U,l.high=I+M+(C>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(i/4294967296),e[31+(n+128>>>10<<5)]=i,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=i._createHelper(s),e.HmacSHA512=i._createHmacHelper(s)}(),function(){var t=y,e=(r=t.x64).Word,i=r.WordArray,n=(r=t.algo).SHA512,r=r.SHA384=n.extend({_doReset:function(){this._hash=new i.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(r),t.HmacSHA384=n._createHmacHelper(r)}(),function(){var t=y,e=(n=t.lib).WordArray,i=n.Hasher,n=t.algo,r=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),o=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);n=n.RIPEMD160=i.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=0;16>i;i++){var n=t[F=e+i];t[F]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var c,l,f,d,g,p,y,v,m,S,F=this._hash.words,w=(n=h.words,u.words),E=r.words,x=s.words,b=o.words,A=a.words;p=c=F[0],y=l=F[1],v=f=F[2],m=d=F[3],S=g=F[4];var I;for(i=0;80>i;i+=1)I=c+t[e+E[i]]|0,I=16>i?I+((l^f^d)+n[0]):32>i?I+((l&f|~l&d)+n[1]):48>i?I+(((l|~f)^d)+n[2]):64>i?I+((l&d|f&~d)+n[3]):I+((l^(f|~d))+n[4]),I=(I=(I|=0)<>>32-b[i])+g|0,c=g,g=d,d=f<<10|f>>>22,f=l,l=I,I=p+t[e+x[i]]|0,I=16>i?I+((y^(v|~m))+w[0]):32>i?I+((y&m|v&~m)+w[1]):48>i?I+(((y|~v)^m)+w[2]):64>i?I+((y&v|~y&m)+w[3]):I+((y^v^m)+w[4]),I=(I=(I|=0)<>>32-A[i])+S|0,p=S,S=m,m=v<<10|v>>>22,v=y,y=I;I=F[1]+f+m|0,F[1]=F[2]+d+S|0,F[2]=F[3]+g+p|0,F[3]=F[4]+c+y|0,F[4]=F[0]+l+v|0,F[0]=I},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,i=0;5>i;i++)n=e[i],e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(n),t.HmacRIPEMD160=i._createHmacHelper(n)}(Math),function(){var t=y,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,i){t=this._hasher=new t.init,"string"==typeof i&&(i=e.parse(i));var n=t.blockSize,r=4*n;i.sigBytes>r&&(i=t.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),o=this._iKey=i.clone(),a=s.words,h=o.words,u=0;u>6)+m.charAt(63&i);if(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),n+=m.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),n+=m.charAt(i>>2)+m.charAt((3&i)<<4)),S)for(;(3&n.length)>0;)n+=S;return n}function w(t){var e,i,n,r="",s=0;for(e=0;e>2),i=3&n,s=1):1==s?(r+=T(i<<2|n>>4),i=15&n,s=2):2==s?(r+=T(i),r+=T(n>>2),i=3&n,s=3):(r+=T(i<<2|n>>4),r+=T(15&n),s=0));return 1==s&&(r+=T(i<<2)),r}function E(t){var e,i=w(t),n=new Array;for(e=0;2*e>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;r=((h=o*h+((32767&c)<<15)+i[n]+(1073741823&r))>>>30)+(c>>>15)+a*u+(r>>>30),i[n++]=1073741823&h}return r},v=30):"Netscape"!=i.appName?(x.prototype.am=function(t,e,i,n,r,s){for(;--s>=0;){var o=e*this[t++]+i[n]+r;r=Math.floor(o/67108864),i[n++]=67108863&o}return r},v=26):(x.prototype.am=function(t,e,i,n,r,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;r=((h=o*h+((16383&c)<<14)+i[n]+r)>>28)+(c>>14)+a*u,i[n++]=268435455&h}return r},v=28),x.prototype.DB=v,x.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function B(t){this.m=t}function N(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function K(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function k(){}function M(t){return t}function U(t){this.r2=b(),this.q3=b(),x.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}B.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},B.prototype.revert=function(t){return t},B.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},B.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},B.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},N.prototype.convert=function(t){var e=b();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(x.ZERO)>0&&this.m.subTo(e,e),e},N.prototype.revert=function(t){var e=b();return t.copyTo(e),this.reduce(e),e},N.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},N.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},N.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},x.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},x.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},x.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,r=!1,s=0;--n>=0;){var o=8==i?255&t[n]:P(t,n);o<0?"-"==t.charAt(n)&&(r=!0):(r=!1,0==s?this[this.t++]=o:s+i>this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},x.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},x.prototype.drShiftTo=function(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>r|a,a=(this[i]&s)<=0;--i)e[i]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},x.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,r=this.DB-n,s=(1<>n;for(var o=i+1;o>n;n>0&&(e[this.t-i-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},x.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),r=i.t;for(e.t=r+n.t;--r>=0;)e[r]=0;for(r=0;r=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},x.prototype.divRemTo=function(t,e,i){var n=t.abs();if(!(n.t<=0)){var r=this.abs();if(r.t0?(n.lShiftTo(h,s),r.lShiftTo(h,i)):(n.copyTo(s),r.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<1?s[u-2]>>this.F2:0),f=this.FV/l,d=(1<=0&&(i[i.t++]=1,i.subTo(v,i)),x.ONE.dlShiftTo(u,v),v.subTo(s,s);s.t=0;){var m=i[--p]==c?this.DM:Math.floor(i[p]*f+(i[p-1]+g)*d);if((i[p]+=s.am(0,m,i,y,0,u))0&&i.rShiftTo(h,i),o<0&&x.ZERO.subTo(i,i)}}},x.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},x.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},x.prototype.exp=function(t,e){if(t>4294967295||t<1)return x.ONE;var i=b(),n=b(),r=e.convert(this),s=H(t)-1;for(r.copyTo(i);--s>=0;)if(e.sqrTo(i,n),(t&1<0)e.mulTo(n,r,i);else{var o=i;i=n,n=o}return e.revert(i)},x.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<0)for(a>a)>0&&(r=!0,s=T(i));o>=0;)a>(a+=this.DB-e)):(i=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),i>0&&(r=!0),r&&(s+=T(i));return r?s:"0"},x.prototype.negate=function(){var t=b();return x.ZERO.subTo(this,t),t},x.prototype.abs=function(){return this.s<0?this.negate():this},x.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},x.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+H(this[this.t-1]^this.s&this.DM)},x.prototype.mod=function(t){var e=b();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(x.ZERO)>0&&t.subTo(e,e),e},x.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new B(e):new N(e),this.exp(t,i)},x.ZERO=R(0),x.ONE=R(1),k.prototype.convert=M,k.prototype.revert=M,k.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},k.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=b();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var q=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],z=(1<<26)/q[q.length-1]; -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function G(){this.i=0,this.j=0,this.S=new Array}x.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},x.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),n=R(i),r=b(),s=b(),o="";for(this.divRemTo(n,r,s);r.signum()>0;)o=(i+s.intValue()).toString(t).substr(1)+o,r.divRemTo(n,r,s);return s.intValue().toString(t)+o},x.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),r=!1,s=0,o=0,a=0;a=i&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),r&&x.ZERO.subTo(this,this)},x.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(x.ONE.shiftLeft(t-1),j,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(x.ONE.shiftLeft(t-1),this);else{var n=new Array,r=7&t;n.length=1+(t>>3),e.nextBytes(n),r>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},x.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},x.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},x.prototype.multiplyLowerTo=function(t,e,i){var n,r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r=0;)i[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},x.prototype.millerRabin=function(t){var e=this.subtract(x.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var n=e.shiftRight(i);(t=t+1>>1)>q.length&&(t=q.length);for(var r=b(),s=0;s>24},x.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},x.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},x.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,r=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[r++]=i|this.s<=0;)n<8?(i=(this[t]&(1<>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(e[r++]=i);return e},x.prototype.equals=function(t){return 0==this.compareTo(t)},x.prototype.min=function(t){return this.compareTo(t)<0?this:t},x.prototype.max=function(t){return this.compareTo(t)>0?this:t},x.prototype.and=function(t){var e=b();return this.bitwiseTo(t,O,e),e},x.prototype.or=function(t){var e=b();return this.bitwiseTo(t,j,e),e},x.prototype.xor=function(t){var e=b();return this.bitwiseTo(t,V,e),e},x.prototype.andNot=function(t){var e=b();return this.bitwiseTo(t,L,e),e},x.prototype.not=function(){for(var t=b(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var c=b();for(n.sqrTo(o[1],c);a<=u;)o[a]=b(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,d=t.t-1,g=!0,p=b();for(r=H(t[d])-1;d>=0;){for(r>=h?l=t[d]>>r-h&u:(l=(t[d]&(1<0&&(l|=t[d-1]>>this.DB+r-h)),a=i;0==(1&l);)l>>=1,--a;if((r-=a)<0&&(r+=this.DB,--d),g)o[l].copyTo(s),g=!1;else{for(;a>1;)n.sqrTo(s,p),n.sqrTo(p,s),a-=2;a>0?n.sqrTo(s,p):(f=s,s=p,p=f),n.mulTo(p,o[l],s)}for(;d>=0&&0==(t[d]&1<=0?(i.subTo(n,i),e&&r.subTo(o,r),s.subTo(a,s)):(n.subTo(i,n),e&&o.subTo(r,o),a.subTo(s,a))}return 0!=n.compareTo(x.ONE)?x.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},x.prototype.pow=function(t){return this.exp(t,new k)},x.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var r=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(r0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(r=e.getLowestSetBit())>0&&e.rShiftTo(r,e),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},x.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=q[q.length-1]){for(e=0;e>8&255,J[W++]^=t>>16&255,J[W++]^=t>>24&255,W>=X&&(W-=X)}((new Date).getTime())}if(null==J){var $;if(J=new Array,W=0,void 0!==n&&(void 0!==n.crypto||void 0!==n.msCrypto)){var Q=n.crypto||n.msCrypto;if(Q.getRandomValues){var tt=new Uint8Array(32);for(Q.getRandomValues(tt),$=0;$<32;++$)J[W++]=tt[$]}else if("Netscape"==i.appName&&i.appVersion<"5"){var et=n.crypto.random(32);for($=0;$>>8,J[W++]=255&$;W=0,Z()}function it(){if(null==Y){for(Z(),(Y=new G).init(J),W=0;W>24,(16711680&r)>>16,(65280&r)>>8,255&r]))),r+=1;return n}function ot(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function at(t,e,i){for(var n="",r=0;n.length>24,(16711680&r)>>16,(65280&r)>>8,255&r])),r+=1;return n} -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function ht(t,e){this.x=e,this.q=t}function ut(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?x.ONE:n,this.zinv=null}function ct(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new ut(this,null,null)}nt.prototype.nextBytes=function(t){var e;for(e=0;e0&&e.length>0))throw"Invalid RSA public key";this.n=rt(t,16),this.e=parseInt(e,16)}},ot.prototype.encrypt=function(t){var e=function(t,e){if(e=0&&e>0;){var r=t.charCodeAt(n--);r<128?i[--e]=r:r>127&&r<2048?(i[--e]=63&r|128,i[--e]=r>>6|192):(i[--e]=63&r|128,i[--e]=r>>6&63|128,i[--e]=r>>12|224)}i[--e]=0;for(var s=new nt,o=new Array;e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new x(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var n=i.toString(16);return 0==(1&n.length)?n:"0"+n},ot.prototype.encryptOAEP=function(t,e,i){var n=function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;if(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t.length+2*n+2>e)throw"Message too long for RSA";var a,h="";for(a=0;a>3,e,i);if(null==n)return null;var r=this.doPublic(n);if(null==r)return null;var s=r.toString(16);return 0==(1&s.length)?s:"0"+s},ot.prototype.type="RSA",ot.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},ot.prototype.setPrivate=function(t,e,i){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=i;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16)}},ot.prototype.setPrivateEx=function(t,e,i,n,r,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16),this.p=rt(n,16),this.q=rt(r,16),this.dmp1=rt(s,16),this.dmq1=rt(o,16),this.coeff=rt(a,16)},ot.prototype.generate=function(t,e){var i=new nt,n=t>>1;this.e=parseInt(e,16);for(var r=new x(e,16);;){for(;this.p=new x(t-n,1,i),0!=this.p.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.p.isProbablePrime(10););for(;this.q=new x(n,1,i),0!=this.q.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(x.ONE),a=this.q.subtract(x.ONE),h=o.multiply(a);if(0==h.gcd(r).compareTo(x.ONE)){this.n=this.p.multiply(this.q),this.d=r.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},ot.prototype.decrypt=function(t){var e=rt(t,16),i=this.doPrivate(e);return null==i?null: -/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ - */ -function(t,e){for(var i=t.toByteArray(),n=0;n=i.length)return null;for(var r="";++n191&&s<224?(r+=String.fromCharCode((31&s)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&s)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},ot.prototype.decryptOAEP=function(t,e,i){var n=rt(t,16),r=this.doPrivate(n);return null==r?null:function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;for(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t=t.toByteArray(),a=0;a>3,e,i)},ht.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ht.prototype.toBigInteger=function(){return this.x},ht.prototype.negate=function(){return new ht(this.q,this.x.negate().mod(this.q))},ht.prototype.add=function(t){return new ht(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ht.prototype.subtract=function(t){return new ht(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ht.prototype.multiply=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ht.prototype.square=function(){return new ht(this.q,this.x.square().mod(this.q))},ht.prototype.divide=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ut.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO))},ut.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(x.ZERO)&&!this.y.toBigInteger().equals(x.ZERO)},ut.prototype.negate=function(){return new ut(this.curve,this.x,this.y.negate(),this.z)},ut.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),i=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(x.ZERO.equals(i))return x.ZERO.equals(e)?this.twice():this.curve.getInfinity();var n=new x("3"),r=this.x.toBigInteger(),s=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),i.square()),a=o.multiply(i),h=r.multiply(o),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(a).multiply(i).mod(this.curve.q),l=h.multiply(n).multiply(e).subtract(s.multiply(a)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),f=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},ut.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new x("3"),e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=i.multiply(this.z),r=n.multiply(i).mod(this.curve.q),s=this.curve.a.toBigInteger(),o=e.square().multiply(t);x.ZERO.equals(s)||(o=o.add(this.z.square().multiply(s)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(r)).shiftLeft(1).multiply(n).mod(this.curve.q),h=o.multiply(t).multiply(e).subtract(r.shiftLeft(1)).shiftLeft(2).multiply(r).subtract(o.square().multiply(o)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),u)},ut.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add(o?this:r))}return s},ut.prototype.multiplyTwo=function(t,e,i){var n;n=t.bitLength()>i.bitLength()?t.bitLength()-1:i.bitLength()-1;for(var r=this.curve.getInfinity(),s=this.add(e);n>=0;)r=r.twice(),t.testBit(n)?r=i.testBit(n)?r.add(s):r.add(this):i.testBit(n)&&(r=r.add(e)),--n;return r},ct.prototype.getQ=function(){return this.q},ct.prototype.getA=function(){return this.a},ct.prototype.getB=function(){return this.b},ct.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ct.prototype.getInfinity=function(){return this.infinity},ct.prototype.fromBigInteger=function(t){return new ht(this.q,t)},ct.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,i=t.substr(2,e),n=t.substr(e+2,e);return new ut(this,this.fromBigInteger(new x(i,16)),this.fromBigInteger(new x(n,16)));default:return null}}, -/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib - */ -ht.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ut.prototype.getEncoded=function(t){var e=function(t,e){var i=t.toByteArrayUnsigned();if(ei.length;)i.unshift(0);return i},i=this.getX().toBigInteger(),n=this.getY().toBigInteger(),r=e(i,32);return t?n.isEven()?r.unshift(2):r.unshift(3):(r.unshift(4),r=r.concat(e(n,32))),r},ut.decodeFrom=function(t,e){e[0];var i=e.length-1,n=e.slice(1,1+i/2),r=e.slice(1+i/2,1+i);n.unshift(0),r.unshift(0);var s=new x(n),o=new x(r);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.decodeFromHex=function(t,e){e.substr(0,2);var i=e.length-2,n=e.substr(2,i/2),r=e.substr(2+i/2,i/2),s=new x(n,16),o=new x(r,16);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),i=t.y.subtract(this.y).divide(e),n=i.square().subtract(this.x).subtract(t.x),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(x.valueOf(2)),e=this.curve.fromBigInteger(x.valueOf(3)),i=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=i.square().subtract(this.x.multiply(t)),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add2D(o?this:r))}return s},ut.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),i=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),r=this.curve.getQ(),s=e.multiply(e).mod(r),o=t.multiply(t).multiply(t).add(i.multiply(t)).add(n).mod(r);return s.equals(o)},ut.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ut.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),i=this.getY().toBigInteger();if(e.compareTo(x.ONE)<0||e.compareTo(t.subtract(x.ONE))>0)throw new Error("x coordinate out of bounds");if(i.compareTo(x.ONE)<0||i.compareTo(t.subtract(x.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0}; -/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval - */ -var lt=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),i={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,n){return e?i[e]:String.fromCharCode(parseInt(n,16))}var r=new String(""),s=(Object,Array,Object.hasOwnProperty);return function(i,o){var a,h,u=i.match(t),c=u[0],l=!1;"{"===c?a={}:"["===c?a=[]:(a=[],l=!0);for(var f=[a],d=1-l,g=u.length;d=0;)delete i[n[h]]}return o.call(t,e,i)};a=y({"":a},"")}return a}}();void 0!==ft&&ft||(ft={}),void 0!==ft.asn1&&ft.asn1||(ft.asn1={}),ft.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},ft.asn1.DERAbstractString=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=bt(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},r.lang.extend(ft.asn1.DERAbstractString,ft.asn1.ASN1Object),ft.asn1.DERAbstractTime=function(t){ft.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var n=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var h=n(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=St(t)},this.setByDateValue=function(t,e,i,n,r,s){var o=new Date(Date.UTC(t,e-1,i,n,r,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},r.lang.extend(ft.asn1.DERAbstractTime,ft.asn1.ASN1Object),ft.asn1.DERAbstractStructured=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},r.lang.extend(ft.asn1.DERAbstractStructured,ft.asn1.ASN1Object),ft.asn1.DERBoolean=function(){ft.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},r.lang.extend(ft.asn1.DERBoolean,ft.asn1.ASN1Object),ft.asn1.DERInteger=function(t){ft.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ft.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},r.lang.extend(ft.asn1.DERInteger,ft.asn1.ASN1Object),ft.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ft.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}ft.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7r.length&&(r=n[i]);return(t=t.replace(r,"::")).slice(1,-1)}function _t(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?Lt(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function Kt(t){for(var e=encodeURIComponent(t),i="",n=0;n"7"?"00"+t:t}function Mt(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,i){var n=parseInt(t);if(n<0||255=2*s)break;if(a>=200)break;n.push(h),o=h,a++}return n},pt.getNthChildIdx=function(t,e,i){return pt.getChildIdx(t,e)[i]},pt.getIdxbyList=function(t,e,i,n){var r,s,o=pt;if(0==i.length){if(void 0!==n&&t.substr(e,2)!==n)throw"checking tag doesn't match: "+t.substr(e,2)+"!="+n;return e}return r=i.shift(),s=o.getChildIdx(t,e),o.getIdxbyList(t,s[r],i,n)},pt.getTLVbyList=function(t,e,i,n){var r=pt,s=r.getIdxbyList(t,e,i);if(void 0===s)throw"can't find nthList object";if(void 0!==n&&t.substr(s,2)!=n)throw"checking tag doesn't match: "+t.substr(s,2)+"!="+n;return r.getTLV(t,s)},pt.getVbyList=function(t,e,i,n,r){var s,o,a=pt;if(void 0===(s=a.getIdxbyList(t,e,i,n)))throw"can't find nthList object";return o=a.getV(t,s),!0===r&&(o=o.substr(2)),o},pt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},i=[],n=t.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var s=t.substr(2),o=[],a=0;a0&&(c=c+"."+h.join(".")),c},pt.dump=function(t,e,i,n){var r=pt,s=r.getV,o=r.dump,a=r.getChildIdx,h=t;t instanceof ft.asn1.ASN1Object&&(h=t.getEncodedHex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var c=e.ommit_long_octet;if("01"==h.substr(i,2))return"00"==(l=s(h,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==h.substr(i,2))return n+"INTEGER "+u(l=s(h,i),c)+"\n";if("03"==h.substr(i,2))return n+"BITSTRING "+u(l=s(h,i),c)+"\n";if("04"==h.substr(i,2)){var l=s(h,i);if(r.isASN1HEX(l)){var f=n+"OCTETSTRING, encapsulates\n";return f+=o(l,e,0,n+" ")}return n+"OCTETSTRING "+u(l,c)+"\n"}if("05"==h.substr(i,2))return n+"NULL\n";if("06"==h.substr(i,2)){var d=s(h,i),g=ft.asn1.ASN1Util.oidHexToInt(d),p=ft.asn1.x509.OID.oid2name(g),y=g.replace(/\./g," ");return""!=p?n+"ObjectIdentifier "+p+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0c"==h.substr(i,2))return n+"UTF8String '"+At(s(h,i))+"'\n";if("13"==h.substr(i,2))return n+"PrintableString '"+At(s(h,i))+"'\n";if("14"==h.substr(i,2))return n+"TeletexString '"+At(s(h,i))+"'\n";if("16"==h.substr(i,2))return n+"IA5String '"+At(s(h,i))+"'\n";if("17"==h.substr(i,2))return n+"UTCTime "+At(s(h,i))+"\n";if("18"==h.substr(i,2))return n+"GeneralizedTime "+At(s(h,i))+"\n";if("30"==h.substr(i,2)){if("3000"==h.substr(i,4))return n+"SEQUENCE {}\n";f=n+"SEQUENCE\n";var v=e;if((2==(F=a(h,i)).length||3==F.length)&&"06"==h.substr(F[0],2)&&"04"==h.substr(F[F.length-1],2)){p=r.oidname(s(h,F[0]));var m=JSON.parse(JSON.stringify(e));m.x509ExtName=p,v=m}for(var S=0;S0){var e=new i({array:this.extensionsArray}),n=new r({explicit:!0,tag:"a3",obj:e});this.asn1Array.push(n)}var s=new i({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertificate,ft.asn1.ASN1Object),ft.asn1.x509.Extension=function(t){ft.asn1.x509.Extension.superclass.constructor.call(this);var e=ft.asn1,i=e.DERObjectIdentifier,n=e.DEROctetString,r=(e.DERBitString,e.DERBoolean),s=e.DERSequence;this.getEncodedHex=function(){var t=new i({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new r),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},r.lang.extend(ft.asn1.x509.Extension,ft.asn1.ASN1Object),ft.asn1.x509.Extension.appendByNameToArray=function(t,e,i){var n=t.toLowerCase(),r=ft.asn1.x509;if("basicconstraints"==n){var s=new r.BasicConstraints(e);i.push(s)}else if("keyusage"==n){s=new r.KeyUsage(e);i.push(s)}else if("crldistributionpoints"==n){s=new r.CRLDistributionPoints(e);i.push(s)}else if("extkeyusage"==n){s=new r.ExtKeyUsage(e);i.push(s)}else if("authoritykeyidentifier"==n){s=new r.AuthorityKeyIdentifier(e);i.push(s)}else if("authorityinfoaccess"==n){s=new r.AuthorityInfoAccess(e);i.push(s)}else if("subjectaltname"==n){s=new r.SubjectAltName(e);i.push(s)}else{if("issueraltname"!=n)throw"unsupported extension name: "+t;s=new r.IssuerAltName(e);i.push(s)}},ft.asn1.x509.KeyUsage=function(t){ft.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Jt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new ft.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var i=t.names,n="000000000",r=0;r-1&&t.push(new ft.asn1.DERInteger({int:this.pathLen}));var e=new ft.asn1.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},r.lang.extend(ft.asn1.x509.BasicConstraints,ft.asn1.x509.Extension),ft.asn1.x509.CRLDistributionPoints=function(t){ft.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ft.asn1,i=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){this.asn1ExtnValue=new e.DERSequence({array:t})},this.setByOneURI=function(t){var e=new i.GeneralNames([{uri:t}]),n=new i.DistributionPointName(e),r=new i.DistributionPoint({dpobj:n});this.setByDPArray([r])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},r.lang.extend(ft.asn1.x509.CRLDistributionPoints,ft.asn1.x509.Extension),ft.asn1.x509.ExtKeyUsage=function(t){ft.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=ft.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var i=0;i0){var t=new i({array:this.aRevokedCert});this.asn1Array.push(t)}var e=new i({array:this.asn1Array});return this.hTLV=e.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize=function(){this.asn1Version=null,this.asn1SignatureAlg=null,this.asn1Issuer=null,this.asn1ThisUpdate=null,this.asn1NextUpdate=null,this.aRevokedCert=new Array},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertList,ft.asn1.ASN1Object),ft.asn1.x509.CRLEntry=function(t){ft.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=ft.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},r.lang.extend(ft.asn1.x509.CRLEntry,ft.asn1.ASN1Object),ft.asn1.x509.X500Name=function(t){ft.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=new Array;var e=ft.asn1,i=e.x509,n=Ht;if(this.setByString=function(t){var e=t.split("/");e.shift();for(var n=[],r=0;r0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},ft.asn1.x509.RDN=function(t){ft.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=new Array,this.addByString=function(t){this.asn1Array.push(new ft.asn1.x509.AttributeTypeAndValue({str:t}))},this.addByMultiValuedString=function(t){for(var e=ft.asn1.x509.RDN.parseString(t),i=0;i0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var a=!1,h=[];for(r=0;n.length>0;r++){s=n.shift();if(!0===a){var u=h.pop();if(s.match(/"$/)){o=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(o),a=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(a=!0)}return h},ft.asn1.x509.AttributeTypeAndValue=function(t){ft.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var e=ft.asn1;this.setByString=function(t){var e=t.match(/^([^=]+)=(.+)$/);if(!e)throw"malformed attrTypeAndValueStr: "+t;this.setByAttrTypeAndValueStr(e[1],e[2])},this.setByAttrTypeAndValueStr=function(t,e){this.typeObj=ft.asn1.x509.OID.atype2obj(t);var i="utf8";"C"==t&&(i="prn"),this.valueObj=this.getValueObj(i,e)},this.getValueObj=function(t,i){if("utf8"==t)return new e.DERUTF8String({str:i});if("prn"==t)return new e.DERPrintableString({str:i});if("tel"==t)return new e.DERTeletexString({str:i});if("ia5"==t)return new e.DERIA5String({str:i});throw"unsupported directory string type: type="+t+" value="+i},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.typeObj,this.valueObj]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&void 0!==t.str&&this.setByString(t.str)},r.lang.extend(ft.asn1.x509.AttributeTypeAndValue,ft.asn1.ASN1Object),ft.asn1.x509.SubjectPublicKeyInfo=function(t){ft.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ft,i=e.asn1,n=i.DERInteger,r=i.DERBitString,s=i.DERObjectIdentifier,o=i.DERSequence,a=i.ASN1Util.newObject,h=i.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof ot){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+e})}}catch(t){}try{if(t instanceof ft.crypto.ECDSA){var i=new s({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ft.crypto.DSA){i=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new h({name:"dsa",asn1params:i});var o=new n({bigint:t.y});this.asn1SubjPKey=new r({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},r.lang.extend(ft.asn1.x509.SubjectPublicKeyInfo,ft.asn1.ASN1Object),ft.asn1.x509.Time=function(t){ft.asn1.x509.Time.superclass.constructor.call(this);var e=ft.asn1,i=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},r.lang.extend(ft.asn1.x509.Time,ft.asn1.ASN1Object),ft.asn1.x509.AlgorithmIdentifier=function(t){ft.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ft.asn1;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw"algorithm not specified";null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var t=[this.asn1Alg];null!==this.asn1Params&&t.push(this.asn1Params);var i=new e.DERSequence({array:t});return this.hTLV=i.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},r.lang.extend(ft.asn1.x509.AlgorithmIdentifier,ft.asn1.ASN1Object),ft.asn1.x509.GeneralName=function(t){ft.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=ft.asn1,n=(i.DERSequence,i.DEROctetString),r=i.DERIA5String,s=i.DERTaggedObject,o=i.ASN1Object,a=i.x509.X500Name,h=Ht;this.explicit=!1,this.setByParam=function(t){var i=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",i=new r({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",i=new r({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",i=new r({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,i=new a({str:t.dn})),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var u=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certissuer param not cert";(f=new Jt).hex=u;var c=f.getIssuerHex();(i=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;u=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certsubj param not cert";(f=new Jt).hex=u;c=f.getSubjectHex();(i=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,g=t.ip,p="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(d=Mt("["+g.split(".").join(",")+"]")).length)throw p}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=Vt(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw p;d=g}i=new n({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},r.lang.extend(ft.asn1.x509.GeneralName,ft.asn1.ASN1Object),ft.asn1.x509.GeneralNames=function(t){ft.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ft.asn1;this.setByParamArray=function(t){for(var i=0;i0&&(e=new n({obj:this.dUnsignedAttrs,tag:"a1",explicit:!1}));var r=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,t,this.dSigAlg,this.dSig];null!=e&&r.push(e);var o=new i.DERSequence({array:r});return this.hTLV=o.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.SignerInfo,ft.asn1.ASN1Object),ft.asn1.cms.EncapsulatedContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.dEContentType=new r({name:"data"}),this.dEContent=null,this.isDetached=!1,this.eContentValueHex=null,this.setContentType=function(t){t.match(/^[0-2][.][0-9.]+$/)?this.dEContentType=new r({oid:t}):this.dEContentType=new r({name:t})},this.setContentValue=function(t){void 0!==t&&("string"==typeof t.hex?this.eContentValueHex=t.hex:"string"==typeof t.str&&(this.eContentValueHex=bt(t.str)))},this.setContentValueHex=function(t){this.eContentValueHex=t},this.setContentValueStr=function(t){this.eContentValueHex=bt(t)},this.getEncodedHex=function(){if("string"!=typeof this.eContentValueHex)throw"eContentValue not yet set";var t=new s({hex:this.eContentValueHex});this.dEContent=new i({obj:t,tag:"a0",explicit:!0});var e=[this.dEContentType];this.isDetached||e.push(this.dEContent);var r=new n({array:e});return this.hTLV=r.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.EncapsulatedContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.ContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.x509;ft.asn1.cms.ContentInfo.superclass.constructor.call(this),this.dContentType=null,this.dContent=null,this.setContentType=function(t){"string"==typeof t&&(this.dContentType=r.OID.name2obj(t))},this.getEncodedHex=function(){var t=new i({obj:this.dContent,tag:"a0",explicit:!0}),e=new n({array:[this.dContentType,t]});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t&&(t.type&&this.setContentType(t.type),t.obj&&t.obj instanceof e.ASN1Object&&(this.dContent=t.obj))},r.lang.extend(ft.asn1.cms.ContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.SignedData=function(t){var e=ft.asn1,i=e.ASN1Object,n=e.DERInteger,r=e.DERSet,s=e.DERSequence,o=e.DERTaggedObject,a=e.cms,h=a.EncapsulatedContentInfo,u=a.SignerInfo,c=a.ContentInfo,l=e.x509.AlgorithmIdentifier;ft.asn1.cms.SignedData.superclass.constructor.call(this),this.dCMSVersion=new n({int:1}),this.dDigestAlgs=null,this.digestAlgNameList=[],this.dEncapContentInfo=new h,this.dCerts=null,this.certificateList=[],this.crlList=[],this.signerInfoList=[new u],this.addCertificatesByPEM=function(t){var e=Ht(t),n=new i;n.hTLV=e,this.certificateList.push(n)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(null==this.dDigestAlgs){for(var t=[],e=0;e0){var h=new r({array:this.certificateList});this.dCerts=new o({obj:h,tag:"a0",explicit:!1})}null!=this.dCerts&&a.push(this.dCerts);var u=new r({array:this.signerInfoList});a.push(u);var c=new s({array:a});return this.hTLV=c.getEncodedHex(),this.hTLV},this.getContentInfo=function(){return this.getEncodedHex(),new c({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},this.getPEM=function(){return Rt(this.getContentInfoEncodedHex(),"CMS")}},r.lang.extend(ft.asn1.cms.SignedData,ft.asn1.ASN1Object),ft.asn1.cms.CMSUtil=new function(){},ft.asn1.cms.CMSUtil.newSignedData=function(t){var e=ft.asn1,i=e.cms,n=i.SignerInfo,r=i.SignedData,s=i.SigningTime,o=i.SigningCertificate,a=i.SigningCertificateV2,h=e.cades.SignaturePolicyIdentifier,u=new r;if(u.dEncapContentInfo.setContentValue(t.content),"object"==typeof t.certs)for(var c=0;c0){var t=new n({array:this.extensionsArray}),e=new r({array:[t]}),i=new n({array:[new a({oid:"1.2.840.113549.1.9.14"}),e]}),h=new o({explicit:!0,tag:"a0",obj:i});this.asn1Array.push(h)}else{h=new o({explicit:!1,tag:"a0",obj:new s});this.asn1Array.push(h)}var u=new n({array:this.asn1Array});return this.hTLV=u.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.csr.CertificationRequestInfo,ft.asn1.ASN1Object),ft.asn1.csr.CSRUtil=new function(){},ft.asn1.csr.CSRUtil.newCSRPEM=function(t){var e=Ut,i=ft.asn1.csr;if(void 0===t.subject)throw"parameter subject undefined";if(void 0===t.sbjpubkey)throw"parameter sbjpubkey undefined";if(void 0===t.sigalg)throw"parameter sigalg undefined";if(void 0===t.sbjprvkey)throw"parameter sbjpubkey undefined";var n=new i.CertificationRequestInfo;if(n.setSubjectByParam(t.subject),n.setSubjectPublicKeyByGetKey(t.sbjpubkey),void 0!==t.ext&&void 0!==t.ext.length)for(var r=0;rr)throw"key is too short for SigAlg: keylen="+i+","+e;for(var s="0001",o="00"+n,a="",h=r-s.length-o.length,u=0;u=0)return!1;if(i.compareTo(x.ONE)<0||i.compareTo(r)>=0)return!1;var o=i.modInverse(r),a=t.multiply(o).mod(r),h=e.multiply(o).mod(r);return s.multiply(a).add(n.multiply(h)).getX().toBigInteger().mod(r).equals(e)},this.serializeSig=function(t,e){var i=t.toByteArraySigned(),n=e.toByteArraySigned(),r=[];return r.push(2),r.push(i.length),(r=r.concat(i)).push(2),r.push(n.length),(r=r.concat(n)).unshift(r.length),r.unshift(48),r},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:x.fromByteArrayUnsigned(i),s:x.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:x.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:x.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[2,0],"06"),i=o(t,0,[1],"04");try{n=o(t,0,[3,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#1/5 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{o(t,0,[1,0],"06"),e=o(t,0,[1,1],"06"),i=o(t,0,[2,0,1],"04");try{n=o(t,0,[2,0,2,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#8 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){var e,i,n=pt,r=ft.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{s(t,0,[0,0],"06"),e=s(t,0,[0,1],"06"),i=s(t,0,[1],"03").substr(2)}catch(t){throw"malformed PKCS#8 ECC public key"}if(this.curveName=r(e),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,e){5!==e&&(e=6);var i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{i=o(t,0,[0,e,0,1],"06"),n=o(t,0,[0,e,1],"03").substr(2)}catch(t){throw"malformed X.509 certificate ECC public key"}if(this.curveName=s(i),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ft.crypto.ECDSA.parseSigHex=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new x(e.r,16),s:new x(e.s,16)}},ft.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=pt,i=e.getChildIdx,n=e.getV;if("30"!=t.substr(0,2))throw"signature is not a ASN.1 sequence";var r=i(t,0);if(2!=r.length)throw"number of signature ASN.1 sequence elements seem wrong";var s=r[0],o=r[1];if("02"!=t.substr(s,2))throw"1st item of sequene of signature is not ASN.1 integer";if("02"!=t.substr(o,2))throw"2nd item of sequene of signature is not ASN.1 integer";return{r:n(t,s),s:n(t,o)}},ft.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t),i=e.r,n=e.s;if("00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),i.length%32==30&&(i="00"+i),n.length%32==30&&(n="00"+n),i.length%32!=0)throw"unknown ECDSA sig r length error";if(n.length%32!=0)throw"unknown ECDSA sig s length error";return i+n},ft.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var e=t.substr(0,t.length/2),i=t.substr(t.length/2);return ft.crypto.ECDSA.hexRSSigToASN1Sig(e,i)},ft.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var i=new x(t,16),n=new x(e,16);return ft.crypto.ECDSA.biRSSigToASN1Sig(i,n)},ft.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var i=ft.asn1,n=new i.DERInteger({bigint:t}),r=new i.DERInteger({bigint:e});return new i.DERSequence({array:[n,r]}).getEncodedHex()},ft.crypto.ECDSA.getName=function(t){return"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040022"===t?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":null},void 0!==ft&&ft||(ft={}),void 0!==ft.crypto&&ft.crypto||(ft.crypto={}),ft.crypto.ECParameterDB=new function(){var t={},e={};function i(t){return new x(t,16)}this.getByName=function(i){var n=i;if(void 0!==e[n]&&(n=e[i]),void 0!==t[n])return t[n];throw"unregistered EC curve name: "+n},this.regist=function(n,r,s,o,a,h,u,c,l,f,d,g){t[n]={};var p=i(s),y=i(o),v=i(a),m=i(h),S=i(u),F=new ct(p,y,v),w=F.decodePointHex("04"+c+l);t[n].name=n,t[n].keylen=r,t[n].curve=F,t[n].G=w,t[n].n=m,t[n].h=S,t[n].oid=d,t[n].info=g;for(var E=0;E1?new x(n,16):null,u=new x(r,16),this.setPrivate(s,o,a,h,u)},this.setPublic=function(t,e,i,n){this.isPublic=!0,this.p=t,this.q=e,this.g=i,this.y=n,this.x=null},this.setPublicHex=function(t,e,i,n){var r,s,o,a;r=new x(t,16),s=new x(e,16),o=new x(i,16),a=new x(n,16),this.setPublic(r,s,o,a)},this.signWithMessageHash=function(t){var e=this.p,i=this.q,n=this.g,r=(this.y,this.x),s=ft.crypto.Util.getRandomBigIntegerMinToMax(x.ONE.add(x.ONE),i.subtract(x.ONE)),o=new x(t.substr(0,i.bitLength()/4),16),a=n.modPow(s,e).mod(i),h=s.modInverse(i).multiply(o.add(r.multiply(a))).mod(i);return ft.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:a}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var i=this.p,n=this.q,r=this.g,s=this.y,o=this.parseASN1Signature(e),a=o[0],h=o[1],u=new x(t.substr(0,n.bitLength()/4),16);if(x.ZERO.compareTo(a)>0||a.compareTo(n)>0)throw"invalid DSA signature";if(x.ZERO.compareTo(h)>=0||h.compareTo(n)>0)throw"invalid DSA signature";var c=h.modInverse(n),l=u.multiply(c).mod(n),f=a.multiply(c).mod(n);return 0==r.modPow(l,i).multiply(s.modPow(f,i)).mod(i).mod(n).compareTo(a)},this.parseASN1Signature=function(t){try{return[new x(pt.getVbyList(t,0,[0],"02"),16),new x(pt.getVbyList(t,0,[1],"02"),16)]}catch(t){throw"malformed ASN.1 DSA signature"}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r,s,o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{e=a(t,0,[1],"02"),i=a(t,0,[2],"02"),n=a(t,0,[3],"02"),r=a(t,0,[4],"02"),s=a(t,0,[5],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#1/5 plain DSA private key"}this.setPrivateHex(e,i,n,r,s)},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[1,1,0],"02"),i=o(t,0,[1,1,1],"02"),n=o(t,0,[1,1,2],"02"),r=o(t,0,[2,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 plain DSA private key"}this.setPrivateHex(e,i,n,null,r)},this.readPKCS8PubKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[0,1,0],"02"),i=o(t,0,[0,1,1],"02"),n=o(t,0,[0,1,2],"02"),r=o(t,0,[1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 DSA public key"}this.setPublicHex(e,i,n,r)},this.readCertPubKeyHex=function(t,e){var i,n,r,s;5!==e&&(e=6);var o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{i=a(t,0,[0,e,0,1,0],"02"),n=a(t,0,[0,e,0,1,1],"02"),r=a(t,0,[0,e,0,1,2],"02"),s=a(t,0,[0,e,1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed X.509 certificate DSA public key"}this.setPublicHex(i,n,r,s)}};var Ut=function(){var t=function(t,i,n){return e(y.AES,t,i,n)},e=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=r;var h=t.decrypt(a,s,{iv:o});return y.enc.Hex.stringify(h)},i=function(t,e,i){return n(y.AES,t,e,i)},n=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a=t.encrypt(r,s,{iv:o}),h=y.enc.Hex.parse(a.toString());return y.enc.Base64.stringify(h)},r={"AES-256-CBC":{proc:t,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,i,n){return e(y.TripleDES,t,i,n)},eproc:function(t,e,i){return n(y.TripleDES,t,e,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,i,n){return e(y.DES,t,i,n)},eproc:function(t,e,i){return n(y.DES,t,e,i)},keylen:8,ivlen:8}},s=function(t){var e={},i=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(e.cipher=i[1],e.ivsalt=i[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var r=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(r=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(r=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=r&&-1!=o){var a=t.substring(r+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,i){for(var n=i.substring(0,16),s=y.enc.Hex.parse(n),o=y.enc.Utf8.parse(e),a=r[t].keylen+r[t].ivlen,h="",u=null;;){var c=y.algo.MD5.create();if(null!=u&&c.update(u),c.update(o),c.update(s),u=c.finalize(),(h+=y.enc.Hex.stringify(u)).length>=2*a)break}var l={};return l.keyhex=h.substr(0,2*r[t].keylen),l.ivhex=h.substr(2*r[t].keylen,2*r[t].ivlen),l},a=function(t,e,i,n){var s=y.enc.Base64.parse(t),o=y.enc.Hex.stringify(s);return(0,r[e].proc)(o,i,n)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,i){return o(t,e,i)},decryptKeyB64:function(t,e,i,n){return a(t,e,i,n)},getDecryptedKeyHex:function(t,e){var i=s(t),n=(i.type,i.cipher),r=i.ivsalt,h=i.data,u=o(n,e,r).keyhex;return a(h,n,u,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,i,n,s){var a="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===r[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==s&&null!=s||(s=function(t){var e=y.lib.WordArray.random(t);return y.enc.Hex.stringify(e)}(r[n].ivlen).toUpperCase());var h=function(t,e,i,n){return(0,r[e].eproc)(t,i,n)}(e,n,o(n,i,s).keyhex,s);a="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+n+","+s+"\r\n",a+="\r\n",a+=h.replace(/(.{64})/g,"$1\r\n"),a+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={},s=i(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;r.ciphertext=n(t,s[1]);var o=i(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=i(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var h=i(t,a[1]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length;if("2a864886f70d0307"!=n(t,h[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(t,h[1]);var u=i(t,a[0]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length;if("2a864886f70d01050c"!=n(t,u[0]))throw"this only supports pkcs5PBKDF2";var c=i(t,u[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;r.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{r.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return r},getPBKDF2KeyHexFromParam:function(t,e){var i=y.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,r=y.PBKDF2(e,i,{keySize:6,iterations:n});return y.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var i=Ht(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=Ut.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=y.enc.Hex.parse(n.ciphertext);var o=y.enc.Hex.parse(r),a=y.enc.Hex.parse(n.encryptionSchemeIV),h=y.TripleDES.decrypt(s,o,{iv:a});return y.enc.Hex.stringify(h)},getKeyFromEncryptedPKCS8PEM:function(t,e){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var s=i(t,0);if(3!=s.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(s[1],2))throw"malformed PKCS8 private key(code:003)";var o=i(t,s[1]);if(2!=o.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(o[0],2))throw"malformed PKCS8 private key(code:005)";if(r.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(r.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw"malformed PKCS8 private key(code:006)";return r.keyidx=e.getVidx(t,s[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Ht(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,i=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==i.algoid)e=new ot;else if("2a8648ce380401"==i.algoid)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";e=new ft.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,i=pt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===i)e=new ot;else if("2a8648ce380401"===i)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";e=new ft.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=i(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(r.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return r.e=n(t,s[1]),r},parsePublicPKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null},s=i(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=i(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?r.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(r.algparam={},r.algparam.p=e.getVbyList(t,a[1],[0],"02"),r.algparam.q=e.getVbyList(t,a[1],[1],"02"),r.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(t,s[1]).substr(2),r}}}();Ut.getKey=function(t,e,i){var n=(y=pt).getChildIdx,r=(y.getV,y.getVbyList),s=ft.crypto,o=s.ECDSA,a=s.DSA,h=ot,u=Ht,c=Ut;if(void 0!==h&&t instanceof h)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(t.n,t.e),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(D=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(D=new h).setPrivate(t.n,t.e,t.d),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(D=new a).setPublic(t.p,t.q,t.g,t.y),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(D=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(xt(t.n),xt(t.e)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(D=new h).setPrivateEx(xt(t.n),xt(t.e),xt(t.d),xt(t.p),xt(t.q),xt(t.dp),xt(t.dq),xt(t.qi)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(D=new h).setPrivate(xt(t.n),xt(t.e),xt(t.d)),D;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);return C.setPublicKeyHex(f),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);var d=("0000000000"+xt(t.d)).slice(-l);return C.setPublicKeyHex(f),C.setPrivateKeyHex(d),C}if("pkcs5prv"===i){var g,p=t,y=pt;if(9===(g=n(p,0)).length)(D=new h).readPKCS5PrvKeyHex(p);else if(6===g.length)(D=new a).readPKCS5PrvKeyHex(p);else{if(!(g.length>2&&"04"===p.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(D=new o).readPKCS5PrvKeyHex(p)}return D}if("pkcs8prv"===i)return D=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===i)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===i)return Jt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Jt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=Ht(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=u(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=r(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),F=r(R,0,[2],"02"),w=r(R,0,[3],"02"),E=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(w,16),new x(E,16),new x(b,16)),D}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var A=c.getDecryptedKeyHex(t,e),I=new ot;return I.readPKCS5PrvKeyHex(A),I}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var C,D=r(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),T=r(R,0,[2,0],"06"),P=r(R,0,[3,0],"03").substr(2);if(void 0===ft.crypto.OID.oidhex2name[T])throw"undefined OID(hex) in KJUR.crypto.OID: "+T;return(C=new o({curve:ft.crypto.OID.oidhex2name[T]})).setPublicKeyHex(P),C.setPrivateKeyHex(D),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;S=r(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),F=r(R,0,[2],"02"),w=r(R,0,[3],"02"),E=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(w,16),new x(E,16),new x(b,16)),D}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw"not supported argument"},Ut.generateKeypair=function(t,e){if("RSA"==t){var i=e;(o=new ot).generate(i,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new ot,r=o.n.toString(16),s=o.e.toString(16);return n.setPublic(r,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,h=e,u=new ft.crypto.ECDSA({curve:h}).generateKeyPairHex();return(o=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),o.setPrivateKeyHex(u.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Ut.getPEM=function(t,e,i,n,r,s){var o=ft,a=o.asn1,h=a.DERObjectIdentifier,u=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,f=o.crypto,d=f.DSA,g=f.ECDSA,p=ot;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function S(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==p&&t instanceof p||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Rt(x=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=v(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===i||null==i)&&1==t.isPrivate){var F=new h({name:t.curveName}).getEncodedHex(),w=m(t).getEncodedHex(),E="";return E+=Rt(F,"EC PARAMETERS"),E+=Rt(w,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=S(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==i&&null!=i&&1==t.isPrivate){var x=v(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==i&&null!=i&&1==t.isPrivate){x=m(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==i&&null!=i&&1==t.isPrivate){x=S(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",x,i,n,s)}var b=function(t,e){var i=A(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},A=function(t,e){var i=y.lib.WordArray.random(8),n=y.lib.WordArray.random(8),r=y.PBKDF2(e,i,{keySize:6,iterations:100}),s=y.enc.Hex.parse(t),o=y.TripleDES.encrypt(s,r,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=y.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=y.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=p&&t instanceof p&&1==t.isPrivate){var I=v(t).getEncodedHex();x=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){I=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){I=new u({bigint:t.x}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}throw"unsupported object nor format"},Ut.getKeyFromCSRPEM=function(t){var e=Ht(t,"CERTIFICATE REQUEST");return Ut.getKeyFromCSRHex(e)},Ut.getKeyFromCSRHex=function(t){var e=Ut.parseCSRHex(t);return Ut.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Ut.parseCSRHex=function(t){var e=pt,i=e.getChildIdx,n=e.getTLV,r={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=i(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=i(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(s,a[2]),r},Ut.getJWKFromKey=function(t){var e={};if(t instanceof ot&&t.isPrivate)return e.kty="RSA",e.n=Et(t.n.toString(16)),e.e=Et(t.e.toString(16)),e.d=Et(t.d.toString(16)),e.p=Et(t.p.toString(16)),e.q=Et(t.q.toString(16)),e.dp=Et(t.dmp1.toString(16)),e.dq=Et(t.dmq1.toString(16)),e.qi=Et(t.coeff.toString(16)),e;if(t instanceof ot&&t.isPublic)return e.kty="RSA",e.n=Et(t.n.toString(16)),e.e=Et(t.e.toString(16)),e;if(t instanceof ft.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=Et(i.x),e.y=Et(i.y),e.d=Et(t.prvKeyHex),e}if(t instanceof ft.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=Et(i.x),e.y=Et(i.y),e}throw"not supported key object"},ot.getPosArrayOfChildrenFromHex=function(t){return pt.getChildIdx(t,0)},ot.getHexValueArrayOfChildrenFromHex=function(t){var e,i=pt.getV,n=i(t,(e=ot.getPosArrayOfChildrenFromHex(t))[0]),r=i(t,e[1]),s=i(t,e[2]),o=i(t,e[3]),a=i(t,e[4]),h=i(t,e[5]),u=i(t,e[6]),c=i(t,e[7]),l=i(t,e[8]);return(e=new Array).push(n,r,s,o,a,h,u,c,l),e},ot.prototype.readPrivateKeyFromPEMString=function(t){var e=Ht(t),i=ot.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},ot.prototype.readPKCS5PrvKeyHex=function(t){var e=ot.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},ot.prototype.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s,o,a,h,u=pt,c=u.getVbyList;if(!1===u.isASN1HEX(t))throw"not ASN.1 hex string";try{e=c(t,0,[2,0,1],"02"),i=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),r=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw"malformed PKCS#8 plain RSA private key"}this.setPrivateEx(e,i,n,r,s,o,a,h)},ot.prototype.readPKCS5PubKeyHex=function(t){var e=pt,i=e.getV;if(!1===e.isASN1HEX(t))throw"keyHex is not ASN.1 hex string";var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw"wrong hex for PKCS#5 public key";var r=i(t,n[0]),s=i(t,n[1]);this.setPublic(r,s)},ot.prototype.readPKCS8PubKeyHex=function(t){var e=pt;if(!1===e.isASN1HEX(t))throw"not ASN.1 hex string";if("06092a864886f70d010101"!==e.getTLVbyList(t,0,[0,0]))throw"not PKCS8 RSA public key";var i=e.getTLVbyList(t,0,[1,0]);this.readPKCS5PubKeyHex(i)},ot.prototype.readCertPubKeyHex=function(t,e){var i,n;(i=new Jt).readCertHex(t),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var qt=new RegExp("");function zt(t,e){for(var i="",n=e/4-t.length,r=0;r>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function Yt(t){for(var e in ft.crypto.Util.DIGESTINFOHEAD){var i=ft.crypto.Util.DIGESTINFOHEAD[e],n=i.length;if(t.substring(0,n)==i)return[e,t.substring(n)]}return[]}function Jt(){var t=pt,e=t.getChildIdx,i=t.getV,n=t.getTLV,r=t.getVbyList,s=t.getTLVbyList,o=t.getIdxbyList,a=t.getVidx,h=t.oidname,u=Jt,c=Ht;this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){return null===this.hex||0!==this.version?this.version:"a003020102"!==s(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return r(this.hex,0,[0,1+this.foffset],"02")},this.getSignatureAlgorithmField=function(){return h(r(this.hex,0,[0,2+this.foffset,0],"06"))},this.getIssuerHex=function(){return s(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return u.hex2dn(this.getIssuerHex())},this.getSubjectHex=function(){return s(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return u.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=r(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=r(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return t.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return o(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return o(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Ut.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){return h(r(this.hex,0,[1,0],"06"))},this.getSignatureValueHex=function(){return r(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmName(),i=this.getSignatureValueHex(),n=s(this.hex,0,[0],"30"),r=new ft.crypto.Signature({alg:e});return r.init(t),r.updateHex(n),r.verify(i)},this.parseExt=function(){if(3!==this.version)return-1;var i=o(this.hex,0,[0,7,0],"30"),n=e(this.hex,i);this.aExtInfo=new Array;for(var s=0;s0&&(u=new Array(i),(new nt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=It(h(Ct("\0\0\0\0\0\0\0\0"+r+u))),l=[];for(n=0;n>8*a-o&255;for(g[0]&=~p,n=0;nthis.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;var r=n[0];return n[1]==function(t){return ft.crypto.Util.hashString(t,r)}(t)},ot.prototype.verifyWithMessageHash=function(t,e){var i=rt(e=(e=e.replace(qt,"")).replace(/[ \n]+/g,""),16);if(i.bitLength()>this.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;n[0];return n[1]==t},ot.prototype.verifyPSS=function(t,e,i,n){var r,s=(r=Ct(t),ft.crypto.Util.hashHex(r,i));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(s,e,i,n)},ot.prototype.verifyWithMessageHashPSS=function(t,e,i,n){var r=new x(e,16);if(r.bitLength()>this.n.bitLength())return!1;var s,o=function(t){return ft.crypto.Util.hashHex(t,i)},a=It(t),h=a.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===n||void 0===n)n=h;else if(-2===n)n=c-h-2;else if(n<-2)throw"invalid salt length";if(c>8*c-u&255;if(0!=(f.charCodeAt(0)&g))throw"bits beyond keysize not zero";var p=Gt(d,f.length,o),y=[];for(s=0;s0)&&-1==(":"+i.join(":")+":").indexOf(":"+p+":"))throw"algorithm '"+p+"' not accepted in the list";if("none"!=p&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Ut.getKey(e)),!("RS"!=y&&"PS"!=y||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==y&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===s.jwsalg2sigalg[g.alg])throw"unsupported alg name: "+p;if("none"==(v=s.jwsalg2sigalg[p]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var S,F=null;try{F=h.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(F)}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(d)},ft.jws.JWS.parse=function(t){var e,i,n,r=t.split("."),s={};if(2!=r.length&&3!=r.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=r[0],i=r[1],3==r.length&&(n=r[2]),s.headerObj=ft.jws.JWS.readSafeJSONString(gt(e)),s.payloadObj=ft.jws.JWS.readSafeJSONString(gt(i)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=gt(i):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==n&&(s.sigHex=xt(n)),s},ft.jws.JWS.verifyJWT=function(t,e,i){var n=ft.jws,r=n.JWS,s=r.readSafeJSONString,o=r.inArray,a=r.includedArray,h=t.split("."),u=h[0],c=h[1],l=(xt(h[2]),s(gt(u))),f=s(gt(c));if(void 0===l.alg)return!1;if(void 0===i.alg)throw"acceptField.alg shall be specified";if(!o(l.alg,i.alg))return!1;if(void 0!==f.iss&&"object"==typeof i.iss&&!o(f.iss,i.iss))return!1;if(void 0!==f.sub&&"object"==typeof i.sub&&!o(f.sub,i.sub))return!1;if(void 0!==f.aud&&"object"==typeof i.aud)if("string"==typeof f.aud){if(!o(f.aud,i.aud))return!1}else if("object"==typeof f.aud&&!a(f.aud,i.aud))return!1;var d=n.IntDate.getNow();return void 0!==i.verifyAt&&"number"==typeof i.verifyAt&&(d=i.verifyAt),void 0!==i.gracePeriod&&"number"==typeof i.gracePeriod||(i.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+i.gracePeriodr&&this.aHeader.pop(),this.aSignature.length>r&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignatures=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},e.SecureRandom=nt,e.rng_seed_time=Z,e.BigInteger=x,e.RSAKey=ot,e.ECDSA=ft.crypto.ECDSA,e.DSA=ft.crypto.DSA,e.Signature=ft.crypto.Signature,e.MessageDigest=ft.crypto.MessageDigest,e.Mac=ft.crypto.Mac,e.Cipher=ft.crypto.Cipher,e.KEYUTIL=Ut,e.ASN1HEX=pt,e.X509=Jt,e.CryptoJS=y,e.b64tohex=w,e.b64toBA=E,e.stoBA=yt,e.BAtos=vt,e.BAtohex=mt,e.stohex=St,e.stob64=function(t){return F(St(t))},e.stob64u=function(t){return Ft(F(St(t)))},e.b64utos=function(t){return vt(E(wt(t)))},e.b64tob64u=Ft,e.b64utob64=wt,e.hex2b64=F,e.hextob64u=Et,e.b64utohex=xt,e.utf8tob64u=dt,e.b64utoutf8=gt,e.utf8tob64=function(t){return F(Ot(Kt(t)))},e.b64toutf8=function(t){return decodeURIComponent(jt(w(t)))},e.utf8tohex=bt,e.hextoutf8=At,e.hextorstr=It,e.rstrtohex=Ct,e.hextob64=Dt,e.hextob64nl=Tt,e.b64nltohex=Pt,e.hextopem=Rt,e.pemtohex=Ht,e.hextoArrayBuffer=function(t){if(t.length%2!=0)throw"input is not even length";if(null==t.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var e=new ArrayBuffer(t.length/2),i=new DataView(e),n=0;ne.length&&(i=e.length);for(var n=0;n300)throw new r(`Failed to fetch ${t}. Response=${s}`,i.status);try{return JSON.parse(s)}catch(e){throw new r(`Invalid response while trying to fetch ${t}. Response=${s}`,i.status,e)}}}},function(t,e,i){const n=i(1),r=i(15);t.exports=class{constructor({jwt:t=i(0)}={}){this.jwt=t}decodeAndValidate({token:t,publicKeys:e,issuer:i,clientId:s,nonce:o}){const a=Math.floor(Date.now()/1e3),h=t.split(".");if(3!==h.length)throw new r(`Invalid JWT token. Got only ${h.length} parts.`);const u=this.jwt.KJUR.jws.JWS.parse(t);if(!u.headerObj)throw new r(n.INVALID_TOKEN);const c=u.headerObj.kid,l=this.getPublicKey(e.keys,c),f=this.jwt.KEYUTIL.getKey(l);if(!this.jwt.KJUR.jws.JWS.verify(t,f,{alg:[n.TOKEN_ALG]}))throw new r(n.INVALID_SIGNATURE);if(u.payloadObj.exp - * @license MIT - */ -var n=i(9),r=i(10),s=i(11);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return A(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function A(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return w(this,t,e,i);case"latin1":case"binary":return E(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function N(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||B(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);B(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);B(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(8))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(17);t.exports=class{constructor({w:t=window}={}){this.window=t}init(t){this.popupConfig=t}open(){const t=this.popupConfig.height,e=this.popupConfig.width,i=(window.screen.width-e)/2,r=(window.screen.height-t)/2;if(this.popup=this.window.open("","popup",`left=${i},top=${r},width=${e},height=${t},resizable,scrollbars=yes,status=1`),!this.popup)throw new n("Unable to open popup")}navigate(t){this.popup.location.href=t}close(){this.popup.close()}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(21);t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t);const i={"x-filter-type":`spa:v${n.version}`};this.publicKeys=e(this.getJwksEndpoint(),{headers:i})}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}},function(t){t.exports=JSON.parse('{"name":"ibmcloud-appid-js","version":"0.3.0","description":"IBM Cloud App ID SDK for Single Page Applications","scripts":{"build":"webpack","test":"mocha","coverage":"nyc --reporter=lcov mocha","docs":"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git"},"main":"dist/appid.umd.min.js","nyc":{"all":true,"include":["src/*.js"],"exclude":["**/PopupController.js","**/IFrameController.js","**/OpenIDConfigurationResource.js","**/constants.js"]},"dependencies":{"jsrsasign":"^8.0.12"},"devDependencies":{"node-fetch":"^2.6.0","@babel/cli":"^7.0.0","@babel/core":"^7.5.5","@babel/plugin-transform-runtime":"^7.5.5","@babel/preset-env":"^7.5.5","babel-cli":"^7.0.0-beta.3","chai":"^4.2.0","coveralls":"^3.0.6","gulp-babel":"^8.0.0","mocha":"^6.2.0","nyc":"^14.1.1","webpack":"^4.39.1","webpack-cli":"^3.3.6","docdash":"^1.1.1","jsdoc":"^3.6.3"}}')}])})); \ No newline at end of file +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["AppID"] = factory(); + else + root["AppID"] = factory(); +})(window, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./node_modules/base64-js/index.js": +/*!*****************************************!*\ + !*** ./node_modules/base64-js/index.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/base64-js/index.js?"); + +/***/ }), + +/***/ "./node_modules/buffer/index.js": +/*!**************************************!*\ + !*** ./node_modules/buffer/index.js ***! + \**************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("/* WEBPACK VAR INJECTION */(function(global) {/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n\n\nvar base64 = __webpack_require__(/*! base64-js */ \"./node_modules/base64-js/index.js\")\nvar ieee754 = __webpack_require__(/*! ieee754 */ \"./node_modules/ieee754/index.js\")\nvar isArray = __webpack_require__(/*! isarray */ \"./node_modules/isarray/index.js\")\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://AppID/./node_modules/buffer/index.js?"); + +/***/ }), + +/***/ "./node_modules/ieee754/index.js": +/*!***************************************!*\ + !*** ./node_modules/ieee754/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/ieee754/index.js?"); + +/***/ }), + +/***/ "./node_modules/isarray/index.js": +/*!***************************************!*\ + !*** ./node_modules/isarray/index.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n\n\n//# sourceURL=webpack://AppID/./node_modules/isarray/index.js?"); + +/***/ }), + +/***/ "./node_modules/jsrsasign/lib/jsrsasign.js": +/*!*************************************************!*\ + !*** ./node_modules/jsrsasign/lib/jsrsasign.js ***! + \*************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\nvar navigator = {};\nnavigator.userAgent = false;\n\nvar window = {};\n/*\n * jsrsasign(all) 8.0.12 (2018-04-22) (c) 2010-2018 Kenji Urushima | kjur.github.com/jsrsasign/license\n */\n\n/*!\nCopyright (c) 2011, Yahoo! Inc. All rights reserved.\nCode licensed under the BSD License:\nhttp://developer.yahoo.com/yui/license.html\nversion: 2.9.0\n*/\nif(YAHOO===undefined){var YAHOO={}}YAHOO.lang={extend:function(g,h,f){if(!h||!g){throw new Error(\"YAHOO.lang.extend failed, please check that all dependencies are included.\")}var d=function(){};d.prototype=h.prototype;g.prototype=new d();g.prototype.constructor=g;g.superclass=h.prototype;if(h.prototype.constructor==Object.prototype.constructor){h.prototype.constructor=h}if(f){var b;for(b in f){g.prototype[b]=f[b]}var e=function(){},c=[\"toString\",\"valueOf\"];try{if(/MSIE/.test(navigator.userAgent)){e=function(j,i){for(b=0;b>>2]>>>(24-(r%4)*8))&255;q[(n+r)>>>2]|=o<<(24-((n+r)%4)*8)}}else{for(var r=0;r>>2]=p[r>>>2]}}this.sigBytes+=s;return this},clamp:function(){var o=this.words;var n=this.sigBytes;o[n>>>2]&=4294967295<<(32-(n%4)*8);o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);n.words=this.words.slice(0);return n},random:function(p){var o=[];for(var n=0;n>>2]>>>(24-(n%4)*8))&255;q.push((s>>>4).toString(16));q.push((s&15).toString(16))}return q.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>3]|=parseInt(p.substr(o,2),16)<<(24-(o%8)*4)}return new l.init(q,n/2)}};var d=m.Latin1={stringify:function(q){var r=q.words;var p=q.sigBytes;var n=[];for(var o=0;o>>2]>>>(24-(o%4)*8))&255;n.push(String.fromCharCode(s))}return n.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>2]|=(p.charCodeAt(o)&255)<<(24-(o%4)*8)}return new l.init(q,n)}};var c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error(\"Malformed UTF-8 data\")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}};var i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init();this._nDataBytes=0},_append:function(n){if(typeof n==\"string\"){n=c.parse(n)}this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data;var x=q.words;var n=q.sigBytes;var t=this.blockSize;var v=t*4;var u=n/v;if(w){u=e.ceil(u)}else{u=e.max((u|0)-this._minBufferSize,0)}var s=u*t;var r=e.min(s*4,n);if(s){for(var p=0;p>>2]&255}};f.BlockCipher=n.extend({cfg:n.cfg.extend({mode:m,padding:h}),reset:function(){n.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;\nthis._mode=c.call(a,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var p=f.CipherParams=k.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(g.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;\nreturn(a?l.create([1398893684,1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=l.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return p.create({ciphertext:a,salt:c})}},j=f.SerializableCipher=k.extend({cfg:k.extend({format:m}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return p.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,\nblockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return\"string\"==typeof a?b.parse(a,this):a}}),g=(g.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=l.random(8));a=v.create({keySize:b+c}).compute(a,d);c=l.create(a.words.slice(b),4*c);a.sigBytes=4*b;return p.create({key:a,iv:c,salt:d})}},s=f.PasswordBasedCipher=j.extend({cfg:j.cfg.extend({kdf:g}),encrypt:function(a,\nb,c,d){d=this.cfg.extend(d);c=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=c.iv;a=j.encrypt.call(this,a,b,c.key,d);a.mixIn(c);return a},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=c.iv;return j.decrypt.call(this,a,b,c.key,d)}})}();\n\n/*\nCryptoJS v3.1.2 aes.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){for(var q=CryptoJS,x=q.lib.BlockCipher,r=q.algo,j=[],y=[],z=[],A=[],B=[],C=[],s=[],u=[],v=[],w=[],g=[],k=0;256>k;k++)g[k]=128>k?k<<1:k<<1^283;for(var n=0,l=0,k=0;256>k;k++){var f=l^l<<1^l<<2^l<<3^l<<4,f=f>>>8^f&255^99;j[n]=f;y[f]=n;var t=g[n],D=g[t],E=g[D],b=257*g[f]^16843008*f;z[n]=b<<24|b>>>8;A[n]=b<<16|b>>>16;B[n]=b<<8|b>>>24;C[n]=b;b=16843009*E^65537*D^257*t^16843008*n;s[f]=b<<24|b>>>8;u[f]=b<<16|b>>>16;v[f]=b<<8|b>>>24;w[f]=b;n?(n=t^g[g[g[E^t]]],l^=g[g[l]]):n=l=1}var F=[0,1,2,4,8,\n16,32,64,128,27,54],r=r.AES=x.extend({_doReset:function(){for(var c=this._key,e=c.words,a=c.sigBytes/4,c=4*((this._nRounds=a+6)+1),b=this._keySchedule=[],h=0;h>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255]):(d=d<<8|d>>>24,d=j[d>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255],d^=F[h/a|0]<<24);b[h]=b[h-a]^d}e=this._invKeySchedule=[];for(a=0;aa||4>=h?d:s[j[d>>>24]]^u[j[d>>>16&255]]^v[j[d>>>\n8&255]]^w[j[d&255]]},encryptBlock:function(c,e){this._doCryptBlock(c,e,this._keySchedule,z,A,B,C,j)},decryptBlock:function(c,e){var a=c[e+1];c[e+1]=c[e+3];c[e+3]=a;this._doCryptBlock(c,e,this._invKeySchedule,s,u,v,w,y);a=c[e+1];c[e+1]=c[e+3];c[e+3]=a},_doCryptBlock:function(c,e,a,b,h,d,j,m){for(var n=this._nRounds,f=c[e]^a[0],g=c[e+1]^a[1],k=c[e+2]^a[2],p=c[e+3]^a[3],l=4,t=1;t>>24]^h[g>>>16&255]^d[k>>>8&255]^j[p&255]^a[l++],r=b[g>>>24]^h[k>>>16&255]^d[p>>>8&255]^j[f&255]^a[l++],s=\nb[k>>>24]^h[p>>>16&255]^d[f>>>8&255]^j[g&255]^a[l++],p=b[p>>>24]^h[f>>>16&255]^d[g>>>8&255]^j[k&255]^a[l++],f=q,g=r,k=s;q=(m[f>>>24]<<24|m[g>>>16&255]<<16|m[k>>>8&255]<<8|m[p&255])^a[l++];r=(m[g>>>24]<<24|m[k>>>16&255]<<16|m[p>>>8&255]<<8|m[f&255])^a[l++];s=(m[k>>>24]<<24|m[p>>>16&255]<<16|m[f>>>8&255]<<8|m[g&255])^a[l++];p=(m[p>>>24]<<24|m[f>>>16&255]<<16|m[g>>>8&255]<<8|m[k&255])^a[l++];c[e]=q;c[e+1]=r;c[e+2]=s;c[e+3]=p},keySize:8});q.AES=x._createHelper(r)})();\n\n/*\nCryptoJS v3.1.2 tripledes-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function j(b,c){var a=(this._lBlock>>>b^this._rBlock)&c;this._rBlock^=a;this._lBlock^=a<>>b^this._lBlock)&c;this._lBlock^=a;this._rBlock^=a<a;a++){var f=q[a]-1;c[a]=b[f>>>5]>>>31-f%32&1}b=this._subKeys=[];for(f=0;16>f;f++){for(var d=b[f]=[],e=r[f],a=0;24>a;a++)d[a/6|0]|=c[(p[a]-1+e)%28]<<31-a%6,d[4+(a/6|0)]|=c[28+(p[a+24]-1+e)%28]<<31-a%6;d[0]=d[0]<<1|d[0]>>>31;for(a=1;7>a;a++)d[a]>>>=\n4*(a-1)+3;d[7]=d[7]<<5|d[7]>>>27}c=this._invSubKeys=[];for(a=0;16>a;a++)c[a]=b[15-a]},encryptBlock:function(b,c){this._doCryptBlock(b,c,this._subKeys)},decryptBlock:function(b,c){this._doCryptBlock(b,c,this._invSubKeys)},_doCryptBlock:function(b,c,a){this._lBlock=b[c];this._rBlock=b[c+1];j.call(this,4,252645135);j.call(this,16,65535);l.call(this,2,858993459);l.call(this,8,16711935);j.call(this,1,1431655765);for(var f=0;16>f;f++){for(var d=a[f],e=this._lBlock,h=this._rBlock,g=0,k=0;8>k;k++)g|=s[k][((h^\nd[k])&t[k])>>>0];this._lBlock=h;this._rBlock=e^g}a=this._lBlock;this._lBlock=this._rBlock;this._rBlock=a;j.call(this,1,1431655765);l.call(this,8,16711935);l.call(this,2,858993459);j.call(this,16,65535);j.call(this,4,252645135);b[c]=this._lBlock;b[c+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});h.DES=e._createHelper(m);g=g.TripleDES=e.extend({_doReset:function(){var b=this._key.words;this._des1=m.createEncryptor(n.create(b.slice(0,2)));this._des2=m.createEncryptor(n.create(b.slice(2,4)));this._des3=\nm.createEncryptor(n.create(b.slice(4,6)))},encryptBlock:function(b,c){this._des1.encryptBlock(b,c);this._des2.decryptBlock(b,c);this._des3.encryptBlock(b,c)},decryptBlock:function(b,c){this._des3.decryptBlock(b,c);this._des2.encryptBlock(b,c);this._des1.decryptBlock(b,c)},keySize:6,ivSize:2,blockSize:2});h.TripleDES=e._createHelper(g)})();\n\n/*\nCryptoJS v3.1.2 enc-base64.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join(\"\")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d<\ne;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\"}})();\n\n/*\nCryptoJS v3.1.2 md5.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(E){function h(a,f,g,j,p,h,k){a=a+(f&g|~f&j)+p+k;return(a<>>32-h)+f}function k(a,f,g,j,p,h,k){a=a+(f&j|g&~j)+p+k;return(a<>>32-h)+f}function l(a,f,g,j,h,k,l){a=a+(f^g^j)+h+l;return(a<>>32-k)+f}function n(a,f,g,j,h,k,l){a=a+(g^(f|~j))+h+l;return(a<>>32-k)+f}for(var r=CryptoJS,q=r.lib,F=q.WordArray,s=q.Hasher,q=r.algo,a=[],t=0;64>t;t++)a[t]=4294967296*E.abs(E.sin(t+1))|0;q=q.MD5=s.extend({_doReset:function(){this._hash=new F.init([1732584193,4023233417,2562383102,271733878])},\n_doProcessBlock:function(m,f){for(var g=0;16>g;g++){var j=f+g,p=m[j];m[j]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360}var g=this._hash.words,j=m[f+0],p=m[f+1],q=m[f+2],r=m[f+3],s=m[f+4],t=m[f+5],u=m[f+6],v=m[f+7],w=m[f+8],x=m[f+9],y=m[f+10],z=m[f+11],A=m[f+12],B=m[f+13],C=m[f+14],D=m[f+15],b=g[0],c=g[1],d=g[2],e=g[3],b=h(b,c,d,e,j,7,a[0]),e=h(e,b,c,d,p,12,a[1]),d=h(d,e,b,c,q,17,a[2]),c=h(c,d,e,b,r,22,a[3]),b=h(b,c,d,e,s,7,a[4]),e=h(e,b,c,d,t,12,a[5]),d=h(d,e,b,c,u,17,a[6]),c=h(c,d,e,b,v,22,a[7]),\nb=h(b,c,d,e,w,7,a[8]),e=h(e,b,c,d,x,12,a[9]),d=h(d,e,b,c,y,17,a[10]),c=h(c,d,e,b,z,22,a[11]),b=h(b,c,d,e,A,7,a[12]),e=h(e,b,c,d,B,12,a[13]),d=h(d,e,b,c,C,17,a[14]),c=h(c,d,e,b,D,22,a[15]),b=k(b,c,d,e,p,5,a[16]),e=k(e,b,c,d,u,9,a[17]),d=k(d,e,b,c,z,14,a[18]),c=k(c,d,e,b,j,20,a[19]),b=k(b,c,d,e,t,5,a[20]),e=k(e,b,c,d,y,9,a[21]),d=k(d,e,b,c,D,14,a[22]),c=k(c,d,e,b,s,20,a[23]),b=k(b,c,d,e,x,5,a[24]),e=k(e,b,c,d,C,9,a[25]),d=k(d,e,b,c,r,14,a[26]),c=k(c,d,e,b,w,20,a[27]),b=k(b,c,d,e,B,5,a[28]),e=k(e,b,\nc,d,q,9,a[29]),d=k(d,e,b,c,v,14,a[30]),c=k(c,d,e,b,A,20,a[31]),b=l(b,c,d,e,t,4,a[32]),e=l(e,b,c,d,w,11,a[33]),d=l(d,e,b,c,z,16,a[34]),c=l(c,d,e,b,C,23,a[35]),b=l(b,c,d,e,p,4,a[36]),e=l(e,b,c,d,s,11,a[37]),d=l(d,e,b,c,v,16,a[38]),c=l(c,d,e,b,y,23,a[39]),b=l(b,c,d,e,B,4,a[40]),e=l(e,b,c,d,j,11,a[41]),d=l(d,e,b,c,r,16,a[42]),c=l(c,d,e,b,u,23,a[43]),b=l(b,c,d,e,x,4,a[44]),e=l(e,b,c,d,A,11,a[45]),d=l(d,e,b,c,D,16,a[46]),c=l(c,d,e,b,q,23,a[47]),b=n(b,c,d,e,j,6,a[48]),e=n(e,b,c,d,v,10,a[49]),d=n(d,e,b,c,\nC,15,a[50]),c=n(c,d,e,b,t,21,a[51]),b=n(b,c,d,e,A,6,a[52]),e=n(e,b,c,d,r,10,a[53]),d=n(d,e,b,c,y,15,a[54]),c=n(c,d,e,b,p,21,a[55]),b=n(b,c,d,e,w,6,a[56]),e=n(e,b,c,d,D,10,a[57]),d=n(d,e,b,c,u,15,a[58]),c=n(c,d,e,b,B,21,a[59]),b=n(b,c,d,e,s,6,a[60]),e=n(e,b,c,d,z,10,a[61]),d=n(d,e,b,c,q,15,a[62]),c=n(c,d,e,b,x,21,a[63]);g[0]=g[0]+b|0;g[1]=g[1]+c|0;g[2]=g[2]+d|0;g[3]=g[3]+e|0},_doFinalize:function(){var a=this._data,f=a.words,g=8*this._nDataBytes,j=8*a.sigBytes;f[j>>>5]|=128<<24-j%32;var h=E.floor(g/\n4294967296);f[(j+64>>>9<<4)+15]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;f[(j+64>>>9<<4)+14]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360;a.sigBytes=4*(f.length+1);this._process();a=this._hash;f=a.words;for(g=0;4>g;g++)j=f[g],f[g]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=s.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=s._createHelper(q);r.HmacMD5=s._createHmacHelper(q)})(Math);\n\n/*\nCryptoJS v3.1.2 sha1-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var k=CryptoJS,b=k.lib,m=b.WordArray,l=b.Hasher,d=[],b=k.algo.SHA1=l.extend({_doReset:function(){this._hash=new m.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(n,p){for(var a=this._hash.words,e=a[0],f=a[1],h=a[2],j=a[3],b=a[4],c=0;80>c;c++){if(16>c)d[c]=n[p+c]|0;else{var g=d[c-3]^d[c-8]^d[c-14]^d[c-16];d[c]=g<<1|g>>>31}g=(e<<5|e>>>27)+b+d[c];g=20>c?g+((f&h|~f&j)+1518500249):40>c?g+((f^h^j)+1859775393):60>c?g+((f&h|f&j|h&j)-1894007588):g+((f^h^\nj)-899497514);b=j;j=h;h=f<<30|f>>>2;f=e;e=g}a[0]=a[0]+e|0;a[1]=a[1]+f|0;a[2]=a[2]+h|0;a[3]=a[3]+j|0;a[4]=a[4]+b|0},_doFinalize:function(){var b=this._data,d=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=Math.floor(a/4294967296);d[(e+64>>>9<<4)+15]=a;b.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var b=l.clone.call(this);b._hash=this._hash.clone();return b}});k.SHA1=l._createHelper(b);k.HmacSHA1=l._createHmacHelper(b)})();\n\n/*\nCryptoJS v3.1.2 sha256-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(k){for(var g=CryptoJS,h=g.lib,v=h.WordArray,j=h.Hasher,h=g.algo,s=[],t=[],u=function(q){return 4294967296*(q-(q|0))|0},l=2,b=0;64>b;){var d;a:{d=l;for(var w=k.sqrt(d),r=2;r<=w;r++)if(!(d%r)){d=!1;break a}d=!0}d&&(8>b&&(s[b]=u(k.pow(l,0.5))),t[b]=u(k.pow(l,1/3)),b++);l++}var n=[],h=h.SHA256=j.extend({_doReset:function(){this._hash=new v.init(s.slice(0))},_doProcessBlock:function(q,h){for(var a=this._hash.words,c=a[0],d=a[1],b=a[2],k=a[3],f=a[4],g=a[5],j=a[6],l=a[7],e=0;64>e;e++){if(16>e)n[e]=\nq[h+e]|0;else{var m=n[e-15],p=n[e-2];n[e]=((m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3)+n[e-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[e-16]}m=l+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&g^~f&j)+t[e]+n[e];p=((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&d^c&b^d&b);l=j;j=g;g=f;f=k+m|0;k=b;b=d;d=c;c=m+p|0}a[0]=a[0]+c|0;a[1]=a[1]+d|0;a[2]=a[2]+b|0;a[3]=a[3]+k|0;a[4]=a[4]+f|0;a[5]=a[5]+g|0;a[6]=a[6]+j|0;a[7]=a[7]+l|0},_doFinalize:function(){var d=this._data,b=d.words,a=8*this._nDataBytes,c=8*d.sigBytes;\nb[c>>>5]|=128<<24-c%32;b[(c+64>>>9<<4)+14]=k.floor(a/4294967296);b[(c+64>>>9<<4)+15]=a;d.sigBytes=4*b.length;this._process();return this._hash},clone:function(){var b=j.clone.call(this);b._hash=this._hash.clone();return b}});g.SHA256=j._createHelper(h);g.HmacSHA256=j._createHmacHelper(h)})(Math);\n\n/*\nCryptoJS v3.1.2 sha224-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var b=CryptoJS,d=b.lib.WordArray,a=b.algo,c=a.SHA256,a=a.SHA224=c.extend({_doReset:function(){this._hash=new d.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var a=c._doFinalize.call(this);a.sigBytes-=4;return a}});b.SHA224=c._createHelper(a);b.HmacSHA224=c._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 sha512-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function a(){return d.create.apply(d,arguments)}for(var n=CryptoJS,r=n.lib.Hasher,e=n.x64,d=e.Word,T=e.WordArray,e=n.algo,ea=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),\na(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,\n2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),\na(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,\n3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],w=0;80>w;w++)v[w]=a();e=e.SHA512=r.extend({_doReset:function(){this._hash=new T.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(a,d){for(var f=this._hash.words,\nF=f[0],e=f[1],n=f[2],r=f[3],G=f[4],H=f[5],I=f[6],f=f[7],w=F.high,J=F.low,X=e.high,K=e.low,Y=n.high,L=n.low,Z=r.high,M=r.low,$=G.high,N=G.low,aa=H.high,O=H.low,ba=I.high,P=I.low,ca=f.high,Q=f.low,k=w,g=J,z=X,x=K,A=Y,y=L,U=Z,B=M,l=$,h=N,R=aa,C=O,S=ba,D=P,V=ca,E=Q,m=0;80>m;m++){var s=v[m];if(16>m)var j=s.high=a[d+2*m]|0,b=s.low=a[d+2*m+1]|0;else{var j=v[m-15],b=j.high,p=j.low,j=(b>>>1|p<<31)^(b>>>8|p<<24)^b>>>7,p=(p>>>1|b<<31)^(p>>>8|b<<24)^(p>>>7|b<<25),u=v[m-2],b=u.high,c=u.low,u=(b>>>19|c<<13)^(b<<\n3|c>>>29)^b>>>6,c=(c>>>19|b<<13)^(c<<3|b>>>29)^(c>>>6|b<<26),b=v[m-7],W=b.high,t=v[m-16],q=t.high,t=t.low,b=p+b.low,j=j+W+(b>>>0

>>0?1:0),b=b+c,j=j+u+(b>>>0>>0?1:0),b=b+t,j=j+q+(b>>>0>>0?1:0);s.high=j;s.low=b}var W=l&R^~l&S,t=h&C^~h&D,s=k&z^k&A^z&A,T=g&x^g&y^x&y,p=(k>>>28|g<<4)^(k<<30|g>>>2)^(k<<25|g>>>7),u=(g>>>28|k<<4)^(g<<30|k>>>2)^(g<<25|k>>>7),c=ea[m],fa=c.high,da=c.low,c=E+((h>>>14|l<<18)^(h>>>18|l<<14)^(h<<23|l>>>9)),q=V+((l>>>14|h<<18)^(l>>>18|h<<14)^(l<<23|h>>>9))+(c>>>0>>0?1:\n0),c=c+t,q=q+W+(c>>>0>>0?1:0),c=c+da,q=q+fa+(c>>>0>>0?1:0),c=c+b,q=q+j+(c>>>0>>0?1:0),b=u+T,s=p+s+(b>>>0>>0?1:0),V=S,E=D,S=R,D=C,R=l,C=h,h=B+c|0,l=U+q+(h>>>0>>0?1:0)|0,U=A,B=y,A=z,y=x,z=k,x=g,g=c+b|0,k=q+s+(g>>>0>>0?1:0)|0}J=F.low=J+g;F.high=w+k+(J>>>0>>0?1:0);K=e.low=K+x;e.high=X+z+(K>>>0>>0?1:0);L=n.low=L+y;n.high=Y+A+(L>>>0>>0?1:0);M=r.low=M+B;r.high=Z+U+(M>>>0>>0?1:0);N=G.low=N+h;G.high=$+l+(N>>>0>>0?1:0);O=H.low=O+C;H.high=aa+R+(O>>>0>>0?1:0);P=I.low=P+D;\nI.high=ba+S+(P>>>0>>0?1:0);Q=f.low=Q+E;f.high=ca+V+(Q>>>0>>0?1:0)},_doFinalize:function(){var a=this._data,d=a.words,f=8*this._nDataBytes,e=8*a.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+128>>>10<<5)+30]=Math.floor(f/4294967296);d[(e+128>>>10<<5)+31]=f;a.sigBytes=4*d.length;this._process();return this._hash.toX32()},clone:function(){var a=r.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});n.SHA512=r._createHelper(e);n.HmacSHA512=r._createHmacHelper(e)})();\n\n/*\nCryptoJS v3.1.2 sha384-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,a=c.x64,b=a.Word,e=a.WordArray,a=c.algo,d=a.SHA512,a=a.SHA384=d.extend({_doReset:function(){this._hash=new e.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var a=d._doFinalize.call(this);a.sigBytes-=16;return a}});c.SHA384=\nd._createHelper(a);c.HmacSHA384=d._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 ripemd160-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n/*\n\n(c) 2012 by Cedric Mesnil. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n(function(){var q=CryptoJS,d=q.lib,n=d.WordArray,p=d.Hasher,d=q.algo,x=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),y=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),z=n.create([11,14,15,12,\n5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),A=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),B=n.create([0,1518500249,1859775393,2400959708,2840853838]),C=n.create([1352829926,1548603684,1836072691,\n2053994217,0]),d=d.RIPEMD160=p.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,v){for(var b=0;16>b;b++){var c=v+b,f=e[c];e[c]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360}var c=this._hash.words,f=B.words,d=C.words,n=x.words,q=y.words,p=z.words,w=A.words,t,g,h,j,r,u,k,l,m,s;u=t=c[0];k=g=c[1];l=h=c[2];m=j=c[3];s=r=c[4];for(var a,b=0;80>b;b+=1)a=t+e[v+n[b]]|0,a=16>b?a+((g^h^j)+f[0]):32>b?a+((g&h|~g&j)+f[1]):48>b?\na+(((g|~h)^j)+f[2]):64>b?a+((g&j|h&~j)+f[3]):a+((g^(h|~j))+f[4]),a|=0,a=a<>>32-p[b],a=a+r|0,t=r,r=j,j=h<<10|h>>>22,h=g,g=a,a=u+e[v+q[b]]|0,a=16>b?a+((k^(l|~m))+d[0]):32>b?a+((k&m|l&~m)+d[1]):48>b?a+(((k|~l)^m)+d[2]):64>b?a+((k&l|~k&m)+d[3]):a+((k^l^m)+d[4]),a|=0,a=a<>>32-w[b],a=a+s|0,u=s,s=m,m=l<<10|l>>>22,l=k,k=a;a=c[1]+h+m|0;c[1]=c[2]+j+s|0;c[2]=c[3]+r+u|0;c[3]=c[4]+t+k|0;c[4]=c[0]+g+l|0;c[0]=a},_doFinalize:function(){var e=this._data,d=e.words,b=8*this._nDataBytes,c=8*e.sigBytes;\nd[c>>>5]|=128<<24-c%32;d[(c+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;e.sigBytes=4*(d.length+1);this._process();e=this._hash;d=e.words;for(b=0;5>b;b++)c=d[b],d[b]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return e},clone:function(){var d=p.clone.call(this);d._hash=this._hash.clone();return d}});q.RIPEMD160=p._createHelper(d);q.HmacRIPEMD160=p._createHmacHelper(d)})(Math);\n\n/*\nCryptoJS v3.1.2 hmac.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,k=c.enc.Utf8;c.algo.HMAC=c.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;\"string\"==typeof b&&(b=k.parse(b));var c=a.blockSize,e=4*c;b.sigBytes>e&&(b=a.finalize(b));b.clamp();for(var f=this._oKey=b.clone(),g=this._iKey=b.clone(),h=f.words,j=g.words,d=0;d>6)+b64map.charAt(e&63)}if(b+1==d.length){e=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(e<<2)}else{if(b+2==d.length){e=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(e>>2)+b64map.charAt((e&3)<<4)}}if(b64pad){while((a.length&3)>0){a+=b64pad}}return a}function b64tohex(f){var d=\"\";var e;var b=0;var c;var a;for(e=0;e>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(e){var d=b64tohex(e);var c;var b=new Array();for(c=0;2*c=0){var d=a*this[f++]+b[e]+h;h=Math.floor(d/67108864);b[e++]=d&67108863}return h}function am2(f,q,r,e,o,a){var k=q&32767,p=q>>15;while(--a>=0){var d=this[f]&32767;var g=this[f++]>>15;var b=p*d+g*k;d=k*d+((b&32767)<<15)+r[e]+(o&1073741823);o=(d>>>30)+(b>>>15)+p*g+(o>>>30);r[e++]=d&1073741823}return o}function am3(f,q,r,e,o,a){var k=q&16383,p=q>>14;while(--a>=0){var d=this[f]&16383;var g=this[f++]>>14;var b=p*d+g*k;d=k*d+((b&16383)<<14)+r[e]+o;o=(d>>28)+(b>>14)+p*g;r[e++]=d&268435455}return o}if(j_lm&&(navigator.appName==\"Microsoft Internet Explorer\")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator.appName!=\"Netscape\")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=((1<=0;--a){b[a]=this[a]}b.t=this.t;b.s=this.s}function bnpFromInt(a){this.t=1;this.s=(a<0)?-1:0;if(a>0){this[0]=a}else{if(a<-1){this[0]=a+this.DV}else{this.t=0}}}function nbv(a){var b=nbi();b.fromInt(a);return b}function bnpFromString(h,c){var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==256){e=8}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{this.fromRadix(h,c);return}}}}}}this.t=0;this.s=0;var g=h.length,d=false,f=0;while(--g>=0){var a=(e==8)?h[g]&255:intAt(h,g);if(a<0){if(h.charAt(g)==\"-\"){d=true}continue}d=false;if(f==0){this[this.t++]=a}else{if(f+e>this.DB){this[this.t-1]|=(a&((1<<(this.DB-f))-1))<>(this.DB-f))}else{this[this.t-1]|=a<=this.DB){f-=this.DB}}if(e==8&&(h[0]&128)!=0){this.s=-1;if(f>0){this[this.t-1]|=((1<<(this.DB-f))-1)<0&&this[this.t-1]==a){--this.t}}function bnToString(c){if(this.s<0){return\"-\"+this.negate().toString(c)}var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{return this.toRadix(c)}}}}}var g=(1<0){if(j>j)>0){a=true;h=int2char(l)}while(f>=0){if(j>(j+=this.DB-e)}else{l=(this[f]>>(j-=e))&g;if(j<=0){j+=this.DB;--f}}if(l>0){a=true}if(a){h+=int2char(l)}}}return a?h:\"0\"}function bnNegate(){var a=nbi();BigInteger.ZERO.subTo(this,a);return a}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(b){var d=this.s-b.s;if(d!=0){return d}var c=this.t;d=c-b.t;if(d!=0){return(this.s<0)?-d:d}while(--c>=0){if((d=this[c]-b[c])!=0){return d}}return 0}function nbits(a){var c=1,b;if((b=a>>>16)!=0){a=b;c+=16}if((b=a>>8)!=0){a=b;c+=8}if((b=a>>4)!=0){a=b;c+=4}if((b=a>>2)!=0){a=b;c+=2}if((b=a>>1)!=0){a=b;c+=1}return c}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(c,b){var a;for(a=this.t-1;a>=0;--a){b[a+c]=this[a]}for(a=c-1;a>=0;--a){b[a]=0}b.t=this.t+c;b.s=this.s}function bnpDRShiftTo(c,b){for(var a=c;a=0;--d){e[d+f+1]=(this[d]>>a)|h;h=(this[d]&g)<=0;--d){e[d]=0}e[f]=h;e.t=this.t+f+1;e.s=this.s;e.clamp()}function bnpRShiftTo(g,d){d.s=this.s;var e=Math.floor(g/this.DB);if(e>=this.t){d.t=0;return}var b=g%this.DB;var a=this.DB-b;var f=(1<>b;for(var c=e+1;c>b}if(b>0){d[this.t-e-1]|=(this.s&f)<>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g-=d.s}f.s=(g<0)?-1:0;if(g<-1){f[e++]=this.DV+g}else{if(g>0){f[e++]=g}}f.t=e;f.clamp()}function bnpMultiplyTo(c,e){var b=this.abs(),f=c.abs();var d=b.t;e.t=d+f.t;while(--d>=0){e[d]=0}for(d=0;d=0){d[b]=0}for(b=0;b=a.DV){d[b+a.t]-=a.DV;d[b+a.t+1]=1}}if(d.t>0){d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)}d.s=0;d.clamp()}function bnpDivRemTo(n,h,g){var w=n.abs();if(w.t<=0){return}var k=this.abs();if(k.t0){w.lShiftTo(v,d);k.lShiftTo(v,g)}else{w.copyTo(d);k.copyTo(g)}var p=d.t;var b=d[p-1];if(b==0){return}var o=b*(1<1)?d[p-2]>>this.F2:0);var A=this.FV/o,z=(1<=0){g[g.t++]=1;g.subTo(f,g)}BigInteger.ONE.dlShiftTo(p,f);f.subTo(d,d);while(d.t=0){var c=(g[--u]==b)?this.DM:Math.floor(g[u]*A+(g[u-1]+x)*z);if((g[u]+=d.am(0,c,g,s,0,p))0){g.rShiftTo(v,g)}if(a<0){BigInteger.ZERO.subTo(g,g)}}function bnMod(b){var c=nbi();this.abs().divRemTo(b,null,c);if(this.s<0&&c.compareTo(BigInteger.ZERO)>0){b.subTo(c,c)}return c}function Classic(a){this.m=a}function cConvert(a){if(a.s<0||a.compareTo(this.m)>=0){return a.mod(this.m)}else{return a}}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var a=this[0];if((a&1)==0){return 0}var b=a&3;b=(b*(2-(a&15)*b))&15;b=(b*(2-(a&255)*b))&255;b=(b*(2-(((a&65535)*b)&65535)))&65535;b=(b*(2-a*b%this.DV))%this.DV;return(b>0)?this.DV-b:-b}function Montgomery(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(a.DB-15))-1;this.mt2=2*a.t}function montConvert(a){var b=nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);if(a.s<0&&b.compareTo(BigInteger.ZERO)>0){this.m.subTo(b,b)}return b}function montRevert(a){var b=nbi();a.copyTo(b);this.reduce(b);return b}function montReduce(a){while(a.t<=this.mt2){a[a.t++]=0}for(var c=0;c>15)*this.mpl)&this.um)<<15))&a.DM;b=c+this.m.t;a[b]+=this.m.am(0,d,a,c,0,this.m.t);while(a[b]>=a.DV){a[b]-=a.DV;a[++b]++}}a.clamp();a.drShiftTo(this.m.t,a);if(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(h,j){if(h>4294967295||h<1){return BigInteger.ONE}var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;d.copyTo(f);while(--c>=0){j.sqrTo(f,a);if((h&(1<0){j.mulTo(a,d,f)}else{var b=f;f=a;a=b}}return j.revert(f)}function bnModPowInt(b,a){var c;if(b<256||a.isEven()){c=new Classic(a)}else{c=new Montgomery(a)}return this.exp(b,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction bnClone(){var a=nbi();this.copyTo(a);return a}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this[0]}else{if(this.t==0){return 0}}}return((this[1]&((1<<(32-this.DB))-1))<>24}function bnShortValue(){return(this.t==0)?this.s:(this[0]<<16)>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this[0]<=0)){return 0}else{return 1}}}function bnpToRadix(c){if(c==null){c=10}if(this.signum()==0||c<2||c>36){return\"0\"}var f=this.chunkSize(c);var e=Math.pow(c,f);var i=nbv(e),j=nbi(),h=nbi(),g=\"\";this.divRemTo(i,j,h);while(j.signum()>0){g=(e+h.intValue()).toString(c).substr(1)+g;j.divRemTo(i,j,h)}return h.intValue().toString(c)+g}function bnpFromRadix(m,h){this.fromInt(0);if(h==null){h=10}var f=this.chunkSize(h);var g=Math.pow(h,f),e=false,a=0,l=0;for(var c=0;c=f){this.dMultiply(g);this.dAddOffset(l,0);a=0;l=0}}if(a>0){this.dMultiply(Math.pow(h,a));this.dAddOffset(l,0)}if(e){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(f,e,h){if(\"number\"==typeof e){if(f<2){this.fromInt(1)}else{this.fromNumber(f,h);if(!this.testBit(f-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(f-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(e)){this.dAddOffset(2,0);if(this.bitLength()>f){this.subTo(BigInteger.ONE.shiftLeft(f-1),this)}}}}else{var d=new Array(),g=f&7;d.length=(f>>3)+1;e.nextBytes(d);if(g>0){d[0]&=((1<0){if(e>e)!=(this.s&this.DM)>>e){c[a++]=f|(this.s<<(this.DB-e))}while(b>=0){if(e<8){f=(this[b]&((1<>(e+=this.DB-8)}else{f=(this[b]>>(e-=8))&255;if(e<=0){e+=this.DB;--b}}if((f&128)!=0){f|=-256}if(a==0&&(this.s&128)!=(f&128)){++a}if(a>0||f!=this.s){c[a++]=f}}}return c}function bnEquals(b){return(this.compareTo(b)==0)}function bnMin(b){return(this.compareTo(b)<0)?this:b}function bnMax(b){return(this.compareTo(b)>0)?this:b}function bnpBitwiseTo(c,h,e){var d,g,b=Math.min(c.t,this.t);for(d=0;d>=16;b+=16}if((a&255)==0){a>>=8;b+=8}if((a&15)==0){a>>=4;b+=4}if((a&3)==0){a>>=2;b+=2}if((a&1)==0){++b}return b}function bnGetLowestSetBit(){for(var a=0;a=this.t){return(this.s!=0)}return((this[a]&(1<<(b%this.DB)))!=0)}function bnpChangeBit(c,b){var a=BigInteger.ONE.shiftLeft(c);this.bitwiseTo(a,b,a);return a}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(d,f){var e=0,g=0,b=Math.min(d.t,this.t);while(e>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g+=d.s}f.s=(g<0)?-1:0;if(g>0){f[e++]=g}else{if(g<-1){f[e++]=this.DV+g}}f.t=e;f.clamp()}function bnAdd(b){var c=nbi();this.addTo(b,c);return c}function bnSubtract(b){var c=nbi();this.subTo(b,c);return c}function bnMultiply(b){var c=nbi();this.multiplyTo(b,c);return c}function bnSquare(){var a=nbi();this.squareTo(a);return a}function bnDivide(b){var c=nbi();this.divRemTo(b,c,null);return c}function bnRemainder(b){var c=nbi();this.divRemTo(b,null,c);return c}function bnDivideAndRemainder(b){var d=nbi(),c=nbi();this.divRemTo(b,d,c);return new Array(d,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(b,a){if(b==0){return}while(this.t<=a){this[this.t++]=0}this[a]+=b;while(this[a]>=this.DV){this[a]-=this.DV;if(++a>=this.t){this[this.t++]=0}++this[a]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,c,b){a.multiplyTo(c,b)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp())}function bnpMultiplyLowerTo(b,f,e){var d=Math.min(this.t+b.t,f);e.s=0;e.t=d;while(d>0){e[--d]=0}var c;for(c=e.t-this.t;d=0){d[c]=0}for(c=Math.max(e-this.t,0);c2*this.m.t){return a.mod(this.m)}else{if(a.compareTo(this.m)<0){return a}else{var b=nbi();a.copyTo(b);this.reduce(b);return b}}}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1){a.t=this.m.t+1;a.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0){a.dAddOffset(1,this.m.t+1)}a.subTo(this.r2,a);while(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(q,f){var o=q.bitLength(),h,b=nbv(1),v;if(o<=0){return b}else{if(o<18){h=1}else{if(o<48){h=3}else{if(o<144){h=4}else{if(o<768){h=5}else{h=6}}}}}if(o<8){v=new Classic(f)}else{if(f.isEven()){v=new Barrett(f)}else{v=new Montgomery(f)}}var p=new Array(),d=3,s=h-1,a=(1<1){var A=nbi();v.sqrTo(p[1],A);while(d<=a){p[d]=nbi();v.mulTo(A,p[d-2],p[d]);d+=2}}var l=q.t-1,x,u=true,c=nbi(),y;o=nbits(q[l])-1;while(l>=0){if(o>=s){x=(q[l]>>(o-s))&a}else{x=(q[l]&((1<<(o+1))-1))<<(s-o);if(l>0){x|=q[l-1]>>(this.DB+o-s)}}d=h;while((x&1)==0){x>>=1;--d}if((o-=d)<0){o+=this.DB;--l}if(u){p[x].copyTo(b);u=false}else{while(d>1){v.sqrTo(b,c);v.sqrTo(c,b);d-=2}if(d>0){v.sqrTo(b,c)}else{y=b;b=c;c=y}v.mulTo(c,p[x],b)}while(l>=0&&(q[l]&(1<0){b.rShiftTo(f,b);h.rShiftTo(f,h)}while(b.signum()>0){if((d=b.getLowestSetBit())>0){b.rShiftTo(d,b)}if((d=h.getLowestSetBit())>0){h.rShiftTo(d,h)}if(b.compareTo(h)>=0){b.subTo(h,b);b.rShiftTo(1,b)}else{h.subTo(b,h);h.rShiftTo(1,h)}}if(f>0){h.lShiftTo(f,h)}return h}function bnpModInt(e){if(e<=0){return 0}var c=this.DV%e,b=(this.s<0)?e-1:0;if(this.t>0){if(c==0){b=this[0]%e}else{for(var a=this.t-1;a>=0;--a){b=(c*b+this[a])%e}}}return b}function bnModInverse(f){var j=f.isEven();if((this.isEven()&&j)||f.signum()==0){return BigInteger.ZERO}var i=f.clone(),h=this.clone();var g=nbv(1),e=nbv(0),l=nbv(0),k=nbv(1);while(i.signum()!=0){while(i.isEven()){i.rShiftTo(1,i);if(j){if(!g.isEven()||!e.isEven()){g.addTo(this,g);e.subTo(f,e)}g.rShiftTo(1,g)}else{if(!e.isEven()){e.subTo(f,e)}}e.rShiftTo(1,e)}while(h.isEven()){h.rShiftTo(1,h);if(j){if(!l.isEven()||!k.isEven()){l.addTo(this,l);k.subTo(f,k)}l.rShiftTo(1,l)}else{if(!k.isEven()){k.subTo(f,k)}}k.rShiftTo(1,k)}if(i.compareTo(h)>=0){i.subTo(h,i);if(j){g.subTo(l,g)}e.subTo(k,e)}else{h.subTo(i,h);if(j){l.subTo(g,l)}k.subTo(e,k)}}if(h.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(k.compareTo(f)>=0){return k.subtract(f)}if(k.signum()<0){k.addTo(f,k)}else{return k}if(k.signum()<0){return k.add(f)}else{return k}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(e){var d,b=this.abs();if(b.t==1&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d>1;if(f>lowprimes.length){f=lowprimes.length}var b=nbi();for(var e=0;e>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(window!==undefined&&(window.crypto!==undefined||window.msCrypto!==undefined)){var crypto=window.crypto||window.msCrypto;if(crypto.getRandomValues){var ua=new Uint8Array(32);crypto.getRandomValues(ua);for(t=0;t<32;++t){rng_pool[rng_pptr++]=ua[t]}}else{if(navigator.appName==\"Netscape\"&&navigator.appVersion<\"5\"){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr=0&&h>0){var f=e.charCodeAt(d--);if(f<128){g[--h]=f}else{if((f>127)&&(f<2048)){g[--h]=(f&63)|128;g[--h]=(f>>6)|192}else{g[--h]=(f&63)|128;g[--h]=((f>>6)&63)|128;g[--h]=(f>>12)|224}}}g[--h]=0;var b=new SecureRandom();var a=new Array();while(h>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}g[--h]=a[0]}g[--h]=2;g[--h]=0;return new BigInteger(g)}function oaep_mgf1_arr(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255])));d+=1}return b}function oaep_pad(q,a,f,l){var c=KJUR.crypto.MessageDigest;var o=KJUR.crypto.Util;var b=null;if(!f){f=\"sha1\"}if(typeof f===\"string\"){b=c.getCanonicalAlgName(f);l=c.getHashLength(b);f=function(i){return hextorstr(o.hashHex(rstrtohex(i),b))}}if(q.length+2*l+2>a){throw\"Message too long for RSA\"}var k=\"\",e;for(e=0;e0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{throw\"Invalid RSA public key\"}}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var e=this.doPublic(a);if(e==null){return null}var b=e.toString(16);if((b.length&1)==0){return b}else{return\"0\"+b}}function RSAEncryptOAEP(f,e,b){var a=oaep_pad(f,(this.n.bitLength()+7)>>3,e,b);if(a==null){return null}var g=this.doPublic(a);if(g==null){return null}var d=g.toString(16);if((d.length&1)==0){return d}else{return\"0\"+d}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;RSAKey.prototype.encryptOAEP=RSAEncryptOAEP;RSAKey.prototype.type=\"RSA\";\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction pkcs1unpad2(g,j){var a=g.toByteArray();var f=0;while(f=a.length){return null}}var e=\"\";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}function oaep_unpad(o,b,g,p){var e=KJUR.crypto.MessageDigest;var r=KJUR.crypto.Util;var c=null;if(!g){g=\"sha1\"}if(typeof g===\"string\"){c=e.getCanonicalAlgName(g);p=e.getHashLength(c);g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}}o=o.toByteArray();var h;for(h=0;h0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{throw\"Invalid RSA private key\"}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;this.isPublic=false;if(g==null){throw\"RSASetPrivateEx N == null\"}if(d==null){throw\"RSASetPrivateEx E == null\"}if(g.length==0){throw\"RSASetPrivateEx N.length == 0\"}if(d.length==0){throw\"RSASetPrivateEx E.length == 0\"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{throw\"Invalid RSA private key in RSASetPrivateEx\"}}function RSAGenerate(b,i){var a=new SecureRandom();var f=b>>1;this.e=parseInt(i,16);var c=new BigInteger(i,16);for(;;){for(;;){this.p=new BigInteger(b-f,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(f,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var h=this.p;this.p=this.q;this.q=h}var g=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var e=g.multiply(d);if(e.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(e);this.dmp1=this.d.mod(g);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=true}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}function RSADecryptOAEP(e,d,b){var f=parseBigInt(e,16);var a=this.doPrivate(f);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,d,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP;\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction ECFieldElementFp(b,a){this.x=a;this.q=b}function feFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.x.equals(a.x))}function feFpToBigInteger(){return this.x}function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))}function feFpAdd(a){return new ECFieldElementFp(this.q,this.x.add(a.toBigInteger()).mod(this.q))}function feFpSubtract(a){return new ECFieldElementFp(this.q,this.x.subtract(a.toBigInteger()).mod(this.q))}function feFpMultiply(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger()).mod(this.q))}function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))}function feFpDivide(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger().modInverse(this.q)).mod(this.q))}ECFieldElementFp.prototype.equals=feFpEquals;ECFieldElementFp.prototype.toBigInteger=feFpToBigInteger;ECFieldElementFp.prototype.negate=feFpNegate;ECFieldElementFp.prototype.add=feFpAdd;ECFieldElementFp.prototype.subtract=feFpSubtract;ECFieldElementFp.prototype.multiply=feFpMultiply;ECFieldElementFp.prototype.square=feFpSquare;ECFieldElementFp.prototype.divide=feFpDivide;function ECPointFp(c,a,d,b){this.curve=c;this.x=a;this.y=d;if(b==null){this.z=BigInteger.ONE}else{this.z=b}this.zinv=null}function pointFpGetX(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpGetY(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpEquals(a){if(a==this){return true}if(this.isInfinity()){return a.isInfinity()}if(a.isInfinity()){return this.isInfinity()}var c,b;c=a.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(a.z)).mod(this.curve.q);if(!c.equals(BigInteger.ZERO)){return false}b=a.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(a.z)).mod(this.curve.q);return b.equals(BigInteger.ZERO)}function pointFpIsInfinity(){if((this.x==null)&&(this.y==null)){return true}return this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)}function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)}function pointFpAdd(l){if(this.isInfinity()){return l}if(l.isInfinity()){return this}var p=l.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(l.z)).mod(this.curve.q);var o=l.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(l.z)).mod(this.curve.q);if(BigInteger.ZERO.equals(o)){if(BigInteger.ZERO.equals(p)){return this.twice()}return this.curve.getInfinity()}var j=new BigInteger(\"3\");var e=this.x.toBigInteger();var n=this.y.toBigInteger();var c=l.x.toBigInteger();var k=l.y.toBigInteger();var m=o.square();var i=m.multiply(o);var d=e.multiply(m);var g=p.square().multiply(this.z);var a=g.subtract(d.shiftLeft(1)).multiply(l.z).subtract(i).multiply(o).mod(this.curve.q);var h=d.multiply(j).multiply(p).subtract(n.multiply(i)).subtract(g.multiply(p)).multiply(l.z).add(p.multiply(i)).mod(this.curve.q);var f=i.multiply(this.z).multiply(l.z).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),f)}function pointFpTwice(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var g=new BigInteger(\"3\");var c=this.x.toBigInteger();var h=this.y.toBigInteger();var e=h.multiply(this.z);var j=e.multiply(h).mod(this.curve.q);var i=this.curve.a.toBigInteger();var k=c.square().multiply(g);if(!BigInteger.ZERO.equals(i)){k=k.add(this.z.square().multiply(i))}k=k.mod(this.curve.q);var b=k.square().subtract(c.shiftLeft(3).multiply(j)).shiftLeft(1).multiply(e).mod(this.curve.q);var f=k.multiply(g).multiply(c).subtract(j.shiftLeft(1)).shiftLeft(2).multiply(j).subtract(k.square().multiply(k)).mod(this.curve.q);var d=e.square().multiply(e).shiftLeft(3).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(b),this.curve.fromBigInteger(f),d)}function pointFpMultiply(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add(a?this:l)}}return d}function pointFpMultiplyTwo(c,a,b){var d;if(c.bitLength()>b.bitLength()){d=c.bitLength()-1}else{d=b.bitLength()-1}var f=this.curve.getInfinity();var e=this.add(a);while(d>=0){f=f.twice();if(c.testBit(d)){if(b.testBit(d)){f=f.add(e)}else{f=f.add(this)}}else{if(b.testBit(d)){f=f.add(a)}}--d}return f}ECPointFp.prototype.getX=pointFpGetX;ECPointFp.prototype.getY=pointFpGetY;ECPointFp.prototype.equals=pointFpEquals;ECPointFp.prototype.isInfinity=pointFpIsInfinity;ECPointFp.prototype.negate=pointFpNegate;ECPointFp.prototype.add=pointFpAdd;ECPointFp.prototype.twice=pointFpTwice;ECPointFp.prototype.multiply=pointFpMultiply;ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo;function ECCurveFp(e,d,c){this.q=e;this.a=this.fromBigInteger(d);this.b=this.fromBigInteger(c);this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b))}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)}function curveFpDecodePointHex(d){switch(parseInt(d.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var a=(d.length-2)/2;var c=d.substr(2,a);var b=d.substr(a+2,a);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(b,16)));default:return null}}ECCurveFp.prototype.getQ=curveFpGetQ;ECCurveFp.prototype.getA=curveFpGetA;ECCurveFp.prototype.getB=curveFpGetB;ECCurveFp.prototype.equals=curveFpEquals;ECCurveFp.prototype.getInfinity=curveFpGetInfinity;ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger;ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex;\n/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib\n */\nECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};ECPointFp.prototype.getEncoded=function(c){var d=function(h,f){var g=h.toByteArrayUnsigned();if(fg.length){g.unshift(0)}}return g};var a=this.getX().toBigInteger();var e=this.getY().toBigInteger();var b=d(a,32);if(c){if(e.isEven()){b.unshift(2)}else{b.unshift(3)}}else{b.unshift(4);b=b.concat(d(e,32))}return b};ECPointFp.decodeFrom=function(g,c){var f=c[0];var e=c.length-1;var d=c.slice(1,1+e/2);var b=c.slice(1+e/2,1+e);d.unshift(0);b.unshift(0);var a=new BigInteger(d);var h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.decodeFromHex=function(g,c){var f=c.substr(0,2);var e=c.length-2;var d=c.substr(2,e/2);var b=c.substr(2+e/2,e/2);var a=new BigInteger(d,16);var h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.prototype.add2D=function(c){if(this.isInfinity()){return c}if(c.isInfinity()){return this}if(this.x.equals(c.x)){if(this.y.equals(c.y)){return this.twice()}return this.curve.getInfinity()}var g=c.x.subtract(this.x);var e=c.y.subtract(this.y);var a=e.divide(g);var d=a.square().subtract(this.x).subtract(c.x);var f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var b=this.curve.fromBigInteger(BigInteger.valueOf(2));var e=this.curve.fromBigInteger(BigInteger.valueOf(3));var a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b));var c=a.square().subtract(this.x.multiply(b));var d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)};ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add2D(a?this:l)}}return d};ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger();var i=this.getY().toBigInteger();var f=this.curve.getA().toBigInteger();var c=this.curve.getB().toBigInteger();var h=this.curve.getQ();var e=i.multiply(i).mod(h);var g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)};ECPointFp.prototype.toString=function(){return\"(\"+this.getX().toBigInteger().toString()+\",\"+this.getY().toBigInteger().toString()+\")\"};ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity()){throw new Error(\"Point is at infinity.\")}var a=this.getX().toBigInteger();var b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"x coordinate out of bounds\")}if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"y coordinate out of bounds\")}if(!this.isOnCurve()){throw new Error(\"Point is not on the curve.\")}if(this.multiply(c).isInfinity()){throw new Error(\"Point is not a scalar multiple of G.\")}return true};\n/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval\n */\nvar jsonParse=(function(){var e=\"(?:-?\\\\b(?:0|[1-9][0-9]*)(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\\\b)\";var j='(?:[^\\\\0-\\\\x08\\\\x0a-\\\\x1f\"\\\\\\\\]|\\\\\\\\(?:[\"/\\\\\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:\"'+j+'*\")';var d=new RegExp(\"(?:false|true|null|[\\\\{\\\\}\\\\[\\\\]]|\"+e+\"|\"+i+\")\",\"g\");var k=new RegExp(\"\\\\\\\\(?:([^u])|u(.{4}))\",\"g\");var g={'\"':'\"',\"/\":\"/\",\"\\\\\":\"\\\\\",b:\"\\b\",f:\"\\f\",n:\"\\n\",r:\"\\r\",t:\"\\t\"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String(\"\");var a=\"\\\\\";var f={\"{\":Object,\"[\":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if(\"{\"===v){x={}}else{if(\"[\"===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({\"\":x},\"\")}return x}})();\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.asn1==\"undefined\"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b=\"0\"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!=\"-\"){if(f.length%2==1){f=\"0\"+f}else{if(!f.match(/^[0-7]/)){f=\"00\"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g=\"\";for(var d=0;d15){throw\"ASN.1 length too long to represent by 8x: n = \"+i.toString(16)}var f=128+g;return f.toString(16)+h}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return\"\"}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!=\"undefined\"){if(typeof c==\"string\"){this.setString(c)}else{if(typeof c.str!=\"undefined\"){this.setString(c.str)}else{if(typeof c.hex!=\"undefined\"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(f){utc=f.getTime()+(f.getTimezoneOffset()*60000);var e=new Date(utc);return e};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o==\"utc\"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,\"\");r=r+\".\"+k}}return r+\"Z\"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join(\"0\")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!=\"undefined\"){if(typeof b.array!=\"undefined\"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT=\"01\";this.hTLV=\"0101ff\"};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT=\"02\";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!=\"undefined\"){if(typeof a.bigint!=\"undefined\"){this.setByBigInteger(a.bigint)}else{if(typeof a[\"int\"]!=\"undefined\"){this.setByInteger(a[\"int\"])}else{if(typeof a==\"number\"){this.setByInteger(a)}else{if(typeof a.hex!=\"undefined\"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!==\"undefined\"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex=\"00\"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT=\"03\";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=(l*2))){break}if(d>=200){break}g.push(b);c=b;d++}return g};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){throw\"checking tag doesn't match: \"+e.substr(d,2)+\"!=\"+i}}return d}f=c.shift();b=g.getChildIdx(e,d);return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getTLVbyList=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyList(d,c,b);if(a===undefined){throw\"can't find nthList object\"}if(f!==undefined){if(d.substr(a,2)!=f){throw\"checking tag doesn't match: \"+d.substr(a,2)+\"!=\"+f}}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a===undefined){throw\"can't find nthList object\"}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join(\"0\")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+\".\"+j.join(\".\")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+\"..(total \"+A.length/2+\"bytes)..\"+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=\"\"}var x=c.ommit_long_octet;if(e.substr(l,2)==\"01\"){var h=j(e,l);if(h==\"00\"){return g+\"BOOLEAN FALSE\\n\"}else{return g+\"BOOLEAN TRUE\\n\"}}if(e.substr(l,2)==\"02\"){var h=j(e,l);return g+\"INTEGER \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"03\"){var h=j(e,l);return g+\"BITSTRING \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"04\"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+\"OCTETSTRING, encapsulates\\n\";k=k+y(h,c,0,g+\" \");return k}else{return g+\"OCTETSTRING \"+q(h,x)+\"\\n\"}}if(e.substr(l,2)==\"05\"){return g+\"NULL\\n\"}if(e.substr(l,2)==\"06\"){var m=j(e,l);var a=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(a);var b=a.replace(/\\./g,\" \");if(o!=\"\"){return g+\"ObjectIdentifier \"+o+\" (\"+b+\")\\n\"}else{return g+\"ObjectIdentifier (\"+b+\")\\n\"}}if(e.substr(l,2)==\"0c\"){return g+\"UTF8String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"13\"){return g+\"PrintableString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"14\"){return g+\"TeletexString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"16\"){return g+\"IA5String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"17\"){return g+\"UTCTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"18\"){return g+\"GeneralizedTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"30\"){if(e.substr(l,4)==\"3000\"){return g+\"SEQUENCE {}\\n\"}var k=g+\"SEQUENCE\\n\";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)==\"06\"&&e.substr(d[d.length-1],2)==\"04\"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u0){var m=new f({array:this.extensionsArray});var k=new c({explicit:true,tag:\"a3\",obj:m});this.asn1Array.push(k)}var n=new f({array:this.asn1Array});this.hTLV=n.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension=function(d){KJUR.asn1.x509.Extension.superclass.constructor.call(this);var f=null,a=KJUR,e=a.asn1,h=e.DERObjectIdentifier,i=e.DEROctetString,b=e.DERBitString,g=e.DERBoolean,c=e.DERSequence;this.getEncodedHex=function(){var m=new h({oid:this.oid});var l=new i({hex:this.getExtnValueHex()});var k=new Array();k.push(m);if(this.critical){k.push(new g())}k.push(l);var j=new c({array:k});return j.getEncodedHex()};this.critical=false;if(d!==undefined){if(d.critical!==undefined){this.critical=d.critical}}};YAHOO.lang.extend(KJUR.asn1.x509.Extension,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension.appendByNameToArray=function(e,c,b){var g=e.toLowerCase(),f=KJUR.asn1.x509;if(g==\"basicconstraints\"){var d=new f.BasicConstraints(c);b.push(d)}else{if(g==\"keyusage\"){var d=new f.KeyUsage(c);b.push(d)}else{if(g==\"crldistributionpoints\"){var d=new f.CRLDistributionPoints(c);b.push(d)}else{if(g==\"extkeyusage\"){var d=new f.ExtKeyUsage(c);b.push(d)}else{if(g==\"authoritykeyidentifier\"){var d=new f.AuthorityKeyIdentifier(c);b.push(d)}else{if(g==\"authorityinfoaccess\"){var d=new f.AuthorityInfoAccess(c);b.push(d)}else{if(g==\"subjectaltname\"){var d=new f.SubjectAltName(c);b.push(d)}else{if(g==\"issueraltname\"){var d=new f.IssuerAltName(c);b.push(d)}else{throw\"unsupported extension name: \"+e}}}}}}}}};KJUR.asn1.x509.KeyUsage=function(f){KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this,f);var a=X509.KEYUSAGE_NAME;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.15\";if(f!==undefined){if(f.bin!==undefined){this.asn1ExtnValue=new KJUR.asn1.DERBitString(f)}if(f.names!==undefined&&f.names.length!==undefined){var e=f.names;var d=\"000000000\";for(var c=0;c-1){e.push(new KJUR.asn1.DERInteger({\"int\":this.pathLen}))}var d=new KJUR.asn1.DERSequence({array:e});this.asn1ExtnValue=d;return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.19\";this.cA=false;this.pathLen=-1;if(c!==undefined){if(c.cA!==undefined){this.cA=c.cA}if(c.pathLen!==undefined){this.pathLen=c.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){this.asn1ExtnValue=new a.DERSequence({array:e})};this.setByOneURI=function(h){var e=new c.GeneralNames([{uri:h}]);var g=new c.DistributionPointName(e);var f=new c.DistributionPoint({dpobj:g});this.setByDPArray([f])};this.oid=\"2.5.29.31\";if(d!==undefined){if(d.array!==undefined){this.setByDPArray(d.array)}else{if(d.uri!==undefined){this.setByOneURI(d.uri)}}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLDistributionPoints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.ExtKeyUsage=function(c){KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,c);var b=KJUR,a=b.asn1;this.setPurposeArray=function(d){this.asn1ExtnValue=new a.DERSequence();for(var e=0;e0){var h=new b({array:this.aRevokedCert});this.asn1Array.push(h)}var i=new b({array:this.asn1Array});this.hTLV=i.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize=function(){this.asn1Version=null;this.asn1SignatureAlg=null;this.asn1Issuer=null;this.asn1ThisUpdate=null;this.asn1NextUpdate=null;this.aRevokedCert=new Array()};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertList,KJUR.asn1.ASN1Object);KJUR.asn1.x509.CRLEntry=function(e){KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);var d=null,c=null,b=KJUR,a=b.asn1;this.setCertSerial=function(f){this.sn=new a.DERInteger(f)};this.setRevocationDate=function(f){this.time=new a.x509.Time(f)};this.getEncodedHex=function(){var f=new a.DERSequence({array:[this.sn,this.time]});this.TLV=f.getEncodedHex();return this.TLV};if(e!==undefined){if(e.time!==undefined){this.setRevocationDate(e.time)}if(e.sn!==undefined){this.setCertSerial(e.sn)}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLEntry,KJUR.asn1.ASN1Object);KJUR.asn1.x509.X500Name=function(f){KJUR.asn1.x509.X500Name.superclass.constructor.call(this);this.asn1Array=new Array();var d=KJUR,c=d.asn1,e=c.x509,b=pemtohex;this.setByString=function(g){var k=g.split(\"/\");k.shift();var j=[];for(var l=0;l0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+\",\"+h).replace(/\\\\,/g,\",\");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)===\"\\\\\"){e=true}}b=b.map(function(a){return a.replace(\"/\",\"\\\\/\")});b.reverse();return\"/\"+b.join(\"/\")};KJUR.asn1.x509.RDN=function(a){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=new Array();this.addByString=function(b){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:b}))};this.addByMultiValuedString=function(d){var b=KJUR.asn1.x509.RDN.parseString(d);for(var c=0;c0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+\"+\"+k).replace(/\\\\\\+/g,\"+\");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)===\"\\\\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/\"$/)){var d=(e+\"+\"+k).replace(/^([^=]+)=\"(.*)\"$/,\"$1=$2\");b.push(d);l=false}else{b.push(e+\"+\"+k)}}else{b.push(k)}if(k.match(/^[^=]+=\"/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(d){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var f=null,e=null,a=\"utf8\",c=KJUR,b=c.asn1;this.setByString=function(h){var g=h.match(/^([^=]+)=(.+)$/);if(g){this.setByAttrTypeAndValueStr(g[1],g[2])}else{throw\"malformed attrTypeAndValueStr: \"+h}};this.setByAttrTypeAndValueStr=function(i,h){this.typeObj=KJUR.asn1.x509.OID.atype2obj(i);var g=a;if(i==\"C\"){g=\"prn\"}this.valueObj=this.getValueObj(g,h)};this.getValueObj=function(h,g){if(h==\"utf8\"){return new b.DERUTF8String({str:g})}if(h==\"prn\"){return new b.DERPrintableString({str:g})}if(h==\"tel\"){return new b.DERTeletexString({str:g})}if(h==\"ia5\"){return new b.DERIA5String({str:g})}throw\"unsupported directory string type: type=\"+h+\" value=\"+g};this.getEncodedHex=function(){var g=new b.DERSequence({array:[this.typeObj,this.valueObj]});this.TLV=g.getEncodedHex();return this.TLV};if(d!==undefined){if(d.str!==undefined){this.setByString(d.str)}}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw\"algId and/or subjPubKey not set\"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{\"int\":{bigint:q.n}},{\"int\":{\"int\":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:\"rsaEncryption\"});this.asn1SubjPKey=new b({hex:\"00\"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:\"ecPublicKey\",asn1params:r});this.asn1SubjPKey=new b({hex:\"00\"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{\"int\":{bigint:q.p}},{\"int\":{bigint:q.q}},{\"int\":{bigint:q.g}}]});this.asn1AlgId=new o({name:\"dsa\",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:\"00\"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type==\"utc\"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type==\"utc\"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type=\"utc\";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type=\"utc\"}if(f.str.match(/^[0-9]{14}Z$/)){this.type=\"gen\"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(d){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw\"algorithm not specified\"}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var e=[this.asn1Alg];if(this.asn1Params!==null){e.push(this.asn1Params)}var f=new a.DERSequence({array:e});this.hTLV=f.getEncodedHex();return this.hTLV};if(d!==undefined){if(d.name!==undefined){this.nameAlg=d.name}if(d.asn1params!==undefined){this.asn1Params=d.asn1params}if(d.paramempty!==undefined){this.paramEmpty=d.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){var c=this.nameAlg.toLowerCase();if(c.substr(-7,7)!==\"withdsa\"&&c.substr(-9,9)!==\"withecdsa\"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:\"81\",dns:\"82\",dn:\"a4\",uri:\"86\",ip:\"87\"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type=\"rfc822\";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type=\"dns\";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type=\"uri\";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({str:p.dn})}if(p.ldapdn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certissuer param not cert\"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certsubj param not cert\"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type=\"ip\";this.explicit=false;var q=p.ip;var s;var n=\"malformed IP address\";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex(\"[\"+q.split(\".\").join(\",\")+\"]\");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw\"unsupported type in params=\"+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){r=new b({obj:this.dUnsignedAttrs,tag:\"a1\",explicit:false})}var q=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,o,this.dSigAlg,this.dSig,];if(r!=null){q.push(r)}var p=new h.DERSequence({array:q});this.hTLV=p.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.SignerInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.EncapsulatedContentInfo=function(g){var c=KJUR,b=c.asn1,e=b.DERTaggedObject,a=b.DERSequence,h=b.DERObjectIdentifier,d=b.DEROctetString,f=b.cms;f.EncapsulatedContentInfo.superclass.constructor.call(this);this.dEContentType=new h({name:\"data\"});this.dEContent=null;this.isDetached=false;this.eContentValueHex=null;this.setContentType=function(i){if(i.match(/^[0-2][.][0-9.]+$/)){this.dEContentType=new h({oid:i})}else{this.dEContentType=new h({name:i})}};this.setContentValue=function(i){if(i!==undefined){if(typeof i.hex==\"string\"){this.eContentValueHex=i.hex}else{if(typeof i.str==\"string\"){this.eContentValueHex=utf8tohex(i.str)}}}};this.setContentValueHex=function(i){this.eContentValueHex=i};this.setContentValueStr=function(i){this.eContentValueHex=utf8tohex(i)};this.getEncodedHex=function(){if(typeof this.eContentValueHex!=\"string\"){throw\"eContentValue not yet set\"}var k=new d({hex:this.eContentValueHex});this.dEContent=new e({obj:k,tag:\"a0\",explicit:true});var i=[this.dEContentType];if(!this.isDetached){i.push(this.dEContent)}var j=new a({array:i});this.hTLV=j.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.EncapsulatedContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.ContentInfo=function(f){var c=KJUR,b=c.asn1,d=b.DERTaggedObject,a=b.DERSequence,e=b.x509;KJUR.asn1.cms.ContentInfo.superclass.constructor.call(this);this.dContentType=null;this.dContent=null;this.setContentType=function(g){if(typeof g==\"string\"){this.dContentType=e.OID.name2obj(g)}};this.getEncodedHex=function(){var h=new d({obj:this.dContent,tag:\"a0\",explicit:true});var g=new a({array:[this.dContentType,h]});this.hTLV=g.getEncodedHex();return this.hTLV};if(f!==undefined){if(f.type){this.setContentType(f.type)}if(f.obj&&f.obj instanceof b.ASN1Object){this.dContent=f.obj}}};YAHOO.lang.extend(KJUR.asn1.cms.ContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.SignedData=function(e){var a=KJUR,h=a.asn1,j=h.ASN1Object,g=h.DERInteger,m=h.DERSet,f=h.DERSequence,b=h.DERTaggedObject,l=h.cms,i=l.EncapsulatedContentInfo,d=l.SignerInfo,n=l.ContentInfo,c=h.x509,k=c.AlgorithmIdentifier;KJUR.asn1.cms.SignedData.superclass.constructor.call(this);this.dCMSVersion=new g({\"int\":1});this.dDigestAlgs=null;this.digestAlgNameList=[];this.dEncapContentInfo=new i();this.dCerts=null;this.certificateList=[];this.crlList=[];this.signerInfoList=[new d()];this.addCertificatesByPEM=function(p){var q=pemtohex(p);var r=new j();r.hTLV=q;this.certificateList.push(r)};this.getEncodedHex=function(){if(typeof this.hTLV==\"string\"){return this.hTLV}if(this.dDigestAlgs==null){var u=[];for(var t=0;t0){var v=new m({array:this.certificateList});this.dCerts=new b({obj:v,tag:\"a0\",explicit:false})}}if(this.dCerts!=null){p.push(this.dCerts)}var r=new m({array:this.signerInfoList});p.push(r);var q=new f({array:p});this.hTLV=q.getEncodedHex();return this.hTLV};this.getContentInfo=function(){this.getEncodedHex();var o=new n({type:\"signed-data\",obj:this});return o};this.getContentInfoEncodedHex=function(){var o=this.getContentInfo();var p=o.getEncodedHex();return p};this.getPEM=function(){return hextopem(this.getContentInfoEncodedHex(),\"CMS\")}};YAHOO.lang.extend(KJUR.asn1.cms.SignedData,KJUR.asn1.ASN1Object);KJUR.asn1.cms.CMSUtil=new function(){};KJUR.asn1.cms.CMSUtil.newSignedData=function(d){var b=KJUR,j=b.asn1,q=j.cms,f=q.SignerInfo,n=q.SignedData,o=q.SigningTime,a=q.SigningCertificate,p=q.SigningCertificateV2,c=j.cades,e=c.SignaturePolicyIdentifier;var m=new n();m.dEncapContentInfo.setContentValue(d.content);if(typeof d.certs==\"object\"){for(var h=0;h0){var s=new f({array:this.extensionsArray});var r=new m({array:[s]});var q=new f({array:[new k({oid:\"1.2.840.113549.1.9.14\"}),r]});var p=new c({explicit:true,tag:\"a0\",obj:q});this.asn1Array.push(p)}else{var p=new c({explicit:false,tag:\"a0\",obj:new j()});this.asn1Array.push(p)}var t=new f({array:this.asn1Array});this.hTLV=t.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CSRUtil=new function(){};KJUR.asn1.csr.CSRUtil.newCSRPEM=function(h){var c=KEYUTIL,b=KJUR.asn1.csr;if(h.subject===undefined){throw\"parameter subject undefined\"}if(h.sbjpubkey===undefined){throw\"parameter sbjpubkey undefined\"}if(h.sigalg===undefined){throw\"parameter sigalg undefined\"}if(h.sbjprvkey===undefined){throw\"parameter sbjpubkey undefined\"}var d=new b.CertificationRequestInfo();d.setSubjectByParam(h.subject);d.setSubjectPublicKeyByGetKey(h.sbjpubkey);if(h.ext!==undefined&&h.ext.length!==undefined){for(var e=0;ef.length){f=c[d]}}e=e.replace(f,\"::\");return e.slice(1,-1)}function hextoip(b){var d=\"malformed hex value\";if(!b.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){throw d}if(b.length==8){var c;try{c=parseInt(b.substr(0,2),16)+\".\"+parseInt(b.substr(2,2),16)+\".\"+parseInt(b.substr(4,2),16)+\".\"+parseInt(b.substr(6,2),16);return c}catch(a){throw d}}else{if(b.length==32){return hextoipv6(b)}else{return b}}}function iptohex(f){var j=\"malformed IP address\";f=f.toLowerCase(f);if(f.match(/^[0-9.]+$/)){var b=f.split(\".\");if(b.length!==4){throw j}var g=\"\";try{for(var e=0;e<4;e++){var h=parseInt(b[e]);g+=(\"0\"+h.toString(16)).slice(-2)}return g}catch(c){throw j}}else{if(f.match(/^[0-9a-f:]+$/)&&f.indexOf(\":\")!==-1){return ipv6tohex(f)}else{throw j}}}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b=\"\";for(var c=0;c\"7\"){return\"00\"+a}return a}function intarystrtohex(b){b=b.replace(/^\\s*\\[\\s*/,\"\");b=b.replace(/\\s*\\]\\s*$/,\"\");b=b.replace(/\\s*/g,\"\");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;bd){throw\"key is too short for SigAlg: keylen=\"+j+\",\"+a}var b=\"0001\";var k=\"00\"+c;var g=\"\";var l=d-b.length-k.length;for(var f=0;f=0;--p){q=q.twice2D();q.z=BigInteger.ONE;if(o.testBit(p)){if(n.testBit(p)){q=q.add2D(t)}else{q=q.add2D(s)}}else{if(n.testBit(p)){q=q.add2D(r)}}}return q}this.getBigRandom=function(i){return new BigInteger(i.bitLength(),a).mod(i.subtract(BigInteger.ONE)).add(BigInteger.ONE)};this.setNamedCurve=function(i){this.ecparams=KJUR.crypto.ECParameterDB.getByName(i);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=i};this.setPrivateKeyHex=function(i){this.isPrivate=true;this.prvKeyHex=i};this.setPublicKeyHex=function(i){this.isPublic=true;this.pubKeyHex=i};this.getPublicKeyXYHex=function(){var k=this.pubKeyHex;if(k.substr(0,2)!==\"04\"){throw\"this method supports uncompressed format(04) only\"}var j=this.ecparams.keylen/4;if(k.length!==2+j*2){throw\"malformed public key hex length\"}var i={};i.x=k.substr(2,j);i.y=k.substr(2+j);return i};this.getShortNISTPCurveName=function(){var i=this.curveName;if(i===\"secp256r1\"||i===\"NIST P-256\"||i===\"P-256\"||i===\"prime256v1\"){return\"P-256\"}if(i===\"secp384r1\"||i===\"NIST P-384\"||i===\"P-384\"){return\"P-384\"}return null};this.generateKeyPairHex=function(){var k=this.ecparams.n;var n=this.getBigRandom(k);var l=this.ecparams.G.multiply(n);var q=l.getX().toBigInteger();var o=l.getY().toBigInteger();var i=this.ecparams.keylen/4;var m=(\"0000000000\"+n.toString(16)).slice(-i);var r=(\"0000000000\"+q.toString(16)).slice(-i);var p=(\"0000000000\"+o.toString(16)).slice(-i);var j=\"04\"+r+p;this.setPrivateKeyHex(m);this.setPublicKeyHex(j);return{ecprvhex:m,ecpubhex:j}};this.signWithMessageHash=function(i){return this.signHex(i,this.prvKeyHex)};this.signHex=function(o,j){var t=new BigInteger(j,16);var l=this.ecparams.n;var q=new BigInteger(o,16);do{var m=this.getBigRandom(l);var u=this.ecparams.G;var p=u.multiply(m);var i=p.getX().toBigInteger().mod(l)}while(i.compareTo(BigInteger.ZERO)<=0);var v=m.modInverse(l).multiply(q.add(t.multiply(i))).mod(l);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(i,v)};this.sign=function(m,u){var q=u;var j=this.ecparams.n;var p=BigInteger.fromByteArrayUnsigned(m);do{var l=this.getBigRandom(j);var t=this.ecparams.G;var o=t.multiply(l);var i=o.getX().toBigInteger().mod(j)}while(i.compareTo(BigInteger.ZERO)<=0);var v=l.modInverse(j).multiply(p.add(q.multiply(i))).mod(j);return this.serializeSig(i,v)};this.verifyWithMessageHash=function(j,i){return this.verifyHex(j,i,this.pubKeyHex)};this.verifyHex=function(m,i,p){var l,j;var o=KJUR.crypto.ECDSA.parseSigHex(i);l=o.r;j=o.s;var k;k=ECPointFp.decodeFromHex(this.ecparams.curve,p);var n=new BigInteger(m,16);return this.verifyRaw(n,l,j,k)};this.verify=function(o,p,j){var l,i;if(Bitcoin.Util.isArray(p)){var n=this.parseSig(p);l=n.r;i=n.s}else{if(\"object\"===typeof p&&p.r&&p.s){l=p.r;i=p.s}else{throw\"Invalid value for signature\"}}var k;if(j instanceof ECPointFp){k=j}else{if(Bitcoin.Util.isArray(j)){k=ECPointFp.decodeFrom(this.ecparams.curve,j)}else{throw\"Invalid format for pubkey value, must be byte array or ECPointFp\"}}var m=BigInteger.fromByteArrayUnsigned(o);return this.verifyRaw(m,l,i,k)};this.verifyRaw=function(o,i,w,m){var l=this.ecparams.n;var u=this.ecparams.G;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(l)>=0){return false}if(w.compareTo(BigInteger.ONE)<0||w.compareTo(l)>=0){return false}var p=w.modInverse(l);var k=o.multiply(p).mod(l);var j=i.multiply(p).mod(l);var q=u.multiply(k).add(m.multiply(j));var t=q.getX().toBigInteger().mod(l);return t.equals(i)};this.serializeSig=function(k,j){var l=k.toByteArraySigned();var i=j.toByteArraySigned();var m=[];m.push(2);m.push(l.length);m=m.concat(l);m.push(2);m.push(i.length);m=m.concat(i);m.unshift(m.length);m.unshift(48);return m};this.parseSig=function(n){var m;if(n[0]!=48){throw new Error(\"Signature not a valid DERSequence\")}m=2;if(n[m]!=2){throw new Error(\"First element in signature must be a DERInteger\")}var l=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];if(n[m]!=2){throw new Error(\"Second element in signature must be a DERInteger\")}var i=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];var k=BigInteger.fromByteArrayUnsigned(l);var j=BigInteger.fromByteArrayUnsigned(i);return{r:k,s:j}};this.parseSigCompact=function(m){if(m.length!==65){throw\"Signature has the wrong length\"}var j=m[0]-27;if(j<0||j>7){throw\"Invalid signature type\"}var o=this.ecparams.n;var l=BigInteger.fromByteArrayUnsigned(m.slice(1,33)).mod(o);var k=BigInteger.fromByteArrayUnsigned(m.slice(33,65)).mod(o);return{r:l,s:k,i:j}};this.readPKCS5PrvKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var i,k,o;try{i=p(l,0,[2,0],\"06\");k=p(l,0,[1],\"04\");try{o=p(l,0,[3,0],\"03\").substr(2)}catch(j){}}catch(j){throw\"malformed PKCS#1/5 plain ECC private key\"}this.curveName=m(i);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o);this.setPrivateKeyHex(k);this.isPublic=false};this.readPKCS8PrvKeyHex=function(l){var q=ASN1HEX;var i=KJUR.crypto.ECDSA.getName;var n=q.getVbyList;if(q.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var j,p,m,k;try{j=n(l,0,[1,0],\"06\");p=n(l,0,[1,1],\"06\");m=n(l,0,[2,0,1],\"04\");try{k=n(l,0,[2,0,2,0],\"03\").substr(2)}catch(o){}}catch(o){throw\"malformed PKCS#8 plain ECC private key\"}this.curveName=i(p);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(k);this.setPrivateKeyHex(m);this.isPublic=false};this.readPKCS8PubKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var k,i,o;try{k=p(l,0,[0,0],\"06\");i=p(l,0,[0,1],\"06\");o=p(l,0,[1],\"03\").substr(2)}catch(j){throw\"malformed PKCS#8 ECC public key\"}this.curveName=m(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o)};this.readCertPubKeyHex=function(k,p){if(p!==5){p=6}var m=ASN1HEX;var l=KJUR.crypto.ECDSA.getName;var o=m.getVbyList;if(m.isASN1HEX(k)===false){throw\"not ASN.1 hex string\"}var i,n;try{i=o(k,0,[0,p,0,1],\"06\");n=o(k,0,[0,p,1],\"03\").substr(2)}catch(j){throw\"malformed X.509 certificate ECC public key\"}this.curveName=l(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(n)};if(h!==undefined){if(h.curve!==undefined){this.curveName=h.curve}}if(this.curveName===undefined){this.curveName=e}this.setNamedCurve(this.curveName);if(h!==undefined){if(h.prv!==undefined){this.setPrivateKeyHex(h.prv)}if(h.pub!==undefined){this.setPublicKeyHex(h.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX;var i=j.getChildIdx;var g=j.getV;if(f.substr(0,2)!=\"30\"){throw\"signature is not a ASN.1 sequence\"}var h=i(f,0);if(h.length!=2){throw\"number of signature ASN.1 sequence elements seem wrong\"}var e=h[0];var d=h[1];if(f.substr(e,2)!=\"02\"){throw\"1st item of sequene of signature is not ASN.1 integer\"}if(f.substr(d,2)!=\"02\"){throw\"2nd item of sequene of signature is not ASN.1 integer\"}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(c){var d=KJUR.crypto.ECDSA.parseSigHexInHexRS(c);var b=d.r;var a=d.s;if(b.substr(0,2)==\"00\"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)==\"00\"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b=\"00\"+b}if((a.length%32)==30){a=\"00\"+a}if(b.length%32!=0){throw\"unknown ECDSA sig r length error\"}if(a.length%32!=0){throw\"unknown ECDSA sig s length error\"}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if((((a.length/2)*8)%(16*8))!=0){throw\"unknown ECDSA concatinated r-s sig length error\"}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.getEncodedHex()};KJUR.crypto.ECDSA.getName=function(a){if(a===\"2a8648ce3d030107\"){return\"secp256r1\"}if(a===\"2b8104000a\"){return\"secp256k1\"}if(a===\"2b81040022\"){return\"secp384r1\"}if(\"|secp256r1|NIST P-256|P-256|prime256v1|\".indexOf(a)!==-1){return\"secp256r1\"}if(\"|secp256k1|\".indexOf(a)!==-1){return\"secp256k1\"}if(\"|secp384r1|NIST P-384|P-384|\".indexOf(a)!==-1){return\"secp384r1\"}return null};\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.crypto==\"undefined\"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!=\"undefined\"){d=c[e]}if(typeof b[d]!=\"undefined\"){return b[d]}throw\"unregistered EC curve name: \"+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex(\"04\"+f+k);b[A][\"name\"]=A;b[A][\"keylen\"]=l;b[A][\"curve\"]=r;b[A][\"G\"]=q;b[A][\"n\"]=t;b[A][\"h\"]=w;b[A][\"oid\"]=d;b[A][\"info\"]=x;for(var v=0;v1){g=new BigInteger(i,16)}else{g=null}h=new BigInteger(j,16);this.setPrivate(c,a,e,g,h)};this.setPublic=function(c,b,a,d){this.isPublic=true;this.p=c;this.q=b;this.g=a;this.y=d;this.x=null};this.setPublicHex=function(f,e,d,g){var b,a,h,c;b=new BigInteger(f,16);a=new BigInteger(e,16);h=new BigInteger(d,16);c=new BigInteger(g,16);this.setPublic(b,a,h,c)};this.signWithMessageHash=function(d){var c=this.p;var b=this.q;var f=this.g;var i=this.y;var j=this.x;var e=KJUR.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),b.subtract(BigInteger.ONE));var l=d.substr(0,b.bitLength()/4);var h=new BigInteger(l,16);var a=(f.modPow(e,c)).mod(b);var n=(e.modInverse(b).multiply(h.add(j.multiply(a)))).mod(b);var m=KJUR.asn1.ASN1Util.jsonToASN1HEX({seq:[{\"int\":{bigint:a}},{\"int\":{bigint:n}}]});return m};this.verifyWithMessageHash=function(h,f){var d=this.p;var b=this.q;var j=this.g;var l=this.y;var i=this.parseASN1Signature(f);var a=i[0];var t=i[1];var o=h.substr(0,b.bitLength()/4);var k=new BigInteger(o,16);if(BigInteger.ZERO.compareTo(a)>0||a.compareTo(b)>0){throw\"invalid DSA signature\"}if(BigInteger.ZERO.compareTo(t)>=0||t.compareTo(b)>0){throw\"invalid DSA signature\"}var m=t.modInverse(b);var e=k.multiply(m).mod(b);var c=a.multiply(m).mod(b);var n=j.modPow(e,d).multiply(l.modPow(c,d)).mod(d).mod(b);return n.compareTo(a)==0};this.parseASN1Signature=function(a){try{var d=new BigInteger(ASN1HEX.getVbyList(a,0,[0],\"02\"),16);var c=new BigInteger(ASN1HEX.getVbyList(a,0,[1],\"02\"),16);return[d,c]}catch(b){throw\"malformed ASN.1 DSA signature\"}};this.readPKCS5PrvKeyHex=function(c){var b,a,f,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[1],\"02\");a=d(c,0,[2],\"02\");f=d(c,0,[3],\"02\");g=d(c,0,[4],\"02\");i=d(c,0,[5],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed PKCS#1/5 plain DSA private key\"}this.setPrivateHex(b,a,f,g,i)};this.readPKCS8PrvKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[1,1,0],\"02\");c=i(d,0,[1,1,1],\"02\");b=i(d,0,[1,1,2],\"02\");g=i(d,0,[2,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 plain DSA private key\"}this.setPrivateHex(f,c,b,null,g)};this.readPKCS8PubKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[0,1,0],\"02\");c=i(d,0,[0,1,1],\"02\");b=i(d,0,[0,1,2],\"02\");g=i(d,0,[1,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 DSA public key\"}this.setPublicHex(f,c,b,g)};this.readCertPubKeyHex=function(c,f){if(f!==5){f=6}var b,a,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[0,f,0,1,0],\"02\");a=d(c,0,[0,f,0,1,1],\"02\");g=d(c,0,[0,f,0,1,2],\"02\");i=d(c,0,[0,f,1,0],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed X.509 certificate DSA public key\"}this.setPublicHex(b,a,g,i)}};\nvar KEYUTIL=function(){var d=function(p,r,q){return k(CryptoJS.AES,p,r,q)};var e=function(p,r,q){return k(CryptoJS.TripleDES,p,r,q)};var a=function(p,r,q){return k(CryptoJS.DES,p,r,q)};var k=function(s,x,u,q){var r=CryptoJS.enc.Hex.parse(x);var w=CryptoJS.enc.Hex.parse(u);var p=CryptoJS.enc.Hex.parse(q);var t={};t.key=w;t.iv=p;t.ciphertext=r;var v=s.decrypt(t,w,{iv:p});return CryptoJS.enc.Hex.stringify(v)};var l=function(p,r,q){return g(CryptoJS.AES,p,r,q)};var o=function(p,r,q){return g(CryptoJS.TripleDES,p,r,q)};var f=function(p,r,q){return g(CryptoJS.DES,p,r,q)};var g=function(t,y,v,q){var s=CryptoJS.enc.Hex.parse(y);var x=CryptoJS.enc.Hex.parse(v);var p=CryptoJS.enc.Hex.parse(q);var w=t.encrypt(s,x,{iv:p});var r=CryptoJS.enc.Hex.parse(w.toString());var u=CryptoJS.enc.Base64.stringify(r);return u};var i={\"AES-256-CBC\":{proc:d,eproc:l,keylen:32,ivlen:16},\"AES-192-CBC\":{proc:d,eproc:l,keylen:24,ivlen:16},\"AES-128-CBC\":{proc:d,eproc:l,keylen:16,ivlen:16},\"DES-EDE3-CBC\":{proc:e,eproc:o,keylen:24,ivlen:8},\"DES-CBC\":{proc:a,eproc:f,keylen:8,ivlen:8}};var c=function(p){return i[p][\"proc\"]};var m=function(p){var r=CryptoJS.lib.WordArray.random(p);var q=CryptoJS.enc.Hex.stringify(r);return q};var n=function(v){var w={};var q=v.match(new RegExp(\"DEK-Info: ([^,]+),([0-9A-Fa-f]+)\",\"m\"));if(q){w.cipher=q[1];w.ivsalt=q[2]}var p=v.match(new RegExp(\"-----BEGIN ([A-Z]+) PRIVATE KEY-----\"));if(p){w.type=p[1]}var u=-1;var x=0;if(v.indexOf(\"\\r\\n\\r\\n\")!=-1){u=v.indexOf(\"\\r\\n\\r\\n\");x=2}if(v.indexOf(\"\\n\\n\")!=-1){u=v.indexOf(\"\\n\\n\");x=1}var t=v.indexOf(\"-----END\");if(u!=-1&&t!=-1){var r=v.substring(u+x*2,t-x);r=r.replace(/\\s+/g,\"\");w.data=r}return w};var j=function(q,y,p){var v=p.substring(0,16);var t=CryptoJS.enc.Hex.parse(v);var r=CryptoJS.enc.Utf8.parse(y);var u=i[q][\"keylen\"]+i[q][\"ivlen\"];var x=\"\";var w=null;for(;;){var s=CryptoJS.algo.MD5.create();if(w!=null){s.update(w)}s.update(r);s.update(t);w=s.finalize();x=x+CryptoJS.enc.Hex.stringify(w);if(x.length>=u*2){break}}var z={};z.keyhex=x.substr(0,i[q][\"keylen\"]*2);z.ivhex=x.substr(i[q][\"keylen\"]*2,i[q][\"ivlen\"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v][\"proc\"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s][\"eproc\"];var t=r(p,q,u);return t};return{version:\"1.0.0\",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p=\"\";if(typeof t==\"undefined\"||t==null){t=\"AES-256-CBC\"}if(typeof i[t]==\"undefined\"){throw\"KEYUTIL unsupported algorithm: \"+t}if(typeof r==\"undefined\"||r==null){var v=i[t][\"ivlen\"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,\"$1\\r\\n\");var p=\"-----BEGIN \"+x+\" PRIVATE KEY-----\\r\\n\";p+=\"Proc-Type: 4,ENCRYPTED\\r\\n\";p+=\"DEK-Info: \"+t+\",\"+r+\"\\r\\n\";p+=\"\\r\\n\";p+=q;p+=\"\\r\\n-----END \"+x+\" PRIVATE KEY-----\\r\\n\";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw\"malformed format: SEQUENCE(0).items != 2: \"+r.length}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0).items != 2: \"+A.length}if(w(y,A[0])!=\"2a864886f70d01050d\"){throw\"this only supports pkcs5PBES2\"}var p=z(y,A[1]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0.1).items != 2: \"+p.length}var q=z(y,p[1]);if(q.length!=2){throw\"malformed format: SEQUENCE(0.0.1.1).items != 2: \"+q.length}if(w(y,q[0])!=\"2a864886f70d0307\"){throw\"this only supports TripleDES\"}t.encryptionSchemeAlg=\"TripleDES\";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw\"malformed format: SEQUENCE(0.0.1.0).items != 2: \"+s.length}if(w(y,s[0])!=\"2a864886f70d01050c\"){throw\"this only supports pkcs5PBKDF2\"}var x=z(y,s[1]);if(x.length<2){throw\"malformed format: SEQUENCE(0.0.1.0.1).items < 2: \"+x.length}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw\"malformed format pbkdf2Iter: \"+u}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,\"ENCRYPTED PRIVATE KEY\");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!=\"30\"){throw\"malformed plain PKCS8 private key(code:001)\"}var r=u(s,0);if(r.length!=3){throw\"malformed plain PKCS8 private key(code:002)\"}if(s.substr(r[1],2)!=\"30\"){throw\"malformed PKCS8 private key(code:003)\"}var p=u(s,r[1]);if(p.length!=2){throw\"malformed PKCS8 private key(code:004)\"}if(s.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 private key(code:005)\"}q.algoid=t(s,p[0]);if(s.substr(p[1],2)==\"06\"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!=\"04\"){throw\"malformed PKCS8 private key(code:006)\"}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,\"PRIVATE KEY\");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid==\"2a864886f70d010101\"){r=new RSAKey()}else{if(q.algoid==\"2a8648ce380401\"){r=new KJUR.crypto.DSA()}else{if(q.algoid==\"2a8648ce3d0201\"){r=new KJUR.crypto.ECDSA()}else{throw\"unsupported private key algorithm\"}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],\"06\");if(r===\"2a864886f70d010101\"){p=new RSAKey()}else{if(r===\"2a8648ce380401\"){p=new KJUR.crypto.DSA()}else{if(r===\"2a8648ce3d0201\"){p=new KJUR.crypto.ECDSA()}else{throw\"unsupported PKCS#8 public key hex\"}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!=\"30\"){throw\"malformed RSA key(code:001)\"}var q=t(r,0);if(q.length!=2){throw\"malformed RSA key(code:002)\"}if(r.substr(q[0],2)!=\"02\"){throw\"malformed RSA key(code:003)\"}p.n=s(r,q[0]);if(r.substr(q[1],2)!=\"02\"){throw\"malformed RSA key(code:004)\"}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw\"outer DERSequence shall have 2 elements: \"+r.length}var w=r[0];if(t.substr(w,2)!=\"30\"){throw\"malformed PKCS8 public key(code:001)\"}var p=u(t,w);if(p.length!=2){throw\"malformed PKCS8 public key(code:002)\"}if(t.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 public key(code:003)\"}q.algoid=s(t,p[0]);if(t.substr(p[1],2)==\"06\"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)==\"30\"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],\"02\");q.algparam.q=v.getVbyList(t,p[1],[1],\"02\");q.algparam.g=v.getVbyList(t,p[1],[2],\"02\")}}if(t.substr(r[1],2)!=\"03\"){throw\"malformed PKCS8 public key(code:004)\"}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!=\"undefined\"&&l instanceof w){return l}if(typeof i!=\"undefined\"&&l instanceof i){return l}if(typeof C!=\"undefined\"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;j.setPublicKeyHex(u);return j}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;var b=(\"0000000000\"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n===\"pkcs5prv\"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)===\"04\"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw\"unsupported PKCS#1/5 hexadecimal key\"}}}return P}if(n===\"pkcs8prv\"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n===\"pkcs8pub\"){return F._getKeyFromPublicPKCS8Hex(l)}if(n===\"x509pub\"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf(\"-END CERTIFICATE-\",0)!=-1||l.indexOf(\"-END X509 CERTIFICATE-\",0)!=-1||l.indexOf(\"-END TRUSTED CERTIFICATE-\",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf(\"-END PUBLIC KEY-\")!=-1){var O=pemtohex(l,\"PUBLIC KEY\");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var m=M(l,\"RSA PRIVATE KEY\");return F.getKey(m,null,\"pkcs5prv\")}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var I=M(l,\"DSA PRIVATE KEY\");var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END PRIVATE KEY-\")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf(\"-END EC PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],\"04\");var f=d(I,0,[2,0],\"06\");var A=d(I,0,[3,0],\"03\").substr(2);var e=\"\";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw\"undefined OID(hex) in KJUR.crypto.OID: \"+f}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END ENCRYPTED PRIVATE KEY-\")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw\"not supported argument\"};KEYUTIL.generateKeypair=function(a,c){if(a==\"RSA\"){var b=c;var h=new RSAKey();h.generate(b,\"10001\");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a==\"EC\"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw\"unknown algorithm: \"+a}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.n}},{\"int\":s.e},{\"int\":{bigint:s.d}},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.dmp1}},{\"int\":{bigint:s.dmq1}},{\"int\":{bigint:s.coeff}}]});return G}function B(G){var s=l({seq:[{\"int\":1},{octstr:{hex:G.prvKeyHex}},{tag:[\"a0\",true,{oid:{name:G.curveName}}]},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+G.pubKeyHex}}]}]});return s}function x(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.g}},{\"int\":{bigint:s.y}},{\"int\":{bigint:s.x}}]});return G}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D==\"PKCS8PUB\")){var E=new C(b);var w=E.getEncodedHex();return hextopem(w,\"PUBLIC KEY\")}if(D==\"PKCS1PRV\"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();return hextopem(w,\"RSA PRIVATE KEY\")}if(D==\"PKCS1PRV\"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.getEncodedHex();var h=B(b);var t=h.getEncodedHex();var p=\"\";p+=hextopem(v,\"EC PARAMETERS\");p+=hextopem(t,\"EC PRIVATE KEY\");return p}if(D==\"PKCS1PRV\"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();return hextopem(w,\"DSA PRIVATE KEY\")}if(D==\"PKCS5PRV\"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"RSA\",w,y,m,j)}if(D==\"PKCS5PRV\"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"EC\",w,y,m,j)}if(D==\"PKCS5PRV\"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"DSA\",w,y,m,j)}var o=function(G,s){var I=c(G,s);var H=new l({seq:[{seq:[{oid:{name:\"pkcs5PBES2\"}},{seq:[{seq:[{oid:{name:\"pkcs5PBKDF2\"}},{seq:[{octstr:{hex:I.pbkdf2Salt}},{\"int\":I.pbkdf2Iter}]}]},{seq:[{oid:{name:\"des-EDE3-CBC\"}},{octstr:{hex:I.encryptionSchemeIV}}]}]}]},{octstr:{hex:I.ciphertext}}]});return H.getEncodedHex()};var c=function(N,O){var H=100;var M=CryptoJS.lib.WordArray.random(8);var L=\"DES-EDE3-CBC\";var s=CryptoJS.lib.WordArray.random(8);var I=CryptoJS.PBKDF2(O,M,{keySize:192/32,iterations:H});var J=CryptoJS.enc.Hex.parse(N);var K=CryptoJS.TripleDES.encrypt(J,I,{iv:s})+\"\";var G={};G.ciphertext=K;G.pbkdf2Salt=CryptoJS.enc.Hex.stringify(M);G.pbkdf2Iter=H;G.encryptionSchemeAlg=L;G.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return G};if(D==\"PKCS8PRV\"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"rsaEncryption\"}},{\"null\":true}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var g=new l({seq:[{\"int\":1},{octstr:{hex:b.prvKeyHex}},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+b.pubKeyHex}}]}]});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"ecPublicKey\"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"dsa\"}},{seq:[{\"int\":{bigint:b.p}},{\"int\":{bigint:b.q}},{\"int\":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}throw\"unsupported object nor format\"};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,\"CERTIFICATE REQUEST\");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,\"pkcs8pub\");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!=\"30\"){throw\"malformed CSR(code:001)\"}var e=f(g,0);if(e.length<1){throw\"malformed CSR(code:002)\"}if(g.substr(e[0],2)!=\"30\"){throw\"malformed CSR(code:003)\"}var a=f(g,e[0]);if(a.length<3){throw\"malformed CSR(code:004)\"}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getJWKFromKey=function(d){var b={};if(d instanceof RSAKey&&d.isPrivate){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));b.d=hextob64u(d.d.toString(16));b.p=hextob64u(d.p.toString(16));b.q=hextob64u(d.q.toString(16));b.dp=hextob64u(d.dmp1.toString(16));b.dq=hextob64u(d.dmq1.toString(16));b.qi=hextob64u(d.coeff.toString(16));return b}else{if(d instanceof RSAKey&&d.isPublic){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPrivate){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);b.d=hextob64u(d.prvKeyHex);return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPublic){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);return b}}}}throw\"not supported key object\"};\nRSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,j,l,b,a,f,d,k;var m=ASN1HEX;var g=m.getVbyList;if(m.isASN1HEX(e)===false){throw\"not ASN.1 hex string\"}try{c=g(e,0,[2,0,1],\"02\");j=g(e,0,[2,0,2],\"02\");l=g(e,0,[2,0,3],\"02\");b=g(e,0,[2,0,4],\"02\");a=g(e,0,[2,0,5],\"02\");f=g(e,0,[2,0,6],\"02\");d=g(e,0,[2,0,7],\"02\");k=g(e,0,[2,0,8],\"02\")}catch(i){throw\"malformed PKCS#8 plain RSA private key\"}this.setPrivateEx(c,j,l,b,a,f,d,k)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw\"keyHex is not ASN.1 hex string\"}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!==\"02\"||c.substr(a[1],2)!==\"02\"){throw\"wrong hex for PKCS#5 public key\"}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw\"not ASN.1 hex string\"}if(c.getTLVbyList(b,0,[0,0])!==\"06092a864886f70d010101\"){throw\"not PKCS8 RSA public key\"}var a=c.getTLVbyList(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)};\nvar _RE_HEXDECONLY=new RegExp(\"\");_RE_HEXDECONLY.compile(\"[^0-9a-f]\",\"gi\");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c=\"\";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw\"invalid salt length\"}}}if(c<(g+k+2)){throw\"data too long\"}var f=\"\";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dthis.n.bitLength()){return 0}var i=this.doPublic(b);var e=i.toString(16).replace(/^1f+00/,\"\");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(k){return KJUR.crypto.Util.hashString(k,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){a=a.replace(_RE_HEXDECONLY,\"\");a=a.replace(/[ \\n]+/g,\"\");var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,\"\");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){var k=new BigInteger(s,16);if(k.bitLength()>this.n.bitLength()){return false}var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw\"invalid salt length\"}}}if(m<(h+c+2)){throw\"data too long\"}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw\"bits beyond keysize not zero\"}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q0){var b=\":\"+n.join(\":\")+\":\";if(b.indexOf(\":\"+k+\":\")==-1){throw\"algorithm '\"+k+\"' not accepted in the list\"}}if(k!=\"none\"&&B===null){throw\"key shall be specified to verify.\"}if(typeof B==\"string\"&&B.indexOf(\"-----BEGIN \")!=-1){B=KEYUTIL.getKey(B)}if(z==\"RS\"||z==\"PS\"){if(!(B instanceof m)){throw\"key shall be a RSAKey obj for RS* and PS* algs\"}}if(z==\"ES\"){if(!(B instanceof p)){throw\"key shall be a ECDSA obj for ES* algs\"}}if(k==\"none\"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw\"unsupported alg name: \"+k}else{u=t.jwsalg2sigalg[k]}if(u==\"none\"){throw\"not supported\"}else{if(u.substr(0,4)==\"Hmac\"){var o=null;if(B===undefined){throw\"hexadecimal key shall be specified for HMAC\"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf(\"withECDSA\")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(\".\");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw\"malformed sJWS: wrong number of '.' splitted elements\"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null,\" \");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null,\" \")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;var k=e.split(\".\");var c=k[0];var i=k[1];var q=c+\".\"+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw\"acceptField.alg shall be specified\"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss===\"object\"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub===\"object\"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud===\"object\"){if(typeof g.aud==\"string\"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud==\"object\"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt===\"number\"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!==\"number\"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp==\"number\"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw\"addSignature failed: \"+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw\"malformed header\"}if(typeof g.payload===\"string\"){this.sPayload=g.payload}else{throw\"malformed signatures\"}if(g.signatures.length>0){this.aSignatures=g.signatures}else{throw\"malformed signatures\"}}catch(e){throw\"malformed JWS-JS JSON object: \"+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}};\nexports.SecureRandom = SecureRandom;\nexports.rng_seed_time = rng_seed_time;\n\nexports.BigInteger = BigInteger;\nexports.RSAKey = RSAKey;\nexports.ECDSA = KJUR.crypto.ECDSA;\nexports.DSA = KJUR.crypto.DSA;\nexports.Signature = KJUR.crypto.Signature;\nexports.MessageDigest = KJUR.crypto.MessageDigest;\nexports.Mac = KJUR.crypto.Mac;\nexports.Cipher = KJUR.crypto.Cipher;\nexports.KEYUTIL = KEYUTIL;\nexports.ASN1HEX = ASN1HEX;\nexports.X509 = X509;\nexports.CryptoJS = CryptoJS;\n\n// ext/base64.js\nexports.b64tohex = b64tohex;\nexports.b64toBA = b64toBA;\n\n// base64x.js\nexports.stoBA = stoBA;\nexports.BAtos = BAtos;\nexports.BAtohex = BAtohex;\nexports.stohex = stohex;\nexports.stob64 = stob64;\nexports.stob64u = stob64u;\nexports.b64utos = b64utos;\nexports.b64tob64u = b64tob64u;\nexports.b64utob64 = b64utob64;\nexports.hex2b64 = hex2b64;\nexports.hextob64u = hextob64u;\nexports.b64utohex = b64utohex;\nexports.utf8tob64u = utf8tob64u;\nexports.b64utoutf8 = b64utoutf8;\nexports.utf8tob64 = utf8tob64;\nexports.b64toutf8 = b64toutf8;\nexports.utf8tohex = utf8tohex;\nexports.hextoutf8 = hextoutf8;\nexports.hextorstr = hextorstr;\nexports.rstrtohex = rstrtohex;\nexports.hextob64 = hextob64;\nexports.hextob64nl = hextob64nl;\nexports.b64nltohex = b64nltohex;\nexports.hextopem = hextopem;\nexports.pemtohex = pemtohex;\nexports.hextoArrayBuffer = hextoArrayBuffer;\nexports.ArrayBuffertohex = ArrayBuffertohex;\nexports.zulutomsec = zulutomsec;\nexports.zulutosec = zulutosec;\nexports.zulutodate = zulutodate;\nexports.datetozulu = datetozulu;\nexports.uricmptohex = uricmptohex;\nexports.hextouricmp = hextouricmp;\nexports.ipv6tohex = ipv6tohex;\nexports.hextoipv6 = hextoipv6;\nexports.hextoip = hextoip;\nexports.iptohex = iptohex;\nexports.encodeURIComponentAll = encodeURIComponentAll;\nexports.newline_toUnix = newline_toUnix;\nexports.newline_toDos = newline_toDos;\nexports.hextoposhex = hextoposhex;\nexports.intarystrtohex = intarystrtohex;\nexports.strdiffidx = strdiffidx;\n\n// name spaces\nexports.KJUR = KJUR;\nexports.crypto = KJUR.crypto;\nexports.asn1 = KJUR.asn1;\nexports.jws = KJUR.jws;\nexports.lang = KJUR.lang;\n\n\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://AppID/./node_modules/jsrsasign/lib/jsrsasign.js?"); + +/***/ }), + +/***/ "./node_modules/node-fetch/browser.js": +/*!********************************************!*\ + !*** ./node_modules/node-fetch/browser.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n// ref: https://github.com/tc39/proposal-global\nvar getGlobal = function () {\n\t// the only reliable means to get the global object is\n\t// `Function('return this')()`\n\t// However, this causes CSP violations in Chrome apps.\n\tif (typeof self !== 'undefined') { return self; }\n\tif (typeof window !== 'undefined') { return window; }\n\tif (typeof global !== 'undefined') { return global; }\n\tthrow new Error('unable to locate global object');\n}\n\nvar global = getGlobal();\n\nmodule.exports = exports = global.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = global.fetch.bind(global);\n\nexports.Headers = global.Headers;\nexports.Request = global.Request;\nexports.Response = global.Response;\n\n//# sourceURL=webpack://AppID/./node_modules/node-fetch/browser.js?"); + +/***/ }), + +/***/ "./node_modules/webpack/buildin/global.js": +/*!***********************************!*\ + !*** (webpack)/buildin/global.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://AppID/(webpack)/buildin/global.js?"); + +/***/ }), + +/***/ "./package.json": +/*!**********************!*\ + !*** ./package.json ***! + \**********************/ +/*! exports provided: name, version, description, scripts, repository, main, nyc, dependencies, devDependencies, default */ +/***/ (function(module) { + +eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"ibmcloud-appid-js\\\",\\\"version\\\":\\\"0.3.0\\\",\\\"description\\\":\\\"IBM Cloud App ID SDK for Single Page Applications\\\",\\\"scripts\\\":{\\\"build\\\":\\\"webpack --mode=development\\\",\\\"test\\\":\\\"mocha\\\",\\\"coverage\\\":\\\"nyc --reporter=lcov mocha\\\",\\\"docs\\\":\\\"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json\\\"},\\\"repository\\\":{\\\"type\\\":\\\"git\\\",\\\"url\\\":\\\"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git\\\"},\\\"main\\\":\\\"dist/appid.umd.min.js\\\",\\\"nyc\\\":{\\\"all\\\":true,\\\"include\\\":[\\\"src/*.js\\\"],\\\"exclude\\\":[\\\"**/PopupController.js\\\",\\\"**/IFrameController.js\\\",\\\"**/OpenIDConfigurationResource.js\\\",\\\"**/constants.js\\\"]},\\\"dependencies\\\":{\\\"jsrsasign\\\":\\\"^8.0.12\\\"},\\\"devDependencies\\\":{\\\"node-fetch\\\":\\\"^2.6.0\\\",\\\"@babel/cli\\\":\\\"^7.0.0\\\",\\\"@babel/core\\\":\\\"^7.5.5\\\",\\\"@babel/plugin-transform-runtime\\\":\\\"^7.5.5\\\",\\\"@babel/preset-env\\\":\\\"^7.5.5\\\",\\\"babel-cli\\\":\\\"^7.0.0-beta.3\\\",\\\"chai\\\":\\\"^4.2.0\\\",\\\"coveralls\\\":\\\"^3.0.6\\\",\\\"gulp-babel\\\":\\\"^8.0.0\\\",\\\"mocha\\\":\\\"^6.2.0\\\",\\\"nyc\\\":\\\"^14.1.1\\\",\\\"webpack\\\":\\\"^4.39.1\\\",\\\"webpack-cli\\\":\\\"^3.3.6\\\",\\\"docdash\\\":\\\"^1.1.1\\\",\\\"jsdoc\\\":\\\"^3.6.3\\\"}}\");\n\n//# sourceURL=webpack://AppID/./package.json?"); + +/***/ }), + +/***/ "./src/IFrameController.js": +/*!*********************************!*\ + !*** ./src/IFrameController.js ***! + \*********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const IFrameError = __webpack_require__(/*! ./errors/IFrameError */ \"./src/errors/IFrameError.js\");\n\nclass IFrameController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t}\n\n\topen(url) {\n\t\tthis.iFrame = this.window.document.createElement('iframe');\n\t\tthis.iFrame.src = url;\n\t\tthis.iFrame.width = 0;\n\t\tthis.iFrame.height = 0;\n\t\tthis.window.document.body.appendChild(this.iFrame);\n\t}\n\n\tremove() {\n\t\twindow.document.body.removeChild(this.iFrame);\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\treject(new IFrameError('Silent sign-in timed out'));\n\t\t\t}, 5 * 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tclearInterval(timer);\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = IFrameController;\n\n\n//# sourceURL=webpack://AppID/./src/IFrameController.js?"); + +/***/ }), + +/***/ "./src/OpenIDConfigurationResource.js": +/*!********************************************!*\ + !*** ./src/OpenIDConfigurationResource.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const packagejson = __webpack_require__(/*! ../package.json */ \"./package.json\");\n\nclass OpenIdConfigurationResource {\n\tasync init({discoveryEndpoint, requestHandler}){\n\t\tthis.openIdConfig = await requestHandler(discoveryEndpoint);\n\t\tconst headers = { 'x-filter-type': `spa:v${packagejson.version}` };\n\t\tthis.publicKeys = requestHandler(this.getJwksEndpoint(), { headers: headers });\n\t}\n\n\tgetAuthorizationEndpoint() {\n\t\treturn this.openIdConfig.authorization_endpoint;\n\t}\n\n\tgetUserInfoEndpoint() {\n\t\treturn this.openIdConfig.userinfo_endpoint;\n\t}\n\n\tgetJwksEndpoint() {\n\t\treturn this.openIdConfig.jwks_uri;\n\t}\n\n\tgetTokenEndpoint() {\n\t\treturn this.openIdConfig.token_endpoint;\n\t}\n\n\tgetIssuer() {\n\t\treturn this.openIdConfig.issuer;\n\t}\n\n\tasync getPublicKeys() {\n\t\treturn await this.publicKeys;\n\t}\n}\nmodule.exports = OpenIdConfigurationResource;\n\n\n\n//# sourceURL=webpack://AppID/./src/OpenIDConfigurationResource.js?"); + +/***/ }), + +/***/ "./src/PopupController.js": +/*!********************************!*\ + !*** ./src/PopupController.js ***! + \********************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const PopupError = __webpack_require__(/*! ./errors/PopupError */ \"./src/errors/PopupError.js\");\n\nclass PopupController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t};\n\n\tinit(popupConfig){\n\t\tthis.popupConfig = popupConfig;\n\t}\n\n\topen() {\n\t\tconst h = this.popupConfig.height;\n\t\tconst w = this.popupConfig.width;\n\t\tconst left = (window.screen.width - w) / 2;\n\t\tconst top = (window.screen.height - h) / 2;\n\t\tthis.popup = this.window.open('', 'popup', `left=${left},top=${top},width=${w},height=${h},resizable,scrollbars=yes,status=1`);\n\t\tif (!this.popup) {\n\t\t\tthrow new PopupError('Unable to open popup')\n\t\t}\n\t};\n\n\tnavigate(url) {\n\t\tthis.popup.location.href = url;\n\t};\n\n\tclose() {\n\t\tthis.popup.close();\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\tif(this.popup.closed) {\n\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\treject(new PopupError('Popup closed'));\n\t\t\t\t}\n\t\t\t}, 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = PopupController;\n\n\n//# sourceURL=webpack://AppID/./src/PopupController.js?"); + +/***/ }), + +/***/ "./src/RequestHandler.js": +/*!*******************************!*\ + !*** ./src/RequestHandler.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t}\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); + +/***/ }), + +/***/ "./src/TokenValidator.js": +/*!*******************************!*\ + !*** ./src/TokenValidator.js ***! + \*******************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg:[constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif (nonce && (!decoded.payloadObj.nonce || decoded.payloadObj.nonce !== nonce)) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor(let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); + +/***/ }), + +/***/ "./src/constants.js": +/*!**************************!*\ + !*** ./src/constants.js ***! + \**************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN: 'Invalid id token',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN: 'Missing id token string',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); + +/***/ }), + +/***/ "./src/errors/AppIDError.js": +/*!**********************************!*\ + !*** ./src/errors/AppIDError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class AppIDError extends Error {}\nmodule.exports = AppIDError;\n\n//# sourceURL=webpack://AppID/./src/errors/AppIDError.js?"); + +/***/ }), + +/***/ "./src/errors/IFrameError.js": +/*!***********************************!*\ + !*** ./src/errors/IFrameError.js ***! + \***********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class IFrameError extends Error {}\nmodule.exports = IFrameError;\n\n//# sourceURL=webpack://AppID/./src/errors/IFrameError.js?"); + +/***/ }), + +/***/ "./src/errors/OAuthError.js": +/*!**********************************!*\ + !*** ./src/errors/OAuthError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class OAuthError extends Error {\n\t// See https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for the possible error messages\n\tconstructor({error, description}) {\n\t\tsuper(description || error);\n\t\tthis.error = error;\n\t\tthis.description = description;\n\t}\n}\nmodule.exports = OAuthError;\n\n//# sourceURL=webpack://AppID/./src/errors/OAuthError.js?"); + +/***/ }), + +/***/ "./src/errors/PopupError.js": +/*!**********************************!*\ + !*** ./src/errors/PopupError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class PopupError extends Error {}\nmodule.exports = PopupError;\n\n//# sourceURL=webpack://AppID/./src/errors/PopupError.js?"); + +/***/ }), + +/***/ "./src/errors/RequestError.js": +/*!************************************!*\ + !*** ./src/errors/RequestError.js ***! + \************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class RequestError extends Error {\n\tconstructor(description, status, originError) {\n\t\tsuper(description);\n\t\tthis.status = status;\n\t\tthis.originError = originError;\n\t}\n}\nmodule.exports = RequestError;\n\n//# sourceURL=webpack://AppID/./src/errors/RequestError.js?"); + +/***/ }), + +/***/ "./src/errors/TokenError.js": +/*!**********************************!*\ + !*** ./src/errors/TokenError.js ***! + \**********************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class TokenError extends Error {}\nmodule.exports = TokenError;\n\n//# sourceURL=webpack://AppID/./src/errors/TokenError.js?"); + +/***/ }), + +/***/ "./src/index.js": +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\")\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in allows you to automatically obtain new tokens for a user without the user having to re-authenticate using a popup.\n\t * This will attempt to authenticate the user in a hidden iframe.\n\t * You will need to [enable Cloud Directory SSO]{@link https://cloud.ibm.com/docs/services/appid?topic=appid-single-page#spa-silent-login}.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {string} idToken A JWT.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @example\n\t * let tokens = await appID.changePassword(idToken);\n\t */\n\tasync changePassword(idToken) {\n\t\tthis._validateInitalize();\n\n\t\tif (!idToken || typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tlet userId;\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\t\tlet decodedToken = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: idToken,\n\t\t\tpublicKeys,\n\t\t\tissuer: this.openIdConfigResource.getIssuer(),\n\t\t\tclientId: this.clientId\n\t\t});\n\n\t\tif (decodedToken.identities && decodedToken.identities[0] && decodedToken.identities[0].id) {\n\t\t\tif (decodedToken.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = decodedToken.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn await this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); + +/***/ }), + +/***/ "./src/utils.js": +/*!**********************!*\ + !*** ./src/utils.js ***! + \**********************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); + +/***/ }) + +/******/ }); +}); \ No newline at end of file diff --git a/src/TokenValidator.js b/src/TokenValidator.js index f97779b..a935145 100644 --- a/src/TokenValidator.js +++ b/src/TokenValidator.js @@ -47,7 +47,7 @@ class TokenValidator { throw new TokenError(constants.INVALID_AUDIENCE); } - if ((nonce && !decoded.payloadObj.nonce) || (decoded.payloadObj.nonce !== nonce)) { + if (nonce && (!decoded.payloadObj.nonce || decoded.payloadObj.nonce !== nonce)) { throw new TokenError(constants.INVALID_NONCE); } diff --git a/src/utils.js b/src/utils.js index 5be994e..ceebf99 100644 --- a/src/utils.js +++ b/src/utils.js @@ -135,8 +135,7 @@ class Utils { token: tokens.access_token, publicKeys, issuer, - clientId, - nonce + clientId }); const idTokenPayload = this.tokenValidator.decodeAndValidate({ diff --git a/test/tokenValidatorTest.js b/test/tokenValidatorTest.js index 43d884e..c6e1299 100644 --- a/test/tokenValidatorTest.js +++ b/test/tokenValidatorTest.js @@ -41,6 +41,13 @@ describe("TokenValidator", () => { assert.equal(res.toString(), validPayload); }); + it('should return decoded payload - without nonce', async function () { + let token = generateToken({header, payload: validPayload}); + let res = await tokenValidator.decodeAndValidate( + {token, publicKeys, issuer: validIssuer, clientId}); + assert.equal(res.toString(), validPayload); + }); + it('should return invalid token - malformed token', async function () { try { let res = await tokenValidator.decodeAndValidate( From 4e99668c2e4ea0765adea6dae37007584b29a96d Mon Sep 17 00:00:00 2001 From: Joyce Huang Date: Tue, 29 Oct 2019 14:54:36 -0500 Subject: [PATCH 6/9] update --- dist/appid.min.js | 10 +++++----- dist/appid.umd.min.js | 10 +++++----- src/RequestHandler.js | 8 +++++++- src/index.js | 2 ++ src/utils.js | 1 + 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/dist/appid.min.js b/dist/appid.min.js index d7459c8..5010bb4 100644 --- a/dist/appid.min.js +++ b/dist/appid.min.js @@ -218,7 +218,7 @@ eval("const PopupError = __webpack_require__(/*! ./errors/PopupError */ \"./src/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t}\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); +eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tdebugger;\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tdebugger;\n\t\t\tif (text.includes('id token not generated with cloud directory idp')) {\n\t\t\t\tthrow new RequestError(`${JSON.parse(text).error_description}`, response.status);\n\t\t\t} else {\n\t\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t\t}\n\t\t}\n\t\t\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tif (text !== '') {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); /***/ }), @@ -229,7 +229,7 @@ eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node- /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg:[constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif (nonce && (!decoded.payloadObj.nonce || decoded.payloadObj.nonce !== nonce)) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor(let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); +eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg: [constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif (nonce && (!decoded.payloadObj.nonce || decoded.payloadObj.nonce !== nonce)) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\n\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); /***/ }), @@ -240,7 +240,7 @@ eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants /*! no static exports found */ /***/ (function(module, exports) { -eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN: 'Invalid id token',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN: 'Missing id token string',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); +eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN: 'Invalid id token',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN: 'Missing id token string',\n\tMISSING_ID_TOKEN_PAYLOAD: 'Missing id token payload',\n\tMISSING_TOKENS: 'Missing tokens',\n\tMISSING_ACCESS_TOKEN: 'Missing access token string',\n\tMISSING_ID_TOKEN: 'Missing access token string',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tGENERATE_CODE: '/cloud_directory/generate_code',\n\tCHANGE_DETAILS: '/cloud_directory/change_details',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); /***/ }), @@ -317,7 +317,7 @@ eval("class TokenError extends Error {}\nmodule.exports = TokenError;\n\n//# sou /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\")\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in allows you to automatically obtain new tokens for a user without the user having to re-authenticate using a popup.\n\t * This will attempt to authenticate the user in a hidden iframe.\n\t * You will need to [enable Cloud Directory SSO]{@link https://cloud.ibm.com/docs/services/appid?topic=appid-single-page#spa-silent-login}.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {string} idToken A JWT.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @example\n\t * let tokens = await appID.changePassword(idToken);\n\t */\n\tasync changePassword(idToken) {\n\t\tthis._validateInitalize();\n\n\t\tif (!idToken || typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tlet userId;\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\t\tlet decodedToken = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: idToken,\n\t\t\tpublicKeys,\n\t\t\tissuer: this.openIdConfigResource.getIssuer(),\n\t\t\tclientId: this.clientId\n\t\t});\n\n\t\tif (decodedToken.identities && decodedToken.identities[0] && decodedToken.identities[0].id) {\n\t\t\tif (decodedToken.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = decodedToken.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn await this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); +eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\")\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in allows you to automatically obtain new tokens for a user without the user having to re-authenticate using a popup.\n\t * This will attempt to authenticate the user in a hidden iframe.\n\t * You will need to [enable Cloud Directory SSO]{@link https://cloud.ibm.com/docs/services/appid?topic=appid-single-page#spa-silent-login}.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {string} idToken A JWT.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @example\n\t * let tokens = await appID.changePassword(idToken);\n\t */\n\tasync changePassword(idToken) {\n\t\tthis._validateInitalize();\n\n\t\tif (!idToken || typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tlet userId;\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\t\tlet decodedToken = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: idToken,\n\t\t\tpublicKeys,\n\t\t\tissuer: this.openIdConfigResource.getIssuer(),\n\t\t\tclientId: this.clientId\n\t\t});\n\n\t\tif (decodedToken.identities && decodedToken.identities[0] && decodedToken.identities[0].id) {\n\t\t\tif (decodedToken.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = decodedToken.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn await this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change details widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {Object} tokens App ID tokens\n\t * @returns {Promise}\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @throws {AppIDError} \"Missing access token string\"\n\t * @throws {AppIDError} \"Missing tokens object\"\n\t * @example\n\t * let tokens = {accessToken, idToken}\n\t * let newTokens = await appID.changeDetails(tokens);\n\t */\n\tasync changeDetails({accessToken, idToken}) {\n\t\tthis._validateInitalize();\n\n\t\tif (!accessToken && typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ACCESS_TOKEN);\n\t\t}\n\n\t\tif (!idToken && typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tconst generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE;\n\t\tconst changeDetailsCode = await this.request(generateCodeUrl, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken + ' ' + idToken\n\t\t\t}\n\t\t});\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS;\n\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint,\n\t\t\tchangeDetailsCode\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); /***/ }), @@ -328,7 +328,7 @@ eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\ncon /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); +eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId, changeDetailsCode}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tif (changeDetailsCode) {\n\t\t\tauthParams.code = changeDetailsCode;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint, changeDetailsCode}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint, changeDetailsCode});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconsole.log(tokens);\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); /***/ }) diff --git a/dist/appid.umd.min.js b/dist/appid.umd.min.js index d831b76..8eb800b 100644 --- a/dist/appid.umd.min.js +++ b/dist/appid.umd.min.js @@ -227,7 +227,7 @@ eval("const PopupError = __webpack_require__(/*! ./errors/PopupError */ \"./src/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t}\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); +eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tdebugger;\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tdebugger;\n\t\t\tif (text.includes('id token not generated with cloud directory idp')) {\n\t\t\t\tthrow new RequestError(`${JSON.parse(text).error_description}`, response.status);\n\t\t\t} else {\n\t\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t\t}\n\t\t}\n\t\t\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tif (text !== '') {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); /***/ }), @@ -238,7 +238,7 @@ eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node- /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg:[constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif (nonce && (!decoded.payloadObj.nonce || decoded.payloadObj.nonce !== nonce)) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor(let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); +eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg: [constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif (nonce && (!decoded.payloadObj.nonce || decoded.payloadObj.nonce !== nonce)) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\n\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); /***/ }), @@ -249,7 +249,7 @@ eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants /*! no static exports found */ /***/ (function(module, exports) { -eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN: 'Invalid id token',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN: 'Missing id token string',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); +eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN: 'Invalid id token',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN: 'Missing id token string',\n\tMISSING_ID_TOKEN_PAYLOAD: 'Missing id token payload',\n\tMISSING_TOKENS: 'Missing tokens',\n\tMISSING_ACCESS_TOKEN: 'Missing access token string',\n\tMISSING_ID_TOKEN: 'Missing access token string',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tGENERATE_CODE: '/cloud_directory/generate_code',\n\tCHANGE_DETAILS: '/cloud_directory/change_details',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); /***/ }), @@ -326,7 +326,7 @@ eval("class TokenError extends Error {}\nmodule.exports = TokenError;\n\n//# sou /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\")\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in allows you to automatically obtain new tokens for a user without the user having to re-authenticate using a popup.\n\t * This will attempt to authenticate the user in a hidden iframe.\n\t * You will need to [enable Cloud Directory SSO]{@link https://cloud.ibm.com/docs/services/appid?topic=appid-single-page#spa-silent-login}.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {string} idToken A JWT.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @example\n\t * let tokens = await appID.changePassword(idToken);\n\t */\n\tasync changePassword(idToken) {\n\t\tthis._validateInitalize();\n\n\t\tif (!idToken || typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tlet userId;\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\t\tlet decodedToken = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: idToken,\n\t\t\tpublicKeys,\n\t\t\tissuer: this.openIdConfigResource.getIssuer(),\n\t\t\tclientId: this.clientId\n\t\t});\n\n\t\tif (decodedToken.identities && decodedToken.identities[0] && decodedToken.identities[0].id) {\n\t\t\tif (decodedToken.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = decodedToken.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn await this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); +eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\")\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in allows you to automatically obtain new tokens for a user without the user having to re-authenticate using a popup.\n\t * This will attempt to authenticate the user in a hidden iframe.\n\t * You will need to [enable Cloud Directory SSO]{@link https://cloud.ibm.com/docs/services/appid?topic=appid-single-page#spa-silent-login}.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {string} idToken A JWT.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @example\n\t * let tokens = await appID.changePassword(idToken);\n\t */\n\tasync changePassword(idToken) {\n\t\tthis._validateInitalize();\n\n\t\tif (!idToken || typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tlet userId;\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\t\tlet decodedToken = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: idToken,\n\t\t\tpublicKeys,\n\t\t\tissuer: this.openIdConfigResource.getIssuer(),\n\t\t\tclientId: this.clientId\n\t\t});\n\n\t\tif (decodedToken.identities && decodedToken.identities[0] && decodedToken.identities[0].id) {\n\t\t\tif (decodedToken.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = decodedToken.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn await this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change details widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {Object} tokens App ID tokens\n\t * @returns {Promise}\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @throws {AppIDError} \"Missing access token string\"\n\t * @throws {AppIDError} \"Missing tokens object\"\n\t * @example\n\t * let tokens = {accessToken, idToken}\n\t * let newTokens = await appID.changeDetails(tokens);\n\t */\n\tasync changeDetails({accessToken, idToken}) {\n\t\tthis._validateInitalize();\n\n\t\tif (!accessToken && typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ACCESS_TOKEN);\n\t\t}\n\n\t\tif (!idToken && typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tconst generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE;\n\t\tconst changeDetailsCode = await this.request(generateCodeUrl, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken + ' ' + idToken\n\t\t\t}\n\t\t});\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS;\n\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint,\n\t\t\tchangeDetailsCode\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); /***/ }), @@ -337,7 +337,7 @@ eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\ncon /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); +eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId, changeDetailsCode}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tif (changeDetailsCode) {\n\t\t\tauthParams.code = changeDetailsCode;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint, changeDetailsCode}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint, changeDetailsCode});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconsole.log(tokens);\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); /***/ }) diff --git a/src/RequestHandler.js b/src/RequestHandler.js index 1c26466..fbde801 100644 --- a/src/RequestHandler.js +++ b/src/RequestHandler.js @@ -7,11 +7,17 @@ class RequestHandler { response = await fetch(url, options); text = await response.text(); } catch (e) { + debugger; throw new RequestError(`Failed to fetch ${url}. ${e}`, null, e); } if (!response.ok || response.status > 300) { - throw new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status); + debugger; + if (text.includes('id token not generated with cloud directory idp')) { + throw new RequestError(`${JSON.parse(text).error_description}`, response.status); + } else { + throw new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status); + } } try { diff --git a/src/index.js b/src/index.js index 2fea68c..2f3465e 100644 --- a/src/index.js +++ b/src/index.js @@ -229,6 +229,8 @@ class AppID { * let newTokens = await appID.changeDetails(tokens); */ async changeDetails({accessToken, idToken}) { + this._validateInitalize(); + if (!accessToken && typeof accessToken !== 'string') { throw new AppIDError(constants.MISSING_ACCESS_TOKEN); } diff --git a/src/utils.js b/src/utils.js index fe8158d..8ebd65d 100644 --- a/src/utils.js +++ b/src/utils.js @@ -133,6 +133,7 @@ class Utils { }, body: requestParams }); + console.log(tokens); const publicKeys = await this.openIdConfigResource.getPublicKeys(); const accessTokenPayload = this.tokenValidator.decodeAndValidate({ From 68ff3f6567ff15afb66a80611c8f6799c117abcc Mon Sep 17 00:00:00 2001 From: Joyce Huang Date: Tue, 5 Nov 2019 07:03:32 -0600 Subject: [PATCH 7/9] adding tests --- dist/appid.min.js | 385 +++++------------------------------- dist/appid.umd.min.js | 395 +++++-------------------------------- src/RequestHandler.js | 2 - test/AppIdTest.js | 54 +++++ test/requestHandlerTest.js | 19 +- 5 files changed, 171 insertions(+), 684 deletions(-) diff --git a/dist/appid.min.js b/dist/appid.min.js index 5010bb4..e4fa0b2 100644 --- a/dist/appid.min.js +++ b/dist/appid.min.js @@ -1,335 +1,50 @@ -var AppID = -/******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ "./node_modules/base64-js/index.js": -/*!*****************************************!*\ - !*** ./node_modules/base64-js/index.js ***! - \*****************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/base64-js/index.js?"); - -/***/ }), - -/***/ "./node_modules/buffer/index.js": -/*!**************************************!*\ - !*** ./node_modules/buffer/index.js ***! - \**************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("/* WEBPACK VAR INJECTION */(function(global) {/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n\n\nvar base64 = __webpack_require__(/*! base64-js */ \"./node_modules/base64-js/index.js\")\nvar ieee754 = __webpack_require__(/*! ieee754 */ \"./node_modules/ieee754/index.js\")\nvar isArray = __webpack_require__(/*! isarray */ \"./node_modules/isarray/index.js\")\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://AppID/./node_modules/buffer/index.js?"); - -/***/ }), - -/***/ "./node_modules/ieee754/index.js": -/*!***************************************!*\ - !*** ./node_modules/ieee754/index.js ***! - \***************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/ieee754/index.js?"); - -/***/ }), - -/***/ "./node_modules/isarray/index.js": -/*!***************************************!*\ - !*** ./node_modules/isarray/index.js ***! - \***************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n\n\n//# sourceURL=webpack://AppID/./node_modules/isarray/index.js?"); - -/***/ }), - -/***/ "./node_modules/jsrsasign/lib/jsrsasign.js": -/*!*************************************************!*\ - !*** ./node_modules/jsrsasign/lib/jsrsasign.js ***! - \*************************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\nvar navigator = {};\nnavigator.userAgent = false;\n\nvar window = {};\n/*\n * jsrsasign(all) 8.0.12 (2018-04-22) (c) 2010-2018 Kenji Urushima | kjur.github.com/jsrsasign/license\n */\n\n/*!\nCopyright (c) 2011, Yahoo! Inc. All rights reserved.\nCode licensed under the BSD License:\nhttp://developer.yahoo.com/yui/license.html\nversion: 2.9.0\n*/\nif(YAHOO===undefined){var YAHOO={}}YAHOO.lang={extend:function(g,h,f){if(!h||!g){throw new Error(\"YAHOO.lang.extend failed, please check that all dependencies are included.\")}var d=function(){};d.prototype=h.prototype;g.prototype=new d();g.prototype.constructor=g;g.superclass=h.prototype;if(h.prototype.constructor==Object.prototype.constructor){h.prototype.constructor=h}if(f){var b;for(b in f){g.prototype[b]=f[b]}var e=function(){},c=[\"toString\",\"valueOf\"];try{if(/MSIE/.test(navigator.userAgent)){e=function(j,i){for(b=0;b>>2]>>>(24-(r%4)*8))&255;q[(n+r)>>>2]|=o<<(24-((n+r)%4)*8)}}else{for(var r=0;r>>2]=p[r>>>2]}}this.sigBytes+=s;return this},clamp:function(){var o=this.words;var n=this.sigBytes;o[n>>>2]&=4294967295<<(32-(n%4)*8);o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);n.words=this.words.slice(0);return n},random:function(p){var o=[];for(var n=0;n>>2]>>>(24-(n%4)*8))&255;q.push((s>>>4).toString(16));q.push((s&15).toString(16))}return q.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>3]|=parseInt(p.substr(o,2),16)<<(24-(o%8)*4)}return new l.init(q,n/2)}};var d=m.Latin1={stringify:function(q){var r=q.words;var p=q.sigBytes;var n=[];for(var o=0;o>>2]>>>(24-(o%4)*8))&255;n.push(String.fromCharCode(s))}return n.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>2]|=(p.charCodeAt(o)&255)<<(24-(o%4)*8)}return new l.init(q,n)}};var c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error(\"Malformed UTF-8 data\")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}};var i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init();this._nDataBytes=0},_append:function(n){if(typeof n==\"string\"){n=c.parse(n)}this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data;var x=q.words;var n=q.sigBytes;var t=this.blockSize;var v=t*4;var u=n/v;if(w){u=e.ceil(u)}else{u=e.max((u|0)-this._minBufferSize,0)}var s=u*t;var r=e.min(s*4,n);if(s){for(var p=0;p>>2]&255}};f.BlockCipher=n.extend({cfg:n.cfg.extend({mode:m,padding:h}),reset:function(){n.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;\nthis._mode=c.call(a,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var p=f.CipherParams=k.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(g.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;\nreturn(a?l.create([1398893684,1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=l.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return p.create({ciphertext:a,salt:c})}},j=f.SerializableCipher=k.extend({cfg:k.extend({format:m}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return p.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,\nblockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return\"string\"==typeof a?b.parse(a,this):a}}),g=(g.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=l.random(8));a=v.create({keySize:b+c}).compute(a,d);c=l.create(a.words.slice(b),4*c);a.sigBytes=4*b;return p.create({key:a,iv:c,salt:d})}},s=f.PasswordBasedCipher=j.extend({cfg:j.cfg.extend({kdf:g}),encrypt:function(a,\nb,c,d){d=this.cfg.extend(d);c=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=c.iv;a=j.encrypt.call(this,a,b,c.key,d);a.mixIn(c);return a},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=c.iv;return j.decrypt.call(this,a,b,c.key,d)}})}();\n\n/*\nCryptoJS v3.1.2 aes.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){for(var q=CryptoJS,x=q.lib.BlockCipher,r=q.algo,j=[],y=[],z=[],A=[],B=[],C=[],s=[],u=[],v=[],w=[],g=[],k=0;256>k;k++)g[k]=128>k?k<<1:k<<1^283;for(var n=0,l=0,k=0;256>k;k++){var f=l^l<<1^l<<2^l<<3^l<<4,f=f>>>8^f&255^99;j[n]=f;y[f]=n;var t=g[n],D=g[t],E=g[D],b=257*g[f]^16843008*f;z[n]=b<<24|b>>>8;A[n]=b<<16|b>>>16;B[n]=b<<8|b>>>24;C[n]=b;b=16843009*E^65537*D^257*t^16843008*n;s[f]=b<<24|b>>>8;u[f]=b<<16|b>>>16;v[f]=b<<8|b>>>24;w[f]=b;n?(n=t^g[g[g[E^t]]],l^=g[g[l]]):n=l=1}var F=[0,1,2,4,8,\n16,32,64,128,27,54],r=r.AES=x.extend({_doReset:function(){for(var c=this._key,e=c.words,a=c.sigBytes/4,c=4*((this._nRounds=a+6)+1),b=this._keySchedule=[],h=0;h>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255]):(d=d<<8|d>>>24,d=j[d>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255],d^=F[h/a|0]<<24);b[h]=b[h-a]^d}e=this._invKeySchedule=[];for(a=0;aa||4>=h?d:s[j[d>>>24]]^u[j[d>>>16&255]]^v[j[d>>>\n8&255]]^w[j[d&255]]},encryptBlock:function(c,e){this._doCryptBlock(c,e,this._keySchedule,z,A,B,C,j)},decryptBlock:function(c,e){var a=c[e+1];c[e+1]=c[e+3];c[e+3]=a;this._doCryptBlock(c,e,this._invKeySchedule,s,u,v,w,y);a=c[e+1];c[e+1]=c[e+3];c[e+3]=a},_doCryptBlock:function(c,e,a,b,h,d,j,m){for(var n=this._nRounds,f=c[e]^a[0],g=c[e+1]^a[1],k=c[e+2]^a[2],p=c[e+3]^a[3],l=4,t=1;t>>24]^h[g>>>16&255]^d[k>>>8&255]^j[p&255]^a[l++],r=b[g>>>24]^h[k>>>16&255]^d[p>>>8&255]^j[f&255]^a[l++],s=\nb[k>>>24]^h[p>>>16&255]^d[f>>>8&255]^j[g&255]^a[l++],p=b[p>>>24]^h[f>>>16&255]^d[g>>>8&255]^j[k&255]^a[l++],f=q,g=r,k=s;q=(m[f>>>24]<<24|m[g>>>16&255]<<16|m[k>>>8&255]<<8|m[p&255])^a[l++];r=(m[g>>>24]<<24|m[k>>>16&255]<<16|m[p>>>8&255]<<8|m[f&255])^a[l++];s=(m[k>>>24]<<24|m[p>>>16&255]<<16|m[f>>>8&255]<<8|m[g&255])^a[l++];p=(m[p>>>24]<<24|m[f>>>16&255]<<16|m[g>>>8&255]<<8|m[k&255])^a[l++];c[e]=q;c[e+1]=r;c[e+2]=s;c[e+3]=p},keySize:8});q.AES=x._createHelper(r)})();\n\n/*\nCryptoJS v3.1.2 tripledes-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function j(b,c){var a=(this._lBlock>>>b^this._rBlock)&c;this._rBlock^=a;this._lBlock^=a<>>b^this._lBlock)&c;this._lBlock^=a;this._rBlock^=a<a;a++){var f=q[a]-1;c[a]=b[f>>>5]>>>31-f%32&1}b=this._subKeys=[];for(f=0;16>f;f++){for(var d=b[f]=[],e=r[f],a=0;24>a;a++)d[a/6|0]|=c[(p[a]-1+e)%28]<<31-a%6,d[4+(a/6|0)]|=c[28+(p[a+24]-1+e)%28]<<31-a%6;d[0]=d[0]<<1|d[0]>>>31;for(a=1;7>a;a++)d[a]>>>=\n4*(a-1)+3;d[7]=d[7]<<5|d[7]>>>27}c=this._invSubKeys=[];for(a=0;16>a;a++)c[a]=b[15-a]},encryptBlock:function(b,c){this._doCryptBlock(b,c,this._subKeys)},decryptBlock:function(b,c){this._doCryptBlock(b,c,this._invSubKeys)},_doCryptBlock:function(b,c,a){this._lBlock=b[c];this._rBlock=b[c+1];j.call(this,4,252645135);j.call(this,16,65535);l.call(this,2,858993459);l.call(this,8,16711935);j.call(this,1,1431655765);for(var f=0;16>f;f++){for(var d=a[f],e=this._lBlock,h=this._rBlock,g=0,k=0;8>k;k++)g|=s[k][((h^\nd[k])&t[k])>>>0];this._lBlock=h;this._rBlock=e^g}a=this._lBlock;this._lBlock=this._rBlock;this._rBlock=a;j.call(this,1,1431655765);l.call(this,8,16711935);l.call(this,2,858993459);j.call(this,16,65535);j.call(this,4,252645135);b[c]=this._lBlock;b[c+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});h.DES=e._createHelper(m);g=g.TripleDES=e.extend({_doReset:function(){var b=this._key.words;this._des1=m.createEncryptor(n.create(b.slice(0,2)));this._des2=m.createEncryptor(n.create(b.slice(2,4)));this._des3=\nm.createEncryptor(n.create(b.slice(4,6)))},encryptBlock:function(b,c){this._des1.encryptBlock(b,c);this._des2.decryptBlock(b,c);this._des3.encryptBlock(b,c)},decryptBlock:function(b,c){this._des3.decryptBlock(b,c);this._des2.encryptBlock(b,c);this._des1.decryptBlock(b,c)},keySize:6,ivSize:2,blockSize:2});h.TripleDES=e._createHelper(g)})();\n\n/*\nCryptoJS v3.1.2 enc-base64.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join(\"\")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d<\ne;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\"}})();\n\n/*\nCryptoJS v3.1.2 md5.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(E){function h(a,f,g,j,p,h,k){a=a+(f&g|~f&j)+p+k;return(a<>>32-h)+f}function k(a,f,g,j,p,h,k){a=a+(f&j|g&~j)+p+k;return(a<>>32-h)+f}function l(a,f,g,j,h,k,l){a=a+(f^g^j)+h+l;return(a<>>32-k)+f}function n(a,f,g,j,h,k,l){a=a+(g^(f|~j))+h+l;return(a<>>32-k)+f}for(var r=CryptoJS,q=r.lib,F=q.WordArray,s=q.Hasher,q=r.algo,a=[],t=0;64>t;t++)a[t]=4294967296*E.abs(E.sin(t+1))|0;q=q.MD5=s.extend({_doReset:function(){this._hash=new F.init([1732584193,4023233417,2562383102,271733878])},\n_doProcessBlock:function(m,f){for(var g=0;16>g;g++){var j=f+g,p=m[j];m[j]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360}var g=this._hash.words,j=m[f+0],p=m[f+1],q=m[f+2],r=m[f+3],s=m[f+4],t=m[f+5],u=m[f+6],v=m[f+7],w=m[f+8],x=m[f+9],y=m[f+10],z=m[f+11],A=m[f+12],B=m[f+13],C=m[f+14],D=m[f+15],b=g[0],c=g[1],d=g[2],e=g[3],b=h(b,c,d,e,j,7,a[0]),e=h(e,b,c,d,p,12,a[1]),d=h(d,e,b,c,q,17,a[2]),c=h(c,d,e,b,r,22,a[3]),b=h(b,c,d,e,s,7,a[4]),e=h(e,b,c,d,t,12,a[5]),d=h(d,e,b,c,u,17,a[6]),c=h(c,d,e,b,v,22,a[7]),\nb=h(b,c,d,e,w,7,a[8]),e=h(e,b,c,d,x,12,a[9]),d=h(d,e,b,c,y,17,a[10]),c=h(c,d,e,b,z,22,a[11]),b=h(b,c,d,e,A,7,a[12]),e=h(e,b,c,d,B,12,a[13]),d=h(d,e,b,c,C,17,a[14]),c=h(c,d,e,b,D,22,a[15]),b=k(b,c,d,e,p,5,a[16]),e=k(e,b,c,d,u,9,a[17]),d=k(d,e,b,c,z,14,a[18]),c=k(c,d,e,b,j,20,a[19]),b=k(b,c,d,e,t,5,a[20]),e=k(e,b,c,d,y,9,a[21]),d=k(d,e,b,c,D,14,a[22]),c=k(c,d,e,b,s,20,a[23]),b=k(b,c,d,e,x,5,a[24]),e=k(e,b,c,d,C,9,a[25]),d=k(d,e,b,c,r,14,a[26]),c=k(c,d,e,b,w,20,a[27]),b=k(b,c,d,e,B,5,a[28]),e=k(e,b,\nc,d,q,9,a[29]),d=k(d,e,b,c,v,14,a[30]),c=k(c,d,e,b,A,20,a[31]),b=l(b,c,d,e,t,4,a[32]),e=l(e,b,c,d,w,11,a[33]),d=l(d,e,b,c,z,16,a[34]),c=l(c,d,e,b,C,23,a[35]),b=l(b,c,d,e,p,4,a[36]),e=l(e,b,c,d,s,11,a[37]),d=l(d,e,b,c,v,16,a[38]),c=l(c,d,e,b,y,23,a[39]),b=l(b,c,d,e,B,4,a[40]),e=l(e,b,c,d,j,11,a[41]),d=l(d,e,b,c,r,16,a[42]),c=l(c,d,e,b,u,23,a[43]),b=l(b,c,d,e,x,4,a[44]),e=l(e,b,c,d,A,11,a[45]),d=l(d,e,b,c,D,16,a[46]),c=l(c,d,e,b,q,23,a[47]),b=n(b,c,d,e,j,6,a[48]),e=n(e,b,c,d,v,10,a[49]),d=n(d,e,b,c,\nC,15,a[50]),c=n(c,d,e,b,t,21,a[51]),b=n(b,c,d,e,A,6,a[52]),e=n(e,b,c,d,r,10,a[53]),d=n(d,e,b,c,y,15,a[54]),c=n(c,d,e,b,p,21,a[55]),b=n(b,c,d,e,w,6,a[56]),e=n(e,b,c,d,D,10,a[57]),d=n(d,e,b,c,u,15,a[58]),c=n(c,d,e,b,B,21,a[59]),b=n(b,c,d,e,s,6,a[60]),e=n(e,b,c,d,z,10,a[61]),d=n(d,e,b,c,q,15,a[62]),c=n(c,d,e,b,x,21,a[63]);g[0]=g[0]+b|0;g[1]=g[1]+c|0;g[2]=g[2]+d|0;g[3]=g[3]+e|0},_doFinalize:function(){var a=this._data,f=a.words,g=8*this._nDataBytes,j=8*a.sigBytes;f[j>>>5]|=128<<24-j%32;var h=E.floor(g/\n4294967296);f[(j+64>>>9<<4)+15]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;f[(j+64>>>9<<4)+14]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360;a.sigBytes=4*(f.length+1);this._process();a=this._hash;f=a.words;for(g=0;4>g;g++)j=f[g],f[g]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=s.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=s._createHelper(q);r.HmacMD5=s._createHmacHelper(q)})(Math);\n\n/*\nCryptoJS v3.1.2 sha1-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var k=CryptoJS,b=k.lib,m=b.WordArray,l=b.Hasher,d=[],b=k.algo.SHA1=l.extend({_doReset:function(){this._hash=new m.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(n,p){for(var a=this._hash.words,e=a[0],f=a[1],h=a[2],j=a[3],b=a[4],c=0;80>c;c++){if(16>c)d[c]=n[p+c]|0;else{var g=d[c-3]^d[c-8]^d[c-14]^d[c-16];d[c]=g<<1|g>>>31}g=(e<<5|e>>>27)+b+d[c];g=20>c?g+((f&h|~f&j)+1518500249):40>c?g+((f^h^j)+1859775393):60>c?g+((f&h|f&j|h&j)-1894007588):g+((f^h^\nj)-899497514);b=j;j=h;h=f<<30|f>>>2;f=e;e=g}a[0]=a[0]+e|0;a[1]=a[1]+f|0;a[2]=a[2]+h|0;a[3]=a[3]+j|0;a[4]=a[4]+b|0},_doFinalize:function(){var b=this._data,d=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=Math.floor(a/4294967296);d[(e+64>>>9<<4)+15]=a;b.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var b=l.clone.call(this);b._hash=this._hash.clone();return b}});k.SHA1=l._createHelper(b);k.HmacSHA1=l._createHmacHelper(b)})();\n\n/*\nCryptoJS v3.1.2 sha256-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(k){for(var g=CryptoJS,h=g.lib,v=h.WordArray,j=h.Hasher,h=g.algo,s=[],t=[],u=function(q){return 4294967296*(q-(q|0))|0},l=2,b=0;64>b;){var d;a:{d=l;for(var w=k.sqrt(d),r=2;r<=w;r++)if(!(d%r)){d=!1;break a}d=!0}d&&(8>b&&(s[b]=u(k.pow(l,0.5))),t[b]=u(k.pow(l,1/3)),b++);l++}var n=[],h=h.SHA256=j.extend({_doReset:function(){this._hash=new v.init(s.slice(0))},_doProcessBlock:function(q,h){for(var a=this._hash.words,c=a[0],d=a[1],b=a[2],k=a[3],f=a[4],g=a[5],j=a[6],l=a[7],e=0;64>e;e++){if(16>e)n[e]=\nq[h+e]|0;else{var m=n[e-15],p=n[e-2];n[e]=((m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3)+n[e-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[e-16]}m=l+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&g^~f&j)+t[e]+n[e];p=((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&d^c&b^d&b);l=j;j=g;g=f;f=k+m|0;k=b;b=d;d=c;c=m+p|0}a[0]=a[0]+c|0;a[1]=a[1]+d|0;a[2]=a[2]+b|0;a[3]=a[3]+k|0;a[4]=a[4]+f|0;a[5]=a[5]+g|0;a[6]=a[6]+j|0;a[7]=a[7]+l|0},_doFinalize:function(){var d=this._data,b=d.words,a=8*this._nDataBytes,c=8*d.sigBytes;\nb[c>>>5]|=128<<24-c%32;b[(c+64>>>9<<4)+14]=k.floor(a/4294967296);b[(c+64>>>9<<4)+15]=a;d.sigBytes=4*b.length;this._process();return this._hash},clone:function(){var b=j.clone.call(this);b._hash=this._hash.clone();return b}});g.SHA256=j._createHelper(h);g.HmacSHA256=j._createHmacHelper(h)})(Math);\n\n/*\nCryptoJS v3.1.2 sha224-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var b=CryptoJS,d=b.lib.WordArray,a=b.algo,c=a.SHA256,a=a.SHA224=c.extend({_doReset:function(){this._hash=new d.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var a=c._doFinalize.call(this);a.sigBytes-=4;return a}});b.SHA224=c._createHelper(a);b.HmacSHA224=c._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 sha512-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function a(){return d.create.apply(d,arguments)}for(var n=CryptoJS,r=n.lib.Hasher,e=n.x64,d=e.Word,T=e.WordArray,e=n.algo,ea=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),\na(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,\n2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),\na(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,\n3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],w=0;80>w;w++)v[w]=a();e=e.SHA512=r.extend({_doReset:function(){this._hash=new T.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(a,d){for(var f=this._hash.words,\nF=f[0],e=f[1],n=f[2],r=f[3],G=f[4],H=f[5],I=f[6],f=f[7],w=F.high,J=F.low,X=e.high,K=e.low,Y=n.high,L=n.low,Z=r.high,M=r.low,$=G.high,N=G.low,aa=H.high,O=H.low,ba=I.high,P=I.low,ca=f.high,Q=f.low,k=w,g=J,z=X,x=K,A=Y,y=L,U=Z,B=M,l=$,h=N,R=aa,C=O,S=ba,D=P,V=ca,E=Q,m=0;80>m;m++){var s=v[m];if(16>m)var j=s.high=a[d+2*m]|0,b=s.low=a[d+2*m+1]|0;else{var j=v[m-15],b=j.high,p=j.low,j=(b>>>1|p<<31)^(b>>>8|p<<24)^b>>>7,p=(p>>>1|b<<31)^(p>>>8|b<<24)^(p>>>7|b<<25),u=v[m-2],b=u.high,c=u.low,u=(b>>>19|c<<13)^(b<<\n3|c>>>29)^b>>>6,c=(c>>>19|b<<13)^(c<<3|b>>>29)^(c>>>6|b<<26),b=v[m-7],W=b.high,t=v[m-16],q=t.high,t=t.low,b=p+b.low,j=j+W+(b>>>0

>>0?1:0),b=b+c,j=j+u+(b>>>0>>0?1:0),b=b+t,j=j+q+(b>>>0>>0?1:0);s.high=j;s.low=b}var W=l&R^~l&S,t=h&C^~h&D,s=k&z^k&A^z&A,T=g&x^g&y^x&y,p=(k>>>28|g<<4)^(k<<30|g>>>2)^(k<<25|g>>>7),u=(g>>>28|k<<4)^(g<<30|k>>>2)^(g<<25|k>>>7),c=ea[m],fa=c.high,da=c.low,c=E+((h>>>14|l<<18)^(h>>>18|l<<14)^(h<<23|l>>>9)),q=V+((l>>>14|h<<18)^(l>>>18|h<<14)^(l<<23|h>>>9))+(c>>>0>>0?1:\n0),c=c+t,q=q+W+(c>>>0>>0?1:0),c=c+da,q=q+fa+(c>>>0>>0?1:0),c=c+b,q=q+j+(c>>>0>>0?1:0),b=u+T,s=p+s+(b>>>0>>0?1:0),V=S,E=D,S=R,D=C,R=l,C=h,h=B+c|0,l=U+q+(h>>>0>>0?1:0)|0,U=A,B=y,A=z,y=x,z=k,x=g,g=c+b|0,k=q+s+(g>>>0>>0?1:0)|0}J=F.low=J+g;F.high=w+k+(J>>>0>>0?1:0);K=e.low=K+x;e.high=X+z+(K>>>0>>0?1:0);L=n.low=L+y;n.high=Y+A+(L>>>0>>0?1:0);M=r.low=M+B;r.high=Z+U+(M>>>0>>0?1:0);N=G.low=N+h;G.high=$+l+(N>>>0>>0?1:0);O=H.low=O+C;H.high=aa+R+(O>>>0>>0?1:0);P=I.low=P+D;\nI.high=ba+S+(P>>>0>>0?1:0);Q=f.low=Q+E;f.high=ca+V+(Q>>>0>>0?1:0)},_doFinalize:function(){var a=this._data,d=a.words,f=8*this._nDataBytes,e=8*a.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+128>>>10<<5)+30]=Math.floor(f/4294967296);d[(e+128>>>10<<5)+31]=f;a.sigBytes=4*d.length;this._process();return this._hash.toX32()},clone:function(){var a=r.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});n.SHA512=r._createHelper(e);n.HmacSHA512=r._createHmacHelper(e)})();\n\n/*\nCryptoJS v3.1.2 sha384-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,a=c.x64,b=a.Word,e=a.WordArray,a=c.algo,d=a.SHA512,a=a.SHA384=d.extend({_doReset:function(){this._hash=new e.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var a=d._doFinalize.call(this);a.sigBytes-=16;return a}});c.SHA384=\nd._createHelper(a);c.HmacSHA384=d._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 ripemd160-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n/*\n\n(c) 2012 by Cedric Mesnil. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n(function(){var q=CryptoJS,d=q.lib,n=d.WordArray,p=d.Hasher,d=q.algo,x=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),y=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),z=n.create([11,14,15,12,\n5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),A=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),B=n.create([0,1518500249,1859775393,2400959708,2840853838]),C=n.create([1352829926,1548603684,1836072691,\n2053994217,0]),d=d.RIPEMD160=p.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,v){for(var b=0;16>b;b++){var c=v+b,f=e[c];e[c]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360}var c=this._hash.words,f=B.words,d=C.words,n=x.words,q=y.words,p=z.words,w=A.words,t,g,h,j,r,u,k,l,m,s;u=t=c[0];k=g=c[1];l=h=c[2];m=j=c[3];s=r=c[4];for(var a,b=0;80>b;b+=1)a=t+e[v+n[b]]|0,a=16>b?a+((g^h^j)+f[0]):32>b?a+((g&h|~g&j)+f[1]):48>b?\na+(((g|~h)^j)+f[2]):64>b?a+((g&j|h&~j)+f[3]):a+((g^(h|~j))+f[4]),a|=0,a=a<>>32-p[b],a=a+r|0,t=r,r=j,j=h<<10|h>>>22,h=g,g=a,a=u+e[v+q[b]]|0,a=16>b?a+((k^(l|~m))+d[0]):32>b?a+((k&m|l&~m)+d[1]):48>b?a+(((k|~l)^m)+d[2]):64>b?a+((k&l|~k&m)+d[3]):a+((k^l^m)+d[4]),a|=0,a=a<>>32-w[b],a=a+s|0,u=s,s=m,m=l<<10|l>>>22,l=k,k=a;a=c[1]+h+m|0;c[1]=c[2]+j+s|0;c[2]=c[3]+r+u|0;c[3]=c[4]+t+k|0;c[4]=c[0]+g+l|0;c[0]=a},_doFinalize:function(){var e=this._data,d=e.words,b=8*this._nDataBytes,c=8*e.sigBytes;\nd[c>>>5]|=128<<24-c%32;d[(c+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;e.sigBytes=4*(d.length+1);this._process();e=this._hash;d=e.words;for(b=0;5>b;b++)c=d[b],d[b]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return e},clone:function(){var d=p.clone.call(this);d._hash=this._hash.clone();return d}});q.RIPEMD160=p._createHelper(d);q.HmacRIPEMD160=p._createHmacHelper(d)})(Math);\n\n/*\nCryptoJS v3.1.2 hmac.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,k=c.enc.Utf8;c.algo.HMAC=c.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;\"string\"==typeof b&&(b=k.parse(b));var c=a.blockSize,e=4*c;b.sigBytes>e&&(b=a.finalize(b));b.clamp();for(var f=this._oKey=b.clone(),g=this._iKey=b.clone(),h=f.words,j=g.words,d=0;d>6)+b64map.charAt(e&63)}if(b+1==d.length){e=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(e<<2)}else{if(b+2==d.length){e=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(e>>2)+b64map.charAt((e&3)<<4)}}if(b64pad){while((a.length&3)>0){a+=b64pad}}return a}function b64tohex(f){var d=\"\";var e;var b=0;var c;var a;for(e=0;e>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(e){var d=b64tohex(e);var c;var b=new Array();for(c=0;2*c=0){var d=a*this[f++]+b[e]+h;h=Math.floor(d/67108864);b[e++]=d&67108863}return h}function am2(f,q,r,e,o,a){var k=q&32767,p=q>>15;while(--a>=0){var d=this[f]&32767;var g=this[f++]>>15;var b=p*d+g*k;d=k*d+((b&32767)<<15)+r[e]+(o&1073741823);o=(d>>>30)+(b>>>15)+p*g+(o>>>30);r[e++]=d&1073741823}return o}function am3(f,q,r,e,o,a){var k=q&16383,p=q>>14;while(--a>=0){var d=this[f]&16383;var g=this[f++]>>14;var b=p*d+g*k;d=k*d+((b&16383)<<14)+r[e]+o;o=(d>>28)+(b>>14)+p*g;r[e++]=d&268435455}return o}if(j_lm&&(navigator.appName==\"Microsoft Internet Explorer\")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator.appName!=\"Netscape\")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=((1<=0;--a){b[a]=this[a]}b.t=this.t;b.s=this.s}function bnpFromInt(a){this.t=1;this.s=(a<0)?-1:0;if(a>0){this[0]=a}else{if(a<-1){this[0]=a+this.DV}else{this.t=0}}}function nbv(a){var b=nbi();b.fromInt(a);return b}function bnpFromString(h,c){var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==256){e=8}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{this.fromRadix(h,c);return}}}}}}this.t=0;this.s=0;var g=h.length,d=false,f=0;while(--g>=0){var a=(e==8)?h[g]&255:intAt(h,g);if(a<0){if(h.charAt(g)==\"-\"){d=true}continue}d=false;if(f==0){this[this.t++]=a}else{if(f+e>this.DB){this[this.t-1]|=(a&((1<<(this.DB-f))-1))<>(this.DB-f))}else{this[this.t-1]|=a<=this.DB){f-=this.DB}}if(e==8&&(h[0]&128)!=0){this.s=-1;if(f>0){this[this.t-1]|=((1<<(this.DB-f))-1)<0&&this[this.t-1]==a){--this.t}}function bnToString(c){if(this.s<0){return\"-\"+this.negate().toString(c)}var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{return this.toRadix(c)}}}}}var g=(1<0){if(j>j)>0){a=true;h=int2char(l)}while(f>=0){if(j>(j+=this.DB-e)}else{l=(this[f]>>(j-=e))&g;if(j<=0){j+=this.DB;--f}}if(l>0){a=true}if(a){h+=int2char(l)}}}return a?h:\"0\"}function bnNegate(){var a=nbi();BigInteger.ZERO.subTo(this,a);return a}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(b){var d=this.s-b.s;if(d!=0){return d}var c=this.t;d=c-b.t;if(d!=0){return(this.s<0)?-d:d}while(--c>=0){if((d=this[c]-b[c])!=0){return d}}return 0}function nbits(a){var c=1,b;if((b=a>>>16)!=0){a=b;c+=16}if((b=a>>8)!=0){a=b;c+=8}if((b=a>>4)!=0){a=b;c+=4}if((b=a>>2)!=0){a=b;c+=2}if((b=a>>1)!=0){a=b;c+=1}return c}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(c,b){var a;for(a=this.t-1;a>=0;--a){b[a+c]=this[a]}for(a=c-1;a>=0;--a){b[a]=0}b.t=this.t+c;b.s=this.s}function bnpDRShiftTo(c,b){for(var a=c;a=0;--d){e[d+f+1]=(this[d]>>a)|h;h=(this[d]&g)<=0;--d){e[d]=0}e[f]=h;e.t=this.t+f+1;e.s=this.s;e.clamp()}function bnpRShiftTo(g,d){d.s=this.s;var e=Math.floor(g/this.DB);if(e>=this.t){d.t=0;return}var b=g%this.DB;var a=this.DB-b;var f=(1<>b;for(var c=e+1;c>b}if(b>0){d[this.t-e-1]|=(this.s&f)<>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g-=d.s}f.s=(g<0)?-1:0;if(g<-1){f[e++]=this.DV+g}else{if(g>0){f[e++]=g}}f.t=e;f.clamp()}function bnpMultiplyTo(c,e){var b=this.abs(),f=c.abs();var d=b.t;e.t=d+f.t;while(--d>=0){e[d]=0}for(d=0;d=0){d[b]=0}for(b=0;b=a.DV){d[b+a.t]-=a.DV;d[b+a.t+1]=1}}if(d.t>0){d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)}d.s=0;d.clamp()}function bnpDivRemTo(n,h,g){var w=n.abs();if(w.t<=0){return}var k=this.abs();if(k.t0){w.lShiftTo(v,d);k.lShiftTo(v,g)}else{w.copyTo(d);k.copyTo(g)}var p=d.t;var b=d[p-1];if(b==0){return}var o=b*(1<1)?d[p-2]>>this.F2:0);var A=this.FV/o,z=(1<=0){g[g.t++]=1;g.subTo(f,g)}BigInteger.ONE.dlShiftTo(p,f);f.subTo(d,d);while(d.t=0){var c=(g[--u]==b)?this.DM:Math.floor(g[u]*A+(g[u-1]+x)*z);if((g[u]+=d.am(0,c,g,s,0,p))0){g.rShiftTo(v,g)}if(a<0){BigInteger.ZERO.subTo(g,g)}}function bnMod(b){var c=nbi();this.abs().divRemTo(b,null,c);if(this.s<0&&c.compareTo(BigInteger.ZERO)>0){b.subTo(c,c)}return c}function Classic(a){this.m=a}function cConvert(a){if(a.s<0||a.compareTo(this.m)>=0){return a.mod(this.m)}else{return a}}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var a=this[0];if((a&1)==0){return 0}var b=a&3;b=(b*(2-(a&15)*b))&15;b=(b*(2-(a&255)*b))&255;b=(b*(2-(((a&65535)*b)&65535)))&65535;b=(b*(2-a*b%this.DV))%this.DV;return(b>0)?this.DV-b:-b}function Montgomery(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(a.DB-15))-1;this.mt2=2*a.t}function montConvert(a){var b=nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);if(a.s<0&&b.compareTo(BigInteger.ZERO)>0){this.m.subTo(b,b)}return b}function montRevert(a){var b=nbi();a.copyTo(b);this.reduce(b);return b}function montReduce(a){while(a.t<=this.mt2){a[a.t++]=0}for(var c=0;c>15)*this.mpl)&this.um)<<15))&a.DM;b=c+this.m.t;a[b]+=this.m.am(0,d,a,c,0,this.m.t);while(a[b]>=a.DV){a[b]-=a.DV;a[++b]++}}a.clamp();a.drShiftTo(this.m.t,a);if(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(h,j){if(h>4294967295||h<1){return BigInteger.ONE}var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;d.copyTo(f);while(--c>=0){j.sqrTo(f,a);if((h&(1<0){j.mulTo(a,d,f)}else{var b=f;f=a;a=b}}return j.revert(f)}function bnModPowInt(b,a){var c;if(b<256||a.isEven()){c=new Classic(a)}else{c=new Montgomery(a)}return this.exp(b,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction bnClone(){var a=nbi();this.copyTo(a);return a}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this[0]}else{if(this.t==0){return 0}}}return((this[1]&((1<<(32-this.DB))-1))<>24}function bnShortValue(){return(this.t==0)?this.s:(this[0]<<16)>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this[0]<=0)){return 0}else{return 1}}}function bnpToRadix(c){if(c==null){c=10}if(this.signum()==0||c<2||c>36){return\"0\"}var f=this.chunkSize(c);var e=Math.pow(c,f);var i=nbv(e),j=nbi(),h=nbi(),g=\"\";this.divRemTo(i,j,h);while(j.signum()>0){g=(e+h.intValue()).toString(c).substr(1)+g;j.divRemTo(i,j,h)}return h.intValue().toString(c)+g}function bnpFromRadix(m,h){this.fromInt(0);if(h==null){h=10}var f=this.chunkSize(h);var g=Math.pow(h,f),e=false,a=0,l=0;for(var c=0;c=f){this.dMultiply(g);this.dAddOffset(l,0);a=0;l=0}}if(a>0){this.dMultiply(Math.pow(h,a));this.dAddOffset(l,0)}if(e){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(f,e,h){if(\"number\"==typeof e){if(f<2){this.fromInt(1)}else{this.fromNumber(f,h);if(!this.testBit(f-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(f-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(e)){this.dAddOffset(2,0);if(this.bitLength()>f){this.subTo(BigInteger.ONE.shiftLeft(f-1),this)}}}}else{var d=new Array(),g=f&7;d.length=(f>>3)+1;e.nextBytes(d);if(g>0){d[0]&=((1<0){if(e>e)!=(this.s&this.DM)>>e){c[a++]=f|(this.s<<(this.DB-e))}while(b>=0){if(e<8){f=(this[b]&((1<>(e+=this.DB-8)}else{f=(this[b]>>(e-=8))&255;if(e<=0){e+=this.DB;--b}}if((f&128)!=0){f|=-256}if(a==0&&(this.s&128)!=(f&128)){++a}if(a>0||f!=this.s){c[a++]=f}}}return c}function bnEquals(b){return(this.compareTo(b)==0)}function bnMin(b){return(this.compareTo(b)<0)?this:b}function bnMax(b){return(this.compareTo(b)>0)?this:b}function bnpBitwiseTo(c,h,e){var d,g,b=Math.min(c.t,this.t);for(d=0;d>=16;b+=16}if((a&255)==0){a>>=8;b+=8}if((a&15)==0){a>>=4;b+=4}if((a&3)==0){a>>=2;b+=2}if((a&1)==0){++b}return b}function bnGetLowestSetBit(){for(var a=0;a=this.t){return(this.s!=0)}return((this[a]&(1<<(b%this.DB)))!=0)}function bnpChangeBit(c,b){var a=BigInteger.ONE.shiftLeft(c);this.bitwiseTo(a,b,a);return a}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(d,f){var e=0,g=0,b=Math.min(d.t,this.t);while(e>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g+=d.s}f.s=(g<0)?-1:0;if(g>0){f[e++]=g}else{if(g<-1){f[e++]=this.DV+g}}f.t=e;f.clamp()}function bnAdd(b){var c=nbi();this.addTo(b,c);return c}function bnSubtract(b){var c=nbi();this.subTo(b,c);return c}function bnMultiply(b){var c=nbi();this.multiplyTo(b,c);return c}function bnSquare(){var a=nbi();this.squareTo(a);return a}function bnDivide(b){var c=nbi();this.divRemTo(b,c,null);return c}function bnRemainder(b){var c=nbi();this.divRemTo(b,null,c);return c}function bnDivideAndRemainder(b){var d=nbi(),c=nbi();this.divRemTo(b,d,c);return new Array(d,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(b,a){if(b==0){return}while(this.t<=a){this[this.t++]=0}this[a]+=b;while(this[a]>=this.DV){this[a]-=this.DV;if(++a>=this.t){this[this.t++]=0}++this[a]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,c,b){a.multiplyTo(c,b)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp())}function bnpMultiplyLowerTo(b,f,e){var d=Math.min(this.t+b.t,f);e.s=0;e.t=d;while(d>0){e[--d]=0}var c;for(c=e.t-this.t;d=0){d[c]=0}for(c=Math.max(e-this.t,0);c2*this.m.t){return a.mod(this.m)}else{if(a.compareTo(this.m)<0){return a}else{var b=nbi();a.copyTo(b);this.reduce(b);return b}}}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1){a.t=this.m.t+1;a.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0){a.dAddOffset(1,this.m.t+1)}a.subTo(this.r2,a);while(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(q,f){var o=q.bitLength(),h,b=nbv(1),v;if(o<=0){return b}else{if(o<18){h=1}else{if(o<48){h=3}else{if(o<144){h=4}else{if(o<768){h=5}else{h=6}}}}}if(o<8){v=new Classic(f)}else{if(f.isEven()){v=new Barrett(f)}else{v=new Montgomery(f)}}var p=new Array(),d=3,s=h-1,a=(1<1){var A=nbi();v.sqrTo(p[1],A);while(d<=a){p[d]=nbi();v.mulTo(A,p[d-2],p[d]);d+=2}}var l=q.t-1,x,u=true,c=nbi(),y;o=nbits(q[l])-1;while(l>=0){if(o>=s){x=(q[l]>>(o-s))&a}else{x=(q[l]&((1<<(o+1))-1))<<(s-o);if(l>0){x|=q[l-1]>>(this.DB+o-s)}}d=h;while((x&1)==0){x>>=1;--d}if((o-=d)<0){o+=this.DB;--l}if(u){p[x].copyTo(b);u=false}else{while(d>1){v.sqrTo(b,c);v.sqrTo(c,b);d-=2}if(d>0){v.sqrTo(b,c)}else{y=b;b=c;c=y}v.mulTo(c,p[x],b)}while(l>=0&&(q[l]&(1<0){b.rShiftTo(f,b);h.rShiftTo(f,h)}while(b.signum()>0){if((d=b.getLowestSetBit())>0){b.rShiftTo(d,b)}if((d=h.getLowestSetBit())>0){h.rShiftTo(d,h)}if(b.compareTo(h)>=0){b.subTo(h,b);b.rShiftTo(1,b)}else{h.subTo(b,h);h.rShiftTo(1,h)}}if(f>0){h.lShiftTo(f,h)}return h}function bnpModInt(e){if(e<=0){return 0}var c=this.DV%e,b=(this.s<0)?e-1:0;if(this.t>0){if(c==0){b=this[0]%e}else{for(var a=this.t-1;a>=0;--a){b=(c*b+this[a])%e}}}return b}function bnModInverse(f){var j=f.isEven();if((this.isEven()&&j)||f.signum()==0){return BigInteger.ZERO}var i=f.clone(),h=this.clone();var g=nbv(1),e=nbv(0),l=nbv(0),k=nbv(1);while(i.signum()!=0){while(i.isEven()){i.rShiftTo(1,i);if(j){if(!g.isEven()||!e.isEven()){g.addTo(this,g);e.subTo(f,e)}g.rShiftTo(1,g)}else{if(!e.isEven()){e.subTo(f,e)}}e.rShiftTo(1,e)}while(h.isEven()){h.rShiftTo(1,h);if(j){if(!l.isEven()||!k.isEven()){l.addTo(this,l);k.subTo(f,k)}l.rShiftTo(1,l)}else{if(!k.isEven()){k.subTo(f,k)}}k.rShiftTo(1,k)}if(i.compareTo(h)>=0){i.subTo(h,i);if(j){g.subTo(l,g)}e.subTo(k,e)}else{h.subTo(i,h);if(j){l.subTo(g,l)}k.subTo(e,k)}}if(h.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(k.compareTo(f)>=0){return k.subtract(f)}if(k.signum()<0){k.addTo(f,k)}else{return k}if(k.signum()<0){return k.add(f)}else{return k}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(e){var d,b=this.abs();if(b.t==1&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d>1;if(f>lowprimes.length){f=lowprimes.length}var b=nbi();for(var e=0;e>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(window!==undefined&&(window.crypto!==undefined||window.msCrypto!==undefined)){var crypto=window.crypto||window.msCrypto;if(crypto.getRandomValues){var ua=new Uint8Array(32);crypto.getRandomValues(ua);for(t=0;t<32;++t){rng_pool[rng_pptr++]=ua[t]}}else{if(navigator.appName==\"Netscape\"&&navigator.appVersion<\"5\"){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr=0&&h>0){var f=e.charCodeAt(d--);if(f<128){g[--h]=f}else{if((f>127)&&(f<2048)){g[--h]=(f&63)|128;g[--h]=(f>>6)|192}else{g[--h]=(f&63)|128;g[--h]=((f>>6)&63)|128;g[--h]=(f>>12)|224}}}g[--h]=0;var b=new SecureRandom();var a=new Array();while(h>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}g[--h]=a[0]}g[--h]=2;g[--h]=0;return new BigInteger(g)}function oaep_mgf1_arr(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255])));d+=1}return b}function oaep_pad(q,a,f,l){var c=KJUR.crypto.MessageDigest;var o=KJUR.crypto.Util;var b=null;if(!f){f=\"sha1\"}if(typeof f===\"string\"){b=c.getCanonicalAlgName(f);l=c.getHashLength(b);f=function(i){return hextorstr(o.hashHex(rstrtohex(i),b))}}if(q.length+2*l+2>a){throw\"Message too long for RSA\"}var k=\"\",e;for(e=0;e0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{throw\"Invalid RSA public key\"}}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var e=this.doPublic(a);if(e==null){return null}var b=e.toString(16);if((b.length&1)==0){return b}else{return\"0\"+b}}function RSAEncryptOAEP(f,e,b){var a=oaep_pad(f,(this.n.bitLength()+7)>>3,e,b);if(a==null){return null}var g=this.doPublic(a);if(g==null){return null}var d=g.toString(16);if((d.length&1)==0){return d}else{return\"0\"+d}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;RSAKey.prototype.encryptOAEP=RSAEncryptOAEP;RSAKey.prototype.type=\"RSA\";\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction pkcs1unpad2(g,j){var a=g.toByteArray();var f=0;while(f=a.length){return null}}var e=\"\";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}function oaep_unpad(o,b,g,p){var e=KJUR.crypto.MessageDigest;var r=KJUR.crypto.Util;var c=null;if(!g){g=\"sha1\"}if(typeof g===\"string\"){c=e.getCanonicalAlgName(g);p=e.getHashLength(c);g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}}o=o.toByteArray();var h;for(h=0;h0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{throw\"Invalid RSA private key\"}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;this.isPublic=false;if(g==null){throw\"RSASetPrivateEx N == null\"}if(d==null){throw\"RSASetPrivateEx E == null\"}if(g.length==0){throw\"RSASetPrivateEx N.length == 0\"}if(d.length==0){throw\"RSASetPrivateEx E.length == 0\"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{throw\"Invalid RSA private key in RSASetPrivateEx\"}}function RSAGenerate(b,i){var a=new SecureRandom();var f=b>>1;this.e=parseInt(i,16);var c=new BigInteger(i,16);for(;;){for(;;){this.p=new BigInteger(b-f,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(f,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var h=this.p;this.p=this.q;this.q=h}var g=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var e=g.multiply(d);if(e.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(e);this.dmp1=this.d.mod(g);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=true}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}function RSADecryptOAEP(e,d,b){var f=parseBigInt(e,16);var a=this.doPrivate(f);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,d,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP;\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction ECFieldElementFp(b,a){this.x=a;this.q=b}function feFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.x.equals(a.x))}function feFpToBigInteger(){return this.x}function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))}function feFpAdd(a){return new ECFieldElementFp(this.q,this.x.add(a.toBigInteger()).mod(this.q))}function feFpSubtract(a){return new ECFieldElementFp(this.q,this.x.subtract(a.toBigInteger()).mod(this.q))}function feFpMultiply(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger()).mod(this.q))}function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))}function feFpDivide(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger().modInverse(this.q)).mod(this.q))}ECFieldElementFp.prototype.equals=feFpEquals;ECFieldElementFp.prototype.toBigInteger=feFpToBigInteger;ECFieldElementFp.prototype.negate=feFpNegate;ECFieldElementFp.prototype.add=feFpAdd;ECFieldElementFp.prototype.subtract=feFpSubtract;ECFieldElementFp.prototype.multiply=feFpMultiply;ECFieldElementFp.prototype.square=feFpSquare;ECFieldElementFp.prototype.divide=feFpDivide;function ECPointFp(c,a,d,b){this.curve=c;this.x=a;this.y=d;if(b==null){this.z=BigInteger.ONE}else{this.z=b}this.zinv=null}function pointFpGetX(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpGetY(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpEquals(a){if(a==this){return true}if(this.isInfinity()){return a.isInfinity()}if(a.isInfinity()){return this.isInfinity()}var c,b;c=a.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(a.z)).mod(this.curve.q);if(!c.equals(BigInteger.ZERO)){return false}b=a.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(a.z)).mod(this.curve.q);return b.equals(BigInteger.ZERO)}function pointFpIsInfinity(){if((this.x==null)&&(this.y==null)){return true}return this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)}function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)}function pointFpAdd(l){if(this.isInfinity()){return l}if(l.isInfinity()){return this}var p=l.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(l.z)).mod(this.curve.q);var o=l.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(l.z)).mod(this.curve.q);if(BigInteger.ZERO.equals(o)){if(BigInteger.ZERO.equals(p)){return this.twice()}return this.curve.getInfinity()}var j=new BigInteger(\"3\");var e=this.x.toBigInteger();var n=this.y.toBigInteger();var c=l.x.toBigInteger();var k=l.y.toBigInteger();var m=o.square();var i=m.multiply(o);var d=e.multiply(m);var g=p.square().multiply(this.z);var a=g.subtract(d.shiftLeft(1)).multiply(l.z).subtract(i).multiply(o).mod(this.curve.q);var h=d.multiply(j).multiply(p).subtract(n.multiply(i)).subtract(g.multiply(p)).multiply(l.z).add(p.multiply(i)).mod(this.curve.q);var f=i.multiply(this.z).multiply(l.z).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),f)}function pointFpTwice(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var g=new BigInteger(\"3\");var c=this.x.toBigInteger();var h=this.y.toBigInteger();var e=h.multiply(this.z);var j=e.multiply(h).mod(this.curve.q);var i=this.curve.a.toBigInteger();var k=c.square().multiply(g);if(!BigInteger.ZERO.equals(i)){k=k.add(this.z.square().multiply(i))}k=k.mod(this.curve.q);var b=k.square().subtract(c.shiftLeft(3).multiply(j)).shiftLeft(1).multiply(e).mod(this.curve.q);var f=k.multiply(g).multiply(c).subtract(j.shiftLeft(1)).shiftLeft(2).multiply(j).subtract(k.square().multiply(k)).mod(this.curve.q);var d=e.square().multiply(e).shiftLeft(3).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(b),this.curve.fromBigInteger(f),d)}function pointFpMultiply(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add(a?this:l)}}return d}function pointFpMultiplyTwo(c,a,b){var d;if(c.bitLength()>b.bitLength()){d=c.bitLength()-1}else{d=b.bitLength()-1}var f=this.curve.getInfinity();var e=this.add(a);while(d>=0){f=f.twice();if(c.testBit(d)){if(b.testBit(d)){f=f.add(e)}else{f=f.add(this)}}else{if(b.testBit(d)){f=f.add(a)}}--d}return f}ECPointFp.prototype.getX=pointFpGetX;ECPointFp.prototype.getY=pointFpGetY;ECPointFp.prototype.equals=pointFpEquals;ECPointFp.prototype.isInfinity=pointFpIsInfinity;ECPointFp.prototype.negate=pointFpNegate;ECPointFp.prototype.add=pointFpAdd;ECPointFp.prototype.twice=pointFpTwice;ECPointFp.prototype.multiply=pointFpMultiply;ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo;function ECCurveFp(e,d,c){this.q=e;this.a=this.fromBigInteger(d);this.b=this.fromBigInteger(c);this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b))}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)}function curveFpDecodePointHex(d){switch(parseInt(d.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var a=(d.length-2)/2;var c=d.substr(2,a);var b=d.substr(a+2,a);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(b,16)));default:return null}}ECCurveFp.prototype.getQ=curveFpGetQ;ECCurveFp.prototype.getA=curveFpGetA;ECCurveFp.prototype.getB=curveFpGetB;ECCurveFp.prototype.equals=curveFpEquals;ECCurveFp.prototype.getInfinity=curveFpGetInfinity;ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger;ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex;\n/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib\n */\nECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};ECPointFp.prototype.getEncoded=function(c){var d=function(h,f){var g=h.toByteArrayUnsigned();if(fg.length){g.unshift(0)}}return g};var a=this.getX().toBigInteger();var e=this.getY().toBigInteger();var b=d(a,32);if(c){if(e.isEven()){b.unshift(2)}else{b.unshift(3)}}else{b.unshift(4);b=b.concat(d(e,32))}return b};ECPointFp.decodeFrom=function(g,c){var f=c[0];var e=c.length-1;var d=c.slice(1,1+e/2);var b=c.slice(1+e/2,1+e);d.unshift(0);b.unshift(0);var a=new BigInteger(d);var h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.decodeFromHex=function(g,c){var f=c.substr(0,2);var e=c.length-2;var d=c.substr(2,e/2);var b=c.substr(2+e/2,e/2);var a=new BigInteger(d,16);var h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.prototype.add2D=function(c){if(this.isInfinity()){return c}if(c.isInfinity()){return this}if(this.x.equals(c.x)){if(this.y.equals(c.y)){return this.twice()}return this.curve.getInfinity()}var g=c.x.subtract(this.x);var e=c.y.subtract(this.y);var a=e.divide(g);var d=a.square().subtract(this.x).subtract(c.x);var f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var b=this.curve.fromBigInteger(BigInteger.valueOf(2));var e=this.curve.fromBigInteger(BigInteger.valueOf(3));var a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b));var c=a.square().subtract(this.x.multiply(b));var d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)};ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add2D(a?this:l)}}return d};ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger();var i=this.getY().toBigInteger();var f=this.curve.getA().toBigInteger();var c=this.curve.getB().toBigInteger();var h=this.curve.getQ();var e=i.multiply(i).mod(h);var g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)};ECPointFp.prototype.toString=function(){return\"(\"+this.getX().toBigInteger().toString()+\",\"+this.getY().toBigInteger().toString()+\")\"};ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity()){throw new Error(\"Point is at infinity.\")}var a=this.getX().toBigInteger();var b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"x coordinate out of bounds\")}if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"y coordinate out of bounds\")}if(!this.isOnCurve()){throw new Error(\"Point is not on the curve.\")}if(this.multiply(c).isInfinity()){throw new Error(\"Point is not a scalar multiple of G.\")}return true};\n/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval\n */\nvar jsonParse=(function(){var e=\"(?:-?\\\\b(?:0|[1-9][0-9]*)(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\\\b)\";var j='(?:[^\\\\0-\\\\x08\\\\x0a-\\\\x1f\"\\\\\\\\]|\\\\\\\\(?:[\"/\\\\\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:\"'+j+'*\")';var d=new RegExp(\"(?:false|true|null|[\\\\{\\\\}\\\\[\\\\]]|\"+e+\"|\"+i+\")\",\"g\");var k=new RegExp(\"\\\\\\\\(?:([^u])|u(.{4}))\",\"g\");var g={'\"':'\"',\"/\":\"/\",\"\\\\\":\"\\\\\",b:\"\\b\",f:\"\\f\",n:\"\\n\",r:\"\\r\",t:\"\\t\"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String(\"\");var a=\"\\\\\";var f={\"{\":Object,\"[\":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if(\"{\"===v){x={}}else{if(\"[\"===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({\"\":x},\"\")}return x}})();\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.asn1==\"undefined\"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b=\"0\"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!=\"-\"){if(f.length%2==1){f=\"0\"+f}else{if(!f.match(/^[0-7]/)){f=\"00\"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g=\"\";for(var d=0;d15){throw\"ASN.1 length too long to represent by 8x: n = \"+i.toString(16)}var f=128+g;return f.toString(16)+h}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return\"\"}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!=\"undefined\"){if(typeof c==\"string\"){this.setString(c)}else{if(typeof c.str!=\"undefined\"){this.setString(c.str)}else{if(typeof c.hex!=\"undefined\"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(f){utc=f.getTime()+(f.getTimezoneOffset()*60000);var e=new Date(utc);return e};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o==\"utc\"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,\"\");r=r+\".\"+k}}return r+\"Z\"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join(\"0\")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!=\"undefined\"){if(typeof b.array!=\"undefined\"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT=\"01\";this.hTLV=\"0101ff\"};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT=\"02\";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!=\"undefined\"){if(typeof a.bigint!=\"undefined\"){this.setByBigInteger(a.bigint)}else{if(typeof a[\"int\"]!=\"undefined\"){this.setByInteger(a[\"int\"])}else{if(typeof a==\"number\"){this.setByInteger(a)}else{if(typeof a.hex!=\"undefined\"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!==\"undefined\"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex=\"00\"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT=\"03\";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=(l*2))){break}if(d>=200){break}g.push(b);c=b;d++}return g};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){throw\"checking tag doesn't match: \"+e.substr(d,2)+\"!=\"+i}}return d}f=c.shift();b=g.getChildIdx(e,d);return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getTLVbyList=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyList(d,c,b);if(a===undefined){throw\"can't find nthList object\"}if(f!==undefined){if(d.substr(a,2)!=f){throw\"checking tag doesn't match: \"+d.substr(a,2)+\"!=\"+f}}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a===undefined){throw\"can't find nthList object\"}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join(\"0\")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+\".\"+j.join(\".\")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+\"..(total \"+A.length/2+\"bytes)..\"+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=\"\"}var x=c.ommit_long_octet;if(e.substr(l,2)==\"01\"){var h=j(e,l);if(h==\"00\"){return g+\"BOOLEAN FALSE\\n\"}else{return g+\"BOOLEAN TRUE\\n\"}}if(e.substr(l,2)==\"02\"){var h=j(e,l);return g+\"INTEGER \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"03\"){var h=j(e,l);return g+\"BITSTRING \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"04\"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+\"OCTETSTRING, encapsulates\\n\";k=k+y(h,c,0,g+\" \");return k}else{return g+\"OCTETSTRING \"+q(h,x)+\"\\n\"}}if(e.substr(l,2)==\"05\"){return g+\"NULL\\n\"}if(e.substr(l,2)==\"06\"){var m=j(e,l);var a=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(a);var b=a.replace(/\\./g,\" \");if(o!=\"\"){return g+\"ObjectIdentifier \"+o+\" (\"+b+\")\\n\"}else{return g+\"ObjectIdentifier (\"+b+\")\\n\"}}if(e.substr(l,2)==\"0c\"){return g+\"UTF8String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"13\"){return g+\"PrintableString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"14\"){return g+\"TeletexString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"16\"){return g+\"IA5String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"17\"){return g+\"UTCTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"18\"){return g+\"GeneralizedTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"30\"){if(e.substr(l,4)==\"3000\"){return g+\"SEQUENCE {}\\n\"}var k=g+\"SEQUENCE\\n\";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)==\"06\"&&e.substr(d[d.length-1],2)==\"04\"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u0){var m=new f({array:this.extensionsArray});var k=new c({explicit:true,tag:\"a3\",obj:m});this.asn1Array.push(k)}var n=new f({array:this.asn1Array});this.hTLV=n.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension=function(d){KJUR.asn1.x509.Extension.superclass.constructor.call(this);var f=null,a=KJUR,e=a.asn1,h=e.DERObjectIdentifier,i=e.DEROctetString,b=e.DERBitString,g=e.DERBoolean,c=e.DERSequence;this.getEncodedHex=function(){var m=new h({oid:this.oid});var l=new i({hex:this.getExtnValueHex()});var k=new Array();k.push(m);if(this.critical){k.push(new g())}k.push(l);var j=new c({array:k});return j.getEncodedHex()};this.critical=false;if(d!==undefined){if(d.critical!==undefined){this.critical=d.critical}}};YAHOO.lang.extend(KJUR.asn1.x509.Extension,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension.appendByNameToArray=function(e,c,b){var g=e.toLowerCase(),f=KJUR.asn1.x509;if(g==\"basicconstraints\"){var d=new f.BasicConstraints(c);b.push(d)}else{if(g==\"keyusage\"){var d=new f.KeyUsage(c);b.push(d)}else{if(g==\"crldistributionpoints\"){var d=new f.CRLDistributionPoints(c);b.push(d)}else{if(g==\"extkeyusage\"){var d=new f.ExtKeyUsage(c);b.push(d)}else{if(g==\"authoritykeyidentifier\"){var d=new f.AuthorityKeyIdentifier(c);b.push(d)}else{if(g==\"authorityinfoaccess\"){var d=new f.AuthorityInfoAccess(c);b.push(d)}else{if(g==\"subjectaltname\"){var d=new f.SubjectAltName(c);b.push(d)}else{if(g==\"issueraltname\"){var d=new f.IssuerAltName(c);b.push(d)}else{throw\"unsupported extension name: \"+e}}}}}}}}};KJUR.asn1.x509.KeyUsage=function(f){KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this,f);var a=X509.KEYUSAGE_NAME;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.15\";if(f!==undefined){if(f.bin!==undefined){this.asn1ExtnValue=new KJUR.asn1.DERBitString(f)}if(f.names!==undefined&&f.names.length!==undefined){var e=f.names;var d=\"000000000\";for(var c=0;c-1){e.push(new KJUR.asn1.DERInteger({\"int\":this.pathLen}))}var d=new KJUR.asn1.DERSequence({array:e});this.asn1ExtnValue=d;return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.19\";this.cA=false;this.pathLen=-1;if(c!==undefined){if(c.cA!==undefined){this.cA=c.cA}if(c.pathLen!==undefined){this.pathLen=c.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){this.asn1ExtnValue=new a.DERSequence({array:e})};this.setByOneURI=function(h){var e=new c.GeneralNames([{uri:h}]);var g=new c.DistributionPointName(e);var f=new c.DistributionPoint({dpobj:g});this.setByDPArray([f])};this.oid=\"2.5.29.31\";if(d!==undefined){if(d.array!==undefined){this.setByDPArray(d.array)}else{if(d.uri!==undefined){this.setByOneURI(d.uri)}}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLDistributionPoints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.ExtKeyUsage=function(c){KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,c);var b=KJUR,a=b.asn1;this.setPurposeArray=function(d){this.asn1ExtnValue=new a.DERSequence();for(var e=0;e0){var h=new b({array:this.aRevokedCert});this.asn1Array.push(h)}var i=new b({array:this.asn1Array});this.hTLV=i.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize=function(){this.asn1Version=null;this.asn1SignatureAlg=null;this.asn1Issuer=null;this.asn1ThisUpdate=null;this.asn1NextUpdate=null;this.aRevokedCert=new Array()};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertList,KJUR.asn1.ASN1Object);KJUR.asn1.x509.CRLEntry=function(e){KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);var d=null,c=null,b=KJUR,a=b.asn1;this.setCertSerial=function(f){this.sn=new a.DERInteger(f)};this.setRevocationDate=function(f){this.time=new a.x509.Time(f)};this.getEncodedHex=function(){var f=new a.DERSequence({array:[this.sn,this.time]});this.TLV=f.getEncodedHex();return this.TLV};if(e!==undefined){if(e.time!==undefined){this.setRevocationDate(e.time)}if(e.sn!==undefined){this.setCertSerial(e.sn)}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLEntry,KJUR.asn1.ASN1Object);KJUR.asn1.x509.X500Name=function(f){KJUR.asn1.x509.X500Name.superclass.constructor.call(this);this.asn1Array=new Array();var d=KJUR,c=d.asn1,e=c.x509,b=pemtohex;this.setByString=function(g){var k=g.split(\"/\");k.shift();var j=[];for(var l=0;l0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+\",\"+h).replace(/\\\\,/g,\",\");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)===\"\\\\\"){e=true}}b=b.map(function(a){return a.replace(\"/\",\"\\\\/\")});b.reverse();return\"/\"+b.join(\"/\")};KJUR.asn1.x509.RDN=function(a){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=new Array();this.addByString=function(b){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:b}))};this.addByMultiValuedString=function(d){var b=KJUR.asn1.x509.RDN.parseString(d);for(var c=0;c0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+\"+\"+k).replace(/\\\\\\+/g,\"+\");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)===\"\\\\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/\"$/)){var d=(e+\"+\"+k).replace(/^([^=]+)=\"(.*)\"$/,\"$1=$2\");b.push(d);l=false}else{b.push(e+\"+\"+k)}}else{b.push(k)}if(k.match(/^[^=]+=\"/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(d){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var f=null,e=null,a=\"utf8\",c=KJUR,b=c.asn1;this.setByString=function(h){var g=h.match(/^([^=]+)=(.+)$/);if(g){this.setByAttrTypeAndValueStr(g[1],g[2])}else{throw\"malformed attrTypeAndValueStr: \"+h}};this.setByAttrTypeAndValueStr=function(i,h){this.typeObj=KJUR.asn1.x509.OID.atype2obj(i);var g=a;if(i==\"C\"){g=\"prn\"}this.valueObj=this.getValueObj(g,h)};this.getValueObj=function(h,g){if(h==\"utf8\"){return new b.DERUTF8String({str:g})}if(h==\"prn\"){return new b.DERPrintableString({str:g})}if(h==\"tel\"){return new b.DERTeletexString({str:g})}if(h==\"ia5\"){return new b.DERIA5String({str:g})}throw\"unsupported directory string type: type=\"+h+\" value=\"+g};this.getEncodedHex=function(){var g=new b.DERSequence({array:[this.typeObj,this.valueObj]});this.TLV=g.getEncodedHex();return this.TLV};if(d!==undefined){if(d.str!==undefined){this.setByString(d.str)}}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw\"algId and/or subjPubKey not set\"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{\"int\":{bigint:q.n}},{\"int\":{\"int\":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:\"rsaEncryption\"});this.asn1SubjPKey=new b({hex:\"00\"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:\"ecPublicKey\",asn1params:r});this.asn1SubjPKey=new b({hex:\"00\"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{\"int\":{bigint:q.p}},{\"int\":{bigint:q.q}},{\"int\":{bigint:q.g}}]});this.asn1AlgId=new o({name:\"dsa\",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:\"00\"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type==\"utc\"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type==\"utc\"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type=\"utc\";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type=\"utc\"}if(f.str.match(/^[0-9]{14}Z$/)){this.type=\"gen\"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(d){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw\"algorithm not specified\"}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var e=[this.asn1Alg];if(this.asn1Params!==null){e.push(this.asn1Params)}var f=new a.DERSequence({array:e});this.hTLV=f.getEncodedHex();return this.hTLV};if(d!==undefined){if(d.name!==undefined){this.nameAlg=d.name}if(d.asn1params!==undefined){this.asn1Params=d.asn1params}if(d.paramempty!==undefined){this.paramEmpty=d.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){var c=this.nameAlg.toLowerCase();if(c.substr(-7,7)!==\"withdsa\"&&c.substr(-9,9)!==\"withecdsa\"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:\"81\",dns:\"82\",dn:\"a4\",uri:\"86\",ip:\"87\"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type=\"rfc822\";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type=\"dns\";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type=\"uri\";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({str:p.dn})}if(p.ldapdn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certissuer param not cert\"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certsubj param not cert\"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type=\"ip\";this.explicit=false;var q=p.ip;var s;var n=\"malformed IP address\";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex(\"[\"+q.split(\".\").join(\",\")+\"]\");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw\"unsupported type in params=\"+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){r=new b({obj:this.dUnsignedAttrs,tag:\"a1\",explicit:false})}var q=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,o,this.dSigAlg,this.dSig,];if(r!=null){q.push(r)}var p=new h.DERSequence({array:q});this.hTLV=p.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.SignerInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.EncapsulatedContentInfo=function(g){var c=KJUR,b=c.asn1,e=b.DERTaggedObject,a=b.DERSequence,h=b.DERObjectIdentifier,d=b.DEROctetString,f=b.cms;f.EncapsulatedContentInfo.superclass.constructor.call(this);this.dEContentType=new h({name:\"data\"});this.dEContent=null;this.isDetached=false;this.eContentValueHex=null;this.setContentType=function(i){if(i.match(/^[0-2][.][0-9.]+$/)){this.dEContentType=new h({oid:i})}else{this.dEContentType=new h({name:i})}};this.setContentValue=function(i){if(i!==undefined){if(typeof i.hex==\"string\"){this.eContentValueHex=i.hex}else{if(typeof i.str==\"string\"){this.eContentValueHex=utf8tohex(i.str)}}}};this.setContentValueHex=function(i){this.eContentValueHex=i};this.setContentValueStr=function(i){this.eContentValueHex=utf8tohex(i)};this.getEncodedHex=function(){if(typeof this.eContentValueHex!=\"string\"){throw\"eContentValue not yet set\"}var k=new d({hex:this.eContentValueHex});this.dEContent=new e({obj:k,tag:\"a0\",explicit:true});var i=[this.dEContentType];if(!this.isDetached){i.push(this.dEContent)}var j=new a({array:i});this.hTLV=j.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.EncapsulatedContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.ContentInfo=function(f){var c=KJUR,b=c.asn1,d=b.DERTaggedObject,a=b.DERSequence,e=b.x509;KJUR.asn1.cms.ContentInfo.superclass.constructor.call(this);this.dContentType=null;this.dContent=null;this.setContentType=function(g){if(typeof g==\"string\"){this.dContentType=e.OID.name2obj(g)}};this.getEncodedHex=function(){var h=new d({obj:this.dContent,tag:\"a0\",explicit:true});var g=new a({array:[this.dContentType,h]});this.hTLV=g.getEncodedHex();return this.hTLV};if(f!==undefined){if(f.type){this.setContentType(f.type)}if(f.obj&&f.obj instanceof b.ASN1Object){this.dContent=f.obj}}};YAHOO.lang.extend(KJUR.asn1.cms.ContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.SignedData=function(e){var a=KJUR,h=a.asn1,j=h.ASN1Object,g=h.DERInteger,m=h.DERSet,f=h.DERSequence,b=h.DERTaggedObject,l=h.cms,i=l.EncapsulatedContentInfo,d=l.SignerInfo,n=l.ContentInfo,c=h.x509,k=c.AlgorithmIdentifier;KJUR.asn1.cms.SignedData.superclass.constructor.call(this);this.dCMSVersion=new g({\"int\":1});this.dDigestAlgs=null;this.digestAlgNameList=[];this.dEncapContentInfo=new i();this.dCerts=null;this.certificateList=[];this.crlList=[];this.signerInfoList=[new d()];this.addCertificatesByPEM=function(p){var q=pemtohex(p);var r=new j();r.hTLV=q;this.certificateList.push(r)};this.getEncodedHex=function(){if(typeof this.hTLV==\"string\"){return this.hTLV}if(this.dDigestAlgs==null){var u=[];for(var t=0;t0){var v=new m({array:this.certificateList});this.dCerts=new b({obj:v,tag:\"a0\",explicit:false})}}if(this.dCerts!=null){p.push(this.dCerts)}var r=new m({array:this.signerInfoList});p.push(r);var q=new f({array:p});this.hTLV=q.getEncodedHex();return this.hTLV};this.getContentInfo=function(){this.getEncodedHex();var o=new n({type:\"signed-data\",obj:this});return o};this.getContentInfoEncodedHex=function(){var o=this.getContentInfo();var p=o.getEncodedHex();return p};this.getPEM=function(){return hextopem(this.getContentInfoEncodedHex(),\"CMS\")}};YAHOO.lang.extend(KJUR.asn1.cms.SignedData,KJUR.asn1.ASN1Object);KJUR.asn1.cms.CMSUtil=new function(){};KJUR.asn1.cms.CMSUtil.newSignedData=function(d){var b=KJUR,j=b.asn1,q=j.cms,f=q.SignerInfo,n=q.SignedData,o=q.SigningTime,a=q.SigningCertificate,p=q.SigningCertificateV2,c=j.cades,e=c.SignaturePolicyIdentifier;var m=new n();m.dEncapContentInfo.setContentValue(d.content);if(typeof d.certs==\"object\"){for(var h=0;h0){var s=new f({array:this.extensionsArray});var r=new m({array:[s]});var q=new f({array:[new k({oid:\"1.2.840.113549.1.9.14\"}),r]});var p=new c({explicit:true,tag:\"a0\",obj:q});this.asn1Array.push(p)}else{var p=new c({explicit:false,tag:\"a0\",obj:new j()});this.asn1Array.push(p)}var t=new f({array:this.asn1Array});this.hTLV=t.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CSRUtil=new function(){};KJUR.asn1.csr.CSRUtil.newCSRPEM=function(h){var c=KEYUTIL,b=KJUR.asn1.csr;if(h.subject===undefined){throw\"parameter subject undefined\"}if(h.sbjpubkey===undefined){throw\"parameter sbjpubkey undefined\"}if(h.sigalg===undefined){throw\"parameter sigalg undefined\"}if(h.sbjprvkey===undefined){throw\"parameter sbjpubkey undefined\"}var d=new b.CertificationRequestInfo();d.setSubjectByParam(h.subject);d.setSubjectPublicKeyByGetKey(h.sbjpubkey);if(h.ext!==undefined&&h.ext.length!==undefined){for(var e=0;ef.length){f=c[d]}}e=e.replace(f,\"::\");return e.slice(1,-1)}function hextoip(b){var d=\"malformed hex value\";if(!b.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){throw d}if(b.length==8){var c;try{c=parseInt(b.substr(0,2),16)+\".\"+parseInt(b.substr(2,2),16)+\".\"+parseInt(b.substr(4,2),16)+\".\"+parseInt(b.substr(6,2),16);return c}catch(a){throw d}}else{if(b.length==32){return hextoipv6(b)}else{return b}}}function iptohex(f){var j=\"malformed IP address\";f=f.toLowerCase(f);if(f.match(/^[0-9.]+$/)){var b=f.split(\".\");if(b.length!==4){throw j}var g=\"\";try{for(var e=0;e<4;e++){var h=parseInt(b[e]);g+=(\"0\"+h.toString(16)).slice(-2)}return g}catch(c){throw j}}else{if(f.match(/^[0-9a-f:]+$/)&&f.indexOf(\":\")!==-1){return ipv6tohex(f)}else{throw j}}}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b=\"\";for(var c=0;c\"7\"){return\"00\"+a}return a}function intarystrtohex(b){b=b.replace(/^\\s*\\[\\s*/,\"\");b=b.replace(/\\s*\\]\\s*$/,\"\");b=b.replace(/\\s*/g,\"\");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;bd){throw\"key is too short for SigAlg: keylen=\"+j+\",\"+a}var b=\"0001\";var k=\"00\"+c;var g=\"\";var l=d-b.length-k.length;for(var f=0;f=0;--p){q=q.twice2D();q.z=BigInteger.ONE;if(o.testBit(p)){if(n.testBit(p)){q=q.add2D(t)}else{q=q.add2D(s)}}else{if(n.testBit(p)){q=q.add2D(r)}}}return q}this.getBigRandom=function(i){return new BigInteger(i.bitLength(),a).mod(i.subtract(BigInteger.ONE)).add(BigInteger.ONE)};this.setNamedCurve=function(i){this.ecparams=KJUR.crypto.ECParameterDB.getByName(i);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=i};this.setPrivateKeyHex=function(i){this.isPrivate=true;this.prvKeyHex=i};this.setPublicKeyHex=function(i){this.isPublic=true;this.pubKeyHex=i};this.getPublicKeyXYHex=function(){var k=this.pubKeyHex;if(k.substr(0,2)!==\"04\"){throw\"this method supports uncompressed format(04) only\"}var j=this.ecparams.keylen/4;if(k.length!==2+j*2){throw\"malformed public key hex length\"}var i={};i.x=k.substr(2,j);i.y=k.substr(2+j);return i};this.getShortNISTPCurveName=function(){var i=this.curveName;if(i===\"secp256r1\"||i===\"NIST P-256\"||i===\"P-256\"||i===\"prime256v1\"){return\"P-256\"}if(i===\"secp384r1\"||i===\"NIST P-384\"||i===\"P-384\"){return\"P-384\"}return null};this.generateKeyPairHex=function(){var k=this.ecparams.n;var n=this.getBigRandom(k);var l=this.ecparams.G.multiply(n);var q=l.getX().toBigInteger();var o=l.getY().toBigInteger();var i=this.ecparams.keylen/4;var m=(\"0000000000\"+n.toString(16)).slice(-i);var r=(\"0000000000\"+q.toString(16)).slice(-i);var p=(\"0000000000\"+o.toString(16)).slice(-i);var j=\"04\"+r+p;this.setPrivateKeyHex(m);this.setPublicKeyHex(j);return{ecprvhex:m,ecpubhex:j}};this.signWithMessageHash=function(i){return this.signHex(i,this.prvKeyHex)};this.signHex=function(o,j){var t=new BigInteger(j,16);var l=this.ecparams.n;var q=new BigInteger(o,16);do{var m=this.getBigRandom(l);var u=this.ecparams.G;var p=u.multiply(m);var i=p.getX().toBigInteger().mod(l)}while(i.compareTo(BigInteger.ZERO)<=0);var v=m.modInverse(l).multiply(q.add(t.multiply(i))).mod(l);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(i,v)};this.sign=function(m,u){var q=u;var j=this.ecparams.n;var p=BigInteger.fromByteArrayUnsigned(m);do{var l=this.getBigRandom(j);var t=this.ecparams.G;var o=t.multiply(l);var i=o.getX().toBigInteger().mod(j)}while(i.compareTo(BigInteger.ZERO)<=0);var v=l.modInverse(j).multiply(p.add(q.multiply(i))).mod(j);return this.serializeSig(i,v)};this.verifyWithMessageHash=function(j,i){return this.verifyHex(j,i,this.pubKeyHex)};this.verifyHex=function(m,i,p){var l,j;var o=KJUR.crypto.ECDSA.parseSigHex(i);l=o.r;j=o.s;var k;k=ECPointFp.decodeFromHex(this.ecparams.curve,p);var n=new BigInteger(m,16);return this.verifyRaw(n,l,j,k)};this.verify=function(o,p,j){var l,i;if(Bitcoin.Util.isArray(p)){var n=this.parseSig(p);l=n.r;i=n.s}else{if(\"object\"===typeof p&&p.r&&p.s){l=p.r;i=p.s}else{throw\"Invalid value for signature\"}}var k;if(j instanceof ECPointFp){k=j}else{if(Bitcoin.Util.isArray(j)){k=ECPointFp.decodeFrom(this.ecparams.curve,j)}else{throw\"Invalid format for pubkey value, must be byte array or ECPointFp\"}}var m=BigInteger.fromByteArrayUnsigned(o);return this.verifyRaw(m,l,i,k)};this.verifyRaw=function(o,i,w,m){var l=this.ecparams.n;var u=this.ecparams.G;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(l)>=0){return false}if(w.compareTo(BigInteger.ONE)<0||w.compareTo(l)>=0){return false}var p=w.modInverse(l);var k=o.multiply(p).mod(l);var j=i.multiply(p).mod(l);var q=u.multiply(k).add(m.multiply(j));var t=q.getX().toBigInteger().mod(l);return t.equals(i)};this.serializeSig=function(k,j){var l=k.toByteArraySigned();var i=j.toByteArraySigned();var m=[];m.push(2);m.push(l.length);m=m.concat(l);m.push(2);m.push(i.length);m=m.concat(i);m.unshift(m.length);m.unshift(48);return m};this.parseSig=function(n){var m;if(n[0]!=48){throw new Error(\"Signature not a valid DERSequence\")}m=2;if(n[m]!=2){throw new Error(\"First element in signature must be a DERInteger\")}var l=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];if(n[m]!=2){throw new Error(\"Second element in signature must be a DERInteger\")}var i=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];var k=BigInteger.fromByteArrayUnsigned(l);var j=BigInteger.fromByteArrayUnsigned(i);return{r:k,s:j}};this.parseSigCompact=function(m){if(m.length!==65){throw\"Signature has the wrong length\"}var j=m[0]-27;if(j<0||j>7){throw\"Invalid signature type\"}var o=this.ecparams.n;var l=BigInteger.fromByteArrayUnsigned(m.slice(1,33)).mod(o);var k=BigInteger.fromByteArrayUnsigned(m.slice(33,65)).mod(o);return{r:l,s:k,i:j}};this.readPKCS5PrvKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var i,k,o;try{i=p(l,0,[2,0],\"06\");k=p(l,0,[1],\"04\");try{o=p(l,0,[3,0],\"03\").substr(2)}catch(j){}}catch(j){throw\"malformed PKCS#1/5 plain ECC private key\"}this.curveName=m(i);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o);this.setPrivateKeyHex(k);this.isPublic=false};this.readPKCS8PrvKeyHex=function(l){var q=ASN1HEX;var i=KJUR.crypto.ECDSA.getName;var n=q.getVbyList;if(q.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var j,p,m,k;try{j=n(l,0,[1,0],\"06\");p=n(l,0,[1,1],\"06\");m=n(l,0,[2,0,1],\"04\");try{k=n(l,0,[2,0,2,0],\"03\").substr(2)}catch(o){}}catch(o){throw\"malformed PKCS#8 plain ECC private key\"}this.curveName=i(p);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(k);this.setPrivateKeyHex(m);this.isPublic=false};this.readPKCS8PubKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var k,i,o;try{k=p(l,0,[0,0],\"06\");i=p(l,0,[0,1],\"06\");o=p(l,0,[1],\"03\").substr(2)}catch(j){throw\"malformed PKCS#8 ECC public key\"}this.curveName=m(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o)};this.readCertPubKeyHex=function(k,p){if(p!==5){p=6}var m=ASN1HEX;var l=KJUR.crypto.ECDSA.getName;var o=m.getVbyList;if(m.isASN1HEX(k)===false){throw\"not ASN.1 hex string\"}var i,n;try{i=o(k,0,[0,p,0,1],\"06\");n=o(k,0,[0,p,1],\"03\").substr(2)}catch(j){throw\"malformed X.509 certificate ECC public key\"}this.curveName=l(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(n)};if(h!==undefined){if(h.curve!==undefined){this.curveName=h.curve}}if(this.curveName===undefined){this.curveName=e}this.setNamedCurve(this.curveName);if(h!==undefined){if(h.prv!==undefined){this.setPrivateKeyHex(h.prv)}if(h.pub!==undefined){this.setPublicKeyHex(h.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX;var i=j.getChildIdx;var g=j.getV;if(f.substr(0,2)!=\"30\"){throw\"signature is not a ASN.1 sequence\"}var h=i(f,0);if(h.length!=2){throw\"number of signature ASN.1 sequence elements seem wrong\"}var e=h[0];var d=h[1];if(f.substr(e,2)!=\"02\"){throw\"1st item of sequene of signature is not ASN.1 integer\"}if(f.substr(d,2)!=\"02\"){throw\"2nd item of sequene of signature is not ASN.1 integer\"}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(c){var d=KJUR.crypto.ECDSA.parseSigHexInHexRS(c);var b=d.r;var a=d.s;if(b.substr(0,2)==\"00\"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)==\"00\"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b=\"00\"+b}if((a.length%32)==30){a=\"00\"+a}if(b.length%32!=0){throw\"unknown ECDSA sig r length error\"}if(a.length%32!=0){throw\"unknown ECDSA sig s length error\"}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if((((a.length/2)*8)%(16*8))!=0){throw\"unknown ECDSA concatinated r-s sig length error\"}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.getEncodedHex()};KJUR.crypto.ECDSA.getName=function(a){if(a===\"2a8648ce3d030107\"){return\"secp256r1\"}if(a===\"2b8104000a\"){return\"secp256k1\"}if(a===\"2b81040022\"){return\"secp384r1\"}if(\"|secp256r1|NIST P-256|P-256|prime256v1|\".indexOf(a)!==-1){return\"secp256r1\"}if(\"|secp256k1|\".indexOf(a)!==-1){return\"secp256k1\"}if(\"|secp384r1|NIST P-384|P-384|\".indexOf(a)!==-1){return\"secp384r1\"}return null};\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.crypto==\"undefined\"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!=\"undefined\"){d=c[e]}if(typeof b[d]!=\"undefined\"){return b[d]}throw\"unregistered EC curve name: \"+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex(\"04\"+f+k);b[A][\"name\"]=A;b[A][\"keylen\"]=l;b[A][\"curve\"]=r;b[A][\"G\"]=q;b[A][\"n\"]=t;b[A][\"h\"]=w;b[A][\"oid\"]=d;b[A][\"info\"]=x;for(var v=0;v1){g=new BigInteger(i,16)}else{g=null}h=new BigInteger(j,16);this.setPrivate(c,a,e,g,h)};this.setPublic=function(c,b,a,d){this.isPublic=true;this.p=c;this.q=b;this.g=a;this.y=d;this.x=null};this.setPublicHex=function(f,e,d,g){var b,a,h,c;b=new BigInteger(f,16);a=new BigInteger(e,16);h=new BigInteger(d,16);c=new BigInteger(g,16);this.setPublic(b,a,h,c)};this.signWithMessageHash=function(d){var c=this.p;var b=this.q;var f=this.g;var i=this.y;var j=this.x;var e=KJUR.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),b.subtract(BigInteger.ONE));var l=d.substr(0,b.bitLength()/4);var h=new BigInteger(l,16);var a=(f.modPow(e,c)).mod(b);var n=(e.modInverse(b).multiply(h.add(j.multiply(a)))).mod(b);var m=KJUR.asn1.ASN1Util.jsonToASN1HEX({seq:[{\"int\":{bigint:a}},{\"int\":{bigint:n}}]});return m};this.verifyWithMessageHash=function(h,f){var d=this.p;var b=this.q;var j=this.g;var l=this.y;var i=this.parseASN1Signature(f);var a=i[0];var t=i[1];var o=h.substr(0,b.bitLength()/4);var k=new BigInteger(o,16);if(BigInteger.ZERO.compareTo(a)>0||a.compareTo(b)>0){throw\"invalid DSA signature\"}if(BigInteger.ZERO.compareTo(t)>=0||t.compareTo(b)>0){throw\"invalid DSA signature\"}var m=t.modInverse(b);var e=k.multiply(m).mod(b);var c=a.multiply(m).mod(b);var n=j.modPow(e,d).multiply(l.modPow(c,d)).mod(d).mod(b);return n.compareTo(a)==0};this.parseASN1Signature=function(a){try{var d=new BigInteger(ASN1HEX.getVbyList(a,0,[0],\"02\"),16);var c=new BigInteger(ASN1HEX.getVbyList(a,0,[1],\"02\"),16);return[d,c]}catch(b){throw\"malformed ASN.1 DSA signature\"}};this.readPKCS5PrvKeyHex=function(c){var b,a,f,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[1],\"02\");a=d(c,0,[2],\"02\");f=d(c,0,[3],\"02\");g=d(c,0,[4],\"02\");i=d(c,0,[5],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed PKCS#1/5 plain DSA private key\"}this.setPrivateHex(b,a,f,g,i)};this.readPKCS8PrvKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[1,1,0],\"02\");c=i(d,0,[1,1,1],\"02\");b=i(d,0,[1,1,2],\"02\");g=i(d,0,[2,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 plain DSA private key\"}this.setPrivateHex(f,c,b,null,g)};this.readPKCS8PubKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[0,1,0],\"02\");c=i(d,0,[0,1,1],\"02\");b=i(d,0,[0,1,2],\"02\");g=i(d,0,[1,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 DSA public key\"}this.setPublicHex(f,c,b,g)};this.readCertPubKeyHex=function(c,f){if(f!==5){f=6}var b,a,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[0,f,0,1,0],\"02\");a=d(c,0,[0,f,0,1,1],\"02\");g=d(c,0,[0,f,0,1,2],\"02\");i=d(c,0,[0,f,1,0],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed X.509 certificate DSA public key\"}this.setPublicHex(b,a,g,i)}};\nvar KEYUTIL=function(){var d=function(p,r,q){return k(CryptoJS.AES,p,r,q)};var e=function(p,r,q){return k(CryptoJS.TripleDES,p,r,q)};var a=function(p,r,q){return k(CryptoJS.DES,p,r,q)};var k=function(s,x,u,q){var r=CryptoJS.enc.Hex.parse(x);var w=CryptoJS.enc.Hex.parse(u);var p=CryptoJS.enc.Hex.parse(q);var t={};t.key=w;t.iv=p;t.ciphertext=r;var v=s.decrypt(t,w,{iv:p});return CryptoJS.enc.Hex.stringify(v)};var l=function(p,r,q){return g(CryptoJS.AES,p,r,q)};var o=function(p,r,q){return g(CryptoJS.TripleDES,p,r,q)};var f=function(p,r,q){return g(CryptoJS.DES,p,r,q)};var g=function(t,y,v,q){var s=CryptoJS.enc.Hex.parse(y);var x=CryptoJS.enc.Hex.parse(v);var p=CryptoJS.enc.Hex.parse(q);var w=t.encrypt(s,x,{iv:p});var r=CryptoJS.enc.Hex.parse(w.toString());var u=CryptoJS.enc.Base64.stringify(r);return u};var i={\"AES-256-CBC\":{proc:d,eproc:l,keylen:32,ivlen:16},\"AES-192-CBC\":{proc:d,eproc:l,keylen:24,ivlen:16},\"AES-128-CBC\":{proc:d,eproc:l,keylen:16,ivlen:16},\"DES-EDE3-CBC\":{proc:e,eproc:o,keylen:24,ivlen:8},\"DES-CBC\":{proc:a,eproc:f,keylen:8,ivlen:8}};var c=function(p){return i[p][\"proc\"]};var m=function(p){var r=CryptoJS.lib.WordArray.random(p);var q=CryptoJS.enc.Hex.stringify(r);return q};var n=function(v){var w={};var q=v.match(new RegExp(\"DEK-Info: ([^,]+),([0-9A-Fa-f]+)\",\"m\"));if(q){w.cipher=q[1];w.ivsalt=q[2]}var p=v.match(new RegExp(\"-----BEGIN ([A-Z]+) PRIVATE KEY-----\"));if(p){w.type=p[1]}var u=-1;var x=0;if(v.indexOf(\"\\r\\n\\r\\n\")!=-1){u=v.indexOf(\"\\r\\n\\r\\n\");x=2}if(v.indexOf(\"\\n\\n\")!=-1){u=v.indexOf(\"\\n\\n\");x=1}var t=v.indexOf(\"-----END\");if(u!=-1&&t!=-1){var r=v.substring(u+x*2,t-x);r=r.replace(/\\s+/g,\"\");w.data=r}return w};var j=function(q,y,p){var v=p.substring(0,16);var t=CryptoJS.enc.Hex.parse(v);var r=CryptoJS.enc.Utf8.parse(y);var u=i[q][\"keylen\"]+i[q][\"ivlen\"];var x=\"\";var w=null;for(;;){var s=CryptoJS.algo.MD5.create();if(w!=null){s.update(w)}s.update(r);s.update(t);w=s.finalize();x=x+CryptoJS.enc.Hex.stringify(w);if(x.length>=u*2){break}}var z={};z.keyhex=x.substr(0,i[q][\"keylen\"]*2);z.ivhex=x.substr(i[q][\"keylen\"]*2,i[q][\"ivlen\"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v][\"proc\"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s][\"eproc\"];var t=r(p,q,u);return t};return{version:\"1.0.0\",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p=\"\";if(typeof t==\"undefined\"||t==null){t=\"AES-256-CBC\"}if(typeof i[t]==\"undefined\"){throw\"KEYUTIL unsupported algorithm: \"+t}if(typeof r==\"undefined\"||r==null){var v=i[t][\"ivlen\"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,\"$1\\r\\n\");var p=\"-----BEGIN \"+x+\" PRIVATE KEY-----\\r\\n\";p+=\"Proc-Type: 4,ENCRYPTED\\r\\n\";p+=\"DEK-Info: \"+t+\",\"+r+\"\\r\\n\";p+=\"\\r\\n\";p+=q;p+=\"\\r\\n-----END \"+x+\" PRIVATE KEY-----\\r\\n\";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw\"malformed format: SEQUENCE(0).items != 2: \"+r.length}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0).items != 2: \"+A.length}if(w(y,A[0])!=\"2a864886f70d01050d\"){throw\"this only supports pkcs5PBES2\"}var p=z(y,A[1]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0.1).items != 2: \"+p.length}var q=z(y,p[1]);if(q.length!=2){throw\"malformed format: SEQUENCE(0.0.1.1).items != 2: \"+q.length}if(w(y,q[0])!=\"2a864886f70d0307\"){throw\"this only supports TripleDES\"}t.encryptionSchemeAlg=\"TripleDES\";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw\"malformed format: SEQUENCE(0.0.1.0).items != 2: \"+s.length}if(w(y,s[0])!=\"2a864886f70d01050c\"){throw\"this only supports pkcs5PBKDF2\"}var x=z(y,s[1]);if(x.length<2){throw\"malformed format: SEQUENCE(0.0.1.0.1).items < 2: \"+x.length}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw\"malformed format pbkdf2Iter: \"+u}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,\"ENCRYPTED PRIVATE KEY\");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!=\"30\"){throw\"malformed plain PKCS8 private key(code:001)\"}var r=u(s,0);if(r.length!=3){throw\"malformed plain PKCS8 private key(code:002)\"}if(s.substr(r[1],2)!=\"30\"){throw\"malformed PKCS8 private key(code:003)\"}var p=u(s,r[1]);if(p.length!=2){throw\"malformed PKCS8 private key(code:004)\"}if(s.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 private key(code:005)\"}q.algoid=t(s,p[0]);if(s.substr(p[1],2)==\"06\"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!=\"04\"){throw\"malformed PKCS8 private key(code:006)\"}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,\"PRIVATE KEY\");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid==\"2a864886f70d010101\"){r=new RSAKey()}else{if(q.algoid==\"2a8648ce380401\"){r=new KJUR.crypto.DSA()}else{if(q.algoid==\"2a8648ce3d0201\"){r=new KJUR.crypto.ECDSA()}else{throw\"unsupported private key algorithm\"}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],\"06\");if(r===\"2a864886f70d010101\"){p=new RSAKey()}else{if(r===\"2a8648ce380401\"){p=new KJUR.crypto.DSA()}else{if(r===\"2a8648ce3d0201\"){p=new KJUR.crypto.ECDSA()}else{throw\"unsupported PKCS#8 public key hex\"}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!=\"30\"){throw\"malformed RSA key(code:001)\"}var q=t(r,0);if(q.length!=2){throw\"malformed RSA key(code:002)\"}if(r.substr(q[0],2)!=\"02\"){throw\"malformed RSA key(code:003)\"}p.n=s(r,q[0]);if(r.substr(q[1],2)!=\"02\"){throw\"malformed RSA key(code:004)\"}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw\"outer DERSequence shall have 2 elements: \"+r.length}var w=r[0];if(t.substr(w,2)!=\"30\"){throw\"malformed PKCS8 public key(code:001)\"}var p=u(t,w);if(p.length!=2){throw\"malformed PKCS8 public key(code:002)\"}if(t.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 public key(code:003)\"}q.algoid=s(t,p[0]);if(t.substr(p[1],2)==\"06\"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)==\"30\"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],\"02\");q.algparam.q=v.getVbyList(t,p[1],[1],\"02\");q.algparam.g=v.getVbyList(t,p[1],[2],\"02\")}}if(t.substr(r[1],2)!=\"03\"){throw\"malformed PKCS8 public key(code:004)\"}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!=\"undefined\"&&l instanceof w){return l}if(typeof i!=\"undefined\"&&l instanceof i){return l}if(typeof C!=\"undefined\"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;j.setPublicKeyHex(u);return j}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;var b=(\"0000000000\"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n===\"pkcs5prv\"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)===\"04\"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw\"unsupported PKCS#1/5 hexadecimal key\"}}}return P}if(n===\"pkcs8prv\"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n===\"pkcs8pub\"){return F._getKeyFromPublicPKCS8Hex(l)}if(n===\"x509pub\"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf(\"-END CERTIFICATE-\",0)!=-1||l.indexOf(\"-END X509 CERTIFICATE-\",0)!=-1||l.indexOf(\"-END TRUSTED CERTIFICATE-\",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf(\"-END PUBLIC KEY-\")!=-1){var O=pemtohex(l,\"PUBLIC KEY\");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var m=M(l,\"RSA PRIVATE KEY\");return F.getKey(m,null,\"pkcs5prv\")}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var I=M(l,\"DSA PRIVATE KEY\");var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END PRIVATE KEY-\")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf(\"-END EC PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],\"04\");var f=d(I,0,[2,0],\"06\");var A=d(I,0,[3,0],\"03\").substr(2);var e=\"\";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw\"undefined OID(hex) in KJUR.crypto.OID: \"+f}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END ENCRYPTED PRIVATE KEY-\")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw\"not supported argument\"};KEYUTIL.generateKeypair=function(a,c){if(a==\"RSA\"){var b=c;var h=new RSAKey();h.generate(b,\"10001\");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a==\"EC\"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw\"unknown algorithm: \"+a}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.n}},{\"int\":s.e},{\"int\":{bigint:s.d}},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.dmp1}},{\"int\":{bigint:s.dmq1}},{\"int\":{bigint:s.coeff}}]});return G}function B(G){var s=l({seq:[{\"int\":1},{octstr:{hex:G.prvKeyHex}},{tag:[\"a0\",true,{oid:{name:G.curveName}}]},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+G.pubKeyHex}}]}]});return s}function x(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.g}},{\"int\":{bigint:s.y}},{\"int\":{bigint:s.x}}]});return G}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D==\"PKCS8PUB\")){var E=new C(b);var w=E.getEncodedHex();return hextopem(w,\"PUBLIC KEY\")}if(D==\"PKCS1PRV\"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();return hextopem(w,\"RSA PRIVATE KEY\")}if(D==\"PKCS1PRV\"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.getEncodedHex();var h=B(b);var t=h.getEncodedHex();var p=\"\";p+=hextopem(v,\"EC PARAMETERS\");p+=hextopem(t,\"EC PRIVATE KEY\");return p}if(D==\"PKCS1PRV\"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();return hextopem(w,\"DSA PRIVATE KEY\")}if(D==\"PKCS5PRV\"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"RSA\",w,y,m,j)}if(D==\"PKCS5PRV\"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"EC\",w,y,m,j)}if(D==\"PKCS5PRV\"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"DSA\",w,y,m,j)}var o=function(G,s){var I=c(G,s);var H=new l({seq:[{seq:[{oid:{name:\"pkcs5PBES2\"}},{seq:[{seq:[{oid:{name:\"pkcs5PBKDF2\"}},{seq:[{octstr:{hex:I.pbkdf2Salt}},{\"int\":I.pbkdf2Iter}]}]},{seq:[{oid:{name:\"des-EDE3-CBC\"}},{octstr:{hex:I.encryptionSchemeIV}}]}]}]},{octstr:{hex:I.ciphertext}}]});return H.getEncodedHex()};var c=function(N,O){var H=100;var M=CryptoJS.lib.WordArray.random(8);var L=\"DES-EDE3-CBC\";var s=CryptoJS.lib.WordArray.random(8);var I=CryptoJS.PBKDF2(O,M,{keySize:192/32,iterations:H});var J=CryptoJS.enc.Hex.parse(N);var K=CryptoJS.TripleDES.encrypt(J,I,{iv:s})+\"\";var G={};G.ciphertext=K;G.pbkdf2Salt=CryptoJS.enc.Hex.stringify(M);G.pbkdf2Iter=H;G.encryptionSchemeAlg=L;G.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return G};if(D==\"PKCS8PRV\"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"rsaEncryption\"}},{\"null\":true}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var g=new l({seq:[{\"int\":1},{octstr:{hex:b.prvKeyHex}},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+b.pubKeyHex}}]}]});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"ecPublicKey\"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"dsa\"}},{seq:[{\"int\":{bigint:b.p}},{\"int\":{bigint:b.q}},{\"int\":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}throw\"unsupported object nor format\"};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,\"CERTIFICATE REQUEST\");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,\"pkcs8pub\");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!=\"30\"){throw\"malformed CSR(code:001)\"}var e=f(g,0);if(e.length<1){throw\"malformed CSR(code:002)\"}if(g.substr(e[0],2)!=\"30\"){throw\"malformed CSR(code:003)\"}var a=f(g,e[0]);if(a.length<3){throw\"malformed CSR(code:004)\"}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getJWKFromKey=function(d){var b={};if(d instanceof RSAKey&&d.isPrivate){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));b.d=hextob64u(d.d.toString(16));b.p=hextob64u(d.p.toString(16));b.q=hextob64u(d.q.toString(16));b.dp=hextob64u(d.dmp1.toString(16));b.dq=hextob64u(d.dmq1.toString(16));b.qi=hextob64u(d.coeff.toString(16));return b}else{if(d instanceof RSAKey&&d.isPublic){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPrivate){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);b.d=hextob64u(d.prvKeyHex);return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPublic){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);return b}}}}throw\"not supported key object\"};\nRSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,j,l,b,a,f,d,k;var m=ASN1HEX;var g=m.getVbyList;if(m.isASN1HEX(e)===false){throw\"not ASN.1 hex string\"}try{c=g(e,0,[2,0,1],\"02\");j=g(e,0,[2,0,2],\"02\");l=g(e,0,[2,0,3],\"02\");b=g(e,0,[2,0,4],\"02\");a=g(e,0,[2,0,5],\"02\");f=g(e,0,[2,0,6],\"02\");d=g(e,0,[2,0,7],\"02\");k=g(e,0,[2,0,8],\"02\")}catch(i){throw\"malformed PKCS#8 plain RSA private key\"}this.setPrivateEx(c,j,l,b,a,f,d,k)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw\"keyHex is not ASN.1 hex string\"}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!==\"02\"||c.substr(a[1],2)!==\"02\"){throw\"wrong hex for PKCS#5 public key\"}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw\"not ASN.1 hex string\"}if(c.getTLVbyList(b,0,[0,0])!==\"06092a864886f70d010101\"){throw\"not PKCS8 RSA public key\"}var a=c.getTLVbyList(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)};\nvar _RE_HEXDECONLY=new RegExp(\"\");_RE_HEXDECONLY.compile(\"[^0-9a-f]\",\"gi\");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c=\"\";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw\"invalid salt length\"}}}if(c<(g+k+2)){throw\"data too long\"}var f=\"\";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dthis.n.bitLength()){return 0}var i=this.doPublic(b);var e=i.toString(16).replace(/^1f+00/,\"\");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(k){return KJUR.crypto.Util.hashString(k,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){a=a.replace(_RE_HEXDECONLY,\"\");a=a.replace(/[ \\n]+/g,\"\");var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,\"\");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){var k=new BigInteger(s,16);if(k.bitLength()>this.n.bitLength()){return false}var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw\"invalid salt length\"}}}if(m<(h+c+2)){throw\"data too long\"}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw\"bits beyond keysize not zero\"}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q0){var b=\":\"+n.join(\":\")+\":\";if(b.indexOf(\":\"+k+\":\")==-1){throw\"algorithm '\"+k+\"' not accepted in the list\"}}if(k!=\"none\"&&B===null){throw\"key shall be specified to verify.\"}if(typeof B==\"string\"&&B.indexOf(\"-----BEGIN \")!=-1){B=KEYUTIL.getKey(B)}if(z==\"RS\"||z==\"PS\"){if(!(B instanceof m)){throw\"key shall be a RSAKey obj for RS* and PS* algs\"}}if(z==\"ES\"){if(!(B instanceof p)){throw\"key shall be a ECDSA obj for ES* algs\"}}if(k==\"none\"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw\"unsupported alg name: \"+k}else{u=t.jwsalg2sigalg[k]}if(u==\"none\"){throw\"not supported\"}else{if(u.substr(0,4)==\"Hmac\"){var o=null;if(B===undefined){throw\"hexadecimal key shall be specified for HMAC\"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf(\"withECDSA\")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(\".\");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw\"malformed sJWS: wrong number of '.' splitted elements\"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null,\" \");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null,\" \")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;var k=e.split(\".\");var c=k[0];var i=k[1];var q=c+\".\"+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw\"acceptField.alg shall be specified\"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss===\"object\"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub===\"object\"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud===\"object\"){if(typeof g.aud==\"string\"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud==\"object\"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt===\"number\"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!==\"number\"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp==\"number\"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw\"addSignature failed: \"+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw\"malformed header\"}if(typeof g.payload===\"string\"){this.sPayload=g.payload}else{throw\"malformed signatures\"}if(g.signatures.length>0){this.aSignatures=g.signatures}else{throw\"malformed signatures\"}}catch(e){throw\"malformed JWS-JS JSON object: \"+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}};\nexports.SecureRandom = SecureRandom;\nexports.rng_seed_time = rng_seed_time;\n\nexports.BigInteger = BigInteger;\nexports.RSAKey = RSAKey;\nexports.ECDSA = KJUR.crypto.ECDSA;\nexports.DSA = KJUR.crypto.DSA;\nexports.Signature = KJUR.crypto.Signature;\nexports.MessageDigest = KJUR.crypto.MessageDigest;\nexports.Mac = KJUR.crypto.Mac;\nexports.Cipher = KJUR.crypto.Cipher;\nexports.KEYUTIL = KEYUTIL;\nexports.ASN1HEX = ASN1HEX;\nexports.X509 = X509;\nexports.CryptoJS = CryptoJS;\n\n// ext/base64.js\nexports.b64tohex = b64tohex;\nexports.b64toBA = b64toBA;\n\n// base64x.js\nexports.stoBA = stoBA;\nexports.BAtos = BAtos;\nexports.BAtohex = BAtohex;\nexports.stohex = stohex;\nexports.stob64 = stob64;\nexports.stob64u = stob64u;\nexports.b64utos = b64utos;\nexports.b64tob64u = b64tob64u;\nexports.b64utob64 = b64utob64;\nexports.hex2b64 = hex2b64;\nexports.hextob64u = hextob64u;\nexports.b64utohex = b64utohex;\nexports.utf8tob64u = utf8tob64u;\nexports.b64utoutf8 = b64utoutf8;\nexports.utf8tob64 = utf8tob64;\nexports.b64toutf8 = b64toutf8;\nexports.utf8tohex = utf8tohex;\nexports.hextoutf8 = hextoutf8;\nexports.hextorstr = hextorstr;\nexports.rstrtohex = rstrtohex;\nexports.hextob64 = hextob64;\nexports.hextob64nl = hextob64nl;\nexports.b64nltohex = b64nltohex;\nexports.hextopem = hextopem;\nexports.pemtohex = pemtohex;\nexports.hextoArrayBuffer = hextoArrayBuffer;\nexports.ArrayBuffertohex = ArrayBuffertohex;\nexports.zulutomsec = zulutomsec;\nexports.zulutosec = zulutosec;\nexports.zulutodate = zulutodate;\nexports.datetozulu = datetozulu;\nexports.uricmptohex = uricmptohex;\nexports.hextouricmp = hextouricmp;\nexports.ipv6tohex = ipv6tohex;\nexports.hextoipv6 = hextoipv6;\nexports.hextoip = hextoip;\nexports.iptohex = iptohex;\nexports.encodeURIComponentAll = encodeURIComponentAll;\nexports.newline_toUnix = newline_toUnix;\nexports.newline_toDos = newline_toDos;\nexports.hextoposhex = hextoposhex;\nexports.intarystrtohex = intarystrtohex;\nexports.strdiffidx = strdiffidx;\n\n// name spaces\nexports.KJUR = KJUR;\nexports.crypto = KJUR.crypto;\nexports.asn1 = KJUR.asn1;\nexports.jws = KJUR.jws;\nexports.lang = KJUR.lang;\n\n\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://AppID/./node_modules/jsrsasign/lib/jsrsasign.js?"); - -/***/ }), - -/***/ "./node_modules/node-fetch/browser.js": -/*!********************************************!*\ - !*** ./node_modules/node-fetch/browser.js ***! - \********************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("\n\n// ref: https://github.com/tc39/proposal-global\nvar getGlobal = function () {\n\t// the only reliable means to get the global object is\n\t// `Function('return this')()`\n\t// However, this causes CSP violations in Chrome apps.\n\tif (typeof self !== 'undefined') { return self; }\n\tif (typeof window !== 'undefined') { return window; }\n\tif (typeof global !== 'undefined') { return global; }\n\tthrow new Error('unable to locate global object');\n}\n\nvar global = getGlobal();\n\nmodule.exports = exports = global.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = global.fetch.bind(global);\n\nexports.Headers = global.Headers;\nexports.Request = global.Request;\nexports.Response = global.Response;\n\n//# sourceURL=webpack://AppID/./node_modules/node-fetch/browser.js?"); - -/***/ }), - -/***/ "./node_modules/webpack/buildin/global.js": -/*!***********************************!*\ - !*** (webpack)/buildin/global.js ***! - \***********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://AppID/(webpack)/buildin/global.js?"); - -/***/ }), - -/***/ "./package.json": -/*!**********************!*\ - !*** ./package.json ***! - \**********************/ -/*! exports provided: name, version, description, scripts, repository, main, nyc, dependencies, devDependencies, default */ -/***/ (function(module) { - -eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"ibmcloud-appid-js\\\",\\\"version\\\":\\\"0.3.0\\\",\\\"description\\\":\\\"IBM Cloud App ID SDK for Single Page Applications\\\",\\\"scripts\\\":{\\\"build\\\":\\\"webpack --mode=development\\\",\\\"test\\\":\\\"mocha\\\",\\\"coverage\\\":\\\"nyc --reporter=lcov mocha\\\",\\\"docs\\\":\\\"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json\\\"},\\\"repository\\\":{\\\"type\\\":\\\"git\\\",\\\"url\\\":\\\"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git\\\"},\\\"main\\\":\\\"dist/appid.umd.min.js\\\",\\\"nyc\\\":{\\\"all\\\":true,\\\"include\\\":[\\\"src/*.js\\\"],\\\"exclude\\\":[\\\"**/PopupController.js\\\",\\\"**/IFrameController.js\\\",\\\"**/OpenIDConfigurationResource.js\\\",\\\"**/constants.js\\\"]},\\\"dependencies\\\":{\\\"jsrsasign\\\":\\\"^8.0.12\\\"},\\\"devDependencies\\\":{\\\"node-fetch\\\":\\\"^2.6.0\\\",\\\"@babel/cli\\\":\\\"^7.0.0\\\",\\\"@babel/core\\\":\\\"^7.5.5\\\",\\\"@babel/plugin-transform-runtime\\\":\\\"^7.5.5\\\",\\\"@babel/preset-env\\\":\\\"^7.5.5\\\",\\\"babel-cli\\\":\\\"^7.0.0-beta.3\\\",\\\"chai\\\":\\\"^4.2.0\\\",\\\"coveralls\\\":\\\"^3.0.6\\\",\\\"gulp-babel\\\":\\\"^8.0.0\\\",\\\"mocha\\\":\\\"^6.2.0\\\",\\\"nyc\\\":\\\"^14.1.1\\\",\\\"webpack\\\":\\\"^4.39.1\\\",\\\"webpack-cli\\\":\\\"^3.3.6\\\",\\\"docdash\\\":\\\"^1.1.1\\\",\\\"jsdoc\\\":\\\"^3.6.3\\\"}}\");\n\n//# sourceURL=webpack://AppID/./package.json?"); - -/***/ }), - -/***/ "./src/IFrameController.js": -/*!*********************************!*\ - !*** ./src/IFrameController.js ***! - \*********************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const IFrameError = __webpack_require__(/*! ./errors/IFrameError */ \"./src/errors/IFrameError.js\");\n\nclass IFrameController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t}\n\n\topen(url) {\n\t\tthis.iFrame = this.window.document.createElement('iframe');\n\t\tthis.iFrame.src = url;\n\t\tthis.iFrame.width = 0;\n\t\tthis.iFrame.height = 0;\n\t\tthis.window.document.body.appendChild(this.iFrame);\n\t}\n\n\tremove() {\n\t\twindow.document.body.removeChild(this.iFrame);\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\treject(new IFrameError('Silent sign-in timed out'));\n\t\t\t}, 5 * 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tclearInterval(timer);\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = IFrameController;\n\n\n//# sourceURL=webpack://AppID/./src/IFrameController.js?"); - -/***/ }), - -/***/ "./src/OpenIDConfigurationResource.js": -/*!********************************************!*\ - !*** ./src/OpenIDConfigurationResource.js ***! - \********************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const packagejson = __webpack_require__(/*! ../package.json */ \"./package.json\");\n\nclass OpenIdConfigurationResource {\n\tasync init({discoveryEndpoint, requestHandler}){\n\t\tthis.openIdConfig = await requestHandler(discoveryEndpoint);\n\t\tconst headers = { 'x-filter-type': `spa:v${packagejson.version}` };\n\t\tthis.publicKeys = requestHandler(this.getJwksEndpoint(), { headers: headers });\n\t}\n\n\tgetAuthorizationEndpoint() {\n\t\treturn this.openIdConfig.authorization_endpoint;\n\t}\n\n\tgetUserInfoEndpoint() {\n\t\treturn this.openIdConfig.userinfo_endpoint;\n\t}\n\n\tgetJwksEndpoint() {\n\t\treturn this.openIdConfig.jwks_uri;\n\t}\n\n\tgetTokenEndpoint() {\n\t\treturn this.openIdConfig.token_endpoint;\n\t}\n\n\tgetIssuer() {\n\t\treturn this.openIdConfig.issuer;\n\t}\n\n\tasync getPublicKeys() {\n\t\treturn await this.publicKeys;\n\t}\n}\nmodule.exports = OpenIdConfigurationResource;\n\n\n\n//# sourceURL=webpack://AppID/./src/OpenIDConfigurationResource.js?"); - -/***/ }), - -/***/ "./src/PopupController.js": -/*!********************************!*\ - !*** ./src/PopupController.js ***! - \********************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const PopupError = __webpack_require__(/*! ./errors/PopupError */ \"./src/errors/PopupError.js\");\n\nclass PopupController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t};\n\n\tinit(popupConfig){\n\t\tthis.popupConfig = popupConfig;\n\t}\n\n\topen() {\n\t\tconst h = this.popupConfig.height;\n\t\tconst w = this.popupConfig.width;\n\t\tconst left = (window.screen.width - w) / 2;\n\t\tconst top = (window.screen.height - h) / 2;\n\t\tthis.popup = this.window.open('', 'popup', `left=${left},top=${top},width=${w},height=${h},resizable,scrollbars=yes,status=1`);\n\t\tif (!this.popup) {\n\t\t\tthrow new PopupError('Unable to open popup')\n\t\t}\n\t};\n\n\tnavigate(url) {\n\t\tthis.popup.location.href = url;\n\t};\n\n\tclose() {\n\t\tthis.popup.close();\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\tif(this.popup.closed) {\n\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\treject(new PopupError('Popup closed'));\n\t\t\t\t}\n\t\t\t}, 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = PopupController;\n\n\n//# sourceURL=webpack://AppID/./src/PopupController.js?"); - -/***/ }), - -/***/ "./src/RequestHandler.js": -/*!*******************************!*\ - !*** ./src/RequestHandler.js ***! - \*******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tdebugger;\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tdebugger;\n\t\t\tif (text.includes('id token not generated with cloud directory idp')) {\n\t\t\t\tthrow new RequestError(`${JSON.parse(text).error_description}`, response.status);\n\t\t\t} else {\n\t\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t\t}\n\t\t}\n\t\t\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tif (text !== '') {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); - -/***/ }), - -/***/ "./src/TokenValidator.js": -/*!*******************************!*\ - !*** ./src/TokenValidator.js ***! - \*******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg: [constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif (nonce && (!decoded.payloadObj.nonce || decoded.payloadObj.nonce !== nonce)) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\n\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); - -/***/ }), - -/***/ "./src/constants.js": -/*!**************************!*\ - !*** ./src/constants.js ***! - \**************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN: 'Invalid id token',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN: 'Missing id token string',\n\tMISSING_ID_TOKEN_PAYLOAD: 'Missing id token payload',\n\tMISSING_TOKENS: 'Missing tokens',\n\tMISSING_ACCESS_TOKEN: 'Missing access token string',\n\tMISSING_ID_TOKEN: 'Missing access token string',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tGENERATE_CODE: '/cloud_directory/generate_code',\n\tCHANGE_DETAILS: '/cloud_directory/change_details',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); - -/***/ }), - -/***/ "./src/errors/AppIDError.js": -/*!**********************************!*\ - !*** ./src/errors/AppIDError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class AppIDError extends Error {}\nmodule.exports = AppIDError;\n\n//# sourceURL=webpack://AppID/./src/errors/AppIDError.js?"); - -/***/ }), - -/***/ "./src/errors/IFrameError.js": -/*!***********************************!*\ - !*** ./src/errors/IFrameError.js ***! - \***********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class IFrameError extends Error {}\nmodule.exports = IFrameError;\n\n//# sourceURL=webpack://AppID/./src/errors/IFrameError.js?"); - -/***/ }), - -/***/ "./src/errors/OAuthError.js": -/*!**********************************!*\ - !*** ./src/errors/OAuthError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class OAuthError extends Error {\n\t// See https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for the possible error messages\n\tconstructor({error, description}) {\n\t\tsuper(description || error);\n\t\tthis.error = error;\n\t\tthis.description = description;\n\t}\n}\nmodule.exports = OAuthError;\n\n//# sourceURL=webpack://AppID/./src/errors/OAuthError.js?"); - -/***/ }), - -/***/ "./src/errors/PopupError.js": -/*!**********************************!*\ - !*** ./src/errors/PopupError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class PopupError extends Error {}\nmodule.exports = PopupError;\n\n//# sourceURL=webpack://AppID/./src/errors/PopupError.js?"); - -/***/ }), - -/***/ "./src/errors/RequestError.js": -/*!************************************!*\ - !*** ./src/errors/RequestError.js ***! - \************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class RequestError extends Error {\n\tconstructor(description, status, originError) {\n\t\tsuper(description);\n\t\tthis.status = status;\n\t\tthis.originError = originError;\n\t}\n}\nmodule.exports = RequestError;\n\n//# sourceURL=webpack://AppID/./src/errors/RequestError.js?"); - -/***/ }), - -/***/ "./src/errors/TokenError.js": -/*!**********************************!*\ - !*** ./src/errors/TokenError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class TokenError extends Error {}\nmodule.exports = TokenError;\n\n//# sourceURL=webpack://AppID/./src/errors/TokenError.js?"); - -/***/ }), - -/***/ "./src/index.js": -/*!**********************!*\ - !*** ./src/index.js ***! - \**********************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\")\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in allows you to automatically obtain new tokens for a user without the user having to re-authenticate using a popup.\n\t * This will attempt to authenticate the user in a hidden iframe.\n\t * You will need to [enable Cloud Directory SSO]{@link https://cloud.ibm.com/docs/services/appid?topic=appid-single-page#spa-silent-login}.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {string} idToken A JWT.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @example\n\t * let tokens = await appID.changePassword(idToken);\n\t */\n\tasync changePassword(idToken) {\n\t\tthis._validateInitalize();\n\n\t\tif (!idToken || typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tlet userId;\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\t\tlet decodedToken = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: idToken,\n\t\t\tpublicKeys,\n\t\t\tissuer: this.openIdConfigResource.getIssuer(),\n\t\t\tclientId: this.clientId\n\t\t});\n\n\t\tif (decodedToken.identities && decodedToken.identities[0] && decodedToken.identities[0].id) {\n\t\t\tif (decodedToken.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = decodedToken.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn await this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change details widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {Object} tokens App ID tokens\n\t * @returns {Promise}\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @throws {AppIDError} \"Missing access token string\"\n\t * @throws {AppIDError} \"Missing tokens object\"\n\t * @example\n\t * let tokens = {accessToken, idToken}\n\t * let newTokens = await appID.changeDetails(tokens);\n\t */\n\tasync changeDetails({accessToken, idToken}) {\n\t\tthis._validateInitalize();\n\n\t\tif (!accessToken && typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ACCESS_TOKEN);\n\t\t}\n\n\t\tif (!idToken && typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tconst generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE;\n\t\tconst changeDetailsCode = await this.request(generateCodeUrl, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken + ' ' + idToken\n\t\t\t}\n\t\t});\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS;\n\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint,\n\t\t\tchangeDetailsCode\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); - -/***/ }), - -/***/ "./src/utils.js": -/*!**********************!*\ - !*** ./src/utils.js ***! - \**********************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId, changeDetailsCode}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tif (changeDetailsCode) {\n\t\t\tauthParams.code = changeDetailsCode;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint, changeDetailsCode}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint, changeDetailsCode});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconsole.log(tokens);\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); - -/***/ }) - -/******/ }); \ No newline at end of file +var AppID=function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=5)}([function(t,e,i){(function(t){var i={userAgent:!1},n={}; +/*! +Copyright (c) 2011, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.com/yui/license.html +version: 2.9.0 +*/ +if(void 0===r)var r={};r.lang={extend:function(t,e,n){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),n){var s;for(s in n)t.prototype[s]=n[s];var o=function(){},a=["toString","valueOf"];try{/MSIE/.test(i.userAgent)&&(o=function(t,e){for(s=0;s>>2]>>>24-s%4*8&255;e[n+s>>>2]|=o<<24-(n+s)%4*8}else for(s=0;s>>2]=i[s>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=s.ceil(e/4)},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i>>2]>>>24-r%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new u.init(i,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,i=t.sigBytes,n=[],r=0;r>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new u.init(i,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},g=a.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,n=e.sigBytes,r=this.blockSize,o=n/(4*r),a=(o=t?s.ceil(o):s.max((0|o)-this._minBufferSize,0))*r,h=s.min(4*a,n);if(a){for(var c=0;c>>2]}},e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:h,padding:c}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(h=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?n.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=n.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:i})}},e.SerializableCipher=i.extend({cfg:i.extend({format:h}),encrypt:function(t,e,i,n){n=this.cfg.extend(n);var r=t.createEncryptor(i,n);return e=r.finalize(e),r=r.cfg,l.create({ciphertext:e,key:i,iv:r.iv,algorithm:t,mode:r.mode,padding:r.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(i,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,i,r){return r||(r=n.random(8)),t=o.create({keySize:e+i}).compute(t,r),i=n.create(t.words.slice(e),4*i),t.sigBytes=4*e,l.create({key:t,iv:i,salt:r})}},g=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:d}),encrypt:function(t,e,i,n){return i=(n=this.cfg.extend(n)).kdf.execute(i,t.keySize,t.ivSize),n.iv=i.iv,(t=f.encrypt.call(this,t,e,i.key,n)).mixIn(i),t},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),i=n.kdf.execute(i,t.keySize,t.ivSize,e.salt),n.iv=i.iv,f.decrypt.call(this,t,e,i.key,n)}})}(),function(){for(var t=y,e=t.lib.BlockCipher,i=t.algo,n=[],r=[],s=[],o=[],a=[],h=[],u=[],c=[],l=[],f=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var p=0,v=0;for(g=0;256>g;g++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;n[p]=m,r[m]=p;var S=d[p],F=d[S],E=d[F],w=257*d[m]^16843008*m;s[p]=w<<24|w>>>8,o[p]=w<<16|w>>>16,a[p]=w<<8|w>>>24,h[p]=w,w=16843009*E^65537*F^257*S^16843008*p,u[m]=w<<24|w>>>8,c[m]=w<<16|w>>>16,l[m]=w<<8|w>>>24,f[m]=w,p?(p=S^d[d[d[E^S]]],v^=d[d[v]]):p=v=1}var x=[0,1,2,4,8,16,32,64,128,27,54];i=i.AES=e.extend({_doReset:function(){for(var t=(i=this._key).words,e=i.sigBytes/4,i=4*((this._nRounds=e+6)+1),r=this._keySchedule=[],s=0;s>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o]):(o=n[(o=o<<8|o>>>24)>>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o],o^=x[s/e|0]<<24),r[s]=r[s-e]^o}for(t=this._invKeySchedule=[],e=0;ee||4>=s?o:u[n[o>>>24]]^c[n[o>>>16&255]]^l[n[o>>>8&255]]^f[n[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,o,a,h,n)},decryptBlock:function(t,e){var i=t[e+1];t[e+1]=t[e+3],t[e+3]=i,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,r),i=t[e+1],t[e+1]=t[e+3],t[e+3]=i},_doCryptBlock:function(t,e,i,n,r,s,o,a){for(var h=this._nRounds,u=t[e]^i[0],c=t[e+1]^i[1],l=t[e+2]^i[2],f=t[e+3]^i[3],d=4,g=1;g>>24]^r[c>>>16&255]^s[l>>>8&255]^o[255&f]^i[d++],y=n[c>>>24]^r[l>>>16&255]^s[f>>>8&255]^o[255&u]^i[d++],v=n[l>>>24]^r[f>>>16&255]^s[u>>>8&255]^o[255&c]^i[d++];f=n[f>>>24]^r[u>>>16&255]^s[c>>>8&255]^o[255&l]^i[d++],u=p,c=y,l=v}p=(a[u>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&f])^i[d++],y=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[f>>>8&255]<<8|a[255&u])^i[d++],v=(a[l>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[255&c])^i[d++],f=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^i[d++],t[e]=p,t[e+1]=y,t[e+2]=v,t[e+3]=f},keySize:8});t.AES=e._createHelper(i)}(),function(){function t(t,e){var i=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=i,this._lBlock^=i<>>t^this._lBlock)&e;this._lBlock^=i,this._rBlock^=i<i;i++){var n=o[i]-1;e[i]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;16>n;n++){var r=t[n]=[],s=h[n];for(i=0;24>i;i++)r[i/6|0]|=e[(a[i]-1+s)%28]<<31-i%6,r[4+(i/6|0)]|=e[28+(a[i+24]-1+s)%28]<<31-i%6;for(r[0]=r[0]<<1|r[0]>>>31,i=1;7>i;i++)r[i]>>>=4*(i-1)+3;r[7]=r[7]<<5|r[7]>>>27}for(e=this._invSubKeys=[],i=0;16>i;i++)e[i]=t[15-i]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(i,n,r){this._lBlock=i[n],this._rBlock=i[n+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var o=r[s],a=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^o[f])&c[f])>>>0];this._lBlock=h,this._rBlock=a^l}r=this._lBlock,this._lBlock=this._rBlock,this._rBlock=r,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),i[n]=this._lBlock,i[n+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});i.DES=r._createHelper(l),s=s.TripleDES=r.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(n.create(t.slice(0,2))),this._des2=l.createEncryptor(n.create(t.slice(2,4))),this._des3=l.createEncryptor(n.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),i.TripleDES=r._createHelper(s)}(),function(){var t=y,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,i=t.sigBytes,n=this._map;t.clamp(),t=[];for(var r=0;r>>2]>>>24-r%4*8&255)<<16|(e[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|e[r+2>>>2]>>>24-(r+2)%4*8&255,o=0;4>o&&r+.75*o>>6*(3-o)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var i=t.length,n=this._map;(r=n.charAt(64))&&(-1!=(r=t.indexOf(r))&&(i=r));for(var r=[],s=0,o=0;o>>6-o%4*2;r[s>>>2]|=(a|h)<<24-s%4*8,s++}return e.create(r,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,i,n,r,s,o){return((t=t+(e&i|~e&n)+r+o)<>>32-s)+e}function i(t,e,i,n,r,s,o){return((t=t+(e&n|i&~n)+r+o)<>>32-s)+e}function n(t,e,i,n,r,s,o){return((t=t+(e^i^n)+r+o)<>>32-s)+e}function r(t,e,i,n,r,s,o){return((t=t+(i^(e|~n))+r+o)<>>32-s)+e}for(var s=y,o=(h=s.lib).WordArray,a=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var o=0;16>o;o++){var a=t[h=s+o];t[h]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var h=t[s+0],c=(a=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],d=t[s+5],g=t[s+6],p=t[s+7],y=t[s+8],v=t[s+9],m=t[s+10],S=t[s+11],F=t[s+12],E=t[s+13],w=t[s+14],x=t[s+15],b=e(b=o[0],C=o[1],I=o[2],A=o[3],h,7,u[0]),A=e(A,b,C,I,a,12,u[1]),I=e(I,A,b,C,c,17,u[2]),C=e(C,I,A,b,l,22,u[3]);b=e(b,C,I,A,f,7,u[4]),A=e(A,b,C,I,d,12,u[5]),I=e(I,A,b,C,g,17,u[6]),C=e(C,I,A,b,p,22,u[7]),b=e(b,C,I,A,y,7,u[8]),A=e(A,b,C,I,v,12,u[9]),I=e(I,A,b,C,m,17,u[10]),C=e(C,I,A,b,S,22,u[11]),b=e(b,C,I,A,F,7,u[12]),A=e(A,b,C,I,E,12,u[13]),I=e(I,A,b,C,w,17,u[14]),b=i(b,C=e(C,I,A,b,x,22,u[15]),I,A,a,5,u[16]),A=i(A,b,C,I,g,9,u[17]),I=i(I,A,b,C,S,14,u[18]),C=i(C,I,A,b,h,20,u[19]),b=i(b,C,I,A,d,5,u[20]),A=i(A,b,C,I,m,9,u[21]),I=i(I,A,b,C,x,14,u[22]),C=i(C,I,A,b,f,20,u[23]),b=i(b,C,I,A,v,5,u[24]),A=i(A,b,C,I,w,9,u[25]),I=i(I,A,b,C,l,14,u[26]),C=i(C,I,A,b,y,20,u[27]),b=i(b,C,I,A,E,5,u[28]),A=i(A,b,C,I,c,9,u[29]),I=i(I,A,b,C,p,14,u[30]),b=n(b,C=i(C,I,A,b,F,20,u[31]),I,A,d,4,u[32]),A=n(A,b,C,I,y,11,u[33]),I=n(I,A,b,C,S,16,u[34]),C=n(C,I,A,b,w,23,u[35]),b=n(b,C,I,A,a,4,u[36]),A=n(A,b,C,I,f,11,u[37]),I=n(I,A,b,C,p,16,u[38]),C=n(C,I,A,b,m,23,u[39]),b=n(b,C,I,A,E,4,u[40]),A=n(A,b,C,I,h,11,u[41]),I=n(I,A,b,C,l,16,u[42]),C=n(C,I,A,b,g,23,u[43]),b=n(b,C,I,A,v,4,u[44]),A=n(A,b,C,I,F,11,u[45]),I=n(I,A,b,C,x,16,u[46]),b=r(b,C=n(C,I,A,b,c,23,u[47]),I,A,h,6,u[48]),A=r(A,b,C,I,p,10,u[49]),I=r(I,A,b,C,w,15,u[50]),C=r(C,I,A,b,d,21,u[51]),b=r(b,C,I,A,F,6,u[52]),A=r(A,b,C,I,l,10,u[53]),I=r(I,A,b,C,m,15,u[54]),C=r(C,I,A,b,a,21,u[55]),b=r(b,C,I,A,y,6,u[56]),A=r(A,b,C,I,x,10,u[57]),I=r(I,A,b,C,g,15,u[58]),C=r(C,I,A,b,E,21,u[59]),b=r(b,C,I,A,f,6,u[60]),A=r(A,b,C,I,S,10,u[61]),I=r(I,A,b,C,c,15,u[62]),C=r(C,I,A,b,v,21,u[63]);o[0]=o[0]+b|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+A|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;i[r>>>5]|=128<<24-r%32;var s=t.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(i.length+1),this._process(),i=(e=this._hash).words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=a._createHelper(h),s.HmacMD5=a._createHmacHelper(h)}(Math),function(){var t=y,e=(r=t.lib).WordArray,i=r.Hasher,n=[],r=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=this._hash.words,r=i[0],s=i[1],o=i[2],a=i[3],h=i[4],u=0;80>u;u++){if(16>u)n[u]=0|t[e+u];else{var c=n[u-3]^n[u-8]^n[u-14]^n[u-16];n[u]=c<<1|c>>>31}c=(r<<5|r>>>27)+h+n[u],c=20>u?c+(1518500249+(s&o|~s&a)):40>u?c+(1859775393+(s^o^a)):60>u?c+((s&o|s&a|o&a)-1894007588):c+((s^o^a)-899497514),h=a,a=o,o=s<<30|s>>>2,s=r,r=c}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+o|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(i/4294967296),e[15+(n+64>>>9<<4)]=i,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=i._createHelper(r),t.HmacSHA1=i._createHmacHelper(r)}(),function(t){for(var e=y,i=(r=e.lib).WordArray,n=r.Hasher,r=e.algo,s=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=a(t.pow(h,.5))),o[u]=a(t.pow(h,1/3)),u++),h++}var d=[];r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(t,e){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],a=i[3],h=i[4],u=i[5],c=i[6],l=i[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var g=d[f-15],p=d[f-2];d[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[f-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[f-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+o[f]+d[f],p=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&r^n&s^r&s),l=c,c=u,u=h,h=a+g|0,a=s,s=r,r=n,n=g+p|0}i[0]=i[0]+n|0,i[1]=i[1]+r|0,i[2]=i[2]+s|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0,i[5]=i[5]+u|0,i[6]=i[6]+c|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return i[r>>>5]|=128<<24-r%32,i[14+(r+64>>>9<<4)]=t.floor(n/4294967296),i[15+(r+64>>>9<<4)]=n,e.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(r),e.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var t=y,e=t.lib.WordArray,i=(n=t.algo).SHA256,n=n.SHA224=i.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=i._createHelper(n),t.HmacSHA224=i._createHmacHelper(n)}(),function(){function t(){return n.create.apply(n,arguments)}for(var e=y,i=e.lib.Hasher,n=(s=e.x64).Word,r=s.WordArray,s=e.algo,o=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],a=[],h=0;80>h;h++)a[h]=t();s=s.SHA512=i.extend({_doReset:function(){this._hash=new r.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var i=(l=this._hash.words)[0],n=l[1],r=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=i.high,d=i.low,g=n.high,p=n.low,y=r.high,v=r.low,m=s.high,S=s.low,F=h.high,E=h.low,w=u.high,x=u.low,b=c.high,A=c.low,I=l.high,C=l.low,D=f,T=d,P=g,R=p,H=y,N=v,B=m,O=S,j=F,V=E,L=w,_=x,K=b,k=A,M=I,U=C,q=0;80>q;q++){var z=a[q];if(16>q)var G=z.high=0|t[e+2*q],Y=z.low=0|t[e+2*q+1];else{G=((Y=(G=a[q-15]).high)>>>1|(J=G.low)<<31)^(Y>>>8|J<<24)^Y>>>7;var J=(J>>>1|Y<<31)^(J>>>8|Y<<24)^(J>>>7|Y<<25),W=((Y=(W=a[q-2]).high)>>>19|(X=W.low)<<13)^(Y<<3|X>>>29)^Y>>>6,X=(X>>>19|Y<<13)^(X<<3|Y>>>29)^(X>>>6|Y<<26),Z=(Y=a[q-7]).high,$=(Q=a[q-16]).high,Q=Q.low;G=(G=(G=G+Z+((Y=J+Y.low)>>>0>>0?1:0))+W+((Y=Y+X)>>>0>>0?1:0))+$+((Y=Y+Q)>>>0>>0?1:0);z.high=G,z.low=Y}Z=j&L^~j&K,Q=V&_^~V&k,z=D&P^D&H^P&H;var tt=T&R^T&N^R&N,et=(J=(D>>>28|T<<4)^(D<<30|T>>>2)^(D<<25|T>>>7),W=(T>>>28|D<<4)^(T<<30|D>>>2)^(T<<25|D>>>7),(X=o[q]).high),it=X.low;$=M+((j>>>14|V<<18)^(j>>>18|V<<14)^(j<<23|V>>>9))+((X=U+((V>>>14|j<<18)^(V>>>18|j<<14)^(V<<23|j>>>9)))>>>0>>0?1:0),M=K,U=k,K=L,k=_,L=j,_=V,j=B+($=($=($=$+Z+((X=X+Q)>>>0>>0?1:0))+et+((X=X+it)>>>0>>0?1:0))+G+((X=X+Y)>>>0>>0?1:0))+((V=O+X|0)>>>0>>0?1:0)|0,B=H,O=N,H=P,N=R,P=D,R=T,D=$+(z=J+z+((Y=W+tt)>>>0>>0?1:0))+((T=X+Y|0)>>>0>>0?1:0)|0}d=i.low=d+T,i.high=f+D+(d>>>0>>0?1:0),p=n.low=p+R,n.high=g+P+(p>>>0>>0?1:0),v=r.low=v+N,r.high=y+H+(v>>>0>>0?1:0),S=s.low=S+O,s.high=m+B+(S>>>0>>0?1:0),E=h.low=E+V,h.high=F+j+(E>>>0>>0?1:0),x=u.low=x+_,u.high=w+L+(x>>>0<_>>>0?1:0),A=c.low=A+k,c.high=b+K+(A>>>0>>0?1:0),C=l.low=C+U,l.high=I+M+(C>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(i/4294967296),e[31+(n+128>>>10<<5)]=i,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=i._createHelper(s),e.HmacSHA512=i._createHmacHelper(s)}(),function(){var t=y,e=(r=t.x64).Word,i=r.WordArray,n=(r=t.algo).SHA512,r=r.SHA384=n.extend({_doReset:function(){this._hash=new i.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(r),t.HmacSHA384=n._createHmacHelper(r)}(),function(){var t=y,e=(n=t.lib).WordArray,i=n.Hasher,n=t.algo,r=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),o=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);n=n.RIPEMD160=i.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=0;16>i;i++){var n=t[F=e+i];t[F]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var c,l,f,d,g,p,y,v,m,S,F=this._hash.words,E=(n=h.words,u.words),w=r.words,x=s.words,b=o.words,A=a.words;p=c=F[0],y=l=F[1],v=f=F[2],m=d=F[3],S=g=F[4];var I;for(i=0;80>i;i+=1)I=c+t[e+w[i]]|0,I=16>i?I+((l^f^d)+n[0]):32>i?I+((l&f|~l&d)+n[1]):48>i?I+(((l|~f)^d)+n[2]):64>i?I+((l&d|f&~d)+n[3]):I+((l^(f|~d))+n[4]),I=(I=(I|=0)<>>32-b[i])+g|0,c=g,g=d,d=f<<10|f>>>22,f=l,l=I,I=p+t[e+x[i]]|0,I=16>i?I+((y^(v|~m))+E[0]):32>i?I+((y&m|v&~m)+E[1]):48>i?I+(((y|~v)^m)+E[2]):64>i?I+((y&v|~y&m)+E[3]):I+((y^v^m)+E[4]),I=(I=(I|=0)<>>32-A[i])+S|0,p=S,S=m,m=v<<10|v>>>22,v=y,y=I;I=F[1]+f+m|0,F[1]=F[2]+d+S|0,F[2]=F[3]+g+p|0,F[3]=F[4]+c+y|0,F[4]=F[0]+l+v|0,F[0]=I},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,i=0;5>i;i++)n=e[i],e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(n),t.HmacRIPEMD160=i._createHmacHelper(n)}(Math),function(){var t=y,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,i){t=this._hasher=new t.init,"string"==typeof i&&(i=e.parse(i));var n=t.blockSize,r=4*n;i.sigBytes>r&&(i=t.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),o=this._iKey=i.clone(),a=s.words,h=o.words,u=0;u>6)+m.charAt(63&i);if(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),n+=m.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),n+=m.charAt(i>>2)+m.charAt((3&i)<<4)),S)for(;(3&n.length)>0;)n+=S;return n}function E(t){var e,i,n,r="",s=0;for(e=0;e>2),i=3&n,s=1):1==s?(r+=T(i<<2|n>>4),i=15&n,s=2):2==s?(r+=T(i),r+=T(n>>2),i=3&n,s=3):(r+=T(i<<2|n>>4),r+=T(15&n),s=0));return 1==s&&(r+=T(i<<2)),r}function w(t){var e,i=E(t),n=new Array;for(e=0;2*e>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;r=((h=o*h+((32767&c)<<15)+i[n]+(1073741823&r))>>>30)+(c>>>15)+a*u+(r>>>30),i[n++]=1073741823&h}return r},v=30):"Netscape"!=i.appName?(x.prototype.am=function(t,e,i,n,r,s){for(;--s>=0;){var o=e*this[t++]+i[n]+r;r=Math.floor(o/67108864),i[n++]=67108863&o}return r},v=26):(x.prototype.am=function(t,e,i,n,r,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;r=((h=o*h+((16383&c)<<14)+i[n]+r)>>28)+(c>>14)+a*u,i[n++]=268435455&h}return r},v=28),x.prototype.DB=v,x.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function N(t){this.m=t}function B(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function K(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function k(){}function M(t){return t}function U(t){this.r2=b(),this.q3=b(),x.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}N.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},N.prototype.revert=function(t){return t},N.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},N.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},N.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},B.prototype.convert=function(t){var e=b();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(x.ZERO)>0&&this.m.subTo(e,e),e},B.prototype.revert=function(t){var e=b();return t.copyTo(e),this.reduce(e),e},B.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},B.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},B.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},x.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},x.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},x.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,r=!1,s=0;--n>=0;){var o=8==i?255&t[n]:P(t,n);o<0?"-"==t.charAt(n)&&(r=!0):(r=!1,0==s?this[this.t++]=o:s+i>this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},x.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},x.prototype.drShiftTo=function(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>r|a,a=(this[i]&s)<=0;--i)e[i]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},x.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,r=this.DB-n,s=(1<>n;for(var o=i+1;o>n;n>0&&(e[this.t-i-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},x.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),r=i.t;for(e.t=r+n.t;--r>=0;)e[r]=0;for(r=0;r=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},x.prototype.divRemTo=function(t,e,i){var n=t.abs();if(!(n.t<=0)){var r=this.abs();if(r.t0?(n.lShiftTo(h,s),r.lShiftTo(h,i)):(n.copyTo(s),r.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<1?s[u-2]>>this.F2:0),f=this.FV/l,d=(1<=0&&(i[i.t++]=1,i.subTo(v,i)),x.ONE.dlShiftTo(u,v),v.subTo(s,s);s.t=0;){var m=i[--p]==c?this.DM:Math.floor(i[p]*f+(i[p-1]+g)*d);if((i[p]+=s.am(0,m,i,y,0,u))0&&i.rShiftTo(h,i),o<0&&x.ZERO.subTo(i,i)}}},x.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},x.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},x.prototype.exp=function(t,e){if(t>4294967295||t<1)return x.ONE;var i=b(),n=b(),r=e.convert(this),s=H(t)-1;for(r.copyTo(i);--s>=0;)if(e.sqrTo(i,n),(t&1<0)e.mulTo(n,r,i);else{var o=i;i=n,n=o}return e.revert(i)},x.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<0)for(a>a)>0&&(r=!0,s=T(i));o>=0;)a>(a+=this.DB-e)):(i=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),i>0&&(r=!0),r&&(s+=T(i));return r?s:"0"},x.prototype.negate=function(){var t=b();return x.ZERO.subTo(this,t),t},x.prototype.abs=function(){return this.s<0?this.negate():this},x.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},x.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+H(this[this.t-1]^this.s&this.DM)},x.prototype.mod=function(t){var e=b();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(x.ZERO)>0&&t.subTo(e,e),e},x.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new N(e):new B(e),this.exp(t,i)},x.ZERO=R(0),x.ONE=R(1),k.prototype.convert=M,k.prototype.revert=M,k.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},k.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=b();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var q=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],z=(1<<26)/q[q.length-1]; +/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ + */ +function G(){this.i=0,this.j=0,this.S=new Array}x.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},x.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),n=R(i),r=b(),s=b(),o="";for(this.divRemTo(n,r,s);r.signum()>0;)o=(i+s.intValue()).toString(t).substr(1)+o,r.divRemTo(n,r,s);return s.intValue().toString(t)+o},x.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),r=!1,s=0,o=0,a=0;a=i&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),r&&x.ZERO.subTo(this,this)},x.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(x.ONE.shiftLeft(t-1),j,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(x.ONE.shiftLeft(t-1),this);else{var n=new Array,r=7&t;n.length=1+(t>>3),e.nextBytes(n),r>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},x.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},x.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},x.prototype.multiplyLowerTo=function(t,e,i){var n,r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r=0;)i[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},x.prototype.millerRabin=function(t){var e=this.subtract(x.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var n=e.shiftRight(i);(t=t+1>>1)>q.length&&(t=q.length);for(var r=b(),s=0;s>24},x.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},x.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},x.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,r=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[r++]=i|this.s<=0;)n<8?(i=(this[t]&(1<>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(e[r++]=i);return e},x.prototype.equals=function(t){return 0==this.compareTo(t)},x.prototype.min=function(t){return this.compareTo(t)<0?this:t},x.prototype.max=function(t){return this.compareTo(t)>0?this:t},x.prototype.and=function(t){var e=b();return this.bitwiseTo(t,O,e),e},x.prototype.or=function(t){var e=b();return this.bitwiseTo(t,j,e),e},x.prototype.xor=function(t){var e=b();return this.bitwiseTo(t,V,e),e},x.prototype.andNot=function(t){var e=b();return this.bitwiseTo(t,L,e),e},x.prototype.not=function(){for(var t=b(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var c=b();for(n.sqrTo(o[1],c);a<=u;)o[a]=b(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,d=t.t-1,g=!0,p=b();for(r=H(t[d])-1;d>=0;){for(r>=h?l=t[d]>>r-h&u:(l=(t[d]&(1<0&&(l|=t[d-1]>>this.DB+r-h)),a=i;0==(1&l);)l>>=1,--a;if((r-=a)<0&&(r+=this.DB,--d),g)o[l].copyTo(s),g=!1;else{for(;a>1;)n.sqrTo(s,p),n.sqrTo(p,s),a-=2;a>0?n.sqrTo(s,p):(f=s,s=p,p=f),n.mulTo(p,o[l],s)}for(;d>=0&&0==(t[d]&1<=0?(i.subTo(n,i),e&&r.subTo(o,r),s.subTo(a,s)):(n.subTo(i,n),e&&o.subTo(r,o),a.subTo(s,a))}return 0!=n.compareTo(x.ONE)?x.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},x.prototype.pow=function(t){return this.exp(t,new k)},x.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var r=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(r0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(r=e.getLowestSetBit())>0&&e.rShiftTo(r,e),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},x.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=q[q.length-1]){for(e=0;e>8&255,J[W++]^=t>>16&255,J[W++]^=t>>24&255,W>=X&&(W-=X)}((new Date).getTime())}if(null==J){var $;if(J=new Array,W=0,void 0!==n&&(void 0!==n.crypto||void 0!==n.msCrypto)){var Q=n.crypto||n.msCrypto;if(Q.getRandomValues){var tt=new Uint8Array(32);for(Q.getRandomValues(tt),$=0;$<32;++$)J[W++]=tt[$]}else if("Netscape"==i.appName&&i.appVersion<"5"){var et=n.crypto.random(32);for($=0;$>>8,J[W++]=255&$;W=0,Z()}function it(){if(null==Y){for(Z(),(Y=new G).init(J),W=0;W>24,(16711680&r)>>16,(65280&r)>>8,255&r]))),r+=1;return n}function ot(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function at(t,e,i){for(var n="",r=0;n.length>24,(16711680&r)>>16,(65280&r)>>8,255&r])),r+=1;return n} +/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ + */ +function ht(t,e){this.x=e,this.q=t}function ut(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?x.ONE:n,this.zinv=null}function ct(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new ut(this,null,null)}nt.prototype.nextBytes=function(t){var e;for(e=0;e0&&e.length>0))throw"Invalid RSA public key";this.n=rt(t,16),this.e=parseInt(e,16)}},ot.prototype.encrypt=function(t){var e=function(t,e){if(e=0&&e>0;){var r=t.charCodeAt(n--);r<128?i[--e]=r:r>127&&r<2048?(i[--e]=63&r|128,i[--e]=r>>6|192):(i[--e]=63&r|128,i[--e]=r>>6&63|128,i[--e]=r>>12|224)}i[--e]=0;for(var s=new nt,o=new Array;e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new x(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var n=i.toString(16);return 0==(1&n.length)?n:"0"+n},ot.prototype.encryptOAEP=function(t,e,i){var n=function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;if(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t.length+2*n+2>e)throw"Message too long for RSA";var a,h="";for(a=0;a>3,e,i);if(null==n)return null;var r=this.doPublic(n);if(null==r)return null;var s=r.toString(16);return 0==(1&s.length)?s:"0"+s},ot.prototype.type="RSA",ot.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},ot.prototype.setPrivate=function(t,e,i){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=i;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16)}},ot.prototype.setPrivateEx=function(t,e,i,n,r,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16),this.p=rt(n,16),this.q=rt(r,16),this.dmp1=rt(s,16),this.dmq1=rt(o,16),this.coeff=rt(a,16)},ot.prototype.generate=function(t,e){var i=new nt,n=t>>1;this.e=parseInt(e,16);for(var r=new x(e,16);;){for(;this.p=new x(t-n,1,i),0!=this.p.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.p.isProbablePrime(10););for(;this.q=new x(n,1,i),0!=this.q.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(x.ONE),a=this.q.subtract(x.ONE),h=o.multiply(a);if(0==h.gcd(r).compareTo(x.ONE)){this.n=this.p.multiply(this.q),this.d=r.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},ot.prototype.decrypt=function(t){var e=rt(t,16),i=this.doPrivate(e);return null==i?null: +/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ + */ +function(t,e){for(var i=t.toByteArray(),n=0;n=i.length)return null;for(var r="";++n191&&s<224?(r+=String.fromCharCode((31&s)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&s)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},ot.prototype.decryptOAEP=function(t,e,i){var n=rt(t,16),r=this.doPrivate(n);return null==r?null:function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;for(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t=t.toByteArray(),a=0;a>3,e,i)},ht.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ht.prototype.toBigInteger=function(){return this.x},ht.prototype.negate=function(){return new ht(this.q,this.x.negate().mod(this.q))},ht.prototype.add=function(t){return new ht(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ht.prototype.subtract=function(t){return new ht(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ht.prototype.multiply=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ht.prototype.square=function(){return new ht(this.q,this.x.square().mod(this.q))},ht.prototype.divide=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ut.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO))},ut.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(x.ZERO)&&!this.y.toBigInteger().equals(x.ZERO)},ut.prototype.negate=function(){return new ut(this.curve,this.x,this.y.negate(),this.z)},ut.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),i=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(x.ZERO.equals(i))return x.ZERO.equals(e)?this.twice():this.curve.getInfinity();var n=new x("3"),r=this.x.toBigInteger(),s=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),i.square()),a=o.multiply(i),h=r.multiply(o),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(a).multiply(i).mod(this.curve.q),l=h.multiply(n).multiply(e).subtract(s.multiply(a)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),f=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},ut.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new x("3"),e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=i.multiply(this.z),r=n.multiply(i).mod(this.curve.q),s=this.curve.a.toBigInteger(),o=e.square().multiply(t);x.ZERO.equals(s)||(o=o.add(this.z.square().multiply(s)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(r)).shiftLeft(1).multiply(n).mod(this.curve.q),h=o.multiply(t).multiply(e).subtract(r.shiftLeft(1)).shiftLeft(2).multiply(r).subtract(o.square().multiply(o)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),u)},ut.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add(o?this:r))}return s},ut.prototype.multiplyTwo=function(t,e,i){var n;n=t.bitLength()>i.bitLength()?t.bitLength()-1:i.bitLength()-1;for(var r=this.curve.getInfinity(),s=this.add(e);n>=0;)r=r.twice(),t.testBit(n)?r=i.testBit(n)?r.add(s):r.add(this):i.testBit(n)&&(r=r.add(e)),--n;return r},ct.prototype.getQ=function(){return this.q},ct.prototype.getA=function(){return this.a},ct.prototype.getB=function(){return this.b},ct.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ct.prototype.getInfinity=function(){return this.infinity},ct.prototype.fromBigInteger=function(t){return new ht(this.q,t)},ct.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,i=t.substr(2,e),n=t.substr(e+2,e);return new ut(this,this.fromBigInteger(new x(i,16)),this.fromBigInteger(new x(n,16)));default:return null}}, +/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib + */ +ht.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ut.prototype.getEncoded=function(t){var e=function(t,e){var i=t.toByteArrayUnsigned();if(ei.length;)i.unshift(0);return i},i=this.getX().toBigInteger(),n=this.getY().toBigInteger(),r=e(i,32);return t?n.isEven()?r.unshift(2):r.unshift(3):(r.unshift(4),r=r.concat(e(n,32))),r},ut.decodeFrom=function(t,e){e[0];var i=e.length-1,n=e.slice(1,1+i/2),r=e.slice(1+i/2,1+i);n.unshift(0),r.unshift(0);var s=new x(n),o=new x(r);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.decodeFromHex=function(t,e){e.substr(0,2);var i=e.length-2,n=e.substr(2,i/2),r=e.substr(2+i/2,i/2),s=new x(n,16),o=new x(r,16);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),i=t.y.subtract(this.y).divide(e),n=i.square().subtract(this.x).subtract(t.x),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(x.valueOf(2)),e=this.curve.fromBigInteger(x.valueOf(3)),i=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=i.square().subtract(this.x.multiply(t)),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add2D(o?this:r))}return s},ut.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),i=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),r=this.curve.getQ(),s=e.multiply(e).mod(r),o=t.multiply(t).multiply(t).add(i.multiply(t)).add(n).mod(r);return s.equals(o)},ut.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ut.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),i=this.getY().toBigInteger();if(e.compareTo(x.ONE)<0||e.compareTo(t.subtract(x.ONE))>0)throw new Error("x coordinate out of bounds");if(i.compareTo(x.ONE)<0||i.compareTo(t.subtract(x.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0}; +/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval + */ +var lt=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),i={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,n){return e?i[e]:String.fromCharCode(parseInt(n,16))}var r=new String(""),s=(Object,Array,Object.hasOwnProperty);return function(i,o){var a,h,u=i.match(t),c=u[0],l=!1;"{"===c?a={}:"["===c?a=[]:(a=[],l=!0);for(var f=[a],d=1-l,g=u.length;d=0;)delete i[n[h]]}return o.call(t,e,i)};a=y({"":a},"")}return a}}();void 0!==ft&&ft||(ft={}),void 0!==ft.asn1&&ft.asn1||(ft.asn1={}),ft.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},ft.asn1.DERAbstractString=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=bt(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},r.lang.extend(ft.asn1.DERAbstractString,ft.asn1.ASN1Object),ft.asn1.DERAbstractTime=function(t){ft.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var n=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var h=n(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=St(t)},this.setByDateValue=function(t,e,i,n,r,s){var o=new Date(Date.UTC(t,e-1,i,n,r,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},r.lang.extend(ft.asn1.DERAbstractTime,ft.asn1.ASN1Object),ft.asn1.DERAbstractStructured=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},r.lang.extend(ft.asn1.DERAbstractStructured,ft.asn1.ASN1Object),ft.asn1.DERBoolean=function(){ft.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},r.lang.extend(ft.asn1.DERBoolean,ft.asn1.ASN1Object),ft.asn1.DERInteger=function(t){ft.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ft.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},r.lang.extend(ft.asn1.DERInteger,ft.asn1.ASN1Object),ft.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ft.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}ft.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7r.length&&(r=n[i]);return(t=t.replace(r,"::")).slice(1,-1)}function _t(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?Lt(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function Kt(t){for(var e=encodeURIComponent(t),i="",n=0;n"7"?"00"+t:t}function Mt(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,i){var n=parseInt(t);if(n<0||255=2*s)break;if(a>=200)break;n.push(h),o=h,a++}return n},pt.getNthChildIdx=function(t,e,i){return pt.getChildIdx(t,e)[i]},pt.getIdxbyList=function(t,e,i,n){var r,s,o=pt;if(0==i.length){if(void 0!==n&&t.substr(e,2)!==n)throw"checking tag doesn't match: "+t.substr(e,2)+"!="+n;return e}return r=i.shift(),s=o.getChildIdx(t,e),o.getIdxbyList(t,s[r],i,n)},pt.getTLVbyList=function(t,e,i,n){var r=pt,s=r.getIdxbyList(t,e,i);if(void 0===s)throw"can't find nthList object";if(void 0!==n&&t.substr(s,2)!=n)throw"checking tag doesn't match: "+t.substr(s,2)+"!="+n;return r.getTLV(t,s)},pt.getVbyList=function(t,e,i,n,r){var s,o,a=pt;if(void 0===(s=a.getIdxbyList(t,e,i,n)))throw"can't find nthList object";return o=a.getV(t,s),!0===r&&(o=o.substr(2)),o},pt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},i=[],n=t.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var s=t.substr(2),o=[],a=0;a0&&(c=c+"."+h.join(".")),c},pt.dump=function(t,e,i,n){var r=pt,s=r.getV,o=r.dump,a=r.getChildIdx,h=t;t instanceof ft.asn1.ASN1Object&&(h=t.getEncodedHex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var c=e.ommit_long_octet;if("01"==h.substr(i,2))return"00"==(l=s(h,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==h.substr(i,2))return n+"INTEGER "+u(l=s(h,i),c)+"\n";if("03"==h.substr(i,2))return n+"BITSTRING "+u(l=s(h,i),c)+"\n";if("04"==h.substr(i,2)){var l=s(h,i);if(r.isASN1HEX(l)){var f=n+"OCTETSTRING, encapsulates\n";return f+=o(l,e,0,n+" ")}return n+"OCTETSTRING "+u(l,c)+"\n"}if("05"==h.substr(i,2))return n+"NULL\n";if("06"==h.substr(i,2)){var d=s(h,i),g=ft.asn1.ASN1Util.oidHexToInt(d),p=ft.asn1.x509.OID.oid2name(g),y=g.replace(/\./g," ");return""!=p?n+"ObjectIdentifier "+p+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0c"==h.substr(i,2))return n+"UTF8String '"+At(s(h,i))+"'\n";if("13"==h.substr(i,2))return n+"PrintableString '"+At(s(h,i))+"'\n";if("14"==h.substr(i,2))return n+"TeletexString '"+At(s(h,i))+"'\n";if("16"==h.substr(i,2))return n+"IA5String '"+At(s(h,i))+"'\n";if("17"==h.substr(i,2))return n+"UTCTime "+At(s(h,i))+"\n";if("18"==h.substr(i,2))return n+"GeneralizedTime "+At(s(h,i))+"\n";if("30"==h.substr(i,2)){if("3000"==h.substr(i,4))return n+"SEQUENCE {}\n";f=n+"SEQUENCE\n";var v=e;if((2==(F=a(h,i)).length||3==F.length)&&"06"==h.substr(F[0],2)&&"04"==h.substr(F[F.length-1],2)){p=r.oidname(s(h,F[0]));var m=JSON.parse(JSON.stringify(e));m.x509ExtName=p,v=m}for(var S=0;S0){var e=new i({array:this.extensionsArray}),n=new r({explicit:!0,tag:"a3",obj:e});this.asn1Array.push(n)}var s=new i({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertificate,ft.asn1.ASN1Object),ft.asn1.x509.Extension=function(t){ft.asn1.x509.Extension.superclass.constructor.call(this);var e=ft.asn1,i=e.DERObjectIdentifier,n=e.DEROctetString,r=(e.DERBitString,e.DERBoolean),s=e.DERSequence;this.getEncodedHex=function(){var t=new i({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new r),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},r.lang.extend(ft.asn1.x509.Extension,ft.asn1.ASN1Object),ft.asn1.x509.Extension.appendByNameToArray=function(t,e,i){var n=t.toLowerCase(),r=ft.asn1.x509;if("basicconstraints"==n){var s=new r.BasicConstraints(e);i.push(s)}else if("keyusage"==n){s=new r.KeyUsage(e);i.push(s)}else if("crldistributionpoints"==n){s=new r.CRLDistributionPoints(e);i.push(s)}else if("extkeyusage"==n){s=new r.ExtKeyUsage(e);i.push(s)}else if("authoritykeyidentifier"==n){s=new r.AuthorityKeyIdentifier(e);i.push(s)}else if("authorityinfoaccess"==n){s=new r.AuthorityInfoAccess(e);i.push(s)}else if("subjectaltname"==n){s=new r.SubjectAltName(e);i.push(s)}else{if("issueraltname"!=n)throw"unsupported extension name: "+t;s=new r.IssuerAltName(e);i.push(s)}},ft.asn1.x509.KeyUsage=function(t){ft.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Jt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new ft.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var i=t.names,n="000000000",r=0;r-1&&t.push(new ft.asn1.DERInteger({int:this.pathLen}));var e=new ft.asn1.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},r.lang.extend(ft.asn1.x509.BasicConstraints,ft.asn1.x509.Extension),ft.asn1.x509.CRLDistributionPoints=function(t){ft.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ft.asn1,i=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){this.asn1ExtnValue=new e.DERSequence({array:t})},this.setByOneURI=function(t){var e=new i.GeneralNames([{uri:t}]),n=new i.DistributionPointName(e),r=new i.DistributionPoint({dpobj:n});this.setByDPArray([r])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},r.lang.extend(ft.asn1.x509.CRLDistributionPoints,ft.asn1.x509.Extension),ft.asn1.x509.ExtKeyUsage=function(t){ft.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=ft.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var i=0;i0){var t=new i({array:this.aRevokedCert});this.asn1Array.push(t)}var e=new i({array:this.asn1Array});return this.hTLV=e.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize=function(){this.asn1Version=null,this.asn1SignatureAlg=null,this.asn1Issuer=null,this.asn1ThisUpdate=null,this.asn1NextUpdate=null,this.aRevokedCert=new Array},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertList,ft.asn1.ASN1Object),ft.asn1.x509.CRLEntry=function(t){ft.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=ft.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},r.lang.extend(ft.asn1.x509.CRLEntry,ft.asn1.ASN1Object),ft.asn1.x509.X500Name=function(t){ft.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=new Array;var e=ft.asn1,i=e.x509,n=Ht;if(this.setByString=function(t){var e=t.split("/");e.shift();for(var n=[],r=0;r0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},ft.asn1.x509.RDN=function(t){ft.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=new Array,this.addByString=function(t){this.asn1Array.push(new ft.asn1.x509.AttributeTypeAndValue({str:t}))},this.addByMultiValuedString=function(t){for(var e=ft.asn1.x509.RDN.parseString(t),i=0;i0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var a=!1,h=[];for(r=0;n.length>0;r++){s=n.shift();if(!0===a){var u=h.pop();if(s.match(/"$/)){o=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(o),a=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(a=!0)}return h},ft.asn1.x509.AttributeTypeAndValue=function(t){ft.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var e=ft.asn1;this.setByString=function(t){var e=t.match(/^([^=]+)=(.+)$/);if(!e)throw"malformed attrTypeAndValueStr: "+t;this.setByAttrTypeAndValueStr(e[1],e[2])},this.setByAttrTypeAndValueStr=function(t,e){this.typeObj=ft.asn1.x509.OID.atype2obj(t);var i="utf8";"C"==t&&(i="prn"),this.valueObj=this.getValueObj(i,e)},this.getValueObj=function(t,i){if("utf8"==t)return new e.DERUTF8String({str:i});if("prn"==t)return new e.DERPrintableString({str:i});if("tel"==t)return new e.DERTeletexString({str:i});if("ia5"==t)return new e.DERIA5String({str:i});throw"unsupported directory string type: type="+t+" value="+i},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.typeObj,this.valueObj]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&void 0!==t.str&&this.setByString(t.str)},r.lang.extend(ft.asn1.x509.AttributeTypeAndValue,ft.asn1.ASN1Object),ft.asn1.x509.SubjectPublicKeyInfo=function(t){ft.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ft,i=e.asn1,n=i.DERInteger,r=i.DERBitString,s=i.DERObjectIdentifier,o=i.DERSequence,a=i.ASN1Util.newObject,h=i.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof ot){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+e})}}catch(t){}try{if(t instanceof ft.crypto.ECDSA){var i=new s({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ft.crypto.DSA){i=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new h({name:"dsa",asn1params:i});var o=new n({bigint:t.y});this.asn1SubjPKey=new r({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},r.lang.extend(ft.asn1.x509.SubjectPublicKeyInfo,ft.asn1.ASN1Object),ft.asn1.x509.Time=function(t){ft.asn1.x509.Time.superclass.constructor.call(this);var e=ft.asn1,i=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},r.lang.extend(ft.asn1.x509.Time,ft.asn1.ASN1Object),ft.asn1.x509.AlgorithmIdentifier=function(t){ft.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ft.asn1;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw"algorithm not specified";null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var t=[this.asn1Alg];null!==this.asn1Params&&t.push(this.asn1Params);var i=new e.DERSequence({array:t});return this.hTLV=i.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},r.lang.extend(ft.asn1.x509.AlgorithmIdentifier,ft.asn1.ASN1Object),ft.asn1.x509.GeneralName=function(t){ft.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=ft.asn1,n=(i.DERSequence,i.DEROctetString),r=i.DERIA5String,s=i.DERTaggedObject,o=i.ASN1Object,a=i.x509.X500Name,h=Ht;this.explicit=!1,this.setByParam=function(t){var i=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",i=new r({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",i=new r({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",i=new r({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,i=new a({str:t.dn})),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var u=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certissuer param not cert";(f=new Jt).hex=u;var c=f.getIssuerHex();(i=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;u=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certsubj param not cert";(f=new Jt).hex=u;c=f.getSubjectHex();(i=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,g=t.ip,p="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(d=Mt("["+g.split(".").join(",")+"]")).length)throw p}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=Vt(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw p;d=g}i=new n({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},r.lang.extend(ft.asn1.x509.GeneralName,ft.asn1.ASN1Object),ft.asn1.x509.GeneralNames=function(t){ft.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ft.asn1;this.setByParamArray=function(t){for(var i=0;i0&&(e=new n({obj:this.dUnsignedAttrs,tag:"a1",explicit:!1}));var r=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,t,this.dSigAlg,this.dSig];null!=e&&r.push(e);var o=new i.DERSequence({array:r});return this.hTLV=o.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.SignerInfo,ft.asn1.ASN1Object),ft.asn1.cms.EncapsulatedContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.dEContentType=new r({name:"data"}),this.dEContent=null,this.isDetached=!1,this.eContentValueHex=null,this.setContentType=function(t){t.match(/^[0-2][.][0-9.]+$/)?this.dEContentType=new r({oid:t}):this.dEContentType=new r({name:t})},this.setContentValue=function(t){void 0!==t&&("string"==typeof t.hex?this.eContentValueHex=t.hex:"string"==typeof t.str&&(this.eContentValueHex=bt(t.str)))},this.setContentValueHex=function(t){this.eContentValueHex=t},this.setContentValueStr=function(t){this.eContentValueHex=bt(t)},this.getEncodedHex=function(){if("string"!=typeof this.eContentValueHex)throw"eContentValue not yet set";var t=new s({hex:this.eContentValueHex});this.dEContent=new i({obj:t,tag:"a0",explicit:!0});var e=[this.dEContentType];this.isDetached||e.push(this.dEContent);var r=new n({array:e});return this.hTLV=r.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.EncapsulatedContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.ContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.x509;ft.asn1.cms.ContentInfo.superclass.constructor.call(this),this.dContentType=null,this.dContent=null,this.setContentType=function(t){"string"==typeof t&&(this.dContentType=r.OID.name2obj(t))},this.getEncodedHex=function(){var t=new i({obj:this.dContent,tag:"a0",explicit:!0}),e=new n({array:[this.dContentType,t]});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t&&(t.type&&this.setContentType(t.type),t.obj&&t.obj instanceof e.ASN1Object&&(this.dContent=t.obj))},r.lang.extend(ft.asn1.cms.ContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.SignedData=function(t){var e=ft.asn1,i=e.ASN1Object,n=e.DERInteger,r=e.DERSet,s=e.DERSequence,o=e.DERTaggedObject,a=e.cms,h=a.EncapsulatedContentInfo,u=a.SignerInfo,c=a.ContentInfo,l=e.x509.AlgorithmIdentifier;ft.asn1.cms.SignedData.superclass.constructor.call(this),this.dCMSVersion=new n({int:1}),this.dDigestAlgs=null,this.digestAlgNameList=[],this.dEncapContentInfo=new h,this.dCerts=null,this.certificateList=[],this.crlList=[],this.signerInfoList=[new u],this.addCertificatesByPEM=function(t){var e=Ht(t),n=new i;n.hTLV=e,this.certificateList.push(n)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(null==this.dDigestAlgs){for(var t=[],e=0;e0){var h=new r({array:this.certificateList});this.dCerts=new o({obj:h,tag:"a0",explicit:!1})}null!=this.dCerts&&a.push(this.dCerts);var u=new r({array:this.signerInfoList});a.push(u);var c=new s({array:a});return this.hTLV=c.getEncodedHex(),this.hTLV},this.getContentInfo=function(){return this.getEncodedHex(),new c({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},this.getPEM=function(){return Rt(this.getContentInfoEncodedHex(),"CMS")}},r.lang.extend(ft.asn1.cms.SignedData,ft.asn1.ASN1Object),ft.asn1.cms.CMSUtil=new function(){},ft.asn1.cms.CMSUtil.newSignedData=function(t){var e=ft.asn1,i=e.cms,n=i.SignerInfo,r=i.SignedData,s=i.SigningTime,o=i.SigningCertificate,a=i.SigningCertificateV2,h=e.cades.SignaturePolicyIdentifier,u=new r;if(u.dEncapContentInfo.setContentValue(t.content),"object"==typeof t.certs)for(var c=0;c0){var t=new n({array:this.extensionsArray}),e=new r({array:[t]}),i=new n({array:[new a({oid:"1.2.840.113549.1.9.14"}),e]}),h=new o({explicit:!0,tag:"a0",obj:i});this.asn1Array.push(h)}else{h=new o({explicit:!1,tag:"a0",obj:new s});this.asn1Array.push(h)}var u=new n({array:this.asn1Array});return this.hTLV=u.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.csr.CertificationRequestInfo,ft.asn1.ASN1Object),ft.asn1.csr.CSRUtil=new function(){},ft.asn1.csr.CSRUtil.newCSRPEM=function(t){var e=Ut,i=ft.asn1.csr;if(void 0===t.subject)throw"parameter subject undefined";if(void 0===t.sbjpubkey)throw"parameter sbjpubkey undefined";if(void 0===t.sigalg)throw"parameter sigalg undefined";if(void 0===t.sbjprvkey)throw"parameter sbjpubkey undefined";var n=new i.CertificationRequestInfo;if(n.setSubjectByParam(t.subject),n.setSubjectPublicKeyByGetKey(t.sbjpubkey),void 0!==t.ext&&void 0!==t.ext.length)for(var r=0;rr)throw"key is too short for SigAlg: keylen="+i+","+e;for(var s="0001",o="00"+n,a="",h=r-s.length-o.length,u=0;u=0)return!1;if(i.compareTo(x.ONE)<0||i.compareTo(r)>=0)return!1;var o=i.modInverse(r),a=t.multiply(o).mod(r),h=e.multiply(o).mod(r);return s.multiply(a).add(n.multiply(h)).getX().toBigInteger().mod(r).equals(e)},this.serializeSig=function(t,e){var i=t.toByteArraySigned(),n=e.toByteArraySigned(),r=[];return r.push(2),r.push(i.length),(r=r.concat(i)).push(2),r.push(n.length),(r=r.concat(n)).unshift(r.length),r.unshift(48),r},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:x.fromByteArrayUnsigned(i),s:x.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:x.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:x.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[2,0],"06"),i=o(t,0,[1],"04");try{n=o(t,0,[3,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#1/5 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{o(t,0,[1,0],"06"),e=o(t,0,[1,1],"06"),i=o(t,0,[2,0,1],"04");try{n=o(t,0,[2,0,2,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#8 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){var e,i,n=pt,r=ft.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{s(t,0,[0,0],"06"),e=s(t,0,[0,1],"06"),i=s(t,0,[1],"03").substr(2)}catch(t){throw"malformed PKCS#8 ECC public key"}if(this.curveName=r(e),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,e){5!==e&&(e=6);var i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{i=o(t,0,[0,e,0,1],"06"),n=o(t,0,[0,e,1],"03").substr(2)}catch(t){throw"malformed X.509 certificate ECC public key"}if(this.curveName=s(i),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ft.crypto.ECDSA.parseSigHex=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new x(e.r,16),s:new x(e.s,16)}},ft.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=pt,i=e.getChildIdx,n=e.getV;if("30"!=t.substr(0,2))throw"signature is not a ASN.1 sequence";var r=i(t,0);if(2!=r.length)throw"number of signature ASN.1 sequence elements seem wrong";var s=r[0],o=r[1];if("02"!=t.substr(s,2))throw"1st item of sequene of signature is not ASN.1 integer";if("02"!=t.substr(o,2))throw"2nd item of sequene of signature is not ASN.1 integer";return{r:n(t,s),s:n(t,o)}},ft.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t),i=e.r,n=e.s;if("00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),i.length%32==30&&(i="00"+i),n.length%32==30&&(n="00"+n),i.length%32!=0)throw"unknown ECDSA sig r length error";if(n.length%32!=0)throw"unknown ECDSA sig s length error";return i+n},ft.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var e=t.substr(0,t.length/2),i=t.substr(t.length/2);return ft.crypto.ECDSA.hexRSSigToASN1Sig(e,i)},ft.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var i=new x(t,16),n=new x(e,16);return ft.crypto.ECDSA.biRSSigToASN1Sig(i,n)},ft.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var i=ft.asn1,n=new i.DERInteger({bigint:t}),r=new i.DERInteger({bigint:e});return new i.DERSequence({array:[n,r]}).getEncodedHex()},ft.crypto.ECDSA.getName=function(t){return"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040022"===t?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":null},void 0!==ft&&ft||(ft={}),void 0!==ft.crypto&&ft.crypto||(ft.crypto={}),ft.crypto.ECParameterDB=new function(){var t={},e={};function i(t){return new x(t,16)}this.getByName=function(i){var n=i;if(void 0!==e[n]&&(n=e[i]),void 0!==t[n])return t[n];throw"unregistered EC curve name: "+n},this.regist=function(n,r,s,o,a,h,u,c,l,f,d,g){t[n]={};var p=i(s),y=i(o),v=i(a),m=i(h),S=i(u),F=new ct(p,y,v),E=F.decodePointHex("04"+c+l);t[n].name=n,t[n].keylen=r,t[n].curve=F,t[n].G=E,t[n].n=m,t[n].h=S,t[n].oid=d,t[n].info=g;for(var w=0;w1?new x(n,16):null,u=new x(r,16),this.setPrivate(s,o,a,h,u)},this.setPublic=function(t,e,i,n){this.isPublic=!0,this.p=t,this.q=e,this.g=i,this.y=n,this.x=null},this.setPublicHex=function(t,e,i,n){var r,s,o,a;r=new x(t,16),s=new x(e,16),o=new x(i,16),a=new x(n,16),this.setPublic(r,s,o,a)},this.signWithMessageHash=function(t){var e=this.p,i=this.q,n=this.g,r=(this.y,this.x),s=ft.crypto.Util.getRandomBigIntegerMinToMax(x.ONE.add(x.ONE),i.subtract(x.ONE)),o=new x(t.substr(0,i.bitLength()/4),16),a=n.modPow(s,e).mod(i),h=s.modInverse(i).multiply(o.add(r.multiply(a))).mod(i);return ft.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:a}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var i=this.p,n=this.q,r=this.g,s=this.y,o=this.parseASN1Signature(e),a=o[0],h=o[1],u=new x(t.substr(0,n.bitLength()/4),16);if(x.ZERO.compareTo(a)>0||a.compareTo(n)>0)throw"invalid DSA signature";if(x.ZERO.compareTo(h)>=0||h.compareTo(n)>0)throw"invalid DSA signature";var c=h.modInverse(n),l=u.multiply(c).mod(n),f=a.multiply(c).mod(n);return 0==r.modPow(l,i).multiply(s.modPow(f,i)).mod(i).mod(n).compareTo(a)},this.parseASN1Signature=function(t){try{return[new x(pt.getVbyList(t,0,[0],"02"),16),new x(pt.getVbyList(t,0,[1],"02"),16)]}catch(t){throw"malformed ASN.1 DSA signature"}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r,s,o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{e=a(t,0,[1],"02"),i=a(t,0,[2],"02"),n=a(t,0,[3],"02"),r=a(t,0,[4],"02"),s=a(t,0,[5],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#1/5 plain DSA private key"}this.setPrivateHex(e,i,n,r,s)},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[1,1,0],"02"),i=o(t,0,[1,1,1],"02"),n=o(t,0,[1,1,2],"02"),r=o(t,0,[2,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 plain DSA private key"}this.setPrivateHex(e,i,n,null,r)},this.readPKCS8PubKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[0,1,0],"02"),i=o(t,0,[0,1,1],"02"),n=o(t,0,[0,1,2],"02"),r=o(t,0,[1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 DSA public key"}this.setPublicHex(e,i,n,r)},this.readCertPubKeyHex=function(t,e){var i,n,r,s;5!==e&&(e=6);var o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{i=a(t,0,[0,e,0,1,0],"02"),n=a(t,0,[0,e,0,1,1],"02"),r=a(t,0,[0,e,0,1,2],"02"),s=a(t,0,[0,e,1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed X.509 certificate DSA public key"}this.setPublicHex(i,n,r,s)}};var Ut=function(){var t=function(t,i,n){return e(y.AES,t,i,n)},e=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=r;var h=t.decrypt(a,s,{iv:o});return y.enc.Hex.stringify(h)},i=function(t,e,i){return n(y.AES,t,e,i)},n=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a=t.encrypt(r,s,{iv:o}),h=y.enc.Hex.parse(a.toString());return y.enc.Base64.stringify(h)},r={"AES-256-CBC":{proc:t,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,i,n){return e(y.TripleDES,t,i,n)},eproc:function(t,e,i){return n(y.TripleDES,t,e,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,i,n){return e(y.DES,t,i,n)},eproc:function(t,e,i){return n(y.DES,t,e,i)},keylen:8,ivlen:8}},s=function(t){var e={},i=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(e.cipher=i[1],e.ivsalt=i[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var r=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(r=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(r=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=r&&-1!=o){var a=t.substring(r+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,i){for(var n=i.substring(0,16),s=y.enc.Hex.parse(n),o=y.enc.Utf8.parse(e),a=r[t].keylen+r[t].ivlen,h="",u=null;;){var c=y.algo.MD5.create();if(null!=u&&c.update(u),c.update(o),c.update(s),u=c.finalize(),(h+=y.enc.Hex.stringify(u)).length>=2*a)break}var l={};return l.keyhex=h.substr(0,2*r[t].keylen),l.ivhex=h.substr(2*r[t].keylen,2*r[t].ivlen),l},a=function(t,e,i,n){var s=y.enc.Base64.parse(t),o=y.enc.Hex.stringify(s);return(0,r[e].proc)(o,i,n)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,i){return o(t,e,i)},decryptKeyB64:function(t,e,i,n){return a(t,e,i,n)},getDecryptedKeyHex:function(t,e){var i=s(t),n=(i.type,i.cipher),r=i.ivsalt,h=i.data,u=o(n,e,r).keyhex;return a(h,n,u,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,i,n,s){var a="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===r[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==s&&null!=s||(s=function(t){var e=y.lib.WordArray.random(t);return y.enc.Hex.stringify(e)}(r[n].ivlen).toUpperCase());var h=function(t,e,i,n){return(0,r[e].eproc)(t,i,n)}(e,n,o(n,i,s).keyhex,s);a="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+n+","+s+"\r\n",a+="\r\n",a+=h.replace(/(.{64})/g,"$1\r\n"),a+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={},s=i(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;r.ciphertext=n(t,s[1]);var o=i(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=i(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var h=i(t,a[1]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length;if("2a864886f70d0307"!=n(t,h[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(t,h[1]);var u=i(t,a[0]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length;if("2a864886f70d01050c"!=n(t,u[0]))throw"this only supports pkcs5PBKDF2";var c=i(t,u[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;r.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{r.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return r},getPBKDF2KeyHexFromParam:function(t,e){var i=y.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,r=y.PBKDF2(e,i,{keySize:6,iterations:n});return y.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var i=Ht(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=Ut.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=y.enc.Hex.parse(n.ciphertext);var o=y.enc.Hex.parse(r),a=y.enc.Hex.parse(n.encryptionSchemeIV),h=y.TripleDES.decrypt(s,o,{iv:a});return y.enc.Hex.stringify(h)},getKeyFromEncryptedPKCS8PEM:function(t,e){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var s=i(t,0);if(3!=s.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(s[1],2))throw"malformed PKCS8 private key(code:003)";var o=i(t,s[1]);if(2!=o.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(o[0],2))throw"malformed PKCS8 private key(code:005)";if(r.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(r.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw"malformed PKCS8 private key(code:006)";return r.keyidx=e.getVidx(t,s[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Ht(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,i=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==i.algoid)e=new ot;else if("2a8648ce380401"==i.algoid)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";e=new ft.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,i=pt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===i)e=new ot;else if("2a8648ce380401"===i)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";e=new ft.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=i(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(r.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return r.e=n(t,s[1]),r},parsePublicPKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null},s=i(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=i(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?r.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(r.algparam={},r.algparam.p=e.getVbyList(t,a[1],[0],"02"),r.algparam.q=e.getVbyList(t,a[1],[1],"02"),r.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(t,s[1]).substr(2),r}}}();Ut.getKey=function(t,e,i){var n=(y=pt).getChildIdx,r=(y.getV,y.getVbyList),s=ft.crypto,o=s.ECDSA,a=s.DSA,h=ot,u=Ht,c=Ut;if(void 0!==h&&t instanceof h)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(t.n,t.e),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(D=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(D=new h).setPrivate(t.n,t.e,t.d),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(D=new a).setPublic(t.p,t.q,t.g,t.y),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(D=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(xt(t.n),xt(t.e)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(D=new h).setPrivateEx(xt(t.n),xt(t.e),xt(t.d),xt(t.p),xt(t.q),xt(t.dp),xt(t.dq),xt(t.qi)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(D=new h).setPrivate(xt(t.n),xt(t.e),xt(t.d)),D;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);return C.setPublicKeyHex(f),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);var d=("0000000000"+xt(t.d)).slice(-l);return C.setPublicKeyHex(f),C.setPrivateKeyHex(d),C}if("pkcs5prv"===i){var g,p=t,y=pt;if(9===(g=n(p,0)).length)(D=new h).readPKCS5PrvKeyHex(p);else if(6===g.length)(D=new a).readPKCS5PrvKeyHex(p);else{if(!(g.length>2&&"04"===p.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(D=new o).readPKCS5PrvKeyHex(p)}return D}if("pkcs8prv"===i)return D=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===i)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===i)return Jt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Jt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=Ht(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=u(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=r(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),F=r(R,0,[2],"02"),E=r(R,0,[3],"02"),w=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(E,16),new x(w,16),new x(b,16)),D}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var A=c.getDecryptedKeyHex(t,e),I=new ot;return I.readPKCS5PrvKeyHex(A),I}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var C,D=r(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),T=r(R,0,[2,0],"06"),P=r(R,0,[3,0],"03").substr(2);if(void 0===ft.crypto.OID.oidhex2name[T])throw"undefined OID(hex) in KJUR.crypto.OID: "+T;return(C=new o({curve:ft.crypto.OID.oidhex2name[T]})).setPublicKeyHex(P),C.setPrivateKeyHex(D),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;S=r(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),F=r(R,0,[2],"02"),E=r(R,0,[3],"02"),w=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(E,16),new x(w,16),new x(b,16)),D}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw"not supported argument"},Ut.generateKeypair=function(t,e){if("RSA"==t){var i=e;(o=new ot).generate(i,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new ot,r=o.n.toString(16),s=o.e.toString(16);return n.setPublic(r,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,h=e,u=new ft.crypto.ECDSA({curve:h}).generateKeyPairHex();return(o=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),o.setPrivateKeyHex(u.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Ut.getPEM=function(t,e,i,n,r,s){var o=ft,a=o.asn1,h=a.DERObjectIdentifier,u=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,f=o.crypto,d=f.DSA,g=f.ECDSA,p=ot;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function S(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==p&&t instanceof p||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Rt(x=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=v(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===i||null==i)&&1==t.isPrivate){var F=new h({name:t.curveName}).getEncodedHex(),E=m(t).getEncodedHex(),w="";return w+=Rt(F,"EC PARAMETERS"),w+=Rt(E,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=S(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==i&&null!=i&&1==t.isPrivate){var x=v(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==i&&null!=i&&1==t.isPrivate){x=m(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==i&&null!=i&&1==t.isPrivate){x=S(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",x,i,n,s)}var b=function(t,e){var i=A(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},A=function(t,e){var i=y.lib.WordArray.random(8),n=y.lib.WordArray.random(8),r=y.PBKDF2(e,i,{keySize:6,iterations:100}),s=y.enc.Hex.parse(t),o=y.TripleDES.encrypt(s,r,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=y.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=y.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=p&&t instanceof p&&1==t.isPrivate){var I=v(t).getEncodedHex();x=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){I=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){I=new u({bigint:t.x}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(E=b(x,i),"ENCRYPTED PRIVATE KEY")}throw"unsupported object nor format"},Ut.getKeyFromCSRPEM=function(t){var e=Ht(t,"CERTIFICATE REQUEST");return Ut.getKeyFromCSRHex(e)},Ut.getKeyFromCSRHex=function(t){var e=Ut.parseCSRHex(t);return Ut.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Ut.parseCSRHex=function(t){var e=pt,i=e.getChildIdx,n=e.getTLV,r={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=i(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=i(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(s,a[2]),r},Ut.getJWKFromKey=function(t){var e={};if(t instanceof ot&&t.isPrivate)return e.kty="RSA",e.n=wt(t.n.toString(16)),e.e=wt(t.e.toString(16)),e.d=wt(t.d.toString(16)),e.p=wt(t.p.toString(16)),e.q=wt(t.q.toString(16)),e.dp=wt(t.dmp1.toString(16)),e.dq=wt(t.dmq1.toString(16)),e.qi=wt(t.coeff.toString(16)),e;if(t instanceof ot&&t.isPublic)return e.kty="RSA",e.n=wt(t.n.toString(16)),e.e=wt(t.e.toString(16)),e;if(t instanceof ft.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=wt(i.x),e.y=wt(i.y),e.d=wt(t.prvKeyHex),e}if(t instanceof ft.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=wt(i.x),e.y=wt(i.y),e}throw"not supported key object"},ot.getPosArrayOfChildrenFromHex=function(t){return pt.getChildIdx(t,0)},ot.getHexValueArrayOfChildrenFromHex=function(t){var e,i=pt.getV,n=i(t,(e=ot.getPosArrayOfChildrenFromHex(t))[0]),r=i(t,e[1]),s=i(t,e[2]),o=i(t,e[3]),a=i(t,e[4]),h=i(t,e[5]),u=i(t,e[6]),c=i(t,e[7]),l=i(t,e[8]);return(e=new Array).push(n,r,s,o,a,h,u,c,l),e},ot.prototype.readPrivateKeyFromPEMString=function(t){var e=Ht(t),i=ot.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},ot.prototype.readPKCS5PrvKeyHex=function(t){var e=ot.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},ot.prototype.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s,o,a,h,u=pt,c=u.getVbyList;if(!1===u.isASN1HEX(t))throw"not ASN.1 hex string";try{e=c(t,0,[2,0,1],"02"),i=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),r=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw"malformed PKCS#8 plain RSA private key"}this.setPrivateEx(e,i,n,r,s,o,a,h)},ot.prototype.readPKCS5PubKeyHex=function(t){var e=pt,i=e.getV;if(!1===e.isASN1HEX(t))throw"keyHex is not ASN.1 hex string";var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw"wrong hex for PKCS#5 public key";var r=i(t,n[0]),s=i(t,n[1]);this.setPublic(r,s)},ot.prototype.readPKCS8PubKeyHex=function(t){var e=pt;if(!1===e.isASN1HEX(t))throw"not ASN.1 hex string";if("06092a864886f70d010101"!==e.getTLVbyList(t,0,[0,0]))throw"not PKCS8 RSA public key";var i=e.getTLVbyList(t,0,[1,0]);this.readPKCS5PubKeyHex(i)},ot.prototype.readCertPubKeyHex=function(t,e){var i,n;(i=new Jt).readCertHex(t),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var qt=new RegExp("");function zt(t,e){for(var i="",n=e/4-t.length,r=0;r>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function Yt(t){for(var e in ft.crypto.Util.DIGESTINFOHEAD){var i=ft.crypto.Util.DIGESTINFOHEAD[e],n=i.length;if(t.substring(0,n)==i)return[e,t.substring(n)]}return[]}function Jt(){var t=pt,e=t.getChildIdx,i=t.getV,n=t.getTLV,r=t.getVbyList,s=t.getTLVbyList,o=t.getIdxbyList,a=t.getVidx,h=t.oidname,u=Jt,c=Ht;this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){return null===this.hex||0!==this.version?this.version:"a003020102"!==s(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return r(this.hex,0,[0,1+this.foffset],"02")},this.getSignatureAlgorithmField=function(){return h(r(this.hex,0,[0,2+this.foffset,0],"06"))},this.getIssuerHex=function(){return s(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return u.hex2dn(this.getIssuerHex())},this.getSubjectHex=function(){return s(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return u.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=r(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=r(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return t.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return o(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return o(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Ut.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){return h(r(this.hex,0,[1,0],"06"))},this.getSignatureValueHex=function(){return r(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmName(),i=this.getSignatureValueHex(),n=s(this.hex,0,[0],"30"),r=new ft.crypto.Signature({alg:e});return r.init(t),r.updateHex(n),r.verify(i)},this.parseExt=function(){if(3!==this.version)return-1;var i=o(this.hex,0,[0,7,0],"30"),n=e(this.hex,i);this.aExtInfo=new Array;for(var s=0;s0&&(u=new Array(i),(new nt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=It(h(Ct("\0\0\0\0\0\0\0\0"+r+u))),l=[];for(n=0;n>8*a-o&255;for(g[0]&=~p,n=0;nthis.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;var r=n[0];return n[1]==function(t){return ft.crypto.Util.hashString(t,r)}(t)},ot.prototype.verifyWithMessageHash=function(t,e){var i=rt(e=(e=e.replace(qt,"")).replace(/[ \n]+/g,""),16);if(i.bitLength()>this.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;n[0];return n[1]==t},ot.prototype.verifyPSS=function(t,e,i,n){var r,s=(r=Ct(t),ft.crypto.Util.hashHex(r,i));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(s,e,i,n)},ot.prototype.verifyWithMessageHashPSS=function(t,e,i,n){var r=new x(e,16);if(r.bitLength()>this.n.bitLength())return!1;var s,o=function(t){return ft.crypto.Util.hashHex(t,i)},a=It(t),h=a.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===n||void 0===n)n=h;else if(-2===n)n=c-h-2;else if(n<-2)throw"invalid salt length";if(c>8*c-u&255;if(0!=(f.charCodeAt(0)&g))throw"bits beyond keysize not zero";var p=Gt(d,f.length,o),y=[];for(s=0;s0)&&-1==(":"+i.join(":")+":").indexOf(":"+p+":"))throw"algorithm '"+p+"' not accepted in the list";if("none"!=p&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Ut.getKey(e)),!("RS"!=y&&"PS"!=y||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==y&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===s.jwsalg2sigalg[g.alg])throw"unsupported alg name: "+p;if("none"==(v=s.jwsalg2sigalg[p]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var S,F=null;try{F=h.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(F)}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(d)},ft.jws.JWS.parse=function(t){var e,i,n,r=t.split("."),s={};if(2!=r.length&&3!=r.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=r[0],i=r[1],3==r.length&&(n=r[2]),s.headerObj=ft.jws.JWS.readSafeJSONString(gt(e)),s.payloadObj=ft.jws.JWS.readSafeJSONString(gt(i)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=gt(i):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==n&&(s.sigHex=xt(n)),s},ft.jws.JWS.verifyJWT=function(t,e,i){var n=ft.jws,r=n.JWS,s=r.readSafeJSONString,o=r.inArray,a=r.includedArray,h=t.split("."),u=h[0],c=h[1],l=(xt(h[2]),s(gt(u))),f=s(gt(c));if(void 0===l.alg)return!1;if(void 0===i.alg)throw"acceptField.alg shall be specified";if(!o(l.alg,i.alg))return!1;if(void 0!==f.iss&&"object"==typeof i.iss&&!o(f.iss,i.iss))return!1;if(void 0!==f.sub&&"object"==typeof i.sub&&!o(f.sub,i.sub))return!1;if(void 0!==f.aud&&"object"==typeof i.aud)if("string"==typeof f.aud){if(!o(f.aud,i.aud))return!1}else if("object"==typeof f.aud&&!a(f.aud,i.aud))return!1;var d=n.IntDate.getNow();return void 0!==i.verifyAt&&"number"==typeof i.verifyAt&&(d=i.verifyAt),void 0!==i.gracePeriod&&"number"==typeof i.gracePeriod||(i.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+i.gracePeriodr&&this.aHeader.pop(),this.aSignature.length>r&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignatures=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},e.SecureRandom=nt,e.rng_seed_time=Z,e.BigInteger=x,e.RSAKey=ot,e.ECDSA=ft.crypto.ECDSA,e.DSA=ft.crypto.DSA,e.Signature=ft.crypto.Signature,e.MessageDigest=ft.crypto.MessageDigest,e.Mac=ft.crypto.Mac,e.Cipher=ft.crypto.Cipher,e.KEYUTIL=Ut,e.ASN1HEX=pt,e.X509=Jt,e.CryptoJS=y,e.b64tohex=E,e.b64toBA=w,e.stoBA=yt,e.BAtos=vt,e.BAtohex=mt,e.stohex=St,e.stob64=function(t){return F(St(t))},e.stob64u=function(t){return Ft(F(St(t)))},e.b64utos=function(t){return vt(w(Et(t)))},e.b64tob64u=Ft,e.b64utob64=Et,e.hex2b64=F,e.hextob64u=wt,e.b64utohex=xt,e.utf8tob64u=dt,e.b64utoutf8=gt,e.utf8tob64=function(t){return F(Ot(Kt(t)))},e.b64toutf8=function(t){return decodeURIComponent(jt(E(t)))},e.utf8tohex=bt,e.hextoutf8=At,e.hextorstr=It,e.rstrtohex=Ct,e.hextob64=Dt,e.hextob64nl=Tt,e.b64nltohex=Pt,e.hextopem=Rt,e.pemtohex=Ht,e.hextoArrayBuffer=function(t){if(t.length%2!=0)throw"input is not even length";if(null==t.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var e=new ArrayBuffer(t.length/2),i=new DataView(e),n=0;ne.length&&(i=e.length);for(var n=0;n300)throw s.includes("id token not generated with cloud directory idp")?new r(`${JSON.parse(s).error_description}`,i.status):new r(`Failed to fetch ${t}. Response=${s}`,i.status);try{return JSON.parse(s)}catch(e){if(""!==s)return s;throw new r(`Invalid response while trying to fetch ${t}. Response=${s}`,i.status,e)}}}},function(t,e,i){const n=i(1),r=i(15);t.exports=class{constructor({jwt:t=i(0)}={}){this.jwt=t}decodeAndValidate({token:t,publicKeys:e,issuer:i,clientId:s,nonce:o}){const a=Math.floor(Date.now()/1e3),h=t.split(".");if(3!==h.length)throw new r(`Invalid JWT token. Got only ${h.length} parts.`);const u=this.jwt.KJUR.jws.JWS.parse(t);if(!u.headerObj)throw new r(n.INVALID_TOKEN);const c=u.headerObj.kid,l=this.getPublicKey(e.keys,c),f=this.jwt.KEYUTIL.getKey(l);if(!this.jwt.KJUR.jws.JWS.verify(t,f,{alg:[n.TOKEN_ALG]}))throw new r(n.INVALID_SIGNATURE);if(u.payloadObj.exp + * @license MIT + */ +var n=i(9),r=i(10),s=i(11);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return A(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function A(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return E(this,t,e,i);case"latin1":case"binary":return w(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function B(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||N(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(8))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(17);t.exports=class{constructor({w:t=window}={}){this.window=t}init(t){this.popupConfig=t}open(){const t=this.popupConfig.height,e=this.popupConfig.width,i=(window.screen.width-e)/2,r=(window.screen.height-t)/2;if(this.popup=this.window.open("","popup",`left=${i},top=${r},width=${e},height=${t},resizable,scrollbars=yes,status=1`),!this.popup)throw new n("Unable to open popup")}navigate(t){this.popup.location.href=t}close(){this.popup.close()}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(21);t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t);const i={"x-filter-type":`spa:v${n.version}`};this.publicKeys=e(this.getJwksEndpoint(),{headers:i})}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}},function(t){t.exports=JSON.parse('{"name":"ibmcloud-appid-js","version":"0.3.0","description":"IBM Cloud App ID SDK for Single Page Applications","scripts":{"build":"webpack","test":"mocha","coverage":"nyc --reporter=lcov mocha","docs":"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git"},"main":"dist/appid.umd.min.js","nyc":{"all":true,"include":["src/*.js"],"exclude":["**/PopupController.js","**/IFrameController.js","**/OpenIDConfigurationResource.js","**/constants.js"]},"dependencies":{"jsrsasign":"^8.0.12"},"devDependencies":{"node-fetch":"^2.6.0","@babel/cli":"^7.0.0","@babel/core":"^7.5.5","@babel/plugin-transform-runtime":"^7.5.5","@babel/preset-env":"^7.5.5","babel-cli":"^7.0.0-beta.3","chai":"^4.2.0","coveralls":"^3.0.6","gulp-babel":"^8.0.0","mocha":"^6.2.0","nyc":"^14.1.1","webpack":"^4.39.1","webpack-cli":"^3.3.6","docdash":"^1.1.1","jsdoc":"^3.6.3"}}')}]); \ No newline at end of file diff --git a/dist/appid.umd.min.js b/dist/appid.umd.min.js index 8eb800b..35ad0e0 100644 --- a/dist/appid.umd.min.js +++ b/dist/appid.umd.min.js @@ -1,345 +1,50 @@ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else if(typeof exports === 'object') - exports["AppID"] = factory(); - else - root["AppID"] = factory(); -})(window, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ "./node_modules/base64-js/index.js": -/*!*****************************************!*\ - !*** ./node_modules/base64-js/index.js ***! - \*****************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/base64-js/index.js?"); - -/***/ }), - -/***/ "./node_modules/buffer/index.js": -/*!**************************************!*\ - !*** ./node_modules/buffer/index.js ***! - \**************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("/* WEBPACK VAR INJECTION */(function(global) {/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n\n\nvar base64 = __webpack_require__(/*! base64-js */ \"./node_modules/base64-js/index.js\")\nvar ieee754 = __webpack_require__(/*! ieee754 */ \"./node_modules/ieee754/index.js\")\nvar isArray = __webpack_require__(/*! isarray */ \"./node_modules/isarray/index.js\")\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://AppID/./node_modules/buffer/index.js?"); - -/***/ }), - -/***/ "./node_modules/ieee754/index.js": -/*!***************************************!*\ - !*** ./node_modules/ieee754/index.js ***! - \***************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("exports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n\n\n//# sourceURL=webpack://AppID/./node_modules/ieee754/index.js?"); - -/***/ }), - -/***/ "./node_modules/isarray/index.js": -/*!***************************************!*\ - !*** ./node_modules/isarray/index.js ***! - \***************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n\n\n//# sourceURL=webpack://AppID/./node_modules/isarray/index.js?"); - -/***/ }), - -/***/ "./node_modules/jsrsasign/lib/jsrsasign.js": -/*!*************************************************!*\ - !*** ./node_modules/jsrsasign/lib/jsrsasign.js ***! - \*************************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\nvar navigator = {};\nnavigator.userAgent = false;\n\nvar window = {};\n/*\n * jsrsasign(all) 8.0.12 (2018-04-22) (c) 2010-2018 Kenji Urushima | kjur.github.com/jsrsasign/license\n */\n\n/*!\nCopyright (c) 2011, Yahoo! Inc. All rights reserved.\nCode licensed under the BSD License:\nhttp://developer.yahoo.com/yui/license.html\nversion: 2.9.0\n*/\nif(YAHOO===undefined){var YAHOO={}}YAHOO.lang={extend:function(g,h,f){if(!h||!g){throw new Error(\"YAHOO.lang.extend failed, please check that all dependencies are included.\")}var d=function(){};d.prototype=h.prototype;g.prototype=new d();g.prototype.constructor=g;g.superclass=h.prototype;if(h.prototype.constructor==Object.prototype.constructor){h.prototype.constructor=h}if(f){var b;for(b in f){g.prototype[b]=f[b]}var e=function(){},c=[\"toString\",\"valueOf\"];try{if(/MSIE/.test(navigator.userAgent)){e=function(j,i){for(b=0;b>>2]>>>(24-(r%4)*8))&255;q[(n+r)>>>2]|=o<<(24-((n+r)%4)*8)}}else{for(var r=0;r>>2]=p[r>>>2]}}this.sigBytes+=s;return this},clamp:function(){var o=this.words;var n=this.sigBytes;o[n>>>2]&=4294967295<<(32-(n%4)*8);o.length=e.ceil(n/4)},clone:function(){var n=j.clone.call(this);n.words=this.words.slice(0);return n},random:function(p){var o=[];for(var n=0;n>>2]>>>(24-(n%4)*8))&255;q.push((s>>>4).toString(16));q.push((s&15).toString(16))}return q.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>3]|=parseInt(p.substr(o,2),16)<<(24-(o%8)*4)}return new l.init(q,n/2)}};var d=m.Latin1={stringify:function(q){var r=q.words;var p=q.sigBytes;var n=[];for(var o=0;o>>2]>>>(24-(o%4)*8))&255;n.push(String.fromCharCode(s))}return n.join(\"\")},parse:function(p){var n=p.length;var q=[];for(var o=0;o>>2]|=(p.charCodeAt(o)&255)<<(24-(o%4)*8)}return new l.init(q,n)}};var c=m.Utf8={stringify:function(n){try{return decodeURIComponent(escape(d.stringify(n)))}catch(o){throw new Error(\"Malformed UTF-8 data\")}},parse:function(n){return d.parse(unescape(encodeURIComponent(n)))}};var i=b.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new l.init();this._nDataBytes=0},_append:function(n){if(typeof n==\"string\"){n=c.parse(n)}this._data.concat(n);this._nDataBytes+=n.sigBytes},_process:function(w){var q=this._data;var x=q.words;var n=q.sigBytes;var t=this.blockSize;var v=t*4;var u=n/v;if(w){u=e.ceil(u)}else{u=e.max((u|0)-this._minBufferSize,0)}var s=u*t;var r=e.min(s*4,n);if(s){for(var p=0;p>>2]&255}};f.BlockCipher=n.extend({cfg:n.cfg.extend({mode:m,padding:h}),reset:function(){n.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;\nthis._mode=c.call(a,this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var p=f.CipherParams=k.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),m=(g.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;\nreturn(a?l.create([1398893684,1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=l.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return p.create({ciphertext:a,salt:c})}},j=f.SerializableCipher=k.extend({cfg:k.extend({format:m}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return p.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,\nblockSize:a.blockSize,formatter:d.format})},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return\"string\"==typeof a?b.parse(a,this):a}}),g=(g.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=l.random(8));a=v.create({keySize:b+c}).compute(a,d);c=l.create(a.words.slice(b),4*c);a.sigBytes=4*b;return p.create({key:a,iv:c,salt:d})}},s=f.PasswordBasedCipher=j.extend({cfg:j.cfg.extend({kdf:g}),encrypt:function(a,\nb,c,d){d=this.cfg.extend(d);c=d.kdf.execute(c,a.keySize,a.ivSize);d.iv=c.iv;a=j.encrypt.call(this,a,b,c.key,d);a.mixIn(c);return a},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=c.iv;return j.decrypt.call(this,a,b,c.key,d)}})}();\n\n/*\nCryptoJS v3.1.2 aes.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){for(var q=CryptoJS,x=q.lib.BlockCipher,r=q.algo,j=[],y=[],z=[],A=[],B=[],C=[],s=[],u=[],v=[],w=[],g=[],k=0;256>k;k++)g[k]=128>k?k<<1:k<<1^283;for(var n=0,l=0,k=0;256>k;k++){var f=l^l<<1^l<<2^l<<3^l<<4,f=f>>>8^f&255^99;j[n]=f;y[f]=n;var t=g[n],D=g[t],E=g[D],b=257*g[f]^16843008*f;z[n]=b<<24|b>>>8;A[n]=b<<16|b>>>16;B[n]=b<<8|b>>>24;C[n]=b;b=16843009*E^65537*D^257*t^16843008*n;s[f]=b<<24|b>>>8;u[f]=b<<16|b>>>16;v[f]=b<<8|b>>>24;w[f]=b;n?(n=t^g[g[g[E^t]]],l^=g[g[l]]):n=l=1}var F=[0,1,2,4,8,\n16,32,64,128,27,54],r=r.AES=x.extend({_doReset:function(){for(var c=this._key,e=c.words,a=c.sigBytes/4,c=4*((this._nRounds=a+6)+1),b=this._keySchedule=[],h=0;h>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255]):(d=d<<8|d>>>24,d=j[d>>>24]<<24|j[d>>>16&255]<<16|j[d>>>8&255]<<8|j[d&255],d^=F[h/a|0]<<24);b[h]=b[h-a]^d}e=this._invKeySchedule=[];for(a=0;aa||4>=h?d:s[j[d>>>24]]^u[j[d>>>16&255]]^v[j[d>>>\n8&255]]^w[j[d&255]]},encryptBlock:function(c,e){this._doCryptBlock(c,e,this._keySchedule,z,A,B,C,j)},decryptBlock:function(c,e){var a=c[e+1];c[e+1]=c[e+3];c[e+3]=a;this._doCryptBlock(c,e,this._invKeySchedule,s,u,v,w,y);a=c[e+1];c[e+1]=c[e+3];c[e+3]=a},_doCryptBlock:function(c,e,a,b,h,d,j,m){for(var n=this._nRounds,f=c[e]^a[0],g=c[e+1]^a[1],k=c[e+2]^a[2],p=c[e+3]^a[3],l=4,t=1;t>>24]^h[g>>>16&255]^d[k>>>8&255]^j[p&255]^a[l++],r=b[g>>>24]^h[k>>>16&255]^d[p>>>8&255]^j[f&255]^a[l++],s=\nb[k>>>24]^h[p>>>16&255]^d[f>>>8&255]^j[g&255]^a[l++],p=b[p>>>24]^h[f>>>16&255]^d[g>>>8&255]^j[k&255]^a[l++],f=q,g=r,k=s;q=(m[f>>>24]<<24|m[g>>>16&255]<<16|m[k>>>8&255]<<8|m[p&255])^a[l++];r=(m[g>>>24]<<24|m[k>>>16&255]<<16|m[p>>>8&255]<<8|m[f&255])^a[l++];s=(m[k>>>24]<<24|m[p>>>16&255]<<16|m[f>>>8&255]<<8|m[g&255])^a[l++];p=(m[p>>>24]<<24|m[f>>>16&255]<<16|m[g>>>8&255]<<8|m[k&255])^a[l++];c[e]=q;c[e+1]=r;c[e+2]=s;c[e+3]=p},keySize:8});q.AES=x._createHelper(r)})();\n\n/*\nCryptoJS v3.1.2 tripledes-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function j(b,c){var a=(this._lBlock>>>b^this._rBlock)&c;this._rBlock^=a;this._lBlock^=a<>>b^this._lBlock)&c;this._lBlock^=a;this._rBlock^=a<a;a++){var f=q[a]-1;c[a]=b[f>>>5]>>>31-f%32&1}b=this._subKeys=[];for(f=0;16>f;f++){for(var d=b[f]=[],e=r[f],a=0;24>a;a++)d[a/6|0]|=c[(p[a]-1+e)%28]<<31-a%6,d[4+(a/6|0)]|=c[28+(p[a+24]-1+e)%28]<<31-a%6;d[0]=d[0]<<1|d[0]>>>31;for(a=1;7>a;a++)d[a]>>>=\n4*(a-1)+3;d[7]=d[7]<<5|d[7]>>>27}c=this._invSubKeys=[];for(a=0;16>a;a++)c[a]=b[15-a]},encryptBlock:function(b,c){this._doCryptBlock(b,c,this._subKeys)},decryptBlock:function(b,c){this._doCryptBlock(b,c,this._invSubKeys)},_doCryptBlock:function(b,c,a){this._lBlock=b[c];this._rBlock=b[c+1];j.call(this,4,252645135);j.call(this,16,65535);l.call(this,2,858993459);l.call(this,8,16711935);j.call(this,1,1431655765);for(var f=0;16>f;f++){for(var d=a[f],e=this._lBlock,h=this._rBlock,g=0,k=0;8>k;k++)g|=s[k][((h^\nd[k])&t[k])>>>0];this._lBlock=h;this._rBlock=e^g}a=this._lBlock;this._lBlock=this._rBlock;this._rBlock=a;j.call(this,1,1431655765);l.call(this,8,16711935);l.call(this,2,858993459);j.call(this,16,65535);j.call(this,4,252645135);b[c]=this._lBlock;b[c+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});h.DES=e._createHelper(m);g=g.TripleDES=e.extend({_doReset:function(){var b=this._key.words;this._des1=m.createEncryptor(n.create(b.slice(0,2)));this._des2=m.createEncryptor(n.create(b.slice(2,4)));this._des3=\nm.createEncryptor(n.create(b.slice(4,6)))},encryptBlock:function(b,c){this._des1.encryptBlock(b,c);this._des2.decryptBlock(b,c);this._des3.encryptBlock(b,c)},decryptBlock:function(b,c){this._des3.decryptBlock(b,c);this._des2.encryptBlock(b,c);this._des1.decryptBlock(b,c)},keySize:6,ivSize:2,blockSize:2});h.TripleDES=e._createHelper(g)})();\n\n/*\nCryptoJS v3.1.2 enc-base64.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join(\"\")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d<\ne;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\"}})();\n\n/*\nCryptoJS v3.1.2 md5.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(E){function h(a,f,g,j,p,h,k){a=a+(f&g|~f&j)+p+k;return(a<>>32-h)+f}function k(a,f,g,j,p,h,k){a=a+(f&j|g&~j)+p+k;return(a<>>32-h)+f}function l(a,f,g,j,h,k,l){a=a+(f^g^j)+h+l;return(a<>>32-k)+f}function n(a,f,g,j,h,k,l){a=a+(g^(f|~j))+h+l;return(a<>>32-k)+f}for(var r=CryptoJS,q=r.lib,F=q.WordArray,s=q.Hasher,q=r.algo,a=[],t=0;64>t;t++)a[t]=4294967296*E.abs(E.sin(t+1))|0;q=q.MD5=s.extend({_doReset:function(){this._hash=new F.init([1732584193,4023233417,2562383102,271733878])},\n_doProcessBlock:function(m,f){for(var g=0;16>g;g++){var j=f+g,p=m[j];m[j]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360}var g=this._hash.words,j=m[f+0],p=m[f+1],q=m[f+2],r=m[f+3],s=m[f+4],t=m[f+5],u=m[f+6],v=m[f+7],w=m[f+8],x=m[f+9],y=m[f+10],z=m[f+11],A=m[f+12],B=m[f+13],C=m[f+14],D=m[f+15],b=g[0],c=g[1],d=g[2],e=g[3],b=h(b,c,d,e,j,7,a[0]),e=h(e,b,c,d,p,12,a[1]),d=h(d,e,b,c,q,17,a[2]),c=h(c,d,e,b,r,22,a[3]),b=h(b,c,d,e,s,7,a[4]),e=h(e,b,c,d,t,12,a[5]),d=h(d,e,b,c,u,17,a[6]),c=h(c,d,e,b,v,22,a[7]),\nb=h(b,c,d,e,w,7,a[8]),e=h(e,b,c,d,x,12,a[9]),d=h(d,e,b,c,y,17,a[10]),c=h(c,d,e,b,z,22,a[11]),b=h(b,c,d,e,A,7,a[12]),e=h(e,b,c,d,B,12,a[13]),d=h(d,e,b,c,C,17,a[14]),c=h(c,d,e,b,D,22,a[15]),b=k(b,c,d,e,p,5,a[16]),e=k(e,b,c,d,u,9,a[17]),d=k(d,e,b,c,z,14,a[18]),c=k(c,d,e,b,j,20,a[19]),b=k(b,c,d,e,t,5,a[20]),e=k(e,b,c,d,y,9,a[21]),d=k(d,e,b,c,D,14,a[22]),c=k(c,d,e,b,s,20,a[23]),b=k(b,c,d,e,x,5,a[24]),e=k(e,b,c,d,C,9,a[25]),d=k(d,e,b,c,r,14,a[26]),c=k(c,d,e,b,w,20,a[27]),b=k(b,c,d,e,B,5,a[28]),e=k(e,b,\nc,d,q,9,a[29]),d=k(d,e,b,c,v,14,a[30]),c=k(c,d,e,b,A,20,a[31]),b=l(b,c,d,e,t,4,a[32]),e=l(e,b,c,d,w,11,a[33]),d=l(d,e,b,c,z,16,a[34]),c=l(c,d,e,b,C,23,a[35]),b=l(b,c,d,e,p,4,a[36]),e=l(e,b,c,d,s,11,a[37]),d=l(d,e,b,c,v,16,a[38]),c=l(c,d,e,b,y,23,a[39]),b=l(b,c,d,e,B,4,a[40]),e=l(e,b,c,d,j,11,a[41]),d=l(d,e,b,c,r,16,a[42]),c=l(c,d,e,b,u,23,a[43]),b=l(b,c,d,e,x,4,a[44]),e=l(e,b,c,d,A,11,a[45]),d=l(d,e,b,c,D,16,a[46]),c=l(c,d,e,b,q,23,a[47]),b=n(b,c,d,e,j,6,a[48]),e=n(e,b,c,d,v,10,a[49]),d=n(d,e,b,c,\nC,15,a[50]),c=n(c,d,e,b,t,21,a[51]),b=n(b,c,d,e,A,6,a[52]),e=n(e,b,c,d,r,10,a[53]),d=n(d,e,b,c,y,15,a[54]),c=n(c,d,e,b,p,21,a[55]),b=n(b,c,d,e,w,6,a[56]),e=n(e,b,c,d,D,10,a[57]),d=n(d,e,b,c,u,15,a[58]),c=n(c,d,e,b,B,21,a[59]),b=n(b,c,d,e,s,6,a[60]),e=n(e,b,c,d,z,10,a[61]),d=n(d,e,b,c,q,15,a[62]),c=n(c,d,e,b,x,21,a[63]);g[0]=g[0]+b|0;g[1]=g[1]+c|0;g[2]=g[2]+d|0;g[3]=g[3]+e|0},_doFinalize:function(){var a=this._data,f=a.words,g=8*this._nDataBytes,j=8*a.sigBytes;f[j>>>5]|=128<<24-j%32;var h=E.floor(g/\n4294967296);f[(j+64>>>9<<4)+15]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;f[(j+64>>>9<<4)+14]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360;a.sigBytes=4*(f.length+1);this._process();a=this._hash;f=a.words;for(g=0;4>g;g++)j=f[g],f[g]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=s.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=s._createHelper(q);r.HmacMD5=s._createHmacHelper(q)})(Math);\n\n/*\nCryptoJS v3.1.2 sha1-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var k=CryptoJS,b=k.lib,m=b.WordArray,l=b.Hasher,d=[],b=k.algo.SHA1=l.extend({_doReset:function(){this._hash=new m.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(n,p){for(var a=this._hash.words,e=a[0],f=a[1],h=a[2],j=a[3],b=a[4],c=0;80>c;c++){if(16>c)d[c]=n[p+c]|0;else{var g=d[c-3]^d[c-8]^d[c-14]^d[c-16];d[c]=g<<1|g>>>31}g=(e<<5|e>>>27)+b+d[c];g=20>c?g+((f&h|~f&j)+1518500249):40>c?g+((f^h^j)+1859775393):60>c?g+((f&h|f&j|h&j)-1894007588):g+((f^h^\nj)-899497514);b=j;j=h;h=f<<30|f>>>2;f=e;e=g}a[0]=a[0]+e|0;a[1]=a[1]+f|0;a[2]=a[2]+h|0;a[3]=a[3]+j|0;a[4]=a[4]+b|0},_doFinalize:function(){var b=this._data,d=b.words,a=8*this._nDataBytes,e=8*b.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=Math.floor(a/4294967296);d[(e+64>>>9<<4)+15]=a;b.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var b=l.clone.call(this);b._hash=this._hash.clone();return b}});k.SHA1=l._createHelper(b);k.HmacSHA1=l._createHmacHelper(b)})();\n\n/*\nCryptoJS v3.1.2 sha256-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(k){for(var g=CryptoJS,h=g.lib,v=h.WordArray,j=h.Hasher,h=g.algo,s=[],t=[],u=function(q){return 4294967296*(q-(q|0))|0},l=2,b=0;64>b;){var d;a:{d=l;for(var w=k.sqrt(d),r=2;r<=w;r++)if(!(d%r)){d=!1;break a}d=!0}d&&(8>b&&(s[b]=u(k.pow(l,0.5))),t[b]=u(k.pow(l,1/3)),b++);l++}var n=[],h=h.SHA256=j.extend({_doReset:function(){this._hash=new v.init(s.slice(0))},_doProcessBlock:function(q,h){for(var a=this._hash.words,c=a[0],d=a[1],b=a[2],k=a[3],f=a[4],g=a[5],j=a[6],l=a[7],e=0;64>e;e++){if(16>e)n[e]=\nq[h+e]|0;else{var m=n[e-15],p=n[e-2];n[e]=((m<<25|m>>>7)^(m<<14|m>>>18)^m>>>3)+n[e-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+n[e-16]}m=l+((f<<26|f>>>6)^(f<<21|f>>>11)^(f<<7|f>>>25))+(f&g^~f&j)+t[e]+n[e];p=((c<<30|c>>>2)^(c<<19|c>>>13)^(c<<10|c>>>22))+(c&d^c&b^d&b);l=j;j=g;g=f;f=k+m|0;k=b;b=d;d=c;c=m+p|0}a[0]=a[0]+c|0;a[1]=a[1]+d|0;a[2]=a[2]+b|0;a[3]=a[3]+k|0;a[4]=a[4]+f|0;a[5]=a[5]+g|0;a[6]=a[6]+j|0;a[7]=a[7]+l|0},_doFinalize:function(){var d=this._data,b=d.words,a=8*this._nDataBytes,c=8*d.sigBytes;\nb[c>>>5]|=128<<24-c%32;b[(c+64>>>9<<4)+14]=k.floor(a/4294967296);b[(c+64>>>9<<4)+15]=a;d.sigBytes=4*b.length;this._process();return this._hash},clone:function(){var b=j.clone.call(this);b._hash=this._hash.clone();return b}});g.SHA256=j._createHelper(h);g.HmacSHA256=j._createHmacHelper(h)})(Math);\n\n/*\nCryptoJS v3.1.2 sha224-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var b=CryptoJS,d=b.lib.WordArray,a=b.algo,c=a.SHA256,a=a.SHA224=c.extend({_doReset:function(){this._hash=new d.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var a=c._doFinalize.call(this);a.sigBytes-=4;return a}});b.SHA224=c._createHelper(a);b.HmacSHA224=c._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 sha512-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){function a(){return d.create.apply(d,arguments)}for(var n=CryptoJS,r=n.lib.Hasher,e=n.x64,d=e.Word,T=e.WordArray,e=n.algo,ea=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),\na(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,\n2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),\na(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,\n3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],w=0;80>w;w++)v[w]=a();e=e.SHA512=r.extend({_doReset:function(){this._hash=new T.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(a,d){for(var f=this._hash.words,\nF=f[0],e=f[1],n=f[2],r=f[3],G=f[4],H=f[5],I=f[6],f=f[7],w=F.high,J=F.low,X=e.high,K=e.low,Y=n.high,L=n.low,Z=r.high,M=r.low,$=G.high,N=G.low,aa=H.high,O=H.low,ba=I.high,P=I.low,ca=f.high,Q=f.low,k=w,g=J,z=X,x=K,A=Y,y=L,U=Z,B=M,l=$,h=N,R=aa,C=O,S=ba,D=P,V=ca,E=Q,m=0;80>m;m++){var s=v[m];if(16>m)var j=s.high=a[d+2*m]|0,b=s.low=a[d+2*m+1]|0;else{var j=v[m-15],b=j.high,p=j.low,j=(b>>>1|p<<31)^(b>>>8|p<<24)^b>>>7,p=(p>>>1|b<<31)^(p>>>8|b<<24)^(p>>>7|b<<25),u=v[m-2],b=u.high,c=u.low,u=(b>>>19|c<<13)^(b<<\n3|c>>>29)^b>>>6,c=(c>>>19|b<<13)^(c<<3|b>>>29)^(c>>>6|b<<26),b=v[m-7],W=b.high,t=v[m-16],q=t.high,t=t.low,b=p+b.low,j=j+W+(b>>>0

>>0?1:0),b=b+c,j=j+u+(b>>>0>>0?1:0),b=b+t,j=j+q+(b>>>0>>0?1:0);s.high=j;s.low=b}var W=l&R^~l&S,t=h&C^~h&D,s=k&z^k&A^z&A,T=g&x^g&y^x&y,p=(k>>>28|g<<4)^(k<<30|g>>>2)^(k<<25|g>>>7),u=(g>>>28|k<<4)^(g<<30|k>>>2)^(g<<25|k>>>7),c=ea[m],fa=c.high,da=c.low,c=E+((h>>>14|l<<18)^(h>>>18|l<<14)^(h<<23|l>>>9)),q=V+((l>>>14|h<<18)^(l>>>18|h<<14)^(l<<23|h>>>9))+(c>>>0>>0?1:\n0),c=c+t,q=q+W+(c>>>0>>0?1:0),c=c+da,q=q+fa+(c>>>0>>0?1:0),c=c+b,q=q+j+(c>>>0>>0?1:0),b=u+T,s=p+s+(b>>>0>>0?1:0),V=S,E=D,S=R,D=C,R=l,C=h,h=B+c|0,l=U+q+(h>>>0>>0?1:0)|0,U=A,B=y,A=z,y=x,z=k,x=g,g=c+b|0,k=q+s+(g>>>0>>0?1:0)|0}J=F.low=J+g;F.high=w+k+(J>>>0>>0?1:0);K=e.low=K+x;e.high=X+z+(K>>>0>>0?1:0);L=n.low=L+y;n.high=Y+A+(L>>>0>>0?1:0);M=r.low=M+B;r.high=Z+U+(M>>>0>>0?1:0);N=G.low=N+h;G.high=$+l+(N>>>0>>0?1:0);O=H.low=O+C;H.high=aa+R+(O>>>0>>0?1:0);P=I.low=P+D;\nI.high=ba+S+(P>>>0>>0?1:0);Q=f.low=Q+E;f.high=ca+V+(Q>>>0>>0?1:0)},_doFinalize:function(){var a=this._data,d=a.words,f=8*this._nDataBytes,e=8*a.sigBytes;d[e>>>5]|=128<<24-e%32;d[(e+128>>>10<<5)+30]=Math.floor(f/4294967296);d[(e+128>>>10<<5)+31]=f;a.sigBytes=4*d.length;this._process();return this._hash.toX32()},clone:function(){var a=r.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});n.SHA512=r._createHelper(e);n.HmacSHA512=r._createHmacHelper(e)})();\n\n/*\nCryptoJS v3.1.2 sha384-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,a=c.x64,b=a.Word,e=a.WordArray,a=c.algo,d=a.SHA512,a=a.SHA384=d.extend({_doReset:function(){this._hash=new e.init([new b.init(3418070365,3238371032),new b.init(1654270250,914150663),new b.init(2438529370,812702999),new b.init(355462360,4144912697),new b.init(1731405415,4290775857),new b.init(2394180231,1750603025),new b.init(3675008525,1694076839),new b.init(1203062813,3204075428)])},_doFinalize:function(){var a=d._doFinalize.call(this);a.sigBytes-=16;return a}});c.SHA384=\nd._createHelper(a);c.HmacSHA384=d._createHmacHelper(a)})();\n\n/*\nCryptoJS v3.1.2 ripemd160-min.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n/*\n\n(c) 2012 by Cedric Mesnil. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n(function(){var q=CryptoJS,d=q.lib,n=d.WordArray,p=d.Hasher,d=q.algo,x=n.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),y=n.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),z=n.create([11,14,15,12,\n5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),A=n.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),B=n.create([0,1518500249,1859775393,2400959708,2840853838]),C=n.create([1352829926,1548603684,1836072691,\n2053994217,0]),d=d.RIPEMD160=p.extend({_doReset:function(){this._hash=n.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,v){for(var b=0;16>b;b++){var c=v+b,f=e[c];e[c]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360}var c=this._hash.words,f=B.words,d=C.words,n=x.words,q=y.words,p=z.words,w=A.words,t,g,h,j,r,u,k,l,m,s;u=t=c[0];k=g=c[1];l=h=c[2];m=j=c[3];s=r=c[4];for(var a,b=0;80>b;b+=1)a=t+e[v+n[b]]|0,a=16>b?a+((g^h^j)+f[0]):32>b?a+((g&h|~g&j)+f[1]):48>b?\na+(((g|~h)^j)+f[2]):64>b?a+((g&j|h&~j)+f[3]):a+((g^(h|~j))+f[4]),a|=0,a=a<>>32-p[b],a=a+r|0,t=r,r=j,j=h<<10|h>>>22,h=g,g=a,a=u+e[v+q[b]]|0,a=16>b?a+((k^(l|~m))+d[0]):32>b?a+((k&m|l&~m)+d[1]):48>b?a+(((k|~l)^m)+d[2]):64>b?a+((k&l|~k&m)+d[3]):a+((k^l^m)+d[4]),a|=0,a=a<>>32-w[b],a=a+s|0,u=s,s=m,m=l<<10|l>>>22,l=k,k=a;a=c[1]+h+m|0;c[1]=c[2]+j+s|0;c[2]=c[3]+r+u|0;c[3]=c[4]+t+k|0;c[4]=c[0]+g+l|0;c[0]=a},_doFinalize:function(){var e=this._data,d=e.words,b=8*this._nDataBytes,c=8*e.sigBytes;\nd[c>>>5]|=128<<24-c%32;d[(c+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;e.sigBytes=4*(d.length+1);this._process();e=this._hash;d=e.words;for(b=0;5>b;b++)c=d[b],d[b]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return e},clone:function(){var d=p.clone.call(this);d._hash=this._hash.clone();return d}});q.RIPEMD160=p._createHelper(d);q.HmacRIPEMD160=p._createHmacHelper(d)})(Math);\n\n/*\nCryptoJS v3.1.2 hmac.js\ncode.google.com/p/crypto-js\n(c) 2009-2013 by Jeff Mott. All rights reserved.\ncode.google.com/p/crypto-js/wiki/License\n*/\n(function(){var c=CryptoJS,k=c.enc.Utf8;c.algo.HMAC=c.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;\"string\"==typeof b&&(b=k.parse(b));var c=a.blockSize,e=4*c;b.sigBytes>e&&(b=a.finalize(b));b.clamp();for(var f=this._oKey=b.clone(),g=this._iKey=b.clone(),h=f.words,j=g.words,d=0;d>6)+b64map.charAt(e&63)}if(b+1==d.length){e=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(e<<2)}else{if(b+2==d.length){e=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(e>>2)+b64map.charAt((e&3)<<4)}}if(b64pad){while((a.length&3)>0){a+=b64pad}}return a}function b64tohex(f){var d=\"\";var e;var b=0;var c;var a;for(e=0;e>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(e){var d=b64tohex(e);var c;var b=new Array();for(c=0;2*c=0){var d=a*this[f++]+b[e]+h;h=Math.floor(d/67108864);b[e++]=d&67108863}return h}function am2(f,q,r,e,o,a){var k=q&32767,p=q>>15;while(--a>=0){var d=this[f]&32767;var g=this[f++]>>15;var b=p*d+g*k;d=k*d+((b&32767)<<15)+r[e]+(o&1073741823);o=(d>>>30)+(b>>>15)+p*g+(o>>>30);r[e++]=d&1073741823}return o}function am3(f,q,r,e,o,a){var k=q&16383,p=q>>14;while(--a>=0){var d=this[f]&16383;var g=this[f++]>>14;var b=p*d+g*k;d=k*d+((b&16383)<<14)+r[e]+o;o=(d>>28)+(b>>14)+p*g;r[e++]=d&268435455}return o}if(j_lm&&(navigator.appName==\"Microsoft Internet Explorer\")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator.appName!=\"Netscape\")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=((1<=0;--a){b[a]=this[a]}b.t=this.t;b.s=this.s}function bnpFromInt(a){this.t=1;this.s=(a<0)?-1:0;if(a>0){this[0]=a}else{if(a<-1){this[0]=a+this.DV}else{this.t=0}}}function nbv(a){var b=nbi();b.fromInt(a);return b}function bnpFromString(h,c){var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==256){e=8}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{this.fromRadix(h,c);return}}}}}}this.t=0;this.s=0;var g=h.length,d=false,f=0;while(--g>=0){var a=(e==8)?h[g]&255:intAt(h,g);if(a<0){if(h.charAt(g)==\"-\"){d=true}continue}d=false;if(f==0){this[this.t++]=a}else{if(f+e>this.DB){this[this.t-1]|=(a&((1<<(this.DB-f))-1))<>(this.DB-f))}else{this[this.t-1]|=a<=this.DB){f-=this.DB}}if(e==8&&(h[0]&128)!=0){this.s=-1;if(f>0){this[this.t-1]|=((1<<(this.DB-f))-1)<0&&this[this.t-1]==a){--this.t}}function bnToString(c){if(this.s<0){return\"-\"+this.negate().toString(c)}var e;if(c==16){e=4}else{if(c==8){e=3}else{if(c==2){e=1}else{if(c==32){e=5}else{if(c==4){e=2}else{return this.toRadix(c)}}}}}var g=(1<0){if(j>j)>0){a=true;h=int2char(l)}while(f>=0){if(j>(j+=this.DB-e)}else{l=(this[f]>>(j-=e))&g;if(j<=0){j+=this.DB;--f}}if(l>0){a=true}if(a){h+=int2char(l)}}}return a?h:\"0\"}function bnNegate(){var a=nbi();BigInteger.ZERO.subTo(this,a);return a}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(b){var d=this.s-b.s;if(d!=0){return d}var c=this.t;d=c-b.t;if(d!=0){return(this.s<0)?-d:d}while(--c>=0){if((d=this[c]-b[c])!=0){return d}}return 0}function nbits(a){var c=1,b;if((b=a>>>16)!=0){a=b;c+=16}if((b=a>>8)!=0){a=b;c+=8}if((b=a>>4)!=0){a=b;c+=4}if((b=a>>2)!=0){a=b;c+=2}if((b=a>>1)!=0){a=b;c+=1}return c}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(c,b){var a;for(a=this.t-1;a>=0;--a){b[a+c]=this[a]}for(a=c-1;a>=0;--a){b[a]=0}b.t=this.t+c;b.s=this.s}function bnpDRShiftTo(c,b){for(var a=c;a=0;--d){e[d+f+1]=(this[d]>>a)|h;h=(this[d]&g)<=0;--d){e[d]=0}e[f]=h;e.t=this.t+f+1;e.s=this.s;e.clamp()}function bnpRShiftTo(g,d){d.s=this.s;var e=Math.floor(g/this.DB);if(e>=this.t){d.t=0;return}var b=g%this.DB;var a=this.DB-b;var f=(1<>b;for(var c=e+1;c>b}if(b>0){d[this.t-e-1]|=(this.s&f)<>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g-=d.s}f.s=(g<0)?-1:0;if(g<-1){f[e++]=this.DV+g}else{if(g>0){f[e++]=g}}f.t=e;f.clamp()}function bnpMultiplyTo(c,e){var b=this.abs(),f=c.abs();var d=b.t;e.t=d+f.t;while(--d>=0){e[d]=0}for(d=0;d=0){d[b]=0}for(b=0;b=a.DV){d[b+a.t]-=a.DV;d[b+a.t+1]=1}}if(d.t>0){d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)}d.s=0;d.clamp()}function bnpDivRemTo(n,h,g){var w=n.abs();if(w.t<=0){return}var k=this.abs();if(k.t0){w.lShiftTo(v,d);k.lShiftTo(v,g)}else{w.copyTo(d);k.copyTo(g)}var p=d.t;var b=d[p-1];if(b==0){return}var o=b*(1<1)?d[p-2]>>this.F2:0);var A=this.FV/o,z=(1<=0){g[g.t++]=1;g.subTo(f,g)}BigInteger.ONE.dlShiftTo(p,f);f.subTo(d,d);while(d.t=0){var c=(g[--u]==b)?this.DM:Math.floor(g[u]*A+(g[u-1]+x)*z);if((g[u]+=d.am(0,c,g,s,0,p))0){g.rShiftTo(v,g)}if(a<0){BigInteger.ZERO.subTo(g,g)}}function bnMod(b){var c=nbi();this.abs().divRemTo(b,null,c);if(this.s<0&&c.compareTo(BigInteger.ZERO)>0){b.subTo(c,c)}return c}function Classic(a){this.m=a}function cConvert(a){if(a.s<0||a.compareTo(this.m)>=0){return a.mod(this.m)}else{return a}}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var a=this[0];if((a&1)==0){return 0}var b=a&3;b=(b*(2-(a&15)*b))&15;b=(b*(2-(a&255)*b))&255;b=(b*(2-(((a&65535)*b)&65535)))&65535;b=(b*(2-a*b%this.DV))%this.DV;return(b>0)?this.DV-b:-b}function Montgomery(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(a.DB-15))-1;this.mt2=2*a.t}function montConvert(a){var b=nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);if(a.s<0&&b.compareTo(BigInteger.ZERO)>0){this.m.subTo(b,b)}return b}function montRevert(a){var b=nbi();a.copyTo(b);this.reduce(b);return b}function montReduce(a){while(a.t<=this.mt2){a[a.t++]=0}for(var c=0;c>15)*this.mpl)&this.um)<<15))&a.DM;b=c+this.m.t;a[b]+=this.m.am(0,d,a,c,0,this.m.t);while(a[b]>=a.DV){a[b]-=a.DV;a[++b]++}}a.clamp();a.drShiftTo(this.m.t,a);if(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(h,j){if(h>4294967295||h<1){return BigInteger.ONE}var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;d.copyTo(f);while(--c>=0){j.sqrTo(f,a);if((h&(1<0){j.mulTo(a,d,f)}else{var b=f;f=a;a=b}}return j.revert(f)}function bnModPowInt(b,a){var c;if(b<256||a.isEven()){c=new Classic(a)}else{c=new Montgomery(a)}return this.exp(b,c)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction bnClone(){var a=nbi();this.copyTo(a);return a}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this[0]}else{if(this.t==0){return 0}}}return((this[1]&((1<<(32-this.DB))-1))<>24}function bnShortValue(){return(this.t==0)?this.s:(this[0]<<16)>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this[0]<=0)){return 0}else{return 1}}}function bnpToRadix(c){if(c==null){c=10}if(this.signum()==0||c<2||c>36){return\"0\"}var f=this.chunkSize(c);var e=Math.pow(c,f);var i=nbv(e),j=nbi(),h=nbi(),g=\"\";this.divRemTo(i,j,h);while(j.signum()>0){g=(e+h.intValue()).toString(c).substr(1)+g;j.divRemTo(i,j,h)}return h.intValue().toString(c)+g}function bnpFromRadix(m,h){this.fromInt(0);if(h==null){h=10}var f=this.chunkSize(h);var g=Math.pow(h,f),e=false,a=0,l=0;for(var c=0;c=f){this.dMultiply(g);this.dAddOffset(l,0);a=0;l=0}}if(a>0){this.dMultiply(Math.pow(h,a));this.dAddOffset(l,0)}if(e){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(f,e,h){if(\"number\"==typeof e){if(f<2){this.fromInt(1)}else{this.fromNumber(f,h);if(!this.testBit(f-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(f-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(e)){this.dAddOffset(2,0);if(this.bitLength()>f){this.subTo(BigInteger.ONE.shiftLeft(f-1),this)}}}}else{var d=new Array(),g=f&7;d.length=(f>>3)+1;e.nextBytes(d);if(g>0){d[0]&=((1<0){if(e>e)!=(this.s&this.DM)>>e){c[a++]=f|(this.s<<(this.DB-e))}while(b>=0){if(e<8){f=(this[b]&((1<>(e+=this.DB-8)}else{f=(this[b]>>(e-=8))&255;if(e<=0){e+=this.DB;--b}}if((f&128)!=0){f|=-256}if(a==0&&(this.s&128)!=(f&128)){++a}if(a>0||f!=this.s){c[a++]=f}}}return c}function bnEquals(b){return(this.compareTo(b)==0)}function bnMin(b){return(this.compareTo(b)<0)?this:b}function bnMax(b){return(this.compareTo(b)>0)?this:b}function bnpBitwiseTo(c,h,e){var d,g,b=Math.min(c.t,this.t);for(d=0;d>=16;b+=16}if((a&255)==0){a>>=8;b+=8}if((a&15)==0){a>>=4;b+=4}if((a&3)==0){a>>=2;b+=2}if((a&1)==0){++b}return b}function bnGetLowestSetBit(){for(var a=0;a=this.t){return(this.s!=0)}return((this[a]&(1<<(b%this.DB)))!=0)}function bnpChangeBit(c,b){var a=BigInteger.ONE.shiftLeft(c);this.bitwiseTo(a,b,a);return a}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(d,f){var e=0,g=0,b=Math.min(d.t,this.t);while(e>=this.DB}if(d.t>=this.DB}g+=this.s}else{g+=this.s;while(e>=this.DB}g+=d.s}f.s=(g<0)?-1:0;if(g>0){f[e++]=g}else{if(g<-1){f[e++]=this.DV+g}}f.t=e;f.clamp()}function bnAdd(b){var c=nbi();this.addTo(b,c);return c}function bnSubtract(b){var c=nbi();this.subTo(b,c);return c}function bnMultiply(b){var c=nbi();this.multiplyTo(b,c);return c}function bnSquare(){var a=nbi();this.squareTo(a);return a}function bnDivide(b){var c=nbi();this.divRemTo(b,c,null);return c}function bnRemainder(b){var c=nbi();this.divRemTo(b,null,c);return c}function bnDivideAndRemainder(b){var d=nbi(),c=nbi();this.divRemTo(b,d,c);return new Array(d,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(b,a){if(b==0){return}while(this.t<=a){this[this.t++]=0}this[a]+=b;while(this[a]>=this.DV){this[a]-=this.DV;if(++a>=this.t){this[this.t++]=0}++this[a]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,c,b){a.multiplyTo(c,b)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp())}function bnpMultiplyLowerTo(b,f,e){var d=Math.min(this.t+b.t,f);e.s=0;e.t=d;while(d>0){e[--d]=0}var c;for(c=e.t-this.t;d=0){d[c]=0}for(c=Math.max(e-this.t,0);c2*this.m.t){return a.mod(this.m)}else{if(a.compareTo(this.m)<0){return a}else{var b=nbi();a.copyTo(b);this.reduce(b);return b}}}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1){a.t=this.m.t+1;a.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0){a.dAddOffset(1,this.m.t+1)}a.subTo(this.r2,a);while(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(q,f){var o=q.bitLength(),h,b=nbv(1),v;if(o<=0){return b}else{if(o<18){h=1}else{if(o<48){h=3}else{if(o<144){h=4}else{if(o<768){h=5}else{h=6}}}}}if(o<8){v=new Classic(f)}else{if(f.isEven()){v=new Barrett(f)}else{v=new Montgomery(f)}}var p=new Array(),d=3,s=h-1,a=(1<1){var A=nbi();v.sqrTo(p[1],A);while(d<=a){p[d]=nbi();v.mulTo(A,p[d-2],p[d]);d+=2}}var l=q.t-1,x,u=true,c=nbi(),y;o=nbits(q[l])-1;while(l>=0){if(o>=s){x=(q[l]>>(o-s))&a}else{x=(q[l]&((1<<(o+1))-1))<<(s-o);if(l>0){x|=q[l-1]>>(this.DB+o-s)}}d=h;while((x&1)==0){x>>=1;--d}if((o-=d)<0){o+=this.DB;--l}if(u){p[x].copyTo(b);u=false}else{while(d>1){v.sqrTo(b,c);v.sqrTo(c,b);d-=2}if(d>0){v.sqrTo(b,c)}else{y=b;b=c;c=y}v.mulTo(c,p[x],b)}while(l>=0&&(q[l]&(1<0){b.rShiftTo(f,b);h.rShiftTo(f,h)}while(b.signum()>0){if((d=b.getLowestSetBit())>0){b.rShiftTo(d,b)}if((d=h.getLowestSetBit())>0){h.rShiftTo(d,h)}if(b.compareTo(h)>=0){b.subTo(h,b);b.rShiftTo(1,b)}else{h.subTo(b,h);h.rShiftTo(1,h)}}if(f>0){h.lShiftTo(f,h)}return h}function bnpModInt(e){if(e<=0){return 0}var c=this.DV%e,b=(this.s<0)?e-1:0;if(this.t>0){if(c==0){b=this[0]%e}else{for(var a=this.t-1;a>=0;--a){b=(c*b+this[a])%e}}}return b}function bnModInverse(f){var j=f.isEven();if((this.isEven()&&j)||f.signum()==0){return BigInteger.ZERO}var i=f.clone(),h=this.clone();var g=nbv(1),e=nbv(0),l=nbv(0),k=nbv(1);while(i.signum()!=0){while(i.isEven()){i.rShiftTo(1,i);if(j){if(!g.isEven()||!e.isEven()){g.addTo(this,g);e.subTo(f,e)}g.rShiftTo(1,g)}else{if(!e.isEven()){e.subTo(f,e)}}e.rShiftTo(1,e)}while(h.isEven()){h.rShiftTo(1,h);if(j){if(!l.isEven()||!k.isEven()){l.addTo(this,l);k.subTo(f,k)}l.rShiftTo(1,l)}else{if(!k.isEven()){k.subTo(f,k)}}k.rShiftTo(1,k)}if(i.compareTo(h)>=0){i.subTo(h,i);if(j){g.subTo(l,g)}e.subTo(k,e)}else{h.subTo(i,h);if(j){l.subTo(g,l)}k.subTo(e,k)}}if(h.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(k.compareTo(f)>=0){return k.subtract(f)}if(k.signum()<0){k.addTo(f,k)}else{return k}if(k.signum()<0){return k.add(f)}else{return k}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(e){var d,b=this.abs();if(b.t==1&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d>1;if(f>lowprimes.length){f=lowprimes.length}var b=nbi();for(var e=0;e>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(window!==undefined&&(window.crypto!==undefined||window.msCrypto!==undefined)){var crypto=window.crypto||window.msCrypto;if(crypto.getRandomValues){var ua=new Uint8Array(32);crypto.getRandomValues(ua);for(t=0;t<32;++t){rng_pool[rng_pptr++]=ua[t]}}else{if(navigator.appName==\"Netscape\"&&navigator.appVersion<\"5\"){var z=window.crypto.random(32);for(t=0;t>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr=0&&h>0){var f=e.charCodeAt(d--);if(f<128){g[--h]=f}else{if((f>127)&&(f<2048)){g[--h]=(f&63)|128;g[--h]=(f>>6)|192}else{g[--h]=(f&63)|128;g[--h]=((f>>6)&63)|128;g[--h]=(f>>12)|224}}}g[--h]=0;var b=new SecureRandom();var a=new Array();while(h>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}g[--h]=a[0]}g[--h]=2;g[--h]=0;return new BigInteger(g)}function oaep_mgf1_arr(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255])));d+=1}return b}function oaep_pad(q,a,f,l){var c=KJUR.crypto.MessageDigest;var o=KJUR.crypto.Util;var b=null;if(!f){f=\"sha1\"}if(typeof f===\"string\"){b=c.getCanonicalAlgName(f);l=c.getHashLength(b);f=function(i){return hextorstr(o.hashHex(rstrtohex(i),b))}}if(q.length+2*l+2>a){throw\"Message too long for RSA\"}var k=\"\",e;for(e=0;e0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{throw\"Invalid RSA public key\"}}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var e=this.doPublic(a);if(e==null){return null}var b=e.toString(16);if((b.length&1)==0){return b}else{return\"0\"+b}}function RSAEncryptOAEP(f,e,b){var a=oaep_pad(f,(this.n.bitLength()+7)>>3,e,b);if(a==null){return null}var g=this.doPublic(a);if(g==null){return null}var d=g.toString(16);if((d.length&1)==0){return d}else{return\"0\"+d}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;RSAKey.prototype.encryptOAEP=RSAEncryptOAEP;RSAKey.prototype.type=\"RSA\";\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction pkcs1unpad2(g,j){var a=g.toByteArray();var f=0;while(f=a.length){return null}}var e=\"\";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b=\"\",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}function oaep_unpad(o,b,g,p){var e=KJUR.crypto.MessageDigest;var r=KJUR.crypto.Util;var c=null;if(!g){g=\"sha1\"}if(typeof g===\"string\"){c=e.getCanonicalAlgName(g);p=e.getHashLength(c);g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}}o=o.toByteArray();var h;for(h=0;h0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{throw\"Invalid RSA private key\"}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;this.isPublic=false;if(g==null){throw\"RSASetPrivateEx N == null\"}if(d==null){throw\"RSASetPrivateEx E == null\"}if(g.length==0){throw\"RSASetPrivateEx N.length == 0\"}if(d.length==0){throw\"RSASetPrivateEx E.length == 0\"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{throw\"Invalid RSA private key in RSASetPrivateEx\"}}function RSAGenerate(b,i){var a=new SecureRandom();var f=b>>1;this.e=parseInt(i,16);var c=new BigInteger(i,16);for(;;){for(;;){this.p=new BigInteger(b-f,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(f,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var h=this.p;this.p=this.q;this.q=h}var g=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var e=g.multiply(d);if(e.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(e);this.dmp1=this.d.mod(g);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=true}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}function RSADecryptOAEP(e,d,b){var f=parseBigInt(e,16);var a=this.doPrivate(f);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,d,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP;\n/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/\n */\nfunction ECFieldElementFp(b,a){this.x=a;this.q=b}function feFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.x.equals(a.x))}function feFpToBigInteger(){return this.x}function feFpNegate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))}function feFpAdd(a){return new ECFieldElementFp(this.q,this.x.add(a.toBigInteger()).mod(this.q))}function feFpSubtract(a){return new ECFieldElementFp(this.q,this.x.subtract(a.toBigInteger()).mod(this.q))}function feFpMultiply(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger()).mod(this.q))}function feFpSquare(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))}function feFpDivide(a){return new ECFieldElementFp(this.q,this.x.multiply(a.toBigInteger().modInverse(this.q)).mod(this.q))}ECFieldElementFp.prototype.equals=feFpEquals;ECFieldElementFp.prototype.toBigInteger=feFpToBigInteger;ECFieldElementFp.prototype.negate=feFpNegate;ECFieldElementFp.prototype.add=feFpAdd;ECFieldElementFp.prototype.subtract=feFpSubtract;ECFieldElementFp.prototype.multiply=feFpMultiply;ECFieldElementFp.prototype.square=feFpSquare;ECFieldElementFp.prototype.divide=feFpDivide;function ECPointFp(c,a,d,b){this.curve=c;this.x=a;this.y=d;if(b==null){this.z=BigInteger.ONE}else{this.z=b}this.zinv=null}function pointFpGetX(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpGetY(){if(this.zinv==null){this.zinv=this.z.modInverse(this.curve.q)}return this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}function pointFpEquals(a){if(a==this){return true}if(this.isInfinity()){return a.isInfinity()}if(a.isInfinity()){return this.isInfinity()}var c,b;c=a.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(a.z)).mod(this.curve.q);if(!c.equals(BigInteger.ZERO)){return false}b=a.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(a.z)).mod(this.curve.q);return b.equals(BigInteger.ZERO)}function pointFpIsInfinity(){if((this.x==null)&&(this.y==null)){return true}return this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)}function pointFpNegate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)}function pointFpAdd(l){if(this.isInfinity()){return l}if(l.isInfinity()){return this}var p=l.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(l.z)).mod(this.curve.q);var o=l.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(l.z)).mod(this.curve.q);if(BigInteger.ZERO.equals(o)){if(BigInteger.ZERO.equals(p)){return this.twice()}return this.curve.getInfinity()}var j=new BigInteger(\"3\");var e=this.x.toBigInteger();var n=this.y.toBigInteger();var c=l.x.toBigInteger();var k=l.y.toBigInteger();var m=o.square();var i=m.multiply(o);var d=e.multiply(m);var g=p.square().multiply(this.z);var a=g.subtract(d.shiftLeft(1)).multiply(l.z).subtract(i).multiply(o).mod(this.curve.q);var h=d.multiply(j).multiply(p).subtract(n.multiply(i)).subtract(g.multiply(p)).multiply(l.z).add(p.multiply(i)).mod(this.curve.q);var f=i.multiply(this.z).multiply(l.z).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),f)}function pointFpTwice(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var g=new BigInteger(\"3\");var c=this.x.toBigInteger();var h=this.y.toBigInteger();var e=h.multiply(this.z);var j=e.multiply(h).mod(this.curve.q);var i=this.curve.a.toBigInteger();var k=c.square().multiply(g);if(!BigInteger.ZERO.equals(i)){k=k.add(this.z.square().multiply(i))}k=k.mod(this.curve.q);var b=k.square().subtract(c.shiftLeft(3).multiply(j)).shiftLeft(1).multiply(e).mod(this.curve.q);var f=k.multiply(g).multiply(c).subtract(j.shiftLeft(1)).shiftLeft(2).multiply(j).subtract(k.square().multiply(k)).mod(this.curve.q);var d=e.square().multiply(e).shiftLeft(3).mod(this.curve.q);return new ECPointFp(this.curve,this.curve.fromBigInteger(b),this.curve.fromBigInteger(f),d)}function pointFpMultiply(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add(a?this:l)}}return d}function pointFpMultiplyTwo(c,a,b){var d;if(c.bitLength()>b.bitLength()){d=c.bitLength()-1}else{d=b.bitLength()-1}var f=this.curve.getInfinity();var e=this.add(a);while(d>=0){f=f.twice();if(c.testBit(d)){if(b.testBit(d)){f=f.add(e)}else{f=f.add(this)}}else{if(b.testBit(d)){f=f.add(a)}}--d}return f}ECPointFp.prototype.getX=pointFpGetX;ECPointFp.prototype.getY=pointFpGetY;ECPointFp.prototype.equals=pointFpEquals;ECPointFp.prototype.isInfinity=pointFpIsInfinity;ECPointFp.prototype.negate=pointFpNegate;ECPointFp.prototype.add=pointFpAdd;ECPointFp.prototype.twice=pointFpTwice;ECPointFp.prototype.multiply=pointFpMultiply;ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo;function ECCurveFp(e,d,c){this.q=e;this.a=this.fromBigInteger(d);this.b=this.fromBigInteger(c);this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(a){if(a==this){return true}return(this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b))}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)}function curveFpDecodePointHex(d){switch(parseInt(d.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var a=(d.length-2)/2;var c=d.substr(2,a);var b=d.substr(a+2,a);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(b,16)));default:return null}}ECCurveFp.prototype.getQ=curveFpGetQ;ECCurveFp.prototype.getA=curveFpGetA;ECCurveFp.prototype.getB=curveFpGetB;ECCurveFp.prototype.equals=curveFpEquals;ECCurveFp.prototype.getInfinity=curveFpGetInfinity;ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger;ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex;\n/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib\n */\nECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};ECPointFp.prototype.getEncoded=function(c){var d=function(h,f){var g=h.toByteArrayUnsigned();if(fg.length){g.unshift(0)}}return g};var a=this.getX().toBigInteger();var e=this.getY().toBigInteger();var b=d(a,32);if(c){if(e.isEven()){b.unshift(2)}else{b.unshift(3)}}else{b.unshift(4);b=b.concat(d(e,32))}return b};ECPointFp.decodeFrom=function(g,c){var f=c[0];var e=c.length-1;var d=c.slice(1,1+e/2);var b=c.slice(1+e/2,1+e);d.unshift(0);b.unshift(0);var a=new BigInteger(d);var h=new BigInteger(b);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.decodeFromHex=function(g,c){var f=c.substr(0,2);var e=c.length-2;var d=c.substr(2,e/2);var b=c.substr(2+e/2,e/2);var a=new BigInteger(d,16);var h=new BigInteger(b,16);return new ECPointFp(g,g.fromBigInteger(a),g.fromBigInteger(h))};ECPointFp.prototype.add2D=function(c){if(this.isInfinity()){return c}if(c.isInfinity()){return this}if(this.x.equals(c.x)){if(this.y.equals(c.y)){return this.twice()}return this.curve.getInfinity()}var g=c.x.subtract(this.x);var e=c.y.subtract(this.y);var a=e.divide(g);var d=a.square().subtract(this.x).subtract(c.x);var f=a.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,f)};ECPointFp.prototype.twice2D=function(){if(this.isInfinity()){return this}if(this.y.toBigInteger().signum()==0){return this.curve.getInfinity()}var b=this.curve.fromBigInteger(BigInteger.valueOf(2));var e=this.curve.fromBigInteger(BigInteger.valueOf(3));var a=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(b));var c=a.square().subtract(this.x.multiply(b));var d=a.multiply(this.x.subtract(c)).subtract(this.y);return new ECPointFp(this.curve,c,d)};ECPointFp.prototype.multiply2D=function(b){if(this.isInfinity()){return this}if(b.signum()==0){return this.curve.getInfinity()}var g=b;var f=g.multiply(new BigInteger(\"3\"));var l=this.negate();var d=this;var c;for(c=f.bitLength()-2;c>0;--c){d=d.twice();var a=f.testBit(c);var j=g.testBit(c);if(a!=j){d=d.add2D(a?this:l)}}return d};ECPointFp.prototype.isOnCurve=function(){var d=this.getX().toBigInteger();var i=this.getY().toBigInteger();var f=this.curve.getA().toBigInteger();var c=this.curve.getB().toBigInteger();var h=this.curve.getQ();var e=i.multiply(i).mod(h);var g=d.multiply(d).multiply(d).add(f.multiply(d)).add(c).mod(h);return e.equals(g)};ECPointFp.prototype.toString=function(){return\"(\"+this.getX().toBigInteger().toString()+\",\"+this.getY().toBigInteger().toString()+\")\"};ECPointFp.prototype.validate=function(){var c=this.curve.getQ();if(this.isInfinity()){throw new Error(\"Point is at infinity.\")}var a=this.getX().toBigInteger();var b=this.getY().toBigInteger();if(a.compareTo(BigInteger.ONE)<0||a.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"x coordinate out of bounds\")}if(b.compareTo(BigInteger.ONE)<0||b.compareTo(c.subtract(BigInteger.ONE))>0){throw new Error(\"y coordinate out of bounds\")}if(!this.isOnCurve()){throw new Error(\"Point is not on the curve.\")}if(this.multiply(c).isInfinity()){throw new Error(\"Point is not a scalar multiple of G.\")}return true};\n/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval\n */\nvar jsonParse=(function(){var e=\"(?:-?\\\\b(?:0|[1-9][0-9]*)(?:\\\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\\\b)\";var j='(?:[^\\\\0-\\\\x08\\\\x0a-\\\\x1f\"\\\\\\\\]|\\\\\\\\(?:[\"/\\\\\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:\"'+j+'*\")';var d=new RegExp(\"(?:false|true|null|[\\\\{\\\\}\\\\[\\\\]]|\"+e+\"|\"+i+\")\",\"g\");var k=new RegExp(\"\\\\\\\\(?:([^u])|u(.{4}))\",\"g\");var g={'\"':'\"',\"/\":\"/\",\"\\\\\":\"\\\\\",b:\"\\b\",f:\"\\f\",n:\"\\n\",r:\"\\r\",t:\"\\t\"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String(\"\");var a=\"\\\\\";var f={\"{\":Object,\"[\":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if(\"{\"===v){x={}}else{if(\"[\"===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({\"\":x},\"\")}return x}})();\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.asn1==\"undefined\"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b=\"0\"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!=\"-\"){if(f.length%2==1){f=\"0\"+f}else{if(!f.match(/^[0-7]/)){f=\"00\"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g=\"\";for(var d=0;d15){throw\"ASN.1 length too long to represent by 8x: n = \"+i.toString(16)}var f=128+g;return f.toString(16)+h}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return\"\"}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!=\"undefined\"){if(typeof c==\"string\"){this.setString(c)}else{if(typeof c.str!=\"undefined\"){this.setString(c.str)}else{if(typeof c.hex!=\"undefined\"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(f){utc=f.getTime()+(f.getTimezoneOffset()*60000);var e=new Date(utc);return e};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o==\"utc\"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,\"\");r=r+\".\"+k}}return r+\"Z\"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join(\"0\")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!=\"undefined\"){if(typeof b.array!=\"undefined\"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT=\"01\";this.hTLV=\"0101ff\"};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT=\"02\";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!=\"undefined\"){if(typeof a.bigint!=\"undefined\"){this.setByBigInteger(a.bigint)}else{if(typeof a[\"int\"]!=\"undefined\"){this.setByInteger(a[\"int\"])}else{if(typeof a==\"number\"){this.setByInteger(a)}else{if(typeof a.hex!=\"undefined\"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!==\"undefined\"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex=\"00\"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT=\"03\";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=(l*2))){break}if(d>=200){break}g.push(b);c=b;d++}return g};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){throw\"checking tag doesn't match: \"+e.substr(d,2)+\"!=\"+i}}return d}f=c.shift();b=g.getChildIdx(e,d);return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getTLVbyList=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyList(d,c,b);if(a===undefined){throw\"can't find nthList object\"}if(f!==undefined){if(d.substr(a,2)!=f){throw\"checking tag doesn't match: \"+d.substr(a,2)+\"!=\"+f}}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a===undefined){throw\"can't find nthList object\"}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join(\"0\")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+\".\"+j.join(\".\")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+\"..(total \"+A.length/2+\"bytes)..\"+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=\"\"}var x=c.ommit_long_octet;if(e.substr(l,2)==\"01\"){var h=j(e,l);if(h==\"00\"){return g+\"BOOLEAN FALSE\\n\"}else{return g+\"BOOLEAN TRUE\\n\"}}if(e.substr(l,2)==\"02\"){var h=j(e,l);return g+\"INTEGER \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"03\"){var h=j(e,l);return g+\"BITSTRING \"+q(h,x)+\"\\n\"}if(e.substr(l,2)==\"04\"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+\"OCTETSTRING, encapsulates\\n\";k=k+y(h,c,0,g+\" \");return k}else{return g+\"OCTETSTRING \"+q(h,x)+\"\\n\"}}if(e.substr(l,2)==\"05\"){return g+\"NULL\\n\"}if(e.substr(l,2)==\"06\"){var m=j(e,l);var a=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(a);var b=a.replace(/\\./g,\" \");if(o!=\"\"){return g+\"ObjectIdentifier \"+o+\" (\"+b+\")\\n\"}else{return g+\"ObjectIdentifier (\"+b+\")\\n\"}}if(e.substr(l,2)==\"0c\"){return g+\"UTF8String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"13\"){return g+\"PrintableString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"14\"){return g+\"TeletexString '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"16\"){return g+\"IA5String '\"+hextoutf8(j(e,l))+\"'\\n\"}if(e.substr(l,2)==\"17\"){return g+\"UTCTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"18\"){return g+\"GeneralizedTime \"+hextoutf8(j(e,l))+\"\\n\"}if(e.substr(l,2)==\"30\"){if(e.substr(l,4)==\"3000\"){return g+\"SEQUENCE {}\\n\"}var k=g+\"SEQUENCE\\n\";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)==\"06\"&&e.substr(d[d.length-1],2)==\"04\"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u0){var m=new f({array:this.extensionsArray});var k=new c({explicit:true,tag:\"a3\",obj:m});this.asn1Array.push(k)}var n=new f({array:this.asn1Array});this.hTLV=n.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension=function(d){KJUR.asn1.x509.Extension.superclass.constructor.call(this);var f=null,a=KJUR,e=a.asn1,h=e.DERObjectIdentifier,i=e.DEROctetString,b=e.DERBitString,g=e.DERBoolean,c=e.DERSequence;this.getEncodedHex=function(){var m=new h({oid:this.oid});var l=new i({hex:this.getExtnValueHex()});var k=new Array();k.push(m);if(this.critical){k.push(new g())}k.push(l);var j=new c({array:k});return j.getEncodedHex()};this.critical=false;if(d!==undefined){if(d.critical!==undefined){this.critical=d.critical}}};YAHOO.lang.extend(KJUR.asn1.x509.Extension,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extension.appendByNameToArray=function(e,c,b){var g=e.toLowerCase(),f=KJUR.asn1.x509;if(g==\"basicconstraints\"){var d=new f.BasicConstraints(c);b.push(d)}else{if(g==\"keyusage\"){var d=new f.KeyUsage(c);b.push(d)}else{if(g==\"crldistributionpoints\"){var d=new f.CRLDistributionPoints(c);b.push(d)}else{if(g==\"extkeyusage\"){var d=new f.ExtKeyUsage(c);b.push(d)}else{if(g==\"authoritykeyidentifier\"){var d=new f.AuthorityKeyIdentifier(c);b.push(d)}else{if(g==\"authorityinfoaccess\"){var d=new f.AuthorityInfoAccess(c);b.push(d)}else{if(g==\"subjectaltname\"){var d=new f.SubjectAltName(c);b.push(d)}else{if(g==\"issueraltname\"){var d=new f.IssuerAltName(c);b.push(d)}else{throw\"unsupported extension name: \"+e}}}}}}}}};KJUR.asn1.x509.KeyUsage=function(f){KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this,f);var a=X509.KEYUSAGE_NAME;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.15\";if(f!==undefined){if(f.bin!==undefined){this.asn1ExtnValue=new KJUR.asn1.DERBitString(f)}if(f.names!==undefined&&f.names.length!==undefined){var e=f.names;var d=\"000000000\";for(var c=0;c-1){e.push(new KJUR.asn1.DERInteger({\"int\":this.pathLen}))}var d=new KJUR.asn1.DERSequence({array:e});this.asn1ExtnValue=d;return this.asn1ExtnValue.getEncodedHex()};this.oid=\"2.5.29.19\";this.cA=false;this.pathLen=-1;if(c!==undefined){if(c.cA!==undefined){this.cA=c.cA}if(c.pathLen!==undefined){this.pathLen=c.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){this.asn1ExtnValue=new a.DERSequence({array:e})};this.setByOneURI=function(h){var e=new c.GeneralNames([{uri:h}]);var g=new c.DistributionPointName(e);var f=new c.DistributionPoint({dpobj:g});this.setByDPArray([f])};this.oid=\"2.5.29.31\";if(d!==undefined){if(d.array!==undefined){this.setByDPArray(d.array)}else{if(d.uri!==undefined){this.setByOneURI(d.uri)}}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLDistributionPoints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.ExtKeyUsage=function(c){KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,c);var b=KJUR,a=b.asn1;this.setPurposeArray=function(d){this.asn1ExtnValue=new a.DERSequence();for(var e=0;e0){var h=new b({array:this.aRevokedCert});this.asn1Array.push(h)}var i=new b({array:this.asn1Array});this.hTLV=i.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize=function(){this.asn1Version=null;this.asn1SignatureAlg=null;this.asn1Issuer=null;this.asn1ThisUpdate=null;this.asn1NextUpdate=null;this.aRevokedCert=new Array()};this._initialize()};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertList,KJUR.asn1.ASN1Object);KJUR.asn1.x509.CRLEntry=function(e){KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);var d=null,c=null,b=KJUR,a=b.asn1;this.setCertSerial=function(f){this.sn=new a.DERInteger(f)};this.setRevocationDate=function(f){this.time=new a.x509.Time(f)};this.getEncodedHex=function(){var f=new a.DERSequence({array:[this.sn,this.time]});this.TLV=f.getEncodedHex();return this.TLV};if(e!==undefined){if(e.time!==undefined){this.setRevocationDate(e.time)}if(e.sn!==undefined){this.setCertSerial(e.sn)}}};YAHOO.lang.extend(KJUR.asn1.x509.CRLEntry,KJUR.asn1.ASN1Object);KJUR.asn1.x509.X500Name=function(f){KJUR.asn1.x509.X500Name.superclass.constructor.call(this);this.asn1Array=new Array();var d=KJUR,c=d.asn1,e=c.x509,b=pemtohex;this.setByString=function(g){var k=g.split(\"/\");k.shift();var j=[];for(var l=0;l0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+\",\"+h).replace(/\\\\,/g,\",\");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)===\"\\\\\"){e=true}}b=b.map(function(a){return a.replace(\"/\",\"\\\\/\")});b.reverse();return\"/\"+b.join(\"/\")};KJUR.asn1.x509.RDN=function(a){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=new Array();this.addByString=function(b){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:b}))};this.addByMultiValuedString=function(d){var b=KJUR.asn1.x509.RDN.parseString(d);for(var c=0;c0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+\"+\"+k).replace(/\\\\\\+/g,\"+\");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)===\"\\\\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/\"$/)){var d=(e+\"+\"+k).replace(/^([^=]+)=\"(.*)\"$/,\"$1=$2\");b.push(d);l=false}else{b.push(e+\"+\"+k)}}else{b.push(k)}if(k.match(/^[^=]+=\"/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(d){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var f=null,e=null,a=\"utf8\",c=KJUR,b=c.asn1;this.setByString=function(h){var g=h.match(/^([^=]+)=(.+)$/);if(g){this.setByAttrTypeAndValueStr(g[1],g[2])}else{throw\"malformed attrTypeAndValueStr: \"+h}};this.setByAttrTypeAndValueStr=function(i,h){this.typeObj=KJUR.asn1.x509.OID.atype2obj(i);var g=a;if(i==\"C\"){g=\"prn\"}this.valueObj=this.getValueObj(g,h)};this.getValueObj=function(h,g){if(h==\"utf8\"){return new b.DERUTF8String({str:g})}if(h==\"prn\"){return new b.DERPrintableString({str:g})}if(h==\"tel\"){return new b.DERTeletexString({str:g})}if(h==\"ia5\"){return new b.DERIA5String({str:g})}throw\"unsupported directory string type: type=\"+h+\" value=\"+g};this.getEncodedHex=function(){var g=new b.DERSequence({array:[this.typeObj,this.valueObj]});this.TLV=g.getEncodedHex();return this.TLV};if(d!==undefined){if(d.str!==undefined){this.setByString(d.str)}}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw\"algId and/or subjPubKey not set\"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{\"int\":{bigint:q.n}},{\"int\":{\"int\":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:\"rsaEncryption\"});this.asn1SubjPKey=new b({hex:\"00\"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:\"ecPublicKey\",asn1params:r});this.asn1SubjPKey=new b({hex:\"00\"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{\"int\":{bigint:q.p}},{\"int\":{bigint:q.q}},{\"int\":{bigint:q.g}}]});this.asn1AlgId=new o({name:\"dsa\",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:\"00\"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type==\"utc\"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type==\"utc\"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type=\"utc\";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type=\"utc\"}if(f.str.match(/^[0-9]{14}Z$/)){this.type=\"gen\"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(d){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw\"algorithm not specified\"}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var e=[this.asn1Alg];if(this.asn1Params!==null){e.push(this.asn1Params)}var f=new a.DERSequence({array:e});this.hTLV=f.getEncodedHex();return this.hTLV};if(d!==undefined){if(d.name!==undefined){this.nameAlg=d.name}if(d.asn1params!==undefined){this.asn1Params=d.asn1params}if(d.paramempty!==undefined){this.paramEmpty=d.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){var c=this.nameAlg.toLowerCase();if(c.substr(-7,7)!==\"withdsa\"&&c.substr(-9,9)!==\"withecdsa\"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:\"81\",dns:\"82\",dn:\"a4\",uri:\"86\",ip:\"87\"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type=\"rfc822\";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type=\"dns\";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type=\"uri\";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({str:p.dn})}if(p.ldapdn!==undefined){this.type=\"dn\";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certissuer param not cert\"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type=\"dn\";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf(\"-----BEGIN \")!=-1){w=h(o)}if(w==null){throw\"certsubj param not cert\"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type=\"ip\";this.explicit=false;var q=p.ip;var s;var n=\"malformed IP address\";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex(\"[\"+q.split(\".\").join(\",\")+\"]\");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw\"unsupported type in params=\"+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){r=new b({obj:this.dUnsignedAttrs,tag:\"a1\",explicit:false})}var q=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,o,this.dSigAlg,this.dSig,];if(r!=null){q.push(r)}var p=new h.DERSequence({array:q});this.hTLV=p.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.SignerInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.EncapsulatedContentInfo=function(g){var c=KJUR,b=c.asn1,e=b.DERTaggedObject,a=b.DERSequence,h=b.DERObjectIdentifier,d=b.DEROctetString,f=b.cms;f.EncapsulatedContentInfo.superclass.constructor.call(this);this.dEContentType=new h({name:\"data\"});this.dEContent=null;this.isDetached=false;this.eContentValueHex=null;this.setContentType=function(i){if(i.match(/^[0-2][.][0-9.]+$/)){this.dEContentType=new h({oid:i})}else{this.dEContentType=new h({name:i})}};this.setContentValue=function(i){if(i!==undefined){if(typeof i.hex==\"string\"){this.eContentValueHex=i.hex}else{if(typeof i.str==\"string\"){this.eContentValueHex=utf8tohex(i.str)}}}};this.setContentValueHex=function(i){this.eContentValueHex=i};this.setContentValueStr=function(i){this.eContentValueHex=utf8tohex(i)};this.getEncodedHex=function(){if(typeof this.eContentValueHex!=\"string\"){throw\"eContentValue not yet set\"}var k=new d({hex:this.eContentValueHex});this.dEContent=new e({obj:k,tag:\"a0\",explicit:true});var i=[this.dEContentType];if(!this.isDetached){i.push(this.dEContent)}var j=new a({array:i});this.hTLV=j.getEncodedHex();return this.hTLV}};YAHOO.lang.extend(KJUR.asn1.cms.EncapsulatedContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.ContentInfo=function(f){var c=KJUR,b=c.asn1,d=b.DERTaggedObject,a=b.DERSequence,e=b.x509;KJUR.asn1.cms.ContentInfo.superclass.constructor.call(this);this.dContentType=null;this.dContent=null;this.setContentType=function(g){if(typeof g==\"string\"){this.dContentType=e.OID.name2obj(g)}};this.getEncodedHex=function(){var h=new d({obj:this.dContent,tag:\"a0\",explicit:true});var g=new a({array:[this.dContentType,h]});this.hTLV=g.getEncodedHex();return this.hTLV};if(f!==undefined){if(f.type){this.setContentType(f.type)}if(f.obj&&f.obj instanceof b.ASN1Object){this.dContent=f.obj}}};YAHOO.lang.extend(KJUR.asn1.cms.ContentInfo,KJUR.asn1.ASN1Object);KJUR.asn1.cms.SignedData=function(e){var a=KJUR,h=a.asn1,j=h.ASN1Object,g=h.DERInteger,m=h.DERSet,f=h.DERSequence,b=h.DERTaggedObject,l=h.cms,i=l.EncapsulatedContentInfo,d=l.SignerInfo,n=l.ContentInfo,c=h.x509,k=c.AlgorithmIdentifier;KJUR.asn1.cms.SignedData.superclass.constructor.call(this);this.dCMSVersion=new g({\"int\":1});this.dDigestAlgs=null;this.digestAlgNameList=[];this.dEncapContentInfo=new i();this.dCerts=null;this.certificateList=[];this.crlList=[];this.signerInfoList=[new d()];this.addCertificatesByPEM=function(p){var q=pemtohex(p);var r=new j();r.hTLV=q;this.certificateList.push(r)};this.getEncodedHex=function(){if(typeof this.hTLV==\"string\"){return this.hTLV}if(this.dDigestAlgs==null){var u=[];for(var t=0;t0){var v=new m({array:this.certificateList});this.dCerts=new b({obj:v,tag:\"a0\",explicit:false})}}if(this.dCerts!=null){p.push(this.dCerts)}var r=new m({array:this.signerInfoList});p.push(r);var q=new f({array:p});this.hTLV=q.getEncodedHex();return this.hTLV};this.getContentInfo=function(){this.getEncodedHex();var o=new n({type:\"signed-data\",obj:this});return o};this.getContentInfoEncodedHex=function(){var o=this.getContentInfo();var p=o.getEncodedHex();return p};this.getPEM=function(){return hextopem(this.getContentInfoEncodedHex(),\"CMS\")}};YAHOO.lang.extend(KJUR.asn1.cms.SignedData,KJUR.asn1.ASN1Object);KJUR.asn1.cms.CMSUtil=new function(){};KJUR.asn1.cms.CMSUtil.newSignedData=function(d){var b=KJUR,j=b.asn1,q=j.cms,f=q.SignerInfo,n=q.SignedData,o=q.SigningTime,a=q.SigningCertificate,p=q.SigningCertificateV2,c=j.cades,e=c.SignaturePolicyIdentifier;var m=new n();m.dEncapContentInfo.setContentValue(d.content);if(typeof d.certs==\"object\"){for(var h=0;h0){var s=new f({array:this.extensionsArray});var r=new m({array:[s]});var q=new f({array:[new k({oid:\"1.2.840.113549.1.9.14\"}),r]});var p=new c({explicit:true,tag:\"a0\",obj:q});this.asn1Array.push(p)}else{var p=new c({explicit:false,tag:\"a0\",obj:new j()});this.asn1Array.push(p)}var t=new f({array:this.asn1Array});this.hTLV=t.getEncodedHex();this.isModified=false;return this.hTLV};this._initialize()};YAHOO.lang.extend(KJUR.asn1.csr.CertificationRequestInfo,KJUR.asn1.ASN1Object);KJUR.asn1.csr.CSRUtil=new function(){};KJUR.asn1.csr.CSRUtil.newCSRPEM=function(h){var c=KEYUTIL,b=KJUR.asn1.csr;if(h.subject===undefined){throw\"parameter subject undefined\"}if(h.sbjpubkey===undefined){throw\"parameter sbjpubkey undefined\"}if(h.sigalg===undefined){throw\"parameter sigalg undefined\"}if(h.sbjprvkey===undefined){throw\"parameter sbjpubkey undefined\"}var d=new b.CertificationRequestInfo();d.setSubjectByParam(h.subject);d.setSubjectPublicKeyByGetKey(h.sbjpubkey);if(h.ext!==undefined&&h.ext.length!==undefined){for(var e=0;ef.length){f=c[d]}}e=e.replace(f,\"::\");return e.slice(1,-1)}function hextoip(b){var d=\"malformed hex value\";if(!b.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){throw d}if(b.length==8){var c;try{c=parseInt(b.substr(0,2),16)+\".\"+parseInt(b.substr(2,2),16)+\".\"+parseInt(b.substr(4,2),16)+\".\"+parseInt(b.substr(6,2),16);return c}catch(a){throw d}}else{if(b.length==32){return hextoipv6(b)}else{return b}}}function iptohex(f){var j=\"malformed IP address\";f=f.toLowerCase(f);if(f.match(/^[0-9.]+$/)){var b=f.split(\".\");if(b.length!==4){throw j}var g=\"\";try{for(var e=0;e<4;e++){var h=parseInt(b[e]);g+=(\"0\"+h.toString(16)).slice(-2)}return g}catch(c){throw j}}else{if(f.match(/^[0-9a-f:]+$/)&&f.indexOf(\":\")!==-1){return ipv6tohex(f)}else{throw j}}}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b=\"\";for(var c=0;c\"7\"){return\"00\"+a}return a}function intarystrtohex(b){b=b.replace(/^\\s*\\[\\s*/,\"\");b=b.replace(/\\s*\\]\\s*$/,\"\");b=b.replace(/\\s*/g,\"\");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;bd){throw\"key is too short for SigAlg: keylen=\"+j+\",\"+a}var b=\"0001\";var k=\"00\"+c;var g=\"\";var l=d-b.length-k.length;for(var f=0;f=0;--p){q=q.twice2D();q.z=BigInteger.ONE;if(o.testBit(p)){if(n.testBit(p)){q=q.add2D(t)}else{q=q.add2D(s)}}else{if(n.testBit(p)){q=q.add2D(r)}}}return q}this.getBigRandom=function(i){return new BigInteger(i.bitLength(),a).mod(i.subtract(BigInteger.ONE)).add(BigInteger.ONE)};this.setNamedCurve=function(i){this.ecparams=KJUR.crypto.ECParameterDB.getByName(i);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=i};this.setPrivateKeyHex=function(i){this.isPrivate=true;this.prvKeyHex=i};this.setPublicKeyHex=function(i){this.isPublic=true;this.pubKeyHex=i};this.getPublicKeyXYHex=function(){var k=this.pubKeyHex;if(k.substr(0,2)!==\"04\"){throw\"this method supports uncompressed format(04) only\"}var j=this.ecparams.keylen/4;if(k.length!==2+j*2){throw\"malformed public key hex length\"}var i={};i.x=k.substr(2,j);i.y=k.substr(2+j);return i};this.getShortNISTPCurveName=function(){var i=this.curveName;if(i===\"secp256r1\"||i===\"NIST P-256\"||i===\"P-256\"||i===\"prime256v1\"){return\"P-256\"}if(i===\"secp384r1\"||i===\"NIST P-384\"||i===\"P-384\"){return\"P-384\"}return null};this.generateKeyPairHex=function(){var k=this.ecparams.n;var n=this.getBigRandom(k);var l=this.ecparams.G.multiply(n);var q=l.getX().toBigInteger();var o=l.getY().toBigInteger();var i=this.ecparams.keylen/4;var m=(\"0000000000\"+n.toString(16)).slice(-i);var r=(\"0000000000\"+q.toString(16)).slice(-i);var p=(\"0000000000\"+o.toString(16)).slice(-i);var j=\"04\"+r+p;this.setPrivateKeyHex(m);this.setPublicKeyHex(j);return{ecprvhex:m,ecpubhex:j}};this.signWithMessageHash=function(i){return this.signHex(i,this.prvKeyHex)};this.signHex=function(o,j){var t=new BigInteger(j,16);var l=this.ecparams.n;var q=new BigInteger(o,16);do{var m=this.getBigRandom(l);var u=this.ecparams.G;var p=u.multiply(m);var i=p.getX().toBigInteger().mod(l)}while(i.compareTo(BigInteger.ZERO)<=0);var v=m.modInverse(l).multiply(q.add(t.multiply(i))).mod(l);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(i,v)};this.sign=function(m,u){var q=u;var j=this.ecparams.n;var p=BigInteger.fromByteArrayUnsigned(m);do{var l=this.getBigRandom(j);var t=this.ecparams.G;var o=t.multiply(l);var i=o.getX().toBigInteger().mod(j)}while(i.compareTo(BigInteger.ZERO)<=0);var v=l.modInverse(j).multiply(p.add(q.multiply(i))).mod(j);return this.serializeSig(i,v)};this.verifyWithMessageHash=function(j,i){return this.verifyHex(j,i,this.pubKeyHex)};this.verifyHex=function(m,i,p){var l,j;var o=KJUR.crypto.ECDSA.parseSigHex(i);l=o.r;j=o.s;var k;k=ECPointFp.decodeFromHex(this.ecparams.curve,p);var n=new BigInteger(m,16);return this.verifyRaw(n,l,j,k)};this.verify=function(o,p,j){var l,i;if(Bitcoin.Util.isArray(p)){var n=this.parseSig(p);l=n.r;i=n.s}else{if(\"object\"===typeof p&&p.r&&p.s){l=p.r;i=p.s}else{throw\"Invalid value for signature\"}}var k;if(j instanceof ECPointFp){k=j}else{if(Bitcoin.Util.isArray(j)){k=ECPointFp.decodeFrom(this.ecparams.curve,j)}else{throw\"Invalid format for pubkey value, must be byte array or ECPointFp\"}}var m=BigInteger.fromByteArrayUnsigned(o);return this.verifyRaw(m,l,i,k)};this.verifyRaw=function(o,i,w,m){var l=this.ecparams.n;var u=this.ecparams.G;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(l)>=0){return false}if(w.compareTo(BigInteger.ONE)<0||w.compareTo(l)>=0){return false}var p=w.modInverse(l);var k=o.multiply(p).mod(l);var j=i.multiply(p).mod(l);var q=u.multiply(k).add(m.multiply(j));var t=q.getX().toBigInteger().mod(l);return t.equals(i)};this.serializeSig=function(k,j){var l=k.toByteArraySigned();var i=j.toByteArraySigned();var m=[];m.push(2);m.push(l.length);m=m.concat(l);m.push(2);m.push(i.length);m=m.concat(i);m.unshift(m.length);m.unshift(48);return m};this.parseSig=function(n){var m;if(n[0]!=48){throw new Error(\"Signature not a valid DERSequence\")}m=2;if(n[m]!=2){throw new Error(\"First element in signature must be a DERInteger\")}var l=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];if(n[m]!=2){throw new Error(\"Second element in signature must be a DERInteger\")}var i=n.slice(m+2,m+2+n[m+1]);m+=2+n[m+1];var k=BigInteger.fromByteArrayUnsigned(l);var j=BigInteger.fromByteArrayUnsigned(i);return{r:k,s:j}};this.parseSigCompact=function(m){if(m.length!==65){throw\"Signature has the wrong length\"}var j=m[0]-27;if(j<0||j>7){throw\"Invalid signature type\"}var o=this.ecparams.n;var l=BigInteger.fromByteArrayUnsigned(m.slice(1,33)).mod(o);var k=BigInteger.fromByteArrayUnsigned(m.slice(33,65)).mod(o);return{r:l,s:k,i:j}};this.readPKCS5PrvKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var i,k,o;try{i=p(l,0,[2,0],\"06\");k=p(l,0,[1],\"04\");try{o=p(l,0,[3,0],\"03\").substr(2)}catch(j){}}catch(j){throw\"malformed PKCS#1/5 plain ECC private key\"}this.curveName=m(i);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o);this.setPrivateKeyHex(k);this.isPublic=false};this.readPKCS8PrvKeyHex=function(l){var q=ASN1HEX;var i=KJUR.crypto.ECDSA.getName;var n=q.getVbyList;if(q.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var j,p,m,k;try{j=n(l,0,[1,0],\"06\");p=n(l,0,[1,1],\"06\");m=n(l,0,[2,0,1],\"04\");try{k=n(l,0,[2,0,2,0],\"03\").substr(2)}catch(o){}}catch(o){throw\"malformed PKCS#8 plain ECC private key\"}this.curveName=i(p);if(this.curveName===undefined){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(k);this.setPrivateKeyHex(m);this.isPublic=false};this.readPKCS8PubKeyHex=function(l){var n=ASN1HEX;var m=KJUR.crypto.ECDSA.getName;var p=n.getVbyList;if(n.isASN1HEX(l)===false){throw\"not ASN.1 hex string\"}var k,i,o;try{k=p(l,0,[0,0],\"06\");i=p(l,0,[0,1],\"06\");o=p(l,0,[1],\"03\").substr(2)}catch(j){throw\"malformed PKCS#8 ECC public key\"}this.curveName=m(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(o)};this.readCertPubKeyHex=function(k,p){if(p!==5){p=6}var m=ASN1HEX;var l=KJUR.crypto.ECDSA.getName;var o=m.getVbyList;if(m.isASN1HEX(k)===false){throw\"not ASN.1 hex string\"}var i,n;try{i=o(k,0,[0,p,0,1],\"06\");n=o(k,0,[0,p,1],\"03\").substr(2)}catch(j){throw\"malformed X.509 certificate ECC public key\"}this.curveName=l(i);if(this.curveName===null){throw\"unsupported curve name\"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(n)};if(h!==undefined){if(h.curve!==undefined){this.curveName=h.curve}}if(this.curveName===undefined){this.curveName=e}this.setNamedCurve(this.curveName);if(h!==undefined){if(h.prv!==undefined){this.setPrivateKeyHex(h.prv)}if(h.pub!==undefined){this.setPublicKeyHex(h.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX;var i=j.getChildIdx;var g=j.getV;if(f.substr(0,2)!=\"30\"){throw\"signature is not a ASN.1 sequence\"}var h=i(f,0);if(h.length!=2){throw\"number of signature ASN.1 sequence elements seem wrong\"}var e=h[0];var d=h[1];if(f.substr(e,2)!=\"02\"){throw\"1st item of sequene of signature is not ASN.1 integer\"}if(f.substr(d,2)!=\"02\"){throw\"2nd item of sequene of signature is not ASN.1 integer\"}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(c){var d=KJUR.crypto.ECDSA.parseSigHexInHexRS(c);var b=d.r;var a=d.s;if(b.substr(0,2)==\"00\"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)==\"00\"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b=\"00\"+b}if((a.length%32)==30){a=\"00\"+a}if(b.length%32!=0){throw\"unknown ECDSA sig r length error\"}if(a.length%32!=0){throw\"unknown ECDSA sig s length error\"}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if((((a.length/2)*8)%(16*8))!=0){throw\"unknown ECDSA concatinated r-s sig length error\"}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.getEncodedHex()};KJUR.crypto.ECDSA.getName=function(a){if(a===\"2a8648ce3d030107\"){return\"secp256r1\"}if(a===\"2b8104000a\"){return\"secp256k1\"}if(a===\"2b81040022\"){return\"secp384r1\"}if(\"|secp256r1|NIST P-256|P-256|prime256v1|\".indexOf(a)!==-1){return\"secp256r1\"}if(\"|secp256k1|\".indexOf(a)!==-1){return\"secp256k1\"}if(\"|secp384r1|NIST P-384|P-384|\".indexOf(a)!==-1){return\"secp384r1\"}return null};\nif(typeof KJUR==\"undefined\"||!KJUR){KJUR={}}if(typeof KJUR.crypto==\"undefined\"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!=\"undefined\"){d=c[e]}if(typeof b[d]!=\"undefined\"){return b[d]}throw\"unregistered EC curve name: \"+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex(\"04\"+f+k);b[A][\"name\"]=A;b[A][\"keylen\"]=l;b[A][\"curve\"]=r;b[A][\"G\"]=q;b[A][\"n\"]=t;b[A][\"h\"]=w;b[A][\"oid\"]=d;b[A][\"info\"]=x;for(var v=0;v1){g=new BigInteger(i,16)}else{g=null}h=new BigInteger(j,16);this.setPrivate(c,a,e,g,h)};this.setPublic=function(c,b,a,d){this.isPublic=true;this.p=c;this.q=b;this.g=a;this.y=d;this.x=null};this.setPublicHex=function(f,e,d,g){var b,a,h,c;b=new BigInteger(f,16);a=new BigInteger(e,16);h=new BigInteger(d,16);c=new BigInteger(g,16);this.setPublic(b,a,h,c)};this.signWithMessageHash=function(d){var c=this.p;var b=this.q;var f=this.g;var i=this.y;var j=this.x;var e=KJUR.crypto.Util.getRandomBigIntegerMinToMax(BigInteger.ONE.add(BigInteger.ONE),b.subtract(BigInteger.ONE));var l=d.substr(0,b.bitLength()/4);var h=new BigInteger(l,16);var a=(f.modPow(e,c)).mod(b);var n=(e.modInverse(b).multiply(h.add(j.multiply(a)))).mod(b);var m=KJUR.asn1.ASN1Util.jsonToASN1HEX({seq:[{\"int\":{bigint:a}},{\"int\":{bigint:n}}]});return m};this.verifyWithMessageHash=function(h,f){var d=this.p;var b=this.q;var j=this.g;var l=this.y;var i=this.parseASN1Signature(f);var a=i[0];var t=i[1];var o=h.substr(0,b.bitLength()/4);var k=new BigInteger(o,16);if(BigInteger.ZERO.compareTo(a)>0||a.compareTo(b)>0){throw\"invalid DSA signature\"}if(BigInteger.ZERO.compareTo(t)>=0||t.compareTo(b)>0){throw\"invalid DSA signature\"}var m=t.modInverse(b);var e=k.multiply(m).mod(b);var c=a.multiply(m).mod(b);var n=j.modPow(e,d).multiply(l.modPow(c,d)).mod(d).mod(b);return n.compareTo(a)==0};this.parseASN1Signature=function(a){try{var d=new BigInteger(ASN1HEX.getVbyList(a,0,[0],\"02\"),16);var c=new BigInteger(ASN1HEX.getVbyList(a,0,[1],\"02\"),16);return[d,c]}catch(b){throw\"malformed ASN.1 DSA signature\"}};this.readPKCS5PrvKeyHex=function(c){var b,a,f,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[1],\"02\");a=d(c,0,[2],\"02\");f=d(c,0,[3],\"02\");g=d(c,0,[4],\"02\");i=d(c,0,[5],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed PKCS#1/5 plain DSA private key\"}this.setPrivateHex(b,a,f,g,i)};this.readPKCS8PrvKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[1,1,0],\"02\");c=i(d,0,[1,1,1],\"02\");b=i(d,0,[1,1,2],\"02\");g=i(d,0,[2,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 plain DSA private key\"}this.setPrivateHex(f,c,b,null,g)};this.readPKCS8PubKeyHex=function(d){var f,c,b,g;var e=ASN1HEX;var i=e.getVbyList;if(e.isASN1HEX(d)===false){throw\"not ASN.1 hex string\"}try{f=i(d,0,[0,1,0],\"02\");c=i(d,0,[0,1,1],\"02\");b=i(d,0,[0,1,2],\"02\");g=i(d,0,[1,0],\"02\")}catch(a){console.log(\"EXCEPTION:\"+a);throw\"malformed PKCS#8 DSA public key\"}this.setPublicHex(f,c,b,g)};this.readCertPubKeyHex=function(c,f){if(f!==5){f=6}var b,a,g,i;var j=ASN1HEX;var d=j.getVbyList;if(j.isASN1HEX(c)===false){throw\"not ASN.1 hex string\"}try{b=d(c,0,[0,f,0,1,0],\"02\");a=d(c,0,[0,f,0,1,1],\"02\");g=d(c,0,[0,f,0,1,2],\"02\");i=d(c,0,[0,f,1,0],\"02\")}catch(e){console.log(\"EXCEPTION:\"+e);throw\"malformed X.509 certificate DSA public key\"}this.setPublicHex(b,a,g,i)}};\nvar KEYUTIL=function(){var d=function(p,r,q){return k(CryptoJS.AES,p,r,q)};var e=function(p,r,q){return k(CryptoJS.TripleDES,p,r,q)};var a=function(p,r,q){return k(CryptoJS.DES,p,r,q)};var k=function(s,x,u,q){var r=CryptoJS.enc.Hex.parse(x);var w=CryptoJS.enc.Hex.parse(u);var p=CryptoJS.enc.Hex.parse(q);var t={};t.key=w;t.iv=p;t.ciphertext=r;var v=s.decrypt(t,w,{iv:p});return CryptoJS.enc.Hex.stringify(v)};var l=function(p,r,q){return g(CryptoJS.AES,p,r,q)};var o=function(p,r,q){return g(CryptoJS.TripleDES,p,r,q)};var f=function(p,r,q){return g(CryptoJS.DES,p,r,q)};var g=function(t,y,v,q){var s=CryptoJS.enc.Hex.parse(y);var x=CryptoJS.enc.Hex.parse(v);var p=CryptoJS.enc.Hex.parse(q);var w=t.encrypt(s,x,{iv:p});var r=CryptoJS.enc.Hex.parse(w.toString());var u=CryptoJS.enc.Base64.stringify(r);return u};var i={\"AES-256-CBC\":{proc:d,eproc:l,keylen:32,ivlen:16},\"AES-192-CBC\":{proc:d,eproc:l,keylen:24,ivlen:16},\"AES-128-CBC\":{proc:d,eproc:l,keylen:16,ivlen:16},\"DES-EDE3-CBC\":{proc:e,eproc:o,keylen:24,ivlen:8},\"DES-CBC\":{proc:a,eproc:f,keylen:8,ivlen:8}};var c=function(p){return i[p][\"proc\"]};var m=function(p){var r=CryptoJS.lib.WordArray.random(p);var q=CryptoJS.enc.Hex.stringify(r);return q};var n=function(v){var w={};var q=v.match(new RegExp(\"DEK-Info: ([^,]+),([0-9A-Fa-f]+)\",\"m\"));if(q){w.cipher=q[1];w.ivsalt=q[2]}var p=v.match(new RegExp(\"-----BEGIN ([A-Z]+) PRIVATE KEY-----\"));if(p){w.type=p[1]}var u=-1;var x=0;if(v.indexOf(\"\\r\\n\\r\\n\")!=-1){u=v.indexOf(\"\\r\\n\\r\\n\");x=2}if(v.indexOf(\"\\n\\n\")!=-1){u=v.indexOf(\"\\n\\n\");x=1}var t=v.indexOf(\"-----END\");if(u!=-1&&t!=-1){var r=v.substring(u+x*2,t-x);r=r.replace(/\\s+/g,\"\");w.data=r}return w};var j=function(q,y,p){var v=p.substring(0,16);var t=CryptoJS.enc.Hex.parse(v);var r=CryptoJS.enc.Utf8.parse(y);var u=i[q][\"keylen\"]+i[q][\"ivlen\"];var x=\"\";var w=null;for(;;){var s=CryptoJS.algo.MD5.create();if(w!=null){s.update(w)}s.update(r);s.update(t);w=s.finalize();x=x+CryptoJS.enc.Hex.stringify(w);if(x.length>=u*2){break}}var z={};z.keyhex=x.substr(0,i[q][\"keylen\"]*2);z.ivhex=x.substr(i[q][\"keylen\"]*2,i[q][\"ivlen\"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v][\"proc\"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s][\"eproc\"];var t=r(p,q,u);return t};return{version:\"1.0.0\",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p=\"\";if(typeof t==\"undefined\"||t==null){t=\"AES-256-CBC\"}if(typeof i[t]==\"undefined\"){throw\"KEYUTIL unsupported algorithm: \"+t}if(typeof r==\"undefined\"||r==null){var v=i[t][\"ivlen\"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,\"$1\\r\\n\");var p=\"-----BEGIN \"+x+\" PRIVATE KEY-----\\r\\n\";p+=\"Proc-Type: 4,ENCRYPTED\\r\\n\";p+=\"DEK-Info: \"+t+\",\"+r+\"\\r\\n\";p+=\"\\r\\n\";p+=q;p+=\"\\r\\n-----END \"+x+\" PRIVATE KEY-----\\r\\n\";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw\"malformed format: SEQUENCE(0).items != 2: \"+r.length}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0).items != 2: \"+A.length}if(w(y,A[0])!=\"2a864886f70d01050d\"){throw\"this only supports pkcs5PBES2\"}var p=z(y,A[1]);if(A.length!=2){throw\"malformed format: SEQUENCE(0.0.1).items != 2: \"+p.length}var q=z(y,p[1]);if(q.length!=2){throw\"malformed format: SEQUENCE(0.0.1.1).items != 2: \"+q.length}if(w(y,q[0])!=\"2a864886f70d0307\"){throw\"this only supports TripleDES\"}t.encryptionSchemeAlg=\"TripleDES\";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw\"malformed format: SEQUENCE(0.0.1.0).items != 2: \"+s.length}if(w(y,s[0])!=\"2a864886f70d01050c\"){throw\"this only supports pkcs5PBKDF2\"}var x=z(y,s[1]);if(x.length<2){throw\"malformed format: SEQUENCE(0.0.1.0.1).items < 2: \"+x.length}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw\"malformed format pbkdf2Iter: \"+u}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,\"ENCRYPTED PRIVATE KEY\");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!=\"30\"){throw\"malformed plain PKCS8 private key(code:001)\"}var r=u(s,0);if(r.length!=3){throw\"malformed plain PKCS8 private key(code:002)\"}if(s.substr(r[1],2)!=\"30\"){throw\"malformed PKCS8 private key(code:003)\"}var p=u(s,r[1]);if(p.length!=2){throw\"malformed PKCS8 private key(code:004)\"}if(s.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 private key(code:005)\"}q.algoid=t(s,p[0]);if(s.substr(p[1],2)==\"06\"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!=\"04\"){throw\"malformed PKCS8 private key(code:006)\"}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,\"PRIVATE KEY\");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid==\"2a864886f70d010101\"){r=new RSAKey()}else{if(q.algoid==\"2a8648ce380401\"){r=new KJUR.crypto.DSA()}else{if(q.algoid==\"2a8648ce3d0201\"){r=new KJUR.crypto.ECDSA()}else{throw\"unsupported private key algorithm\"}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],\"06\");if(r===\"2a864886f70d010101\"){p=new RSAKey()}else{if(r===\"2a8648ce380401\"){p=new KJUR.crypto.DSA()}else{if(r===\"2a8648ce3d0201\"){p=new KJUR.crypto.ECDSA()}else{throw\"unsupported PKCS#8 public key hex\"}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!=\"30\"){throw\"malformed RSA key(code:001)\"}var q=t(r,0);if(q.length!=2){throw\"malformed RSA key(code:002)\"}if(r.substr(q[0],2)!=\"02\"){throw\"malformed RSA key(code:003)\"}p.n=s(r,q[0]);if(r.substr(q[1],2)!=\"02\"){throw\"malformed RSA key(code:004)\"}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw\"outer DERSequence shall have 2 elements: \"+r.length}var w=r[0];if(t.substr(w,2)!=\"30\"){throw\"malformed PKCS8 public key(code:001)\"}var p=u(t,w);if(p.length!=2){throw\"malformed PKCS8 public key(code:002)\"}if(t.substr(p[0],2)!=\"06\"){throw\"malformed PKCS8 public key(code:003)\"}q.algoid=s(t,p[0]);if(t.substr(p[1],2)==\"06\"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)==\"30\"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],\"02\");q.algparam.q=v.getVbyList(t,p[1],[1],\"02\");q.algparam.g=v.getVbyList(t,p[1],[2],\"02\")}}if(t.substr(r[1],2)!=\"03\"){throw\"malformed PKCS8 public key(code:004)\"}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!=\"undefined\"&&l instanceof w){return l}if(typeof i!=\"undefined\"&&l instanceof i){return l}if(typeof C!=\"undefined\"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty===\"RSA\"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;j.setPublicKeyHex(u);return j}if(l.kty===\"EC\"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keylen/4;var B=(\"0000000000\"+b64utohex(l.x)).slice(-t);var z=(\"0000000000\"+b64utohex(l.y)).slice(-t);var u=\"04\"+B+z;var b=(\"0000000000\"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n===\"pkcs5prv\"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)===\"04\"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw\"unsupported PKCS#1/5 hexadecimal key\"}}}return P}if(n===\"pkcs8prv\"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n===\"pkcs8pub\"){return F._getKeyFromPublicPKCS8Hex(l)}if(n===\"x509pub\"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf(\"-END CERTIFICATE-\",0)!=-1||l.indexOf(\"-END X509 CERTIFICATE-\",0)!=-1||l.indexOf(\"-END TRUSTED CERTIFICATE-\",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf(\"-END PUBLIC KEY-\")!=-1){var O=pemtohex(l,\"PUBLIC KEY\");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var m=M(l,\"RSA PRIVATE KEY\");return F.getKey(m,null,\"pkcs5prv\")}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")==-1){var I=M(l,\"DSA PRIVATE KEY\");var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END PRIVATE KEY-\")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf(\"-END RSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf(\"-END EC PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],\"04\");var f=d(I,0,[2,0],\"06\");var A=d(I,0,[3,0],\"03\").substr(2);var e=\"\";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw\"undefined OID(hex) in KJUR.crypto.OID: \"+f}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf(\"-END DSA PRIVATE KEY-\")!=-1&&l.indexOf(\"4,ENCRYPTED\")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],\"02\");var D=d(I,0,[2],\"02\");var K=d(I,0,[3],\"02\");var r=d(I,0,[4],\"02\");var s=d(I,0,[5],\"02\");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf(\"-END ENCRYPTED PRIVATE KEY-\")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw\"not supported argument\"};KEYUTIL.generateKeypair=function(a,c){if(a==\"RSA\"){var b=c;var h=new RSAKey();h.generate(b,\"10001\");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a==\"EC\"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw\"unknown algorithm: \"+a}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.n}},{\"int\":s.e},{\"int\":{bigint:s.d}},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.dmp1}},{\"int\":{bigint:s.dmq1}},{\"int\":{bigint:s.coeff}}]});return G}function B(G){var s=l({seq:[{\"int\":1},{octstr:{hex:G.prvKeyHex}},{tag:[\"a0\",true,{oid:{name:G.curveName}}]},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+G.pubKeyHex}}]}]});return s}function x(s){var G=l({seq:[{\"int\":0},{\"int\":{bigint:s.p}},{\"int\":{bigint:s.q}},{\"int\":{bigint:s.g}},{\"int\":{bigint:s.y}},{\"int\":{bigint:s.x}}]});return G}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D==\"PKCS8PUB\")){var E=new C(b);var w=E.getEncodedHex();return hextopem(w,\"PUBLIC KEY\")}if(D==\"PKCS1PRV\"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();return hextopem(w,\"RSA PRIVATE KEY\")}if(D==\"PKCS1PRV\"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.getEncodedHex();var h=B(b);var t=h.getEncodedHex();var p=\"\";p+=hextopem(v,\"EC PARAMETERS\");p+=hextopem(t,\"EC PRIVATE KEY\");return p}if(D==\"PKCS1PRV\"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();return hextopem(w,\"DSA PRIVATE KEY\")}if(D==\"PKCS5PRV\"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"RSA\",w,y,m,j)}if(D==\"PKCS5PRV\"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"EC\",w,y,m,j)}if(D==\"PKCS5PRV\"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.getEncodedHex();if(m===undefined){m=\"DES-EDE3-CBC\"}return this.getEncryptedPKCS5PEMFromPrvKeyHex(\"DSA\",w,y,m,j)}var o=function(G,s){var I=c(G,s);var H=new l({seq:[{seq:[{oid:{name:\"pkcs5PBES2\"}},{seq:[{seq:[{oid:{name:\"pkcs5PBKDF2\"}},{seq:[{octstr:{hex:I.pbkdf2Salt}},{\"int\":I.pbkdf2Iter}]}]},{seq:[{oid:{name:\"des-EDE3-CBC\"}},{octstr:{hex:I.encryptionSchemeIV}}]}]}]},{octstr:{hex:I.ciphertext}}]});return H.getEncodedHex()};var c=function(N,O){var H=100;var M=CryptoJS.lib.WordArray.random(8);var L=\"DES-EDE3-CBC\";var s=CryptoJS.lib.WordArray.random(8);var I=CryptoJS.PBKDF2(O,M,{keySize:192/32,iterations:H});var J=CryptoJS.enc.Hex.parse(N);var K=CryptoJS.TripleDES.encrypt(J,I,{iv:s})+\"\";var G={};G.ciphertext=K;G.pbkdf2Salt=CryptoJS.enc.Hex.stringify(M);G.pbkdf2Iter=H;G.encryptionSchemeAlg=L;G.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return G};if(D==\"PKCS8PRV\"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"rsaEncryption\"}},{\"null\":true}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var g=new l({seq:[{\"int\":1},{octstr:{hex:b.prvKeyHex}},{tag:[\"a1\",true,{bitstr:{hex:\"00\"+b.pubKeyHex}}]}]});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"ecPublicKey\"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}if(D==\"PKCS8PRV\"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.getEncodedHex();var E=l({seq:[{\"int\":0},{seq:[{oid:{name:\"dsa\"}},{seq:[{\"int\":{bigint:b.p}},{\"int\":{bigint:b.q}},{\"int\":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.getEncodedHex();if(y===undefined||y==null){return hextopem(w,\"PRIVATE KEY\")}else{var t=o(w,y);return hextopem(t,\"ENCRYPTED PRIVATE KEY\")}}throw\"unsupported object nor format\"};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,\"CERTIFICATE REQUEST\");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,\"pkcs8pub\");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!=\"30\"){throw\"malformed CSR(code:001)\"}var e=f(g,0);if(e.length<1){throw\"malformed CSR(code:002)\"}if(g.substr(e[0],2)!=\"30\"){throw\"malformed CSR(code:003)\"}var a=f(g,e[0]);if(a.length<3){throw\"malformed CSR(code:004)\"}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getJWKFromKey=function(d){var b={};if(d instanceof RSAKey&&d.isPrivate){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));b.d=hextob64u(d.d.toString(16));b.p=hextob64u(d.p.toString(16));b.q=hextob64u(d.q.toString(16));b.dp=hextob64u(d.dmp1.toString(16));b.dq=hextob64u(d.dmq1.toString(16));b.qi=hextob64u(d.coeff.toString(16));return b}else{if(d instanceof RSAKey&&d.isPublic){b.kty=\"RSA\";b.n=hextob64u(d.n.toString(16));b.e=hextob64u(d.e.toString(16));return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPrivate){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);b.d=hextob64u(d.prvKeyHex);return b}else{if(d instanceof KJUR.crypto.ECDSA&&d.isPublic){var a=d.getShortNISTPCurveName();if(a!==\"P-256\"&&a!==\"P-384\"){throw\"unsupported curve name for JWT: \"+a}var c=d.getPublicKeyXYHex();b.kty=\"EC\";b.crv=a;b.x=hextob64u(c.x);b.y=hextob64u(c.y);return b}}}}throw\"not supported key object\"};\nRSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,j,l,b,a,f,d,k;var m=ASN1HEX;var g=m.getVbyList;if(m.isASN1HEX(e)===false){throw\"not ASN.1 hex string\"}try{c=g(e,0,[2,0,1],\"02\");j=g(e,0,[2,0,2],\"02\");l=g(e,0,[2,0,3],\"02\");b=g(e,0,[2,0,4],\"02\");a=g(e,0,[2,0,5],\"02\");f=g(e,0,[2,0,6],\"02\");d=g(e,0,[2,0,7],\"02\");k=g(e,0,[2,0,8],\"02\")}catch(i){throw\"malformed PKCS#8 plain RSA private key\"}this.setPrivateEx(c,j,l,b,a,f,d,k)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw\"keyHex is not ASN.1 hex string\"}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!==\"02\"||c.substr(a[1],2)!==\"02\"){throw\"wrong hex for PKCS#5 public key\"}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw\"not ASN.1 hex string\"}if(c.getTLVbyList(b,0,[0,0])!==\"06092a864886f70d010101\"){throw\"not PKCS8 RSA public key\"}var a=c.getTLVbyList(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)};\nvar _RE_HEXDECONLY=new RegExp(\"\");_RE_HEXDECONLY.compile(\"[^0-9a-f]\",\"gi\");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c=\"\";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw\"invalid salt length\"}}}if(c<(g+k+2)){throw\"data too long\"}var f=\"\";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dthis.n.bitLength()){return 0}var i=this.doPublic(b);var e=i.toString(16).replace(/^1f+00/,\"\");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(k){return KJUR.crypto.Util.hashString(k,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){a=a.replace(_RE_HEXDECONLY,\"\");a=a.replace(/[ \\n]+/g,\"\");var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,\"\");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){var k=new BigInteger(s,16);if(k.bitLength()>this.n.bitLength()){return false}var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw\"invalid salt length\"}}}if(m<(h+c+2)){throw\"data too long\"}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw\"bits beyond keysize not zero\"}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q0){var b=\":\"+n.join(\":\")+\":\";if(b.indexOf(\":\"+k+\":\")==-1){throw\"algorithm '\"+k+\"' not accepted in the list\"}}if(k!=\"none\"&&B===null){throw\"key shall be specified to verify.\"}if(typeof B==\"string\"&&B.indexOf(\"-----BEGIN \")!=-1){B=KEYUTIL.getKey(B)}if(z==\"RS\"||z==\"PS\"){if(!(B instanceof m)){throw\"key shall be a RSAKey obj for RS* and PS* algs\"}}if(z==\"ES\"){if(!(B instanceof p)){throw\"key shall be a ECDSA obj for ES* algs\"}}if(k==\"none\"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw\"unsupported alg name: \"+k}else{u=t.jwsalg2sigalg[k]}if(u==\"none\"){throw\"not supported\"}else{if(u.substr(0,4)==\"Hmac\"){var o=null;if(B===undefined){throw\"hexadecimal key shall be specified for HMAC\"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf(\"withECDSA\")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(\".\");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw\"malformed sJWS: wrong number of '.' splitted elements\"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null,\" \");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null,\" \")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;var k=e.split(\".\");var c=k[0];var i=k[1];var q=c+\".\"+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw\"acceptField.alg shall be specified\"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss===\"object\"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub===\"object\"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud===\"object\"){if(typeof g.aud==\"string\"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud==\"object\"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt===\"number\"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!==\"number\"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp==\"number\"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw\"addSignature failed: \"+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw\"malformed header\"}if(typeof g.payload===\"string\"){this.sPayload=g.payload}else{throw\"malformed signatures\"}if(g.signatures.length>0){this.aSignatures=g.signatures}else{throw\"malformed signatures\"}}catch(e){throw\"malformed JWS-JS JSON object: \"+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}};\nexports.SecureRandom = SecureRandom;\nexports.rng_seed_time = rng_seed_time;\n\nexports.BigInteger = BigInteger;\nexports.RSAKey = RSAKey;\nexports.ECDSA = KJUR.crypto.ECDSA;\nexports.DSA = KJUR.crypto.DSA;\nexports.Signature = KJUR.crypto.Signature;\nexports.MessageDigest = KJUR.crypto.MessageDigest;\nexports.Mac = KJUR.crypto.Mac;\nexports.Cipher = KJUR.crypto.Cipher;\nexports.KEYUTIL = KEYUTIL;\nexports.ASN1HEX = ASN1HEX;\nexports.X509 = X509;\nexports.CryptoJS = CryptoJS;\n\n// ext/base64.js\nexports.b64tohex = b64tohex;\nexports.b64toBA = b64toBA;\n\n// base64x.js\nexports.stoBA = stoBA;\nexports.BAtos = BAtos;\nexports.BAtohex = BAtohex;\nexports.stohex = stohex;\nexports.stob64 = stob64;\nexports.stob64u = stob64u;\nexports.b64utos = b64utos;\nexports.b64tob64u = b64tob64u;\nexports.b64utob64 = b64utob64;\nexports.hex2b64 = hex2b64;\nexports.hextob64u = hextob64u;\nexports.b64utohex = b64utohex;\nexports.utf8tob64u = utf8tob64u;\nexports.b64utoutf8 = b64utoutf8;\nexports.utf8tob64 = utf8tob64;\nexports.b64toutf8 = b64toutf8;\nexports.utf8tohex = utf8tohex;\nexports.hextoutf8 = hextoutf8;\nexports.hextorstr = hextorstr;\nexports.rstrtohex = rstrtohex;\nexports.hextob64 = hextob64;\nexports.hextob64nl = hextob64nl;\nexports.b64nltohex = b64nltohex;\nexports.hextopem = hextopem;\nexports.pemtohex = pemtohex;\nexports.hextoArrayBuffer = hextoArrayBuffer;\nexports.ArrayBuffertohex = ArrayBuffertohex;\nexports.zulutomsec = zulutomsec;\nexports.zulutosec = zulutosec;\nexports.zulutodate = zulutodate;\nexports.datetozulu = datetozulu;\nexports.uricmptohex = uricmptohex;\nexports.hextouricmp = hextouricmp;\nexports.ipv6tohex = ipv6tohex;\nexports.hextoipv6 = hextoipv6;\nexports.hextoip = hextoip;\nexports.iptohex = iptohex;\nexports.encodeURIComponentAll = encodeURIComponentAll;\nexports.newline_toUnix = newline_toUnix;\nexports.newline_toDos = newline_toDos;\nexports.hextoposhex = hextoposhex;\nexports.intarystrtohex = intarystrtohex;\nexports.strdiffidx = strdiffidx;\n\n// name spaces\nexports.KJUR = KJUR;\nexports.crypto = KJUR.crypto;\nexports.asn1 = KJUR.asn1;\nexports.jws = KJUR.jws;\nexports.lang = KJUR.lang;\n\n\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack://AppID/./node_modules/jsrsasign/lib/jsrsasign.js?"); - -/***/ }), - -/***/ "./node_modules/node-fetch/browser.js": -/*!********************************************!*\ - !*** ./node_modules/node-fetch/browser.js ***! - \********************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; -eval("\n\n// ref: https://github.com/tc39/proposal-global\nvar getGlobal = function () {\n\t// the only reliable means to get the global object is\n\t// `Function('return this')()`\n\t// However, this causes CSP violations in Chrome apps.\n\tif (typeof self !== 'undefined') { return self; }\n\tif (typeof window !== 'undefined') { return window; }\n\tif (typeof global !== 'undefined') { return global; }\n\tthrow new Error('unable to locate global object');\n}\n\nvar global = getGlobal();\n\nmodule.exports = exports = global.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = global.fetch.bind(global);\n\nexports.Headers = global.Headers;\nexports.Request = global.Request;\nexports.Response = global.Response;\n\n//# sourceURL=webpack://AppID/./node_modules/node-fetch/browser.js?"); - -/***/ }), - -/***/ "./node_modules/webpack/buildin/global.js": -/*!***********************************!*\ - !*** (webpack)/buildin/global.js ***! - \***********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://AppID/(webpack)/buildin/global.js?"); - -/***/ }), - -/***/ "./package.json": -/*!**********************!*\ - !*** ./package.json ***! - \**********************/ -/*! exports provided: name, version, description, scripts, repository, main, nyc, dependencies, devDependencies, default */ -/***/ (function(module) { - -eval("module.exports = JSON.parse(\"{\\\"name\\\":\\\"ibmcloud-appid-js\\\",\\\"version\\\":\\\"0.3.0\\\",\\\"description\\\":\\\"IBM Cloud App ID SDK for Single Page Applications\\\",\\\"scripts\\\":{\\\"build\\\":\\\"webpack --mode=development\\\",\\\"test\\\":\\\"mocha\\\",\\\"coverage\\\":\\\"nyc --reporter=lcov mocha\\\",\\\"docs\\\":\\\"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json\\\"},\\\"repository\\\":{\\\"type\\\":\\\"git\\\",\\\"url\\\":\\\"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git\\\"},\\\"main\\\":\\\"dist/appid.umd.min.js\\\",\\\"nyc\\\":{\\\"all\\\":true,\\\"include\\\":[\\\"src/*.js\\\"],\\\"exclude\\\":[\\\"**/PopupController.js\\\",\\\"**/IFrameController.js\\\",\\\"**/OpenIDConfigurationResource.js\\\",\\\"**/constants.js\\\"]},\\\"dependencies\\\":{\\\"jsrsasign\\\":\\\"^8.0.12\\\"},\\\"devDependencies\\\":{\\\"node-fetch\\\":\\\"^2.6.0\\\",\\\"@babel/cli\\\":\\\"^7.0.0\\\",\\\"@babel/core\\\":\\\"^7.5.5\\\",\\\"@babel/plugin-transform-runtime\\\":\\\"^7.5.5\\\",\\\"@babel/preset-env\\\":\\\"^7.5.5\\\",\\\"babel-cli\\\":\\\"^7.0.0-beta.3\\\",\\\"chai\\\":\\\"^4.2.0\\\",\\\"coveralls\\\":\\\"^3.0.6\\\",\\\"gulp-babel\\\":\\\"^8.0.0\\\",\\\"mocha\\\":\\\"^6.2.0\\\",\\\"nyc\\\":\\\"^14.1.1\\\",\\\"webpack\\\":\\\"^4.39.1\\\",\\\"webpack-cli\\\":\\\"^3.3.6\\\",\\\"docdash\\\":\\\"^1.1.1\\\",\\\"jsdoc\\\":\\\"^3.6.3\\\"}}\");\n\n//# sourceURL=webpack://AppID/./package.json?"); - -/***/ }), - -/***/ "./src/IFrameController.js": -/*!*********************************!*\ - !*** ./src/IFrameController.js ***! - \*********************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const IFrameError = __webpack_require__(/*! ./errors/IFrameError */ \"./src/errors/IFrameError.js\");\n\nclass IFrameController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t}\n\n\topen(url) {\n\t\tthis.iFrame = this.window.document.createElement('iframe');\n\t\tthis.iFrame.src = url;\n\t\tthis.iFrame.width = 0;\n\t\tthis.iFrame.height = 0;\n\t\tthis.window.document.body.appendChild(this.iFrame);\n\t}\n\n\tremove() {\n\t\twindow.document.body.removeChild(this.iFrame);\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\treject(new IFrameError('Silent sign-in timed out'));\n\t\t\t}, 5 * 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tclearInterval(timer);\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = IFrameController;\n\n\n//# sourceURL=webpack://AppID/./src/IFrameController.js?"); - -/***/ }), - -/***/ "./src/OpenIDConfigurationResource.js": -/*!********************************************!*\ - !*** ./src/OpenIDConfigurationResource.js ***! - \********************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const packagejson = __webpack_require__(/*! ../package.json */ \"./package.json\");\n\nclass OpenIdConfigurationResource {\n\tasync init({discoveryEndpoint, requestHandler}){\n\t\tthis.openIdConfig = await requestHandler(discoveryEndpoint);\n\t\tconst headers = { 'x-filter-type': `spa:v${packagejson.version}` };\n\t\tthis.publicKeys = requestHandler(this.getJwksEndpoint(), { headers: headers });\n\t}\n\n\tgetAuthorizationEndpoint() {\n\t\treturn this.openIdConfig.authorization_endpoint;\n\t}\n\n\tgetUserInfoEndpoint() {\n\t\treturn this.openIdConfig.userinfo_endpoint;\n\t}\n\n\tgetJwksEndpoint() {\n\t\treturn this.openIdConfig.jwks_uri;\n\t}\n\n\tgetTokenEndpoint() {\n\t\treturn this.openIdConfig.token_endpoint;\n\t}\n\n\tgetIssuer() {\n\t\treturn this.openIdConfig.issuer;\n\t}\n\n\tasync getPublicKeys() {\n\t\treturn await this.publicKeys;\n\t}\n}\nmodule.exports = OpenIdConfigurationResource;\n\n\n\n//# sourceURL=webpack://AppID/./src/OpenIDConfigurationResource.js?"); - -/***/ }), - -/***/ "./src/PopupController.js": -/*!********************************!*\ - !*** ./src/PopupController.js ***! - \********************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const PopupError = __webpack_require__(/*! ./errors/PopupError */ \"./src/errors/PopupError.js\");\n\nclass PopupController {\n\tconstructor({w = window} = {}) {\n\t\tthis.window = w;\n\t};\n\n\tinit(popupConfig){\n\t\tthis.popupConfig = popupConfig;\n\t}\n\n\topen() {\n\t\tconst h = this.popupConfig.height;\n\t\tconst w = this.popupConfig.width;\n\t\tconst left = (window.screen.width - w) / 2;\n\t\tconst top = (window.screen.height - h) / 2;\n\t\tthis.popup = this.window.open('', 'popup', `left=${left},top=${top},width=${w},height=${h},resizable,scrollbars=yes,status=1`);\n\t\tif (!this.popup) {\n\t\t\tthrow new PopupError('Unable to open popup')\n\t\t}\n\t};\n\n\tnavigate(url) {\n\t\tthis.popup.location.href = url;\n\t};\n\n\tclose() {\n\t\tthis.popup.close();\n\t}\n\n\tasync waitForMessage({messageType}) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst timer = setInterval(() => {\n\t\t\t\tif(this.popup.closed) {\n\t\t\t\t\tclearInterval(timer);\n\t\t\t\t\treject(new PopupError('Popup closed'));\n\t\t\t\t}\n\t\t\t}, 1000);\n\t\t\twindow.addEventListener('message', (message) => {\n\t\t\t\tif (!message.data || message.data.type !== messageType) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tresolve(message);\n\t\t\t});\n\t\t});\n\t}\n}\nmodule.exports = PopupController;\n\n\n//# sourceURL=webpack://AppID/./src/PopupController.js?"); - -/***/ }), - -/***/ "./src/RequestHandler.js": -/*!*******************************!*\ - !*** ./src/RequestHandler.js ***! - \*******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const fetch = __webpack_require__(/*! node-fetch */ \"./node_modules/node-fetch/browser.js\");\nconst RequestError = __webpack_require__(/*! ./errors/RequestError */ \"./src/errors/RequestError.js\");\nclass RequestHandler {\n\tasync request(url, options) {\n\t\tlet response, text;\n\t\ttry {\n\t\t\tresponse = await fetch(url, options);\n\t\t\ttext = await response.text();\n\t\t} catch (e) {\n\t\t\tdebugger;\n\t\t\tthrow new RequestError(`Failed to fetch ${url}. ${e}`, null, e);\n\t\t}\n\n\t\tif (!response.ok || response.status > 300) {\n\t\t\tdebugger;\n\t\t\tif (text.includes('id token not generated with cloud directory idp')) {\n\t\t\t\tthrow new RequestError(`${JSON.parse(text).error_description}`, response.status);\n\t\t\t} else {\n\t\t\t\tthrow new RequestError(`Failed to fetch ${url}. Response=${text}`, response.status);\n\t\t\t}\n\t\t}\n\t\t\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch(err) {\n\t\t\tif (text !== '') {\n\t\t\t\treturn text;\n\t\t\t}\n\t\t\tthrow new RequestError(`Invalid response while trying to fetch ${url}. Response=${text}`, response.status, err);\n\t\t}\n\t};\n}\nmodule.exports = RequestHandler;\n\n\n//# sourceURL=webpack://AppID/./src/RequestHandler.js?"); - -/***/ }), - -/***/ "./src/TokenValidator.js": -/*!*******************************!*\ - !*** ./src/TokenValidator.js ***! - \*******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst TokenError = __webpack_require__(/*! ./errors/TokenError */ \"./src/errors/TokenError.js\");\n\nclass TokenValidator {\n\tconstructor({jwt = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\")} = {}) {\n\t\tthis.jwt = jwt;\n\t}\n\n\tdecodeAndValidate({token, publicKeys, issuer, clientId, nonce}) {\n\t\tconst now = Math.floor(Date.now() / 1000);\n\n\t\tconst tokenParts = token.split('.');\n\t\tif (tokenParts.length !== 3) {\n\t\t\tthrow new TokenError(`Invalid JWT token. Got only ${tokenParts.length} parts.`);\n\t\t}\n\n\t\tconst decoded = this.jwt.KJUR.jws.JWS.parse(token);\n\t\tif (!decoded.headerObj) {\n\t\t\tthrow new TokenError(constants.INVALID_TOKEN);\n\t\t}\n\t\tconst kid = decoded.headerObj.kid;\n\t\tconst publicKey = this.getPublicKey(publicKeys.keys, kid);\n\n\t\tconst myKey = this.jwt.KEYUTIL.getKey(publicKey);\n\t\tconst isValid = this.jwt.KJUR.jws.JWS.verify(token, myKey, {alg: [constants.TOKEN_ALG]});\n\t\tif (!isValid) {\n\t\t\tthrow new TokenError(constants.INVALID_SIGNATURE);\n\t\t}\n\n\t\tif (decoded.payloadObj.exp < now) {\n\t\t\tthrow new TokenError(constants.EXPIRED_TOKEN);\n\t\t}\n\n\t\tif (decoded.headerObj.ver !== constants.VERSION) {\n\t\t\tthrow new TokenError(constants.INVALID_VERSION);\n\t\t}\n\n\t\tif (decoded.headerObj.alg !== constants.TOKEN_ALG) {\n\t\t\tthrow new TokenError(constants.INVALID_ALGORITHM);\n\t\t}\n\n\t\tif (decoded.payloadObj.iss !== issuer) {\n\t\t\tthrow new TokenError(constants.INVALID_ISSUER);\n\t\t}\n\n\t\tif (!decoded.payloadObj.aud.includes(clientId)) {\n\t\t\tthrow new TokenError(constants.INVALID_AUDIENCE);\n\t\t}\n\n\t\tif (nonce && (!decoded.payloadObj.nonce || decoded.payloadObj.nonce !== nonce)) {\n\t\t\tthrow new TokenError(constants.INVALID_NONCE);\n\t\t}\n\n\t\treturn decoded.payloadObj;\n\t}\n\n\tgetPublicKey(keys, kid) {\n\t\tlet publicKey;\n\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\tif (keys[i].kid === kid) {\n\t\t\t\tpublicKey = keys[i];\n\t\t\t}\n\t\t}\n\n\t\tif (!publicKey) {\n\t\t\tthrow new TokenError(constants.MISSING_PUBLIC_KEY);\n\t\t}\n\t\treturn publicKey;\n\t}\n}\n\nmodule.exports = TokenValidator;\n\n\n//# sourceURL=webpack://AppID/./src/TokenValidator.js?"); - -/***/ }), - -/***/ "./src/constants.js": -/*!**************************!*\ - !*** ./src/constants.js ***! - \**************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("module.exports = {\n\tMALFORMED_TOKEN: 'Invalid JWT token. Got only 2 parts.',\n\tINVALID_SIGNATURE: 'Invalid signature',\n\tINVALID_VERSION: 'Invalid version',\n\tINVALID_ALGORITHM: 'Invalid algorithm',\n\tINVALID_ISSUER: 'Invalid issuer',\n\tINVALID_AUDIENCE: 'Invalid audience',\n\tINVALID_NONCE: 'Invalid nonce',\n\tEXPIRED_TOKEN: 'Expired token',\n\tINVALID_STATE: 'Invalid state',\n\tINVALID_ORIGIN: 'Invalid origin',\n\tINVALID_TOKEN: 'Invalid token',\n\tMISSING_PUBLIC_KEY: 'Cannot find public key',\n\tINVALID_ACCESS_TOKEN: 'Access token must be a string',\n\tINVALID_ID_TOKEN: 'Invalid id token',\n\tNOT_CD_USER: 'Must be a Cloud Directory user',\n\tMISSING_CLIENT_ID: 'Missing client ID',\n\tMISSING_ID_TOKEN: 'Missing id token string',\n\tMISSING_ID_TOKEN_PAYLOAD: 'Missing id token payload',\n\tMISSING_TOKENS: 'Missing tokens',\n\tMISSING_ACCESS_TOKEN: 'Missing access token string',\n\tMISSING_ID_TOKEN: 'Missing access token string',\n\tINVALID_DISCOVERY_ENDPOINT: 'Invalid discovery endpoint',\n\tFAIL_TO_INITIALIZE: 'You must call and wait for init() before calling this function.',\n\tRESPONSE_TYPE: 'code',\n\tRESPONSE_MODE: 'web_message',\n\tPROMPT: 'none',\n \tSCOPE: 'openid',\n \tSTATE_LENGTH: 20,\n \tNONCE_LENGTH: 20,\n \tCODE_VERIFIER_LENGTH: 44,\n\tCHALLENGE_METHOD: 'S256',\n\tTOKEN_ALG: 'RS256',\n\tVERSION: 4,\n\tCHANGE_PASSWORD: '/cloud_directory/change_password',\n\tGENERATE_CODE: '/cloud_directory/generate_code',\n\tCHANGE_DETAILS: '/cloud_directory/change_details',\n\tOAUTH: '/oauth/v4/',\n\tMALFORMED_ACCESS_TOKEN: 'eyJpc3MiOiJtb2JpbGVjbGllbnRhY2Nlc3Muc3RhZ2UxLm5nLmJsdWVtaXgubmV0IiwiZXhwIjoxNDg3MDg0ODc4LCJhdWQiOiIyNmNiMDEyZWIzMjdjNjEyZDkwYTY4MTkxNjNiNmJjYmQ0ODQ5Y2JiIiwiaWF0IjoxNDg3MDgxMjc4LCJhdXRoX2J5IjoiZmFjZWJvb2siLCJ0ZW5hbnQiOiI0ZGJhOTQzMC01NGU2LTRjZjItYTUxNi02ZjczZmViNzAyYmIiLCJzY29wZSI6ImFwcGlkX2RlZmF1bHQgYXBwaWRfcmVhZHByb2ZpbGUgYXBwaWRfcmVhZHVzZXJhdHRyIGFwcGlkX3dyaXRldXNlcmF0dHIifQ.HHterec250JSDY1965cM2DadBznl2wTKmzKNSnfjpdTAqax9VZvV3EwuFbEnGp9-i6AC-OlsVj7xvbALkdjwG2lZvpQx0M_gRc_3E0NiYuOGVolcm0wEXtbtDUFFqZQAf9BYYOPZ8OintdBiwUGETbH1ZRVtUvt3nalIko1OPE1Q12LvuRlhz5MClNHmvxJcXc7kucxCx4s4UFFy_HJA1gow7HWFqc9-PZf4JMWA-siYqPrdw_zYeBTBzE5co92F6JBEtGLLCjhJVz9eYgLLECXbak3z6hOaY9352Weuj7AgMOWxzw56jKKsiixMtvzrCzLVIcRUG96UJszwPHtPlA',\n\tINVALID_SIGNATURE_TOKEN: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTU2NjMxMDg5NSwiZXhwIjoxNTY2MzE0NDk1LCJpYXQiOjE1NjYzMTA4OTUsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.NBDYg8VZxW770qcbIl40OFvaQntO-FVYUUJocE5ZgcyrvFTuomwF997OcEJghO8BE_Y2m67PbfPFsbN0VI6j'\n};\n\n//# sourceURL=webpack://AppID/./src/constants.js?"); - -/***/ }), - -/***/ "./src/errors/AppIDError.js": -/*!**********************************!*\ - !*** ./src/errors/AppIDError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class AppIDError extends Error {}\nmodule.exports = AppIDError;\n\n//# sourceURL=webpack://AppID/./src/errors/AppIDError.js?"); - -/***/ }), - -/***/ "./src/errors/IFrameError.js": -/*!***********************************!*\ - !*** ./src/errors/IFrameError.js ***! - \***********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class IFrameError extends Error {}\nmodule.exports = IFrameError;\n\n//# sourceURL=webpack://AppID/./src/errors/IFrameError.js?"); - -/***/ }), - -/***/ "./src/errors/OAuthError.js": -/*!**********************************!*\ - !*** ./src/errors/OAuthError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class OAuthError extends Error {\n\t// See https://tools.ietf.org/html/rfc6749#section-4.1.2.1 for the possible error messages\n\tconstructor({error, description}) {\n\t\tsuper(description || error);\n\t\tthis.error = error;\n\t\tthis.description = description;\n\t}\n}\nmodule.exports = OAuthError;\n\n//# sourceURL=webpack://AppID/./src/errors/OAuthError.js?"); - -/***/ }), - -/***/ "./src/errors/PopupError.js": -/*!**********************************!*\ - !*** ./src/errors/PopupError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class PopupError extends Error {}\nmodule.exports = PopupError;\n\n//# sourceURL=webpack://AppID/./src/errors/PopupError.js?"); - -/***/ }), - -/***/ "./src/errors/RequestError.js": -/*!************************************!*\ - !*** ./src/errors/RequestError.js ***! - \************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class RequestError extends Error {\n\tconstructor(description, status, originError) {\n\t\tsuper(description);\n\t\tthis.status = status;\n\t\tthis.originError = originError;\n\t}\n}\nmodule.exports = RequestError;\n\n//# sourceURL=webpack://AppID/./src/errors/RequestError.js?"); - -/***/ }), - -/***/ "./src/errors/TokenError.js": -/*!**********************************!*\ - !*** ./src/errors/TokenError.js ***! - \**********************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("class TokenError extends Error {}\nmodule.exports = TokenError;\n\n//# sourceURL=webpack://AppID/./src/errors/TokenError.js?"); - -/***/ }), - -/***/ "./src/index.js": -/*!**********************!*\ - !*** ./src/index.js ***! - \**********************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const Utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst PopupController = __webpack_require__(/*! ./PopupController */ \"./src/PopupController.js\");\nconst IFrameController = __webpack_require__(/*! ./IFrameController */ \"./src/IFrameController.js\");\nconst OpenIdConfigurationResource = __webpack_require__(/*! ./OpenIDConfigurationResource */ \"./src/OpenIDConfigurationResource.js\")\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\n\n/**\n * This class provides functions to support authentication.\n */\nclass AppID {\n\t/**\n\t * This creates an instance of AppID. Once created, call init() before attempting to sign in.\n\t * @example\n\t * const appID = new AppID();\n\t */\n\tconstructor(\n\t\t{\n\t\t\tpopup = new PopupController(),\n\t\t\tiframe = new IFrameController(),\n\t\t\topenIdConfigResource = new OpenIdConfigurationResource(),\n\t\t\tutils,\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\tw = window,\n\t\t\turl = URL\n\t\t} = {}) {\n\n\t\tthis.popup = popup;\n\t\tthis.iframe = iframe;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.URL = url;\n\t\tthis.utils = utils;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tif (!utils) {\n\t\t\tthis.utils = new Utils({\n\t\t\t\topenIdConfigResource: this.openIdConfigResource,\n\t\t\t\turl: this.URL,\n\t\t\t\tpopup: this.popup,\n\t\t\t\tjsrsasign\n\t\t\t});\n\t\t}\n\t\tthis.request = requestHandler.request;\n\t\tthis.window = w;\n\t\tthis.initialized = false;\n\t}\n\n\t/**\n\t * Initialize AppID. Call this function before attempting to sign in. You must wait for the promise to resolve.\n\t * @param {Object} options\n\t * @param {string} options.clientId - The clientId from the singlepageapp application credentials.\n\t * @param {string} options.discoveryEndpoint - The discoveryEndpoint from the singlepageapp application credentials.\n\t * @param {Object} [options.popup] - The popup configuration.\n\t * @param {Number} options.popup.height - The popup height.\n\t * @param {Number} options.popup.width - The popup width.\n\t * @returns {Promise}\n\t * @throws {AppIDError} For missing required params.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * await appID.init({\n\t * \tclientId: '',\n\t * \tdiscoveryEndpoint: ''\n\t * });\n\t *\n\t */\n\tasync init({clientId, discoveryEndpoint, popup = {height: window.screen.height * .80, width: 400}}) {\n\t\tif (!clientId) {\n\t\t\tthrow new AppIDError(constants.MISSING_CLIENT_ID);\n\t\t}\n\t\ttry {\n\t\t\tnew this.URL(discoveryEndpoint)\n\t\t} catch (e) {\n\t\t\tthrow new AppIDError(constants.INVALID_DISCOVERY_ENDPOINT);\n\t\t}\n\n\t\tawait this.openIdConfigResource.init({discoveryEndpoint, requestHandler: this.request});\n\t\tthis.popup.init(popup);\n\t\tthis.clientId = clientId;\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * @typedef {Object} Tokens\n\t * @property {string} accessToken A JWT.\n\t * @property {Object} accessTokenPayload The decoded JWT.\n\t * @property {string} idToken A JWT.\n\t * @property {Object} idTokenPayload The decoded JWT.\n\t */\n\n\t/**\n\t * This will open a sign in widget in a popup which will prompt the user to enter their credentials.\n\t * After a successful sign in, the popup will close and tokens are returned.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {PopupError} \"Popup closed\" - The user closed the popup before authentication was completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'server_error', description: ''}\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.signin();\n\t */\n\tasync signin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\treturn this.utils.performOAuthFlowAndGetTokens({origin: this.window.origin, clientId: this.clientId, endpoint});\n\t}\n\n\t/**\n\t * Silent sign in allows you to automatically obtain new tokens for a user without the user having to re-authenticate using a popup.\n\t * This will attempt to authenticate the user in a hidden iframe.\n\t * You will need to [enable Cloud Directory SSO]{@link https://cloud.ibm.com/docs/services/appid?topic=appid-single-page#spa-silent-login}.\n\t * Sign in will be successful only if the user has previously signed in using Cloud Directory and their session is not expired.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {OAuthError} Any errors from the server according to the [OAuth spec]{@link https://tools.ietf.org/html/rfc6749#section-4.1.2.1}. e.g. {error: 'access_denied', description: 'User not signed in'}\n\t * @throws {IFrameError} \"Silent sign-in timed out\" - The iframe will close after 5 seconds if authentication could not be completed.\n\t * @throws {TokenError} Any token validation error.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t * @example\n\t * const {accessToken, accessTokenPayload, idToken, idTokenPayload} = await appID.silentSignin();\n\t */\n\tasync silentSignin() {\n\t\tthis._validateInitalize();\n\t\tconst endpoint = this.openIdConfigResource.getAuthorizationEndpoint();\n\t\tconst {codeVerifier, nonce, state, url} = this.utils.getAuthParamsAndUrl({\n\t\t\tclientId: this.clientId,\n\t\t\torigin: this.window.origin,\n\t\t\tprompt: constants.PROMPT,\n\t\t\tendpoint\n\t\t});\n\n\t\tthis.iframe.open(url);\n\n\t\tlet message;\n\t\ttry {\n\t\t\tmessage = await this.iframe.waitForMessage({messageType: 'authorization_response'});\n\t\t} finally {\n\t\t\tthis.iframe.remove();\n\t\t}\n\t\tthis.utils.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.utils.retrieveTokens({\n\t\t\tclientId: this.clientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\topenId: this.openIdConfigResource,\n\t\t\twindowOrigin: this.window.origin\n\t\t});\n\t}\n\n\t/**\n\t * This method will make a GET request to the [user info endpoint]{@link https://us-south.appid.cloud.ibm.com/swagger-ui/#/Authorization%2520Server%2520-%2520Authorization%2520Server%2520V4/oauth-server.userInfo} using the access token of the authenticated user.\n\t * @param {string} accessToken The App ID access token of the user.\n\t * @returns {Promise} The user information for the authenticated user. Example: {sub: '', email: ''}\n\t * @throws {AppIDError} \"Access token must be a string\" Invalid access token.\n\t * @throws {RequestError} Any errors during a HTTP request.\n\t */\n\tasync getUserInfo(accessToken) {\n\t\tthis._validateInitalize();\n\t\tif (typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.INVALID_ACCESS_TOKEN);\n\t\t}\n\n\t\treturn await this.request(this.openIdConfigResource.getUserInfoEndpoint(), {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change password widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {string} idToken A JWT.\n\t * @returns {Promise} The tokens of the authenticated user.\n\t * @throws {AppIDError} \"Expect id token payload object to have identities field\"\n\t * @throws {AppIDError} \"Must be a Cloud Directory user\"\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @example\n\t * let tokens = await appID.changePassword(idToken);\n\t */\n\tasync changePassword(idToken) {\n\t\tthis._validateInitalize();\n\n\t\tif (!idToken || typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tlet userId;\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\t\tlet decodedToken = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: idToken,\n\t\t\tpublicKeys,\n\t\t\tissuer: this.openIdConfigResource.getIssuer(),\n\t\t\tclientId: this.clientId\n\t\t});\n\n\t\tif (decodedToken.identities && decodedToken.identities[0] && decodedToken.identities[0].id) {\n\t\t\tif (decodedToken.identities[0].provider !== 'cloud_directory') {\n\t\t\t\tthrow new AppIDError(constants.NOT_CD_USER);\n\t\t\t}\n\t\t\tuserId = decodedToken.identities[0].id;\n\t\t} else {\n\t\t\tthrow new AppIDError(constants.INVALID_ID_TOKEN);\n\t\t}\n\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_PASSWORD;\n\t\treturn await this.utils.performOAuthFlowAndGetTokens({\n\t\t\tuserId,\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint\n\t\t});\n\t}\n\n\t/**\n\t * This method will open a popup to the change details widget for Cloud Directory users.\n\t * You must enable users to manage their account from your app in Cloud Directory settings.\n\t * @param {Object} tokens App ID tokens\n\t * @returns {Promise}\n\t * @throws {AppIDError} \"Missing id token string\"\n\t * @throws {AppIDError} \"Missing access token string\"\n\t * @throws {AppIDError} \"Missing tokens object\"\n\t * @example\n\t * let tokens = {accessToken, idToken}\n\t * let newTokens = await appID.changeDetails(tokens);\n\t */\n\tasync changeDetails({accessToken, idToken}) {\n\t\tthis._validateInitalize();\n\n\t\tif (!accessToken && typeof accessToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ACCESS_TOKEN);\n\t\t}\n\n\t\tif (!idToken && typeof idToken !== 'string') {\n\t\t\tthrow new AppIDError(constants.MISSING_ID_TOKEN);\n\t\t}\n\n\t\tconst generateCodeUrl = this.openIdConfigResource.getIssuer() + constants.GENERATE_CODE;\n\t\tconst changeDetailsCode = await this.request(generateCodeUrl, {\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Bearer ' + accessToken + ' ' + idToken\n\t\t\t}\n\t\t});\n\t\tconst endpoint = this.openIdConfigResource.getIssuer() + constants.CHANGE_DETAILS;\n\n\t\treturn this.utils.performOAuthFlowAndGetTokens({\n\t\t\torigin: this.window.origin,\n\t\t\tclientId: this.clientId,\n\t\t\tendpoint,\n\t\t\tchangeDetailsCode\n\t\t});\n\t}\n\n\t/**\n\t *\n\t * @private\n\t */\n\t_validateInitalize() {\n\t\tif (!this.initialized) {\n\t\t\tthrow new AppIDError(constants.FAIL_TO_INITIALIZE);\n\t\t}\n\t}\n}\n\nmodule.exports = AppID;\n\n\n//# sourceURL=webpack://AppID/./src/index.js?"); - -/***/ }), - -/***/ "./src/utils.js": -/*!**********************!*\ - !*** ./src/utils.js ***! - \**********************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("const jsrsasign = __webpack_require__(/*! jsrsasign */ \"./node_modules/jsrsasign/lib/jsrsasign.js\");\nconst AppIDError = __webpack_require__(/*! ./errors/AppIDError */ \"./src/errors/AppIDError.js\");\nconst OAuthError = __webpack_require__(/*! ./errors/OAuthError */ \"./src/errors/OAuthError.js\");\nconst RequestHandler = __webpack_require__(/*! ./RequestHandler */ \"./src/RequestHandler.js\");\nconst TokenValidator = __webpack_require__(/*! ./TokenValidator */ \"./src/TokenValidator.js\");\nconst constants = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n\nclass Utils {\n\tconstructor(\n\t\t{\n\t\t\trequestHandler = new RequestHandler(),\n\t\t\ttokenValidator = new TokenValidator(),\n\t\t\turl = URL,\n\t\t\topenIdConfigResource,\n\t\t\tpopup,\n\t\t\tjsrsasign = jsrsasign\n\t\t} = {}) {\n\t\tthis.URL = url;\n\t\tthis.request = requestHandler.request;\n\t\tthis.tokenValidator = tokenValidator;\n\t\tthis.openIdConfigResource = openIdConfigResource;\n\t\tthis.popup = popup;\n\t\tthis.rs = jsrsasign;\n\t};\n\n\tbuildParams(params) {\n\t\treturn Object.keys(params).map(function (key) {\n\t\t\treturn encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);\n\t\t}).join('&');\n\t};\n\n\tgetRandomString(length) {\n\t\treturn this.rs.KJUR.crypto.Util.getRandomHexOfNbytes(length / 2);\n\t};\n\n\tsha256(message) {\n\t\treturn this.rs.KJUR.crypto.Util.sha256(message);\n\t}\n\n\tgetPKCEFields() {\n\t\tconst codeVerifier = this.getRandomString(constants.CODE_VERIFIER_LENGTH);\n\t\tconst codeChallenge = this.sha256(codeVerifier);\n\t\tconst state = this.getRandomString(constants.STATE_LENGTH);\n\t\tconst nonce = this.getRandomString(constants.NONCE_LENGTH);\n\t\treturn {codeVerifier, codeChallenge, state, nonce};\n\t}\n\n\tgetAuthParamsAndUrl({clientId, origin, prompt, endpoint, userId, changeDetailsCode}) {\n\t\tconst {codeVerifier, codeChallenge, state, nonce} = this.getPKCEFields();\n\t\tlet authParams = {\n\t\t\tclient_id: clientId,\n\t\t\tresponse_type: constants.RESPONSE_TYPE,\n\t\t\tstate: this.rs.stob64(state),\n\t\t\tcode_challenge: this.rs.stob64(codeChallenge),\n\t\t\tcode_challenge_method: constants.CHALLENGE_METHOD,\n\t\t\tredirect_uri: origin,\n\t\t\tresponse_mode: constants.RESPONSE_MODE,\n\t\t\tnonce,\n\t\t\tscope: constants.SCOPE\n\t\t};\n\n\t\tif (prompt) {\n\t\t\tauthParams.prompt = prompt;\n\t\t}\n\n\t\tif (userId) {\n\t\t\tauthParams.user_id = userId;\n\t\t}\n\n\t\tif (changeDetailsCode) {\n\t\t\tauthParams.code = changeDetailsCode;\n\t\t}\n\n\t\tconst url = endpoint + '?' + this.buildParams(authParams);\n\t\treturn {\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\tstate,\n\t\t\turl\n\t\t};\n\t}\n\n\tasync performOAuthFlowAndGetTokens({userId, origin, clientId, endpoint, changeDetailsCode}) {\n\t\tconst {codeVerifier, state, nonce, url} = this.getAuthParamsAndUrl({userId, origin, clientId, endpoint, changeDetailsCode});\n\n\t\tthis.popup.open();\n\t\tthis.popup.navigate(url);\n\t\tconst message = await this.popup.waitForMessage({messageType: 'authorization_response'});\n\t\tthis.popup.close();\n\t\tthis.verifyMessage({message, state});\n\t\tlet authCode = message.data.code;\n\n\t\treturn await this.retrieveTokens({\n\t\t\tclientId,\n\t\t\tauthCode,\n\t\t\tcodeVerifier,\n\t\t\tnonce,\n\t\t\twindowOrigin: origin\n\t\t});\n\t}\n\n\tverifyMessage({message, state}) {\n\t\tif (message.data.error || message.data.error_description) {\n\t\t\tthrow new OAuthError({description: message.data.error_description, error: message.data.error});\n\t\t}\n\n\t\tif (this.rs.b64utos(message.data.state) !== state) {\n\t\t\tthrow new AppIDError(constants.INVALID_STATE);\n\t\t}\n\n\t\tif (message.origin !== new this.URL(this.openIdConfigResource.getAuthorizationEndpoint()).origin) {\n\t\t\tthrow new AppIDError(constants.INVALID_ORIGIN);\n\t\t}\n\t}\n\n\tasync retrieveTokens({clientId, authCode, nonce, codeVerifier, windowOrigin}) {\n\t\tlet issuer = this.openIdConfigResource.getIssuer();\n\t\tlet params = {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tredirect_uri: windowOrigin,\n\t\t\tcode: authCode,\n\t\t\tcode_verifier: codeVerifier\n\t\t};\n\n\t\tconst requestParams = this.buildParams(params);\n\t\tconst tokenEndpoint = this.openIdConfigResource.getTokenEndpoint();\n\n\t\tconst tokens = await this.request(tokenEndpoint, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'Authorization': 'Basic ' + this.rs.stob64(`${clientId}:${codeVerifier}`),\n\t\t\t\t'Content-Type': 'application/x-www-form-urlencoded'\n\t\t\t},\n\t\t\tbody: requestParams\n\t\t});\n\t\tconsole.log(tokens);\n\t\tconst publicKeys = await this.openIdConfigResource.getPublicKeys();\n\n\t\tconst accessTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.access_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId\n\t\t});\n\n\t\tconst idTokenPayload = this.tokenValidator.decodeAndValidate({\n\t\t\ttoken: tokens.id_token,\n\t\t\tpublicKeys,\n\t\t\tissuer,\n\t\t\tclientId,\n\t\t\tnonce\n\t\t});\n\n\t\treturn {accessToken: tokens.access_token, accessTokenPayload, idToken: tokens.id_token, idTokenPayload};\n\t}\n}\n\nmodule.exports = Utils;\n\n//# sourceURL=webpack://AppID/./src/utils.js?"); - -/***/ }) - -/******/ }); -}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.AppID=e():t.AppID=e()}(window,(function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=5)}([function(t,e,i){(function(t){var i={userAgent:!1},n={}; +/*! +Copyright (c) 2011, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.com/yui/license.html +version: 2.9.0 +*/ +if(void 0===r)var r={};r.lang={extend:function(t,e,n){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),n){var s;for(s in n)t.prototype[s]=n[s];var o=function(){},a=["toString","valueOf"];try{/MSIE/.test(i.userAgent)&&(o=function(t,e){for(s=0;s>>2]>>>24-s%4*8&255;e[n+s>>>2]|=o<<24-(n+s)%4*8}else for(s=0;s>>2]=i[s>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=s.ceil(e/4)},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],i=0;i>>2]>>>24-r%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new u.init(i,e/2)}},f=c.Latin1={stringify:function(t){for(var e=t.words,i=t.sigBytes,n=[],r=0;r>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(t){for(var e=t.length,i=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new u.init(i,e)}},d=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},g=a.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=d.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e=this._data,i=e.words,n=e.sigBytes,r=this.blockSize,o=n/(4*r),a=(o=t?s.ceil(o):s.max((0|o)-this._minBufferSize,0))*r,h=s.min(4*a,n);if(a){for(var c=0;c>>2]}},e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:h,padding:c}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var i=e.createEncryptor;else i=e.createDecryptor,this._minBufferSize=1;this._mode=i.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var l=e.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),f=(h=(d.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?n.create([1398893684,1701076831]).concat(t).concat(e):e).toString(s)},parse:function(t){var e=(t=s.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=n.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return l.create({ciphertext:t,salt:i})}},e.SerializableCipher=i.extend({cfg:i.extend({format:h}),encrypt:function(t,e,i,n){n=this.cfg.extend(n);var r=t.createEncryptor(i,n);return e=r.finalize(e),r=r.cfg,l.create({ciphertext:e,key:i,iv:r.iv,algorithm:t,mode:r.mode,padding:r.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(i,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),d=(d.kdf={}).OpenSSL={execute:function(t,e,i,r){return r||(r=n.random(8)),t=o.create({keySize:e+i}).compute(t,r),i=n.create(t.words.slice(e),4*i),t.sigBytes=4*e,l.create({key:t,iv:i,salt:r})}},g=e.PasswordBasedCipher=f.extend({cfg:f.cfg.extend({kdf:d}),encrypt:function(t,e,i,n){return i=(n=this.cfg.extend(n)).kdf.execute(i,t.keySize,t.ivSize),n.iv=i.iv,(t=f.encrypt.call(this,t,e,i.key,n)).mixIn(i),t},decrypt:function(t,e,i,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),i=n.kdf.execute(i,t.keySize,t.ivSize,e.salt),n.iv=i.iv,f.decrypt.call(this,t,e,i.key,n)}})}(),function(){for(var t=y,e=t.lib.BlockCipher,i=t.algo,n=[],r=[],s=[],o=[],a=[],h=[],u=[],c=[],l=[],f=[],d=[],g=0;256>g;g++)d[g]=128>g?g<<1:g<<1^283;var p=0,v=0;for(g=0;256>g;g++){var m=(m=v^v<<1^v<<2^v<<3^v<<4)>>>8^255&m^99;n[p]=m,r[m]=p;var S=d[p],F=d[S],w=d[F],E=257*d[m]^16843008*m;s[p]=E<<24|E>>>8,o[p]=E<<16|E>>>16,a[p]=E<<8|E>>>24,h[p]=E,E=16843009*w^65537*F^257*S^16843008*p,u[m]=E<<24|E>>>8,c[m]=E<<16|E>>>16,l[m]=E<<8|E>>>24,f[m]=E,p?(p=S^d[d[d[w^S]]],v^=d[d[v]]):p=v=1}var x=[0,1,2,4,8,16,32,64,128,27,54];i=i.AES=e.extend({_doReset:function(){for(var t=(i=this._key).words,e=i.sigBytes/4,i=4*((this._nRounds=e+6)+1),r=this._keySchedule=[],s=0;s>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o]):(o=n[(o=o<<8|o>>>24)>>>24]<<24|n[o>>>16&255]<<16|n[o>>>8&255]<<8|n[255&o],o^=x[s/e|0]<<24),r[s]=r[s-e]^o}for(t=this._invKeySchedule=[],e=0;ee||4>=s?o:u[n[o>>>24]]^c[n[o>>>16&255]]^l[n[o>>>8&255]]^f[n[255&o]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,o,a,h,n)},decryptBlock:function(t,e){var i=t[e+1];t[e+1]=t[e+3],t[e+3]=i,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,r),i=t[e+1],t[e+1]=t[e+3],t[e+3]=i},_doCryptBlock:function(t,e,i,n,r,s,o,a){for(var h=this._nRounds,u=t[e]^i[0],c=t[e+1]^i[1],l=t[e+2]^i[2],f=t[e+3]^i[3],d=4,g=1;g>>24]^r[c>>>16&255]^s[l>>>8&255]^o[255&f]^i[d++],y=n[c>>>24]^r[l>>>16&255]^s[f>>>8&255]^o[255&u]^i[d++],v=n[l>>>24]^r[f>>>16&255]^s[u>>>8&255]^o[255&c]^i[d++];f=n[f>>>24]^r[u>>>16&255]^s[c>>>8&255]^o[255&l]^i[d++],u=p,c=y,l=v}p=(a[u>>>24]<<24|a[c>>>16&255]<<16|a[l>>>8&255]<<8|a[255&f])^i[d++],y=(a[c>>>24]<<24|a[l>>>16&255]<<16|a[f>>>8&255]<<8|a[255&u])^i[d++],v=(a[l>>>24]<<24|a[f>>>16&255]<<16|a[u>>>8&255]<<8|a[255&c])^i[d++],f=(a[f>>>24]<<24|a[u>>>16&255]<<16|a[c>>>8&255]<<8|a[255&l])^i[d++],t[e]=p,t[e+1]=y,t[e+2]=v,t[e+3]=f},keySize:8});t.AES=e._createHelper(i)}(),function(){function t(t,e){var i=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=i,this._lBlock^=i<>>t^this._lBlock)&e;this._lBlock^=i,this._rBlock^=i<i;i++){var n=o[i]-1;e[i]=t[n>>>5]>>>31-n%32&1}for(t=this._subKeys=[],n=0;16>n;n++){var r=t[n]=[],s=h[n];for(i=0;24>i;i++)r[i/6|0]|=e[(a[i]-1+s)%28]<<31-i%6,r[4+(i/6|0)]|=e[28+(a[i+24]-1+s)%28]<<31-i%6;for(r[0]=r[0]<<1|r[0]>>>31,i=1;7>i;i++)r[i]>>>=4*(i-1)+3;r[7]=r[7]<<5|r[7]>>>27}for(e=this._invSubKeys=[],i=0;16>i;i++)e[i]=t[15-i]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(i,n,r){this._lBlock=i[n],this._rBlock=i[n+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var o=r[s],a=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^o[f])&c[f])>>>0];this._lBlock=h,this._rBlock=a^l}r=this._lBlock,this._lBlock=this._rBlock,this._rBlock=r,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),i[n]=this._lBlock,i[n+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});i.DES=r._createHelper(l),s=s.TripleDES=r.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(n.create(t.slice(0,2))),this._des2=l.createEncryptor(n.create(t.slice(2,4))),this._des3=l.createEncryptor(n.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),i.TripleDES=r._createHelper(s)}(),function(){var t=y,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,i=t.sigBytes,n=this._map;t.clamp(),t=[];for(var r=0;r>>2]>>>24-r%4*8&255)<<16|(e[r+1>>>2]>>>24-(r+1)%4*8&255)<<8|e[r+2>>>2]>>>24-(r+2)%4*8&255,o=0;4>o&&r+.75*o>>6*(3-o)&63));if(e=n.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var i=t.length,n=this._map;(r=n.charAt(64))&&(-1!=(r=t.indexOf(r))&&(i=r));for(var r=[],s=0,o=0;o>>6-o%4*2;r[s>>>2]|=(a|h)<<24-s%4*8,s++}return e.create(r,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,i,n,r,s,o){return((t=t+(e&i|~e&n)+r+o)<>>32-s)+e}function i(t,e,i,n,r,s,o){return((t=t+(e&n|i&~n)+r+o)<>>32-s)+e}function n(t,e,i,n,r,s,o){return((t=t+(e^i^n)+r+o)<>>32-s)+e}function r(t,e,i,n,r,s,o){return((t=t+(i^(e|~n))+r+o)<>>32-s)+e}for(var s=y,o=(h=s.lib).WordArray,a=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=a.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var o=0;16>o;o++){var a=t[h=s+o];t[h]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}o=this._hash.words;var h=t[s+0],c=(a=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],d=t[s+5],g=t[s+6],p=t[s+7],y=t[s+8],v=t[s+9],m=t[s+10],S=t[s+11],F=t[s+12],w=t[s+13],E=t[s+14],x=t[s+15],b=e(b=o[0],C=o[1],I=o[2],A=o[3],h,7,u[0]),A=e(A,b,C,I,a,12,u[1]),I=e(I,A,b,C,c,17,u[2]),C=e(C,I,A,b,l,22,u[3]);b=e(b,C,I,A,f,7,u[4]),A=e(A,b,C,I,d,12,u[5]),I=e(I,A,b,C,g,17,u[6]),C=e(C,I,A,b,p,22,u[7]),b=e(b,C,I,A,y,7,u[8]),A=e(A,b,C,I,v,12,u[9]),I=e(I,A,b,C,m,17,u[10]),C=e(C,I,A,b,S,22,u[11]),b=e(b,C,I,A,F,7,u[12]),A=e(A,b,C,I,w,12,u[13]),I=e(I,A,b,C,E,17,u[14]),b=i(b,C=e(C,I,A,b,x,22,u[15]),I,A,a,5,u[16]),A=i(A,b,C,I,g,9,u[17]),I=i(I,A,b,C,S,14,u[18]),C=i(C,I,A,b,h,20,u[19]),b=i(b,C,I,A,d,5,u[20]),A=i(A,b,C,I,m,9,u[21]),I=i(I,A,b,C,x,14,u[22]),C=i(C,I,A,b,f,20,u[23]),b=i(b,C,I,A,v,5,u[24]),A=i(A,b,C,I,E,9,u[25]),I=i(I,A,b,C,l,14,u[26]),C=i(C,I,A,b,y,20,u[27]),b=i(b,C,I,A,w,5,u[28]),A=i(A,b,C,I,c,9,u[29]),I=i(I,A,b,C,p,14,u[30]),b=n(b,C=i(C,I,A,b,F,20,u[31]),I,A,d,4,u[32]),A=n(A,b,C,I,y,11,u[33]),I=n(I,A,b,C,S,16,u[34]),C=n(C,I,A,b,E,23,u[35]),b=n(b,C,I,A,a,4,u[36]),A=n(A,b,C,I,f,11,u[37]),I=n(I,A,b,C,p,16,u[38]),C=n(C,I,A,b,m,23,u[39]),b=n(b,C,I,A,w,4,u[40]),A=n(A,b,C,I,h,11,u[41]),I=n(I,A,b,C,l,16,u[42]),C=n(C,I,A,b,g,23,u[43]),b=n(b,C,I,A,v,4,u[44]),A=n(A,b,C,I,F,11,u[45]),I=n(I,A,b,C,x,16,u[46]),b=r(b,C=n(C,I,A,b,c,23,u[47]),I,A,h,6,u[48]),A=r(A,b,C,I,p,10,u[49]),I=r(I,A,b,C,E,15,u[50]),C=r(C,I,A,b,d,21,u[51]),b=r(b,C,I,A,F,6,u[52]),A=r(A,b,C,I,l,10,u[53]),I=r(I,A,b,C,m,15,u[54]),C=r(C,I,A,b,a,21,u[55]),b=r(b,C,I,A,y,6,u[56]),A=r(A,b,C,I,x,10,u[57]),I=r(I,A,b,C,g,15,u[58]),C=r(C,I,A,b,w,21,u[59]),b=r(b,C,I,A,f,6,u[60]),A=r(A,b,C,I,S,10,u[61]),I=r(I,A,b,C,c,15,u[62]),C=r(C,I,A,b,v,21,u[63]);o[0]=o[0]+b|0,o[1]=o[1]+C|0,o[2]=o[2]+I|0,o[3]=o[3]+A|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;i[r>>>5]|=128<<24-r%32;var s=t.floor(n/4294967296);for(i[15+(r+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),i[14+(r+64>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e.sigBytes=4*(i.length+1),this._process(),i=(e=this._hash).words,n=0;4>n;n++)r=i[n],i[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8);return e},clone:function(){var t=a.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=a._createHelper(h),s.HmacMD5=a._createHmacHelper(h)}(Math),function(){var t=y,e=(r=t.lib).WordArray,i=r.Hasher,n=[],r=t.algo.SHA1=i.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=this._hash.words,r=i[0],s=i[1],o=i[2],a=i[3],h=i[4],u=0;80>u;u++){if(16>u)n[u]=0|t[e+u];else{var c=n[u-3]^n[u-8]^n[u-14]^n[u-16];n[u]=c<<1|c>>>31}c=(r<<5|r>>>27)+h+n[u],c=20>u?c+(1518500249+(s&o|~s&a)):40>u?c+(1859775393+(s^o^a)):60>u?c+((s&o|s&a|o&a)-1894007588):c+((s^o^a)-899497514),h=a,a=o,o=s<<30|s>>>2,s=r,r=c}i[0]=i[0]+r|0,i[1]=i[1]+s|0,i[2]=i[2]+o|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=Math.floor(i/4294967296),e[15+(n+64>>>9<<4)]=i,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.SHA1=i._createHelper(r),t.HmacSHA1=i._createHmacHelper(r)}(),function(t){for(var e=y,i=(r=e.lib).WordArray,n=r.Hasher,r=e.algo,s=[],o=[],a=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=a(t.pow(h,.5))),o[u]=a(t.pow(h,1/3)),u++),h++}var d=[];r=r.SHA256=n.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(t,e){for(var i=this._hash.words,n=i[0],r=i[1],s=i[2],a=i[3],h=i[4],u=i[5],c=i[6],l=i[7],f=0;64>f;f++){if(16>f)d[f]=0|t[e+f];else{var g=d[f-15],p=d[f-2];d[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+d[f-7]+((p<<15|p>>>17)^(p<<13|p>>>19)^p>>>10)+d[f-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+o[f]+d[f],p=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&r^n&s^r&s),l=c,c=u,u=h,h=a+g|0,a=s,s=r,r=n,n=g+p|0}i[0]=i[0]+n|0,i[1]=i[1]+r|0,i[2]=i[2]+s|0,i[3]=i[3]+a|0,i[4]=i[4]+h|0,i[5]=i[5]+u|0,i[6]=i[6]+c|0,i[7]=i[7]+l|0},_doFinalize:function(){var e=this._data,i=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return i[r>>>5]|=128<<24-r%32,i[14+(r+64>>>9<<4)]=t.floor(n/4294967296),i[15+(r+64>>>9<<4)]=n,e.sigBytes=4*i.length,this._process(),this._hash},clone:function(){var t=n.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=n._createHelper(r),e.HmacSHA256=n._createHmacHelper(r)}(Math),function(){var t=y,e=t.lib.WordArray,i=(n=t.algo).SHA256,n=n.SHA224=i.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=i._createHelper(n),t.HmacSHA224=i._createHmacHelper(n)}(),function(){function t(){return n.create.apply(n,arguments)}for(var e=y,i=e.lib.Hasher,n=(s=e.x64).Word,r=s.WordArray,s=e.algo,o=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],a=[],h=0;80>h;h++)a[h]=t();s=s.SHA512=i.extend({_doReset:function(){this._hash=new r.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var i=(l=this._hash.words)[0],n=l[1],r=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=i.high,d=i.low,g=n.high,p=n.low,y=r.high,v=r.low,m=s.high,S=s.low,F=h.high,w=h.low,E=u.high,x=u.low,b=c.high,A=c.low,I=l.high,C=l.low,D=f,T=d,P=g,R=p,H=y,N=v,B=m,O=S,j=F,V=w,L=E,_=x,K=b,k=A,M=I,U=C,q=0;80>q;q++){var z=a[q];if(16>q)var G=z.high=0|t[e+2*q],Y=z.low=0|t[e+2*q+1];else{G=((Y=(G=a[q-15]).high)>>>1|(J=G.low)<<31)^(Y>>>8|J<<24)^Y>>>7;var J=(J>>>1|Y<<31)^(J>>>8|Y<<24)^(J>>>7|Y<<25),W=((Y=(W=a[q-2]).high)>>>19|(X=W.low)<<13)^(Y<<3|X>>>29)^Y>>>6,X=(X>>>19|Y<<13)^(X<<3|Y>>>29)^(X>>>6|Y<<26),Z=(Y=a[q-7]).high,$=(Q=a[q-16]).high,Q=Q.low;G=(G=(G=G+Z+((Y=J+Y.low)>>>0>>0?1:0))+W+((Y=Y+X)>>>0>>0?1:0))+$+((Y=Y+Q)>>>0>>0?1:0);z.high=G,z.low=Y}Z=j&L^~j&K,Q=V&_^~V&k,z=D&P^D&H^P&H;var tt=T&R^T&N^R&N,et=(J=(D>>>28|T<<4)^(D<<30|T>>>2)^(D<<25|T>>>7),W=(T>>>28|D<<4)^(T<<30|D>>>2)^(T<<25|D>>>7),(X=o[q]).high),it=X.low;$=M+((j>>>14|V<<18)^(j>>>18|V<<14)^(j<<23|V>>>9))+((X=U+((V>>>14|j<<18)^(V>>>18|j<<14)^(V<<23|j>>>9)))>>>0>>0?1:0),M=K,U=k,K=L,k=_,L=j,_=V,j=B+($=($=($=$+Z+((X=X+Q)>>>0>>0?1:0))+et+((X=X+it)>>>0>>0?1:0))+G+((X=X+Y)>>>0>>0?1:0))+((V=O+X|0)>>>0>>0?1:0)|0,B=H,O=N,H=P,N=R,P=D,R=T,D=$+(z=J+z+((Y=W+tt)>>>0>>0?1:0))+((T=X+Y|0)>>>0>>0?1:0)|0}d=i.low=d+T,i.high=f+D+(d>>>0>>0?1:0),p=n.low=p+R,n.high=g+P+(p>>>0>>0?1:0),v=r.low=v+N,r.high=y+H+(v>>>0>>0?1:0),S=s.low=S+O,s.high=m+B+(S>>>0>>0?1:0),w=h.low=w+V,h.high=F+j+(w>>>0>>0?1:0),x=u.low=x+_,u.high=E+L+(x>>>0<_>>>0?1:0),A=c.low=A+k,c.high=b+K+(A>>>0>>0?1:0),C=l.low=C+U,l.high=I+M+(C>>>0>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;return e[n>>>5]|=128<<24-n%32,e[30+(n+128>>>10<<5)]=Math.floor(i/4294967296),e[31+(n+128>>>10<<5)]=i,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=i._createHelper(s),e.HmacSHA512=i._createHmacHelper(s)}(),function(){var t=y,e=(r=t.x64).Word,i=r.WordArray,n=(r=t.algo).SHA512,r=r.SHA384=n.extend({_doReset:function(){this._hash=new i.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=n._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=n._createHelper(r),t.HmacSHA384=n._createHmacHelper(r)}(),function(){var t=y,e=(n=t.lib).WordArray,i=n.Hasher,n=t.algo,r=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),o=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),a=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);n=n.RIPEMD160=i.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var i=0;16>i;i++){var n=t[F=e+i];t[F]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var c,l,f,d,g,p,y,v,m,S,F=this._hash.words,w=(n=h.words,u.words),E=r.words,x=s.words,b=o.words,A=a.words;p=c=F[0],y=l=F[1],v=f=F[2],m=d=F[3],S=g=F[4];var I;for(i=0;80>i;i+=1)I=c+t[e+E[i]]|0,I=16>i?I+((l^f^d)+n[0]):32>i?I+((l&f|~l&d)+n[1]):48>i?I+(((l|~f)^d)+n[2]):64>i?I+((l&d|f&~d)+n[3]):I+((l^(f|~d))+n[4]),I=(I=(I|=0)<>>32-b[i])+g|0,c=g,g=d,d=f<<10|f>>>22,f=l,l=I,I=p+t[e+x[i]]|0,I=16>i?I+((y^(v|~m))+w[0]):32>i?I+((y&m|v&~m)+w[1]):48>i?I+(((y|~v)^m)+w[2]):64>i?I+((y&v|~y&m)+w[3]):I+((y^v^m)+w[4]),I=(I=(I|=0)<>>32-A[i])+S|0,p=S,S=m,m=v<<10|v>>>22,v=y,y=I;I=F[1]+f+m|0,F[1]=F[2]+d+S|0,F[2]=F[3]+g+p|0,F[3]=F[4]+c+y|0,F[4]=F[0]+l+v|0,F[0]=I},_doFinalize:function(){var t=this._data,e=t.words,i=8*this._nDataBytes,n=8*t.sigBytes;for(e[n>>>5]|=128<<24-n%32,e[14+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,i=0;5>i;i++)n=e[i],e[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return t},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(n),t.HmacRIPEMD160=i._createHmacHelper(n)}(Math),function(){var t=y,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,i){t=this._hasher=new t.init,"string"==typeof i&&(i=e.parse(i));var n=t.blockSize,r=4*n;i.sigBytes>r&&(i=t.finalize(i)),i.clamp();for(var s=this._oKey=i.clone(),o=this._iKey=i.clone(),a=s.words,h=o.words,u=0;u>6)+m.charAt(63&i);if(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),n+=m.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),n+=m.charAt(i>>2)+m.charAt((3&i)<<4)),S)for(;(3&n.length)>0;)n+=S;return n}function w(t){var e,i,n,r="",s=0;for(e=0;e>2),i=3&n,s=1):1==s?(r+=T(i<<2|n>>4),i=15&n,s=2):2==s?(r+=T(i),r+=T(n>>2),i=3&n,s=3):(r+=T(i<<2|n>>4),r+=T(15&n),s=0));return 1==s&&(r+=T(i<<2)),r}function E(t){var e,i=w(t),n=new Array;for(e=0;2*e>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;r=((h=o*h+((32767&c)<<15)+i[n]+(1073741823&r))>>>30)+(c>>>15)+a*u+(r>>>30),i[n++]=1073741823&h}return r},v=30):"Netscape"!=i.appName?(x.prototype.am=function(t,e,i,n,r,s){for(;--s>=0;){var o=e*this[t++]+i[n]+r;r=Math.floor(o/67108864),i[n++]=67108863&o}return r},v=26):(x.prototype.am=function(t,e,i,n,r,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;r=((h=o*h+((16383&c)<<14)+i[n]+r)>>28)+(c>>14)+a*u,i[n++]=268435455&h}return r},v=28),x.prototype.DB=v,x.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}function N(t){this.m=t}function B(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function K(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function k(){}function M(t){return t}function U(t){this.r2=b(),this.q3=b(),x.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}N.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},N.prototype.revert=function(t){return t},N.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},N.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},N.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},B.prototype.convert=function(t){var e=b();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(x.ZERO)>0&&this.m.subTo(e,e),e},B.prototype.revert=function(t){var e=b();return t.copyTo(e),this.reduce(e),e},B.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,n,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},B.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},B.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},x.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},x.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},x.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,r=!1,s=0;--n>=0;){var o=8==i?255&t[n]:P(t,n);o<0?"-"==t.charAt(n)&&(r=!0):(r=!1,0==s?this[this.t++]=o:s+i>this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t},x.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},x.prototype.drShiftTo=function(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>r|a,a=(this[i]&s)<=0;--i)e[i]=0;e[o]=a,e.t=this.t+o+1,e.s=this.s,e.clamp()},x.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var n=t%this.DB,r=this.DB-n,s=(1<>n;for(var o=i+1;o>n;n>0&&(e[this.t-i-1]|=(this.s&s)<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e[i++]=this.DV+n:n>0&&(e[i++]=n),e.t=i,e.clamp()},x.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),r=i.t;for(e.t=r+n.t;--r>=0;)e[r]=0;for(r=0;r=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},x.prototype.divRemTo=function(t,e,i){var n=t.abs();if(!(n.t<=0)){var r=this.abs();if(r.t0?(n.lShiftTo(h,s),r.lShiftTo(h,i)):(n.copyTo(s),r.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<1?s[u-2]>>this.F2:0),f=this.FV/l,d=(1<=0&&(i[i.t++]=1,i.subTo(v,i)),x.ONE.dlShiftTo(u,v),v.subTo(s,s);s.t=0;){var m=i[--p]==c?this.DM:Math.floor(i[p]*f+(i[p-1]+g)*d);if((i[p]+=s.am(0,m,i,y,0,u))0&&i.rShiftTo(h,i),o<0&&x.ZERO.subTo(i,i)}}},x.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},x.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},x.prototype.exp=function(t,e){if(t>4294967295||t<1)return x.ONE;var i=b(),n=b(),r=e.convert(this),s=H(t)-1;for(r.copyTo(i);--s>=0;)if(e.sqrTo(i,n),(t&1<0)e.mulTo(n,r,i);else{var o=i;i=n,n=o}return e.revert(i)},x.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,n=(1<0)for(a>a)>0&&(r=!0,s=T(i));o>=0;)a>(a+=this.DB-e)):(i=this[o]>>(a-=e)&n,a<=0&&(a+=this.DB,--o)),i>0&&(r=!0),r&&(s+=T(i));return r?s:"0"},x.prototype.negate=function(){var t=b();return x.ZERO.subTo(this,t),t},x.prototype.abs=function(){return this.s<0?this.negate():this},x.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},x.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+H(this[this.t-1]^this.s&this.DM)},x.prototype.mod=function(t){var e=b();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(x.ZERO)>0&&t.subTo(e,e),e},x.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new N(e):new B(e),this.exp(t,i)},x.ZERO=R(0),x.ONE=R(1),k.prototype.convert=M,k.prototype.revert=M,k.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},k.prototype.sqrTo=function(t,e){t.squareTo(e)},U.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=b();return t.copyTo(e),this.reduce(e),e},U.prototype.revert=function(t){return t},U.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},U.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},U.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var q=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],z=(1<<26)/q[q.length-1]; +/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ + */ +function G(){this.i=0,this.j=0,this.S=new Array}x.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},x.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),n=R(i),r=b(),s=b(),o="";for(this.divRemTo(n,r,s);r.signum()>0;)o=(i+s.intValue()).toString(t).substr(1)+o,r.divRemTo(n,r,s);return s.intValue().toString(t)+o},x.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),r=!1,s=0,o=0,a=0;a=i&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),r&&x.ZERO.subTo(this,this)},x.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(x.ONE.shiftLeft(t-1),j,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(x.ONE.shiftLeft(t-1),this);else{var n=new Array,r=7&t;n.length=1+(t>>3),e.nextBytes(n),r>0?n[0]&=(1<>=this.DB;if(t.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e[i++]=n:n<-1&&(e[i++]=this.DV+n),e.t=i,e.clamp()},x.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},x.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},x.prototype.multiplyLowerTo=function(t,e,i){var n,r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r=0;)i[n]=0;for(n=Math.max(e-this.t,0);n0)if(0==e)i=this[0]%t;else for(var n=this.t-1;n>=0;--n)i=(e*i+this[n])%t;return i},x.prototype.millerRabin=function(t){var e=this.subtract(x.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var n=e.shiftRight(i);(t=t+1>>1)>q.length&&(t=q.length);for(var r=b(),s=0;s>24},x.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},x.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},x.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var i,n=this.DB-t*this.DB%8,r=0;if(t-- >0)for(n>n)!=(this.s&this.DM)>>n&&(e[r++]=i|this.s<=0;)n<8?(i=(this[t]&(1<>(n+=this.DB-8)):(i=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(e[r++]=i);return e},x.prototype.equals=function(t){return 0==this.compareTo(t)},x.prototype.min=function(t){return this.compareTo(t)<0?this:t},x.prototype.max=function(t){return this.compareTo(t)>0?this:t},x.prototype.and=function(t){var e=b();return this.bitwiseTo(t,O,e),e},x.prototype.or=function(t){var e=b();return this.bitwiseTo(t,j,e),e},x.prototype.xor=function(t){var e=b();return this.bitwiseTo(t,V,e),e},x.prototype.andNot=function(t){var e=b();return this.bitwiseTo(t,L,e),e},x.prototype.not=function(){for(var t=b(),e=0;e=this.t?0!=this.s:0!=(this[e]&1<1){var c=b();for(n.sqrTo(o[1],c);a<=u;)o[a]=b(),n.mulTo(c,o[a-2],o[a]),a+=2}var l,f,d=t.t-1,g=!0,p=b();for(r=H(t[d])-1;d>=0;){for(r>=h?l=t[d]>>r-h&u:(l=(t[d]&(1<0&&(l|=t[d-1]>>this.DB+r-h)),a=i;0==(1&l);)l>>=1,--a;if((r-=a)<0&&(r+=this.DB,--d),g)o[l].copyTo(s),g=!1;else{for(;a>1;)n.sqrTo(s,p),n.sqrTo(p,s),a-=2;a>0?n.sqrTo(s,p):(f=s,s=p,p=f),n.mulTo(p,o[l],s)}for(;d>=0&&0==(t[d]&1<=0?(i.subTo(n,i),e&&r.subTo(o,r),s.subTo(a,s)):(n.subTo(i,n),e&&o.subTo(r,o),a.subTo(s,a))}return 0!=n.compareTo(x.ONE)?x.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},x.prototype.pow=function(t){return this.exp(t,new k)},x.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var n=e;e=i,i=n}var r=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(r0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(r=e.getLowestSetBit())>0&&e.rShiftTo(r,e),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},x.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=q[q.length-1]){for(e=0;e>8&255,J[W++]^=t>>16&255,J[W++]^=t>>24&255,W>=X&&(W-=X)}((new Date).getTime())}if(null==J){var $;if(J=new Array,W=0,void 0!==n&&(void 0!==n.crypto||void 0!==n.msCrypto)){var Q=n.crypto||n.msCrypto;if(Q.getRandomValues){var tt=new Uint8Array(32);for(Q.getRandomValues(tt),$=0;$<32;++$)J[W++]=tt[$]}else if("Netscape"==i.appName&&i.appVersion<"5"){var et=n.crypto.random(32);for($=0;$>>8,J[W++]=255&$;W=0,Z()}function it(){if(null==Y){for(Z(),(Y=new G).init(J),W=0;W>24,(16711680&r)>>16,(65280&r)>>8,255&r]))),r+=1;return n}function ot(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function at(t,e,i){for(var n="",r=0;n.length>24,(16711680&r)>>16,(65280&r)>>8,255&r])),r+=1;return n} +/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ + */ +function ht(t,e){this.x=e,this.q=t}function ut(t,e,i,n){this.curve=t,this.x=e,this.y=i,this.z=null==n?x.ONE:n,this.zinv=null}function ct(t,e,i){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(i),this.infinity=new ut(this,null,null)}nt.prototype.nextBytes=function(t){var e;for(e=0;e0&&e.length>0))throw"Invalid RSA public key";this.n=rt(t,16),this.e=parseInt(e,16)}},ot.prototype.encrypt=function(t){var e=function(t,e){if(e=0&&e>0;){var r=t.charCodeAt(n--);r<128?i[--e]=r:r>127&&r<2048?(i[--e]=63&r|128,i[--e]=r>>6|192):(i[--e]=63&r|128,i[--e]=r>>6&63|128,i[--e]=r>>12|224)}i[--e]=0;for(var s=new nt,o=new Array;e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new x(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var n=i.toString(16);return 0==(1&n.length)?n:"0"+n},ot.prototype.encryptOAEP=function(t,e,i){var n=function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;if(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t.length+2*n+2>e)throw"Message too long for RSA";var a,h="";for(a=0;a>3,e,i);if(null==n)return null;var r=this.doPublic(n);if(null==r)return null;var s=r.toString(16);return 0==(1&s.length)?s:"0"+s},ot.prototype.type="RSA",ot.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},ot.prototype.setPrivate=function(t,e,i){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=i;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16)}},ot.prototype.setPrivateEx=function(t,e,i,n,r,s,o,a){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=rt(t,16),this.e=parseInt(e,16),this.d=rt(i,16),this.p=rt(n,16),this.q=rt(r,16),this.dmp1=rt(s,16),this.dmq1=rt(o,16),this.coeff=rt(a,16)},ot.prototype.generate=function(t,e){var i=new nt,n=t>>1;this.e=parseInt(e,16);for(var r=new x(e,16);;){for(;this.p=new x(t-n,1,i),0!=this.p.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.p.isProbablePrime(10););for(;this.q=new x(n,1,i),0!=this.q.subtract(x.ONE).gcd(r).compareTo(x.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(x.ONE),a=this.q.subtract(x.ONE),h=o.multiply(a);if(0==h.gcd(r).compareTo(x.ONE)){this.n=this.p.multiply(this.q),this.d=r.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}this.isPrivate=!0},ot.prototype.decrypt=function(t){var e=rt(t,16),i=this.doPrivate(e);return null==i?null: +/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ + */ +function(t,e){for(var i=t.toByteArray(),n=0;n=i.length)return null;for(var r="";++n191&&s<224?(r+=String.fromCharCode((31&s)<<6|63&i[n+1]),++n):(r+=String.fromCharCode((15&s)<<12|(63&i[n+1])<<6|63&i[n+2]),n+=2)}return r}(i,this.n.bitLength()+7>>3)},ot.prototype.decryptOAEP=function(t,e,i){var n=rt(t,16),r=this.doPrivate(n);return null==r?null:function(t,e,i,n){var r=ft.crypto.MessageDigest,s=ft.crypto.Util,o=null;for(i||(i="sha1"),"string"==typeof i&&(o=r.getCanonicalAlgName(i),n=r.getHashLength(o),i=function(t){return It(s.hashHex(Ct(t),o))}),t=t.toByteArray(),a=0;a>3,e,i)},ht.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},ht.prototype.toBigInteger=function(){return this.x},ht.prototype.negate=function(){return new ht(this.q,this.x.negate().mod(this.q))},ht.prototype.add=function(t){return new ht(this.q,this.x.add(t.toBigInteger()).mod(this.q))},ht.prototype.subtract=function(t){return new ht(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},ht.prototype.multiply=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},ht.prototype.square=function(){return new ht(this.q,this.x.square().mod(this.q))},ht.prototype.divide=function(t){return new ht(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},ut.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ut.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO))},ut.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(x.ZERO)&&!this.y.toBigInteger().equals(x.ZERO)},ut.prototype.negate=function(){return new ut(this.curve,this.x,this.y.negate(),this.z)},ut.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),i=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(x.ZERO.equals(i))return x.ZERO.equals(e)?this.twice():this.curve.getInfinity();var n=new x("3"),r=this.x.toBigInteger(),s=this.y.toBigInteger(),o=(t.x.toBigInteger(),t.y.toBigInteger(),i.square()),a=o.multiply(i),h=r.multiply(o),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(a).multiply(i).mod(this.curve.q),l=h.multiply(n).multiply(e).subtract(s.multiply(a)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(a)).mod(this.curve.q),f=a.multiply(this.z).multiply(t.z).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},ut.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new x("3"),e=this.x.toBigInteger(),i=this.y.toBigInteger(),n=i.multiply(this.z),r=n.multiply(i).mod(this.curve.q),s=this.curve.a.toBigInteger(),o=e.square().multiply(t);x.ZERO.equals(s)||(o=o.add(this.z.square().multiply(s)));var a=(o=o.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(r)).shiftLeft(1).multiply(n).mod(this.curve.q),h=o.multiply(t).multiply(e).subtract(r.shiftLeft(1)).shiftLeft(2).multiply(r).subtract(o.square().multiply(o)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new ut(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(h),u)},ut.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add(o?this:r))}return s},ut.prototype.multiplyTwo=function(t,e,i){var n;n=t.bitLength()>i.bitLength()?t.bitLength()-1:i.bitLength()-1;for(var r=this.curve.getInfinity(),s=this.add(e);n>=0;)r=r.twice(),t.testBit(n)?r=i.testBit(n)?r.add(s):r.add(this):i.testBit(n)&&(r=r.add(e)),--n;return r},ct.prototype.getQ=function(){return this.q},ct.prototype.getA=function(){return this.a},ct.prototype.getB=function(){return this.b},ct.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},ct.prototype.getInfinity=function(){return this.infinity},ct.prototype.fromBigInteger=function(t){return new ht(this.q,t)},ct.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,i=t.substr(2,e),n=t.substr(e+2,e);return new ut(this,this.fromBigInteger(new x(i,16)),this.fromBigInteger(new x(n,16)));default:return null}}, +/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib + */ +ht.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ut.prototype.getEncoded=function(t){var e=function(t,e){var i=t.toByteArrayUnsigned();if(ei.length;)i.unshift(0);return i},i=this.getX().toBigInteger(),n=this.getY().toBigInteger(),r=e(i,32);return t?n.isEven()?r.unshift(2):r.unshift(3):(r.unshift(4),r=r.concat(e(n,32))),r},ut.decodeFrom=function(t,e){e[0];var i=e.length-1,n=e.slice(1,1+i/2),r=e.slice(1+i/2,1+i);n.unshift(0),r.unshift(0);var s=new x(n),o=new x(r);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.decodeFromHex=function(t,e){e.substr(0,2);var i=e.length-2,n=e.substr(2,i/2),r=e.substr(2+i/2,i/2),s=new x(n,16),o=new x(r,16);return new ut(t,t.fromBigInteger(s),t.fromBigInteger(o))},ut.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),i=t.y.subtract(this.y).divide(e),n=i.square().subtract(this.x).subtract(t.x),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(x.valueOf(2)),e=this.curve.fromBigInteger(x.valueOf(3)),i=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),n=i.square().subtract(this.x.multiply(t)),r=i.multiply(this.x.subtract(n)).subtract(this.y);return new ut(this.curve,n,r)},ut.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,i=t,n=i.multiply(new x("3")),r=this.negate(),s=this;for(e=n.bitLength()-2;e>0;--e){s=s.twice();var o=n.testBit(e);o!=i.testBit(e)&&(s=s.add2D(o?this:r))}return s},ut.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),i=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),r=this.curve.getQ(),s=e.multiply(e).mod(r),o=t.multiply(t).multiply(t).add(i.multiply(t)).add(n).mod(r);return s.equals(o)},ut.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ut.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),i=this.getY().toBigInteger();if(e.compareTo(x.ONE)<0||e.compareTo(t.subtract(x.ONE))>0)throw new Error("x coordinate out of bounds");if(i.compareTo(x.ONE)<0||i.compareTo(t.subtract(x.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0}; +/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval + */ +var lt=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),i={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(t,e,n){return e?i[e]:String.fromCharCode(parseInt(n,16))}var r=new String(""),s=(Object,Array,Object.hasOwnProperty);return function(i,o){var a,h,u=i.match(t),c=u[0],l=!1;"{"===c?a={}:"["===c?a=[]:(a=[],l=!0);for(var f=[a],d=1-l,g=u.length;d=0;)delete i[n[h]]}return o.call(t,e,i)};a=y({"":a},"")}return a}}();void 0!==ft&&ft||(ft={}),void 0!==ft.asn1&&ft.asn1||(ft.asn1={}),ft.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var n="",r=0;r15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},ft.asn1.DERAbstractString=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=bt(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},r.lang.extend(ft.asn1.DERAbstractString,ft.asn1.ASN1Object),ft.asn1.DERAbstractTime=function(t){ft.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var n=this.zeroPadding,r=this.localDateToUTC(t),s=String(r.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+n(String(r.getMonth()+1),2)+n(String(r.getDate()),2)+n(String(r.getHours()),2)+n(String(r.getMinutes()),2)+n(String(r.getSeconds()),2);if(!0===i){var a=r.getMilliseconds();if(0!=a){var h=n(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=St(t)},this.setByDateValue=function(t,e,i,n,r,s){var o=new Date(Date.UTC(t,e-1,i,n,r,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},r.lang.extend(ft.asn1.DERAbstractTime,ft.asn1.ASN1Object),ft.asn1.DERAbstractStructured=function(t){ft.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},r.lang.extend(ft.asn1.DERAbstractStructured,ft.asn1.ASN1Object),ft.asn1.DERBoolean=function(){ft.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},r.lang.extend(ft.asn1.DERBoolean,ft.asn1.ASN1Object),ft.asn1.DERInteger=function(t){ft.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=ft.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},r.lang.extend(ft.asn1.DERInteger,ft.asn1.ASN1Object),ft.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ft.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}ft.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7r.length&&(r=n[i]);return(t=t.replace(r,"::")).slice(1,-1)}function _t(t){var e="malformed hex value";if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8!=t.length)return 32==t.length?Lt(t):t;try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}function Kt(t){for(var e=encodeURIComponent(t),i="",n=0;n"7"?"00"+t:t}function Mt(t){t=(t=(t=t.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return t.split(/,/).map((function(t,e,i){var n=parseInt(t);if(n<0||255=2*s)break;if(a>=200)break;n.push(h),o=h,a++}return n},pt.getNthChildIdx=function(t,e,i){return pt.getChildIdx(t,e)[i]},pt.getIdxbyList=function(t,e,i,n){var r,s,o=pt;if(0==i.length){if(void 0!==n&&t.substr(e,2)!==n)throw"checking tag doesn't match: "+t.substr(e,2)+"!="+n;return e}return r=i.shift(),s=o.getChildIdx(t,e),o.getIdxbyList(t,s[r],i,n)},pt.getTLVbyList=function(t,e,i,n){var r=pt,s=r.getIdxbyList(t,e,i);if(void 0===s)throw"can't find nthList object";if(void 0!==n&&t.substr(s,2)!=n)throw"checking tag doesn't match: "+t.substr(s,2)+"!="+n;return r.getTLV(t,s)},pt.getVbyList=function(t,e,i,n,r){var s,o,a=pt;if(void 0===(s=a.getIdxbyList(t,e,i,n)))throw"can't find nthList object";return o=a.getV(t,s),!0===r&&(o=o.substr(2)),o},pt.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},i=[],n=t.substr(0,2),r=parseInt(n,16);i[0]=new String(Math.floor(r/40)),i[1]=new String(r%40);for(var s=t.substr(2),o=[],a=0;a0&&(c=c+"."+h.join(".")),c},pt.dump=function(t,e,i,n){var r=pt,s=r.getV,o=r.dump,a=r.getChildIdx,h=t;t instanceof ft.asn1.ASN1Object&&(h=t.getEncodedHex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===i&&(i=0),void 0===n&&(n="");var c=e.ommit_long_octet;if("01"==h.substr(i,2))return"00"==(l=s(h,i))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==h.substr(i,2))return n+"INTEGER "+u(l=s(h,i),c)+"\n";if("03"==h.substr(i,2))return n+"BITSTRING "+u(l=s(h,i),c)+"\n";if("04"==h.substr(i,2)){var l=s(h,i);if(r.isASN1HEX(l)){var f=n+"OCTETSTRING, encapsulates\n";return f+=o(l,e,0,n+" ")}return n+"OCTETSTRING "+u(l,c)+"\n"}if("05"==h.substr(i,2))return n+"NULL\n";if("06"==h.substr(i,2)){var d=s(h,i),g=ft.asn1.ASN1Util.oidHexToInt(d),p=ft.asn1.x509.OID.oid2name(g),y=g.replace(/\./g," ");return""!=p?n+"ObjectIdentifier "+p+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0c"==h.substr(i,2))return n+"UTF8String '"+At(s(h,i))+"'\n";if("13"==h.substr(i,2))return n+"PrintableString '"+At(s(h,i))+"'\n";if("14"==h.substr(i,2))return n+"TeletexString '"+At(s(h,i))+"'\n";if("16"==h.substr(i,2))return n+"IA5String '"+At(s(h,i))+"'\n";if("17"==h.substr(i,2))return n+"UTCTime "+At(s(h,i))+"\n";if("18"==h.substr(i,2))return n+"GeneralizedTime "+At(s(h,i))+"\n";if("30"==h.substr(i,2)){if("3000"==h.substr(i,4))return n+"SEQUENCE {}\n";f=n+"SEQUENCE\n";var v=e;if((2==(F=a(h,i)).length||3==F.length)&&"06"==h.substr(F[0],2)&&"04"==h.substr(F[F.length-1],2)){p=r.oidname(s(h,F[0]));var m=JSON.parse(JSON.stringify(e));m.x509ExtName=p,v=m}for(var S=0;S0){var e=new i({array:this.extensionsArray}),n=new r({explicit:!0,tag:"a3",obj:e});this.asn1Array.push(n)}var s=new i({array:this.asn1Array});return this.hTLV=s.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertificate,ft.asn1.ASN1Object),ft.asn1.x509.Extension=function(t){ft.asn1.x509.Extension.superclass.constructor.call(this);var e=ft.asn1,i=e.DERObjectIdentifier,n=e.DEROctetString,r=(e.DERBitString,e.DERBoolean),s=e.DERSequence;this.getEncodedHex=function(){var t=new i({oid:this.oid}),e=new n({hex:this.getExtnValueHex()}),o=new Array;return o.push(t),this.critical&&o.push(new r),o.push(e),new s({array:o}).getEncodedHex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},r.lang.extend(ft.asn1.x509.Extension,ft.asn1.ASN1Object),ft.asn1.x509.Extension.appendByNameToArray=function(t,e,i){var n=t.toLowerCase(),r=ft.asn1.x509;if("basicconstraints"==n){var s=new r.BasicConstraints(e);i.push(s)}else if("keyusage"==n){s=new r.KeyUsage(e);i.push(s)}else if("crldistributionpoints"==n){s=new r.CRLDistributionPoints(e);i.push(s)}else if("extkeyusage"==n){s=new r.ExtKeyUsage(e);i.push(s)}else if("authoritykeyidentifier"==n){s=new r.AuthorityKeyIdentifier(e);i.push(s)}else if("authorityinfoaccess"==n){s=new r.AuthorityInfoAccess(e);i.push(s)}else if("subjectaltname"==n){s=new r.SubjectAltName(e);i.push(s)}else{if("issueraltname"!=n)throw"unsupported extension name: "+t;s=new r.IssuerAltName(e);i.push(s)}},ft.asn1.x509.KeyUsage=function(t){ft.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Jt.KEYUSAGE_NAME;if(this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.15",void 0!==t&&(void 0!==t.bin&&(this.asn1ExtnValue=new ft.asn1.DERBitString(t)),void 0!==t.names&&void 0!==t.names.length)){for(var i=t.names,n="000000000",r=0;r-1&&t.push(new ft.asn1.DERInteger({int:this.pathLen}));var e=new ft.asn1.DERSequence({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.getEncodedHex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},r.lang.extend(ft.asn1.x509.BasicConstraints,ft.asn1.x509.Extension),ft.asn1.x509.CRLDistributionPoints=function(t){ft.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ft.asn1,i=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()},this.setByDPArray=function(t){this.asn1ExtnValue=new e.DERSequence({array:t})},this.setByOneURI=function(t){var e=new i.GeneralNames([{uri:t}]),n=new i.DistributionPointName(e),r=new i.DistributionPoint({dpobj:n});this.setByDPArray([r])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},r.lang.extend(ft.asn1.x509.CRLDistributionPoints,ft.asn1.x509.Extension),ft.asn1.x509.ExtKeyUsage=function(t){ft.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=ft.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var i=0;i0){var t=new i({array:this.aRevokedCert});this.asn1Array.push(t)}var e=new i({array:this.asn1Array});return this.hTLV=e.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize=function(){this.asn1Version=null,this.asn1SignatureAlg=null,this.asn1Issuer=null,this.asn1ThisUpdate=null,this.asn1NextUpdate=null,this.aRevokedCert=new Array},this._initialize()},r.lang.extend(ft.asn1.x509.TBSCertList,ft.asn1.ASN1Object),ft.asn1.x509.CRLEntry=function(t){ft.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=ft.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},r.lang.extend(ft.asn1.x509.CRLEntry,ft.asn1.ASN1Object),ft.asn1.x509.X500Name=function(t){ft.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=new Array;var e=ft.asn1,i=e.x509,n=Ht;if(this.setByString=function(t){var e=t.split("/");e.shift();for(var n=[],r=0;r0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+","+s).replace(/\\,/g,",");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}return(n=n.map((function(t){return t.replace("/","\\/")}))).reverse(),"/"+n.join("/")},ft.asn1.x509.RDN=function(t){ft.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=new Array,this.addByString=function(t){this.asn1Array.push(new ft.asn1.x509.AttributeTypeAndValue({str:t}))},this.addByMultiValuedString=function(t){for(var e=ft.asn1.x509.RDN.parseString(t),i=0;i0;r++){var s=e.shift();if(!0===i){var o=(n.pop()+"+"+s).replace(/\\\+/g,"+");n.push(o),i=!1}else n.push(s);"\\"===s.substr(-1,1)&&(i=!0)}var a=!1,h=[];for(r=0;n.length>0;r++){s=n.shift();if(!0===a){var u=h.pop();if(s.match(/"$/)){o=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(o),a=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(a=!0)}return h},ft.asn1.x509.AttributeTypeAndValue=function(t){ft.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);var e=ft.asn1;this.setByString=function(t){var e=t.match(/^([^=]+)=(.+)$/);if(!e)throw"malformed attrTypeAndValueStr: "+t;this.setByAttrTypeAndValueStr(e[1],e[2])},this.setByAttrTypeAndValueStr=function(t,e){this.typeObj=ft.asn1.x509.OID.atype2obj(t);var i="utf8";"C"==t&&(i="prn"),this.valueObj=this.getValueObj(i,e)},this.getValueObj=function(t,i){if("utf8"==t)return new e.DERUTF8String({str:i});if("prn"==t)return new e.DERPrintableString({str:i});if("tel"==t)return new e.DERTeletexString({str:i});if("ia5"==t)return new e.DERIA5String({str:i});throw"unsupported directory string type: type="+t+" value="+i},this.getEncodedHex=function(){var t=new e.DERSequence({array:[this.typeObj,this.valueObj]});return this.TLV=t.getEncodedHex(),this.TLV},void 0!==t&&void 0!==t.str&&this.setByString(t.str)},r.lang.extend(ft.asn1.x509.AttributeTypeAndValue,ft.asn1.ASN1Object),ft.asn1.x509.SubjectPublicKeyInfo=function(t){ft.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ft,i=e.asn1,n=i.DERInteger,r=i.DERBitString,s=i.DERObjectIdentifier,o=i.DERSequence,a=i.ASN1Util.newObject,h=i.x509.AlgorithmIdentifier,u=e.crypto;u.ECDSA,u.DSA;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new o({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.getEncodedHex=function(){var t=this.getASN1Object();return this.hTLV=t.getEncodedHex(),this.hTLV},this.setPubKey=function(t){try{if(t instanceof ot){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).getEncodedHex();this.asn1AlgId=new h({name:"rsaEncryption"}),this.asn1SubjPKey=new r({hex:"00"+e})}}catch(t){}try{if(t instanceof ft.crypto.ECDSA){var i=new s({name:t.curveName});this.asn1AlgId=new h({name:"ecPublicKey",asn1params:i}),this.asn1SubjPKey=new r({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ft.crypto.DSA){i=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new h({name:"dsa",asn1params:i});var o=new n({bigint:t.y});this.asn1SubjPKey=new r({hex:"00"+o.getEncodedHex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},r.lang.extend(ft.asn1.x509.SubjectPublicKeyInfo,ft.asn1.ASN1Object),ft.asn1.x509.Time=function(t){ft.asn1.x509.Time.superclass.constructor.call(this);var e=ft.asn1,i=e.DERUTCTime,n=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.getEncodedHex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new i(this.timeParams):new n(this.timeParams):"utc"==this.type?new i:new n,this.TLV=t.getEncodedHex(),this.TLV},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},r.lang.extend(ft.asn1.x509.Time,ft.asn1.ASN1Object),ft.asn1.x509.AlgorithmIdentifier=function(t){ft.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ft.asn1;if(this.getEncodedHex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw"algorithm not specified";null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var t=[this.asn1Alg];null!==this.asn1Params&&t.push(this.asn1Params);var i=new e.DERSequence({array:t});return this.hTLV=i.getEncodedHex(),this.hTLV},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},r.lang.extend(ft.asn1.x509.AlgorithmIdentifier,ft.asn1.ASN1Object),ft.asn1.x509.GeneralName=function(t){ft.asn1.x509.GeneralName.superclass.constructor.call(this);var e={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},i=ft.asn1,n=(i.DERSequence,i.DEROctetString),r=i.DERIA5String,s=i.DERTaggedObject,o=i.ASN1Object,a=i.x509.X500Name,h=Ht;this.explicit=!1,this.setByParam=function(t){var i=null;if(void 0!==t){if(void 0!==t.rfc822&&(this.type="rfc822",i=new r({str:t[this.type]})),void 0!==t.dns&&(this.type="dns",i=new r({str:t[this.type]})),void 0!==t.uri&&(this.type="uri",i=new r({str:t[this.type]})),void 0!==t.dn&&(this.type="dn",this.explicit=!0,i=new a({str:t.dn})),void 0!==t.ldapdn&&(this.type="dn",this.explicit=!0,i=new a({ldapstr:t.ldapdn})),void 0!==t.certissuer){this.type="dn",this.explicit=!0;var u=null;if((l=t.certissuer).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certissuer param not cert";(f=new Jt).hex=u;var c=f.getIssuerHex();(i=new o).hTLV=c}if(void 0!==t.certsubj){this.type="dn",this.explicit=!0;var l,f;u=null;if((l=t.certsubj).match(/^[0-9A-Fa-f]+$/),-1!=l.indexOf("-----BEGIN ")&&(u=h(l)),null==u)throw"certsubj param not cert";(f=new Jt).hex=u;c=f.getSubjectHex();(i=new o).hTLV=c}if(void 0!==t.ip){this.type="ip",this.explicit=!1;var d,g=t.ip,p="malformed IP address";if(g.match(/^[0-9.]+[.][0-9.]+$/)){if(8!==(d=Mt("["+g.split(".").join(",")+"]")).length)throw p}else if(g.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/))d=Vt(g);else{if(!g.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw p;d=g}i=new n({hex:d})}if(null==this.type)throw"unsupported type in params="+t;this.asn1Obj=new s({explicit:this.explicit,tag:e[this.type],obj:i})}},this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()},void 0!==t&&this.setByParam(t)},r.lang.extend(ft.asn1.x509.GeneralName,ft.asn1.ASN1Object),ft.asn1.x509.GeneralNames=function(t){ft.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ft.asn1;this.setByParamArray=function(t){for(var i=0;i0&&(e=new n({obj:this.dUnsignedAttrs,tag:"a1",explicit:!1}));var r=[this.dCMSVersion,this.dSignerIdentifier,this.dDigestAlgorithm,t,this.dSigAlg,this.dSig];null!=e&&r.push(e);var o=new i.DERSequence({array:r});return this.hTLV=o.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.SignerInfo,ft.asn1.ASN1Object),ft.asn1.cms.EncapsulatedContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.dEContentType=new r({name:"data"}),this.dEContent=null,this.isDetached=!1,this.eContentValueHex=null,this.setContentType=function(t){t.match(/^[0-2][.][0-9.]+$/)?this.dEContentType=new r({oid:t}):this.dEContentType=new r({name:t})},this.setContentValue=function(t){void 0!==t&&("string"==typeof t.hex?this.eContentValueHex=t.hex:"string"==typeof t.str&&(this.eContentValueHex=bt(t.str)))},this.setContentValueHex=function(t){this.eContentValueHex=t},this.setContentValueStr=function(t){this.eContentValueHex=bt(t)},this.getEncodedHex=function(){if("string"!=typeof this.eContentValueHex)throw"eContentValue not yet set";var t=new s({hex:this.eContentValueHex});this.dEContent=new i({obj:t,tag:"a0",explicit:!0});var e=[this.dEContentType];this.isDetached||e.push(this.dEContent);var r=new n({array:e});return this.hTLV=r.getEncodedHex(),this.hTLV}},r.lang.extend(ft.asn1.cms.EncapsulatedContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.ContentInfo=function(t){var e=ft.asn1,i=e.DERTaggedObject,n=e.DERSequence,r=e.x509;ft.asn1.cms.ContentInfo.superclass.constructor.call(this),this.dContentType=null,this.dContent=null,this.setContentType=function(t){"string"==typeof t&&(this.dContentType=r.OID.name2obj(t))},this.getEncodedHex=function(){var t=new i({obj:this.dContent,tag:"a0",explicit:!0}),e=new n({array:[this.dContentType,t]});return this.hTLV=e.getEncodedHex(),this.hTLV},void 0!==t&&(t.type&&this.setContentType(t.type),t.obj&&t.obj instanceof e.ASN1Object&&(this.dContent=t.obj))},r.lang.extend(ft.asn1.cms.ContentInfo,ft.asn1.ASN1Object),ft.asn1.cms.SignedData=function(t){var e=ft.asn1,i=e.ASN1Object,n=e.DERInteger,r=e.DERSet,s=e.DERSequence,o=e.DERTaggedObject,a=e.cms,h=a.EncapsulatedContentInfo,u=a.SignerInfo,c=a.ContentInfo,l=e.x509.AlgorithmIdentifier;ft.asn1.cms.SignedData.superclass.constructor.call(this),this.dCMSVersion=new n({int:1}),this.dDigestAlgs=null,this.digestAlgNameList=[],this.dEncapContentInfo=new h,this.dCerts=null,this.certificateList=[],this.crlList=[],this.signerInfoList=[new u],this.addCertificatesByPEM=function(t){var e=Ht(t),n=new i;n.hTLV=e,this.certificateList.push(n)},this.getEncodedHex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(null==this.dDigestAlgs){for(var t=[],e=0;e0){var h=new r({array:this.certificateList});this.dCerts=new o({obj:h,tag:"a0",explicit:!1})}null!=this.dCerts&&a.push(this.dCerts);var u=new r({array:this.signerInfoList});a.push(u);var c=new s({array:a});return this.hTLV=c.getEncodedHex(),this.hTLV},this.getContentInfo=function(){return this.getEncodedHex(),new c({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().getEncodedHex()},this.getPEM=function(){return Rt(this.getContentInfoEncodedHex(),"CMS")}},r.lang.extend(ft.asn1.cms.SignedData,ft.asn1.ASN1Object),ft.asn1.cms.CMSUtil=new function(){},ft.asn1.cms.CMSUtil.newSignedData=function(t){var e=ft.asn1,i=e.cms,n=i.SignerInfo,r=i.SignedData,s=i.SigningTime,o=i.SigningCertificate,a=i.SigningCertificateV2,h=e.cades.SignaturePolicyIdentifier,u=new r;if(u.dEncapContentInfo.setContentValue(t.content),"object"==typeof t.certs)for(var c=0;c0){var t=new n({array:this.extensionsArray}),e=new r({array:[t]}),i=new n({array:[new a({oid:"1.2.840.113549.1.9.14"}),e]}),h=new o({explicit:!0,tag:"a0",obj:i});this.asn1Array.push(h)}else{h=new o({explicit:!1,tag:"a0",obj:new s});this.asn1Array.push(h)}var u=new n({array:this.asn1Array});return this.hTLV=u.getEncodedHex(),this.isModified=!1,this.hTLV},this._initialize()},r.lang.extend(ft.asn1.csr.CertificationRequestInfo,ft.asn1.ASN1Object),ft.asn1.csr.CSRUtil=new function(){},ft.asn1.csr.CSRUtil.newCSRPEM=function(t){var e=Ut,i=ft.asn1.csr;if(void 0===t.subject)throw"parameter subject undefined";if(void 0===t.sbjpubkey)throw"parameter sbjpubkey undefined";if(void 0===t.sigalg)throw"parameter sigalg undefined";if(void 0===t.sbjprvkey)throw"parameter sbjpubkey undefined";var n=new i.CertificationRequestInfo;if(n.setSubjectByParam(t.subject),n.setSubjectPublicKeyByGetKey(t.sbjpubkey),void 0!==t.ext&&void 0!==t.ext.length)for(var r=0;rr)throw"key is too short for SigAlg: keylen="+i+","+e;for(var s="0001",o="00"+n,a="",h=r-s.length-o.length,u=0;u=0)return!1;if(i.compareTo(x.ONE)<0||i.compareTo(r)>=0)return!1;var o=i.modInverse(r),a=t.multiply(o).mod(r),h=e.multiply(o).mod(r);return s.multiply(a).add(n.multiply(h)).getX().toBigInteger().mod(r).equals(e)},this.serializeSig=function(t,e){var i=t.toByteArraySigned(),n=e.toByteArraySigned(),r=[];return r.push(2),r.push(i.length),(r=r.concat(i)).push(2),r.push(n.length),(r=r.concat(n)).unshift(r.length),r.unshift(48),r},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:x.fromByteArrayUnsigned(i),s:x.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:x.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:x.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[2,0],"06"),i=o(t,0,[1],"04");try{n=o(t,0,[3,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#1/5 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{o(t,0,[1,0],"06"),e=o(t,0,[1,1],"06"),i=o(t,0,[2,0,1],"04");try{n=o(t,0,[2,0,2,0],"03").substr(2)}catch(t){}}catch(t){throw"malformed PKCS#8 plain ECC private key"}if(this.curveName=s(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){var e,i,n=pt,r=ft.crypto.ECDSA.getName,s=n.getVbyList;if(!1===n.isASN1HEX(t))throw"not ASN.1 hex string";try{s(t,0,[0,0],"06"),e=s(t,0,[0,1],"06"),i=s(t,0,[1],"03").substr(2)}catch(t){throw"malformed PKCS#8 ECC public key"}if(this.curveName=r(e),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,e){5!==e&&(e=6);var i,n,r=pt,s=ft.crypto.ECDSA.getName,o=r.getVbyList;if(!1===r.isASN1HEX(t))throw"not ASN.1 hex string";try{i=o(t,0,[0,e,0,1],"06"),n=o(t,0,[0,e,1],"03").substr(2)}catch(t){throw"malformed X.509 certificate ECC public key"}if(this.curveName=s(i),null===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ft.crypto.ECDSA.parseSigHex=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new x(e.r,16),s:new x(e.s,16)}},ft.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=pt,i=e.getChildIdx,n=e.getV;if("30"!=t.substr(0,2))throw"signature is not a ASN.1 sequence";var r=i(t,0);if(2!=r.length)throw"number of signature ASN.1 sequence elements seem wrong";var s=r[0],o=r[1];if("02"!=t.substr(s,2))throw"1st item of sequene of signature is not ASN.1 integer";if("02"!=t.substr(o,2))throw"2nd item of sequene of signature is not ASN.1 integer";return{r:n(t,s),s:n(t,o)}},ft.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ft.crypto.ECDSA.parseSigHexInHexRS(t),i=e.r,n=e.s;if("00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),i.length%32==30&&(i="00"+i),n.length%32==30&&(n="00"+n),i.length%32!=0)throw"unknown ECDSA sig r length error";if(n.length%32!=0)throw"unknown ECDSA sig s length error";return i+n},ft.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var e=t.substr(0,t.length/2),i=t.substr(t.length/2);return ft.crypto.ECDSA.hexRSSigToASN1Sig(e,i)},ft.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var i=new x(t,16),n=new x(e,16);return ft.crypto.ECDSA.biRSSigToASN1Sig(i,n)},ft.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var i=ft.asn1,n=new i.DERInteger({bigint:t}),r=new i.DERInteger({bigint:e});return new i.DERSequence({array:[n,r]}).getEncodedHex()},ft.crypto.ECDSA.getName=function(t){return"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040022"===t?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":null},void 0!==ft&&ft||(ft={}),void 0!==ft.crypto&&ft.crypto||(ft.crypto={}),ft.crypto.ECParameterDB=new function(){var t={},e={};function i(t){return new x(t,16)}this.getByName=function(i){var n=i;if(void 0!==e[n]&&(n=e[i]),void 0!==t[n])return t[n];throw"unregistered EC curve name: "+n},this.regist=function(n,r,s,o,a,h,u,c,l,f,d,g){t[n]={};var p=i(s),y=i(o),v=i(a),m=i(h),S=i(u),F=new ct(p,y,v),w=F.decodePointHex("04"+c+l);t[n].name=n,t[n].keylen=r,t[n].curve=F,t[n].G=w,t[n].n=m,t[n].h=S,t[n].oid=d,t[n].info=g;for(var E=0;E1?new x(n,16):null,u=new x(r,16),this.setPrivate(s,o,a,h,u)},this.setPublic=function(t,e,i,n){this.isPublic=!0,this.p=t,this.q=e,this.g=i,this.y=n,this.x=null},this.setPublicHex=function(t,e,i,n){var r,s,o,a;r=new x(t,16),s=new x(e,16),o=new x(i,16),a=new x(n,16),this.setPublic(r,s,o,a)},this.signWithMessageHash=function(t){var e=this.p,i=this.q,n=this.g,r=(this.y,this.x),s=ft.crypto.Util.getRandomBigIntegerMinToMax(x.ONE.add(x.ONE),i.subtract(x.ONE)),o=new x(t.substr(0,i.bitLength()/4),16),a=n.modPow(s,e).mod(i),h=s.modInverse(i).multiply(o.add(r.multiply(a))).mod(i);return ft.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:a}},{int:{bigint:h}}]})},this.verifyWithMessageHash=function(t,e){var i=this.p,n=this.q,r=this.g,s=this.y,o=this.parseASN1Signature(e),a=o[0],h=o[1],u=new x(t.substr(0,n.bitLength()/4),16);if(x.ZERO.compareTo(a)>0||a.compareTo(n)>0)throw"invalid DSA signature";if(x.ZERO.compareTo(h)>=0||h.compareTo(n)>0)throw"invalid DSA signature";var c=h.modInverse(n),l=u.multiply(c).mod(n),f=a.multiply(c).mod(n);return 0==r.modPow(l,i).multiply(s.modPow(f,i)).mod(i).mod(n).compareTo(a)},this.parseASN1Signature=function(t){try{return[new x(pt.getVbyList(t,0,[0],"02"),16),new x(pt.getVbyList(t,0,[1],"02"),16)]}catch(t){throw"malformed ASN.1 DSA signature"}},this.readPKCS5PrvKeyHex=function(t){var e,i,n,r,s,o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{e=a(t,0,[1],"02"),i=a(t,0,[2],"02"),n=a(t,0,[3],"02"),r=a(t,0,[4],"02"),s=a(t,0,[5],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#1/5 plain DSA private key"}this.setPrivateHex(e,i,n,r,s)},this.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[1,1,0],"02"),i=o(t,0,[1,1,1],"02"),n=o(t,0,[1,1,2],"02"),r=o(t,0,[2,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 plain DSA private key"}this.setPrivateHex(e,i,n,null,r)},this.readPKCS8PubKeyHex=function(t){var e,i,n,r,s=pt,o=s.getVbyList;if(!1===s.isASN1HEX(t))throw"not ASN.1 hex string";try{e=o(t,0,[0,1,0],"02"),i=o(t,0,[0,1,1],"02"),n=o(t,0,[0,1,2],"02"),r=o(t,0,[1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed PKCS#8 DSA public key"}this.setPublicHex(e,i,n,r)},this.readCertPubKeyHex=function(t,e){var i,n,r,s;5!==e&&(e=6);var o=pt,a=o.getVbyList;if(!1===o.isASN1HEX(t))throw"not ASN.1 hex string";try{i=a(t,0,[0,e,0,1,0],"02"),n=a(t,0,[0,e,0,1,1],"02"),r=a(t,0,[0,e,0,1,2],"02"),s=a(t,0,[0,e,1,0],"02")}catch(t){throw console.log("EXCEPTION:"+t),"malformed X.509 certificate DSA public key"}this.setPublicHex(i,n,r,s)}};var Ut=function(){var t=function(t,i,n){return e(y.AES,t,i,n)},e=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a={};a.key=s,a.iv=o,a.ciphertext=r;var h=t.decrypt(a,s,{iv:o});return y.enc.Hex.stringify(h)},i=function(t,e,i){return n(y.AES,t,e,i)},n=function(t,e,i,n){var r=y.enc.Hex.parse(e),s=y.enc.Hex.parse(i),o=y.enc.Hex.parse(n),a=t.encrypt(r,s,{iv:o}),h=y.enc.Hex.parse(a.toString());return y.enc.Base64.stringify(h)},r={"AES-256-CBC":{proc:t,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,i,n){return e(y.TripleDES,t,i,n)},eproc:function(t,e,i){return n(y.TripleDES,t,e,i)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,i,n){return e(y.DES,t,i,n)},eproc:function(t,e,i){return n(y.DES,t,e,i)},keylen:8,ivlen:8}},s=function(t){var e={},i=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));i&&(e.cipher=i[1],e.ivsalt=i[2]);var n=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(e.type=n[1]);var r=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(r=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(r=t.indexOf("\n\n"),s=1);var o=t.indexOf("-----END");if(-1!=r&&-1!=o){var a=t.substring(r+2*s,o-s);a=a.replace(/\s+/g,""),e.data=a}return e},o=function(t,e,i){for(var n=i.substring(0,16),s=y.enc.Hex.parse(n),o=y.enc.Utf8.parse(e),a=r[t].keylen+r[t].ivlen,h="",u=null;;){var c=y.algo.MD5.create();if(null!=u&&c.update(u),c.update(o),c.update(s),u=c.finalize(),(h+=y.enc.Hex.stringify(u)).length>=2*a)break}var l={};return l.keyhex=h.substr(0,2*r[t].keylen),l.ivhex=h.substr(2*r[t].keylen,2*r[t].ivlen),l},a=function(t,e,i,n){var s=y.enc.Base64.parse(t),o=y.enc.Hex.stringify(s);return(0,r[e].proc)(o,i,n)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,i){return o(t,e,i)},decryptKeyB64:function(t,e,i,n){return a(t,e,i,n)},getDecryptedKeyHex:function(t,e){var i=s(t),n=(i.type,i.cipher),r=i.ivsalt,h=i.data,u=o(n,e,r).keyhex;return a(h,n,u,r)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,i,n,s){var a="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===r[n])throw"KEYUTIL unsupported algorithm: "+n;void 0!==s&&null!=s||(s=function(t){var e=y.lib.WordArray.random(t);return y.enc.Hex.stringify(e)}(r[n].ivlen).toUpperCase());var h=function(t,e,i,n){return(0,r[e].eproc)(t,i,n)}(e,n,o(n,i,s).keyhex,s);a="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+n+","+s+"\r\n",a+="\r\n",a+=h.replace(/(.{64})/g,"$1\r\n"),a+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={},s=i(t,0);if(2!=s.length)throw"malformed format: SEQUENCE(0).items != 2: "+s.length;r.ciphertext=n(t,s[1]);var o=i(t,s[0]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0).items != 2: "+o.length;if("2a864886f70d01050d"!=n(t,o[0]))throw"this only supports pkcs5PBES2";var a=i(t,o[1]);if(2!=o.length)throw"malformed format: SEQUENCE(0.0.1).items != 2: "+a.length;var h=i(t,a[1]);if(2!=h.length)throw"malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length;if("2a864886f70d0307"!=n(t,h[0]))throw"this only supports TripleDES";r.encryptionSchemeAlg="TripleDES",r.encryptionSchemeIV=n(t,h[1]);var u=i(t,a[0]);if(2!=u.length)throw"malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length;if("2a864886f70d01050c"!=n(t,u[0]))throw"this only supports pkcs5PBKDF2";var c=i(t,u[1]);if(c.length<2)throw"malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length;r.pbkdf2Salt=n(t,c[0]);var l=n(t,c[1]);try{r.pbkdf2Iter=parseInt(l,16)}catch(t){throw"malformed format pbkdf2Iter: "+l}return r},getPBKDF2KeyHexFromParam:function(t,e){var i=y.enc.Hex.parse(t.pbkdf2Salt),n=t.pbkdf2Iter,r=y.PBKDF2(e,i,{keySize:6,iterations:n});return y.enc.Hex.stringify(r)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var i=Ht(t,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(i),r=Ut.getPBKDF2KeyHexFromParam(n,e),s={};s.ciphertext=y.enc.Hex.parse(n.ciphertext);var o=y.enc.Hex.parse(r),a=y.enc.Hex.parse(n.encryptionSchemeIV),h=y.TripleDES.decrypt(s,o,{iv:a});return y.enc.Hex.stringify(h)},getKeyFromEncryptedPKCS8PEM:function(t,e){var i=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(i)},parsePlainPrivatePKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null};if("30"!=t.substr(0,2))throw"malformed plain PKCS8 private key(code:001)";var s=i(t,0);if(3!=s.length)throw"malformed plain PKCS8 private key(code:002)";if("30"!=t.substr(s[1],2))throw"malformed PKCS8 private key(code:003)";var o=i(t,s[1]);if(2!=o.length)throw"malformed PKCS8 private key(code:004)";if("06"!=t.substr(o[0],2))throw"malformed PKCS8 private key(code:005)";if(r.algoid=n(t,o[0]),"06"==t.substr(o[1],2)&&(r.algparam=n(t,o[1])),"04"!=t.substr(s[2],2))throw"malformed PKCS8 private key(code:006)";return r.keyidx=e.getVidx(t,s[2]),r},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Ht(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,i=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==i.algoid)e=new ot;else if("2a8648ce380401"==i.algoid)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!=i.algoid)throw"unsupported private key algorithm";e=new ft.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,i=pt.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===i)e=new ot;else if("2a8648ce380401"===i)e=new ft.crypto.DSA;else{if("2a8648ce3d0201"!==i)throw"unsupported PKCS#8 public key hex";e=new ft.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={};if("30"!=t.substr(0,2))throw"malformed RSA key(code:001)";var s=i(t,0);if(2!=s.length)throw"malformed RSA key(code:002)";if("02"!=t.substr(s[0],2))throw"malformed RSA key(code:003)";if(r.n=n(t,s[0]),"02"!=t.substr(s[1],2))throw"malformed RSA key(code:004)";return r.e=n(t,s[1]),r},parsePublicPKCS8Hex:function(t){var e=pt,i=e.getChildIdx,n=e.getV,r={algparam:null},s=i(t,0);if(2!=s.length)throw"outer DERSequence shall have 2 elements: "+s.length;var o=s[0];if("30"!=t.substr(o,2))throw"malformed PKCS8 public key(code:001)";var a=i(t,o);if(2!=a.length)throw"malformed PKCS8 public key(code:002)";if("06"!=t.substr(a[0],2))throw"malformed PKCS8 public key(code:003)";if(r.algoid=n(t,a[0]),"06"==t.substr(a[1],2)?r.algparam=n(t,a[1]):"30"==t.substr(a[1],2)&&(r.algparam={},r.algparam.p=e.getVbyList(t,a[1],[0],"02"),r.algparam.q=e.getVbyList(t,a[1],[1],"02"),r.algparam.g=e.getVbyList(t,a[1],[2],"02")),"03"!=t.substr(s[1],2))throw"malformed PKCS8 public key(code:004)";return r.key=n(t,s[1]).substr(2),r}}}();Ut.getKey=function(t,e,i){var n=(y=pt).getChildIdx,r=(y.getV,y.getVbyList),s=ft.crypto,o=s.ECDSA,a=s.DSA,h=ot,u=Ht,c=Ut;if(void 0!==h&&t instanceof h)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new o({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new o({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(t.n,t.e),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(D=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),D;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(D=new h).setPrivate(t.n,t.e,t.d),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(D=new a).setPublic(t.p,t.q,t.g,t.y),D;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(D=new a).setPrivate(t.p,t.q,t.g,t.y,t.x),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(D=new h).setPublic(xt(t.n),xt(t.e)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(D=new h).setPrivateEx(xt(t.n),xt(t.e),xt(t.d),xt(t.p),xt(t.q),xt(t.dp),xt(t.dq),xt(t.qi)),D;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(D=new h).setPrivate(xt(t.n),xt(t.e),xt(t.d)),D;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);return C.setPublicKeyHex(f),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(C=new o({curve:t.crv})).ecparams.keylen/4,f="04"+("0000000000"+xt(t.x)).slice(-l)+("0000000000"+xt(t.y)).slice(-l);var d=("0000000000"+xt(t.d)).slice(-l);return C.setPublicKeyHex(f),C.setPrivateKeyHex(d),C}if("pkcs5prv"===i){var g,p=t,y=pt;if(9===(g=n(p,0)).length)(D=new h).readPKCS5PrvKeyHex(p);else if(6===g.length)(D=new a).readPKCS5PrvKeyHex(p);else{if(!(g.length>2&&"04"===p.substr(g[1],2)))throw"unsupported PKCS#1/5 hexadecimal key";(D=new o).readPKCS5PrvKeyHex(p)}return D}if("pkcs8prv"===i)return D=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===i)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===i)return Jt.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return Jt.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var v=Ht(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(v)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var m=u(t,"RSA PRIVATE KEY");return c.getKey(m,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=r(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),F=r(R,0,[2],"02"),w=r(R,0,[3],"02"),E=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(w,16),new x(E,16),new x(b,16)),D}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var A=c.getDecryptedKeyHex(t,e),I=new ot;return I.readPKCS5PrvKeyHex(A),I}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var C,D=r(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),T=r(R,0,[2,0],"06"),P=r(R,0,[3,0],"03").substr(2);if(void 0===ft.crypto.OID.oidhex2name[T])throw"undefined OID(hex) in KJUR.crypto.OID: "+T;return(C=new o({curve:ft.crypto.OID.oidhex2name[T]})).setPublicKeyHex(P),C.setPrivateKeyHex(D),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;S=r(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),F=r(R,0,[2],"02"),w=r(R,0,[3],"02"),E=r(R,0,[4],"02"),b=r(R,0,[5],"02");return(D=new a).setPrivate(new x(S,16),new x(F,16),new x(w,16),new x(E,16),new x(b,16)),D}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw"not supported argument"},Ut.generateKeypair=function(t,e){if("RSA"==t){var i=e;(o=new ot).generate(i,"10001"),o.isPrivate=!0,o.isPublic=!0;var n=new ot,r=o.n.toString(16),s=o.e.toString(16);return n.setPublic(r,s),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}if("EC"==t){var o,a,h=e,u=new ft.crypto.ECDSA({curve:h}).generateKeyPairHex();return(o=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),o.setPrivateKeyHex(u.ecprvhex),o.isPrivate=!0,o.isPublic=!1,(n=new ft.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=o,a.pubKeyObj=n,a}throw"unknown algorithm: "+t},Ut.getPEM=function(t,e,i,n,r,s){var o=ft,a=o.asn1,h=a.DERObjectIdentifier,u=a.DERInteger,c=a.ASN1Util.newObject,l=a.x509.SubjectPublicKeyInfo,f=o.crypto,d=f.DSA,g=f.ECDSA,p=ot;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function S(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==p&&t instanceof p||void 0!==d&&t instanceof d||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return Rt(x=new l(t).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=v(t).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===i||null==i)&&1==t.isPrivate){var F=new h({name:t.curveName}).getEncodedHex(),w=m(t).getEncodedHex(),E="";return E+=Rt(F,"EC PARAMETERS"),E+=Rt(w,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===i||null==i)&&1==t.isPrivate)return Rt(x=S(t).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==i&&null!=i&&1==t.isPrivate){var x=v(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==i&&null!=i&&1==t.isPrivate){x=m(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",x,i,n,s)}if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==i&&null!=i&&1==t.isPrivate){x=S(t).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",x,i,n,s)}var b=function(t,e){var i=A(t,e);return new c({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:i.pbkdf2Salt}},{int:i.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:i.encryptionSchemeIV}}]}]}]},{octstr:{hex:i.ciphertext}}]}).getEncodedHex()},A=function(t,e){var i=y.lib.WordArray.random(8),n=y.lib.WordArray.random(8),r=y.PBKDF2(e,i,{keySize:6,iterations:100}),s=y.enc.Hex.parse(t),o=y.TripleDES.encrypt(s,r,{iv:n})+"",a={};return a.ciphertext=o,a.pbkdf2Salt=y.enc.Hex.stringify(i),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=y.enc.Hex.stringify(n),a};if("PKCS8PRV"==e&&null!=p&&t instanceof p&&1==t.isPrivate){var I=v(t).getEncodedHex();x=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){I=new c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==e&&void 0!==d&&t instanceof d&&1==t.isPrivate){I=new u({bigint:t.x}).getEncodedHex(),x=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:I}}]}).getEncodedHex();return void 0===i||null==i?Rt(x,"PRIVATE KEY"):Rt(w=b(x,i),"ENCRYPTED PRIVATE KEY")}throw"unsupported object nor format"},Ut.getKeyFromCSRPEM=function(t){var e=Ht(t,"CERTIFICATE REQUEST");return Ut.getKeyFromCSRHex(e)},Ut.getKeyFromCSRHex=function(t){var e=Ut.parseCSRHex(t);return Ut.getKey(e.p8pubkeyhex,null,"pkcs8pub")},Ut.parseCSRHex=function(t){var e=pt,i=e.getChildIdx,n=e.getTLV,r={},s=t;if("30"!=s.substr(0,2))throw"malformed CSR(code:001)";var o=i(s,0);if(o.length<1)throw"malformed CSR(code:002)";if("30"!=s.substr(o[0],2))throw"malformed CSR(code:003)";var a=i(s,o[0]);if(a.length<3)throw"malformed CSR(code:004)";return r.p8pubkeyhex=n(s,a[2]),r},Ut.getJWKFromKey=function(t){var e={};if(t instanceof ot&&t.isPrivate)return e.kty="RSA",e.n=Et(t.n.toString(16)),e.e=Et(t.e.toString(16)),e.d=Et(t.d.toString(16)),e.p=Et(t.p.toString(16)),e.q=Et(t.q.toString(16)),e.dp=Et(t.dmp1.toString(16)),e.dq=Et(t.dmq1.toString(16)),e.qi=Et(t.coeff.toString(16)),e;if(t instanceof ot&&t.isPublic)return e.kty="RSA",e.n=Et(t.n.toString(16)),e.e=Et(t.e.toString(16)),e;if(t instanceof ft.crypto.ECDSA&&t.isPrivate){if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;var i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=Et(i.x),e.y=Et(i.y),e.d=Et(t.prvKeyHex),e}if(t instanceof ft.crypto.ECDSA&&t.isPublic){var n;if("P-256"!==(n=t.getShortNISTPCurveName())&&"P-384"!==n)throw"unsupported curve name for JWT: "+n;i=t.getPublicKeyXYHex();return e.kty="EC",e.crv=n,e.x=Et(i.x),e.y=Et(i.y),e}throw"not supported key object"},ot.getPosArrayOfChildrenFromHex=function(t){return pt.getChildIdx(t,0)},ot.getHexValueArrayOfChildrenFromHex=function(t){var e,i=pt.getV,n=i(t,(e=ot.getPosArrayOfChildrenFromHex(t))[0]),r=i(t,e[1]),s=i(t,e[2]),o=i(t,e[3]),a=i(t,e[4]),h=i(t,e[5]),u=i(t,e[6]),c=i(t,e[7]),l=i(t,e[8]);return(e=new Array).push(n,r,s,o,a,h,u,c,l),e},ot.prototype.readPrivateKeyFromPEMString=function(t){var e=Ht(t),i=ot.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8])},ot.prototype.readPKCS5PrvKeyHex=function(t){var e=ot.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},ot.prototype.readPKCS8PrvKeyHex=function(t){var e,i,n,r,s,o,a,h,u=pt,c=u.getVbyList;if(!1===u.isASN1HEX(t))throw"not ASN.1 hex string";try{e=c(t,0,[2,0,1],"02"),i=c(t,0,[2,0,2],"02"),n=c(t,0,[2,0,3],"02"),r=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),o=c(t,0,[2,0,6],"02"),a=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw"malformed PKCS#8 plain RSA private key"}this.setPrivateEx(e,i,n,r,s,o,a,h)},ot.prototype.readPKCS5PubKeyHex=function(t){var e=pt,i=e.getV;if(!1===e.isASN1HEX(t))throw"keyHex is not ASN.1 hex string";var n=e.getChildIdx(t,0);if(2!==n.length||"02"!==t.substr(n[0],2)||"02"!==t.substr(n[1],2))throw"wrong hex for PKCS#5 public key";var r=i(t,n[0]),s=i(t,n[1]);this.setPublic(r,s)},ot.prototype.readPKCS8PubKeyHex=function(t){var e=pt;if(!1===e.isASN1HEX(t))throw"not ASN.1 hex string";if("06092a864886f70d010101"!==e.getTLVbyList(t,0,[0,0]))throw"not PKCS8 RSA public key";var i=e.getTLVbyList(t,0,[1,0]);this.readPKCS5PubKeyHex(i)},ot.prototype.readCertPubKeyHex=function(t,e){var i,n;(i=new Jt).readCertHex(t),n=i.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var qt=new RegExp("");function zt(t,e){for(var i="",n=e/4-t.length,r=0;r>24,(16711680&r)>>16,(65280&r)>>8,255&r])))),r+=1;return n}function Yt(t){for(var e in ft.crypto.Util.DIGESTINFOHEAD){var i=ft.crypto.Util.DIGESTINFOHEAD[e],n=i.length;if(t.substring(0,n)==i)return[e,t.substring(n)]}return[]}function Jt(){var t=pt,e=t.getChildIdx,i=t.getV,n=t.getTLV,r=t.getVbyList,s=t.getTLVbyList,o=t.getIdxbyList,a=t.getVidx,h=t.oidname,u=Jt,c=Ht;this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){return null===this.hex||0!==this.version?this.version:"a003020102"!==s(this.hex,0,[0,0])?(this.version=1,this.foffset=-1,1):(this.version=3,3)},this.getSerialNumberHex=function(){return r(this.hex,0,[0,1+this.foffset],"02")},this.getSignatureAlgorithmField=function(){return h(r(this.hex,0,[0,2+this.foffset,0],"06"))},this.getIssuerHex=function(){return s(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return u.hex2dn(this.getIssuerHex())},this.getSubjectHex=function(){return s(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return u.hex2dn(this.getSubjectHex())},this.getNotBefore=function(){var t=r(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=r(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return t.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return o(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return o(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return Ut.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){return h(r(this.hex,0,[1,0],"06"))},this.getSignatureValueHex=function(){return r(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmName(),i=this.getSignatureValueHex(),n=s(this.hex,0,[0],"30"),r=new ft.crypto.Signature({alg:e});return r.init(t),r.updateHex(n),r.verify(i)},this.parseExt=function(){if(3!==this.version)return-1;var i=o(this.hex,0,[0,7,0],"30"),n=e(this.hex,i);this.aExtInfo=new Array;for(var s=0;s0&&(u=new Array(i),(new nt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=It(h(Ct("\0\0\0\0\0\0\0\0"+r+u))),l=[];for(n=0;n>8*a-o&255;for(g[0]&=~p,n=0;nthis.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;var r=n[0];return n[1]==function(t){return ft.crypto.Util.hashString(t,r)}(t)},ot.prototype.verifyWithMessageHash=function(t,e){var i=rt(e=(e=e.replace(qt,"")).replace(/[ \n]+/g,""),16);if(i.bitLength()>this.n.bitLength())return 0;var n=Yt(this.doPublic(i).toString(16).replace(/^1f+00/,""));if(0==n.length)return!1;n[0];return n[1]==t},ot.prototype.verifyPSS=function(t,e,i,n){var r,s=(r=Ct(t),ft.crypto.Util.hashHex(r,i));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(s,e,i,n)},ot.prototype.verifyWithMessageHashPSS=function(t,e,i,n){var r=new x(e,16);if(r.bitLength()>this.n.bitLength())return!1;var s,o=function(t){return ft.crypto.Util.hashHex(t,i)},a=It(t),h=a.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===n||void 0===n)n=h;else if(-2===n)n=c-h-2;else if(n<-2)throw"invalid salt length";if(c>8*c-u&255;if(0!=(f.charCodeAt(0)&g))throw"bits beyond keysize not zero";var p=Gt(d,f.length,o),y=[];for(s=0;s0)&&-1==(":"+i.join(":")+":").indexOf(":"+p+":"))throw"algorithm '"+p+"' not accepted in the list";if("none"!=p&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=Ut.getKey(e)),!("RS"!=y&&"PS"!=y||e instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==y&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var v=null;if(void 0===s.jwsalg2sigalg[g.alg])throw"unsupported alg name: "+p;if("none"==(v=s.jwsalg2sigalg[p]))throw"not supported";if("Hmac"==v.substr(0,4)){if(void 0===e)throw"hexadecimal key shall be specified for HMAC";var m=new u({alg:v,pass:e});return m.updateString(f),d==m.doFinal()}if(-1!=v.indexOf("withECDSA")){var S,F=null;try{F=h.concatSigToASN1Sig(d)}catch(t){return!1}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(F)}return(S=new c({alg:v})).init(e),S.updateString(f),S.verify(d)},ft.jws.JWS.parse=function(t){var e,i,n,r=t.split("."),s={};if(2!=r.length&&3!=r.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=r[0],i=r[1],3==r.length&&(n=r[2]),s.headerObj=ft.jws.JWS.readSafeJSONString(gt(e)),s.payloadObj=ft.jws.JWS.readSafeJSONString(gt(i)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=gt(i):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==n&&(s.sigHex=xt(n)),s},ft.jws.JWS.verifyJWT=function(t,e,i){var n=ft.jws,r=n.JWS,s=r.readSafeJSONString,o=r.inArray,a=r.includedArray,h=t.split("."),u=h[0],c=h[1],l=(xt(h[2]),s(gt(u))),f=s(gt(c));if(void 0===l.alg)return!1;if(void 0===i.alg)throw"acceptField.alg shall be specified";if(!o(l.alg,i.alg))return!1;if(void 0!==f.iss&&"object"==typeof i.iss&&!o(f.iss,i.iss))return!1;if(void 0!==f.sub&&"object"==typeof i.sub&&!o(f.sub,i.sub))return!1;if(void 0!==f.aud&&"object"==typeof i.aud)if("string"==typeof f.aud){if(!o(f.aud,i.aud))return!1}else if("object"==typeof f.aud&&!a(f.aud,i.aud))return!1;var d=n.IntDate.getNow();return void 0!==i.verifyAt&&"number"==typeof i.verifyAt&&(d=i.verifyAt),void 0!==i.gracePeriod&&"number"==typeof i.gracePeriod||(i.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+i.gracePeriodr&&this.aHeader.pop(),this.aSignature.length>r&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignatures=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}},e.SecureRandom=nt,e.rng_seed_time=Z,e.BigInteger=x,e.RSAKey=ot,e.ECDSA=ft.crypto.ECDSA,e.DSA=ft.crypto.DSA,e.Signature=ft.crypto.Signature,e.MessageDigest=ft.crypto.MessageDigest,e.Mac=ft.crypto.Mac,e.Cipher=ft.crypto.Cipher,e.KEYUTIL=Ut,e.ASN1HEX=pt,e.X509=Jt,e.CryptoJS=y,e.b64tohex=w,e.b64toBA=E,e.stoBA=yt,e.BAtos=vt,e.BAtohex=mt,e.stohex=St,e.stob64=function(t){return F(St(t))},e.stob64u=function(t){return Ft(F(St(t)))},e.b64utos=function(t){return vt(E(wt(t)))},e.b64tob64u=Ft,e.b64utob64=wt,e.hex2b64=F,e.hextob64u=Et,e.b64utohex=xt,e.utf8tob64u=dt,e.b64utoutf8=gt,e.utf8tob64=function(t){return F(Ot(Kt(t)))},e.b64toutf8=function(t){return decodeURIComponent(jt(w(t)))},e.utf8tohex=bt,e.hextoutf8=At,e.hextorstr=It,e.rstrtohex=Ct,e.hextob64=Dt,e.hextob64nl=Tt,e.b64nltohex=Pt,e.hextopem=Rt,e.pemtohex=Ht,e.hextoArrayBuffer=function(t){if(t.length%2!=0)throw"input is not even length";if(null==t.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var e=new ArrayBuffer(t.length/2),i=new DataView(e),n=0;ne.length&&(i=e.length);for(var n=0;n300)throw s.includes("id token not generated with cloud directory idp")?new r(`${JSON.parse(s).error_description}`,i.status):new r(`Failed to fetch ${t}. Response=${s}`,i.status);try{return JSON.parse(s)}catch(e){if(""!==s)return s;throw new r(`Invalid response while trying to fetch ${t}. Response=${s}`,i.status,e)}}}},function(t,e,i){const n=i(1),r=i(15);t.exports=class{constructor({jwt:t=i(0)}={}){this.jwt=t}decodeAndValidate({token:t,publicKeys:e,issuer:i,clientId:s,nonce:o}){const a=Math.floor(Date.now()/1e3),h=t.split(".");if(3!==h.length)throw new r(`Invalid JWT token. Got only ${h.length} parts.`);const u=this.jwt.KJUR.jws.JWS.parse(t);if(!u.headerObj)throw new r(n.INVALID_TOKEN);const c=u.headerObj.kid,l=this.getPublicKey(e.keys,c),f=this.jwt.KEYUTIL.getKey(l);if(!this.jwt.KJUR.jws.JWS.verify(t,f,{alg:[n.TOKEN_ALG]}))throw new r(n.INVALID_SIGNATURE);if(u.payloadObj.exp + * @license MIT + */ +var n=i(9),r=i(10),s=i(11);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return A(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function A(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return w(this,t,e,i);case"latin1":case"binary":return E(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function B(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||N(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(8))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(17);t.exports=class{constructor({w:t=window}={}){this.window=t}init(t){this.popupConfig=t}open(){const t=this.popupConfig.height,e=this.popupConfig.width,i=(window.screen.width-e)/2,r=(window.screen.height-t)/2;if(this.popup=this.window.open("","popup",`left=${i},top=${r},width=${e},height=${t},resizable,scrollbars=yes,status=1`),!this.popup)throw new n("Unable to open popup")}navigate(t){this.popup.location.href=t}close(){this.popup.close()}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(21);t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t);const i={"x-filter-type":`spa:v${n.version}`};this.publicKeys=e(this.getJwksEndpoint(),{headers:i})}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}},function(t){t.exports=JSON.parse('{"name":"ibmcloud-appid-js","version":"0.3.0","description":"IBM Cloud App ID SDK for Single Page Applications","scripts":{"build":"webpack","test":"mocha","coverage":"nyc --reporter=lcov mocha","docs":"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git"},"main":"dist/appid.umd.min.js","nyc":{"all":true,"include":["src/*.js"],"exclude":["**/PopupController.js","**/IFrameController.js","**/OpenIDConfigurationResource.js","**/constants.js"]},"dependencies":{"jsrsasign":"^8.0.12"},"devDependencies":{"node-fetch":"^2.6.0","@babel/cli":"^7.0.0","@babel/core":"^7.5.5","@babel/plugin-transform-runtime":"^7.5.5","@babel/preset-env":"^7.5.5","babel-cli":"^7.0.0-beta.3","chai":"^4.2.0","coveralls":"^3.0.6","gulp-babel":"^8.0.0","mocha":"^6.2.0","nyc":"^14.1.1","webpack":"^4.39.1","webpack-cli":"^3.3.6","docdash":"^1.1.1","jsdoc":"^3.6.3"}}')}])})); \ No newline at end of file diff --git a/src/RequestHandler.js b/src/RequestHandler.js index fbde801..b3540a1 100644 --- a/src/RequestHandler.js +++ b/src/RequestHandler.js @@ -7,12 +7,10 @@ class RequestHandler { response = await fetch(url, options); text = await response.text(); } catch (e) { - debugger; throw new RequestError(`Failed to fetch ${url}. ${e}`, null, e); } if (!response.ok || response.status > 300) { - debugger; if (text.includes('id token not generated with cloud directory idp')) { throw new RequestError(`${JSON.parse(text).error_description}`, response.status); } else { diff --git a/test/AppIdTest.js b/test/AppIdTest.js index 04d74ab..722f011 100644 --- a/test/AppIdTest.js +++ b/test/AppIdTest.js @@ -276,4 +276,58 @@ describe('AppID tests', () => { } }); }) + + describe('changeDetails', () => { + let appID; + + it('should succeed', async () => { + appID = new AppID({ + popup: new PopupControllerMock({invalidState: false, error: false}), + iframe: new IFrameControllerMock({invalidState: false, error: false, invalidOrigin: false}), + openIdConfigResource: new OpenIdConfigurationResourceMock(), + utils: new Utils(), + tokenValidator: new TokenValidatorMock({}), + requestHandler: new RequestHandlerMock(), + w: {origin: 'localhost'}, + url: URL + }); + await appID.init(defaultInit); + let res = await appID.changeDetails({accessToken: 'accessToken', idToken: 'idToken'}); + assert.equal(res.accessToken, 'accessToken'); + assert.equal(res.idToken, 'idToken'); + assert.equal(res.accessTokenPayload, 'tokenPayload'); + }); + + it('should throw missing access token error if not exist', async () => { + try { + await appID.changeDetails({}); + } catch (e) { + assert.equal(e.message, constants.MISSING_ACCESS_TOKEN); + } + }); + + it('should throw missing id token error if not jwt string', async () => { + try { + await appID.changeDetails({accessToken: {id: 'not a jwt'}}); + } catch (e) { + assert.equal(e.message, constants.MISSING_ID_TOKEN); + } + }); + + it('should throw missing id token error if not exist', async () => { + try { + await appID.changeDetails({accessToken: 'accessToken'}); + } catch (e) { + assert.equal(e.message, constants.MISSING_ID_TOKEN); + } + }); + + it('should throw missing id token error if not jwt string', async () => { + try { + await appID.changeDetails({accessToken: 'accessToken', idToken: {id: 'not a jwt'}}); + } catch (e) { + assert.equal(e.message, constants.MISSING_ID_TOKEN); + } + }); + }) }); \ No newline at end of file diff --git a/test/requestHandlerTest.js b/test/requestHandlerTest.js index a4bf229..e47714c 100644 --- a/test/requestHandlerTest.js +++ b/test/requestHandlerTest.js @@ -25,16 +25,31 @@ describe('RequestHandler tests', async () => { try { let res = await requestHandler(invalidUrl); } catch (e) { - assert.deepEqual(e.toString(),'Error: Failed to fetch notvalid. TypeError: Only absolute URLs are supported') + assert.deepEqual(e.toString(), 'Error: Failed to fetch notvalid. TypeError: Only absolute URLs are supported') + } + }); + + it('returns id token not generated with cloud directory idp', async () => { + const htmlResponse = 'http://www.mocky.io/v2/5dc17100330000c8b61a526f'; + try { + let res = await requestHandler(htmlResponse); + } catch (e) { + expect(e.toString()).to.include('Error: id token not generated with cloud directory idp') } }); it('returns invalid response type', async () => { - const htmlResponse = url + 'html'; + const htmlResponse = 'http://www.mocky.io/v2/5dc171fe330000b3a41a527e'; try { let res = await requestHandler(htmlResponse); } catch (e) { expect(e.toString()).to.include('Invalid response while trying to fetch ' + htmlResponse) } }); + + it('returns text', async () => { + const htmlResponse = 'http://www.mocky.io/v2/5dc17255330000cdbd1a5283'; + let res = await requestHandler(htmlResponse); + assert.deepEqual(res, 'working'); + }); }); \ No newline at end of file From c50673372cc2e1646e28f6d7364cf5f8a577308b Mon Sep 17 00:00:00 2001 From: Joyce Huang Date: Tue, 5 Nov 2019 07:07:35 -0600 Subject: [PATCH 8/9] build files --- dist/appid.min.js | 2 +- dist/appid.umd.min.js | 2 +- sample/package-lock.json | 374 --------------------------------------- sample/public/index.css | 18 ++ sample/public/index.html | 59 ++++-- 5 files changed, 63 insertions(+), 392 deletions(-) delete mode 100644 sample/package-lock.json diff --git a/dist/appid.min.js b/dist/appid.min.js index e4fa0b2..d881b0a 100644 --- a/dist/appid.min.js +++ b/dist/appid.min.js @@ -47,4 +47,4 @@ var lt=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(? * @author Feross Aboukhadijeh * @license MIT */ -var n=i(9),r=i(10),s=i(11);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return A(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function A(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return E(this,t,e,i);case"latin1":case"binary":return w(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function B(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||N(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(8))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(17);t.exports=class{constructor({w:t=window}={}){this.window=t}init(t){this.popupConfig=t}open(){const t=this.popupConfig.height,e=this.popupConfig.width,i=(window.screen.width-e)/2,r=(window.screen.height-t)/2;if(this.popup=this.window.open("","popup",`left=${i},top=${r},width=${e},height=${t},resizable,scrollbars=yes,status=1`),!this.popup)throw new n("Unable to open popup")}navigate(t){this.popup.location.href=t}close(){this.popup.close()}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(21);t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t);const i={"x-filter-type":`spa:v${n.version}`};this.publicKeys=e(this.getJwksEndpoint(),{headers:i})}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}},function(t){t.exports=JSON.parse('{"name":"ibmcloud-appid-js","version":"0.3.0","description":"IBM Cloud App ID SDK for Single Page Applications","scripts":{"build":"webpack","test":"mocha","coverage":"nyc --reporter=lcov mocha","docs":"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git"},"main":"dist/appid.umd.min.js","nyc":{"all":true,"include":["src/*.js"],"exclude":["**/PopupController.js","**/IFrameController.js","**/OpenIDConfigurationResource.js","**/constants.js"]},"dependencies":{"jsrsasign":"^8.0.12"},"devDependencies":{"node-fetch":"^2.6.0","@babel/cli":"^7.0.0","@babel/core":"^7.5.5","@babel/plugin-transform-runtime":"^7.5.5","@babel/preset-env":"^7.5.5","babel-cli":"^7.0.0-beta.3","chai":"^4.2.0","coveralls":"^3.0.6","gulp-babel":"^8.0.0","mocha":"^6.2.0","nyc":"^14.1.1","webpack":"^4.39.1","webpack-cli":"^3.3.6","docdash":"^1.1.1","jsdoc":"^3.6.3"}}')}]); \ No newline at end of file +var n=i(9),r=i(10),s=i(11);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return A(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function A(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return E(this,t,e,i);case"latin1":case"binary":return w(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function B(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||N(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(8))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(17);t.exports=class{constructor({w:t=window}={}){this.window=t}init(t){this.popupConfig=t}open(){const t=this.popupConfig.height,e=this.popupConfig.width,i=(window.screen.width-e)/2,r=(window.screen.height-t)/2;if(this.popup=this.window.open("","popup",`left=${i},top=${r},width=${e},height=${t},resizable,scrollbars=yes,status=1`),!this.popup)throw new n("Unable to open popup")}navigate(t){this.popup.location.href=t}close(){this.popup.close()}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(21);t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t);const i={"x-filter-type":`spa:v${n.version}`};this.publicKeys=e(this.getJwksEndpoint(),{headers:i})}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}},function(t){t.exports=JSON.parse('{"name":"ibmcloud-appid-js","version":"0.3.0","description":"IBM Cloud App ID SDK for Single Page Applications","scripts":{"build":"webpack","test":"mocha","coverage":"nyc --reporter=lcov mocha","docs":"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git"},"main":"dist/appid.umd.min.js","license":"Apache-2.0","nyc":{"all":true,"include":["src/*.js"],"exclude":["**/PopupController.js","**/IFrameController.js","**/OpenIDConfigurationResource.js","**/constants.js"]},"dependencies":{"jsrsasign":"^8.0.12"},"devDependencies":{"node-fetch":"^2.6.0","@babel/cli":"^7.0.0","@babel/core":"^7.5.5","@babel/plugin-transform-runtime":"^7.5.5","@babel/preset-env":"^7.5.5","babel-cli":"^7.0.0-beta.3","chai":"^4.2.0","coveralls":"^3.0.6","gulp-babel":"^8.0.0","mocha":"^6.2.0","nyc":"^14.1.1","webpack":"^4.39.1","webpack-cli":"^3.3.6","docdash":"^1.1.1","jsdoc":"^3.6.3"}}')}]); \ No newline at end of file diff --git a/dist/appid.umd.min.js b/dist/appid.umd.min.js index 35ad0e0..fa24daf 100644 --- a/dist/appid.umd.min.js +++ b/dist/appid.umd.min.js @@ -47,4 +47,4 @@ var lt=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(? * @author Feross Aboukhadijeh * @license MIT */ -var n=i(9),r=i(10),s=i(11);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return A(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function A(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return w(this,t,e,i);case"latin1":case"binary":return E(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function B(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||N(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(8))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(17);t.exports=class{constructor({w:t=window}={}){this.window=t}init(t){this.popupConfig=t}open(){const t=this.popupConfig.height,e=this.popupConfig.width,i=(window.screen.width-e)/2,r=(window.screen.height-t)/2;if(this.popup=this.window.open("","popup",`left=${i},top=${r},width=${e},height=${t},resizable,scrollbars=yes,status=1`),!this.popup)throw new n("Unable to open popup")}navigate(t){this.popup.location.href=t}close(){this.popup.close()}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(21);t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t);const i={"x-filter-type":`spa:v${n.version}`};this.publicKeys=e(this.getJwksEndpoint(),{headers:i})}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}},function(t){t.exports=JSON.parse('{"name":"ibmcloud-appid-js","version":"0.3.0","description":"IBM Cloud App ID SDK for Single Page Applications","scripts":{"build":"webpack","test":"mocha","coverage":"nyc --reporter=lcov mocha","docs":"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git"},"main":"dist/appid.umd.min.js","nyc":{"all":true,"include":["src/*.js"],"exclude":["**/PopupController.js","**/IFrameController.js","**/OpenIDConfigurationResource.js","**/constants.js"]},"dependencies":{"jsrsasign":"^8.0.12"},"devDependencies":{"node-fetch":"^2.6.0","@babel/cli":"^7.0.0","@babel/core":"^7.5.5","@babel/plugin-transform-runtime":"^7.5.5","@babel/preset-env":"^7.5.5","babel-cli":"^7.0.0-beta.3","chai":"^4.2.0","coveralls":"^3.0.6","gulp-babel":"^8.0.0","mocha":"^6.2.0","nyc":"^14.1.1","webpack":"^4.39.1","webpack-cli":"^3.3.6","docdash":"^1.1.1","jsdoc":"^3.6.3"}}')}])})); \ No newline at end of file +var n=i(9),r=i(10),s=i(11);function o(){return h.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function g(t,e){if(h.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var i=t.length;if(0===i)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return k(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return M(t).length;default:if(n)return k(t).length;e=(""+e).toLowerCase(),n=!0}}function p(t,e,i){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,i);case"utf8":case"utf-8":return I(this,e,i);case"ascii":return D(this,e,i);case"latin1":case"binary":return T(this,e,i);case"base64":return A(this,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,i);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function v(t,e,i,n,r){if(0===t.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:t.length-1),i<0&&(i=t.length+i),i>=t.length){if(r)return-1;i=t.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:m(t,e,i,n,r);if("number"==typeof e)return e&=255,h.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,i):Uint8Array.prototype.lastIndexOf.call(t,e,i):m(t,[e],i,n,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,i,n,r){var s,o=1,a=t.length,h=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,i/=2}function u(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){var c=-1;for(s=i;sa&&(i=a-h),s=i;s>=0;s--){for(var l=!0,f=0;fr&&(n=r):n=r;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,r=i%256,s.push(r),s.push(n);return s}(e,t.length-i),t,i,n)}function A(t,e,i){return 0===e&&i===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,i))}function I(t,e,i){i=Math.min(t.length,i);for(var n=[],r=e;r239?4:u>223?3:u>191?2:1;if(r+l<=i)switch(l){case 1:u<128&&(c=u);break;case 2:128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)>127&&(c=h);break;case 3:s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&(h=(15&u)<<12|(63&s)<<6|63&o)>2047&&(h<55296||h>57343)&&(c=h);break;case 4:s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&h<1114112&&(c=h)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),r+=l}return function(t){var e=t.length;if(e<=C)return String.fromCharCode.apply(String,t);var i="",n=0;for(;n0&&(t=this.toString("hex",0,i).match(/.{2}/g).join(" "),this.length>i&&(t+=" ... ")),""},h.prototype.compare=function(t,e,i,n,r){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===i&&(i=t?t.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),e<0||i>t.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&e>=i)return 0;if(n>=r)return-1;if(e>=i)return 1;if(this===t)return 0;for(var s=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,r),c=t.slice(e,i),l=0;lr)&&(i=r),t.length>0&&(i<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return S(this,t,e,i);case"utf8":case"utf-8":return F(this,t,e,i);case"ascii":return w(this,t,e,i);case"latin1":case"binary":return E(this,t,e,i);case"base64":return x(this,t,e,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,e,i);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var C=4096;function D(t,e,i){var n="";i=Math.min(t.length,i);for(var r=e;rn)&&(i=n);for(var r="",s=e;si)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,i,n,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function B(t,e,i,n){e<0&&(e=65535+e+1);for(var r=0,s=Math.min(t.length-i,2);r>>8*(n?r:1-r)}function O(t,e,i,n){e<0&&(e=4294967295+e+1);for(var r=0,s=Math.min(t.length-i,4);r>>8*(n?r:3-r)&255}function j(t,e,i,n,r,s){if(i+n>t.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function V(t,e,i,n,s){return s||j(t,0,i,4),r.write(t,e,i,n,23,4),i+4}function L(t,e,i,n,s){return s||j(t,0,i,8),r.write(t,e,i,n,52,8),i+8}h.prototype.slice=function(t,e){var i,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e0&&(r*=256);)n+=this[t+--e]*r;return n},h.prototype.readUInt8=function(t,e){return e||H(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return e||H(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return e||H(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return e||H(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return e||H(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=this[t],r=1,s=0;++s=(r*=128)&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,i){t|=0,e|=0,i||H(t,e,this.length);for(var n=e,r=1,s=this[t+--n];n>0&&(r*=256);)s+=this[t+--n]*r;return s>=(r*=128)&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return e||H(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){e||H(t,2,this.length);var i=this[t]|this[t+1]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt16BE=function(t,e){e||H(t,2,this.length);var i=this[t+1]|this[t]<<8;return 32768&i?4294901760|i:i},h.prototype.readInt32LE=function(t,e){return e||H(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return e||H(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return e||H(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return e||H(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,i,n){(t=+t,e|=0,i|=0,n)||N(this,t,e,i,Math.pow(2,8*i)-1,0);var r=1,s=0;for(this[e]=255&t;++s=0&&(s*=256);)this[e+r]=t/s&255;return e+i},h.prototype.writeUInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,255,0),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeUInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,65535,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeUInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):O(this,t,e,!0),e+4},h.prototype.writeUInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,4294967295,0),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeIntLE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+i},h.prototype.writeIntBE=function(t,e,i,n){if(t=+t,e|=0,!n){var r=Math.pow(2,8*i-1);N(this,t,e,i,r-1,-r)}var s=i-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+i},h.prototype.writeInt8=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,1,127,-128),h.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):B(this,t,e,!0),e+2},h.prototype.writeInt16BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,2,32767,-32768),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):B(this,t,e,!1),e+2},h.prototype.writeInt32LE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),h.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):O(this,t,e,!0),e+4},h.prototype.writeInt32BE=function(t,e,i){return t=+t,e|=0,i||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),h.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):O(this,t,e,!1),e+4},h.prototype.writeFloatLE=function(t,e,i){return V(this,t,e,!0,i)},h.prototype.writeFloatBE=function(t,e,i){return V(this,t,e,!1,i)},h.prototype.writeDoubleLE=function(t,e,i){return L(this,t,e,!0,i)},h.prototype.writeDoubleBE=function(t,e,i){return L(this,t,e,!1,i)},h.prototype.copy=function(t,e,i,n){if(i||(i=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--r)t[r+e]=this[r+i];else if(s<1e3||!h.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,t||(t=0),"number"==typeof t)for(s=e;s55295&&i<57344){if(!r){if(i>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}r=i;continue}if(i<56320){(e-=3)>-1&&s.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,i<128){if((e-=1)<0)break;s.push(i)}else if(i<2048){if((e-=2)<0)break;s.push(i>>6|192,63&i|128)}else if(i<65536){if((e-=3)<0)break;s.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return s}function M(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(_,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function U(t,e,i,n){for(var r=0;r=e.length||r>=t.length);++r)e[r+i]=t[r];return r}}).call(this,i(8))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,i){"use strict";e.byteLength=function(t){var e=u(t),i=e[0],n=e[1];return 3*(i+n)/4-n},e.toByteArray=function(t){var e,i,n=u(t),o=n[0],a=n[1],h=new s(function(t,e,i){return 3*(e+i)/4-i}(0,o,a)),c=0,l=a>0?o-4:o;for(i=0;i>16&255,h[c++]=e>>8&255,h[c++]=255&e;2===a&&(e=r[t.charCodeAt(i)]<<2|r[t.charCodeAt(i+1)]>>4,h[c++]=255&e);1===a&&(e=r[t.charCodeAt(i)]<<10|r[t.charCodeAt(i+1)]<<4|r[t.charCodeAt(i+2)]>>2,h[c++]=e>>8&255,h[c++]=255&e);return h},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=0,a=i-r;oa?a:o+16383));1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],r=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var i=t.indexOf("=");return-1===i&&(i=e),[i,i===e?0:4-i%4]}function c(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,h=(1<>1,c=-7,l=i?r-1:0,f=i?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-c)-1,d>>=-c,c+=a;c>0;s=256*s+t[e+l],l+=f,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+l],l+=f,c-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=u}return(d?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,h,u=8*s-r-1,c=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,g=n?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=c?(a=0,o=c):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[i+d]=255&a,d+=g,a/=256,r-=8);for(o=o<0;t[i+d]=255&o,d+=g,o/=256,u-=8);t[i+d-g]|=128*p}},function(t,e){var i={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},function(t,e){t.exports=class extends Error{constructor({error:t,description:e}){super(e||t),this.error=t,this.description=e}}},function(t,e,i){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();t.exports=e=n.fetch,e.default=n.fetch.bind(n),e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response},function(t,e){t.exports=class extends Error{constructor(t,e,i){super(t),this.status=e,this.originError=i}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(17);t.exports=class{constructor({w:t=window}={}){this.window=t}init(t){this.popupConfig=t}open(){const t=this.popupConfig.height,e=this.popupConfig.width,i=(window.screen.width-e)/2,r=(window.screen.height-t)/2;if(this.popup=this.window.open("","popup",`left=${i},top=${r},width=${e},height=${t},resizable,scrollbars=yes,status=1`),!this.popup)throw new n("Unable to open popup")}navigate(t){this.popup.location.href=t}close(){this.popup.close()}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{this.popup.closed&&(clearInterval(r),i(new n("Popup closed")))},1e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&e(i)})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(19);t.exports=class{constructor({w:t=window}={}){this.window=t}open(t){this.iFrame=this.window.document.createElement("iframe"),this.iFrame.src=t,this.iFrame.width=0,this.iFrame.height=0,this.window.document.body.appendChild(this.iFrame)}remove(){window.document.body.removeChild(this.iFrame)}async waitForMessage({messageType:t}){return new Promise((e,i)=>{const r=setInterval(()=>{i(new n("Silent sign-in timed out"))},5e3);window.addEventListener("message",i=>{i.data&&i.data.type===t&&(clearInterval(r),e(i))})})}}},function(t,e){t.exports=class extends Error{}},function(t,e,i){const n=i(21);t.exports=class{async init({discoveryEndpoint:t,requestHandler:e}){this.openIdConfig=await e(t);const i={"x-filter-type":`spa:v${n.version}`};this.publicKeys=e(this.getJwksEndpoint(),{headers:i})}getAuthorizationEndpoint(){return this.openIdConfig.authorization_endpoint}getUserInfoEndpoint(){return this.openIdConfig.userinfo_endpoint}getJwksEndpoint(){return this.openIdConfig.jwks_uri}getTokenEndpoint(){return this.openIdConfig.token_endpoint}getIssuer(){return this.openIdConfig.issuer}async getPublicKeys(){return await this.publicKeys}}},function(t){t.exports=JSON.parse('{"name":"ibmcloud-appid-js","version":"0.3.0","description":"IBM Cloud App ID SDK for Single Page Applications","scripts":{"build":"webpack","test":"mocha","coverage":"nyc --reporter=lcov mocha","docs":"jsdoc src/index.js src/errors -t node_modules/docdash --readme README.md --destination docs -c jsdoc.json"},"repository":{"type":"git","url":"git+https://github.com/ibm-cloud-security/appid-clientsdk-js.git"},"main":"dist/appid.umd.min.js","license":"Apache-2.0","nyc":{"all":true,"include":["src/*.js"],"exclude":["**/PopupController.js","**/IFrameController.js","**/OpenIDConfigurationResource.js","**/constants.js"]},"dependencies":{"jsrsasign":"^8.0.12"},"devDependencies":{"node-fetch":"^2.6.0","@babel/cli":"^7.0.0","@babel/core":"^7.5.5","@babel/plugin-transform-runtime":"^7.5.5","@babel/preset-env":"^7.5.5","babel-cli":"^7.0.0-beta.3","chai":"^4.2.0","coveralls":"^3.0.6","gulp-babel":"^8.0.0","mocha":"^6.2.0","nyc":"^14.1.1","webpack":"^4.39.1","webpack-cli":"^3.3.6","docdash":"^1.1.1","jsdoc":"^3.6.3"}}')}])})); \ No newline at end of file diff --git a/sample/package-lock.json b/sample/package-lock.json deleted file mode 100644 index be28411..0000000 --- a/sample/package-lock.json +++ /dev/null @@ -1,374 +0,0 @@ -{ - "name": "sample", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "accepts": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", - "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", - "requires": { - "mime-types": "~2.1.24", - "negotiator": "0.6.2" - } - }, - "array-flatten": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" - }, - "body-parser": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", - "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", - "requires": { - "bytes": "3.1.0", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "~1.1.2", - "http-errors": "1.7.2", - "iconv-lite": "0.4.24", - "on-finished": "~2.3.0", - "qs": "6.7.0", - "raw-body": "2.4.0", - "type-is": "~1.6.17" - } - }, - "bytes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", - "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" - }, - "content-disposition": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", - "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", - "requires": { - "safe-buffer": "5.1.2" - } - }, - "content-type": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" - }, - "cookie": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", - "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" - }, - "cookie-signature": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "requires": { - "ms": "2.0.0" - } - }, - "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" - }, - "destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" - }, - "ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" - }, - "encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" - }, - "escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" - }, - "etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" - }, - "express": { - "version": "4.17.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", - "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", - "requires": { - "accepts": "~1.3.7", - "array-flatten": "1.1.1", - "body-parser": "1.19.0", - "content-disposition": "0.5.3", - "content-type": "~1.0.4", - "cookie": "0.4.0", - "cookie-signature": "1.0.6", - "debug": "2.6.9", - "depd": "~1.1.2", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "finalhandler": "~1.1.2", - "fresh": "0.5.2", - "merge-descriptors": "1.0.1", - "methods": "~1.1.2", - "on-finished": "~2.3.0", - "parseurl": "~1.3.3", - "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.5", - "qs": "6.7.0", - "range-parser": "~1.2.1", - "safe-buffer": "5.1.2", - "send": "0.17.1", - "serve-static": "1.14.1", - "setprototypeof": "1.1.1", - "statuses": "~1.5.0", - "type-is": "~1.6.18", - "utils-merge": "1.0.1", - "vary": "~1.1.2" - } - }, - "finalhandler": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", - "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", - "requires": { - "debug": "2.6.9", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "on-finished": "~2.3.0", - "parseurl": "~1.3.3", - "statuses": "~1.5.0", - "unpipe": "~1.0.0" - } - }, - "forwarded": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", - "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" - }, - "fresh": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" - }, - "http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.1", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" - } - }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" - }, - "ipaddr.js": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", - "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" - }, - "media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" - }, - "merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" - }, - "methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" - }, - "mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" - }, - "mime-db": { - "version": "1.40.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", - "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" - }, - "mime-types": { - "version": "2.1.24", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", - "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", - "requires": { - "mime-db": "1.40.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - }, - "negotiator": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", - "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" - }, - "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", - "requires": { - "ee-first": "1.1.1" - } - }, - "parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" - }, - "path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" - }, - "proxy-addr": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", - "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", - "requires": { - "forwarded": "~0.1.2", - "ipaddr.js": "1.9.0" - } - }, - "qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" - }, - "range-parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" - }, - "raw-body": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", - "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", - "requires": { - "bytes": "3.1.0", - "http-errors": "1.7.2", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" - }, - "send": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", - "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", - "requires": { - "debug": "2.6.9", - "depd": "~1.1.2", - "destroy": "~1.0.4", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "fresh": "0.5.2", - "http-errors": "~1.7.2", - "mime": "1.6.0", - "ms": "2.1.1", - "on-finished": "~2.3.0", - "range-parser": "~1.2.1", - "statuses": "~1.5.0" - }, - "dependencies": { - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" - } - } - }, - "serve-static": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", - "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", - "requires": { - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "parseurl": "~1.3.3", - "send": "0.17.1" - } - }, - "setprototypeof": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", - "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" - }, - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" - }, - "toidentifier": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", - "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" - }, - "type-is": { - "version": "1.6.18", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", - "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", - "requires": { - "media-typer": "0.3.0", - "mime-types": "~2.1.24" - } - }, - "unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" - }, - "utils-merge": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" - }, - "vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" - } - } -} diff --git a/sample/public/index.css b/sample/public/index.css index 5c4b2c6..79f62cb 100644 --- a/sample/public/index.css +++ b/sample/public/index.css @@ -58,6 +58,24 @@ body { margin-bottom: 59px; } +.loader { + border: 16px solid #f3f3f3; /* Light grey */ + border-top: 16px solid #4178BE; /* Blue */ + border-radius: 50%; + width: 40px; + height: 40px; + animation: spin 1s linear infinite; +} + +@keyframes spin { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } +} + +#passwordChanged { + color: #018033; +} + .button { font-family: IBMPlexSans-Medium; font-size: 14px; diff --git a/sample/public/index.html b/sample/public/index.html index fda76a0..94b14e8 100644 --- a/sample/public/index.html +++ b/sample/public/index.html @@ -16,9 +16,12 @@

+
+ - + +
@@ -34,27 +37,37 @@ document.getElementById('login').setAttribute('class', 'button'); } + function success(decodeIDToken) { + document.getElementById('welcome').textContent = 'Hello, ' + decodeIDToken.name; + document.getElementById('id_token').textContent = JSON.stringify(decodeIDToken); + document.getElementById('changePassword').setAttribute('class', 'button'); + document.getElementById('changeDetails').setAttribute('class', 'button'); + } + (async function () { const appID = new AppID(); let tokens; try { await appID.init({ - clientId: '', - discoveryEndpoint: '' + clientId: '1b0e3658-fc1f-402e-843c-18402d4dbe58', + discoveryEndpoint: 'http://localhost:6002/oauth/v4/5b1eb5f1-34bd-41fd-b6dd-e257c188a4dd/.well-known/openid-configuration' }); } catch (e) { console.error(e); document.getElementById('error').textContent = e; return; } - try { - tokens = await appID.silentSignin(); - if (tokens) { - document.getElementById('id_token').textContent = JSON.stringify(tokens.idTokenPayload); - } - } catch (e) { - showError(e); - } + // try { + // tokens = await appID.silentSignin(); + // if (tokens) { + // document.getElementById('loader').setAttribute('class', 'hidden'); + // document.getElementById('login').setAttribute('class', 'hidden'); + // success(tokens.idTokenPayload); + // } + // } catch (e) { + // document.getElementById('loader').setAttribute('class', 'hidden'); + // showError(e); + // } document.getElementById('login').addEventListener('click', async () => { document.getElementById('login').setAttribute('class', 'hidden'); document.getElementById('error').textContent = ''; @@ -62,20 +75,34 @@ try { tokens = await appID.signin(); let userInfo = await appID.getUserInfo(tokens.accessToken); - let decodeIDToken = tokens.idTokenPayload; - document.getElementById('welcome').textContent = 'Hello, ' + decodeIDToken.name; - document.getElementById('id_token').textContent = JSON.stringify(decodeIDToken); - document.getElementById('user_info').textContent = JSON.stringify(userInfo); + success(tokens.idTokenPayload); } catch (e) { showError(e); } }); document.getElementById('changePassword').addEventListener('click', async () => { + document.getElementById('passwordChanged').textContent = ''; + document.getElementById('error').textContent = ''; + try { + tokens = await appID.changePassword(tokens.idToken); + document.getElementById('passwordChanged').textContent = 'Your password is changed.'; + } catch (e) { + showError(e); + document.getElementById('login').setAttribute('class', 'hidden'); + } + }); + + document.getElementById('changeDetails').addEventListener('click', async () => { + document.getElementById('passwordChanged').textContent = ''; + document.getElementById('error').textContent = ''; try { - await appID.changePassword(tokens.idToken); + tokens = await appID.changeDetails(tokens); + success(tokens.idTokenPayload); + document.getElementById('passwordChanged').textContent = 'Your details is changed.'; } catch (e) { showError(e); + document.getElementById('login').setAttribute('class', 'hidden'); } }); })() From 117b74e0993474e123402f4c272a68b8736b4a69 Mon Sep 17 00:00:00 2001 From: Joyce Huang Date: Wed, 6 Nov 2019 11:26:14 -0600 Subject: [PATCH 9/9] update sample app --- sample/public/index.html | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sample/public/index.html b/sample/public/index.html index 94b14e8..4143632 100644 --- a/sample/public/index.html +++ b/sample/public/index.html @@ -18,8 +18,8 @@
- - +
+
@@ -49,25 +49,25 @@ let tokens; try { await appID.init({ - clientId: '1b0e3658-fc1f-402e-843c-18402d4dbe58', - discoveryEndpoint: 'http://localhost:6002/oauth/v4/5b1eb5f1-34bd-41fd-b6dd-e257c188a4dd/.well-known/openid-configuration' + clientId: '', + discoveryEndpoint: '' }); } catch (e) { console.error(e); document.getElementById('error').textContent = e; return; } - // try { - // tokens = await appID.silentSignin(); - // if (tokens) { - // document.getElementById('loader').setAttribute('class', 'hidden'); - // document.getElementById('login').setAttribute('class', 'hidden'); - // success(tokens.idTokenPayload); - // } - // } catch (e) { - // document.getElementById('loader').setAttribute('class', 'hidden'); - // showError(e); - // } + try { + tokens = await appID.silentSignin(); + if (tokens) { + document.getElementById('loader').setAttribute('class', 'hidden'); + document.getElementById('login').setAttribute('class', 'hidden'); + success(tokens.idTokenPayload); + } + } catch (e) { + document.getElementById('loader').setAttribute('class', 'hidden'); + showError(e); + } document.getElementById('login').addEventListener('click', async () => { document.getElementById('login').setAttribute('class', 'hidden'); document.getElementById('error').textContent = '';