UNPKG

etkframework

Version:

First test release of Etk over colored coins SDK

2 lines 454 kB
!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g.et=f()}}(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";var Bip38=require("bip38"),bip38=new Bip38,bipEncrypt=function(privateKeyWif,passphrase,pubAddr){return bip38.encrypt(privateKeyWif,passphrase,pubAddr)},bipDecrypt=function(encKey,passphrase){return bip38.decrypt(encKey,passphrase)};exports.bipEncrypt=bipEncrypt,exports.bipDecrypt=bipDecrypt},{bip38:28}],2:[function(require,module,exports){(function(Buffer){"use strict";var crypto=require("crypto"),pbkdf2=require("pbkdf2-sha256"),algorithm="aes-256-ctr",iterations=4096,keyLenBytes=32,hashedLen=(crypto.randomBytes(32),function(hashed,byteLen){byteLen=byteLen||16;for(var x=0,ln=hashed.length;32-ln>x;x++)hashed+=hashed[x];return new Buffer(hashed).slice(0,byteLen)}),encrypt=function(password,secret,iv,buf,encryptCB){var err;try{var key=pbkdf2(password,buf.toString("ascii"),iterations,keyLenBytes),cipher=crypto.createCipheriv(algorithm,key,iv),cipherText=cipher.update(secret,"utf8","hex")+cipher["final"]("hex");encryptCB(err,cipherText,iv)}catch(e){err=e,encryptCB(err,null,null)}},decrypt=function(password,buf,cipherText,iv,cbDecrypt){var err=void 0,key=pbkdf2(password,buf.toString("ascii"),iterations,keyLenBytes);try{if(cipherText===key&&key===iv&&null===iv)throw Error("Null Values");var decipher=crypto.createDecipheriv(algorithm,key,iv),decipherText=decipher.update(cipherText,"hex","utf8")+decipher["final"]("utf8");cbDecrypt(err,decipherText)}catch(e){cbDecrypt(err,null)}},hashCipherText=function(cipherText,password){var cipher=crypto.createCipher(algorithm,password),crypted=cipher.update(cipherText,"utf8","hex")+cipher["final"]("hex");return crypted},dehashCipherText=function(cryptedText,password){var decipher=crypto.createDecipher(algorithm,password),cipherText=decipher.update(cryptedText,"hex","utf8")+decipher["final"]("utf8");return cipherText};exports.hashedLen=hashedLen,exports.encrypt=encrypt,exports.decrypt=decrypt,exports.hashCipherText=hashCipherText,exports.dehashCipherText=dehashCipherText}).call(this,require("buffer").Buffer)},{buffer:58,crypto:68,"pbkdf2-sha256":122}],3:[function(require,module,exports){"use strict";var scrypt=require("scryptsy"),N=16384,r=8,p=2,keyLenBytes=64,savePass=function(masterpassword,slavepass){var data=scrypt(masterpassword,slavepass,N,r,p,keyLenBytes);return data=data.toString("hex")},compoundFunctionConstructor=function(){return{init:function(){this.acc=[],this.salt},push:function(arg1){this.acc.push(arg1),this._mergeHash()},_mergeHash:function(){this.acc.length>=2&&(this.salt=savePass(this.acc[0],this.acc[1]),this.acc.push(this.hash()))},unshift:function(arg1){this.acc.unshift(arg1),this._mergeHash()},hash:function(){return this.acc.splice(0,this.acc.length),this.salt}}}(),compoundedSalt=function(){if(!(arguments.length>1))throw Error("Not enough arguments. Inputs absent");for(var args=[],masterpassword="",compoundFn=Object.create(compoundFunctionConstructor),ix=0,ln=arguments.length;ln>ix;ix++)args.push(arguments[ix]);masterpassword=args[0],compoundFn.init(),args.slice(1).forEach(function(inputVal,index){compoundFn.push(inputVal)}),compoundFn.unshift(masterpassword);var res=compoundFn.hash();return res};exports.savePass=savePass,exports.compoundFunctionConstructor=compoundFunctionConstructor,exports.compoundedSalt=compoundedSalt},{scryptsy:144}],4:[function(require,module,exports){"use strict";var compoundedSalt=require("./passCrypt").compoundedSalt,pvtKeyWIFEncode=require("./wifCrypto").pvtKeyWIFEncode,pvtKeyWIFDecode=require("./wifCrypto").pvtKeyWIFDecode,hashedLen=require("./kdfCrypt").hashedLen,encrypt=require("./kdfCrypt").encrypt,hashCipherText=require("./kdfCrypt").hashCipherText,bipEncrypt=require("./bipCrypt").bipEncrypt,bipDecrypt=require("./bipCrypt").bipDecrypt,pvtKeyEnc=function(masterpassword,pubAddr,pvtKey,secret,ivInputs,bufInputs,storeCB){ivInputs.unshift(masterpassword),bufInputs.unshift(masterpassword);var ivSalt=hashedLen(hashCipherText(masterpassword,compoundedSalt.apply(this,ivInputs))),bufSalt=hashedLen(hashCipherText(masterpassword,compoundedSalt.apply(this,bufInputs))),privateKeyWif=pvtKeyWIFEncode(pvtKey);encrypt(masterpassword,secret,ivSalt,bufSalt,function(err,cipherText,iv){if(err)throw Error(err);var ivCipher=hashCipherText(cipherText,iv),storeKey=bipEncrypt(privateKeyWif,ivCipher,pubAddr);storeCB(storeKey)})},pvtKeyDec=function(masterpassword,secret,storeKey,ivInputs,bufInputs,cb){ivInputs.unshift(masterpassword),bufInputs.unshift(masterpassword);var ivSalt=hashedLen(hashCipherText(masterpassword,compoundedSalt.apply(this,ivInputs))),bufSalt=hashedLen(hashCipherText(masterpassword,compoundedSalt.apply(this,bufInputs)));encrypt(masterpassword,secret,ivSalt,bufSalt,function(err,cipherText,iv){if(err)throw Error(err);var ivCipher=hashCipherText(cipherText,iv),privateKeyWif=bipDecrypt(storeKey,ivCipher),pvtKey=pvtKeyWIFDecode(privateKeyWif);cb(pvtKey)})};exports.pvtKeyEnc=pvtKeyEnc,exports.pvtKeyDec=pvtKeyDec},{"./bipCrypt":1,"./kdfCrypt":2,"./passCrypt":3,"./wifCrypto":6}],5:[function(require,module,exports){"use strict";var compoundedSalt=require("./passCrypt").compoundedSalt,hashCipherText=require("./kdfCrypt").hashCipherText,hashedLen=require("./kdfCrypt").hashedLen,encrypt=require("./kdfCrypt").encrypt,decrypt=require("./kdfCrypt").decrypt,encryptSeed=function(masterpassword,seed,ivInputs,bufInputs,storeCB){ivInputs.unshift(masterpassword),bufInputs.unshift(masterpassword);var ivSalt=hashedLen(hashCipherText(masterpassword,compoundedSalt.apply(this,ivInputs))),bufSalt=hashedLen(hashCipherText(masterpassword,compoundedSalt.apply(this,bufInputs)));encrypt(masterpassword,seed,ivSalt,bufSalt,function(err,cipherText,iv){if(err)throw Error(err);storeCB(cipherText,iv)})},decryptSeed=function(masterpassword,cipherText,iv,bufInputs,getCB){bufInputs.unshift(masterpassword);var bufSalt=hashedLen(hashCipherText(masterpassword,compoundedSalt.apply(this,bufInputs)));decrypt(masterpassword,bufSalt,cipherText,iv,function(err,decipherText){if(err)throw Error(err);getCB(decipherText.toString("utf8"))})};exports.encryptSeed=encryptSeed,exports.decryptSeed=decryptSeed},{"./kdfCrypt":2,"./passCrypt":3}],6:[function(require,module,exports){(function(Buffer){"use strict";var cs=require("coinstring"),pvtKeyWIFDecode=function(pvtKeyBase58,version){return cs.decode(pvtKeyBase58,version||128).toString("hex")},pvtKeyWIFEncode=function(privateKeyHex,version){return cs.encode(new Buffer(privateKeyHex,"hex"),version||128)};exports.pvtKeyWIFDecode=pvtKeyWIFDecode,exports.pvtKeyWIFEncode=pvtKeyWIFEncode}).call(this,require("buffer").Buffer)},{buffer:58,coinstring:61}],7:[function(require,module,exports){(function(__dirname){"use strict";var path=require("path"),getAddr=(require("util"),path.join(__dirname,"db.json"),require("../operations/getAddrInfo").getAddr),getAddrInfo=require("../operations/getAddrInfo").getAddrInfo,getAsset=require("../operations/getAsset").getAssetData,getAssetHolder=require("../operations/getAssetHolder").getAssetHolder,getAssetMeta=require("../operations/getAssetMeta").getAssetMeta,initializer=require("../operations/initializer").et_int,issueToken=require("../operations/issueToken").issueToken,mint=require("../operations/mint").issueSend,transfer=require("../operations/send").transfer,getAddrPvtKey=require("../operations/getAddrPvtKey").getAddrPvtKey,passCrypt=require("../crypto_lib/passCrypt").compoundedSalt,pvtKeyCrypt=require("../crypto_lib/pvtKeyCrypt"),seedCrypt=require("../crypto_lib/seedCrypt"),rbTree=require("llrbtree"),et=function(){return{init:initializer,issueToken:issueToken,transfer:transfer,mint:mint,getAddr:getAddr,getAddrInfo:getAddrInfo,getAddrPvtKey:getAddrPvtKey,getAssetMeta:getAssetMeta,getAssetHolder:getAssetHolder,getAsset:getAsset,salting:passCrypt,storePvtKey:pvtKeyCrypt,storeSeed:seedCrypt,rbTree:rbTree}}();module.exports=et}).call(this,"/dist")},{"../crypto_lib/passCrypt":3,"../crypto_lib/pvtKeyCrypt":4,"../crypto_lib/seedCrypt":5,"../operations/getAddrInfo":159,"../operations/getAddrPvtKey":160,"../operations/getAsset":161,"../operations/getAssetHolder":162,"../operations/getAssetMeta":163,"../operations/initializer":164,"../operations/issueToken":165,"../operations/mint":166,"../operations/send":168,llrbtree:114,path:121,util:157}],8:[function(require,module,exports){var asn1=exports;asn1.bignum=require("bn.js"),asn1.define=require("./asn1/api").define,asn1.base=require("./asn1/base"),asn1.constants=require("./asn1/constants"),asn1.decoders=require("./asn1/decoders"),asn1.encoders=require("./asn1/encoders")},{"./asn1/api":9,"./asn1/base":11,"./asn1/constants":15,"./asn1/decoders":17,"./asn1/encoders":20,"bn.js":29}],9:[function(require,module,exports){function Entity(name,body){this.name=name,this.body=body,this.decoders={},this.encoders={}}var asn1=require("../asn1"),inherits=require("inherits"),api=exports;api.define=function(name,body){return new Entity(name,body)},Entity.prototype._createNamed=function(base){var named;try{named=require("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(e){named=function(entity){this._initNamed(entity)}}return inherits(named,base),named.prototype._initNamed=function(entity){base.call(this,entity)},new named(this)},Entity.prototype._getDecoder=function(enc){return this.decoders.hasOwnProperty(enc)||(this.decoders[enc]=this._createNamed(asn1.decoders[enc])),this.decoders[enc]},Entity.prototype.decode=function(data,enc,options){return this._getDecoder(enc).decode(data,options)},Entity.prototype._getEncoder=function(enc){return this.encoders.hasOwnProperty(enc)||(this.encoders[enc]=this._createNamed(asn1.encoders[enc])),this.encoders[enc]},Entity.prototype.encode=function(data,enc,reporter){return this._getEncoder(enc).encode(data,reporter)}},{"../asn1":8,inherits:111,vm:158}],10:[function(require,module,exports){function DecoderBuffer(base,options){return Reporter.call(this,options),Buffer.isBuffer(base)?(this.base=base,this.offset=0,void(this.length=base.length)):void this.error("Input not Buffer")}function EncoderBuffer(value,reporter){if(Array.isArray(value))this.length=0,this.value=value.map(function(item){return item instanceof EncoderBuffer||(item=new EncoderBuffer(item,reporter)),this.length+=item.length,item},this);else if("number"==typeof value){if(!(value>=0&&255>=value))return reporter.error("non-byte EncoderBuffer value");this.value=value,this.length=1}else if("string"==typeof value)this.value=value,this.length=Buffer.byteLength(value);else{if(!Buffer.isBuffer(value))return reporter.error("Unsupported type: "+typeof value);this.value=value,this.length=value.length}}var inherits=require("inherits"),Reporter=require("../base").Reporter,Buffer=require("buffer").Buffer;inherits(DecoderBuffer,Reporter),exports.DecoderBuffer=DecoderBuffer,DecoderBuffer.prototype.save=function(){return{offset:this.offset,reporter:Reporter.prototype.save.call(this)}},DecoderBuffer.prototype.restore=function(save){var res=new DecoderBuffer(this.base);return res.offset=save.offset,res.length=this.offset,this.offset=save.offset,Reporter.prototype.restore.call(this,save.reporter),res},DecoderBuffer.prototype.isEmpty=function(){return this.offset===this.length},DecoderBuffer.prototype.readUInt8=function(fail){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(fail||"DecoderBuffer overrun")},DecoderBuffer.prototype.skip=function(bytes,fail){if(!(this.offset+bytes<=this.length))return this.error(fail||"DecoderBuffer overrun");var res=new DecoderBuffer(this.base);return res._reporterState=this._reporterState,res.offset=this.offset,res.length=this.offset+bytes,this.offset+=bytes,res},DecoderBuffer.prototype.raw=function(save){return this.base.slice(save?save.offset:this.offset,this.length)},exports.EncoderBuffer=EncoderBuffer,EncoderBuffer.prototype.join=function(out,offset){return out||(out=new Buffer(this.length)),offset||(offset=0),0===this.length?out:(Array.isArray(this.value)?this.value.forEach(function(item){item.join(out,offset),offset+=item.length}):("number"==typeof this.value?out[offset]=this.value:"string"==typeof this.value?out.write(this.value,offset):Buffer.isBuffer(this.value)&&this.value.copy(out,offset),offset+=this.length),out)}},{"../base":11,buffer:58,inherits:111}],11:[function(require,module,exports){var base=exports;base.Reporter=require("./reporter").Reporter,base.DecoderBuffer=require("./buffer").DecoderBuffer,base.EncoderBuffer=require("./buffer").EncoderBuffer,base.Node=require("./node")},{"./buffer":10,"./node":12,"./reporter":13}],12:[function(require,module,exports){function Node(enc,parent){var state={};this._baseState=state,state.enc=enc,state.parent=parent||null,state.children=null,state.tag=null,state.args=null,state.reverseArgs=null,state.choice=null,state.optional=!1,state.any=!1,state.obj=!1,state.use=null,state.useDecoder=null,state.key=null,state["default"]=null,state.explicit=null,state.implicit=null,state.parent||(state.children=[],this._wrap())}var Reporter=require("../base").Reporter,EncoderBuffer=require("../base").EncoderBuffer,assert=require("minimalistic-assert"),tags=["seq","seqof","set","setof","octstr","bitstr","objid","bool","gentime","utctime","null_","enum","int","ia5str","utf8str","bmpstr","numstr","printstr"],methods=["key","obj","use","optional","explicit","implicit","def","choice","any"].concat(tags),overrided=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];module.exports=Node;var stateProps=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit"];Node.prototype.clone=function(){var state=this._baseState,cstate={};stateProps.forEach(function(prop){cstate[prop]=state[prop]});var res=new this.constructor(cstate.parent);return res._baseState=cstate,res},Node.prototype._wrap=function(){var state=this._baseState;methods.forEach(function(method){this[method]=function(){var clone=new this.constructor(this);return state.children.push(clone),clone[method].apply(clone,arguments)}},this)},Node.prototype._init=function(body){var state=this._baseState;assert(null===state.parent),body.call(this),state.children=state.children.filter(function(child){return child._baseState.parent===this},this),assert.equal(state.children.length,1,"Root node can have only one child")},Node.prototype._useArgs=function(args){var state=this._baseState,children=args.filter(function(arg){return arg instanceof this.constructor},this);args=args.filter(function(arg){return!(arg instanceof this.constructor)},this),0!==children.length&&(assert(null===state.children),state.children=children,children.forEach(function(child){child._baseState.parent=this},this)),0!==args.length&&(assert(null===state.args),state.args=args,state.reverseArgs=args.map(function(arg){if("object"!=typeof arg||arg.constructor!==Object)return arg;var res={};return Object.keys(arg).forEach(function(key){key==(0|key)&&(key|=0);var value=arg[key];res[value]=key}),res}))},overrided.forEach(function(method){Node.prototype[method]=function(){var state=this._baseState;throw new Error(method+" not implemented for encoding: "+state.enc)}}),tags.forEach(function(tag){Node.prototype[tag]=function(){var state=this._baseState,args=Array.prototype.slice.call(arguments);return assert(null===state.tag),state.tag=tag,this._useArgs(args),this}}),Node.prototype.use=function(item){var state=this._baseState;return assert(null===state.use),state.use=item,this},Node.prototype.optional=function(){var state=this._baseState;return state.optional=!0,this},Node.prototype.def=function(val){var state=this._baseState;return assert(null===state["default"]),state["default"]=val,state.optional=!0,this},Node.prototype.explicit=function(num){var state=this._baseState;return assert(null===state.explicit&&null===state.implicit),state.explicit=num,this},Node.prototype.implicit=function(num){var state=this._baseState;return assert(null===state.explicit&&null===state.implicit),state.implicit=num,this},Node.prototype.obj=function(){var state=this._baseState,args=Array.prototype.slice.call(arguments);return state.obj=!0,0!==args.length&&this._useArgs(args),this},Node.prototype.key=function(newKey){var state=this._baseState;return assert(null===state.key),state.key=newKey,this},Node.prototype.any=function(){var state=this._baseState;return state.any=!0,this},Node.prototype.choice=function(obj){var state=this._baseState;return assert(null===state.choice),state.choice=obj,this._useArgs(Object.keys(obj).map(function(key){return obj[key]})),this},Node.prototype._decode=function(input){var state=this._baseState;if(null===state.parent)return input.wrapResult(state.children[0]._decode(input));var prevKey,result=state["default"],present=!0;if(null!==state.key&&(prevKey=input.enterKey(state.key)),state.optional){var tag=null;if(null!==state.explicit?tag=state.explicit:null!==state.implicit?tag=state.implicit:null!==state.tag&&(tag=state.tag),null!==tag||state.any){if(present=this._peekTag(input,tag,state.any),input.isError(present))return present}else{var save=input.save();try{null===state.choice?this._decodeGeneric(state.tag,input):this._decodeChoice(input),present=!0}catch(e){present=!1}input.restore(save)}}var prevObj;if(state.obj&&present&&(prevObj=input.enterObject()),present){if(null!==state.explicit){var explicit=this._decodeTag(input,state.explicit);if(input.isError(explicit))return explicit;input=explicit}if(null===state.use&&null===state.choice){if(state.any)var save=input.save();var body=this._decodeTag(input,null!==state.implicit?state.implicit:state.tag,state.any);if(input.isError(body))return body;state.any?result=input.raw(save):input=body}if(result=state.any?result:null===state.choice?this._decodeGeneric(state.tag,input):this._decodeChoice(input),input.isError(result))return result;if(!state.any&&null===state.choice&&null!==state.children){var fail=state.children.some(function(child){child._decode(input)});if(fail)return err}}return state.obj&&present&&(result=input.leaveObject(prevObj)),null===state.key||null===result&&present!==!0||input.leaveKey(prevKey,state.key,result),result},Node.prototype._decodeGeneric=function(tag,input){var state=this._baseState;return"seq"===tag||"set"===tag?null:"seqof"===tag||"setof"===tag?this._decodeList(input,tag,state.args[0]):"octstr"===tag||"bitstr"===tag?this._decodeStr(input,tag):"ia5str"===tag||"utf8str"===tag||"bmpstr"===tag?this._decodeStr(input,tag):"numstr"===tag||"printstr"===tag?this._decodeStr(input,tag):"objid"===tag&&state.args?this._decodeObjid(input,state.args[0],state.args[1]):"objid"===tag?this._decodeObjid(input,null,null):"gentime"===tag||"utctime"===tag?this._decodeTime(input,tag):"null_"===tag?this._decodeNull(input):"bool"===tag?this._decodeBool(input):"int"===tag||"enum"===tag?this._decodeInt(input,state.args&&state.args[0]):null!==state.use?this._getUse(state.use,input._reporterState.obj)._decode(input):input.error("unknown tag: "+tag)},Node.prototype._getUse=function(entity,obj){var state=this._baseState;return state.useDecoder=this._use(entity,obj),assert(null===state.useDecoder._baseState.parent),state.useDecoder=state.useDecoder._baseState.children[0],state.implicit!==state.useDecoder._baseState.implicit&&(state.useDecoder=state.useDecoder.clone(),state.useDecoder._baseState.implicit=state.implicit),state.useDecoder},Node.prototype._decodeChoice=function(input){var state=this._baseState,result=null,match=!1;return Object.keys(state.choice).some(function(key){var save=input.save(),node=state.choice[key];try{var value=node._decode(input);if(input.isError(value))return!1;result={type:key,value:value},match=!0}catch(e){return input.restore(save),!1}return!0},this),match?result:input.error("Choice not matched")},Node.prototype._createEncoderBuffer=function(data){return new EncoderBuffer(data,this.reporter)},Node.prototype._encode=function(data,reporter,parent){var state=this._baseState;if(null===state["default"]||state["default"]!==data){var result=this._encodeValue(data,reporter,parent);if(void 0!==result&&!this._skipDefault(result,reporter,parent))return result}},Node.prototype._encodeValue=function(data,reporter,parent){var state=this._baseState;if(null===state.parent)return state.children[0]._encode(data,reporter||new Reporter);var result=null;if(this.reporter=reporter,state.optional&&void 0===data){if(null===state["default"])return;data=state["default"]}var content=null,primitive=!1;if(state.any)result=this._createEncoderBuffer(data);else if(state.choice)result=this._encodeChoice(data,reporter);else if(state.children)content=state.children.map(function(child){if("null_"===child._baseState.tag)return child._encode(null,reporter,data);if(null===child._baseState.key)return reporter.error("Child should have a key");var prevKey=reporter.enterKey(child._baseState.key);if("object"!=typeof data)return reporter.error("Child expected, but input is not object");var res=child._encode(data[child._baseState.key],reporter,data);return reporter.leaveKey(prevKey),res},this).filter(function(child){return child}),content=this._createEncoderBuffer(content);else if("seqof"===state.tag||"setof"===state.tag){if(!state.args||1!==state.args.length)return reporter.error("Too many args for : "+state.tag);if(!Array.isArray(data))return reporter.error("seqof/setof, but data is not Array");var child=this.clone();child._baseState.implicit=null,content=this._createEncoderBuffer(data.map(function(item){var state=this._baseState;return this._getUse(state.args[0],data)._encode(item,reporter)},child))}else null!==state.use?result=this._getUse(state.use,parent)._encode(data,reporter):(content=this._encodePrimitive(state.tag,data),primitive=!0);var result;if(!state.any&&null===state.choice){var tag=null!==state.implicit?state.implicit:state.tag,cls=null===state.implicit?"universal":"context";null===tag?null===state.use&&reporter.error("Tag could be ommited only for .use()"):null===state.use&&(result=this._encodeComposite(tag,primitive,cls,content))}return null!==state.explicit&&(result=this._encodeComposite(state.explicit,!1,"context",result)),result},Node.prototype._encodeChoice=function(data,reporter){var state=this._baseState,node=state.choice[data.type];return node||assert(!1,data.type+" not found in "+JSON.stringify(Object.keys(state.choice))),node._encode(data.value,reporter)},Node.prototype._encodePrimitive=function(tag,data){var state=this._baseState;if("octstr"===tag||"bitstr"===tag||"ia5str"===tag)return this._encodeStr(data,tag);if("utf8str"===tag||"bmpstr"===tag)return this._encodeStr(data,tag);if("numstr"===tag||"printstr"===tag)return this._encodeStr(data,tag);if("objid"===tag&&state.args)return this._encodeObjid(data,state.reverseArgs[0],state.args[1]);if("objid"===tag)return this._encodeObjid(data,null,null);if("gentime"===tag||"utctime"===tag)return this._encodeTime(data,tag);if("null_"===tag)return this._encodeNull();if("int"===tag||"enum"===tag)return this._encodeInt(data,state.args&&state.reverseArgs[0]);if("bool"===tag)return this._encodeBool(data);throw new Error("Unsupported tag: "+tag)},Node.prototype._isNumstr=function(str){return/^[0-9 ]*$/.test(str)},Node.prototype._isPrintstr=function(str){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(str)}},{"../base":11,"minimalistic-assert":116}],13:[function(require,module,exports){function Reporter(options){this._reporterState={obj:null,path:[],options:options||{},errors:[]}}function ReporterError(path,msg){this.path=path,this.rethrow(msg)}var inherits=require("inherits");exports.Reporter=Reporter,Reporter.prototype.isError=function(obj){return obj instanceof ReporterError},Reporter.prototype.save=function(){var state=this._reporterState;return{obj:state.obj,pathLen:state.path.length}},Reporter.prototype.restore=function(data){var state=this._reporterState;state.obj=data.obj,state.path=state.path.slice(0,data.pathLen)},Reporter.prototype.enterKey=function(key){return this._reporterState.path.push(key)},Reporter.prototype.leaveKey=function(index,key,value){var state=this._reporterState;state.path=state.path.slice(0,index-1),null!==state.obj&&(state.obj[key]=value)},Reporter.prototype.enterObject=function(){var state=this._reporterState,prev=state.obj;return state.obj={},prev},Reporter.prototype.leaveObject=function(prev){var state=this._reporterState,now=state.obj;return state.obj=prev,now},Reporter.prototype.error=function(msg){var err,state=this._reporterState,inherited=msg instanceof ReporterError;if(err=inherited?msg:new ReporterError(state.path.map(function(elem){return"["+JSON.stringify(elem)+"]"}).join(""),msg.message||msg,msg.stack),!state.options.partial)throw err;return inherited||state.errors.push(err),err},Reporter.prototype.wrapResult=function(result){var state=this._reporterState;return state.options.partial?{result:this.isError(result)?null:result,errors:state.errors}:result},inherits(ReporterError,Error),ReporterError.prototype.rethrow=function(msg){return this.message=msg+" at: "+(this.path||"(shallow)"),Error.captureStackTrace(this,ReporterError),this}},{inherits:111}],14:[function(require,module,exports){var constants=require("../constants");exports.tagClass={0:"universal",1:"application",2:"context",3:"private"},exports.tagClassByName=constants._reverse(exports.tagClass),exports.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},exports.tagByName=constants._reverse(exports.tag)},{"../constants":15}],15:[function(require,module,exports){var constants=exports;constants._reverse=function(map){var res={};return Object.keys(map).forEach(function(key){(0|key)==key&&(key=0|key);var value=map[key];res[value]=key}),res},constants.der=require("./der")},{"./der":14}],16:[function(require,module,exports){function DERDecoder(entity){this.enc="der",this.name=entity.name,this.entity=entity,this.tree=new DERNode,this.tree._init(entity.body)}function DERNode(parent){base.Node.call(this,"der",parent)}function derDecodeTag(buf,fail){var tag=buf.readUInt8(fail);if(buf.isError(tag))return tag;var cls=der.tagClass[tag>>6],primitive=0===(32&tag);if(31===(31&tag)){var oct=tag;for(tag=0;128===(128&oct);){if(oct=buf.readUInt8(fail),buf.isError(oct))return oct;tag<<=7,tag|=127&oct}}else tag&=31;var tagStr=der.tag[tag];return{cls:cls,primitive:primitive,tag:tag,tagStr:tagStr}}function derDecodeLen(buf,primitive,fail){var len=buf.readUInt8(fail);if(buf.isError(len))return len;if(!primitive&&128===len)return null;if(0===(128&len))return len;var num=127&len;if(num>=4)return buf.error("length octect is too long");len=0;for(var i=0;num>i;i++){len<<=8;var j=buf.readUInt8(fail);if(buf.isError(j))return j;len|=j}return len}var inherits=require("inherits"),asn1=require("../../asn1"),base=asn1.base,bignum=asn1.bignum,der=asn1.constants.der;module.exports=DERDecoder,DERDecoder.prototype.decode=function(data,options){return data instanceof base.DecoderBuffer||(data=new base.DecoderBuffer(data,options)),this.tree._decode(data,options)},inherits(DERNode,base.Node),DERNode.prototype._peekTag=function(buffer,tag,any){if(buffer.isEmpty())return!1;var state=buffer.save(),decodedTag=derDecodeTag(buffer,'Failed to peek tag: "'+tag+'"');return buffer.isError(decodedTag)?decodedTag:(buffer.restore(state),decodedTag.tag===tag||decodedTag.tagStr===tag||any)},DERNode.prototype._decodeTag=function(buffer,tag,any){var decodedTag=derDecodeTag(buffer,'Failed to decode tag of "'+tag+'"');if(buffer.isError(decodedTag))return decodedTag;var len=derDecodeLen(buffer,decodedTag.primitive,'Failed to get length of "'+tag+'"');if(buffer.isError(len))return len;if(!any&&decodedTag.tag!==tag&&decodedTag.tagStr!==tag&&decodedTag.tagStr+"of"!==tag)return buffer.error('Failed to match tag: "'+tag+'"');if(decodedTag.primitive||null!==len)return buffer.skip(len,'Failed to match body of: "'+tag+'"');var state=buffer.save(),res=this._skipUntilEnd(buffer,'Failed to skip indefinite length body: "'+this.tag+'"');return buffer.isError(res)?res:(len=buffer.offset-state.offset,buffer.restore(state),buffer.skip(len,'Failed to match body of: "'+tag+'"'))},DERNode.prototype._skipUntilEnd=function(buffer,fail){for(;;){var tag=derDecodeTag(buffer,fail);if(buffer.isError(tag))return tag;var len=derDecodeLen(buffer,tag.primitive,fail);if(buffer.isError(len))return len;var res;if(res=tag.primitive||null!==len?buffer.skip(len):this._skipUntilEnd(buffer,fail),buffer.isError(res))return res;if("end"===tag.tagStr)break}},DERNode.prototype._decodeList=function(buffer,tag,decoder){for(var result=[];!buffer.isEmpty();){var possibleEnd=this._peekTag(buffer,"end");if(buffer.isError(possibleEnd))return possibleEnd;var res=decoder.decode(buffer,"der");if(buffer.isError(res)&&possibleEnd)break;result.push(res)}return result},DERNode.prototype._decodeStr=function(buffer,tag){if("octstr"===tag)return buffer.raw();if("bitstr"===tag){var unused=buffer.readUInt8();return buffer.isError(unused)?unused:{unused:unused,data:buffer.raw()}}if("ia5str"===tag||"utf8str"===tag)return buffer.raw().toString();if("numstr"===tag){var numstr=buffer.raw().toString("ascii");return this._isNumstr(numstr)?numstr:buffer.error("Decoding of string type: numstr unsupported characters")}if("printstr"===tag){var printstr=buffer.raw().toString("ascii");return this._isPrintstr(printstr)?printstr:buffer.error("Decoding of string type: printstr unsupported characters")}if("bmpstr"===tag){var raw=buffer.raw();if(raw.length%2===1)return buffer.error("Decoding of string type: bmpstr length mismatch");for(var str="",i=0;i<raw.length/2;i++)str+=String.fromCharCode(raw.readUInt16BE(2*i));return str}return buffer.error("Decoding of string type: "+tag+" unsupported")},DERNode.prototype._decodeObjid=function(buffer,values,relative){for(var identifiers=[],ident=0;!buffer.isEmpty();){var subident=buffer.readUInt8();ident<<=7,ident|=127&subident,0===(128&subident)&&(identifiers.push(ident),ident=0)}128&subident&&identifiers.push(ident);var first=identifiers[0]/40|0,second=identifiers[0]%40;if(relative?result=identifiers:result=[first,second].concat(identifiers.slice(1)),values){var tmp=values[result.join(" ")];void 0===tmp&&(tmp=values[result.join(".")]),void 0!==tmp&&(result=tmp)}return result},DERNode.prototype._decodeTime=function(buffer,tag){var str=buffer.raw().toString();if("gentime"===tag)var year=0|str.slice(0,4),mon=0|str.slice(4,6),day=0|str.slice(6,8),hour=0|str.slice(8,10),min=0|str.slice(10,12),sec=0|str.slice(12,14);else{if("utctime"!==tag)return buffer.error("Decoding "+tag+" time is not supported yet");var year=0|str.slice(0,2),mon=0|str.slice(2,4),day=0|str.slice(4,6),hour=0|str.slice(6,8),min=0|str.slice(8,10),sec=0|str.slice(10,12);year=70>year?2e3+year:1900+year}return Date.UTC(year,mon-1,day,hour,min,sec,0)},DERNode.prototype._decodeNull=function(buffer){return null},DERNode.prototype._decodeBool=function(buffer){var res=buffer.readUInt8(); return buffer.isError(res)?res:0!==res},DERNode.prototype._decodeInt=function(buffer,values){var raw=buffer.raw(),res=new bignum(raw);return values&&(res=values[res.toString(10)]||res),res},DERNode.prototype._use=function(entity,obj){return"function"==typeof entity&&(entity=entity(obj)),entity._getDecoder("der").tree}},{"../../asn1":8,inherits:111}],17:[function(require,module,exports){var decoders=exports;decoders.der=require("./der"),decoders.pem=require("./pem")},{"./der":16,"./pem":18}],18:[function(require,module,exports){function PEMDecoder(entity){DERDecoder.call(this,entity),this.enc="pem"}var inherits=require("inherits"),Buffer=require("buffer").Buffer,DERDecoder=(require("../../asn1"),require("./der"));inherits(PEMDecoder,DERDecoder),module.exports=PEMDecoder,PEMDecoder.prototype.decode=function(data,options){for(var lines=data.toString().split(/[\r\n]+/g),label=options.label.toUpperCase(),re=/^-----(BEGIN|END) ([^-]+)-----$/,start=-1,end=-1,i=0;i<lines.length;i++){var match=lines[i].match(re);if(null!==match&&match[2]===label){if(-1!==start){if("END"!==match[1])break;end=i;break}if("BEGIN"!==match[1])break;start=i}}if(-1===start||-1===end)throw new Error("PEM section not found for: "+label);var base64=lines.slice(start+1,end).join("");base64.replace(/[^a-z0-9\+\/=]+/gi,"");var input=new Buffer(base64,"base64");return DERDecoder.prototype.decode.call(this,input,options)}},{"../../asn1":8,"./der":16,buffer:58,inherits:111}],19:[function(require,module,exports){function DEREncoder(entity){this.enc="der",this.name=entity.name,this.entity=entity,this.tree=new DERNode,this.tree._init(entity.body)}function DERNode(parent){base.Node.call(this,"der",parent)}function two(num){return 10>num?"0"+num:num}function encodeTag(tag,primitive,cls,reporter){var res;if("seqof"===tag?tag="seq":"setof"===tag&&(tag="set"),der.tagByName.hasOwnProperty(tag))res=der.tagByName[tag];else{if("number"!=typeof tag||(0|tag)!==tag)return reporter.error("Unknown tag: "+tag);res=tag}return res>=31?reporter.error("Multi-octet tag encoding unsupported"):(primitive||(res|=32),res|=der.tagClassByName[cls||"universal"]<<6)}var inherits=require("inherits"),Buffer=require("buffer").Buffer,asn1=require("../../asn1"),base=asn1.base,der=(asn1.bignum,asn1.constants.der);module.exports=DEREncoder,DEREncoder.prototype.encode=function(data,reporter){return this.tree._encode(data,reporter).join()},inherits(DERNode,base.Node),DERNode.prototype._encodeComposite=function(tag,primitive,cls,content){var encodedTag=encodeTag(tag,primitive,cls,this.reporter);if(content.length<128){var header=new Buffer(2);return header[0]=encodedTag,header[1]=content.length,this._createEncoderBuffer([header,content])}for(var lenOctets=1,i=content.length;i>=256;i>>=8)lenOctets++;var header=new Buffer(2+lenOctets);header[0]=encodedTag,header[1]=128|lenOctets;for(var i=1+lenOctets,j=content.length;j>0;i--,j>>=8)header[i]=255&j;return this._createEncoderBuffer([header,content])},DERNode.prototype._encodeStr=function(str,tag){if("octstr"===tag)return this._createEncoderBuffer(str);if("bitstr"===tag)return this._createEncoderBuffer([0|str.unused,str.data]);if("ia5str"===tag||"utf8str"===tag)return this._createEncoderBuffer(str);if("bmpstr"===tag){for(var buf=new Buffer(2*str.length),i=0;i<str.length;i++)buf.writeUInt16BE(str.charCodeAt(i),2*i);return this._createEncoderBuffer(buf)}return"numstr"===tag?this._isNumstr(str)?this._createEncoderBuffer(str):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===tag?this._isPrintstr(str)?this._createEncoderBuffer(str):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):this.reporter.error("Encoding of string type: "+tag+" unsupported")},DERNode.prototype._encodeObjid=function(id,values,relative){if("string"==typeof id){if(!values)return this.reporter.error("string objid given, but no values map found");if(!values.hasOwnProperty(id))return this.reporter.error("objid not found in values map");id=values[id].split(/[\s\.]+/g);for(var i=0;i<id.length;i++)id[i]|=0}else if(Array.isArray(id)){id=id.slice();for(var i=0;i<id.length;i++)id[i]|=0}if(!Array.isArray(id))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(id));if(!relative){if(id[1]>=40)return this.reporter.error("Second objid identifier OOB");id.splice(0,2,40*id[0]+id[1])}for(var size=0,i=0;i<id.length;i++){var ident=id[i];for(size++;ident>=128;ident>>=7)size++}for(var objid=new Buffer(size),offset=objid.length-1,i=id.length-1;i>=0;i--){var ident=id[i];for(objid[offset--]=127&ident;(ident>>=7)>0;)objid[offset--]=128|127&ident}return this._createEncoderBuffer(objid)},DERNode.prototype._encodeTime=function(time,tag){var str,date=new Date(time);return"gentime"===tag?str=[two(date.getFullYear()),two(date.getUTCMonth()+1),two(date.getUTCDate()),two(date.getUTCHours()),two(date.getUTCMinutes()),two(date.getUTCSeconds()),"Z"].join(""):"utctime"===tag?str=[two(date.getFullYear()%100),two(date.getUTCMonth()+1),two(date.getUTCDate()),two(date.getUTCHours()),two(date.getUTCMinutes()),two(date.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+tag+" time is not supported yet"),this._encodeStr(str,"octstr")},DERNode.prototype._encodeNull=function(){return this._createEncoderBuffer("")},DERNode.prototype._encodeInt=function(num,values){if("string"==typeof num){if(!values)return this.reporter.error("String int or enum given, but no values map");if(!values.hasOwnProperty(num))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(num));num=values[num]}if("number"!=typeof num&&!Buffer.isBuffer(num)){var numArray=num.toArray();!num.sign&&128&numArray[0]&&numArray.unshift(0),num=new Buffer(numArray)}if(Buffer.isBuffer(num)){var size=num.length;0===num.length&&size++;var out=new Buffer(size);return num.copy(out),0===num.length&&(out[0]=0),this._createEncoderBuffer(out)}if(128>num)return this._createEncoderBuffer(num);if(256>num)return this._createEncoderBuffer([0,num]);for(var size=1,i=num;i>=256;i>>=8)size++;for(var out=new Array(size),i=out.length-1;i>=0;i--)out[i]=255&num,num>>=8;return 128&out[0]&&out.unshift(0),this._createEncoderBuffer(new Buffer(out))},DERNode.prototype._encodeBool=function(value){return this._createEncoderBuffer(value?255:0)},DERNode.prototype._use=function(entity,obj){return"function"==typeof entity&&(entity=entity(obj)),entity._getEncoder("der").tree},DERNode.prototype._skipDefault=function(dataBuffer,reporter,parent){var i,state=this._baseState;if(null===state["default"])return!1;var data=dataBuffer.join();if(void 0===state.defaultBuffer&&(state.defaultBuffer=this._encodeValue(state["default"],reporter,parent).join()),data.length!==state.defaultBuffer.length)return!1;for(i=0;i<data.length;i++)if(data[i]!==state.defaultBuffer[i])return!1;return!0}},{"../../asn1":8,buffer:58,inherits:111}],20:[function(require,module,exports){var encoders=exports;encoders.der=require("./der"),encoders.pem=require("./pem")},{"./der":19,"./pem":21}],21:[function(require,module,exports){function PEMEncoder(entity){DEREncoder.call(this,entity),this.enc="pem"}var inherits=require("inherits"),DEREncoder=(require("buffer").Buffer,require("../../asn1"),require("./der"));inherits(PEMEncoder,DEREncoder),module.exports=PEMEncoder,PEMEncoder.prototype.encode=function(data,options){for(var buf=DEREncoder.prototype.encode.call(this,data),p=buf.toString("base64"),out=["-----BEGIN "+options.label+"-----"],i=0;i<p.length;i+=64)out.push(p.slice(i,i+64));return out.push("-----END "+options.label+"-----"),out.join("\n")}},{"../../asn1":8,"./der":19,buffer:58,inherits:111}],22:[function(require,module,exports){function replacer(key,value){return util.isUndefined(value)?""+value:util.isNumber(value)&&!isFinite(value)?value.toString():util.isFunction(value)||util.isRegExp(value)?value.toString():value}function truncate(s,n){return util.isString(s)?s.length<n?s:s.slice(0,n):s}function getMessage(self){return truncate(JSON.stringify(self.actual,replacer),128)+" "+self.operator+" "+truncate(JSON.stringify(self.expected,replacer),128)}function fail(actual,expected,message,operator,stackStartFunction){throw new assert.AssertionError({message:message,actual:actual,expected:expected,operator:operator,stackStartFunction:stackStartFunction})}function ok(value,message){value||fail(value,!0,message,"==",assert.ok)}function _deepEqual(actual,expected){if(actual===expected)return!0;if(util.isBuffer(actual)&&util.isBuffer(expected)){if(actual.length!=expected.length)return!1;for(var i=0;i<actual.length;i++)if(actual[i]!==expected[i])return!1;return!0}return util.isDate(actual)&&util.isDate(expected)?actual.getTime()===expected.getTime():util.isRegExp(actual)&&util.isRegExp(expected)?actual.source===expected.source&&actual.global===expected.global&&actual.multiline===expected.multiline&&actual.lastIndex===expected.lastIndex&&actual.ignoreCase===expected.ignoreCase:util.isObject(actual)||util.isObject(expected)?objEquiv(actual,expected):actual==expected}function isArguments(object){return"[object Arguments]"==Object.prototype.toString.call(object)}function objEquiv(a,b){if(util.isNullOrUndefined(a)||util.isNullOrUndefined(b))return!1;if(a.prototype!==b.prototype)return!1;if(util.isPrimitive(a)||util.isPrimitive(b))return a===b;var aIsArgs=isArguments(a),bIsArgs=isArguments(b);if(aIsArgs&&!bIsArgs||!aIsArgs&&bIsArgs)return!1;if(aIsArgs)return a=pSlice.call(a),b=pSlice.call(b),_deepEqual(a,b);var key,i,ka=objectKeys(a),kb=objectKeys(b);if(ka.length!=kb.length)return!1;for(ka.sort(),kb.sort(),i=ka.length-1;i>=0;i--)if(ka[i]!=kb[i])return!1;for(i=ka.length-1;i>=0;i--)if(key=ka[i],!_deepEqual(a[key],b[key]))return!1;return!0}function expectedException(actual,expected){return actual&&expected?"[object RegExp]"==Object.prototype.toString.call(expected)?expected.test(actual):actual instanceof expected?!0:expected.call({},actual)===!0?!0:!1:!1}function _throws(shouldThrow,block,expected,message){var actual;util.isString(expected)&&(message=expected,expected=null);try{block()}catch(e){actual=e}if(message=(expected&&expected.name?" ("+expected.name+").":".")+(message?" "+message:"."),shouldThrow&&!actual&&fail(actual,expected,"Missing expected exception"+message),!shouldThrow&&expectedException(actual,expected)&&fail(actual,expected,"Got unwanted exception"+message),shouldThrow&&actual&&expected&&!expectedException(actual,expected)||!shouldThrow&&actual)throw actual}var util=require("util/"),pSlice=Array.prototype.slice,hasOwn=Object.prototype.hasOwnProperty,assert=module.exports=ok;assert.AssertionError=function(options){this.name="AssertionError",this.actual=options.actual,this.expected=options.expected,this.operator=options.operator,options.message?(this.message=options.message,this.generatedMessage=!1):(this.message=getMessage(this),this.generatedMessage=!0);var stackStartFunction=options.stackStartFunction||fail;if(Error.captureStackTrace)Error.captureStackTrace(this,stackStartFunction);else{var err=new Error;if(err.stack){var out=err.stack,fn_name=stackStartFunction.name,idx=out.indexOf("\n"+fn_name);if(idx>=0){var next_line=out.indexOf("\n",idx+1);out=out.substring(next_line+1)}this.stack=out}}},util.inherits(assert.AssertionError,Error),assert.fail=fail,assert.ok=ok,assert.equal=function(actual,expected,message){actual!=expected&&fail(actual,expected,message,"==",assert.equal)},assert.notEqual=function(actual,expected,message){actual==expected&&fail(actual,expected,message,"!=",assert.notEqual)},assert.deepEqual=function(actual,expected,message){_deepEqual(actual,expected)||fail(actual,expected,message,"deepEqual",assert.deepEqual)},assert.notDeepEqual=function(actual,expected,message){_deepEqual(actual,expected)&&fail(actual,expected,message,"notDeepEqual",assert.notDeepEqual)},assert.strictEqual=function(actual,expected,message){actual!==expected&&fail(actual,expected,message,"===",assert.strictEqual)},assert.notStrictEqual=function(actual,expected,message){actual===expected&&fail(actual,expected,message,"!==",assert.notStrictEqual)},assert["throws"]=function(block,error,message){_throws.apply(this,[!0].concat(pSlice.call(arguments)))},assert.doesNotThrow=function(block,message){_throws.apply(this,[!1].concat(pSlice.call(arguments)))},assert.ifError=function(err){if(err)throw err};var objectKeys=Object.keys||function(obj){var keys=[];for(var key in obj)hasOwn.call(obj,key)&&keys.push(key);return keys}},{"util/":157}],23:[function(require,module,exports){var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(exports){"use strict";function decode(elt){var code=elt.charCodeAt(0);return code===PLUS||code===PLUS_URL_SAFE?62:code===SLASH||code===SLASH_URL_SAFE?63:NUMBER>code?-1:NUMBER+10>code?code-NUMBER+26+26:UPPER+26>code?code-UPPER:LOWER+26>code?code-LOWER+26:void 0}function b64ToByteArray(b64){function push(v){arr[L++]=v}var i,j,l,tmp,placeHolders,arr;if(b64.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var len=b64.length;placeHolders="="===b64.charAt(len-2)?2:"="===b64.charAt(len-1)?1:0,arr=new Arr(3*b64.length/4-placeHolders),l=placeHolders>0?b64.length-4:b64.length;var L=0;for(i=0,j=0;l>i;i+=4,j+=3)tmp=decode(b64.charAt(i))<<18|decode(b64.charAt(i+1))<<12|decode(b64.charAt(i+2))<<6|decode(b64.charAt(i+3)),push((16711680&tmp)>>16),push((65280&tmp)>>8),push(255&tmp);return 2===placeHolders?(tmp=decode(b64.charAt(i))<<2|decode(b64.charAt(i+1))>>4,push(255&tmp)):1===placeHolders&&(tmp=decode(b64.charAt(i))<<10|decode(b64.charAt(i+1))<<4|decode(b64.charAt(i+2))>>2,push(tmp>>8&255),push(255&tmp)),arr}function uint8ToBase64(uint8){function encode(num){return lookup.charAt(num)}function tripletToBase64(num){return encode(num>>18&63)+encode(num>>12&63)+encode(num>>6&63)+encode(63&num)}var i,temp,length,extraBytes=uint8.length%3,output="";for(i=0,length=uint8.length-extraBytes;length>i;i+=3)temp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2],output+=tripletToBase64(temp);switch(extraBytes){case 1:temp=uint8[uint8.length-1],output+=encode(temp>>2),output+=encode(temp<<4&63),output+="==";break;case 2:temp=(uint8[uint8.length-2]<<8)+uint8[uint8.length-1],output+=encode(temp>>10),output+=encode(temp>>4&63),output+=encode(temp<<2&63),output+="="}return output}var Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,PLUS="+".charCodeAt(0),SLASH="/".charCodeAt(0),NUMBER="0".charCodeAt(0),LOWER="a".charCodeAt(0),UPPER="A".charCodeAt(0),PLUS_URL_SAFE="-".charCodeAt(0),SLASH_URL_SAFE="_".charCodeAt(0);exports.toByteArray=b64ToByteArray,exports.fromByteArray=uint8ToBase64}("undefined"==typeof exports?this.base64js={}:exports)},{}],24:[function(require,module,exports){function BigInteger(a,b,c){return this instanceof BigInteger?void(null!=a&&("number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))):new BigInteger(a,b,c)}function am1(i,x,w,j,c,n){for(;--n>=0;){var v=x*this[i++]+w[j]+c;c=Math.floor(v/67108864),w[j++]=67108863&v}return c}function int2char(n){return BI_RM.charAt(n)}function intAt(s,i){var c=BI_RC[s.charCodeAt(i)];return null==c?-1:c}function bnpCopyTo(r){for(var i=this.t-1;i>=0;--i)r[i]=this[i];r.t=this.t,r.s=this.s}function bnpFromInt(x){this.t=1,this.s=0>x?-1:0,x>0?this[0]=x:-1>x?this[0]=x+DV:this.t=0}function nbv(i){var r=new BigInteger;return r.fromInt(i),r}function bnpFromString(s,b){var k,self=this;if(16==b)k=4;else if(8==b)k=3;else if(256==b)k=8;else if(2==b)k=1;else if(32==b)k=5;else{if(4!=b)return void self.fromRadix(s,b);k=2}self.t=0,self.s=0;for(var i=s.length,mi=!1,sh=0;--i>=0;){var x=8==k?255&s[i]:intAt(s,i);0>x?"-"==s.charAt(i)&&(mi=!0):(mi=!1,0==sh?self[self.t++]=x:sh+k>self.DB?(self[self.t-1]|=(x&(1<<self.DB-sh)-1)<<sh,self[self.t++]=x>>self.DB-sh):self[self.t-1]|=x<<sh,sh+=k,sh>=self.DB&&(sh-=self.DB))}8==k&&0!=(128&s[0])&&(self.s=-1,sh>0&&(self[self.t-1]|=(1<<self.DB-sh)-1<<sh)),self.clamp(),mi&&BigInteger.ZERO.subTo(self,self)}function bnpClamp(){for(var c=this.s&this.DM;this.t>0&&this[this.t-1]==c;)--this.t}function bnToString(b){var self=this;if(self.s<0)return"-"+self.negate().toString(b);var k;if(16==b)k=4;else if(8==b)k=3;else if(2==b)k=1;else if(32==b)k=5;else{if(4!=b)return self.toRadix(b);k=2}var d,km=(1<<k)-1,m=!1,r="",i=self.t,p=self.DB-i*self.DB%k;if(i-- >0)for(p<self.DB&&(d=self[i]>>p)>0&&(m=!0,r=int2char(d));i>=0;)k>p?(d=(self[i]&(1<<p)-1)<<k-p,d|=self[--i]>>(p+=self.DB-k)):(d=self[i]>>(p-=k)&km,0>=p&&(p+=self.DB,--i)),d>0&&(m=!0),m&&(r+=int2char(d));return m?r:"0"}function bnNegate(){var r=new BigInteger;return BigInteger.ZERO.subTo(this,r),r}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(a){var r=this.s-a.s;if(0!=r)return r;var i=this.t;if(r=i-a.t,0!=r)return this.s<0?-r:r;for(;--i>=0;)if(0!=(r=this[i]-a[i]))return r;return 0}function nbits(x){var t,r=1;return 0!=(t=x>>>16)&&(x=t,r+=16),0!=(t=x>>8)&&(x=t,r+=8),0!=(t=x>>4)&&(x=t,r+=4),0!=(t=x>>2)&&(x=t,r+=2),0!=(t=x>>1)&&(x=t,r+=1),r}function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnByteLength(){return this.bitLength()>>3}function bnpDLShiftTo(n,r){var i;for(i=this.t-1;i>=0;--i)r[i+n]=this[i];for(i=n-1;i>=0;--i)r[i]=0;r.t=this.t+n,r.s=this.s}function bnpDRShiftTo(n,r){for(var i=n;i<this.t;++i)r[i-n]=this[i];r.t=Math.max(this.t-n,0),r.s=this.s}function bnpLShiftTo(n,r){var i,self=this,bs=n%self.DB,cbs=self.DB-bs,bm=(1<<cbs)-1,ds=Math.floor(n/self.DB),c=self.s<<bs&self.DM;for(i=self.t-1;i>=0;--i)r[i+ds+1]=self[i]>>cbs|c,c=(self[i]&bm)<<bs;for(i=ds-1;i>=0;--i)r[i]=0;r[ds]=c,r.t=self.t+ds+1,r.s=self.s,r.clamp()}function bnpRShiftTo(n,r){var self=this;r.s=self.s;var ds=Math.floor(n/self.DB);if(ds>=self.t)return void(r.t=0);var bs=n%self.DB,cbs=self.DB-bs,bm=(1<<bs)-1;r[0]=self[ds]>>bs;for(var