oauth3.js/oauth3.crypto.fallback.min.js

8 lines
228 KiB
JavaScript
Raw Normal View History

2017-03-30 00:33:06 +00:00
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.OAUTH3_crypto_fallback=e()}}(function(){return function e(t,r,i){function n(a,s){if(!r[a]){if(!t[a]){var o="function"==typeof require&&require;if(!s&&o)return o(a,!0);if(f)return f(a,!0);var h=new Error("Cannot find module '"+a+"'");throw h.code="MODULE_NOT_FOUND",h}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return n(r||e)},c,c.exports,e,t,r,i)}return r[a].exports}for(var f="function"==typeof require&&require,a=0;a<i.length;a++)n(i[a]);return n}({1:[function(e,t,r){(function(t){!function(){"use strict";function i(e){return l("sha256").update(e).digest()}function n(e,r){return b.pbkdf2Sync(e,t(r),8192,16,"sha256")}function f(e,r,i){var n=p.createCipheriv("aes-128-gcm",t(e),t(r));return t.concat([n.update(t(i)),n.final(),n.getAuthTag()])}function a(e,r,i){var n=p.createDecipheriv("aes-128-gcm",t(e),t(r));return n.setAuthTag(t(i.slice(-16))),t.concat([n.update(t(i.slice(0,-16))),n.final()])}function s(e,r){var i=e.toArrayLike(t);if(!r||i.length===r)return i;if(i.length<r)return t.concat([t(r-i.length).fill(0),i]);if(i.length>r)throw new Error("EC signature number bigger than expected");throw new Error('invalid size "'+r+'" converting BigNumber to Buffer')}function o(e){return s(e).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=*$/,"")}function h(){var e=m.genKeyPair(),t={key_ops:["verify"],kty:"EC",crv:"P-256",x:o(e.getPublic().getX()),y:o(e.getPublic().getY())},r=JSON.parse(JSON.stringify(t));return r.key_ops=["sign"],r.d=o(e.getPrivate()),{privateKey:r,publicKey:t}}function c(e,r){var n=m.keyFromPrivate(t(e.d,"base64")),f=n.sign(i(r));return t.concat([s(f.r,32),s(f.s,32)])}function d(e,r,n){var f=m.keyFromPublic({x:t(e.x,"base64"),y:t(e.y,"base64")}),a={r:t(n.slice(0,n.length/2)),s:t(n.slice(n.length/2))};return f.verify(i(r),a)}function u(e){return function(){var t=arguments;return new OAUTH3.PromiseA(function(r){r(e.apply(null,t))})}}var l=e("create-hash"),b=e("pbkdf2"),p=e("browserify-aes"),m=e("elliptic/lib/elliptic/ec")("p256");r.sha256=u(i),r.pbkdf2=u(n),r.encrypt=u(f),r.decrypt=u(a),r.sign=u(c),r.verify=u(d),r.genEcdsaKeyPair=u(h)}()}).call(this,e("buffer").Buffer)},{"browserify-aes":8,buffer:23,"create-hash":26,"elliptic/lib/elliptic/ec":37,pbkdf2:61}],2:[function(e,t,r){"use strict";function i(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function n(e){return 3*e.length/4-i(e)}function f(e){var t,r,n,f,a,s,o=e.length;a=i(e),s=new d(3*o/4-a),n=a>0?o-4:o;var h=0;for(t=0,r=0;t<n;t+=4,r+=3)f=c[e.charCodeAt(t)]<<18|c[e.charCodeAt(t+1)]<<12|c[e.charCodeAt(t+2)]<<6|c[e.charCodeAt(t+3)],s[h++]=f>>16&255,s[h++]=f>>8&255,s[h++]=255&f;return 2===a?(f=c[e.charCodeAt(t)]<<2|c[e.charCodeAt(t+1)]>>4,s[h++]=255&f):1===a&&(f=c[e.charCodeAt(t)]<<10|c[e.charCodeAt(t+1)]<<4|c[e.charCodeAt(t+2)]>>2,s[h++]=f>>8&255,s[h++]=255&f),s}function a(e){return h[e>>18&63]+h[e>>12&63]+h[e>>6&63]+h[63&e]}function s(e,t,r){for(var i,n=[],f=t;f<r;f+=3)i=(e[f]<<16)+(e[f+1]<<8)+e[f+2],n.push(a(i));return n.join("")}function o(e){for(var t,r=e.length,i=r%3,n="",f=[],a=0,o=r-i;a<o;a+=16383)f.push(s(e,a,a+16383>o?o:a+16383));return 1===i?(t=e[r-1],n+=h[t>>2],n+=h[t<<4&63],n+="=="):2===i&&(t=(e[r-2]<<8)+e[r-1],n+=h[t>>10],n+=h[t>>4&63],n+=h[t<<2&63],n+="="),f.push(n),f.join("")}r.byteLength=n,r.toByteArray=f,r.fromByteArray=o;for(var h=[],c=[],d="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,b=u.length;l<b;++l)h[l]=u[l],c[u.charCodeAt(l)]=l;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63},{}],3:[function(e,t,r){!function(t,r){"use strict";function i(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r
;return!(this.length<=r)&&!!(this.words[r]&n)},f.prototype.imaskn=function(e){i("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var n=67108863^67108863>>>t<<t;this.words[this.length-1]&=n}return this.strip()},f.prototype.maskn=function(e){return this.clone().imaskn(e)},f.prototype.iaddn=function(e){return i("number"==typeof e),i(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},f.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},f.prototype.isubn=function(e){if(i("number"==typeof e),i(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},f.prototype.addn=function(e){return this.clone().iaddn(e)},f.prototype.subn=function(e){return this.clone().isubn(e)},f.prototype.iabs=function(){return this.negative=0,this},f.prototype.abs=function(){return this.clone().iabs()},f.prototype._ishlnsubmul=function(e,t,r){var n,f=e.length+r;this._expand(f);var a,s=0;for(n=0;n<e.length;n++){a=(0|this.words[n+r])+s;var o=(0|e.words[n])*t;a-=67108863&o,s=(a>>26)-(o/67108864|0),this.words[n+r]=67108863&a}for(;n<this.length-r;n++)a=(0|this.words[n+r])+s,s=a>>26,this.words[n+r]=67108863&a;if(0===s)return this.strip();for(i(s===-1),s=0,n=0;n<this.length;n++)a=-(0|this.words[n])+s,s=a>>26,this.words[n]=67108863&a;return this.negative=1,this.strip()},f.prototype._wordDiv=function(e,t){var r=this.length-e.length,i=this.clone(),n=e,a=0|n.words[n.length-1];0!==(r=26-this._countBits(a))&&(n=n.ushln(r),i.iushln(r),a=0|n.words[n.length-1]);var s,o=i.length-n.length;if("mod"!==t){s=new f(null),s.length=o+1,s.words=new Array(s.length);for(var h=0;h<s.length;h++)s.words[h]=0}var c=i.clone()._ishlnsubmul(n,1,o);0===c.negative&&(i=c,s&&(s.words[o]=1));for(var d=o-1;d>=0;d--){var u=67108864*(0|i.words[n.length+d])+(0|i.words[n.length+d-1]);for(u=Math.min(u/a|0,67108863),i._ishlnsubmul(n,u,d);0!==i.negative;)u--,i.negative=0,i._ishlnsubmul(n,1,d),i.isZero()||(i.negative^=1);s&&(s.words[d]=u)}return s&&s.strip(),i.strip(),"div"!==t&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},f.prototype.divmod=function(e,t,r){if(i(!e.isZero()),this.isZero())return{div:new f(0),mod:new f(0)};var n,a,s;return 0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(n=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:n,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(n=s.div.neg()),{div:n,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new f(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new f(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new f(this.modn(e.words[0]))}:this._wordDiv(e,t)},f.prototype.div=function(e){return this.divmod(e,"div",!1).div},f.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},f.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},f.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,i=e.ushrn(1),n=e.andln(1),f=r.cmp(i);return f<0||1===n&&0===f?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},f.prototype.modn=function(e){i(e<=67108863);for(var t=(1<<26)%e,r=0,n=this.length-1;n>=0;n--)r=(t*r+(0|this.words[n]))%e;return r},f.prototype.idi
var n=e("./aes"),f=e("cipher-base");e("inherits")(i,f),t.exports=i,i.prototype._update=function(e){return this._mode.encrypt(this,e,this._decrypt)},i.prototype._final=function(){this._cipher.scrub()}}).call(this,e("buffer").Buffer)},{"./aes":6,buffer:23,"cipher-base":24,inherits:56}],21:[function(e,t,r){(function(t){"use strict";var i=e("buffer"),n=i.Buffer,f=i.SlowBuffer,a=i.kMaxLength||2147483647;r.alloc=function(e,t,r){if("function"==typeof n.alloc)return n.alloc(e,t,r);if("number"==typeof r)throw new TypeError("encoding must not be number");if("number"!=typeof e)throw new TypeError("size must be a number");if(e>a)throw new RangeError("size is too large");var i=r,f=t;void 0===f&&(i=void 0,f=0);var s=new n(e);if("string"==typeof f)for(var o=new n(f,i),h=o.length,c=-1;++c<e;)s[c]=o[c%h];else s.fill(f);return s},r.allocUnsafe=function(e){if("function"==typeof n.allocUnsafe)return n.allocUnsafe(e);if("number"!=typeof e)throw new TypeError("size must be a number");if(e>a)throw new RangeError("size is too large");return new n(e)},r.from=function(e,r,i){if("function"==typeof n.from&&(!t.Uint8Array||Uint8Array.from!==n.from))return n.from(e,r,i);if("number"==typeof e)throw new TypeError('"value" argument must not be a number');if("string"==typeof e)return new n(e,r);if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer){var f=r;if(1===arguments.length)return new n(e);void 0===f&&(f=0);var a=i;if(void 0===a&&(a=e.byteLength-f),f>=e.byteLength)throw new RangeError("'offset' is out of bounds");if(a>e.byteLength-f)throw new RangeError("'length' is out of bounds");return new n(e.slice(f,f+a))}if(n.isBuffer(e)){var s=new n(e.length);return e.copy(s,0,0,e.length),s}if(e){if(Array.isArray(e)||"undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return new n(e);if("Buffer"===e.type&&Array.isArray(e.data))return new n(e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},r.allocUnsafeSlow=function(e){if("function"==typeof n.allocUnsafeSlow)return n.allocUnsafeSlow(e);if("number"!=typeof e)throw new TypeError("size must be a number");if(e>=a)throw new RangeError("size is too large");return new f(e)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{buffer:23}],22:[function(e,t,r){(function(e){t.exports=function(t,r){for(var i=Math.min(t.length,r.length),n=new e(i),f=0;f<i;++f)n[f]=t[f]^r[f];return n}}).call(this,e("buffer").Buffer)},{buffer:23}],23:[function(e,t,r){"use strict";function i(e){if(e>K)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=n.prototype,t}function n(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return o(e)}return f(e,t,r)}function f(e,t,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return e instanceof ArrayBuffer?d(e,t,r):"string"==typeof e?h(e,t):u(e)}function a(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function s(e,t,r){return a(e),e<=0?i(e):void 0!==t?"string"==typeof r?i(e).fill(t,r):i(e).fill(t):i(e)}function o(e){return a(e),i(e<0?0:0|l(e))}function h(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!n.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var r=0|p(e,t),f=i(r),a=f.write(e,t);return a!==r&&(f=f.slice(0,a)),f}function c(e){for(var t=e.length<0?0:0|l(e.length),r=i(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}function d(e,t,r){if(t<0||e.byteLength<t)throw new RangeError("'offset' is out of bounds");if(e.byteLength<t+(r||0))throw new RangeError("'length' is out of bounds");var i;return i=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),i.__proto__=n.prototype,i}function u(e){if(n.isBuffer(e)){var t=0|l(e.length),r=i(t);return 0===r.length?r:(e.copy(r,0,0,t),r)}if(e){if(ArrayBuffer.isView(e)||"length"
if(d>=0&&A++,M=M.dblp(A),d<0)break;for(var y=0;y<i;y++){var u,E=S[y];0!==E&&(E>0?u=a[y][E-1>>1]:E<0&&(u=a[y][-E-1>>1].neg()),M="affine"===u.type?M.mixedAdd(u):M.add(u))}}for(var d=0;d<i;d++)a[d]=null;return n?M:M.toP()},i.BasePoint=n,n.prototype.eq=function(){throw new Error("Not implemented")},n.prototype.validate=function(){return this.curve.validate(this)},i.prototype.decodePoint=function(e,t){e=s.toArray(e,t);var r=this.p.byteLength();if((4===e[0]||6===e[0]||7===e[0])&&e.length-1==2*r){6===e[0]?c(e[e.length-1]%2==0):7===e[0]&&c(e[e.length-1]%2==1);return this.point(e.slice(1,1+r),e.slice(1+r,1+2*r))}if((2===e[0]||3===e[0])&&e.length-1===r)return this.pointFromX(e.slice(1,1+r),3===e[0]);throw new Error("Unknown point format")},n.prototype.encodeCompressed=function(e){return this.encode(e,!0)},n.prototype._encode=function(e){var t=this.curve.p.byteLength(),r=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",t))},n.prototype.encode=function(e,t){return s.encode(this._encode(t),e)},n.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},n.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return!!t&&t.points.length>=Math.ceil((e.bitLength()+1)/t.step)},n.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n<t;n+=e){for(var f=0;f<e;f++)i=i.dbl();r.push(i)}return{step:e,points:r}},n.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],r=(1<<e)-1,i=1===r?null:this.dbl(),n=1;n<r;n++)t[n]=t[n-1].add(i);return{wnd:e,points:t}},n.prototype._getBeta=function(){return null},n.prototype.dblp=function(e){for(var t=this,r=0;r<e;r++)t=t.dbl();return t}},{"../../elliptic":30,"bn.js":3}],32:[function(e,t,r){"use strict";function i(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&(0|e.a)==-1,this.extended=this.mOneA,h.call(this,"edwards",e),this.a=new s(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new s(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new s(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),c(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function n(e,t,r,i,n){h.BasePoint.call(this,e,"projective"),null===t&&null===r&&null===i?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new s(t,16),this.y=new s(r,16),this.z=i?new s(i,16):this.curve.one,this.t=n&&new s(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}var f=e("../curve"),a=e("../../elliptic"),s=e("bn.js"),o=e("inherits"),h=f.base,c=a.utils.assert;o(i,h),t.exports=i,i.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},i.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},i.prototype.jpoint=function(e,t,r,i){return this.point(e,t,r,i)},i.prototype.pointFromX=function(e,t){e=new s(e,16),e.red||(e=e.toRed(this.red));var r=e.redSqr(),i=this.c2.redSub(this.a.redMul(r)),n=this.one.redSub(this.c2.redMul(this.d).redMul(r)),f=i.redMul(n.redInvm()),a=f.redSqrt();if(0!==a.redSqr().redSub(f).cmp(this.zero))throw new Error("invalid point");var o=a.fromRed().isOdd();return(t&&!o||!t&&o)&&(a=a.redNeg()),this.point(e,a)},i.prototype.pointFromY=function(e,t){e=new s(e,16),e.red||(e=e.toRed(this.red));var r=e.redSqr(),i=r.redSub(this.one),n=r.redMul(this.d).redAdd(this.one),f=i.redMul(n.redInvm());if(0===f.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var a=f.redSqrt();
null!==t.recoveryParam)return t.recoveryParam;for(var n=0;n<4;n++){var f;try{f=this.recoverPubKey(e,t,n)}catch(e){continue}if(f.eq(r))return n}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":30,"./key":38,"./signature":39,"bn.js":3,"hmac-drbg":54}],38:[function(e,t,r){"use strict";function i(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}var n=e("bn.js"),f=e("../../elliptic"),a=f.utils,s=a.assert;t.exports=i,i.fromPublic=function(e,t,r){return t instanceof i?t:new i(e,{pub:t,pubEnc:r})},i.fromPrivate=function(e,t,r){return t instanceof i?t:new i(e,{priv:t,privEnc:r})},i.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},i.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},i.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},i.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},i.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?s(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||s(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},i.prototype.derive=function(e){return e.mul(this.priv).getX()},i.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},i.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},i.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},{"../../elliptic":30,"bn.js":3}],39:[function(e,t,r){"use strict";function i(e,t){if(e instanceof i)return e;this._importDER(e,t)||(d(e.r&&e.s,"Signature without r or s"),this.r=new o(e.r,16),this.s=new o(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function n(){this.place=0}function f(e,t){var r=e[t.place++];if(!(128&r))return r;for(var i=15&r,n=0,f=0,a=t.place;f<i;f++,a++)n<<=8,n|=e[a];return t.place=a,n}function a(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t<r;)t++;return 0===t?e:e.slice(t)}function s(e,t){if(t<128)return void e.push(t);var r=1+(Math.log(t)/Math.LN2>>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}var o=e("bn.js"),h=e("../../elliptic"),c=h.utils,d=c.assert;t.exports=i,i.prototype._importDER=function(e,t){e=c.toArray(e,t);var r=new n;if(48!==e[r.place++])return!1;if(f(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var i=f(e,r),a=e.slice(r.place,i+r.place);if(r.place+=i,2!==e[r.place++])return!1;var s=f(e,r);if(e.length!==s+r.place)return!1;var h=e.slice(r.place,s+r.place);return 0===a[0]&&128&a[1]&&(a=a.slice(1)),0===h[0]&&128&h[1]&&(h=h.slice(1)),this.r=new o(a),this.s=new o(h),this.recoveryParam=null,!0},i.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=a(t),r=a(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];s(i,t.length),i=i.concat(t),i.push(2),s(i,r.length);var n=i.concat(r),f=[48];return s(f,n.length),f=f.concat(n),c.encode(f,e)}},{"../../elliptic":30,"bn.js":3}],40:[function(e,t,r){"use strict";function i(e){if(s("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof i))return new i(e);var e=f.curves[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}var n=e("hash.js"),f=e("../../elliptic"),a=f.utils,s=a.assert,o=a.parseBytes,h=e("./key"),c=e("./signature");t.exports=i,i.prototype.sign=function(e,t){e=o(e);var r=this.keyFromSecret(t),i=this.hashInt(r.messagePrefix(),e),n=this.g.mul(i),f=
2017-03-30 00:34:09 +00:00
points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1
2017-03-30 00:33:06 +00:00
;return f<0&&(f+=4294967296),f}function k(e,t){var r=P(e,t,19),i=P(t,e,29),n=O(e,t,6),f=r^i^n;return f<0&&(f+=4294967296),f}var I=e("../hash"),B=I.utils,R=B.assert,z=B.rotr32,j=B.rotl32,L=B.sum32,C=B.sum32_4,q=B.sum32_5,T=B.rotr64_hi,P=B.rotr64_lo,N=B.shr64_hi,O=B.shr64_lo,U=B.sum64,F=B.sum64_hi,D=B.sum64_lo,X=B.sum64_4_hi,W=B.sum64_4_lo,V=B.sum64_5_hi,H=B.sum64_5_lo,J=I.common.BlockHash,Z=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],K=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],Y=[1518500249,1859775393,2400959708,3395469782];B.inherits(i,J),r.sha256=i,i.blockSize=512,i.outSize=256,i.hmacStrength=192,i.padLength=64,i.prototype._update=function(e,t){for(var r=this.W,i=0;i<16;i++)r[i]=e[t+i];for(;i<r.length;i++)r[i]=C(b(r[i-2]),r[i-7],l(r[i-15]),r[i-16]);var n=this.h[0],f=this.h[1],a=this.h[2],s=this.h[3],c=this.h[4],p=this.h[5],m=this.h[6],v=this.h[7];R(this.k.length===r.length);for(var i=0;i<r.length;i++){var g=q(v,u(c),o(c,p,m),this.k[i],r[i]),y=L(d(n),h(n,f,a));v=m,m=p,p=c,c=L(s,g),s=a,a=f,f=n,n=L(g,y)}this.h[0]=L(this.h[0],n),this.h[1]=L(this.h[1],f),this.h[2]=L(this.h[2],a),this.h[3]=L(this.h[3],s),this.h[4]=L(this.h[4],c),this.h[5]=L(this.h[5],p),this.h[6]=L(this.h[6],m),this.h[7]=L(this.h[7],v)},i.prototype._digest=function(e){return"hex"===e?B.toHex32(this.h,"big"):B.split32(this.h,"big")},B.inherits(n,i),r.sha224=n,n.blockSize=512,n.outSize=224,n.hmacStrength=192,n.padLength=64,n.prototype._digest=function(e){return"hex"===e?B.toHex32(this.h.slice(0,7),"big"):B.split32(this.h.slice(0,7),"big")},B.inherits(f,J),r.sha512=f,f.blockSize=1024,f.outSize=512,f.hmacStrength=192,f.padLength=128,f.prototype._prepareBlock=function(e,t){for(var r=this.W,i=0;i<32;i++)r[i]=e[t+i];for(;i<r.length;i+=2){var n=E(r[i-4],r[i-3]),f=k(r[i-4],r[i-3]),a=r
r?e._writev(n,t.onwrite):e._write(n,f,t.onwrite),t.sync=!1}function u(e,t,r,i,n){--t.pendingcb,r?A(n,i):n(i),e._writableState.errorEmitted=!0,e.emit("error",i)}function l(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function b(e,t){var r=e._writableState,i=r.sync,n=r.writecb;if(l(r),t)u(e,r,i,t,n);else{var f=g(r);f||r.corked||r.bufferProcessing||!r.bufferedRequest||v(e,r),i?x(p,e,r,f,n):p(e,r,f,n)}}function p(e,t,r,i){r||m(e,t),t.pendingcb--,i(),w(e,t)}function m(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function v(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,n=new Array(i),f=t.corkedRequestsFree;f.entry=r;for(var a=0;r;)n[a]=r,r=r.next,a+=1;d(e,t,!0,t.length,n,"",f.finish),t.pendingcb++,t.lastBufferedRequest=null,f.next?(t.corkedRequestsFree=f.next,f.next=null):t.corkedRequestsFree=new M(t)}else{for(;r;){var s=r.chunk,o=r.encoding,h=r.callback;if(d(e,t,!1,t.objectMode?1:s.length,s,o,h),r=r.next,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=r,t.bufferProcessing=!1}function g(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function y(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function w(e,t){var r=g(t);return r&&(0===t.pendingcb?(y(e,t),t.finished=!0,e.emit("finish")):y(e,t)),r}function _(e,t,r){t.ending=!0,w(e,t),r&&(t.finished?A(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function M(e){var t=this;this.next=null,this.entry=null,this.finish=function(r){var i=t.entry;for(t.entry=null;i;){var n=i.callback;e.pendingcb--,n(r),i=i.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}t.exports=a;var S,A=e("process-nextick-args"),x=!r.browser&&["v0.10","v0.9."].indexOf(r.version.slice(0,5))>-1?setImmediate:A;a.WritableState=f;var E=e("core-util-is");E.inherits=e("inherits");var k,I={deprecate:e("util-deprecate")};!function(){try{k=e("stream")}catch(e){}finally{k||(k=e("events").EventEmitter)}}();var B=e("buffer").Buffer,R=e("buffer-shims");E.inherits(a,k),f.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(f.prototype,"buffer",{get:I.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var z;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(z=Function.prototype[Symbol.hasInstance],Object.defineProperty(a,Symbol.hasInstance,{value:function(e){return!!z.call(this,e)||e&&e._writableState instanceof f}})):z=function(e){return e instanceof this},a.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},a.prototype.write=function(e,t,r){var n=this._writableState,f=!1,a=B.isBuffer(e);return"function"==typeof t&&(r=t,t=null),a?t="buffer":t||(t=n.defaultEncoding),"function"!=typeof r&&(r=i),n.ended?s(this,r):(a||o(this,n,e,r))&&(n.pendingcb++,f=c(this,n,a,e,t,r)),f},a.prototype.cork=function(){this._writableState.corked++},a.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||v(this,e))},a.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},a.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},a.prototype._writev=null,a.prototype.end=function(e,t,r){var i=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||_(this,i,r)}}).call(this,e("_process"))},{"./_stream_duplex":66,_process:64,buffer:23,"buffer-shims":21,"core-util-is":25,events:46,inherits