UNPKG

filepay

Version:

Post data and upload files to bitcoin sv

1 lines 781 kB
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.filepay=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r}()({1:[function(require,module,exports){(function(Buffer){const mingo=require("mingo");const _Buffer=require("buffer/");const bitcoin=require("bsv");const axios=require("axios");const textEncoder=require("text-encoder");const bsvCoinselect=require("bsv-coinselect");const defaults={api_key:"abc",rpc:"https://api.mattercloud.net",fee:400,feeb:1.4};var isPublicKeyHashIn=function(script){if(script.chunks.length===2){var signatureBuf=script.chunks[0].buf;var pubkeyBuf=script.chunks[1].buf;if(signatureBuf&&signatureBuf.length&&signatureBuf[0]===48&&pubkeyBuf&&pubkeyBuf.length){var version=pubkeyBuf[0];if((version===4||version===6||version===7)&&pubkeyBuf.length===65){return true}else if((version===3||version===2)&&pubkeyBuf.length===33){return true}}}return false};var isPublicKeyIn=function(script){if(script.chunks.length===1){var signatureBuf=script.chunks[0].buf;if(signatureBuf&&signatureBuf.length&&signatureBuf[0]===48){return true}}return false};var buildPublicKeyIn=function(signature,sigtype){if(signature instanceof bitcoin.Signature){signature=signature.toBuffer()}var script=new Script;script.add(Buffer.concat([signature,Buffer.from([(sigtype||bitcoin.Signature.SIGHASH_ALL)&255])]));return script};var isPublicKeyOut=function(script){if(script.chunks.length===2&&script.chunks[0].buf&&script.chunks[0].buf.length&&script.chunks[1].opcodenum===bitcoin.Opcode.OP_CHECKSIG){var pubkeyBuf=script.chunks[0].buf;var version=pubkeyBuf[0];var isVersion=false;if((version===4||version===6||version===7)&&pubkeyBuf.length===65){isVersion=true}else if((version===3||version===2)&&pubkeyBuf.length===33){isVersion=true}if(isVersion){return PublicKey.isValid(pubkeyBuf)}}return false};var isPublicKeyHashOut=function(script){return!!(script.chunks.length===5&&script.chunks[0].opcodenum===bitcoin.Opcode.OP_DUP&&script.chunks[1].opcodenum===bitcoin.Opcode.OP_HASH160&&script.chunks[2].buf&&script.chunks[2].buf.length===20&&script.chunks[3].opcodenum===bitcoin.Opcode.OP_EQUALVERIFY&&script.chunks[4].opcodenum===bitcoin.Opcode.OP_CHECKSIG)};var buildPublicKeyHashIn=function(publicKey,signature,sigtype){signature=signature.toBuffer();var script=(new bitcoin.Script).add(Buffer.concat([signature,Buffer.from([(sigtype||bitcoin.Signature.SIGHASH_ALL)&255])])).add(new bitcoin.PublicKey(publicKey).toBuffer());return script};var signStandard=function(tx,index,satoshis,script,key){let unlockingScript;const privKey=new bitcoin.PrivateKey(key);const pubKey=privKey.publicKey;const sigtype=bitcoin.crypto.Signature.SIGHASH_ALL|bitcoin.crypto.Signature.SIGHASH_FORKID;const flags=bitcoin.Script.Interpreter.SCRIPT_VERIFY_MINIMALDATA|bitcoin.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID|bitcoin.Script.Interpreter.SCRIPT_ENABLE_MAGNETIC_OPCODES|bitcoin.Script.Interpreter.SCRIPT_ENABLE_MONOLITH_OPCODES;const signature=bitcoin.Transaction.sighash.sign(tx,privKey,sigtype,index,script,new bitcoin.crypto.BN(satoshis),flags);if(isPublicKeyOut(script)){unlockingScript=buildPublicKeyIn(signature,sigtype)}else if(isPublicKeyHashOut(script)){unlockingScript=buildPublicKeyHashIn(pubKey,signature,sigtype)}else{throw new Error("Non-standard script")}return unlockingScript};var signStandardLike=function(tx,index,satoshis,script,key){const privKey=new bitcoin.PrivateKey(key);const pubKey=privKey.publicKey;const sigtype=bitcoin.crypto.Signature.SIGHASH_ALL|bitcoin.crypto.Signature.SIGHASH_FORKID;const flags=bitcoin.Script.Interpreter.SCRIPT_VERIFY_MINIMALDATA|bitcoin.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID|bitcoin.Script.Interpreter.SCRIPT_ENABLE_MAGNETIC_OPCODES|bitcoin.Script.Interpreter.SCRIPT_ENABLE_MONOLITH_OPCODES;const signature=bitcoin.Transaction.sighash.sign(tx,privKey,sigtype,index,script,new bitcoin.crypto.BN(satoshis),flags);return buildPublicKeyHashIn(pubKey,signature,sigtype)};var signCustom=function(tx,txoutMapToUnlockingScript,key){for(let i=0;i<tx.inputs.length;i++){const prevTxId=tx.inputs[i].prevTxId.toString("hex");const outputIndex=tx.inputs[i].outputIndex;const hasUnlockingScript=txoutMapToUnlockingScript.get(`${prevTxId}-${outputIndex}`);if(!hasUnlockingScript){continue}tx.inputs[i].setScript(hasUnlockingScript(tx,i,tx.inputs[i].output.satoshis,tx.inputs[i].output.script,key))}for(let i=0;i<tx.inputs.length;i++){const prevTxId=tx.inputs[i].prevTxId.toString("hex");const outputIndex=tx.inputs[i].outputIndex;const hasUnlockingScript=txoutMapToUnlockingScript.get(`${prevTxId}-${outputIndex}`);if(hasUnlockingScript){continue}tx.inputs[i].setScript(signStandard(tx,i,tx.inputs[i].output.satoshis,tx.inputs[i].output.script,key))}return tx};var dedupUtxosPreserveRequiredIfFound=function(inputs){let modifiedInputs=[];let map=new Map;for(const input of inputs){if(input.required){modifiedInputs.push(input);map.set(input.txid+"-"+input.outputIndex,true)}}for(const input of inputs){if(map.get(input.txid+"-"+input.outputIndex)){continue}if(!input.required){modifiedInputs.push(input);map.set(input.txid+"-"+input.outputIndex,true)}}return modifiedInputs};var calculateFee=function(inputs,outputs){let inputSum=0;let outputSum=0;if(inputs){for(const input of inputs){inputSum+=input.value}}if(outputs){for(const output of outputs){outputSum+=output.value}}return inputSum-outputSum};var buildTransactionInputsOutputs=function(inputs,outputs){let modifiedInputs=[];let map=new Map;for(const input of inputs){if(map.get(input.txid+"-"+input.outputIndex)){continue}modifiedInputs.push(Object.assign({},input,{amount:input.value/1e8,satoshis:input.value}));map.set(input.txid+"-"+input.outputIndex,true)}let tx=(new bitcoin.Transaction).from(modifiedInputs);if(outputs){for(const output of outputs){if(output.script){const a=new bitcoin.Script(output.script).toString();tx.addOutput(new bitcoin.Transaction.Output({script:a,satoshis:output.value}))}}}let sumInputValues=0;let sumOutputValues=0;for(const input of tx.inputs){sumInputValues+=input.output.satoshis}for(const output of tx.outputs){sumOutputValues+=output.satoshis}if(!isNaN(sumInputValues)&&!isNaN(sumOutputValues)&&sumInputValues>=0&&sumOutputValues>=0&&sumInputValues-sumOutputValues<=1e7){return tx}throw new Error("Too large fee error")};var selectCoins=function(utxos,outputs,feeRate,changeScript){return bsvCoinselect(utxos,outputs,feeRate,changeScript)};var build=function(options,callback){let script=null;if(options.tx){let tx=new bitcoin.Transaction(options.tx);if(tx.inputs.length>0&&tx.inputs[0].script){if(options.pay||options.data){callback(new Error("the transaction is already signed and cannot be modified"));return}}return tx}else{if(options.data){script=_script(options)}}if(options.pay&&options.pay.key){let key=options.pay.key;const privateKey=new bitcoin.PrivateKey(key);const address=privateKey.toAddress();const processWithUtxos=function(err,utxos,innerCallback){if(err){innerCallback?innerCallback(err,null,null):"";return}if(!utxos||!utxos.length){innerCallback?innerCallback("Error: No available utxos",null,null):"";return}if(options.pay.filter&&options.pay.filter.q&&options.pay.filter.q.find){let f=new mingo.Query(options.pay.filter.q.find);utxos=utxos.filter(function(item){return f.test(item)})}const desiredOutputs=[];if(script){desiredOutputs.push({script:script.toHex(),value:0})}if(options.pay.to&&Array.isArray(options.pay.to)){options.pay.to.forEach(function(receiver){if(receiver.address){desiredOutputs.push({script:bitcoin.Script.fromAddress(receiver.address).toHex(),value:receiver.value})}else if(receiver.data){desiredOutputs.push({script:_script({data:receiver.data}).toHex(),value:receiver.value})}else if(receiver.script){desiredOutputs.push({script:receiver.script,value:receiver.value})}else{throw new Error("Invalid to. Required script and value")}})}let feeb=options.pay&&options.pay.feeb?options.pay.feeb:.5;let changeScriptHex=bitcoin.Script.fromAddress(address).toHex();if(options.pay.changeAddress){changeScriptHex=bitcoin.Script.fromAddress(options.pay.changeAddress).toHex()}if(options.pay.changeScript){changeScriptHex=bitcoin.Script.fromHex(options.pay.changeScript).toHex()}const coinSelectedBuiltTx=selectCoins(dedupUtxosPreserveRequiredIfFound(utxos),desiredOutputs,feeb,changeScriptHex);if(!coinSelectedBuiltTx.inputs||!coinSelectedBuiltTx.outputs){innerCallback("Insufficient input utxo",null,null);return}let tx=buildTransactionInputsOutputs(coinSelectedBuiltTx.inputs,coinSelectedBuiltTx.outputs);let actualFee=calculateFee(coinSelectedBuiltTx.inputs,coinSelectedBuiltTx.outputs);const utxoUnlockingMap=new Map;for(const utxo of utxos){if(utxo.unlockingScript){utxoUnlockingMap.set(utxo.txid+"-"+utxo.outputIndex,utxo.unlockingScript)}}let transaction=signCustom(tx,utxoUnlockingMap,key);innerCallback(null,transaction,actualFee)};if(options.pay.inputs&&Array.isArray(options.pay.inputs)){processWithUtxos(null,options.pay.inputs,function(err,tx,fee){if(!err&&tx){callback(null,tx,fee);return}connect(options).getUnspentUtxos(address,function(err,utxos){if(err){callback(err,null,null);return}let mergedUtxos=utxos.concat(options.pay.inputs);processWithUtxos(null,mergedUtxos,function(err,tx,fee){callback(err,tx,fee);return})}).catch(ex=>{console.log("Filepay build ex",ex);callback(ex,null,null)})})}else{connect(options).getUnspentUtxos(address,function(err,utxos){processWithUtxos(err,utxos,function(err,tx,fee){callback(err,tx,fee)})}).catch(ex=>{console.log("Filepay build ex",ex);callback(ex,null,null)})}}else{const desiredOutputs=[];if(script){desiredOutputs.push({script:script,value:0})}if(options.pay&&options.pay.to&&Array.isArray(options.pay.to)){options.pay.to.forEach(function(receiver){if(receiver.address){desiredOutputs.push({script:bitcoin.Script.fromAddress(receiver.address).toHex(),value:receiver.value})}else if(receiver.data){desiredOutputs.push({script:_script({data:receiver.data}).toHex(),value:receiver.value})}else if(receiver.script){desiredOutputs.push({script:receiver.script,value:receiver.value})}})}let fee=options.pay&&options.pay.fee?options.pay.fee:defaults.fee;let tx=new bitcoin.Transaction(options.tx).fee(fee);for(const out of desiredOutputs){tx.addOutput(new bitcoin.Transaction.Output({script:out.script,satoshis:out.value}))}callback(null,tx,null)}};var buildHeader=function(options){if(!options){return{headers:{"Content-Type":"application/json"}}}if(options&&options.pay&&options.pay.api_key){return{headers:{"Content-Type":"application/json",api_key:options.pay.api_key}}}if(options&&options.api_key){return{headers:{"Content-Type":"application/json",api_key:options.api_key}}}return{}};var send=function(options,callback){if(!callback){callback=function(){}}build(options,function(err,tx,fee){if(err){callback(err);return}let rpcaddr=options.pay&&options.pay.rpc?options.pay.rpc:defaults.rpc;axios.post(`${rpcaddr}/api/v3/main/merchants/tx/broadcast`,{rawtx:tx.toString()},buildHeader(options)).then(res=>{callback(null,res.data.result.txid,fee,tx.toString())}).catch(ex=>{console.log("filepay ex",ex);callback(ex,tx.hash,fee,tx.toString())})})};var _script=function(options){var s=null;if(options.data){if(Array.isArray(options.data)){s=new bitcoin.Script;if(!options.hasOwnProperty("safe")){options.safe=true}if(options.safe){s.add(bitcoin.Opcode.OP_FALSE)}s.add(bitcoin.Opcode.OP_RETURN);options.data.forEach(function(item){if(item.constructor.name==="ArrayBuffer"){let buffer=_Buffer.Buffer.from(item);s.add(buffer)}else if(item.constructor.name==="Buffer"){s.add(item)}else if(typeof item==="string"){if(/^0x/i.test(item)){s.add(Buffer.from(item.slice(2),"hex"))}else{s.add(Buffer.from(item))}}else if(typeof item==="object"&&item.hasOwnProperty("op")){s.add({opcodenum:item.op})}})}else if(typeof options.data==="string"){s=bitcoin.Script.fromHex(options.data)}}return s};var apiClient=function(options){return{getUnspentUtxos:async(address,callback)=>{let rpcaddr=options&&options.pay&&options.pay.rpc?options.pay.rpc:defaults.rpc;return axios.get(`${rpcaddr}/api/v3/main/address/${address}/utxo`,buildHeader(options)).then(response=>{if(callback){callback(null,response.data)}return response.data}).catch(err=>{console.log(err);if(callback){callback(err)}return err})}}};var callbackAndResolve=function(resolveOrReject,data,callback){if(callback){callback(data)}if(resolveOrReject){return resolveOrReject(data)}};var hexEncode=function(str){function buf2hex(buffer){const hexStr=Array.prototype.map.call(new Uint8Array(buffer),x=>("00"+x.toString(16)).slice(-2)).join("");return hexStr.toLowerCase()}const checkHexPrefixRegex=/^0x(.*)/i;const match=checkHexPrefixRegex.exec(str);if(match){return str}else{let enc=(new textEncoder.TextEncoder).encode(str);return buf2hex(enc)}};var hexEncodeIfNeeded=function(data){if(!data){return"0x00"}const checkHexPrefixRegex=/^0x(.*)/i;const match=checkHexPrefixRegex.exec(data);if(match&&match[1]){return data.toLowerCase()}return"0x"+hexEncode(data).toLowerCase()};var isUtf8=function(encoding){if(!encoding||/\s*/i.test(encoding)){return true}return/utf\-?8$/i.test(encoding)};var buildFile=function(request,callback){return new Promise((resolve,reject)=>{if(!request.file){return callbackAndResolve(resolve,{success:false,message:"file required"},callback)}if(!request.file.content){return callbackAndResolve(resolve,{success:false,message:"content required"},callback)}if(!request.file.contentType){return callbackAndResolve(resolve,{success:false,message:"contentType required"},callback)}try{let encoding=request.file.encoding?request.file.encoding:"utf-8";if(isUtf8(encoding)){encoding="utf-8"}let args=["0x"+Buffer.from("19HxigV4QyBv3tHpQVcUEQyq1pzZVdoAut").toString("hex"),hexEncodeIfNeeded(request.file.content),hexEncodeIfNeeded(request.file.contentType),hexEncodeIfNeeded(encoding)];const hasFileName=request.file.name&&request.file.name!=="";let filename=request.file.name?request.file.name:"0x00";args.push(hexEncodeIfNeeded(filename));if(request.file.tags){request.file.tags.map(tag=>args.push(hexEncodeIfNeeded(tag)))}if(request.signatures&&Array.isArray(request.signatures)){for(const signatureKey of request.signatures){if(!signatureKey.key||/^\s*$/.test(signatureKey.key)){return callbackAndResolve(resolve,{success:false,message:"signature key required"},callback)}const identityPrivateKey=new filepay.bsv.PrivateKey(signatureKey.key);const identityAddress=identityPrivateKey.toAddress().toLegacyAddress();args.push("0x"+Buffer.from("|").toString("hex"));const opReturnHexArray=Utils.buildAuthorIdentity({args:args,address:identityAddress,key:signatureKey.key,indexes:signatureKey.indexes?signatureKey.indexes:undefined});args=args.concat(opReturnHexArray)}}return callbackAndResolve(resolve,{success:true,data:args},callback)}catch(ex){console.log("ex",ex);callbackAndResolve(resolve,{success:false,message:ex.message?ex.message:ex.toString()},callback)}})};var putFile=async(request,callback)=>{if(!request.pay||!request.pay.key||request.pay.key===""){return new Promise(resolve=>{return callbackAndResolve(resolve,{success:false,message:"key required"},request.callback)})}const buildResult=await buildFile(request);if(!buildResult.success){return new Promise(resolve=>{callbackAndResolve(resolve,{success:false,message:buildResult.message},request.callback)})}const newArgs=[];for(const i of buildResult.data){const checkHexPrefixRegex=/^0x(.*)/i;const match=checkHexPrefixRegex.exec(i);if(match&&match[1]){newArgs.push(i)}else{newArgs.push("0x"+i)}}return send({safe:true,data:newArgs,pay:request.pay,rpc:request.rpc,api_key:request.api_key},callback)};var queueFile=async(request,callback)=>{var formData=new FormData;formData.append("file",Buffer.from(request.data,request.encoding));axios.post(`${rpcaddr}/upload`,formData,{headers:{"Content-Type":"multipart/form-data"}}).then(res=>{callback(null,res.data)}).catch(ex=>{callback(ex,null)})};var connect=function(options){return apiClient(options)};var data2script=function(scriptArray){if(!scriptArray||!Array.isArray(scriptArray)){return""}var s=new bitcoin.Script;s.add(bitcoin.Opcode.OP_FALSE);s.add(bitcoin.Opcode.OP_RETURN);scriptArray.forEach(function(item){if(item.constructor.name==="ArrayBuffer"){let buffer=_Buffer.Buffer.from(item);s.add(buffer)}else if(item.constructor.name==="Buffer"){s.add(item)}else if(typeof item==="string"){if(/^0x/i.test(item)){s.add(Buffer.from(item.slice(2),"hex"))}else{s.add(Buffer.from(item))}}else if(typeof item==="object"&&item.hasOwnProperty("op")){s.add({opcodenum:item.op})}});return s};module.exports={putFile:putFile,queueFile:queueFile,build:build,send:send,bsv:bitcoin,connect:connect,data2script:data2script,coinselect:bsvCoinselect,signStandard:signStandard,signStandardLike:signStandardLike}}).call(this,require("buffer").Buffer)},{axios:2,bsv:36,"bsv-coinselect":34,buffer:176,"buffer/":83,mingo:120,"text-encoder":125}],2:[function(require,module,exports){module.exports=require("./lib/axios")},{"./lib/axios":4}],3:[function(require,module,exports){"use strict";var utils=require("./../utils");var settle=require("./../core/settle");var buildURL=require("./../helpers/buildURL");var buildFullPath=require("../core/buildFullPath");var parseHeaders=require("./../helpers/parseHeaders");var isURLSameOrigin=require("./../helpers/isURLSameOrigin");var createError=require("../core/createError");module.exports=function xhrAdapter(config){return new Promise(function dispatchXhrRequest(resolve,reject){var requestData=config.data;var requestHeaders=config.headers;if(utils.isFormData(requestData)){delete requestHeaders["Content-Type"]}var request=new XMLHttpRequest;if(config.auth){var username=config.auth.username||"";var password=config.auth.password||"";requestHeaders.Authorization="Basic "+btoa(username+":"+password)}var fullPath=buildFullPath(config.baseURL,config.url);request.open(config.method.toUpperCase(),buildURL(fullPath,config.params,config.paramsSerializer),true);request.timeout=config.timeout;request.onreadystatechange=function handleLoad(){if(!request||request.readyState!==4){return}if(request.status===0&&!(request.responseURL&&request.responseURL.indexOf("file:")===0)){return}var responseHeaders="getAllResponseHeaders"in request?parseHeaders(request.getAllResponseHeaders()):null;var responseData=!config.responseType||config.responseType==="text"?request.responseText:request.response;var response={data:responseData,status:request.status,statusText:request.statusText,headers:responseHeaders,config:config,request:request};settle(resolve,reject,response);request=null};request.onabort=function handleAbort(){if(!request){return}reject(createError("Request aborted",config,"ECONNABORTED",request));request=null};request.onerror=function handleError(){reject(createError("Network Error",config,null,request));request=null};request.ontimeout=function handleTimeout(){var timeoutErrorMessage="timeout of "+config.timeout+"ms exceeded";if(config.timeoutErrorMessage){timeoutErrorMessage=config.timeoutErrorMessage}reject(createError(timeoutErrorMessage,config,"ECONNABORTED",request));request=null};if(utils.isStandardBrowserEnv()){var cookies=require("./../helpers/cookies");var xsrfValue=(config.withCredentials||isURLSameOrigin(fullPath))&&config.xsrfCookieName?cookies.read(config.xsrfCookieName):undefined;if(xsrfValue){requestHeaders[config.xsrfHeaderName]=xsrfValue}}if("setRequestHeader"in request){utils.forEach(requestHeaders,function setRequestHeader(val,key){if(typeof requestData==="undefined"&&key.toLowerCase()==="content-type"){delete requestHeaders[key]}else{request.setRequestHeader(key,val)}})}if(!utils.isUndefined(config.withCredentials)){request.withCredentials=!!config.withCredentials}if(config.responseType){try{request.responseType=config.responseType}catch(e){if(config.responseType!=="json"){throw e}}}if(typeof config.onDownloadProgress==="function"){request.addEventListener("progress",config.onDownloadProgress)}if(typeof config.onUploadProgress==="function"&&request.upload){request.upload.addEventListener("progress",config.onUploadProgress)}if(config.cancelToken){config.cancelToken.promise.then(function onCanceled(cancel){if(!request){return}request.abort();reject(cancel);request=null})}if(requestData===undefined){requestData=null}request.send(requestData)})}},{"../core/buildFullPath":10,"../core/createError":11,"./../core/settle":15,"./../helpers/buildURL":19,"./../helpers/cookies":21,"./../helpers/isURLSameOrigin":23,"./../helpers/parseHeaders":25,"./../utils":27}],4:[function(require,module,exports){"use strict";var utils=require("./utils");var bind=require("./helpers/bind");var Axios=require("./core/Axios");var mergeConfig=require("./core/mergeConfig");var defaults=require("./defaults");function createInstance(defaultConfig){var context=new Axios(defaultConfig);var instance=bind(Axios.prototype.request,context);utils.extend(instance,Axios.prototype,context);utils.extend(instance,context);return instance}var axios=createInstance(defaults);axios.Axios=Axios;axios.create=function create(instanceConfig){return createInstance(mergeConfig(axios.defaults,instanceConfig))};axios.Cancel=require("./cancel/Cancel");axios.CancelToken=require("./cancel/CancelToken");axios.isCancel=require("./cancel/isCancel");axios.all=function all(promises){return Promise.all(promises)};axios.spread=require("./helpers/spread");module.exports=axios;module.exports.default=axios},{"./cancel/Cancel":5,"./cancel/CancelToken":6,"./cancel/isCancel":7,"./core/Axios":8,"./core/mergeConfig":14,"./defaults":17,"./helpers/bind":18,"./helpers/spread":26,"./utils":27}],5:[function(require,module,exports){"use strict";function Cancel(message){this.message=message}Cancel.prototype.toString=function toString(){return"Cancel"+(this.message?": "+this.message:"")};Cancel.prototype.__CANCEL__=true;module.exports=Cancel},{}],6:[function(require,module,exports){"use strict";var Cancel=require("./Cancel");function CancelToken(executor){if(typeof executor!=="function"){throw new TypeError("executor must be a function.")}var resolvePromise;this.promise=new Promise(function promiseExecutor(resolve){resolvePromise=resolve});var token=this;executor(function cancel(message){if(token.reason){return}token.reason=new Cancel(message);resolvePromise(token.reason)})}CancelToken.prototype.throwIfRequested=function throwIfRequested(){if(this.reason){throw this.reason}};CancelToken.source=function source(){var cancel;var token=new CancelToken(function executor(c){cancel=c});return{token:token,cancel:cancel}};module.exports=CancelToken},{"./Cancel":5}],7:[function(require,module,exports){"use strict";module.exports=function isCancel(value){return!!(value&&value.__CANCEL__)}},{}],8:[function(require,module,exports){"use strict";var utils=require("./../utils");var buildURL=require("../helpers/buildURL");var InterceptorManager=require("./InterceptorManager");var dispatchRequest=require("./dispatchRequest");var mergeConfig=require("./mergeConfig");function Axios(instanceConfig){this.defaults=instanceConfig;this.interceptors={request:new InterceptorManager,response:new InterceptorManager}}Axios.prototype.request=function request(config){if(typeof config==="string"){config=arguments[1]||{};config.url=arguments[0]}else{config=config||{}}config=mergeConfig(this.defaults,config);if(config.method){config.method=config.method.toLowerCase()}else if(this.defaults.method){config.method=this.defaults.method.toLowerCase()}else{config.method="get"}var chain=[dispatchRequest,undefined];var promise=Promise.resolve(config);this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor){chain.unshift(interceptor.fulfilled,interceptor.rejected)});this.interceptors.response.forEach(function pushResponseInterceptors(interceptor){chain.push(interceptor.fulfilled,interceptor.rejected)});while(chain.length){promise=promise.then(chain.shift(),chain.shift())}return promise};Axios.prototype.getUri=function getUri(config){config=mergeConfig(this.defaults,config);return buildURL(config.url,config.params,config.paramsSerializer).replace(/^\?/,"")};utils.forEach(["delete","get","head","options"],function forEachMethodNoData(method){Axios.prototype[method]=function(url,config){return this.request(utils.merge(config||{},{method:method,url:url}))}});utils.forEach(["post","put","patch"],function forEachMethodWithData(method){Axios.prototype[method]=function(url,data,config){return this.request(utils.merge(config||{},{method:method,url:url,data:data}))}});module.exports=Axios},{"../helpers/buildURL":19,"./../utils":27,"./InterceptorManager":9,"./dispatchRequest":12,"./mergeConfig":14}],9:[function(require,module,exports){"use strict";var utils=require("./../utils");function InterceptorManager(){this.handlers=[]}InterceptorManager.prototype.use=function use(fulfilled,rejected){this.handlers.push({fulfilled:fulfilled,rejected:rejected});return this.handlers.length-1};InterceptorManager.prototype.eject=function eject(id){if(this.handlers[id]){this.handlers[id]=null}};InterceptorManager.prototype.forEach=function forEach(fn){utils.forEach(this.handlers,function forEachHandler(h){if(h!==null){fn(h)}})};module.exports=InterceptorManager},{"./../utils":27}],10:[function(require,module,exports){"use strict";var isAbsoluteURL=require("../helpers/isAbsoluteURL");var combineURLs=require("../helpers/combineURLs");module.exports=function buildFullPath(baseURL,requestedURL){if(baseURL&&!isAbsoluteURL(requestedURL)){return combineURLs(baseURL,requestedURL)}return requestedURL}},{"../helpers/combineURLs":20,"../helpers/isAbsoluteURL":22}],11:[function(require,module,exports){"use strict";var enhanceError=require("./enhanceError");module.exports=function createError(message,config,code,request,response){var error=new Error(message);return enhanceError(error,config,code,request,response)}},{"./enhanceError":13}],12:[function(require,module,exports){"use strict";var utils=require("./../utils");var transformData=require("./transformData");var isCancel=require("../cancel/isCancel");var defaults=require("../defaults");function throwIfCancellationRequested(config){if(config.cancelToken){config.cancelToken.throwIfRequested()}}module.exports=function dispatchRequest(config){throwIfCancellationRequested(config);config.headers=config.headers||{};config.data=transformData(config.data,config.headers,config.transformRequest);config.headers=utils.merge(config.headers.common||{},config.headers[config.method]||{},config.headers);utils.forEach(["delete","get","head","post","put","patch","common"],function cleanHeaderConfig(method){delete config.headers[method]});var adapter=config.adapter||defaults.adapter;return adapter(config).then(function onAdapterResolution(response){throwIfCancellationRequested(config);response.data=transformData(response.data,response.headers,config.transformResponse);return response},function onAdapterRejection(reason){if(!isCancel(reason)){throwIfCancellationRequested(config);if(reason&&reason.response){reason.response.data=transformData(reason.response.data,reason.response.headers,config.transformResponse)}}return Promise.reject(reason)})}},{"../cancel/isCancel":7,"../defaults":17,"./../utils":27,"./transformData":16}],13:[function(require,module,exports){"use strict";module.exports=function enhanceError(error,config,code,request,response){error.config=config;if(code){error.code=code}error.request=request;error.response=response;error.isAxiosError=true;error.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}};return error}},{}],14:[function(require,module,exports){"use strict";var utils=require("../utils");module.exports=function mergeConfig(config1,config2){config2=config2||{};var config={};var valueFromConfig2Keys=["url","method","params","data"];var mergeDeepPropertiesKeys=["headers","auth","proxy"];var defaultToConfig2Keys=["baseURL","url","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"];utils.forEach(valueFromConfig2Keys,function valueFromConfig2(prop){if(typeof config2[prop]!=="undefined"){config[prop]=config2[prop]}});utils.forEach(mergeDeepPropertiesKeys,function mergeDeepProperties(prop){if(utils.isObject(config2[prop])){config[prop]=utils.deepMerge(config1[prop],config2[prop])}else if(typeof config2[prop]!=="undefined"){config[prop]=config2[prop]}else if(utils.isObject(config1[prop])){config[prop]=utils.deepMerge(config1[prop])}else if(typeof config1[prop]!=="undefined"){config[prop]=config1[prop]}});utils.forEach(defaultToConfig2Keys,function defaultToConfig2(prop){if(typeof config2[prop]!=="undefined"){config[prop]=config2[prop]}else if(typeof config1[prop]!=="undefined"){config[prop]=config1[prop]}});var axiosKeys=valueFromConfig2Keys.concat(mergeDeepPropertiesKeys).concat(defaultToConfig2Keys);var otherKeys=Object.keys(config2).filter(function filterAxiosKeys(key){return axiosKeys.indexOf(key)===-1});utils.forEach(otherKeys,function otherKeysDefaultToConfig2(prop){if(typeof config2[prop]!=="undefined"){config[prop]=config2[prop]}else if(typeof config1[prop]!=="undefined"){config[prop]=config1[prop]}});return config}},{"../utils":27}],15:[function(require,module,exports){"use strict";var createError=require("./createError");module.exports=function settle(resolve,reject,response){var validateStatus=response.config.validateStatus;if(!validateStatus||validateStatus(response.status)){resolve(response)}else{reject(createError("Request failed with status code "+response.status,response.config,null,response.request,response))}}},{"./createError":11}],16:[function(require,module,exports){"use strict";var utils=require("./../utils");module.exports=function transformData(data,headers,fns){utils.forEach(fns,function transform(fn){data=fn(data,headers)});return data}},{"./../utils":27}],17:[function(require,module,exports){(function(process){"use strict";var utils=require("./utils");var normalizeHeaderName=require("./helpers/normalizeHeaderName");var DEFAULT_CONTENT_TYPE={"Content-Type":"application/x-www-form-urlencoded"};function setContentTypeIfUnset(headers,value){if(!utils.isUndefined(headers)&&utils.isUndefined(headers["Content-Type"])){headers["Content-Type"]=value}}function getDefaultAdapter(){var adapter;if(typeof XMLHttpRequest!=="undefined"){adapter=require("./adapters/xhr")}else if(typeof process!=="undefined"&&Object.prototype.toString.call(process)==="[object process]"){adapter=require("./adapters/http")}return adapter}var defaults={adapter:getDefaultAdapter(),transformRequest:[function transformRequest(data,headers){normalizeHeaderName(headers,"Accept");normalizeHeaderName(headers,"Content-Type");if(utils.isFormData(data)||utils.isArrayBuffer(data)||utils.isBuffer(data)||utils.isStream(data)||utils.isFile(data)||utils.isBlob(data)){return data}if(utils.isArrayBufferView(data)){return data.buffer}if(utils.isURLSearchParams(data)){setContentTypeIfUnset(headers,"application/x-www-form-urlencoded;charset=utf-8");return data.toString()}if(utils.isObject(data)){setContentTypeIfUnset(headers,"application/json;charset=utf-8");return JSON.stringify(data)}return data}],transformResponse:[function transformResponse(data){if(typeof data==="string"){try{data=JSON.parse(data)}catch(e){}}return data}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function validateStatus(status){return status>=200&&status<300}};defaults.headers={common:{Accept:"application/json, text/plain, */*"}};utils.forEach(["delete","get","head"],function forEachMethodNoData(method){defaults.headers[method]={}});utils.forEach(["post","put","patch"],function forEachMethodWithData(method){defaults.headers[method]=utils.merge(DEFAULT_CONTENT_TYPE)});module.exports=defaults}).call(this,require("_process"))},{"./adapters/http":3,"./adapters/xhr":3,"./helpers/normalizeHeaderName":24,"./utils":27,_process:246}],18:[function(require,module,exports){"use strict";module.exports=function bind(fn,thisArg){return function wrap(){var args=new Array(arguments.length);for(var i=0;i<args.length;i++){args[i]=arguments[i]}return fn.apply(thisArg,args)}}},{}],19:[function(require,module,exports){"use strict";var utils=require("./../utils");function encode(val){return encodeURIComponent(val).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}module.exports=function buildURL(url,params,paramsSerializer){if(!params){return url}var serializedParams;if(paramsSerializer){serializedParams=paramsSerializer(params)}else if(utils.isURLSearchParams(params)){serializedParams=params.toString()}else{var parts=[];utils.forEach(params,function serialize(val,key){if(val===null||typeof val==="undefined"){return}if(utils.isArray(val)){key=key+"[]"}else{val=[val]}utils.forEach(val,function parseValue(v){if(utils.isDate(v)){v=v.toISOString()}else if(utils.isObject(v)){v=JSON.stringify(v)}parts.push(encode(key)+"="+encode(v))})});serializedParams=parts.join("&")}if(serializedParams){var hashmarkIndex=url.indexOf("#");if(hashmarkIndex!==-1){url=url.slice(0,hashmarkIndex)}url+=(url.indexOf("?")===-1?"?":"&")+serializedParams}return url}},{"./../utils":27}],20:[function(require,module,exports){"use strict";module.exports=function combineURLs(baseURL,relativeURL){return relativeURL?baseURL.replace(/\/+$/,"")+"/"+relativeURL.replace(/^\/+/,""):baseURL}},{}],21:[function(require,module,exports){"use strict";var utils=require("./../utils");module.exports=utils.isStandardBrowserEnv()?function standardBrowserEnv(){return{write:function write(name,value,expires,path,domain,secure){var cookie=[];cookie.push(name+"="+encodeURIComponent(value));if(utils.isNumber(expires)){cookie.push("expires="+new Date(expires).toGMTString())}if(utils.isString(path)){cookie.push("path="+path)}if(utils.isString(domain)){cookie.push("domain="+domain)}if(secure===true){cookie.push("secure")}document.cookie=cookie.join("; ")},read:function read(name){var match=document.cookie.match(new RegExp("(^|;\\s*)("+name+")=([^;]*)"));return match?decodeURIComponent(match[3]):null},remove:function remove(name){this.write(name,"",Date.now()-864e5)}}}():function nonStandardBrowserEnv(){return{write:function write(){},read:function read(){return null},remove:function remove(){}}}()},{"./../utils":27}],22:[function(require,module,exports){"use strict";module.exports=function isAbsoluteURL(url){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url)}},{}],23:[function(require,module,exports){"use strict";var utils=require("./../utils");module.exports=utils.isStandardBrowserEnv()?function standardBrowserEnv(){var msie=/(msie|trident)/i.test(navigator.userAgent);var urlParsingNode=document.createElement("a");var originURL;function resolveURL(url){var href=url;if(msie){urlParsingNode.setAttribute("href",href);href=urlParsingNode.href}urlParsingNode.setAttribute("href",href);return{href:urlParsingNode.href,protocol:urlParsingNode.protocol?urlParsingNode.protocol.replace(/:$/,""):"",host:urlParsingNode.host,search:urlParsingNode.search?urlParsingNode.search.replace(/^\?/,""):"",hash:urlParsingNode.hash?urlParsingNode.hash.replace(/^#/,""):"",hostname:urlParsingNode.hostname,port:urlParsingNode.port,pathname:urlParsingNode.pathname.charAt(0)==="/"?urlParsingNode.pathname:"/"+urlParsingNode.pathname}}originURL=resolveURL(window.location.href);return function isURLSameOrigin(requestURL){var parsed=utils.isString(requestURL)?resolveURL(requestURL):requestURL;return parsed.protocol===originURL.protocol&&parsed.host===originURL.host}}():function nonStandardBrowserEnv(){return function isURLSameOrigin(){return true}}()},{"./../utils":27}],24:[function(require,module,exports){"use strict";var utils=require("../utils");module.exports=function normalizeHeaderName(headers,normalizedName){utils.forEach(headers,function processHeader(value,name){if(name!==normalizedName&&name.toUpperCase()===normalizedName.toUpperCase()){headers[normalizedName]=value;delete headers[name]}})}},{"../utils":27}],25:[function(require,module,exports){"use strict";var utils=require("./../utils");var ignoreDuplicateOf=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];module.exports=function parseHeaders(headers){var parsed={};var key;var val;var i;if(!headers){return parsed}utils.forEach(headers.split("\n"),function parser(line){i=line.indexOf(":");key=utils.trim(line.substr(0,i)).toLowerCase();val=utils.trim(line.substr(i+1));if(key){if(parsed[key]&&ignoreDuplicateOf.indexOf(key)>=0){return}if(key==="set-cookie"){parsed[key]=(parsed[key]?parsed[key]:[]).concat([val])}else{parsed[key]=parsed[key]?parsed[key]+", "+val:val}}});return parsed}},{"./../utils":27}],26:[function(require,module,exports){"use strict";module.exports=function spread(callback){return function wrap(arr){return callback.apply(null,arr)}}},{}],27:[function(require,module,exports){"use strict";var bind=require("./helpers/bind");var toString=Object.prototype.toString;function isArray(val){return toString.call(val)==="[object Array]"}function isUndefined(val){return typeof val==="undefined"}function isBuffer(val){return val!==null&&!isUndefined(val)&&val.constructor!==null&&!isUndefined(val.constructor)&&typeof val.constructor.isBuffer==="function"&&val.constructor.isBuffer(val)}function isArrayBuffer(val){return toString.call(val)==="[object ArrayBuffer]"}function isFormData(val){return typeof FormData!=="undefined"&&val instanceof FormData}function isArrayBufferView(val){var result;if(typeof ArrayBuffer!=="undefined"&&ArrayBuffer.isView){result=ArrayBuffer.isView(val)}else{result=val&&val.buffer&&val.buffer instanceof ArrayBuffer}return result}function isString(val){return typeof val==="string"}function isNumber(val){return typeof val==="number"}function isObject(val){return val!==null&&typeof val==="object"}function isDate(val){return toString.call(val)==="[object Date]"}function isFile(val){return toString.call(val)==="[object File]"}function isBlob(val){return toString.call(val)==="[object Blob]"}function isFunction(val){return toString.call(val)==="[object Function]"}function isStream(val){return isObject(val)&&isFunction(val.pipe)}function isURLSearchParams(val){return typeof URLSearchParams!=="undefined"&&val instanceof URLSearchParams}function trim(str){return str.replace(/^\s*/,"").replace(/\s*$/,"")}function isStandardBrowserEnv(){if(typeof navigator!=="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")){return false}return typeof window!=="undefined"&&typeof document!=="undefined"}function forEach(obj,fn){if(obj===null||typeof obj==="undefined"){return}if(typeof obj!=="object"){obj=[obj]}if(isArray(obj)){for(var i=0,l=obj.length;i<l;i++){fn.call(null,obj[i],i,obj)}}else{for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key)){fn.call(null,obj[key],key,obj)}}}}function merge(){var result={};function assignValue(val,key){if(typeof result[key]==="object"&&typeof val==="object"){result[key]=merge(result[key],val)}else{result[key]=val}}for(var i=0,l=arguments.length;i<l;i++){forEach(arguments[i],assignValue)}return result}function deepMerge(){var result={};function assignValue(val,key){if(typeof result[key]==="object"&&typeof val==="object"){result[key]=deepMerge(result[key],val)}else if(typeof val==="object"){result[key]=deepMerge({},val)}else{result[key]=val}}for(var i=0,l=arguments.length;i<l;i++){forEach(arguments[i],assignValue)}return result}function extend(a,b,thisArg){forEach(b,function assignValue(val,key){if(thisArg&&typeof val==="function"){a[key]=bind(val,thisArg)}else{a[key]=val}});return a}module.exports={isArray:isArray,isArrayBuffer:isArrayBuffer,isBuffer:isBuffer,isFormData:isFormData,isArrayBufferView:isArrayBufferView,isString:isString,isNumber:isNumber,isObject:isObject,isUndefined:isUndefined,isDate:isDate,isFile:isFile,isBlob:isBlob,isFunction:isFunction,isStream:isStream,isURLSearchParams:isURLSearchParams,isStandardBrowserEnv:isStandardBrowserEnv,forEach:forEach,merge:merge,deepMerge:deepMerge,extend:extend,trim:trim}},{"./helpers/bind":18}],28:[function(require,module,exports){"use strict";var _Buffer=require("safe-buffer").Buffer;function base(ALPHABET){if(ALPHABET.length>=255){throw new TypeError("Alphabet too long")}var BASE_MAP=new Uint8Array(256);for(var j=0;j<BASE_MAP.length;j++){BASE_MAP[j]=255}for(var i=0;i<ALPHABET.length;i++){var x=ALPHABET.charAt(i);var xc=x.charCodeAt(0);if(BASE_MAP[xc]!==255){throw new TypeError(x+" is ambiguous")}BASE_MAP[xc]=i}var BASE=ALPHABET.length;var LEADER=ALPHABET.charAt(0);var FACTOR=Math.log(BASE)/Math.log(256);var iFACTOR=Math.log(256)/Math.log(BASE);function encode(source){if(Array.isArray(source)||source instanceof Uint8Array){source=_Buffer.from(source)}if(!_Buffer.isBuffer(source)){throw new TypeError("Expected Buffer")}if(source.length===0){return""}var zeroes=0;var length=0;var pbegin=0;var pend=source.length;while(pbegin!==pend&&source[pbegin]===0){pbegin++;zeroes++}var size=(pend-pbegin)*iFACTOR+1>>>0;var b58=new Uint8Array(size);while(pbegin!==pend){var carry=source[pbegin];var i=0;for(var it1=size-1;(carry!==0||i<length)&&it1!==-1;it1--,i++){carry+=256*b58[it1]>>>0;b58[it1]=carry%BASE>>>0;carry=carry/BASE>>>0}if(carry!==0){throw new Error("Non-zero carry")}length=i;pbegin++}var it2=size-length;while(it2!==size&&b58[it2]===0){it2++}var str=LEADER.repeat(zeroes);for(;it2<size;++it2){str+=ALPHABET.charAt(b58[it2])}return str}function decodeUnsafe(source){if(typeof source!=="string"){throw new TypeError("Expected String")}if(source.length===0){return _Buffer.alloc(0)}var psz=0;if(source[psz]===" "){return}var zeroes=0;var length=0;while(source[psz]===LEADER){zeroes++;psz++}var size=(source.length-psz)*FACTOR+1>>>0;var b256=new Uint8Array(size);while(source[psz]){var carry=BASE_MAP[source.charCodeAt(psz)];if(carry===255){return}var i=0;for(var it3=size-1;(carry!==0||i<length)&&it3!==-1;it3--,i++){carry+=BASE*b256[it3]>>>0;b256[it3]=carry%256>>>0;carry=carry/256>>>0}if(carry!==0){throw new Error("Non-zero carry")}length=i;psz++}if(source[psz]===" "){return}var it4=size-length;while(it4!==size&&b256[it4]===0){it4++}var vch=_Buffer.allocUnsafe(zeroes+(size-it4));vch.fill(0,0,zeroes);var j=zeroes;while(it4!==size){vch[j++]=b256[it4++]}return vch}function decode(string){var buffer=decodeUnsafe(string);if(buffer){return buffer}throw new Error("Non-base"+BASE+" character")}return{encode:encode,decodeUnsafe:decodeUnsafe,decode:decode}}module.exports=base},{"safe-buffer":123}],29:[function(require,module,exports){"use strict";exports.byteLength=byteLength;exports.toByteArray=toByteArray;exports.fromByteArray=fromByteArray;var lookup=[];var revLookup=[];var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i=0,len=code.length;i<len;++i){lookup[i]=code[i];revLookup[code.charCodeAt(i)]=i}revLookup["-".charCodeAt(0)]=62;revLookup["_".charCodeAt(0)]=63;function getLens(b64){var len=b64.length;if(len%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var validLen=b64.indexOf("=");if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen]}function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;var len=placeHoldersLen>0?validLen-4:validLen;for(var i=0;i<len;i+=4){tmp=revLookup[b64.charCodeAt(i)]<<18|revLookup[b64.charCodeAt(i+1)]<<12|revLookup[b64.charCodeAt(i+2)]<<6|revLookup[b64.charCodeAt(i+3)];arr[curByte++]=tmp>>16&255;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&255}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&255;arr[curByte++]=tmp&255}return arr}function tripletToBase64(num){return lookup[num>>18&63]+lookup[num>>12&63]+lookup[num>>6&63]+lookup[num&63]}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;i<end;i+=3){tmp=(uint8[i]<<16&16711680)+(uint8[i+1]<<8&65280)+(uint8[i+2]&255);output.push(tripletToBase64(tmp))}return output.join("")}function fromByteArray(uint8){var tmp;var len=uint8.length;var extraBytes=len%3;var parts=[];var maxChunkLength=16383;for(var i=0,len2=len-extraBytes;i<len2;i+=maxChunkLength){parts.push(encodeChunk(uint8,i,i+maxChunkLength>len2?len2:i+maxChunkLength))}if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&63]+"==")}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&63]+lookup[tmp<<2&63]+"=")}return parts.join("")}},{}],30:[function(require,module,exports){(function(module,exports){"use strict";function assert(val,msg){if(!val)throw new Error(msg||"Assertion failed")}function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor;ctor.prototype.constructor=ctor}function BN(number,base,endian){if(BN.isBN(number)){return number}this.negative=0;this.words=null;this.length=0;this.red=null;if(number!==null){if(base==="le"||base==="be"){endian=base;base=10}this._init(number||0,base||10,endian||"be")}}if(typeof module==="object"){module.exports=BN}else{exports.BN=BN}BN.BN=BN;BN.wordSize=26;var Buffer;try{Buffer=require("buffer").Buffer}catch(e){}BN.isBN=function isBN(num){if(num instanceof BN){return true}return num!==null&&typeof num==="object"&&num.constructor.wordSize===BN.wordSize&&Array.isArray(num.words)};BN.max=function max(left,right){if(left.cmp(right)>0)return left;return right};BN.min=function min(left,right){if(left.cmp(right)<0)return left;return right};BN.prototype._init=function init(number,base,endian){if(typeof number==="number"){return this._initNumber(number,base,endian)}if(typeof number==="object"){return this._initArray(number,base,endian)}if(base==="hex"){base=16}assert(base===(base|0)&&base>=2&&base<=36);number=number.toString().replace(/\s+/g,"");var start=0;if(number[0]==="-"){start++}if(base===16){this._parseHex(number,start)}else{this._parseBase(number,base,start)}if(number[0]==="-"){this.negative=1}this.strip();if(endian!=="le")return;this._initArray(this.toArray(),base,endian)};BN.prototype._initNumber=function _initNumber(number,base,endian){if(number<0){this.negative=1;number=-number}if(number<67108864){this.words=[number&67108863];this.length=1}else if(number<4503599627370496){this.words=[number&67108863,number/67108864&67108863];this.length=2}else{assert(number<9007199254740992);this.words=[number&67108863,number/67108864&67108863,1];this.length=3}if(endian!=="le")return;this._initArray(this.toArray(),base,endian)};BN.prototype._initArray=function _initArray(number,base,endian){assert(typeof number.length==="number");if(number.length<=0){this.words=[0];this.length=1;return this}this.length=Math.ceil(number.length/3);this.words=new Array(this.length);for(var i=0;i<this.length;i++){this.words[i]=0}var j,w;var off=0;if(endian==="be"){for(i=number.length-1,j=0;i>=0;i-=3){w=number[i]|number[i-1]<<8|number[i-2]<<16;this.words[j]|=w<<off&67108863;this.words[j+1]=w>>>26-off&67108863;off+=24;if(off>=26){off-=26;j++}}}else if(endian==="le"){for(i=0,j=0;i<number.length;i+=3){w=number[i]|number[i+1]<<8|number[i+2]<<16;this.words[j]|=w<<off&67108863;this.words[j+1]=w>>>26-off&67108863;off+=24;if(off>=26){off-=26;j++}}}return this.strip()};function parseHex(str,start,end){var r=0;var len=Math.min(str.length,end);for(var i=start;i<len;i++){var c=str.charCodeAt(i)-48;r<<=4;if(c>=49&&c<=54){r|=c-49+10}else if(c>=17&&c<=22){r|=c-17+10}else{r|=c&15}}return r}BN.prototype._parseHex=function _parseHex(number,start){this.length=Math.ceil((number.length-start)/6);this.words=new Array(this.length);for(var i=0;i<this.length;i++){this.words[i]=0}var j,w;var off=0;for(i=number.length-6,j=0;i>=start;i-=6){w=parseHex(number,i,i+6);this.words[j]|=w<<off&67108863;this.words[j+1]|=w>>>26-off&4194303;off+=24;if(off>=26){off-=26;j++}}if(i+6!==start){w=parseHex(number,start,i+6);this.words[j]|=w<<off&67108863;this.words[j+1]|=w>>>26-off&4194303}this.strip()};function parseBase(str,start,end,mul){var r=0;var len=Math.min(str.length,end);for(var i=start;i<len;i++){var c=str.charCodeAt(i)-48;r*=mul;if(c>=49){r+=c-49+10}else if(c>=17){r+=c-17+10}else{r+=c}}return r}BN.prototype._parseBase=function _parseBase(num