From 3fae41f0aebcd889f11cdafbc9464698c1792c28 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 16 Apr 2018 12:33:37 -0300 Subject: [PATCH] bump --- bitcore-wallet-client.min.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bitcore-wallet-client.min.js b/bitcore-wallet-client.min.js index c5ab7bff..f7ad8a29 100644 --- a/bitcore-wallet-client.min.js +++ b/bitcore-wallet-client.min.js @@ -1,5 +1,5 @@ !function(){function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g0&&(c.lastNotificationId=e.last(d).id),e.each(d,function(a){c.emit("notification",a)}),b())})},d.prototype._initNotifications=function(a){var b=this;a=a||{};var c=a.notificationIntervalSeconds||5;b.notificationsIntervalId=setInterval(function(){b._fetchLatestNotifications(c,function(a){a&&(a instanceof x.NOT_FOUND||a instanceof x.NOT_AUTHORIZED)&&b._disposeNotifications()})},1e3*c)},d.prototype._disposeNotifications=function(){var a=this;a.notificationsIntervalId&&(clearInterval(a.notificationsIntervalId),a.notificationsIntervalId=null)},d.prototype.setNotificationsInterval=function(a){var b=this;b._disposeNotifications(),a>0&&b._initNotifications({notificationIntervalSeconds:a})},d._encryptMessage=function(a,b){return a?r.encryptMessage(a,b):null},d._decryptMessage=function(a,b){if(!a)return"";try{return r.decryptMessage(a,b)}catch(c){return""}},d.prototype._processTxNotes=function(a){var b=this;if(a){var c=b.credentials.sharedEncryptingKey;e.each([].concat(a),function(a){a.encryptedBody=a.body,a.body=d._decryptMessage(a.body,c),a.encryptedEditedByName=a.editedByName,a.editedByName=d._decryptMessage(a.editedByName,c)})}},d.prototype._processTxps=function(a){var b=this;if(a){var c=b.credentials.sharedEncryptingKey;e.each([].concat(a),function(a){a.encryptedMessage=a.message,a.message=d._decryptMessage(a.message,c)||null,a.creatorName=d._decryptMessage(a.creatorName,c),e.each(a.actions,function(a){a.copayerName=d._decryptMessage(a.copayerName,c),a.comment=d._decryptMessage(a.comment,c)}),e.each(a.outputs,function(a){a.encryptedMessage=a.message,a.message=d._decryptMessage(a.message,c)||null}),a.hasUnconfirmedInputs=e.some(a.inputs,function(a){return 0==a.confirmations}),b._processTxNotes(a.note)})}},d._parseError=function(a){if(a){if(e.isString(a))try{a=JSON.parse(a)}catch(b){a={error:a}}var c;return a.code?x[a.code]?(c=new x[a.code],a.message&&(c.message=a.message)):c=new Error(a.code+": "+a.message):c=new Error(a.error||JSON.stringify(a)),t.error(c),c}},d._signRequest=function(a,b,c,d){var e=[a.toLowerCase(),b,JSON.stringify(c)].join("|");return r.signMessage(e,d)},d.prototype.seedFromRandom=function(a){f.checkArgument(arguments.length<=1,"DEPRECATED: only 1 argument accepted."),f.checkArgument(e.isUndefined(a)||e.isObject(a),"DEPRECATED: argument should be an options object."),a=a||{},this.credentials=u.create(a.coin||"btc",a.network||"livenet")};var z;d.prototype.validateKeyDerivation=function(a,b){function c(a,b){var c="m/0/0",d="Lorem ipsum dolor sit amet, ne amet urbanitas percipitur vim, libris disputando his ne, et facer suavitate qui. Ei quidam laoreet sea. Cu pro dico aliquip gubergren, in mundi postea usu. Ad labitur posidonium interesset duo, est et doctus molestie adipiscing.",e=a.deriveChild(c).privateKey,f=r.signMessage(d,e),g=b.deriveChild(c).publicKey;return r.verifyMessage(d,f,g)}function d(){var a="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about",b=l(a).toHDPrivateKey();if("xprv9s21ZrQH143K3GJpoapnV8SFfukcVBSfeCficPSGfubmSFDxo1kuHnLisriDvSnRRuL2Qrg5ggqHKNVpxR86QEC8w35uxmGoggxtQTPvfUu"!=b.toString())return!1;if(b=b.deriveChild("m/44'/0'/0'"),"xprv9xpXFhFpqdQK3TmytPBqXtGSwS3DLjojFhTGht8gwAAii8py5X6pxeBnQ6ehJiyJ6nDjWGJfZ95WxByFXVkDxHXrqu53WCRGypk2ttuqncb"!=b.toString())return!1;var d=j.HDPublicKey.fromString("xpub6BosfCnifzxcFwrSzQiqu2DBVTshkCXacvNsWGYJVVhhawA7d4R5WSWGFNbi8Aw6ZRc1brxMyWMzG3DSSSSoekkudhUd9yLb6qx39T9nMdj");return c(b,d)}function e(){var b;try{b=g.getMnemonic()}catch(d){}var e;if(b&&(!g.mnemonicHasPassphrase||a.passphrase)){var f=new l(b);e=f.toHDPrivateKey(a.passphrase,g.network)}e||(e=new j.HDPrivateKey(g.xPrivKey)),e=e.deriveChild(g.getBaseAddressDerivationPath());var h=new j.HDPublicKey(g.xPubKey);return c(e,h)}var f=this;a=a||{};var g=f.credentials,h=!0;z||a.skipDeviceValidation||(h=d(),z=!0);var i=g.canSign()&&!g.isPrivKeyEncrypted()?e():!0;return f.keyDerivationOk=h&&i,b(null,f.keyDerivationOk)},d.prototype.seedFromRandomWithMnemonic=function(a){f.checkArgument(arguments.length<=1,"DEPRECATED: only 1 argument accepted."),f.checkArgument(e.isUndefined(a)||e.isObject(a),"DEPRECATED: argument should be an options object."),a=a||{},this.credentials=u.createWithMnemonic(a.coin||"btc",a.network||"livenet",a.passphrase,a.language||"en",a.account||0)},d.prototype.getMnemonic=function(){return this.credentials.getMnemonic()},d.prototype.mnemonicHasPassphrase=function(){return this.credentials.mnemonicHasPassphrase},d.prototype.clearMnemonic=function(){return this.credentials.clearMnemonic()},d.prototype.seedFromExtendedPrivateKey=function(a,b){b=b||{},this.credentials=u.fromExtendedPrivateKey(b.coin||"btc",a,b.account||0,b.derivationStrategy||q.DERIVATION_STRATEGIES.BIP44,b)},d.prototype.seedFromMnemonic=function(a,b){f.checkArgument(e.isUndefined(b)||e.isObject(b),"DEPRECATED: second argument should be an options object."),b=b||{},this.credentials=u.fromMnemonic(b.coin||"btc",b.network||"livenet",a,b.passphrase,b.account||0,b.derivationStrategy||q.DERIVATION_STRATEGIES.BIP44,b)},d.prototype.seedFromExtendedPublicKey=function(a,b,c,d){f.checkArgument(e.isUndefined(d)||e.isObject(d)),d=d||{},this.credentials=u.fromExtendedPublicKey(d.coin||"btc",a,b,c,d.account||0,d.derivationStrategy||q.DERIVATION_STRATEGIES.BIP44)},d.prototype["export"]=function(a){f.checkState(this.credentials),a=a||{};var b,c=u.fromObj(this.credentials);return a.noSign?c.setNoSign():a.password&&c.decryptPrivateKey(a.password),b=JSON.stringify(c.toObj())},d.prototype["import"]=function(a){try{var b=u.fromObj(JSON.parse(a));this.credentials=b}catch(c){throw new x.INVALID_BACKUP}},d.prototype._import=function(a){f.checkState(this.credentials);var b=this;b.openWallet(function(c,d){return c?c instanceof x.NOT_AUTHORIZED||b.isPrivKeyExternal()?a(c):(t.info("Copayer not found, trying to add access"),void b.addAccess({},function(c){return c?a(new x.WALLET_DOES_NOT_EXIST):void b.openWallet(a)})):a(null,d)})},d.prototype.importFromMnemonic=function(a,b,c){function d(c){return u.fromMnemonic(b.coin||"btc",b.network||"livenet",a,b.passphrase,b.account||0,b.derivationStrategy||q.DERIVATION_STRATEGIES.BIP44,{nonCompliantDerivation:c,entropySourcePath:b.entropySourcePath,walletPrivKey:b.walletPrivKey})}t.debug("Importing from 12 Words");var e=this;b=b||{};try{e.credentials=d(!1)}catch(f){return t.info("Mnemonic error:",f),c(new x.INVALID_BACKUP)}e._import(function(a,b){if(!a)return c(null,b);if(a instanceof x.INVALID_BACKUP)return c(a);if(a instanceof x.NOT_AUTHORIZED||a instanceof x.WALLET_DOES_NOT_EXIST){var f=d(!0);return f.xPubKey.toString()==e.credentials.xPubKey.toString()?c(a):(e.credentials=f,e._import(c))}return c(a)})},d.prototype.importFromExtendedPrivateKey=function(a,b,c){t.debug("Importing from Extended Private Key"),c||(c=b,b={},t.warn("DEPRECATED WARN: importFromExtendedPrivateKey should receive 3 parameters."));try{this.credentials=u.fromExtendedPrivateKey(b.coin||"btc",a,b.account||0,b.derivationStrategy||q.DERIVATION_STRATEGIES.BIP44,b)}catch(d){return t.info("xPriv error:",d),c(new x.INVALID_BACKUP)}this._import(c)},d.prototype.importFromExtendedPublicKey=function(a,b,c,d,g){f.checkArgument(5==arguments.length,"DEPRECATED: should receive 5 arguments"),f.checkArgument(e.isUndefined(d)||e.isObject(d)),f.shouldBeFunction(g),d=d||{},t.debug("Importing from Extended Private Key");try{this.credentials=u.fromExtendedPublicKey(d.coin||"btc",a,b,c,d.account||0,d.derivationStrategy||q.DERIVATION_STRATEGIES.BIP44,d)}catch(h){return t.info("xPriv error:",h),g(new x.INVALID_BACKUP)}this._import(g)},d.prototype.decryptBIP38PrivateKey=function(b,d,e,f){var g,h=a("bip38"),i=new h;try{g=i.decrypt(b,d)}catch(k){return f(new Error("Could not decrypt BIP38 private key",k))}var l=new j.PrivateKey(g),m=l.publicKey.toAddress().toString(),n=new c(m,"ascii"),o=j.crypto.Hash.sha256sha256(n).toString("hex").substring(0,8),p=j.encoding.Base58Check.decode(b).toString("hex").substring(6,14);return o!=p?f(new Error("Incorrect passphrase")):f(null,g)},d.prototype.getBalanceFromPrivateKey=function(a,b,c){var d=this;e.isFunction(b)&&(c=b,b="btc");var f=k[b],a=new f.PrivateKey(a),g=a.publicKey.toAddress();d.getUtxos({addresses:g.toString()},function(a,b){return a?c(a):c(null,e.sumBy(b,"satoshis"))})},d.prototype.buildTxFromPrivateKey=function(a,b,c,d){var f=this;c=c||{};var g=c.coin||"btc",i=k[g],a=i.PrivateKey(a),j=a.publicKey.toAddress();h.waterfall([function(a){f.getUtxos({addresses:j.toString()},function(b,c){return a(b,c)})},function(d,f){if(!e.isArray(d)||0==d.length)return f(new Error("No utxos found"));var g=c.fee||1e4,h=e.sumBy(d,"satoshis")-g;if(0>=h)return f(new x.INSUFFICIENT_FUNDS);var j;try{var k=i.Address.fromString(b);j=(new i.Transaction).from(d).to(k,h).fee(g).sign(a),j.serialize()}catch(l){return t.error("Could not build transaction from private key",l),f(new x.COULD_NOT_BUILD_TRANSACTION)}return f(null,j)}],d)},d.prototype.openWallet=function(a){f.checkState(this.credentials);var b=this;return b.credentials.isComplete()&&b.credentials.hasWalletInfo()?a(null,!0):void b._doGetRequest("/v2/wallets/?includeExtendedInfo=1",function(c,f){if(c)return a(c);var g=f.wallet;if(b._processStatus(f),!b.credentials.hasWalletInfo()){var h=e.find(g.copayers,{id:b.credentials.copayerId});b.credentials.addWalletInfo(g.id,g.name,g.m,g.n,h.name)}if("complete"!=g.status)return a();if(b.credentials.walletPrivKey){if(!v.checkCopayers(b.credentials,g.copayers))return a(new x.SERVER_COMPROMISED)}else t.warn("Could not verify copayers key (missing wallet Private Key)");return b.credentials.addPublicKeyRing(d._extractPublicKeyRing(g.copayers)),b.emit("walletCompleted",g),a(null,f)})},d.prototype._getHeaders=function(a,b,c){var d={"x-client-version":"bwc-"+w.version};return this.supportStaffWalletId&&(d["x-wallet-id"]=this.supportStaffWalletId),d},d.prototype._doRequest=function(a,b,c,f,h){var i=this,j=i._getHeaders(a,b,c);if(i.credentials)if(j["x-identity"]=i.credentials.copayerId,f&&i.session)j["x-session"]=i.session;else{var k,l=c._requestPrivKey||i.credentials.requestPrivKey;l&&(delete c._requestPrivKey,k=d._signRequest(a,b,c,l)),j["x-signature"]=k}var m=i.request[a](i.baseUrl+b);m.accept("json"),e.each(j,function(a,b){a&&m.set(b,a)}),c&&("post"==a||"put"==a?m.send(c):m.query(c)),m.timeout(i.timeout),m.end(function(a,b){return b?(b.body&&t.debug(g.inspect(b.body,{depth:10})),200!==b.status?404===b.status?h(new x.NOT_FOUND):b.status?(t.error("HTTP Error:"+b.status),h(b.body?d._parseError(b.body):new Error(b.status))):h(new x.CONNECTION_ERROR):'{"error":"read ECONNRESET"}'===b.body?h(new x.ECONNRESET_ERROR(JSON.parse(b.body))):h(null,b.body,b.header)):h(new x.CONNECTION_ERROR)})},d.prototype._login=function(a){this._doPostRequest("/v1/login",{},a)},d.prototype._logout=function(a){this._doPostRequest("/v1/logout",{},a)},d.prototype._doRequestWithLogin=function(a,b,c,d){function e(a){f._login(function(b,c){return b?a(b):c?(f.session=c,void a()):a(new x.NOT_AUTHORIZED)})}var f=this;h.waterfall([function(a){return f.session?a():void e(a)},function(d){f._doRequest(a,b,c,!0,function(g,h,i){g&&g instanceof x.NOT_AUTHORIZED&&e(function(e){return e?d(e):f._doRequest(a,b,c,!0,d)}),d(null,h,i)})}],d)},d.prototype._doPostRequest=function(a,b,c){return this._doRequest("post",a,b,!1,c)},d.prototype._doPutRequest=function(a,b,c){return this._doRequest("put",a,b,!1,c)},d.prototype._doGetRequest=function(a,b){return a+=a.indexOf("?")>0?"&":"?",a+="r="+e.random(1e4,99999),this._doRequest("get",a,{},!1,b)},d.prototype._doGetRequestWithLogin=function(a,b){return a+=a.indexOf("?")>0?"&":"?",a+="r="+e.random(1e4,99999),this._doRequestWithLogin("get",a,{},b)},d.prototype._doDeleteRequest=function(a,b){return this._doRequest("delete",a,{},!1,b)},d._buildSecret=function(a,b,d,f){e.isString(b)&&(b=j.PrivateKey.fromString(b));var g=new c(a.replace(/-/g,""),"hex"),h=new j.encoding.Base58(g).toString();return e.padEnd(h,22,"0")+b.toWIF()+("testnet"==f?"T":"L")+d},d.parseSecret=function(a){function b(a,b){var c=[];b.push(a.length);for(var d=0;d1?j:null)})})},d.prototype.joinWallet=function(a,b,c,f){var g=this;if(f||(f=c,c={},t.warn("DEPRECATED WARN: joinWallet should receive 4 parameters.")),!g._checkKeyDerivation())return f(new Error("Cannot join wallet"));c=c||{};var h=c.coin||"btc";if(!e.includes(["btc","bch"],h))return f(new Error("Invalid coin"));try{var i=d.parseSecret(a)}catch(j){return f(j)}g.credentials||g.seedFromRandom({coin:h,network:i.network}),g.credentials.addWalletPrivateKey(i.walletPrivKey.toString()),g._doJoinWallet(i.walletId,i.walletPrivKey,g.credentials.xPubKey,g.credentials.requestPubKey,b,{coin:h,dryRun:!!c.dryRun},function(a,d){return a?f(a):(c.dryRun||g.credentials.addWalletInfo(d.id,d.name,d.m,d.n,b),f(null,d))})},d.prototype.recreateWallet=function(a){f.checkState(this.credentials),f.checkState(this.credentials.isComplete()),f.checkState(this.credentials.walletPrivKey);var b=this;this.getStatus({includeExtendedInfo:!0},function(c){if(!c)return t.info("Wallet is already created"),a();var d=b.credentials,e=j.PrivateKey.fromString(d.walletPrivKey),f=d.walletId,g=d.derivationStrategy!=q.DERIVATION_STRATEGIES.BIP45,i=r.encryptMessage(d.walletName||"recovered wallet",d.sharedEncryptingKey),k=(d.coin,{name:i,m:d.m,n:d.n,pubKey:e.toPublicKey().toString(),coin:d.coin,network:d.network,id:f,supportBIP44AndP2PKH:g});b._doPostRequest("/v2/wallets/",k,function(c,i){if(c)return c instanceof x.WALLET_ALREADY_EXISTS?b.addAccess({},function(c){return c?a(c):void b.openWallet(function(b){return a(b)})}):a(c);f||(f=i.walletId);var j=1;h.each(b.credentials.publicKeyRing,function(a,c){var h=a.copayerName||"copayer "+j++;b._doJoinWallet(f,e,a.xPubKey,a.requestPubKey,h,{coin:d.coin,supportBIP44AndP2PKH:g},function(a){return a&&a instanceof x.COPAYER_IN_WALLET?c():c(a)})},a)})})},d.prototype._processWallet=function(a){var b=this,c=b.credentials.sharedEncryptingKey,d=r.decryptMessageNoThrow(a.name,c);d!=a.name&&(a.encryptedName=a.name),a.name=d,e.each(a.copayers,function(a){var b=r.decryptMessageNoThrow(a.name,c);b!=a.name&&(a.encryptedName=a.name),a.name=b,e.each(a.requestPubKeys,function(a){if(a.name){var b=r.decryptMessageNoThrow(a.name,c);b!=a.name&&(a.encryptedName=a.name),a.name=b}})})},d.prototype._processStatus=function(a){function b(a){var b=a.wallet.copayers;if(b){var d=e.find(b,{id:c.credentials.copayerId});if(d&&d.customData){var f;try{f=JSON.parse(r.decryptMessage(d.customData,c.credentials.personalEncryptingKey))}catch(g){t.warn("Could not decrypt customData:",d.customData)}f&&(a.customData=f,!c.credentials.walletPrivKey&&f.walletPrivKey&&c.credentials.addWalletPrivateKey(f.walletPrivKey))}}}var c=this;b(a),c._processWallet(a.wallet),c._processTxps(a.pendingTxps)},d.prototype.getNotifications=function(a,b){f.checkState(this.credentials);var c=this;a=a||{};var d="/v1/notifications/";a.lastNotificationId?d+="?notificationId="+a.lastNotificationId:a.timeSpan&&(d+="?timeSpan="+a.timeSpan),c._doGetRequestWithLogin(d,function(d,f){if(d)return b(d);var g=e.filter(f,function(b){return a.includeOwn||b.creatorId!=c.credentials.copayerId});return b(null,g)})},d.prototype.getStatus=function(a,b){f.checkState(this.credentials),b||(b=a,a={},t.warn("DEPRECATED WARN: getStatus should receive 2 parameters."));var c=this;a=a||{};var e=[];e.push("includeExtendedInfo="+(a.includeExtendedInfo?"1":"0")),e.push("twoStep="+(a.twoStep?"1":"0")),c._doGetRequest("/v2/wallets/?"+e.join("&"),function(a,e){if(a)return b(a);if("pending"==e.wallet.status){var f=c.credentials;e.wallet.secret=d._buildSecret(f.walletId,f.walletPrivKey,f.coin,f.network)}return c._processStatus(e),b(a,e)})},d.prototype.getPreferences=function(a){f.checkState(this.credentials),f.checkArgument(a);var b=this;b._doGetRequest("/v1/preferences/",function(b,c){return b?a(b):a(null,c)})},d.prototype.savePreferences=function(a,b){f.checkState(this.credentials),f.checkArgument(b);var c=this;c._doPutRequest("/v1/preferences/",a,b)},d.prototype.fetchPayPro=function(a,b){f.checkArgument(a).checkArgument(a.payProUrl),s.get({url:a.payProUrl,http:this.payProHttp,coin:this.credentials.coin||"btc"},function(a,c){return a?b(a):b(null,c)})},d.prototype.getUtxos=function(a,b){f.checkState(this.credentials&&this.credentials.isComplete()),a=a||{};var c="/v1/utxos/";a.addresses&&(c+="?"+n.stringify({addresses:[].concat(a.addresses).join(",")})),this._doGetRequest(c,b)},d.prototype._getCreateTxProposalArgs=function(a){var b=this,c=e.cloneDeep(a);return c.message=d._encryptMessage(a.message,this.credentials.sharedEncryptingKey)||null,c.payProUrl=a.payProUrl||null,e.each(c.outputs,function(a){a.message=d._encryptMessage(a.message,b.credentials.sharedEncryptingKey)||null}),c},d.prototype.createTxProposal=function(a,b){f.checkState(this.credentials&&this.credentials.isComplete()),f.checkState(this.credentials.sharedEncryptingKey),f.checkArgument(a);var c=this,d=c._getCreateTxProposalArgs(a);c._doPostRequest("/v2/txproposals/",d,function(a,e){return a?b(a):(c._processTxps(e),v.checkProposalCreation(d,e,c.credentials.sharedEncryptingKey)?b(null,e):b(new x.SERVER_COMPROMISED))})},d.prototype.publishTxProposal=function(a,b){f.checkState(this.credentials&&this.credentials.isComplete()),f.checkArgument(a).checkArgument(a.txp),f.checkState(parseInt(a.txp.version)>=3);var c=this,d=r.buildTx(a.txp),e=d.uncheckedSerialize(),g={proposalSignature:r.signMessage(e,c.credentials.requestPrivKey)},h="/v1/txproposals/"+a.txp.id+"/publish/";c._doPostRequest(h,g,function(a,d){return a?b(a):(c._processTxps(d),b(null,d))})},d.prototype.createAddress=function(a,b){f.checkState(this.credentials&&this.credentials.isComplete());var c=this;return b||(b=a,a={},t.warn("DEPRECATED WARN: createAddress should receive 2 parameters.")),c._checkKeyDerivation()?(a=a||{},void c._doPostRequest("/v3/addresses/",a,function(a,d){return a?b(a):v.checkAddress(c.credentials,d)?b(null,d):b(new x.SERVER_COMPROMISED)})):b(new Error("Cannot create new address for this wallet"))},d.prototype.getMainAddresses=function(a,b){f.checkState(this.credentials&&this.credentials.isComplete());var c=this;a=a||{};var d=[];a.limit&&d.push("limit="+a.limit),a.reverse&&d.push("reverse=1");var g="";d.length>0&&(g="?"+d.join("&"));var h="/v1/addresses/"+g;c._doGetRequest(h,function(d,f){if(d)return b(d);if(!a.doNotVerify){var g=e.some(f,function(a){return!v.checkAddress(c.credentials,a)});if(g)return b(new x.SERVER_COMPROMISED)}return b(null,f)})},d.prototype.getBalance=function(a,b){b||(b=a,a={},t.warn("DEPRECATED WARN: getBalance should receive 2 parameters."));a=a||{},f.checkState(this.credentials&&this.credentials.isComplete());var c=[];if(a.twoStep&&c.push("?twoStep=1"),a.coin){if(!e.includes(["btc","bch"],a.coin))return b(new Error("Invalid coin"));c.push("coin="+a.coin)}var d="";c.length>0&&(d="?"+c.join("&"));var g="/v1/balance/"+d;this._doGetRequest(g,b)},d.prototype.getTxProposals=function(a,b){f.checkState(this.credentials&&this.credentials.isComplete());var c=this;c._doGetRequest("/v1/txproposals/",function(d,e){return d?b(d):(c._processTxps(e),void h.every(e,function(b,d){return a.doNotVerify?d(!0):void c.getPayPro(b,function(a,e){var f=v.checkTxProposal(c.credentials,b,{paypro:e});return d(f)})},function(d){if(!d)return b(new x.SERVER_COMPROMISED);var f;return f=a.forAirGapped?{txps:JSON.parse(JSON.stringify(e)),encryptedPkr:a.doNotEncryptPkr?null:r.encryptMessage(JSON.stringify(c.credentials.publicKeyRing),c.credentials.personalEncryptingKey),unencryptedPkr:a.doNotEncryptPkr?JSON.stringify(c.credentials.publicKeyRing):null,m:c.credentials.m,n:c.credentials.n}:e,b(null,f)}))})},d.prototype.getPayPro=function(a,b){var c=this;return!a.payProUrl||this.doNotVerifyPayPro?b():void s.get({url:a.payProUrl,http:c.payProHttp,coin:a.coin||"btc"},function(a,c){return a?b(new Error("Cannot check transaction now:"+a)):b(null,c)})},d.prototype.signTxProposal=function(a,b,c){f.checkState(this.credentials&&this.credentials.isComplete()),f.checkArgument(a.creatorId),e.isFunction(b)&&(c=b,b=null);var d=this;if(!a.signatures){if(!d.canSign())return c(new x.MISSING_PRIVATE_KEY);if(d.isPrivKeyEncrypted()&&!b)return c(new x.ENCRYPTED_PRIVATE_KEY)}d.getPayPro(a,function(f,g){if(f)return c(f);var h=v.checkTxProposal(d.credentials,a,{paypro:g});if(!h)return c(new x.SERVER_COMPROMISED);var i=a.signatures;if(e.isEmpty(i))try{i=d._signTxp(a,b)}catch(j){return t.error("Error signing tx",j),c(j)}var k="/v1/txproposals/"+a.id+"/signatures/",l={signatures:i};d._doPostRequest(k,l,function(a,b){return a?c(a):(d._processTxps(b),c(null,b))})})},d.prototype.signTxProposalFromAirGapped=function(a,b,c,d,g){f.checkState(this.credentials);var h=this;if(!h.canSign())throw new x.MISSING_PRIVATE_KEY;if(h.isPrivKeyEncrypted()&&!g)throw new x.ENCRYPTED_PRIVATE_KEY;var i;try{i=JSON.parse(r.decryptMessage(b,h.credentials.personalEncryptingKey))}catch(j){throw new Error("Could not decrypt public key ring")}if(!e.isArray(i)||i.length!=d)throw new Error("Invalid public key ring");if(h.credentials.m=c,h.credentials.n=d,h.credentials.addressType=a.addressType,h.credentials.addPublicKeyRing(i),!v.checkTxProposalSignature(h.credentials,a))throw new Error("Fake transaction proposal");return h._signTxp(a,g)},d.signTxProposalFromAirGapped=function(a,b,c,f,g,h){h=h||{};var i=h.coin||"btc";if(!e.includes(["btc","bch"],i))return cb(new Error("Invalid coin"));var j=JSON.parse(c);if(!e.isArray(j)||j.length!=g)throw new Error("Invalid public key ring");var k=new d({baseUrl:"https://bws.example.com/bws/api"});if("xprv"===a.slice(0,4)||"tprv"===a.slice(0,4)){if("xprv"===a.slice(0,4)&&"testnet"==b.network)throw new Error("testnet HD keys must start with tprv");if("tprv"===a.slice(0,4)&&"livenet"==b.network)throw new Error("livenet HD keys must start with xprv");k.seedFromExtendedPrivateKey(a,{coin:i,account:h.account,derivationStrategy:h.derivationStrategy})}else k.seedFromMnemonic(a,{coin:i,network:b.network,passphrase:h.passphrase,account:h.account,derivationStrategy:h.derivationStrategy});if(k.credentials.m=f,k.credentials.n=g,k.credentials.addressType=b.addressType,k.credentials.addPublicKeyRing(j),!v.checkTxProposalSignature(k.credentials,b))throw new Error("Fake transaction proposal");return k._signTxp(b)},d.prototype.rejectTxProposal=function(a,b,c){f.checkState(this.credentials&&this.credentials.isComplete()),f.checkArgument(c);var e=this,g="/v1/txproposals/"+a.id+"/rejections/",h={reason:d._encryptMessage(b,e.credentials.sharedEncryptingKey)||""};e._doPostRequest(g,h,function(a,b){return a?c(a):(e._processTxps(b),c(null,b))})},d.prototype.broadcastRawTx=function(a,b){f.checkState(this.credentials),f.checkArgument(b);var c=this;a=a||{};var d="/v1/broadcast_raw/";c._doPostRequest(d,a,function(a,c){return a?b(a):b(null,c)})},d.prototype._doBroadcast=function(a,b){var c=this,d="/v1/txproposals/"+a.id+"/broadcast/";c._doPostRequest(d,{},function(a,d){return a?b(a):(c._processTxps(d),b(null,d))})},d.prototype.broadcastTxProposal=function(a,b){f.checkState(this.credentials&&this.credentials.isComplete());var c=this;c.getPayPro(a,function(d,e){if(e){var f=r.buildTx(a);c._applyAllSignatures(a,f),s.send({http:c.payProHttp,url:a.payProUrl,amountSat:a.amount,refundAddr:a.changeAddress.address,merchant_data:e.merchant_data,rawTx:f.serialize({disableSmallFees:!0,disableLargeFees:!0,disableDustOutputs:!0}),coin:a.coin||"btc"},function(d,e,f){return d?b(d):void c._doBroadcast(a,function(a,c){return b(a,c,f)})})}else c._doBroadcast(a,b)})},d.prototype.removeTxProposal=function(a,b){f.checkState(this.credentials&&this.credentials.isComplete());var c=this,d="/v1/txproposals/"+a.id;c._doDeleteRequest(d,function(a){return b(a)})},d.prototype.getTxHistory=function(a,b){f.checkState(this.credentials&&this.credentials.isComplete());var c=this,d=[];a&&(a.skip&&d.push("skip="+a.skip),a.limit&&d.push("limit="+a.limit),a.includeExtendedInfo&&d.push("includeExtendedInfo=1"));var e="";d.length>0&&(e="?"+d.join("&"));var g="/v1/txhistory/"+e;c._doGetRequest(g,function(a,d){return a?b(a):(c._processTxps(d),b(null,d))})},d.prototype.getTx=function(a,b){f.checkState(this.credentials&&this.credentials.isComplete());var c=this,d="/v1/txproposals/"+a;this._doGetRequest(d,function(a,d){return a?b(a):(c._processTxps(d),b(null,d))})},d.prototype.startScan=function(a,b){f.checkState(this.credentials&&this.credentials.isComplete());var c=this,d={includeCopayerBranches:a.includeCopayerBranches};c._doPostRequest("/v1/addresses/scan",d,function(a){return b(a)})},d.prototype.addAccess=function(a,b){ -f.checkState(this.credentials&&this.credentials.canSign()),a=a||{};var c=new j.PrivateKey(a.generateNewKey?null:this.credentials.requestPrivKey),d=c.toPublicKey().toString(),e=new j.HDPrivateKey(this.credentials.xPrivKey).deriveChild(this.credentials.getBaseAddressDerivationPath()),g=r.signRequestPubKey(d,e),h=this.credentials.copayerId,i=a.name?r.encryptMessage(a.name,this.credentials.sharedEncryptingKey):null,a={copayerId:h,requestPubKey:d,signature:g,name:i,restrictions:a.restrictions};this._doPutRequest("/v1/copayers/"+h+"/",a,function(a,d){return a?b(a):b(null,d.wallet,c)})},d.prototype.getTxNote=function(a,b){f.checkState(this.credentials);var c=this;a=a||{},c._doGetRequest("/v1/txnotes/"+a.txid+"/",function(a,d){return a?b(a):(c._processTxNotes(d),b(null,d))})},d.prototype.editTxNote=function(a,b){f.checkState(this.credentials);var c=this;a=a||{},a.body&&(a.body=d._encryptMessage(a.body,this.credentials.sharedEncryptingKey)),c._doPutRequest("/v1/txnotes/"+a.txid+"/",a,function(a,d){return a?b(a):(c._processTxNotes(d),b(null,d))})},d.prototype.getTxNotes=function(a,b){f.checkState(this.credentials);var c=this;a=a||{};var d=[];e.isNumber(a.minTs)&&d.push("minTs="+a.minTs);var g="";d.length>0&&(g="?"+d.join("&")),c._doGetRequest("/v1/txnotes/"+g,function(a,d){return a?b(a):(c._processTxNotes(d),b(null,d))})},d.prototype.getFiatRate=function(a,b){f.checkArgument(b);var c=this,a=a||{},d=[];a.ts&&d.push("ts="+a.ts),a.provider&&d.push("provider="+a.provider);var e="";d.length>0&&(e="?"+d.join("&")),c._doGetRequest("/v1/fiatrates/"+a.code+"/"+e,function(a,c){return a?b(a):b(null,c)})},d.prototype.pushNotificationsSubscribe=function(a,b){var c="/v1/pushnotifications/subscriptions/";this._doPostRequest(c,a,function(a,c){return a?b(a):b(null,c)})},d.prototype.pushNotificationsUnsubscribe=function(a,b){var c="/v2/pushnotifications/subscriptions/"+a;this._doDeleteRequest(c,b)},d.prototype.txConfirmationSubscribe=function(a,b){var c="/v1/txconfirmations/";this._doPostRequest(c,a,function(a,c){return a?b(a):b(null,c)})},d.prototype.txConfirmationUnsubscribe=function(a,b){var c="/v1/txconfirmations/"+a;this._doDeleteRequest(c,b)},d.prototype.getSendMaxInfo=function(a,b){var c=this,d=[];a=a||{},a.feeLevel&&d.push("feeLevel="+a.feeLevel),null!=a.feePerKb&&d.push("feePerKb="+a.feePerKb),a.excludeUnconfirmedUtxos&&d.push("excludeUnconfirmedUtxos=1"),a.returnInputs&&d.push("returnInputs=1");var e="";d.length>0&&(e="?"+d.join("&"));var f="/v1/sendmaxinfo/"+e;c._doGetRequest(f,function(a,c){return a?b(a):b(null,c)})},d.prototype.getStatusByIdentifier=function(a,b){f.checkState(this.credentials);var c=this;a=a||{};var e=[];e.push("includeExtendedInfo="+(a.includeExtendedInfo?"1":"0")),e.push("twoStep="+(a.twoStep?"1":"0")),c._doGetRequest("/v1/wallets/"+a.identifier+"?"+e.join("&"),function(a,e){if(a||!e||!e.wallet)return b(a);if("pending"==e.wallet.status){var f=c.credentials;e.wallet.secret=d._buildSecret(f.walletId,f.walletPrivKey,f.coin,f.network)}return c._processStatus(e),b(a,e)})},d.prototype._oldCopayDecrypt=function(a,b,c){var d,e="@#$",f="%^#@";try{var g=a+e+b;d=m.decrypt(g,c)}catch(h){g=a+f+b;try{d=m.decrypt(g,c)}catch(h){t.debug(h)}}if(!d)return null;var i;try{i=JSON.parse(d)}catch(h){}return i},d.prototype.getWalletIdsFromOldCopay=function(a,b,c){var d=this._oldCopayDecrypt(a,b,c);if(!d)return null;var f=d.walletIds.concat(e.keys(d.focusedTimestamps));return e.uniq(f)},d.prototype.createWalletFromOldCopay=function(a,b,c,d){var e=this._oldCopayDecrypt(a,b,c);return e?e.publicKeyRing.copayersExtPubKeys.length!=e.opts.totalCopayers?d(new Error("Wallet is incomplete, cannot be imported")):(this.credentials=u.fromOldCopayWallet(e),void this.recreateWallet(d)):d(new Error("Could not decrypt"))},b.exports=d}).call(this,a("buffer").Buffer)},{"../package.json":343,"./common":5,"./credentials":7,"./errors":8,"./log":11,"./paypro":12,"./verifier":13,async:30,bip38:37,"bitcore-lib":89,"bitcore-lib-cash":38,"bitcore-mnemonic":138,buffer:187,events:232,"json-stable-stringify":254,lodash:259,preconditions:276,querystring:293,sjcl:320,superagent:328,url:335,util:340}],3:[function(a,b,c){"use strict";var d={};d.SCRIPT_TYPES={P2SH:"P2SH",P2PKH:"P2PKH"},d.DERIVATION_STRATEGIES={BIP44:"BIP44",BIP45:"BIP45",BIP48:"BIP48"},d.PATHS={REQUEST_KEY:"m/1'/0",TXPROPOSAL_KEY:"m/1'/1",REQUEST_KEY_AUTH:"m/2"},d.BIP45_SHARED_INDEX=2147483647,d.UNITS={btc:{toSatoshis:1e8,full:{maxDecimals:8,minDecimals:8},"short":{maxDecimals:6,minDecimals:2}},bit:{toSatoshis:100,full:{maxDecimals:2,minDecimals:2},"short":{maxDecimals:0,minDecimals:0}}},b.exports=d},{}],4:[function(a,b,c){"use strict";var d={};d.DEFAULT_FEE_PER_KB=1e4,d.MIN_FEE_PER_KB=0,d.MAX_FEE_PER_KB=1e6,d.MAX_TX_FEE=1e8,b.exports=d},{}],5:[function(a,b,c){var d={};d.Constants=a("./constants"),d.Defaults=a("./defaults"),d.Utils=a("./utils"),b.exports=d},{"./constants":3,"./defaults":4,"./utils":6}],6:[function(a,b,c){(function(c){"use strict";function d(){}var e=a("lodash"),f=a("preconditions").singleton(),g=a("sjcl"),h=a("json-stable-stringify"),i=a("bitcore-lib"),j={btc:i,bch:a("bitcore-lib-cash")},k=i.PrivateKey,l=i.PublicKey,m=i.crypto,n=(i.encoding,a("./constants")),o=a("./defaults");d.SJCL={},d.encryptMessage=function(a,b){var c=g.codec.base64.toBits(b);return g.encrypt(c,a,e.defaults({ks:128,iter:1},d.SJCL))},d.decryptMessage=function(a,b){if(a){if(!b)throw"No key";var c=g.codec.base64.toBits(b);return g.decrypt(c,a)}},d.decryptMessageNoThrow=function(a,b){try{return d.decryptMessage(a,b)}catch(c){return a}},d.hashMessage=function(a){f.checkArgument(a);var b=new c(a),d=m.Hash.sha256sha256(b);return d=new i.encoding.BufferReader(d).readReverse()},d.signMessage=function(a,b){f.checkArgument(a);var c=new k(b),e=d.hashMessage(a);return m.ECDSA.sign(e,c,"little").toString()},d.verifyMessage=function(a,b,c){if(f.checkArgument(a),f.checkArgument(c),!b)return!1;var e=new l(c),g=d.hashMessage(a);try{var h=new m.Signature.fromString(b);return m.ECDSA.verify(g,h,e,"little")}catch(i){return!1}},d.privateKeyToAESKey=function(a){f.checkArgument(a&&e.isString(a)),f.checkArgument(i.PrivateKey.isValid(a),"The private key received is invalid");var b=i.PrivateKey.fromString(a);return i.crypto.Hash.sha256(b.toBuffer()).slice(0,16).toString("base64")},d.getCopayerHash=function(a,b,c){return[a,b,c].join("|")},d.getProposalHash=function(a){function b(a,b,c,d){return[a,b,c||"",d||""].join("|")}return arguments.length>1?b.apply(this,arguments):h(a)},d.deriveAddress=function(a,b,c,d,g,h){f.checkArgument(e.includes(e.values(n.SCRIPT_TYPES),a)),h=h||"btc";var i,k=j[h],l=e.map(b,function(a){var b=new k.HDPublicKey(a.xPubKey);return b.deriveChild(c).publicKey});switch(a){case n.SCRIPT_TYPES.P2SH:i=k.Address.createMultisig(l,d,g);break;case n.SCRIPT_TYPES.P2PKH:f.checkState(e.isArray(l)&&1==l.length),i=k.Address.fromPublicKey(l[0],g)}return{address:i.toString(),path:c,publicKeys:e.invokeMap(l,"toString")}},d.xPubToCopayerId=function(a,b){var c="btc"==a?b:a+b,d=g.hash.sha256.hash(c);return g.codec.hex.fromBits(d)},d.signRequestPubKey=function(a,b){var c=new i.HDPrivateKey(b).deriveChild(n.PATHS.REQUEST_KEY_AUTH).privateKey;return d.signMessage(a,c)},d.verifyRequestPubKey=function(a,b,c){var e=new i.HDPublicKey(c).deriveChild(n.PATHS.REQUEST_KEY_AUTH).publicKey;return d.verifyMessage(a,b,e.toString())},d.formatAmount=function(a,b,c){function d(a,b){var c=a.toString().split("."),d=(c[1]||"0").substring(0,b);return parseFloat(c[0]+"."+d)}function g(a,b,c,d){a=a.replace(".",c);var f=a.split(c),g=f[0],h=f[1];h=e.dropRightWhile(h,function(a,b){return"0"==a&&b>=d}).join("");var i=f.length>1?c+h:"";return g=g.replace(/\B(?=(\d{3})+(?!\d))/g,b),g+i}f.shouldBeNumber(a),f.checkArgument(e.includes(e.keys(n.UNITS),b)),c=c||{};var h=n.UNITS[b],i=c.fullPrecision?"full":"short",j=d(a/h.toSatoshis,h[i].maxDecimals).toFixed(h[i].maxDecimals);return g(j,c.thousandsSeparator||",",c.decimalSeparator||".",h[i].minDecimals)},d.buildTx=function(a){var b=a.coin||"btc",c=j[b],d=new c.Transaction;switch(f.checkState(e.includes(e.values(n.SCRIPT_TYPES),a.addressType)),a.addressType){case n.SCRIPT_TYPES.P2SH:e.each(a.inputs,function(b){d.from(b,b.publicKeys,a.requiredSignatures)});break;case n.SCRIPT_TYPES.P2PKH:d.from(a.inputs)}if(a.toAddress&&a.amount&&!a.outputs?d.to(a.toAddress,a.amount):a.outputs&&e.each(a.outputs,function(a){f.checkState(a.script||a.toAddress,"Output should have either toAddress or script specified"),a.script?d.addOutput(new c.Transaction.Output({script:a.script,satoshis:a.amount})):d.to(a.toAddress,a.amount)}),d.fee(a.fee),d.change(a.changeAddress.address),d.outputs.length>1){var g=e.reject(a.outputOrder,function(a){return a>=d.outputs.length});f.checkState(d.outputs.length==g.length),d.sortOutputs(function(a){return e.map(g,function(b){return a[b]})})}var h=e.reduce(a.inputs,function(a,b){return+b.satoshis+a},0),i=e.reduce(d.outputs,function(a,b){return+b.satoshis+a},0);return f.checkState(h-i>=0),f.checkState(h-i<=o.MAX_TX_FEE),d},b.exports=d}).call(this,a("buffer").Buffer)},{"./constants":3,"./defaults":4,"bitcore-lib":89,"bitcore-lib-cash":38,buffer:187,"json-stable-stringify":254,lodash:259,preconditions:276,sjcl:320}],7:[function(a,b,c){(function(c){"use strict";function d(){this.version="1.0.0",this.derivationStrategy=m.DERIVATION_STRATEGIES.BIP44,this.account=0}function e(a){if(!h.includes(["btc","bch"],a))throw new Error("Invalid coin")}function f(a){if(!h.includes(["livenet","testnet"],a))throw new Error("Invalid network")}var g=a("preconditions").singleton(),h=a("lodash"),i=a("bitcore-lib"),j=a("bitcore-mnemonic"),k=a("sjcl"),l=a("./common"),m=l.Constants,n=l.Utils,o=["coin","network","xPrivKey","xPrivKeyEncrypted","xPubKey","requestPrivKey","requestPubKey","copayerId","publicKeyRing","walletId","walletName","m","n","walletPrivKey","personalEncryptingKey","sharedEncryptingKey","copayerName","externalSource","mnemonic","mnemonicEncrypted","entropySource","mnemonicHasPassphrase","derivationStrategy","account","compliantDerivation","addressType","hwInfo","entropySourcePath"];d.create=function(a,b){e(a),f(b);var c=new d;return c.coin=a,c.network=b,c.xPrivKey=new i.HDPrivateKey(b).toString(),c.compliantDerivation=!0,c._expand(),c};var p={en:j.Words.ENGLISH,es:j.Words.SPANISH,ja:j.Words.JAPANESE,zh:j.Words.CHINESE,fr:j.Words.FRENCH,it:j.Words.ITALIAN};d.createWithMnemonic=function(a,b,c,h,i,k){if(e(a),f(b),!p[h])throw new Error("Unsupported language");g.shouldBeNumber(i),k=k||{};for(var l=new j(p[h]);!j.isValid(l.toString());)l=new j(p[h]);var m=new d;return m.coin=a,m.network=b,m.account=i,m.xPrivKey=l.toHDPrivateKey(c,b).toString(),m.compliantDerivation=!0,m._expand(),m.mnemonic=l.phrase,m.mnemonicHasPassphrase=!!c,m},d.fromExtendedPrivateKey=function(a,b,c,f,i){e(a),g.shouldBeNumber(c),g.checkArgument(h.includes(h.values(m.DERIVATION_STRATEGIES),f)),i=i||{};var j=new d;return j.coin=a,j.xPrivKey=b,j.account=c,j.derivationStrategy=f,j.compliantDerivation=!i.nonCompliantDerivation,i.walletPrivKey&&j.addWalletPrivateKey(i.walletPrivKey),j._expand(),j},d.fromMnemonic=function(a,b,c,i,k,l,n){e(a),f(b),g.shouldBeNumber(k),g.checkArgument(h.includes(h.values(m.DERIVATION_STRATEGIES),l)),n=n||{};var o=new j(c),p=new d;return p.coin=a,p.xPrivKey=o.toHDPrivateKey(i,b).toString(),p.mnemonic=c,p.mnemonicHasPassphrase=!!i,p.account=k,p.derivationStrategy=l,p.compliantDerivation=!n.nonCompliantDerivation,p.entropySourcePath=n.entropySourcePath,n.walletPrivKey&&p.addWalletPrivateKey(n.walletPrivKey),p._expand(),p},d.fromExtendedPublicKey=function(a,b,f,j,k,l,n){e(a),g.checkArgument(j),g.shouldBeNumber(k),g.checkArgument(h.includes(h.values(m.DERIVATION_STRATEGIES),l)),n=n||{};var o=new c(j,"hex");g.checkArgument(o.length>=14,"At least 112 bits of entropy are needed");var p=new d;return p.coin=a,p.xPubKey=b,p.entropySource=i.crypto.Hash.sha256sha256(o).toString("hex"),p.account=k,p.derivationStrategy=l,p.externalSource=f,p.compliantDerivation=!0,p._expand(),p},d._getNetworkFromExtendedKey=function(a){return g.checkArgument(a&&h.isString(a)),"t"==a.charAt(0)?"testnet":"livenet"},d.prototype._hashFromEntropy=function(a,b){g.checkState(a);var d=new c(this.entropySource,"hex"),e=i.crypto.Hash.sha256hmac(d,new c(a));return e.slice(0,b)},d.prototype._expand=function(){g.checkState(this.xPrivKey||this.xPubKey&&this.entropySource);var a=d._getNetworkFromExtendedKey(this.xPrivKey||this.xPubKey);if(this.network?g.checkState(this.network==a):this.network=a,this.xPrivKey){var b=new i.HDPrivateKey.fromString(this.xPrivKey),c=this.compliantDerivation?h.bind(b.deriveChild,b):h.bind(b.deriveNonCompliantChild,b),e=c(this.getBaseAddressDerivationPath());this.xPubKey=e.hdPublicKey.toString()}if(this.entropySourcePath){var f=c(this.entropySourcePath).publicKey.toBuffer();this.entropySource=i.crypto.Hash.sha256sha256(f).toString("hex")}if(this.entropySource){var f=this._hashFromEntropy("reqPrivKey",32),j=new i.PrivateKey(f.toString("hex"),a);this.requestPrivKey=j.toString(),this.requestPubKey=j.toPublicKey().toString()}else{var k=c(m.PATHS.REQUEST_KEY);this.requestPrivKey=k.privateKey.toString();var l=k.publicKey;this.requestPubKey=l.toString(),this.entropySource=i.crypto.Hash.sha256(k.privateKey.toBuffer()).toString("hex")}this.personalEncryptingKey=this._hashFromEntropy("personalKey",16).toString("base64"),g.checkState(this.coin),this.copayerId=n.xPubToCopayerId(this.coin,this.xPubKey),this.publicKeyRing=[{xPubKey:this.xPubKey,requestPubKey:this.requestPubKey}]},d.fromObj=function(a){var b=new d;return h.each(o,function(c){b[c]=a[c]}),b.coin=b.coin||"btc",b.derivationStrategy=b.derivationStrategy||m.DERIVATION_STRATEGIES.BIP45,b.addressType=b.addressType||m.SCRIPT_TYPES.P2SH,b.account=b.account||0,g.checkState(b.xPrivKey||b.xPubKey||b.xPrivKeyEncrypted,"invalid input"),b},d.prototype.toObj=function(){var a=this,b={};return h.each(o,function(c){b[c]=a[c]}),b},d.prototype.getBaseAddressDerivationPath=function(){var a;switch(this.derivationStrategy){case m.DERIVATION_STRATEGIES.BIP45:return"m/45'";case m.DERIVATION_STRATEGIES.BIP44:a="44";break;case m.DERIVATION_STRATEGIES.BIP48:a="48"}var b="livenet"==this.network?"0":"1";return"m/"+a+"'/"+b+"'/"+this.account+"'"},d.prototype.getDerivedXPrivKey=function(a){var b=this.getBaseAddressDerivationPath(),c=new i.HDPrivateKey(this.getKeys(a).xPrivKey,this.network),d=this.compliantDerivation?h.bind(c.deriveChild,c):h.bind(c.deriveNonCompliantChild,c);return d(b)},Credent.prototype.addWalletPrivateKey=function(a){this.walletPrivKey=a,this.sharedEncryptingKey=n.privateKeyToAESKey(a)},d.prototype.addWalletInfo=function(a,b,c,d,e){this.walletId=a,this.walletName=b,this.m=c,this.n=d,e&&(this.copayerName=e),"BIP44"==this.derivationStrategy&&1==d?this.addressType=m.SCRIPT_TYPES.P2PKH:this.addressType=m.SCRIPT_TYPES.P2SH,!this.xPrivKey&&this.externalSource&&d>1&&(this.derivationStrategy=m.DERIVATION_STRATEGIES.BIP48),1==d&&this.addPublicKeyRing([{xPubKey:this.xPubKey,requestPubKey:this.requestPubKey}])},d.prototype.hasWalletInfo=function(){return!!this.walletId},d.prototype.isPrivKeyEncrypted=function(){return!!this.xPrivKeyEncrypted&&!this.xPrivKey},d.prototype.encryptPrivateKey=function(a,b){if(this.xPrivKeyEncrypted)throw new Error("Private key already encrypted");if(!this.xPrivKey)throw new Error("No private key to encrypt");if(this.xPrivKeyEncrypted=k.encrypt(a,this.xPrivKey,b),!this.xPrivKeyEncrypted)throw new Error("Could not encrypt");this.mnemonic&&(this.mnemonicEncrypted=k.encrypt(a,this.mnemonic,b)),delete this.xPrivKey,delete this.mnemonic},d.prototype.decryptPrivateKey=function(a){if(!this.xPrivKeyEncrypted)throw new Error("Private key is not encrypted");try{this.xPrivKey=k.decrypt(a,this.xPrivKeyEncrypted),this.mnemonicEncrypted&&(this.mnemonic=k.decrypt(a,this.mnemonicEncrypted)),delete this.xPrivKeyEncrypted,delete this.mnemonicEncrypted}catch(b){throw new Error("Could not decrypt")}},d.prototype.getKeys=function(a){var b={};if(this.isPrivKeyEncrypted()){g.checkArgument(a,"Private keys are encrypted, a password is needed");try{b.xPrivKey=k.decrypt(a,this.xPrivKeyEncrypted),this.mnemonicEncrypted&&(b.mnemonic=k.decrypt(a,this.mnemonicEncrypted))}catch(c){throw new Error("Could not decrypt")}}else b.xPrivKey=this.xPrivKey,b.mnemonic=this.mnemonic;return b},d.prototype.addPublicKeyRing=function(a){this.publicKeyRing=h.clone(a)},d.prototype.canSign=function(){return!!this.xPrivKey||!!this.xPrivKeyEncrypted},d.prototype.setNoSign=function(){delete this.xPrivKey,delete this.xPrivKeyEncrypted,delete this.mnemonic,delete this.mnemonicEncrypted},d.prototype.isComplete=function(){return this.m&&this.n&&this.publicKeyRing&&this.publicKeyRing.length==this.n?!0:!1},d.prototype.hasExternalSource=function(){return"string"==typeof this.externalSource},d.prototype.getExternalSourceName=function(){return this.externalSource},d.prototype.getMnemonic=function(){if(this.mnemonicEncrypted&&!this.mnemonic)throw new Error("Credentials are encrypted");return this.mnemonic},d.prototype.clearMnemonic=function(){delete this.mnemonic,delete this.mnemonicEncrypted},d.fromOldCopayWallet=function(a){function b(a){var b=a.publicKeyRing.copayersExtPubKeys.sort().join(""),d=new c(b),e=new i.PrivateKey.fromBuffer(i.crypto.Hash.sha256(d));return e.toString()}var e=new d;e.coin="btc",e.derivationStrategy=m.DERIVATION_STRATEGIES.BIP45,e.xPrivKey=a.privateKey.extendedPrivateKeyString,e._expand(),e.addWalletPrivateKey(b(a)),e.addWalletInfo(a.opts.id,a.opts.name,a.opts.requiredCopayers,a.opts.totalCopayers);var f=h.map(a.publicKeyRing.copayersExtPubKeys,function(b){var c,d=b===e.xPubKey;if(d){var f=m.PATHS.REQUEST_KEY;c=new i.HDPrivateKey(e.xPrivKey).deriveChild(f).hdPublicKey}else{var f=m.PATHS.REQUEST_KEY_AUTH;c=new i.HDPublicKey(b).deriveChild(f)}var g=new i.HDPublicKey(b).deriveChild("m/2147483646/0/0"),h=g.publicKey.toString("hex"),j=a.publicKeyRing.nicknameFor[h];return d&&(e.copayerName=j),{xPubKey:b,requestPubKey:c.publicKey.toString(),copayerName:j}});return e.addPublicKeyRing(f),e},b.exports=d}).call(this,a("buffer").Buffer)},{"./common":5,"bitcore-lib":89,"bitcore-mnemonic":138,buffer:187,lodash:259,preconditions:276,sjcl:320}],8:[function(a,b,c){"use strict";function d(a,b){return a.replace("{0}",b[0]).replace("{1}",b[1]).replace("{2}",b[2])}var e=a("lodash"),f=function(a,b){var c=function(){if(e.isString(b.message))this.message=d(b.message,arguments);else{if(!e.isFunction(b.message))throw new Error("Invalid error definition for "+b.name);this.message=b.message.apply(null,arguments)}this.stack=this.message+"\n"+(new Error).stack};return c.prototype=Object.create(a.prototype),c.prototype.name=a.prototype.name+b.name,a[b.name]=c,b.errors&&g(c,b.errors),c},g=function(a,b){e.each(b,function(b){f(a,b)})},h=function(a,b){return g(a,b),a},i={};i.Error=function(){this.message="Internal error",this.stack=this.message+"\n"+(new Error).stack},i.Error.prototype=Object.create(Error.prototype),i.Error.prototype.name="bwc.Error";var j=a("./spec");h(i.Error,j),b.exports=i.Error,b.exports.extend=function(a){return f(i.Error,a)}},{"./spec":9,lodash:259}],9:[function(a,b,c){"use strict";var d=[{name:"INVALID_BACKUP",message:"Invalid Backup."},{name:"WALLET_DOES_NOT_EXIST",message:"Wallet does not exist."},{name:"MISSING_PRIVATE_KEY",message:"Missing private keys to sign."},{name:"ENCRYPTED_PRIVATE_KEY",message:"Private key is encrypted, cannot sign transaction."},{name:"SERVER_COMPROMISED",message:"Server response could not be verified."},{name:"COULD_NOT_BUILD_TRANSACTION",message:"Could not build the transaction."},{name:"INSUFFICIENT_FUNDS",message:"Insufficient funds."},{name:"CONNECTION_ERROR",message:"Wallet service connection error."},{name:"NOT_FOUND",message:"Wallet service not found."},{name:"ECONNRESET_ERROR",message:"ECONNRESET, body: {0}"},{name:"WALLET_ALREADY_EXISTS",message:"Wallet already exists."},{name:"COPAYER_IN_WALLET",message:"Copayer in wallet."},{name:"WALLET_FULL",message:"Wallet is full."},{name:"WALLET_NOT_FOUND",message:"Wallet not found."},{name:"INSUFFICIENT_FUNDS_FOR_FEE",message:"Insufficient funds for fee."},{name:"LOCKED_FUNDS",message:"Locked funds."},{name:"DUST_AMOUNT",message:"Amount below dust threshold."},{name:"COPAYER_VOTED",message:"Copayer already voted on this transaction proposal."},{name:"NOT_AUTHORIZED",message:"Not authorized."},{name:"UNAVAILABLE_UTXOS",message:"Unavailable unspent outputs."},{name:"TX_NOT_FOUND",message:"Transaction proposal not found."},{name:"MAIN_ADDRESS_GAP_REACHED",message:"Maximum number of consecutive addresses without activity reached."},{name:"COPAYER_REGISTERED",message:"Copayer already register on server."}];b.exports=d},{}],10:[function(a,b,c){var d=b.exports=a("./api");d.Verifier=a("./verifier"),d.Utils=a("./common/utils"),d.sjcl=a("sjcl"),d.Bitcore=a("bitcore-lib"),d.BitcoreCash=a("bitcore-lib-cash")},{"./api":2,"./common/utils":6,"./verifier":13,"bitcore-lib":89,"bitcore-lib-cash":38,sjcl:320}],11:[function(a,b,c){var d=a("lodash"),e="silent",f=function(a){this.name=a||"log",this.level=e};f.prototype.getLevels=function(){return g};var g={silent:-1,debug:0,info:1,log:2,warn:3,error:4,fatal:5};d.each(g,function(a,b){"silent"!==b&&(f.prototype[b]=function(){if("silent"!==this.level&&a>=g[this.level]){if(Error.stackTraceLimit&&"debug"==this.level){var c=Error.stackTraceLimit;Error.stackTraceLimit=2;var d;try{anerror()}catch(e){d=e.stack}var f=d.split("\n"),h=f[2];h=":"+h.substr(6),Error.stackTraceLimit=c}var i,j="["+b+(h||"")+"] "+arguments[0],i=[].slice.call(arguments,1);console[b]?(i.unshift(j),console[b].apply(console,i)):(i.length&&(j+=JSON.stringify(i)),console.log(j))}})}),f.prototype.setLevel=function(a){this.level=a};var h=new f("copay");b.exports=h},{lodash:259}],12:[function(a,b,c){(function(c,d){var e=a("preconditions").singleton(),f=a("bitcore-lib"),g={btc:f,bch:a("bitcore-lib-cash")},h=a("bitcore-payment-protocol"),i={};i._nodeRequest=function(b,c){b.agent=!1;var e=b.httpNode||a("http"===b.proto?"http":"https"),f="POST"==b.method?"post":"get";e[f](b,function(a){var b=[];return 200!=a.statusCode?c(new Error("HTTP Request Error: "+a.statusCode+" "+a.statusMessage+" "+(b?b:""))):(a.on("data",function(a){b.push(a)}),void a.on("end",function(){return b=d.concat(b),c(null,b)}))})},i._browserRequest=function(a,b){var c=(a.method||"GET").toUpperCase(),d=a.url,e=a;e.headers=e.headers||{},e.body=e.body||e.data||"";var f=a.xhr||new XMLHttpRequest;f.open(c,d,!0),Object.keys(e.headers).forEach(function(a){var b=e.headers[a];"Content-Length"!==a&&"Content-Transfer-Encoding"!==a&&f.setRequestHeader(a,b)}),f.responseType="arraybuffer",f.onload=function(a){var c=f.response;return 200==f.status?b(null,new Uint8Array(c)):b("HTTP Request Error: "+f.status+" "+f.statusText+" "+c?c:"")},f.onerror=function(a){var c;return c=0!==f.status&&f.statusText?f.statusText:"HTTP Request Error",b(new Error(c))},e.body?f.send(e.body):f.send(null)};var j=function(a){a.url.match(/^((http[s]?):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$/);if(a.proto=RegExp.$2,a.host=RegExp.$3,a.path=RegExp.$4+RegExp.$6,a.http)return a.http;var b=a.env;return b||(b=c&&!c.browser?"node":"browser"),"node"==b?i._nodeRequest:http=i._browserRequest};i.get=function(a,b){e.checkArgument(a&&a.url);var c=j(a),f=a.coin||"btc",i=g[f],k=f.toUpperCase(),l=new h(k);a.headers=a.headers||{Accept:h.LEGACY_PAYMENT[k].REQUEST_CONTENT_TYPE,"Content-Type":"application/octet-stream"},c(a,function(c,e){if(c)return b(c);var f,g,j,k;try{var m=h.PaymentRequest.decode(e);f=l.makePaymentRequest(m),j=f.get("signature"),k=f.get("serialized_payment_details"),g=f.verify(!0)}catch(n){return b(new Error("Could not parse payment protocol"+n))}var o=h.PaymentDetails.decode(k),p=new h;p=p.makePaymentDetails(o);var q=p.get("outputs");if(q.length>1)return b(new Error("Payment Protocol Error: Requests with more that one output are not supported"));var r=q[0],s=r.get("amount").toNumber(),t="test"==p.get("network")?"testnet":"livenet",u=r.get("script").offset,v=r.get("script").limit,w=new d(new Uint8Array(r.get("script").buffer)),x=w.slice(u,v),y=new i.Address.fromScript(new i.Script(x),t),z=p.get("merchant_data");z&&(z=z.toString());var A=g.verified;g.isChain&&(A=A&&g.chainVerified);var B={verified:A,caTrusted:g.caTrusted,caName:g.caName,selfSigned:g.selfSigned,expires:p.get("expires"),memo:p.get("memo"),time:p.get("time"),merchant_data:z,toAddress:y.toString(),amount:s,network:t,domain:a.host,url:a.url},C=p.get("required_fee_rate");return C&&(B.requiredFeeRate=C),b(null,B)})},i._getPayProRefundOutputs=function(a,b,c){b=b.toString(10);var d,e=g[c],f=new h.Output,i=new e.Address(a);if(i.isPayToPublicKeyHash())d=e.Script.buildPublicKeyHashOut(i);else{if(!i.isPayToScriptHash())throw new Error("Unrecognized address type "+i.type);d=e.Script.buildScriptHashOut(i)}return f.set("script",d.toBuffer()),f.set("amount",b),[f]},i._createPayment=function(a,b,c,e,f){var g=new h;g=g.makePayment(),a&&(a=new d(a),g.set("merchant_data",a));var i=new d(b,"hex");g.set("transactions",[i]);var j=this._getPayProRefundOutputs(c,e,f);j&&g.set("refund_to",j),g=g.serialize();for(var k=new ArrayBuffer(g.length),l=new Uint8Array(k),m=0;m=3))throw new Error("Transaction proposal not supported");var k=i.buildTx(b);return h=k.uncheckedSerialize(),j.debug("Regenerating & verifying tx proposal hash -> Hash: ",h," Signature: ",b.proposalSignature),i.verifyMessage(h,b.proposalSignature,g)&&d.checkAddress(a,b.changeAddress)?!0:!1},d.checkPaypro=function(a,b){var c,d,e;return parseInt(a.version)>=3?(c=a.outputs[0].toAddress,d=a.amount,a.feePerKb&&(e=a.feePerKb/1024)):(c=a.toAddress,d=a.amount),c==b.toAddress&&d==b.amount},d.checkTxProposal=function(a,b,c){return c=c||{},this.checkTxProposalSignature(a,b)?c.paypro&&!this.checkPaypro(b,c.paypro)?!1:!0:!1},b.exports=d},{"./common":5,"./log":11,"bitcore-lib":89,lodash:259,preconditions:276}],14:[function(a,b,c){try{var d=a("asn1.js")}catch(e){var d=a("../..")}var f=c,g={"2 5 29 9":"subjectDirectoryAttributes","2 5 29 14":"subjectKeyIdentifier","2 5 29 15":"keyUsage","2 5 29 17":"subjectAlternativeName","2 5 29 18":"issuerAlternativeName","2 5 29 19":"basicConstraints","2 5 29 20":"cRLNumber","2 5 29 21":"reasonCode","2 5 29 24":"invalidityDate","2 5 29 27":"deltaCRLIndicator","2 5 29 28":"issuingDistributionPoint","2 5 29 29":"certificateIssuer","2 5 29 30":"nameConstraints","2 5 29 31":"cRLDistributionPoints","2 5 29 32":"certificatePolicies","2 5 29 33":"policyMappings","2 5 29 35":"authorityKeyIdentifier","2 5 29 36":"policyConstraints","2 5 29 37":"extendedKeyUsage","2 5 29 46":"freshestCRL","2 5 29 54":"inhibitAnyPolicy","1 3 6 1 5 5 7 1 1":"authorityInformationAccess","1 3 6 1 5 5 7 11":"subjectInformationAccess"},h=d.define("CertificateList",function(){this.seq().obj(this.key("tbsCertList").use(p),this.key("signatureAlgorithm").use(i),this.key("signature").bitstr())});f.CertificateList=h;var i=d.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())});f.AlgorithmIdentifier=i;var j=d.define("Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(k),this.key("signatureAlgorithm").use(i),this.key("signature").bitstr())});f.Certificate=j;var k=d.define("TBSCertificate",function(){this.seq().obj(this.key("version").def("v1").explicit(0).use(l),this.key("serialNumber")["int"](),this.key("signature").use(i),this.key("issuer").use(s),this.key("validity").use(m),this.key("subject").use(s),this.key("subjectPublicKeyInfo").use(o),this.key("issuerUniqueID").optional().implicit(1).bitstr(),this.key("subjectUniqueID").optional().implicit(2).bitstr(),this.key("extensions").optional().explicit(3).seqof(r))});f.TBSCertificate=k;var l=d.define("Version",function(){this["int"]({0:"v1",1:"v2",2:"v3"})});f.Version=l;var m=d.define("Validity",function(){this.seq().obj(this.key("notBefore").use(n),this.key("notAfter").use(n))});f.Validity=m;var n=d.define("Time",function(){this.choice({utcTime:this.utctime(),genTime:this.gentime()})});f.Time=n;var o=d.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(i),this.key("subjectPublicKey").bitstr())});f.SubjectPublicKeyInfo=o;var p=d.define("TBSCertList",function(){this.seq().obj(this.key("version").optional()["int"](),this.key("signature").use(i),this.key("issuer").use(s),this.key("thisUpdate").use(n),this.key("nextUpdate").use(n),this.key("revokedCertificates").optional().seqof(q),this.key("crlExtensions").explicit(0).optional().seqof(r))});f.TBSCertList=p;var q=d.define("RevokedCertificate",function(){this.seq().obj(this.key("userCertificate").use(G),this.key("revocationDate").use(n),this.key("crlEntryExtensions").optional().seqof(r))}),r=d.define("Extension",function(){this.seq().obj(this.key("extnID").objid(g),this.key("critical").bool().def(!1),this.key("extnValue").octstr().contains(function(a){ +f.checkState(this.credentials&&this.credentials.canSign()),a=a||{};var c=new j.PrivateKey(a.generateNewKey?null:this.credentials.requestPrivKey),d=c.toPublicKey().toString(),e=new j.HDPrivateKey(this.credentials.xPrivKey).deriveChild(this.credentials.getBaseAddressDerivationPath()),g=r.signRequestPubKey(d,e),h=this.credentials.copayerId,i=a.name?r.encryptMessage(a.name,this.credentials.sharedEncryptingKey):null,a={copayerId:h,requestPubKey:d,signature:g,name:i,restrictions:a.restrictions};this._doPutRequest("/v1/copayers/"+h+"/",a,function(a,d){return a?b(a):b(null,d.wallet,c)})},d.prototype.getTxNote=function(a,b){f.checkState(this.credentials);var c=this;a=a||{},c._doGetRequest("/v1/txnotes/"+a.txid+"/",function(a,d){return a?b(a):(c._processTxNotes(d),b(null,d))})},d.prototype.editTxNote=function(a,b){f.checkState(this.credentials);var c=this;a=a||{},a.body&&(a.body=d._encryptMessage(a.body,this.credentials.sharedEncryptingKey)),c._doPutRequest("/v1/txnotes/"+a.txid+"/",a,function(a,d){return a?b(a):(c._processTxNotes(d),b(null,d))})},d.prototype.getTxNotes=function(a,b){f.checkState(this.credentials);var c=this;a=a||{};var d=[];e.isNumber(a.minTs)&&d.push("minTs="+a.minTs);var g="";d.length>0&&(g="?"+d.join("&")),c._doGetRequest("/v1/txnotes/"+g,function(a,d){return a?b(a):(c._processTxNotes(d),b(null,d))})},d.prototype.getFiatRate=function(a,b){f.checkArgument(b);var c=this,a=a||{},d=[];a.ts&&d.push("ts="+a.ts),a.provider&&d.push("provider="+a.provider);var e="";d.length>0&&(e="?"+d.join("&")),c._doGetRequest("/v1/fiatrates/"+a.code+"/"+e,function(a,c){return a?b(a):b(null,c)})},d.prototype.pushNotificationsSubscribe=function(a,b){var c="/v1/pushnotifications/subscriptions/";this._doPostRequest(c,a,function(a,c){return a?b(a):b(null,c)})},d.prototype.pushNotificationsUnsubscribe=function(a,b){var c="/v2/pushnotifications/subscriptions/"+a;this._doDeleteRequest(c,b)},d.prototype.txConfirmationSubscribe=function(a,b){var c="/v1/txconfirmations/";this._doPostRequest(c,a,function(a,c){return a?b(a):b(null,c)})},d.prototype.txConfirmationUnsubscribe=function(a,b){var c="/v1/txconfirmations/"+a;this._doDeleteRequest(c,b)},d.prototype.getSendMaxInfo=function(a,b){var c=this,d=[];a=a||{},a.feeLevel&&d.push("feeLevel="+a.feeLevel),null!=a.feePerKb&&d.push("feePerKb="+a.feePerKb),a.excludeUnconfirmedUtxos&&d.push("excludeUnconfirmedUtxos=1"),a.returnInputs&&d.push("returnInputs=1");var e="";d.length>0&&(e="?"+d.join("&"));var f="/v1/sendmaxinfo/"+e;c._doGetRequest(f,function(a,c){return a?b(a):b(null,c)})},d.prototype.getStatusByIdentifier=function(a,b){f.checkState(this.credentials);var c=this;a=a||{};var e=[];e.push("includeExtendedInfo="+(a.includeExtendedInfo?"1":"0")),e.push("twoStep="+(a.twoStep?"1":"0")),c._doGetRequest("/v1/wallets/"+a.identifier+"?"+e.join("&"),function(a,e){if(a||!e||!e.wallet)return b(a);if("pending"==e.wallet.status){var f=c.credentials;e.wallet.secret=d._buildSecret(f.walletId,f.walletPrivKey,f.coin,f.network)}return c._processStatus(e),b(a,e)})},d.prototype._oldCopayDecrypt=function(a,b,c){var d,e="@#$",f="%^#@";try{var g=a+e+b;d=m.decrypt(g,c)}catch(h){g=a+f+b;try{d=m.decrypt(g,c)}catch(h){t.debug(h)}}if(!d)return null;var i;try{i=JSON.parse(d)}catch(h){}return i},d.prototype.getWalletIdsFromOldCopay=function(a,b,c){var d=this._oldCopayDecrypt(a,b,c);if(!d)return null;var f=d.walletIds.concat(e.keys(d.focusedTimestamps));return e.uniq(f)},d.prototype.createWalletFromOldCopay=function(a,b,c,d){var e=this._oldCopayDecrypt(a,b,c);return e?e.publicKeyRing.copayersExtPubKeys.length!=e.opts.totalCopayers?d(new Error("Wallet is incomplete, cannot be imported")):(this.credentials=u.fromOldCopayWallet(e),void this.recreateWallet(d)):d(new Error("Could not decrypt"))},b.exports=d}).call(this,a("buffer").Buffer)},{"../package.json":343,"./common":5,"./credentials":7,"./errors":8,"./log":11,"./paypro":12,"./verifier":13,async:30,bip38:37,"bitcore-lib":89,"bitcore-lib-cash":38,"bitcore-mnemonic":138,buffer:187,events:232,"json-stable-stringify":254,lodash:259,preconditions:276,querystring:293,sjcl:320,superagent:328,url:335,util:340}],3:[function(a,b,c){"use strict";var d={};d.SCRIPT_TYPES={P2SH:"P2SH",P2PKH:"P2PKH"},d.DERIVATION_STRATEGIES={BIP44:"BIP44",BIP45:"BIP45",BIP48:"BIP48"},d.PATHS={REQUEST_KEY:"m/1'/0",TXPROPOSAL_KEY:"m/1'/1",REQUEST_KEY_AUTH:"m/2"},d.BIP45_SHARED_INDEX=2147483647,d.UNITS={btc:{toSatoshis:1e8,full:{maxDecimals:8,minDecimals:8},"short":{maxDecimals:6,minDecimals:2}},bit:{toSatoshis:100,full:{maxDecimals:2,minDecimals:2},"short":{maxDecimals:0,minDecimals:0}}},b.exports=d},{}],4:[function(a,b,c){"use strict";var d={};d.DEFAULT_FEE_PER_KB=1e4,d.MIN_FEE_PER_KB=0,d.MAX_FEE_PER_KB=1e6,d.MAX_TX_FEE=1e8,b.exports=d},{}],5:[function(a,b,c){var d={};d.Constants=a("./constants"),d.Defaults=a("./defaults"),d.Utils=a("./utils"),b.exports=d},{"./constants":3,"./defaults":4,"./utils":6}],6:[function(a,b,c){(function(c){"use strict";function d(){}var e=a("lodash"),f=a("preconditions").singleton(),g=a("sjcl"),h=a("json-stable-stringify"),i=a("bitcore-lib"),j={btc:i,bch:a("bitcore-lib-cash")},k=i.PrivateKey,l=i.PublicKey,m=i.crypto,n=(i.encoding,a("./constants")),o=a("./defaults");d.SJCL={},d.encryptMessage=function(a,b){var c=g.codec.base64.toBits(b);return g.encrypt(c,a,e.defaults({ks:128,iter:1},d.SJCL))},d.decryptMessage=function(a,b){if(a){if(!b)throw"No key";var c=g.codec.base64.toBits(b);return g.decrypt(c,a)}},d.decryptMessageNoThrow=function(a,b){try{return d.decryptMessage(a,b)}catch(c){return a}},d.hashMessage=function(a){f.checkArgument(a);var b=new c(a),d=m.Hash.sha256sha256(b);return d=new i.encoding.BufferReader(d).readReverse()},d.signMessage=function(a,b){f.checkArgument(a);var c=new k(b),e=d.hashMessage(a);return m.ECDSA.sign(e,c,"little").toString()},d.verifyMessage=function(a,b,c){if(f.checkArgument(a),f.checkArgument(c),!b)return!1;var e=new l(c),g=d.hashMessage(a);try{var h=new m.Signature.fromString(b);return m.ECDSA.verify(g,h,e,"little")}catch(i){return!1}},d.privateKeyToAESKey=function(a){f.checkArgument(a&&e.isString(a)),f.checkArgument(i.PrivateKey.isValid(a),"The private key received is invalid");var b=i.PrivateKey.fromString(a);return i.crypto.Hash.sha256(b.toBuffer()).slice(0,16).toString("base64")},d.getCopayerHash=function(a,b,c){return[a,b,c].join("|")},d.getProposalHash=function(a){function b(a,b,c,d){return[a,b,c||"",d||""].join("|")}return arguments.length>1?b.apply(this,arguments):h(a)},d.deriveAddress=function(a,b,c,d,g,h){f.checkArgument(e.includes(e.values(n.SCRIPT_TYPES),a)),h=h||"btc";var i,k=j[h],l=e.map(b,function(a){var b=new k.HDPublicKey(a.xPubKey);return b.deriveChild(c).publicKey});switch(a){case n.SCRIPT_TYPES.P2SH:i=k.Address.createMultisig(l,d,g);break;case n.SCRIPT_TYPES.P2PKH:f.checkState(e.isArray(l)&&1==l.length),i=k.Address.fromPublicKey(l[0],g)}return{address:i.toString(),path:c,publicKeys:e.invokeMap(l,"toString")}},d.xPubToCopayerId=function(a,b){var c="btc"==a?b:a+b,d=g.hash.sha256.hash(c);return g.codec.hex.fromBits(d)},d.signRequestPubKey=function(a,b){var c=new i.HDPrivateKey(b).deriveChild(n.PATHS.REQUEST_KEY_AUTH).privateKey;return d.signMessage(a,c)},d.verifyRequestPubKey=function(a,b,c){var e=new i.HDPublicKey(c).deriveChild(n.PATHS.REQUEST_KEY_AUTH).publicKey;return d.verifyMessage(a,b,e.toString())},d.formatAmount=function(a,b,c){function d(a,b){var c=a.toString().split("."),d=(c[1]||"0").substring(0,b);return parseFloat(c[0]+"."+d)}function g(a,b,c,d){a=a.replace(".",c);var f=a.split(c),g=f[0],h=f[1];h=e.dropRightWhile(h,function(a,b){return"0"==a&&b>=d}).join("");var i=f.length>1?c+h:"";return g=g.replace(/\B(?=(\d{3})+(?!\d))/g,b),g+i}f.shouldBeNumber(a),f.checkArgument(e.includes(e.keys(n.UNITS),b)),c=c||{};var h=n.UNITS[b],i=c.fullPrecision?"full":"short",j=d(a/h.toSatoshis,h[i].maxDecimals).toFixed(h[i].maxDecimals);return g(j,c.thousandsSeparator||",",c.decimalSeparator||".",h[i].minDecimals)},d.buildTx=function(a){var b=a.coin||"btc",c=j[b],d=new c.Transaction;switch(f.checkState(e.includes(e.values(n.SCRIPT_TYPES),a.addressType)),a.addressType){case n.SCRIPT_TYPES.P2SH:e.each(a.inputs,function(b){d.from(b,b.publicKeys,a.requiredSignatures)});break;case n.SCRIPT_TYPES.P2PKH:d.from(a.inputs)}if(a.toAddress&&a.amount&&!a.outputs?d.to(a.toAddress,a.amount):a.outputs&&e.each(a.outputs,function(a){f.checkState(a.script||a.toAddress,"Output should have either toAddress or script specified"),a.script?d.addOutput(new c.Transaction.Output({script:a.script,satoshis:a.amount})):d.to(a.toAddress,a.amount)}),d.fee(a.fee),d.change(a.changeAddress.address),d.outputs.length>1){var g=e.reject(a.outputOrder,function(a){return a>=d.outputs.length});f.checkState(d.outputs.length==g.length),d.sortOutputs(function(a){return e.map(g,function(b){return a[b]})})}var h=e.reduce(a.inputs,function(a,b){return+b.satoshis+a},0),i=e.reduce(d.outputs,function(a,b){return+b.satoshis+a},0);return f.checkState(h-i>=0),f.checkState(h-i<=o.MAX_TX_FEE),d},b.exports=d}).call(this,a("buffer").Buffer)},{"./constants":3,"./defaults":4,"bitcore-lib":89,"bitcore-lib-cash":38,buffer:187,"json-stable-stringify":254,lodash:259,preconditions:276,sjcl:320}],7:[function(a,b,c){(function(c){"use strict";function d(){this.version="1.0.0",this.derivationStrategy=m.DERIVATION_STRATEGIES.BIP44,this.account=0}function e(a){if(!h.includes(["btc","bch"],a))throw new Error("Invalid coin")}function f(a){if(!h.includes(["livenet","testnet"],a))throw new Error("Invalid network")}var g=a("preconditions").singleton(),h=a("lodash"),i=a("bitcore-lib"),j=a("bitcore-mnemonic"),k=a("sjcl"),l=a("./common"),m=l.Constants,n=l.Utils,o=["coin","network","xPrivKey","xPrivKeyEncrypted","xPubKey","requestPrivKey","requestPubKey","copayerId","publicKeyRing","walletId","walletName","m","n","walletPrivKey","personalEncryptingKey","sharedEncryptingKey","copayerName","externalSource","mnemonic","mnemonicEncrypted","entropySource","mnemonicHasPassphrase","derivationStrategy","account","compliantDerivation","addressType","hwInfo","entropySourcePath"];d.create=function(a,b){e(a),f(b);var c=new d;return c.coin=a,c.network=b,c.xPrivKey=new i.HDPrivateKey(b).toString(),c.compliantDerivation=!0,c._expand(),c};var p={en:j.Words.ENGLISH,es:j.Words.SPANISH,ja:j.Words.JAPANESE,zh:j.Words.CHINESE,fr:j.Words.FRENCH,it:j.Words.ITALIAN};d.createWithMnemonic=function(a,b,c,h,i,k){if(e(a),f(b),!p[h])throw new Error("Unsupported language");g.shouldBeNumber(i),k=k||{};for(var l=new j(p[h]);!j.isValid(l.toString());)l=new j(p[h]);var m=new d;return m.coin=a,m.network=b,m.account=i,m.xPrivKey=l.toHDPrivateKey(c,b).toString(),m.compliantDerivation=!0,m._expand(),m.mnemonic=l.phrase,m.mnemonicHasPassphrase=!!c,m},d.fromExtendedPrivateKey=function(a,b,c,f,i){e(a),g.shouldBeNumber(c),g.checkArgument(h.includes(h.values(m.DERIVATION_STRATEGIES),f)),i=i||{};var j=new d;return j.coin=a,j.xPrivKey=b,j.account=c,j.derivationStrategy=f,j.compliantDerivation=!i.nonCompliantDerivation,i.walletPrivKey&&j.addWalletPrivateKey(i.walletPrivKey),j._expand(),j},d.fromMnemonic=function(a,b,c,i,k,l,n){e(a),f(b),g.shouldBeNumber(k),g.checkArgument(h.includes(h.values(m.DERIVATION_STRATEGIES),l)),n=n||{};var o=new j(c),p=new d;return p.coin=a,p.xPrivKey=o.toHDPrivateKey(i,b).toString(),p.mnemonic=c,p.mnemonicHasPassphrase=!!i,p.account=k,p.derivationStrategy=l,p.compliantDerivation=!n.nonCompliantDerivation,p.entropySourcePath=n.entropySourcePath,n.walletPrivKey&&p.addWalletPrivateKey(n.walletPrivKey),p._expand(),p},d.fromExtendedPublicKey=function(a,b,f,j,k,l,n){e(a),g.checkArgument(j),g.shouldBeNumber(k),g.checkArgument(h.includes(h.values(m.DERIVATION_STRATEGIES),l)),n=n||{};var o=new c(j,"hex");g.checkArgument(o.length>=14,"At least 112 bits of entropy are needed");var p=new d;return p.coin=a,p.xPubKey=b,p.entropySource=i.crypto.Hash.sha256sha256(o).toString("hex"),p.account=k,p.derivationStrategy=l,p.externalSource=f,p.compliantDerivation=!0,p._expand(),p},d._getNetworkFromExtendedKey=function(a){return g.checkArgument(a&&h.isString(a)),"t"==a.charAt(0)?"testnet":"livenet"},d.prototype._hashFromEntropy=function(a,b){g.checkState(a);var d=new c(this.entropySource,"hex"),e=i.crypto.Hash.sha256hmac(d,new c(a));return e.slice(0,b)},d.prototype._expand=function(){g.checkState(this.xPrivKey||this.xPubKey&&this.entropySource);var a=d._getNetworkFromExtendedKey(this.xPrivKey||this.xPubKey);if(this.network?g.checkState(this.network==a):this.network=a,this.xPrivKey){var b=new i.HDPrivateKey.fromString(this.xPrivKey),c=this.compliantDerivation?h.bind(b.deriveChild,b):h.bind(b.deriveNonCompliantChild,b),e=c(this.getBaseAddressDerivationPath());this.xPubKey=e.hdPublicKey.toString()}if(this.entropySourcePath){var f=c(this.entropySourcePath).publicKey.toBuffer();this.entropySource=i.crypto.Hash.sha256sha256(f).toString("hex")}if(this.entropySource){var f=this._hashFromEntropy("reqPrivKey",32),j=new i.PrivateKey(f.toString("hex"),a);this.requestPrivKey=j.toString(),this.requestPubKey=j.toPublicKey().toString()}else{var k=c(m.PATHS.REQUEST_KEY);this.requestPrivKey=k.privateKey.toString();var l=k.publicKey;this.requestPubKey=l.toString(),this.entropySource=i.crypto.Hash.sha256(k.privateKey.toBuffer()).toString("hex")}this.personalEncryptingKey=this._hashFromEntropy("personalKey",16).toString("base64"),g.checkState(this.coin),this.copayerId=n.xPubToCopayerId(this.coin,this.xPubKey),this.publicKeyRing=[{xPubKey:this.xPubKey,requestPubKey:this.requestPubKey}]},d.fromObj=function(a){var b=new d;return h.each(o,function(c){b[c]=a[c]}),b.coin=b.coin||"btc",b.derivationStrategy=b.derivationStrategy||m.DERIVATION_STRATEGIES.BIP45,b.addressType=b.addressType||m.SCRIPT_TYPES.P2SH,b.account=b.account||0,g.checkState(b.xPrivKey||b.xPubKey||b.xPrivKeyEncrypted,"invalid input"),b},d.prototype.toObj=function(){var a=this,b={};return h.each(o,function(c){b[c]=a[c]}),b},d.prototype.getBaseAddressDerivationPath=function(){var a;switch(this.derivationStrategy){case m.DERIVATION_STRATEGIES.BIP45:return"m/45'";case m.DERIVATION_STRATEGIES.BIP44:a="44";break;case m.DERIVATION_STRATEGIES.BIP48:a="48"}var b="livenet"==this.network?"0":"1";return"m/"+a+"'/"+b+"'/"+this.account+"'"},d.prototype.getDerivedXPrivKey=function(a){var b=this.getBaseAddressDerivationPath(),c=new i.HDPrivateKey(this.getKeys(a).xPrivKey,this.network),d=this.compliantDerivation?h.bind(c.deriveChild,c):h.bind(c.deriveNonCompliantChild,c);return d(b)},d.prototype.addWalletPrivateKey=function(a){this.walletPrivKey=a,this.sharedEncryptingKey=n.privateKeyToAESKey(a)},d.prototype.addWalletInfo=function(a,b,c,d,e){this.walletId=a,this.walletName=b,this.m=c,this.n=d,e&&(this.copayerName=e),"BIP44"==this.derivationStrategy&&1==d?this.addressType=m.SCRIPT_TYPES.P2PKH:this.addressType=m.SCRIPT_TYPES.P2SH,!this.xPrivKey&&this.externalSource&&d>1&&(this.derivationStrategy=m.DERIVATION_STRATEGIES.BIP48),1==d&&this.addPublicKeyRing([{xPubKey:this.xPubKey,requestPubKey:this.requestPubKey}])},d.prototype.hasWalletInfo=function(){return!!this.walletId},d.prototype.isPrivKeyEncrypted=function(){return!!this.xPrivKeyEncrypted&&!this.xPrivKey},d.prototype.encryptPrivateKey=function(a,b){if(this.xPrivKeyEncrypted)throw new Error("Private key already encrypted");if(!this.xPrivKey)throw new Error("No private key to encrypt");if(this.xPrivKeyEncrypted=k.encrypt(a,this.xPrivKey,b),!this.xPrivKeyEncrypted)throw new Error("Could not encrypt");this.mnemonic&&(this.mnemonicEncrypted=k.encrypt(a,this.mnemonic,b)),delete this.xPrivKey,delete this.mnemonic},d.prototype.decryptPrivateKey=function(a){if(!this.xPrivKeyEncrypted)throw new Error("Private key is not encrypted");try{this.xPrivKey=k.decrypt(a,this.xPrivKeyEncrypted),this.mnemonicEncrypted&&(this.mnemonic=k.decrypt(a,this.mnemonicEncrypted)),delete this.xPrivKeyEncrypted,delete this.mnemonicEncrypted}catch(b){throw new Error("Could not decrypt")}},d.prototype.getKeys=function(a){var b={};if(this.isPrivKeyEncrypted()){g.checkArgument(a,"Private keys are encrypted, a password is needed");try{b.xPrivKey=k.decrypt(a,this.xPrivKeyEncrypted),this.mnemonicEncrypted&&(b.mnemonic=k.decrypt(a,this.mnemonicEncrypted))}catch(c){throw new Error("Could not decrypt")}}else b.xPrivKey=this.xPrivKey,b.mnemonic=this.mnemonic;return b},d.prototype.addPublicKeyRing=function(a){this.publicKeyRing=h.clone(a)},d.prototype.canSign=function(){return!!this.xPrivKey||!!this.xPrivKeyEncrypted},d.prototype.setNoSign=function(){delete this.xPrivKey,delete this.xPrivKeyEncrypted,delete this.mnemonic,delete this.mnemonicEncrypted},d.prototype.isComplete=function(){return this.m&&this.n&&this.publicKeyRing&&this.publicKeyRing.length==this.n?!0:!1},d.prototype.hasExternalSource=function(){return"string"==typeof this.externalSource},d.prototype.getExternalSourceName=function(){return this.externalSource},d.prototype.getMnemonic=function(){if(this.mnemonicEncrypted&&!this.mnemonic)throw new Error("Credentials are encrypted");return this.mnemonic},d.prototype.clearMnemonic=function(){delete this.mnemonic,delete this.mnemonicEncrypted},d.fromOldCopayWallet=function(a){function b(a){var b=a.publicKeyRing.copayersExtPubKeys.sort().join(""),d=new c(b),e=new i.PrivateKey.fromBuffer(i.crypto.Hash.sha256(d));return e.toString()}var e=new d;e.coin="btc",e.derivationStrategy=m.DERIVATION_STRATEGIES.BIP45,e.xPrivKey=a.privateKey.extendedPrivateKeyString,e._expand(),e.addWalletPrivateKey(b(a)),e.addWalletInfo(a.opts.id,a.opts.name,a.opts.requiredCopayers,a.opts.totalCopayers);var f=h.map(a.publicKeyRing.copayersExtPubKeys,function(b){var c,d=b===e.xPubKey;if(d){var f=m.PATHS.REQUEST_KEY;c=new i.HDPrivateKey(e.xPrivKey).deriveChild(f).hdPublicKey}else{var f=m.PATHS.REQUEST_KEY_AUTH;c=new i.HDPublicKey(b).deriveChild(f)}var g=new i.HDPublicKey(b).deriveChild("m/2147483646/0/0"),h=g.publicKey.toString("hex"),j=a.publicKeyRing.nicknameFor[h];return d&&(e.copayerName=j),{xPubKey:b,requestPubKey:c.publicKey.toString(),copayerName:j}});return e.addPublicKeyRing(f),e},b.exports=d}).call(this,a("buffer").Buffer)},{"./common":5,"bitcore-lib":89,"bitcore-mnemonic":138,buffer:187,lodash:259,preconditions:276,sjcl:320}],8:[function(a,b,c){"use strict";function d(a,b){return a.replace("{0}",b[0]).replace("{1}",b[1]).replace("{2}",b[2])}var e=a("lodash"),f=function(a,b){var c=function(){if(e.isString(b.message))this.message=d(b.message,arguments);else{if(!e.isFunction(b.message))throw new Error("Invalid error definition for "+b.name);this.message=b.message.apply(null,arguments)}this.stack=this.message+"\n"+(new Error).stack};return c.prototype=Object.create(a.prototype),c.prototype.name=a.prototype.name+b.name,a[b.name]=c,b.errors&&g(c,b.errors),c},g=function(a,b){e.each(b,function(b){f(a,b)})},h=function(a,b){return g(a,b),a},i={};i.Error=function(){this.message="Internal error",this.stack=this.message+"\n"+(new Error).stack},i.Error.prototype=Object.create(Error.prototype),i.Error.prototype.name="bwc.Error";var j=a("./spec");h(i.Error,j),b.exports=i.Error,b.exports.extend=function(a){return f(i.Error,a)}},{"./spec":9,lodash:259}],9:[function(a,b,c){"use strict";var d=[{name:"INVALID_BACKUP",message:"Invalid Backup."},{name:"WALLET_DOES_NOT_EXIST",message:"Wallet does not exist."},{name:"MISSING_PRIVATE_KEY",message:"Missing private keys to sign."},{name:"ENCRYPTED_PRIVATE_KEY",message:"Private key is encrypted, cannot sign transaction."},{name:"SERVER_COMPROMISED",message:"Server response could not be verified."},{name:"COULD_NOT_BUILD_TRANSACTION",message:"Could not build the transaction."},{name:"INSUFFICIENT_FUNDS",message:"Insufficient funds."},{name:"CONNECTION_ERROR",message:"Wallet service connection error."},{name:"NOT_FOUND",message:"Wallet service not found."},{name:"ECONNRESET_ERROR",message:"ECONNRESET, body: {0}"},{name:"WALLET_ALREADY_EXISTS",message:"Wallet already exists."},{name:"COPAYER_IN_WALLET",message:"Copayer in wallet."},{name:"WALLET_FULL",message:"Wallet is full."},{name:"WALLET_NOT_FOUND",message:"Wallet not found."},{name:"INSUFFICIENT_FUNDS_FOR_FEE",message:"Insufficient funds for fee."},{name:"LOCKED_FUNDS",message:"Locked funds."},{name:"DUST_AMOUNT",message:"Amount below dust threshold."},{name:"COPAYER_VOTED",message:"Copayer already voted on this transaction proposal."},{name:"NOT_AUTHORIZED",message:"Not authorized."},{name:"UNAVAILABLE_UTXOS",message:"Unavailable unspent outputs."},{name:"TX_NOT_FOUND",message:"Transaction proposal not found."},{name:"MAIN_ADDRESS_GAP_REACHED",message:"Maximum number of consecutive addresses without activity reached."},{name:"COPAYER_REGISTERED",message:"Copayer already register on server."}];b.exports=d},{}],10:[function(a,b,c){var d=b.exports=a("./api");d.Verifier=a("./verifier"),d.Utils=a("./common/utils"),d.sjcl=a("sjcl"),d.Bitcore=a("bitcore-lib"),d.BitcoreCash=a("bitcore-lib-cash")},{"./api":2,"./common/utils":6,"./verifier":13,"bitcore-lib":89,"bitcore-lib-cash":38,sjcl:320}],11:[function(a,b,c){var d=a("lodash"),e="silent",f=function(a){this.name=a||"log",this.level=e};f.prototype.getLevels=function(){return g};var g={silent:-1,debug:0,info:1,log:2,warn:3,error:4,fatal:5};d.each(g,function(a,b){"silent"!==b&&(f.prototype[b]=function(){if("silent"!==this.level&&a>=g[this.level]){if(Error.stackTraceLimit&&"debug"==this.level){var c=Error.stackTraceLimit;Error.stackTraceLimit=2;var d;try{anerror()}catch(e){d=e.stack}var f=d.split("\n"),h=f[2];h=":"+h.substr(6),Error.stackTraceLimit=c}var i,j="["+b+(h||"")+"] "+arguments[0],i=[].slice.call(arguments,1);console[b]?(i.unshift(j),console[b].apply(console,i)):(i.length&&(j+=JSON.stringify(i)),console.log(j))}})}),f.prototype.setLevel=function(a){this.level=a};var h=new f("copay");b.exports=h},{lodash:259}],12:[function(a,b,c){(function(c,d){var e=a("preconditions").singleton(),f=a("bitcore-lib"),g={btc:f,bch:a("bitcore-lib-cash")},h=a("bitcore-payment-protocol"),i={};i._nodeRequest=function(b,c){b.agent=!1;var e=b.httpNode||a("http"===b.proto?"http":"https"),f="POST"==b.method?"post":"get";e[f](b,function(a){var b=[];return 200!=a.statusCode?c(new Error("HTTP Request Error: "+a.statusCode+" "+a.statusMessage+" "+(b?b:""))):(a.on("data",function(a){b.push(a)}),void a.on("end",function(){return b=d.concat(b),c(null,b)}))})},i._browserRequest=function(a,b){var c=(a.method||"GET").toUpperCase(),d=a.url,e=a;e.headers=e.headers||{},e.body=e.body||e.data||"";var f=a.xhr||new XMLHttpRequest;f.open(c,d,!0),Object.keys(e.headers).forEach(function(a){var b=e.headers[a];"Content-Length"!==a&&"Content-Transfer-Encoding"!==a&&f.setRequestHeader(a,b)}),f.responseType="arraybuffer",f.onload=function(a){var c=f.response;return 200==f.status?b(null,new Uint8Array(c)):b("HTTP Request Error: "+f.status+" "+f.statusText+" "+c?c:"")},f.onerror=function(a){var c;return c=0!==f.status&&f.statusText?f.statusText:"HTTP Request Error",b(new Error(c))},e.body?f.send(e.body):f.send(null)};var j=function(a){a.url.match(/^((http[s]?):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(.*)?(#[\w\-]+)?$/);if(a.proto=RegExp.$2,a.host=RegExp.$3,a.path=RegExp.$4+RegExp.$6,a.http)return a.http;var b=a.env;return b||(b=c&&!c.browser?"node":"browser"),"node"==b?i._nodeRequest:http=i._browserRequest};i.get=function(a,b){e.checkArgument(a&&a.url);var c=j(a),f=a.coin||"btc",i=g[f],k=f.toUpperCase(),l=new h(k);a.headers=a.headers||{Accept:h.LEGACY_PAYMENT[k].REQUEST_CONTENT_TYPE,"Content-Type":"application/octet-stream"},c(a,function(c,e){if(c)return b(c);var f,g,j,k;try{var m=h.PaymentRequest.decode(e);f=l.makePaymentRequest(m),j=f.get("signature"),k=f.get("serialized_payment_details"),g=f.verify(!0)}catch(n){return b(new Error("Could not parse payment protocol"+n))}var o=h.PaymentDetails.decode(k),p=new h;p=p.makePaymentDetails(o);var q=p.get("outputs");if(q.length>1)return b(new Error("Payment Protocol Error: Requests with more that one output are not supported"));var r=q[0],s=r.get("amount").toNumber(),t="test"==p.get("network")?"testnet":"livenet",u=r.get("script").offset,v=r.get("script").limit,w=new d(new Uint8Array(r.get("script").buffer)),x=w.slice(u,v),y=new i.Address.fromScript(new i.Script(x),t),z=p.get("merchant_data");z&&(z=z.toString());var A=g.verified;g.isChain&&(A=A&&g.chainVerified);var B={verified:A,caTrusted:g.caTrusted,caName:g.caName,selfSigned:g.selfSigned,expires:p.get("expires"),memo:p.get("memo"),time:p.get("time"),merchant_data:z,toAddress:y.toString(),amount:s,network:t,domain:a.host,url:a.url},C=p.get("required_fee_rate");return C&&(B.requiredFeeRate=C),b(null,B)})},i._getPayProRefundOutputs=function(a,b,c){b=b.toString(10);var d,e=g[c],f=new h.Output,i=new e.Address(a);if(i.isPayToPublicKeyHash())d=e.Script.buildPublicKeyHashOut(i);else{if(!i.isPayToScriptHash())throw new Error("Unrecognized address type "+i.type);d=e.Script.buildScriptHashOut(i)}return f.set("script",d.toBuffer()),f.set("amount",b),[f]},i._createPayment=function(a,b,c,e,f){var g=new h;g=g.makePayment(),a&&(a=new d(a),g.set("merchant_data",a));var i=new d(b,"hex");g.set("transactions",[i]);var j=this._getPayProRefundOutputs(c,e,f);j&&g.set("refund_to",j),g=g.serialize();for(var k=new ArrayBuffer(g.length),l=new Uint8Array(k),m=0;m=3))throw new Error("Transaction proposal not supported");var k=i.buildTx(b);return h=k.uncheckedSerialize(),j.debug("Regenerating & verifying tx proposal hash -> Hash: ",h," Signature: ",b.proposalSignature),i.verifyMessage(h,b.proposalSignature,g)&&d.checkAddress(a,b.changeAddress)?!0:!1},d.checkPaypro=function(a,b){var c,d,e;return parseInt(a.version)>=3?(c=a.outputs[0].toAddress,d=a.amount,a.feePerKb&&(e=a.feePerKb/1024)):(c=a.toAddress,d=a.amount),c==b.toAddress&&d==b.amount},d.checkTxProposal=function(a,b,c){return c=c||{},this.checkTxProposalSignature(a,b)?c.paypro&&!this.checkPaypro(b,c.paypro)?!1:!0:!1},b.exports=d},{"./common":5,"./log":11,"bitcore-lib":89,lodash:259,preconditions:276}],14:[function(a,b,c){try{var d=a("asn1.js")}catch(e){var d=a("../..")}var f=c,g={"2 5 29 9":"subjectDirectoryAttributes","2 5 29 14":"subjectKeyIdentifier","2 5 29 15":"keyUsage","2 5 29 17":"subjectAlternativeName","2 5 29 18":"issuerAlternativeName","2 5 29 19":"basicConstraints","2 5 29 20":"cRLNumber","2 5 29 21":"reasonCode","2 5 29 24":"invalidityDate","2 5 29 27":"deltaCRLIndicator","2 5 29 28":"issuingDistributionPoint","2 5 29 29":"certificateIssuer","2 5 29 30":"nameConstraints","2 5 29 31":"cRLDistributionPoints","2 5 29 32":"certificatePolicies","2 5 29 33":"policyMappings","2 5 29 35":"authorityKeyIdentifier","2 5 29 36":"policyConstraints","2 5 29 37":"extendedKeyUsage","2 5 29 46":"freshestCRL","2 5 29 54":"inhibitAnyPolicy","1 3 6 1 5 5 7 1 1":"authorityInformationAccess","1 3 6 1 5 5 7 11":"subjectInformationAccess"},h=d.define("CertificateList",function(){this.seq().obj(this.key("tbsCertList").use(p),this.key("signatureAlgorithm").use(i),this.key("signature").bitstr())});f.CertificateList=h;var i=d.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())});f.AlgorithmIdentifier=i;var j=d.define("Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(k),this.key("signatureAlgorithm").use(i),this.key("signature").bitstr())});f.Certificate=j;var k=d.define("TBSCertificate",function(){this.seq().obj(this.key("version").def("v1").explicit(0).use(l),this.key("serialNumber")["int"](),this.key("signature").use(i),this.key("issuer").use(s),this.key("validity").use(m),this.key("subject").use(s),this.key("subjectPublicKeyInfo").use(o),this.key("issuerUniqueID").optional().implicit(1).bitstr(),this.key("subjectUniqueID").optional().implicit(2).bitstr(),this.key("extensions").optional().explicit(3).seqof(r))});f.TBSCertificate=k;var l=d.define("Version",function(){this["int"]({0:"v1",1:"v2",2:"v3"})});f.Version=l;var m=d.define("Validity",function(){this.seq().obj(this.key("notBefore").use(n),this.key("notAfter").use(n))});f.Validity=m;var n=d.define("Time",function(){this.choice({utcTime:this.utctime(),genTime:this.gentime()})});f.Time=n;var o=d.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(i),this.key("subjectPublicKey").bitstr())});f.SubjectPublicKeyInfo=o;var p=d.define("TBSCertList",function(){this.seq().obj(this.key("version").optional()["int"](),this.key("signature").use(i),this.key("issuer").use(s),this.key("thisUpdate").use(n),this.key("nextUpdate").use(n),this.key("revokedCertificates").optional().seqof(q),this.key("crlExtensions").explicit(0).optional().seqof(r))});f.TBSCertList=p;var q=d.define("RevokedCertificate",function(){this.seq().obj(this.key("userCertificate").use(G),this.key("revocationDate").use(n),this.key("crlEntryExtensions").optional().seqof(r))}),r=d.define("Extension",function(){this.seq().obj(this.key("extnID").objid(g),this.key("critical").bool().def(!1),this.key("extnValue").octstr().contains(function(a){ var b=Ha[a.extnID];return b?b:d.define("OctString",function(){this.any()})}))});f.Extension=r;var s=d.define("Name",function(){this.choice({rdnSequence:this.use(x)})});f.Name=s;var t=d.define("GeneralName",function(){this.choice({otherName:this.implicit(0).use(v),rfc822Name:this.implicit(1).ia5str(),dNSName:this.implicit(2).ia5str(),directoryName:this.explicit(4).use(s),ediPartyName:this.implicit(5).use(w),uniformResourceIdentifier:this.implicit(6).ia5str(),iPAddress:this.implicit(7).octstr(),registeredID:this.implicit(8).objid()})});f.GeneralName=t;var u=d.define("GeneralNames",function(){this.seqof(t)});f.GeneralNames=u;var v=d.define("AnotherName",function(){this.seq().obj(this.key("type-id").objid(),this.key("value").explicit(0).any())});f.AnotherName=v;var w=d.define("EDIPartyName",function(){this.seq().obj(this.key("nameAssigner").implicit(0).optional().use(D),this.key("partyName").implicit(1).use(D))});f.EDIPartyName=w;var x=d.define("RDNSequence",function(){this.seqof(y)});f.RDNSequence=x;var y=d.define("RelativeDistinguishedName",function(){this.setof(z)});f.RelativeDistinguishedName=y;var z=d.define("AttributeTypeAndValue",function(){this.seq().obj(this.key("type").use(B),this.key("value").use(C))});f.AttributeTypeAndValue=z;var A=d.define("Attribute",function(){this.seq().obj(this.key("type").use(B),this.key("values").setof(C))});f.Attribute=A;var B=d.define("AttributeType",function(){this.objid()});f.AttributeType=B;var C=d.define("AttributeValue",function(){this.any()});f.AttributeValue=C;var D=d.define("DirectoryString",function(){this.choice({teletexString:this.t61str(),printableString:this.printstr(),universalString:this.unistr(),utf8String:this.utf8str(),bmpString:this.bmpstr()})});f.DirectoryString=D;var E=d.define("AuthorityKeyIdentifier",function(){this.seq().obj(this.key("keyIdentifier").implicit(0).optional().use(F),this.key("authorityCertIssuer").implicit(1).optional().use(u),this.key("authorityCertSerialNumber").implicit(2).optional().use(G))});f.AuthorityKeyIdentifier=E;var F=d.define("KeyIdentifier",function(){this.octstr()});f.KeyIdentifier=F;var G=d.define("CertificateSerialNumber",function(){this["int"]()});f.CertificateSerialNumber=G;var H=d.define("ORAddress",function(){this.seq().obj(this.key("builtInStandardAttributes").use(I),this.key("builtInDomainDefinedAttributes").optional().use(U),this.key("extensionAttributes").optional().use(W))});f.ORAddress=H;var I=d.define("BuiltInStandardAttributes",function(){this.seq().obj(this.key("countryName").optional().use(J),this.key("administrationDomainName").optional().use(K),this.key("networkAddress").implicit(0).optional().use(L),this.key("terminalIdentifier").implicit(1).optional().use(N),this.key("privateDomainName").explicit(2).optional().use(O),this.key("organizationName").implicit(3).optional().use(P),this.key("numericUserIdentifier").implicit(4).optional().use(Q),this.key("personalName").implicit(5).optional().use(R),this.key("organizationalUnitNames").implicit(6).optional().use(S))});f.BuiltInStandardAttributes=I;var J=d.define("CountryName",function(){this.choice({x121DccCode:this.numstr(),iso3166Alpha2Code:this.printstr()})});f.CountryName=J;var K=d.define("AdministrationDomainName",function(){this.choice({numeric:this.numstr(),printable:this.printstr()})});f.AdministrationDomainName=K;var L=d.define("NetworkAddress",function(){this.use(M)});f.NetworkAddress=L;var M=d.define("X121Address",function(){this.numstr()});f.X121Address=M;var N=d.define("TerminalIdentifier",function(){this.printstr()});f.TerminalIdentifier=N;var O=d.define("PrivateDomainName",function(){this.choice({numeric:this.numstr(),printable:this.printstr()})});f.PrivateDomainName=O;var P=d.define("OrganizationName",function(){this.printstr()});f.OrganizationName=P;var Q=d.define("NumericUserIdentifier",function(){this.numstr()});f.NumericUserIdentifier=Q;var R=d.define("PersonalName",function(){this.set().obj(this.key("surname").implicit(0).printstr(),this.key("givenName").implicit(1).printstr(),this.key("initials").implicit(2).printstr(),this.key("generationQualifier").implicit(3).printstr())});f.PersonalName=R;var S=d.define("OrganizationalUnitNames",function(){this.seqof(T)});f.OrganizationalUnitNames=S;var T=d.define("OrganizationalUnitName",function(){this.printstr()});f.OrganizationalUnitName=T;var U=d.define("BuiltInDomainDefinedAttributes",function(){this.seqof(V)});f.BuiltInDomainDefinedAttributes=U;var V=d.define("BuiltInDomainDefinedAttribute",function(){this.seq().obj(this.key("type").printstr(),this.key("value").printstr())});f.BuiltInDomainDefinedAttribute=V;var W=d.define("ExtensionAttributes",function(){this.seqof(X)});f.ExtensionAttributes=W;var X=d.define("ExtensionAttribute",function(){this.seq().obj(this.key("extensionAttributeType").implicit(0)["int"](),this.key("extensionAttributeValue").any().explicit(1)["int"]())});f.ExtensionAttribute=X;var Y=d.define("SubjectKeyIdentifier",function(){this.use(F)});f.SubjectKeyIdentifier=Y;var Z=d.define("KeyUsage",function(){this.bitstr()});f.KeyUsage=Z;var $=d.define("CertificatePolicies",function(){this.seqof(_)});f.CertificatePolicies=$;var _=d.define("PolicyInformation",function(){this.seq().obj(this.key("policyIdentifier").use(aa),this.key("policyQualifiers").optional().use(ba))});f.PolicyInformation=_;var aa=d.define("CertPolicyId",function(){this.objid()});f.CertPolicyId=aa;var ba=d.define("PolicyQualifiers",function(){this.seqof(ca)});f.PolicyQualifiers=ba;var ca=d.define("PolicyQualifierInfo",function(){this.seq().obj(this.key("policyQualifierId").use(da),this.key("qualifier").any())});f.PolicyQualifierInfo=ca;var da=d.define("PolicyQualifierId",function(){this.objid()});f.PolicyQualifierId=da;var ea=d.define("PolicyMappings",function(){this.seqof(fa)});f.PolicyMappings=ea;var fa=d.define("PolicyMapping",function(){this.seq().obj(this.key("issuerDomainPolicy").use(aa),this.key("subjectDomainPolicy").use(aa))});f.PolicyMapping=fa;var ga=d.define("SubjectAlternativeName",function(){this.use(u)});f.SubjectAlternativeName=ga;var ha=d.define("IssuerAlternativeName",function(){this.use(u)});f.IssuerAlternativeName=ha;var ia=d.define("SubjectDirectoryAttributes",function(){this.seqof(A)});f.SubjectDirectoryAttributes=ia;var ja=d.define("BasicConstraints",function(){this.seq().obj(this.key("cA").bool().def(!1),this.key("pathLenConstraint").optional()["int"]())});f.BasicConstraints=ja;var ka=d.define("NameConstraints",function(){this.seq().obj(this.key("permittedSubtrees").implicit(0).optional().use(la),this.key("excludedSubtrees").implicit(1).optional().use(la))});f.NameConstraints=ka;var la=d.define("GeneralSubtrees",function(){this.seqof(ma)});f.GeneralSubtrees=la;var ma=d.define("GeneralSubtree",function(){this.seq().obj(this.key("base").use(t),this.key("minimum").implicit(0).def(0).use(na),this.key("maximum").implicit(0).optional().use(na))});f.GeneralSubtree=ma;var na=d.define("BaseDistance",function(){this["int"]()});f.BaseDistance=na;var oa=d.define("PolicyConstraints",function(){this.seq().obj(this.key("requireExplicitPolicy").implicit(0).optional().use(pa),this.key("inhibitPolicyMapping").implicit(1).optional().use(pa))});f.PolicyConstraints=oa;var pa=d.define("SkipCerts",function(){this["int"]()});f.SkipCerts=pa;var qa=d.define("ExtendedKeyUsage",function(){this.seqof(ra)});f.ExtendedKeyUsage=qa;var ra=d.define("KeyPurposeId",function(){this.objid()});f.KeyPurposeId=ra;var sa=d.define("CRLDistributionPoints",function(){this.seqof(ta)});f.CRLDistributionPoints=sa;var ta=d.define("DistributionPoint",function(){this.seq().obj(this.key("distributionPoint").optional().explicit(0).use(ua),this.key("reasons").optional().implicit(1).use(va),this.key("cRLIssuer").optional().implicit(2).use(u))});f.DistributionPoint=ta;var ua=d.define("DistributionPointName",function(){this.choice({fullName:this.implicit(0).use(u),nameRelativeToCRLIssuer:this.implicit(1).use(y)})});f.DistributionPointName=ua;var va=d.define("ReasonFlags",function(){this.bitstr()});f.ReasonFlags=va;var wa=d.define("InhibitAnyPolicy",function(){this.use(pa)});f.InhibitAnyPolicy=wa;var xa=d.define("FreshestCRL",function(){this.use(sa)});f.FreshestCRL=xa;var ya=d.define("AuthorityInfoAccessSyntax",function(){this.seqof(za)});f.AuthorityInfoAccessSyntax=ya;var za=d.define("AccessDescription",function(){this.seq().obj(this.key("accessMethod").objid(),this.key("accessLocation").use(t))});f.AccessDescription=za;var Aa=d.define("SubjectInformationAccess",function(){this.seqof(za)});f.SubjectInformationAccess=Aa;var Ba=d.define("CRLNumber",function(){this["int"]()});f.CRLNumber=Ba;var Ca=d.define("DeltaCRLIndicator",function(){this.use(Ba)});f.DeltaCRLIndicator=Ca;var Da=d.define("IssuingDistributionPoint",function(){this.seq().obj(this.key("distributionPoint").explicit(0).optional().use(ua),this.key("onlyContainsUserCerts").implicit(1).def(!1).bool(),this.key("onlyContainsCACerts").implicit(2).def(!1).bool(),this.key("onlySomeReasons").implicit(3).optional().use(va),this.key("indirectCRL").implicit(4).def(!1).bool(),this.key("onlyContainsAttributeCerts").implicit(5).def(!1).bool())});f.IssuingDistributionPoint=Da;var Ea=d.define("ReasonCode",function(){this["enum"]({0:"unspecified",1:"keyCompromise",2:"cACompromise",3:"affiliationChanged",4:"superseded",5:"cessationOfOperation",6:"certificateHold",8:"removeFromCRL",9:"privilegeWithdrawn",10:"aACompromise"})});f.ReasonCode=Ea;var Fa=d.define("InvalidityDate",function(){this.gentime()});f.InvalidityDate=Fa;var Ga=d.define("CertificateIssuer",function(){this.use(u)});f.CertificateIssuer=Ga;var Ha={subjectDirectoryAttributes:ia,subjectKeyIdentifier:Y,keyUsage:Z,subjectAlternativeName:ga,issuerAlternativeName:ha,basicConstraints:ja,cRLNumber:Ba,reasonCode:Ea,invalidityDate:Fa,deltaCRLIndicator:Ca,issuingDistributionPoint:Da,certificateIssuer:Ga,nameConstraints:ka,cRLDistributionPoints:sa,certificatePolicies:$,policyMappings:ea,authorityKeyIdentifier:E,policyConstraints:oa,extendedKeyUsage:qa,freshestCRL:xa,inhibitAnyPolicy:wa,authorityInformationAccess:ya,subjectInformationAccess:Aa}},{"../..":1,"asn1.js":15}],15:[function(a,b,c){var d=c;d.bignum=a("bn.js"),d.define=a("./asn1/api").define,d.base=a("./asn1/base"),d.constants=a("./asn1/constants"),d.decoders=a("./asn1/decoders"),d.encoders=a("./asn1/encoders")},{"./asn1/api":16,"./asn1/base":18,"./asn1/constants":22,"./asn1/decoders":24,"./asn1/encoders":27,"bn.js":153}],16:[function(a,b,c){function d(a,b){this.name=a,this.body=b,this.decoders={},this.encoders={}}var e=a("../asn1"),f=a("inherits"),g=c;g.define=function(a,b){return new d(a,b)},d.prototype._createNamed=function(b){var c;try{c=a("vm").runInThisContext("(function "+this.name+"(entity) {\n this._initNamed(entity);\n})")}catch(d){c=function(a){this._initNamed(a)}}return f(c,b),c.prototype._initNamed=function(a){b.call(this,a)},new c(this)},d.prototype._getDecoder=function(a){return a=a||"der",this.decoders.hasOwnProperty(a)||(this.decoders[a]=this._createNamed(e.decoders[a])),this.decoders[a]},d.prototype.decode=function(a,b,c){return this._getDecoder(b).decode(a,c)},d.prototype._getEncoder=function(a){return a=a||"der",this.encoders.hasOwnProperty(a)||(this.encoders[a]=this._createNamed(e.encoders[a])),this.encoders[a]},d.prototype.encode=function(a,b,c){return this._getEncoder(b).encode(a,c)}},{"../asn1":15,inherits:251,vm:341}],17:[function(a,b,c){function d(a,b){return g.call(this,b),h.isBuffer(a)?(this.base=a,this.offset=0,void(this.length=a.length)):void this.error("Input not Buffer")}function e(a,b){if(Array.isArray(a))this.length=0,this.value=a.map(function(a){return a instanceof e||(a=new e(a,b)),this.length+=a.length,a},this);else if("number"==typeof a){if(!(a>=0&&255>=a))return b.error("non-byte EncoderBuffer value");this.value=a,this.length=1}else if("string"==typeof a)this.value=a,this.length=h.byteLength(a);else{if(!h.isBuffer(a))return b.error("Unsupported type: "+typeof a);this.value=a,this.length=a.length}}var f=a("inherits"),g=a("../base").Reporter,h=a("buffer").Buffer;f(d,g),c.DecoderBuffer=d,d.prototype.save=function(){return{offset:this.offset,reporter:g.prototype.save.call(this)}},d.prototype.restore=function(a){var b=new d(this.base);return b.offset=a.offset,b.length=this.offset,this.offset=a.offset,g.prototype.restore.call(this,a.reporter),b},d.prototype.isEmpty=function(){return this.offset===this.length},d.prototype.readUInt8=function(a){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(a||"DecoderBuffer overrun")},d.prototype.skip=function(a,b){if(!(this.offset+a<=this.length))return this.error(b||"DecoderBuffer overrun");var c=new d(this.base);return c._reporterState=this._reporterState,c.offset=this.offset,c.length=this.offset+a,this.offset+=a,c},d.prototype.raw=function(a){return this.base.slice(a?a.offset:this.offset,this.length)},c.EncoderBuffer=e,e.prototype.join=function(a,b){return a||(a=new h(this.length)),b||(b=0),0===this.length?a:(Array.isArray(this.value)?this.value.forEach(function(c){c.join(a,b),b+=c.length}):("number"==typeof this.value?a[b]=this.value:"string"==typeof this.value?a.write(this.value,b):h.isBuffer(this.value)&&this.value.copy(a,b),b+=this.length),a)}},{"../base":18,buffer:187,inherits:251}],18:[function(a,b,c){var d=c;d.Reporter=a("./reporter").Reporter,d.DecoderBuffer=a("./buffer").DecoderBuffer,d.EncoderBuffer=a("./buffer").EncoderBuffer,d.Node=a("./node")},{"./buffer":17,"./node":19,"./reporter":20}],19:[function(a,b,c){function d(a,b){var c={};this._baseState=c,c.enc=a,c.parent=b||null,c.children=null,c.tag=null,c.args=null,c.reverseArgs=null,c.choice=null,c.optional=!1,c.any=!1,c.obj=!1,c.use=null,c.useDecoder=null,c.key=null,c["default"]=null,c.explicit=null,c.implicit=null,c.contains=null,c.parent||(c.children=[],this._wrap())}var e=a("../base").Reporter,f=a("../base").EncoderBuffer,g=a("../base").DecoderBuffer,h=a("minimalistic-assert"),i=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],j=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(i),k=["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"];b.exports=d;var l=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];d.prototype.clone=function(){var a=this._baseState,b={};l.forEach(function(c){b[c]=a[c]});var c=new this.constructor(b.parent);return c._baseState=b,c},d.prototype._wrap=function(){var a=this._baseState;j.forEach(function(b){this[b]=function(){var c=new this.constructor(this);return a.children.push(c),c[b].apply(c,arguments)}},this)},d.prototype._init=function(a){var b=this._baseState;h(null===b.parent),a.call(this),b.children=b.children.filter(function(a){return a._baseState.parent===this},this),h.equal(b.children.length,1,"Root node can have only one child")},d.prototype._useArgs=function(a){var b=this._baseState,c=a.filter(function(a){return a instanceof this.constructor},this);a=a.filter(function(a){return!(a instanceof this.constructor)},this),0!==c.length&&(h(null===b.children),b.children=c,c.forEach(function(a){a._baseState.parent=this},this)),0!==a.length&&(h(null===b.args),b.args=a,b.reverseArgs=a.map(function(a){if("object"!=typeof a||a.constructor!==Object)return a;var b={};return Object.keys(a).forEach(function(c){c==(0|c)&&(c|=0);var d=a[c];b[d]=c}),b}))},k.forEach(function(a){d.prototype[a]=function(){var b=this._baseState;throw new Error(a+" not implemented for encoding: "+b.enc)}}),i.forEach(function(a){d.prototype[a]=function(){var b=this._baseState,c=Array.prototype.slice.call(arguments);return h(null===b.tag),b.tag=a,this._useArgs(c),this}}),d.prototype.use=function(a){h(a);var b=this._baseState;return h(null===b.use),b.use=a,this},d.prototype.optional=function(){var a=this._baseState;return a.optional=!0,this},d.prototype.def=function(a){var b=this._baseState;return h(null===b["default"]),b["default"]=a,b.optional=!0,this},d.prototype.explicit=function(a){var b=this._baseState;return h(null===b.explicit&&null===b.implicit),b.explicit=a,this},d.prototype.implicit=function(a){var b=this._baseState;return h(null===b.explicit&&null===b.implicit),b.implicit=a,this},d.prototype.obj=function(){var a=this._baseState,b=Array.prototype.slice.call(arguments);return a.obj=!0,0!==b.length&&this._useArgs(b),this},d.prototype.key=function(a){var b=this._baseState;return h(null===b.key),b.key=a,this},d.prototype.any=function(){var a=this._baseState;return a.any=!0,this},d.prototype.choice=function(a){var b=this._baseState;return h(null===b.choice),b.choice=a,this._useArgs(Object.keys(a).map(function(b){return a[b]})),this},d.prototype.contains=function(a){var b=this._baseState;return h(null===b.use),b.contains=a,this},d.prototype._decode=function(a,b){var c=this._baseState;if(null===c.parent)return a.wrapResult(c.children[0]._decode(a,b));var d=c["default"],e=!0,f=null;if(null!==c.key&&(f=a.enterKey(c.key)),c.optional){var h=null;if(null!==c.explicit?h=c.explicit:null!==c.implicit?h=c.implicit:null!==c.tag&&(h=c.tag),null!==h||c.any){if(e=this._peekTag(a,h,c.any),a.isError(e))return e}else{var i=a.save();try{null===c.choice?this._decodeGeneric(c.tag,a,b):this._decodeChoice(a,b),e=!0}catch(j){e=!1}a.restore(i)}}var k;if(c.obj&&e&&(k=a.enterObject()),e){if(null!==c.explicit){var l=this._decodeTag(a,c.explicit);if(a.isError(l))return l;a=l}var m=a.offset;if(null===c.use&&null===c.choice){if(c.any)var i=a.save();var n=this._decodeTag(a,null!==c.implicit?c.implicit:c.tag,c.any);if(a.isError(n))return n;c.any?d=a.raw(i):a=n}if(b&&b.track&&null!==c.tag&&b.track(a.path(),m,a.length,"tagged"),b&&b.track&&null!==c.tag&&b.track(a.path(),a.offset,a.length,"content"),d=c.any?d:null===c.choice?this._decodeGeneric(c.tag,a,b):this._decodeChoice(a,b),a.isError(d))return d;if(c.any||null!==c.choice||null===c.children||c.children.forEach(function(c){c._decode(a,b)}),c.contains&&("octstr"===c.tag||"bitstr"===c.tag)){var o=new g(d);d=this._getUse(c.contains,a._reporterState.obj)._decode(o,b)}}return c.obj&&e&&(d=a.leaveObject(k)),null===c.key||null===d&&e!==!0?null!==f&&a.exitKey(f):a.leaveKey(f,c.key,d),d},d.prototype._decodeGeneric=function(a,b,c){var d=this._baseState;return"seq"===a||"set"===a?null:"seqof"===a||"setof"===a?this._decodeList(b,a,d.args[0],c):/str$/.test(a)?this._decodeStr(b,a,c):"objid"===a&&d.args?this._decodeObjid(b,d.args[0],d.args[1],c):"objid"===a?this._decodeObjid(b,null,null,c):"gentime"===a||"utctime"===a?this._decodeTime(b,a,c):"null_"===a?this._decodeNull(b,c):"bool"===a?this._decodeBool(b,c):"objDesc"===a?this._decodeStr(b,a,c):"int"===a||"enum"===a?this._decodeInt(b,d.args&&d.args[0],c):null!==d.use?this._getUse(d.use,b._reporterState.obj)._decode(b,c):b.error("unknown tag: "+a)},d.prototype._getUse=function(a,b){var c=this._baseState;return c.useDecoder=this._use(a,b),h(null===c.useDecoder._baseState.parent),c.useDecoder=c.useDecoder._baseState.children[0],c.implicit!==c.useDecoder._baseState.implicit&&(c.useDecoder=c.useDecoder.clone(),c.useDecoder._baseState.implicit=c.implicit),c.useDecoder},d.prototype._decodeChoice=function(a,b){var c=this._baseState,d=null,e=!1;return Object.keys(c.choice).some(function(f){var g=a.save(),h=c.choice[f];try{var i=h._decode(a,b);if(a.isError(i))return!1;d={type:f,value:i},e=!0}catch(j){return a.restore(g),!1}return!0},this),e?d:a.error("Choice not matched")},d.prototype._createEncoderBuffer=function(a){return new f(a,this.reporter)},d.prototype._encode=function(a,b,c){var d=this._baseState;if(null===d["default"]||d["default"]!==a){var e=this._encodeValue(a,b,c);if(void 0!==e&&!this._skipDefault(e,b,c))return e}},d.prototype._encodeValue=function(a,b,c){var d=this._baseState;if(null===d.parent)return d.children[0]._encode(a,b||new e);var f=null;if(this.reporter=b,d.optional&&void 0===a){if(null===d["default"])return;a=d["default"]}var g=null,h=!1;if(d.any)f=this._createEncoderBuffer(a);else if(d.choice)f=this._encodeChoice(a,b);else if(d.contains)g=this._getUse(d.contains,c)._encode(a,b),h=!0;else if(d.children)g=d.children.map(function(c){if("null_"===c._baseState.tag)return c._encode(null,b,a);if(null===c._baseState.key)return b.error("Child should have a key");var d=b.enterKey(c._baseState.key);if("object"!=typeof a)return b.error("Child expected, but input is not object");var e=c._encode(a[c._baseState.key],b,a);return b.leaveKey(d),e},this).filter(function(a){return a}),g=this._createEncoderBuffer(g);else if("seqof"===d.tag||"setof"===d.tag){if(!d.args||1!==d.args.length)return b.error("Too many args for : "+d.tag);if(!Array.isArray(a))return b.error("seqof/setof, but data is not Array");var i=this.clone();i._baseState.implicit=null,g=this._createEncoderBuffer(a.map(function(c){var d=this._baseState;return this._getUse(d.args[0],a)._encode(c,b)},i))}else null!==d.use?f=this._getUse(d.use,c)._encode(a,b):(g=this._encodePrimitive(d.tag,a),h=!0);var f;if(!d.any&&null===d.choice){var j=null!==d.implicit?d.implicit:d.tag,k=null===d.implicit?"universal":"context";null===j?null===d.use&&b.error("Tag could be ommited only for .use()"):null===d.use&&(f=this._encodeComposite(j,h,k,g))}return null!==d.explicit&&(f=this._encodeComposite(d.explicit,!1,"context",f)),f},d.prototype._encodeChoice=function(a,b){var c=this._baseState,d=c.choice[a.type];return d||h(!1,a.type+" not found in "+JSON.stringify(Object.keys(c.choice))),d._encode(a.value,b)},d.prototype._encodePrimitive=function(a,b){var c=this._baseState;if(/str$/.test(a))return this._encodeStr(b,a);if("objid"===a&&c.args)return this._encodeObjid(b,c.reverseArgs[0],c.args[1]);if("objid"===a)return this._encodeObjid(b,null,null);if("gentime"===a||"utctime"===a)return this._encodeTime(b,a);if("null_"===a)return this._encodeNull();if("int"===a||"enum"===a)return this._encodeInt(b,c.args&&c.reverseArgs[0]);if("bool"===a)return this._encodeBool(b);if("objDesc"===a)return this._encodeStr(b,a);throw new Error("Unsupported tag: "+a)},d.prototype._isNumstr=function(a){return/^[0-9 ]*$/.test(a)},d.prototype._isPrintstr=function(a){return/^[A-Za-z0-9 '\(\)\+,\-\.\/:=\?]*$/.test(a)}},{"../base":18,"minimalistic-assert":264}],20:[function(a,b,c){function d(a){this._reporterState={obj:null,path:[],options:a||{},errors:[]}}function e(a,b){this.path=a,this.rethrow(b)}var f=a("inherits");c.Reporter=d,d.prototype.isError=function(a){return a instanceof e},d.prototype.save=function(){var a=this._reporterState;return{obj:a.obj,pathLen:a.path.length}},d.prototype.restore=function(a){var b=this._reporterState;b.obj=a.obj,b.path=b.path.slice(0,a.pathLen)},d.prototype.enterKey=function(a){return this._reporterState.path.push(a)},d.prototype.exitKey=function(a){var b=this._reporterState;b.path=b.path.slice(0,a-1)},d.prototype.leaveKey=function(a,b,c){var d=this._reporterState;this.exitKey(a),null!==d.obj&&(d.obj[b]=c)},d.prototype.path=function(){return this._reporterState.path.join("/")},d.prototype.enterObject=function(){var a=this._reporterState,b=a.obj;return a.obj={},b},d.prototype.leaveObject=function(a){var b=this._reporterState,c=b.obj;return b.obj=a,c},d.prototype.error=function(a){var b,c=this._reporterState,d=a instanceof e;if(b=d?a:new e(c.path.map(function(a){return"["+JSON.stringify(a)+"]"}).join(""),a.message||a,a.stack),!c.options.partial)throw b;return d||c.errors.push(b),b},d.prototype.wrapResult=function(a){var b=this._reporterState;return b.options.partial?{result:this.isError(a)?null:a,errors:b.errors}:a},f(e,Error),e.prototype.rethrow=function(a){if(this.message=a+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,e),!this.stack)try{throw new Error(this.message)}catch(b){this.stack=b.stack}return this}},{inherits:251}],21:[function(a,b,c){var d=a("../constants");c.tagClass={0:"universal",1:"application",2:"context",3:"private"},c.tagClassByName=d._reverse(c.tagClass),c.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"},c.tagByName=d._reverse(c.tag)},{"../constants":22}],22:[function(a,b,c){var d=c;d._reverse=function(a){var b={};return Object.keys(a).forEach(function(c){(0|c)==c&&(c=0|c);var d=a[c];b[d]=c}),b},d.der=a("./der")},{"./der":21}],23:[function(a,b,c){function d(a){this.enc="der",this.name=a.name,this.entity=a,this.tree=new e,this.tree._init(a.body)}function e(a){j.Node.call(this,"der",a)}function f(a,b){var c=a.readUInt8(b);if(a.isError(c))return c;var d=l.tagClass[c>>6],e=0===(32&c);if(31===(31&c)){var f=c;for(c=0;128===(128&f);){if(f=a.readUInt8(b),a.isError(f))return f;c<<=7,c|=127&f}}else c&=31;var g=l.tag[c];return{cls:d,primitive:e,tag:c,tagStr:g}}function g(a,b,c){var d=a.readUInt8(c);if(a.isError(d))return d;if(!b&&128===d)return null;if(0===(128&d))return d;var e=127&d;if(e>4)return a.error("length octect is too long");d=0;for(var f=0;e>f;f++){d<<=8;var g=a.readUInt8(c);if(a.isError(g))return g;d|=g}return d}var h=a("inherits"),i=a("../../asn1"),j=i.base,k=i.bignum,l=i.constants.der;b.exports=d,d.prototype.decode=function(a,b){return a instanceof j.DecoderBuffer||(a=new j.DecoderBuffer(a,b)),this.tree._decode(a,b)},h(e,j.Node),e.prototype._peekTag=function(a,b,c){if(a.isEmpty())return!1;var d=a.save(),e=f(a,'Failed to peek tag: "'+b+'"');return a.isError(e)?e:(a.restore(d),e.tag===b||e.tagStr===b||e.tagStr+"of"===b||c)},e.prototype._decodeTag=function(a,b,c){var d=f(a,'Failed to decode tag of "'+b+'"');if(a.isError(d))return d;var e=g(a,d.primitive,'Failed to get length of "'+b+'"');if(a.isError(e))return e;if(!c&&d.tag!==b&&d.tagStr!==b&&d.tagStr+"of"!==b)return a.error('Failed to match tag: "'+b+'"');if(d.primitive||null!==e)return a.skip(e,'Failed to match body of: "'+b+'"');var h=a.save(),i=this._skipUntilEnd(a,'Failed to skip indefinite length body: "'+this.tag+'"');return a.isError(i)?i:(e=a.offset-h.offset,a.restore(h),a.skip(e,'Failed to match body of: "'+b+'"'))},e.prototype._skipUntilEnd=function(a,b){for(;;){var c=f(a,b);if(a.isError(c))return c;var d=g(a,c.primitive,b);if(a.isError(d))return d;var e;if(e=c.primitive||null!==d?a.skip(d):this._skipUntilEnd(a,b),a.isError(e))return e;if("end"===c.tagStr)break}},e.prototype._decodeList=function(a,b,c,d){for(var e=[];!a.isEmpty();){var f=this._peekTag(a,"end");if(a.isError(f))return f;var g=c.decode(a,"der",d);if(a.isError(g)&&f)break;e.push(g)}return e},e.prototype._decodeStr=function(a,b){if("bitstr"===b){var c=a.readUInt8();return a.isError(c)?c:{unused:c,data:a.raw()}}if("bmpstr"===b){var d=a.raw();if(d.length%2===1)return a.error("Decoding of string type: bmpstr length mismatch");for(var e="",f=0;fd?2e3+d:1900+d}return Date.UTC(d,e-1,f,g,h,i,0)},e.prototype._decodeNull=function(a){return null},e.prototype._decodeBool=function(a){var b=a.readUInt8();return a.isError(b)?b:0!==b},e.prototype._decodeInt=function(a,b){var c=a.raw(),d=new k(c);return b&&(d=b[d.toString(10)]||d),d},e.prototype._use=function(a,b){return"function"==typeof a&&(a=a(b)),a._getDecoder("der").tree}},{"../../asn1":15,inherits:251}],24:[function(a,b,c){var d=c;d.der=a("./der"),d.pem=a("./pem")},{"./der":23,"./pem":25}],25:[function(a,b,c){function d(a){g.call(this,a),this.enc="pem"}var e=a("inherits"),f=a("buffer").Buffer,g=a("./der");e(d,g),b.exports=d,d.prototype.decode=function(a,b){for(var c=a.toString().split(/[\r\n]+/g),d=b.label.toUpperCase(),e=/^-----(BEGIN|END) ([^-]+)-----$/,h=-1,i=-1,j=0;ja?"0"+a:a}function g(a,b,c,d){var e;if("seqof"===a?a="seq":"setof"===a&&(a="set"),l.tagByName.hasOwnProperty(a))e=l.tagByName[a];else{if("number"!=typeof a||(0|a)!==a)return d.error("Unknown tag: "+a);e=a}return e>=31?d.error("Multi-octet tag encoding unsupported"):(b||(e|=32),e|=l.tagClassByName[c||"universal"]<<6)}var h=a("inherits"),i=a("buffer").Buffer,j=a("../../asn1"),k=j.base,l=j.constants.der;b.exports=d,d.prototype.encode=function(a,b){return this.tree._encode(a,b).join()},h(e,k.Node),e.prototype._encodeComposite=function(a,b,c,d){var e=g(a,b,c,this.reporter);if(d.length<128){var f=new i(2);return f[0]=e,f[1]=d.length,this._createEncoderBuffer([f,d])}for(var h=1,j=d.length;j>=256;j>>=8)h++;var f=new i(2+h);f[0]=e,f[1]=128|h;for(var j=1+h,k=d.length;k>0;j--,k>>=8)f[j]=255&k;return this._createEncoderBuffer([f,d])},e.prototype._encodeStr=function(a,b){if("bitstr"===b)return this._createEncoderBuffer([0|a.unused,a.data]);if("bmpstr"===b){for(var c=new i(2*a.length),d=0;d=40)return this.reporter.error("Second objid identifier OOB");a.splice(0,2,40*a[0]+a[1])}for(var e=0,d=0;d=128;f>>=7)e++}for(var g=new i(e),h=g.length-1,d=a.length-1;d>=0;d--){var f=a[d];for(g[h--]=127&f;(f>>=7)>0;)g[h--]=128|127&f}return this._createEncoderBuffer(g)},e.prototype._encodeTime=function(a,b){var c,d=new Date(a);return"gentime"===b?c=[f(d.getFullYear()),f(d.getUTCMonth()+1),f(d.getUTCDate()),f(d.getUTCHours()),f(d.getUTCMinutes()),f(d.getUTCSeconds()),"Z"].join(""):"utctime"===b?c=[f(d.getFullYear()%100),f(d.getUTCMonth()+1),f(d.getUTCDate()),f(d.getUTCHours()),f(d.getUTCMinutes()),f(d.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+b+" time is not supported yet"),this._encodeStr(c,"octstr")},e.prototype._encodeNull=function(){return this._createEncoderBuffer("")},e.prototype._encodeInt=function(a,b){if("string"==typeof a){if(!b)return this.reporter.error("String int or enum given, but no values map");if(!b.hasOwnProperty(a))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(a));a=b[a]}if("number"!=typeof a&&!i.isBuffer(a)){var c=a.toArray();!a.sign&&128&c[0]&&c.unshift(0),a=new i(c)}if(i.isBuffer(a)){var d=a.length;0===a.length&&d++;var e=new i(d);return a.copy(e),0===a.length&&(e[0]=0),this._createEncoderBuffer(e)}if(128>a)return this._createEncoderBuffer(a);if(256>a)return this._createEncoderBuffer([0,a]);for(var d=1,f=a;f>=256;f>>=8)d++;for(var e=new Array(d),f=e.length-1;f>=0;f--)e[f]=255&a,a>>=8;return 128&e[0]&&e.unshift(0),this._createEncoderBuffer(new i(e))},e.prototype._encodeBool=function(a){return this._createEncoderBuffer(a?255:0)},e.prototype._use=function(a,b){return"function"==typeof a&&(a=a(b)),a._getEncoder("der").tree},e.prototype._skipDefault=function(a,b,c){var d,e=this._baseState;if(null===e["default"])return!1;var f=a.join();if(void 0===e.defaultBuffer&&(e.defaultBuffer=this._encodeValue(e["default"],b,c).join()),f.length!==e.defaultBuffer.length)return!1;for(d=0;de;++e)if(a[e]!==b[e]){c=a[e],d=b[e];break}return d>c?-1:c>d?1:0}function e(a){return c.Buffer&&"function"==typeof c.Buffer.isBuffer?c.Buffer.isBuffer(a):!(null==a||!a._isBuffer)}function f(a){return Object.prototype.toString.call(a)}function g(a){return e(a)?!1:"function"!=typeof c.ArrayBuffer?!1:"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(a):a?a instanceof DataView?!0:a.buffer&&a.buffer instanceof ArrayBuffer?!0:!1:!1}function h(a){if(u.isFunction(a)){if(x)return a.name;var b=a.toString(),c=b.match(z);return c&&c[1]}}function i(a,b){return"string"==typeof a?a.length=0;h--)if(i[h]!==j[h])return!1;for(h=i.length-1;h>=0;h--)if(g=i[h],!n(a[g],b[g],c,d))return!1;return!0}function q(a,b,c){n(a,b,!0)&&l(a,b,c,"notDeepStrictEqual",q)}function r(a,b){if(!a||!b)return!1;if("[object RegExp]"==Object.prototype.toString.call(b))return b.test(a);try{if(a instanceof b)return!0}catch(c){}return Error.isPrototypeOf(b)?!1:b.call({},a)===!0}function s(a){var b;try{a()}catch(c){b=c}return b}function t(a,b,c,d){var e;if("function"!=typeof b)throw new TypeError('"block" argument must be a function');"string"==typeof c&&(d=c,c=null),e=s(b),d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&l(e,c,"Missing expected exception"+d);var f="string"==typeof d,g=!a&&u.isError(e),h=!a&&e&&!c;if((g&&f&&r(e,c)||h)&&l(e,c,"Got unwanted exception"+d),a&&e&&c&&!r(e,c)||!a&&e)throw e}var u=a("util/"),v=Object.prototype.hasOwnProperty,w=Array.prototype.slice,x=function(){return"foo"===function(){}.name}(),y=b.exports=m,z=/\s*function\s+([^\(\s]*)\s*/;y.AssertionError=function(a){this.name="AssertionError",this.actual=a.actual,this.expected=a.expected,this.operator=a.operator,a.message?(this.message=a.message,this.generatedMessage=!1):(this.message=k(this),this.generatedMessage=!0);var b=a.stackStartFunction||l;if(Error.captureStackTrace)Error.captureStackTrace(this,b);else{var c=new Error;if(c.stack){var d=c.stack,e=h(b),f=d.indexOf("\n"+e);if(f>=0){var g=d.indexOf("\n",f+1);d=d.substring(g+1)}this.stack=d}}},u.inherits(y.AssertionError,Error),y.fail=l,y.ok=m,y.equal=function(a,b,c){a!=b&&l(a,b,c,"==",y.equal)},y.notEqual=function(a,b,c){a==b&&l(a,b,c,"!=",y.notEqual)},y.deepEqual=function(a,b,c){n(a,b,!1)||l(a,b,c,"deepEqual",y.deepEqual)},y.deepStrictEqual=function(a,b,c){n(a,b,!0)||l(a,b,c,"deepStrictEqual",y.deepStrictEqual)},y.notDeepEqual=function(a,b,c){n(a,b,!1)&&l(a,b,c,"notDeepEqual",y.notDeepEqual)},y.notDeepStrictEqual=q,y.strictEqual=function(a,b,c){a!==b&&l(a,b,c,"===",y.strictEqual)},y.notStrictEqual=function(a,b,c){a===b&&l(a,b,c,"!==",y.notStrictEqual)},y["throws"]=function(a,b,c){t(!0,a,b,c)},y.doesNotThrow=function(a,b,c){t(!1,a,b,c)},y.ifError=function(a){if(a)throw a};var A=Object.keys||function(a){var b=[];for(var c in a)v.call(a,c)&&b.push(c);return b}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"util/":340}],30:[function(a,b,c){(function(a){!function(){function c(a){var b=!1;return function(){if(b)throw new Error("Callback was already called.");b=!0,a.apply(d,arguments)}}var d,e,f={};d=this,null!=d&&(e=d.async),f.noConflict=function(){return d.async=e,f};var g=Object.prototype.toString,h=Array.isArray||function(a){return"[object Array]"===g.call(a)},i=function(a,b){for(var c=0;c=a.length&&d())}if(d=d||function(){},!a.length)return d();var f=0;i(a,function(a){b(a,c(e))})},f.forEach=f.each,f.eachSeries=function(a,b,c){if(c=c||function(){},!a.length)return c();var d=0,e=function(){b(a[d],function(b){b?(c(b),c=function(){}):(d+=1,d>=a.length?c():e())})};e()},f.forEachSeries=f.eachSeries,f.eachLimit=function(a,b,c,d){var e=m(b);e.apply(null,[a,c,d])},f.forEachLimit=f.eachLimit;var m=function(a){return function(b,c,d){if(d=d||function(){},!b.length||0>=a)return d();var e=0,f=0,g=0;!function h(){if(e>=b.length)return d();for(;a>g&&f=b.length?d():h())})}()}},n=function(a){return function(){var b=Array.prototype.slice.call(arguments);return a.apply(null,[f.each].concat(b))}},o=function(a,b){return function(){var c=Array.prototype.slice.call(arguments);return b.apply(null,[m(a)].concat(c))}},p=function(a){return function(){var b=Array.prototype.slice.call(arguments);return a.apply(null,[f.eachSeries].concat(b))}},q=function(a,b,c,d){if(b=j(b,function(a,b){return{index:b,value:a}}),d){var e=[];a(b,function(a,b){c(a.value,function(c,d){e[a.index]=d,b(c)})},function(a){d(a,e)})}else a(b,function(a,b){c(a.value,function(a){b(a)})})};f.map=n(q),f.mapSeries=p(q),f.mapLimit=function(a,b,c,d){return r(b)(a,c,d)};var r=function(a){return o(a,q)};f.reduce=function(a,b,c,d){f.eachSeries(a,function(a,d){c(b,a,function(a,c){b=c,d(a)})},function(a){d(a,b)})},f.inject=f.reduce,f.foldl=f.reduce,f.reduceRight=function(a,b,c,d){var e=j(a,function(a){return a}).reverse();f.reduce(e,b,c,d)},f.foldr=f.reduceRight;var s=function(a,b,c,d){var e=[];b=j(b,function(a,b){return{index:b,value:a}}),a(b,function(a,b){c(a.value,function(c){c&&e.push(a),b()})},function(a){d(j(e.sort(function(a,b){return a.index-b.index}),function(a){return a.value}))})};f.filter=n(s),f.filterSeries=p(s),f.select=f.filter,f.selectSeries=f.filterSeries;var t=function(a,b,c,d){var e=[];b=j(b,function(a,b){return{index:b,value:a}}),a(b,function(a,b){c(a.value,function(c){c||e.push(a),b()})},function(a){d(j(e.sort(function(a,b){return a.index-b.index}),function(a){return a.value}))})};f.reject=n(t),f.rejectSeries=p(t);var u=function(a,b,c,d){a(b,function(a,b){c(a,function(c){c?(d(a),d=function(){}):b()})},function(a){d()})};f.detect=n(u),f.detectSeries=p(u),f.some=function(a,b,c){f.each(a,function(a,d){b(a,function(a){a&&(c(!0),c=function(){}),d()})},function(a){c(!1)})},f.any=f.some,f.every=function(a,b,c){f.each(a,function(a,d){b(a,function(a){a||(c(!1),c=function(){}),d()})},function(a){c(!0)})},f.all=f.every,f.sortBy=function(a,b,c){f.map(a,function(a,c){b(a,function(b,d){b?c(b):c(null,{value:a,criteria:d})})},function(a,b){if(a)return c(a);var d=function(a,b){var c=a.criteria,d=b.criteria;return d>c?-1:c>d?1:0};c(null,j(b.sort(d),function(a){return a.value}))})},f.auto=function(a,b){b=b||function(){};var c=l(a),d=c.length;if(!d)return b();var e={},g=[],j=function(a){g.unshift(a)},m=function(a){for(var b=0;bd;){var f=d+(e-d+1>>>1);c(b,a[f])>=0?d=f:e=f-1}return d}function e(a,b,e,g){return a.started||(a.started=!0),h(b)||(b=[b]),0==b.length?f.setImmediate(function(){a.drain&&a.drain()}):void i(b,function(b){var h={data:b,priority:e,callback:"function"==typeof g?g:null};a.tasks.splice(d(a.tasks,h,c)+1,0,h),a.saturated&&a.tasks.length===a.concurrency&&a.saturated(),f.setImmediate(a.process)})}var g=f.queue(a,b);return g.push=function(a,b,c){e(g,a,b,c)},delete g.unshift,g},f.cargo=function(a,b){var c=!1,d=[],e={tasks:d,payload:b,saturated:null,empty:null,drain:null,drained:!0,push:function(a,c){h(a)||(a=[a]),i(a,function(a){d.push({data:a,callback:"function"==typeof c?c:null}),e.drained=!1,e.saturated&&d.length===b&&e.saturated()}),f.setImmediate(e.process)},process:function g(){if(!c){if(0===d.length)return e.drain&&!e.drained&&e.drain(),void(e.drained=!0);var f="number"==typeof b?d.splice(0,b):d.splice(0,d.length),h=j(f,function(a){return a.data});e.empty&&e.empty(),c=!0,a(h,function(){c=!1;var a=arguments;i(f,function(b){b.callback&&b.callback.apply(null,a)}),g()})}},length:function(){return d.length},running:function(){return c}};return e};var x=function(a){return function(b){var c=Array.prototype.slice.call(arguments,1);b.apply(null,c.concat([function(b){var c=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(b?console.error&&console.error(b):console[a]&&i(c,function(b){console[a](b)}))}]))}};f.log=x("log"),f.dir=x("dir"),f.memoize=function(a,b){var c={},d={};b=b||function(a){return a};var e=function(){var e=Array.prototype.slice.call(arguments),g=e.pop(),h=b.apply(null,e);h in c?f.nextTick(function(){g.apply(null,c[h])}):h in d?d[h].push(g):(d[h]=[g],a.apply(null,e.concat([function(){c[h]=arguments;var a=d[h];delete d[h];for(var b=0,e=a.length;e>b;b++)a[b].apply(null,arguments)}])))};return e.memo=c,e.unmemoized=a,e},f.unmemoize=function(a){return function(){return(a.unmemoized||a).apply(null,arguments)}},f.times=function(a,b,c){for(var d=[],e=0;a>e;e++)d.push(e);return f.map(d,b,c)},f.timesSeries=function(a,b,c){for(var d=[],e=0;a>e;e++)d.push(e);return f.mapSeries(d,b,c)},f.seq=function(){var a=arguments;return function(){var b=this,c=Array.prototype.slice.call(arguments),d=c.pop();f.reduce(a,c,function(a,c,d){c.apply(b,a.concat([function(){var a=arguments[0],b=Array.prototype.slice.call(arguments,1);d(a,b)}]))},function(a,c){d.apply(b,[a].concat(c))})}},f.compose=function(){return f.seq.apply(null,Array.prototype.reverse.call(arguments))};var y=function(a,b){var c=function(){var c=this,d=Array.prototype.slice.call(arguments),e=d.pop();return a(b,function(a,b){a.apply(c,d.concat([b]))},e)};if(arguments.length>2){var d=Array.prototype.slice.call(arguments,2);return c.apply(this,d)}return c};f.applyEach=n(y),f.applyEachSeries=p(y),f.forever=function(a,b){function c(d){if(d){if(b)return b(d);throw d}a(c)}c()},"undefined"!=typeof b&&b.exports?b.exports=f:"undefined"!=typeof define&&define.amd?define([],function(){return f}):d.async=f}()}).call(this,a("_process"))},{_process:282}],31:[function(a,b,c){var d=a("safe-buffer").Buffer;b.exports=function(a){function b(b){if(0===b.length)return"";for(var c=[0],d=0;d0;)c.push(f%g),f=f/g|0}for(var i="",j=0;0===b[j]&&j=0;--k)i+=a[c[k]];return i}function c(a){if("string"!=typeof a)throw new TypeError("Expected String");if(0===a.length)return d.allocUnsafe(0);for(var b=[0],c=0;c>=8;for(;j>0;)b.push(255&j),j>>=8}for(var k=0;a[k]===h&&k0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===a[b-2]?2:"="===a[b-1]?1:0}function e(a){return 3*a.length/4-d(a)}function f(a){var b,c,e,f,g,h=a.length;f=d(a),g=new l(3*h/4-f),c=f>0?h-4:h;var i=0;for(b=0;c>b;b+=4)e=k[a.charCodeAt(b)]<<18|k[a.charCodeAt(b+1)]<<12|k[a.charCodeAt(b+2)]<<6|k[a.charCodeAt(b+3)],g[i++]=e>>16&255,g[i++]=e>>8&255,g[i++]=255&e;return 2===f?(e=k[a.charCodeAt(b)]<<2|k[a.charCodeAt(b+1)]>>4,g[i++]=255&e):1===f&&(e=k[a.charCodeAt(b)]<<10|k[a.charCodeAt(b+1)]<<4|k[a.charCodeAt(b+2)]>>2,g[i++]=e>>8&255,g[i++]=255&e),g}function g(a){return j[a>>18&63]+j[a>>12&63]+j[a>>6&63]+j[63&a]}function h(a,b,c){for(var d,e=[],f=b;c>f;f+=3)d=(a[f]<<16&16711680)+(a[f+1]<<8&65280)+(255&a[f+2]),e.push(g(d));return e.join("")}function i(a){for(var b,c=a.length,d=c%3,e="",f=[],g=16383,i=0,k=c-d;k>i;i+=g)f.push(h(a,i,i+g>k?k:i+g));return 1===d?(b=a[c-1],e+=j[b>>2],e+=j[b<<4&63],e+="=="):2===d&&(b=(a[c-2]<<8)+a[c-1],e+=j[b>>10],e+=j[b>>4&63],e+=j[b<<2&63],e+="="),f.push(e),f.join("")}c.byteLength=e,c.toByteArray=f,c.fromByteArray=i;for(var j=[],k=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,o=m.length;o>n;++n)j[n]=m[n],k[m.charCodeAt(n)]=n;k["-".charCodeAt(0)]=62,k["_".charCodeAt(0)]=63},{}],33:[function(a,b,c){function d(a,b,c){return this instanceof d?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 d(a,b,c)}function e(a,b,c,d,e,f){for(;--f>=0;){var g=b*this[a++]+c[d]+e;e=Math.floor(g/67108864),c[d++]=67108863&g}return e}function f(a){return fb.charAt(a)}function g(a,b){var c=gb[a.charCodeAt(b)];return null==c?-1:c}function h(a){for(var b=this.t-1;b>=0;--b)a[b]=this[b];a.t=this.t,a.s=this.s}function i(a){this.t=1,this.s=0>a?-1:0,a>0?this[0]=a:-1>a?this[0]=a+bb:this.t=0}function j(a){var b=new d;return b.fromInt(a),b}function k(a,b){var c,e=this;if(16==b)c=4;else if(8==b)c=3;else if(256==b)c=8;else if(2==b)c=1;else if(32==b)c=5;else{if(4!=b)return void e.fromRadix(a,b);c=2}e.t=0,e.s=0;for(var f=a.length,h=!1,i=0;--f>=0;){var j=8==c?255&a[f]:g(a,f);0>j?"-"==a.charAt(f)&&(h=!0):(h=!1,0==i?e[e.t++]=j:i+c>e.DB?(e[e.t-1]|=(j&(1<>e.DB-i):e[e.t-1]|=j<=e.DB&&(i-=e.DB))}8==c&&0!=(128&a[0])&&(e.s=-1,i>0&&(e[e.t-1]|=(1<0&&this[this.t-1]==a;)--this.t}function m(a){var b=this;if(b.s<0)return"-"+b.negate().toString(a);var c;if(16==a)c=4;else if(8==a)c=3;else if(2==a)c=1;else if(32==a)c=5;else{if(4!=a)return b.toRadix(a);c=2}var d,e=(1<0)for(j>j)>0&&(g=!0,h=f(d));i>=0;)c>j?(d=(b[i]&(1<>(j+=b.DB-c)):(d=b[i]>>(j-=c)&e,0>=j&&(j+=b.DB,--i)),d>0&&(g=!0),g&&(h+=f(d));return g?h:"0"}function n(){var a=new d;return d.ZERO.subTo(this,a),a}function o(){return this.s<0?this.negate():this}function p(a){var b=this.s-a.s;if(0!=b)return b;var c=this.t;if(b=c-a.t,0!=b)return this.s<0?-b:b;for(;--c>=0;)if(0!=(b=this[c]-a[c]))return b;return 0}function q(a){var b,c=1;return 0!=(b=a>>>16)&&(a=b,c+=16),0!=(b=a>>8)&&(a=b,c+=8),0!=(b=a>>4)&&(a=b,c+=4),0!=(b=a>>2)&&(a=b,c+=2),0!=(b=a>>1)&&(a=b,c+=1),c}function r(){return this.t<=0?0:this.DB*(this.t-1)+q(this[this.t-1]^this.s&this.DM)}function s(){return this.bitLength()>>3}function t(a,b){var c;for(c=this.t-1;c>=0;--c)b[c+a]=this[c];for(c=a-1;c>=0;--c)b[c]=0;b.t=this.t+a,b.s=this.s}function u(a,b){for(var c=a;c=0;--c)b[c+h+1]=d[c]>>f|i,i=(d[c]&g)<=0;--c)b[c]=0;b[h]=i,b.t=d.t+h+1,b.s=d.s,b.clamp()}function w(a,b){var c=this;b.s=c.s;var d=Math.floor(a/c.DB);if(d>=c.t)return void(b.t=0);var e=a%c.DB,f=c.DB-e,g=(1<>e;for(var h=d+1;h>e;e>0&&(b[c.t-d-1]|=(c.s&g)<d;)e+=c[d]-a[d],b[d++]=e&c.DM,e>>=c.DB;if(a.t>=c.DB;e+=c.s}else{for(e+=c.s;d>=c.DB;e-=a.s}b.s=0>e?-1:0,-1>e?b[d++]=c.DV+e:e>0&&(b[d++]=e),b.t=d,b.clamp()}function y(a,b){var c=this.abs(),e=a.abs(),f=c.t;for(b.t=f+e.t;--f>=0;)b[f]=0;for(f=0;f=0;)a[c]=0;for(c=0;c=b.DV&&(a[c+b.t]-=b.DV,a[c+b.t+1]=1)}a.t>0&&(a[a.t-1]+=b.am(c,b[c],a,2*c,0,1)),a.s=0,a.clamp()}function A(a,b,c){var e=this,f=a.abs();if(!(f.t<=0)){var g=e.abs();if(g.t0?(f.lShiftTo(k,h),g.lShiftTo(k,c)):(f.copyTo(h),g.copyTo(c));var l=h.t,m=h[l-1];if(0!=m){var n=m*(1<1?h[l-2]>>e.F2:0),o=e.FV/n,p=(1<=0&&(c[c.t++]=1,c.subTo(u,c)),d.ONE.dlShiftTo(l,u),u.subTo(h,h);h.t=0;){var v=c[--s]==m?e.DM:Math.floor(c[s]*o+(c[s-1]+r)*p);if((c[s]+=h.am(0,v,c,t,0,l))0&&c.rShiftTo(k,c),0>i&&d.ZERO.subTo(c,c)}}}function B(a){var b=new d;return this.abs().divRemTo(a,null,b),this.s<0&&b.compareTo(d.ZERO)>0&&a.subTo(b,b),b}function C(a){this.m=a}function D(a){return a.s<0||a.compareTo(this.m)>=0?a.mod(this.m):a}function E(a){return a}function F(a){a.divRemTo(this.m,null,a)}function G(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function H(a,b){a.squareTo(b),this.reduce(b)}function I(){if(this.t<1)return 0;var a=this[0];if(0==(1&a))return 0;var b=3&a;return b=b*(2-(15&a)*b)&15,b=b*(2-(255&a)*b)&255,b=b*(2-((65535&a)*b&65535))&65535,b=b*(2-a*b%this.DV)%this.DV,b>0?this.DV-b:-b}function J(a){this.m=a,this.mp=a.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(b,b),b}function L(a){var b=new d;return a.copyTo(b),this.reduce(b),b}function M(a){for(;a.t<=this.mt2;)a[a.t++]=0;for(var b=0;b>15)*this.mpl&this.um)<<15)&a.DM;for(c=b+this.m.t,a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a.DV;)a[c]-=a.DV,a[++c]++}a.clamp(),a.drShiftTo(this.m.t,a),a.compareTo(this.m)>=0&&a.subTo(this.m,a)}function N(a,b){a.squareTo(b),this.reduce(b)}function O(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function P(){return 0==(this.t>0?1&this[0]:this.s)}function Q(a,b){if(a>4294967295||1>a)return d.ONE;var c=new d,e=new d,f=b.convert(this),g=q(a)-1;for(f.copyTo(c);--g>=0;)if(b.sqrTo(c,e),(a&1<0)b.mulTo(e,f,c);else{var h=c;c=e,e=h}return b.revert(c)}function R(a,b){var c;return c=256>a||b.isEven()?new C(b):new J(b),this.exp(a,c)}function S(){var a=new d;return this.copyTo(a),a}function T(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function V(){return 0==this.t?this.s:this[0]<<16>>16}function W(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function X(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function Y(a){if(null==a&&(a=10),0==this.signum()||2>a||a>36)return"0";var b=this.chunkSize(a),c=Math.pow(a,b),e=j(c),f=new d,g=new d,h="";for(this.divRemTo(e,f,g);f.signum()>0;)h=(c+g.intValue()).toString(a).substr(1)+h,f.divRemTo(e,f,g);return g.intValue().toString(a)+h}function Z(a,b){var c=this;c.fromInt(0),null==b&&(b=10);for(var e=c.chunkSize(b),f=Math.pow(b,e),h=!1,i=0,j=0,k=0;kl?"-"==a.charAt(k)&&0==c.signum()&&(h=!0):(j=b*j+l,++i>=e&&(c.dMultiply(f),c.dAddOffset(j,0),i=0,j=0))}i>0&&(c.dMultiply(Math.pow(b,i)),c.dAddOffset(j,0)),h&&d.ZERO.subTo(c,c)}function $(a,b,c){var e=this;if("number"==typeof b)if(2>a)e.fromInt(1);else for(e.fromNumber(a,c),e.testBit(a-1)||e.bitwiseTo(d.ONE.shiftLeft(a-1),ga,e),e.isEven()&&e.dAddOffset(1,0);!e.isProbablePrime(b);)e.dAddOffset(2,0),e.bitLength()>a&&e.subTo(d.ONE.shiftLeft(a-1),e);else{var f=new Array,g=7&a;f.length=(a>>3)+1,b.nextBytes(f),g>0?f[0]&=(1<0)for(e>e)!=(a.s&a.DM)>>e&&(c[f++]=d|a.s<=0;)8>e?(d=(a[b]&(1<>(e+=a.DB-8)):(d=a[b]>>(e-=8)&255,0>=e&&(e+=a.DB,--b)),0!=(128&d)&&(d|=-256),0===f&&(128&a.s)!=(128&d)&&++f,(f>0||d!=a.s)&&(c[f++]=d);return c}function aa(a){return 0==this.compareTo(a)}function ba(a){return this.compareTo(a)<0?this:a}function ca(a){return this.compareTo(a)>0?this:a}function da(a,b,c){var d,e,f=this,g=Math.min(a.t,f.t);for(d=0;g>d;++d)c[d]=b(f[d],a[d]);if(a.ta?this.rShiftTo(-a,b):this.lShiftTo(a,b),b}function oa(a){var b=new d;return 0>a?this.lShiftTo(-a,b):this.rShiftTo(a,b),b}function pa(a){if(0==a)return-1;var b=0;return 0==(65535&a)&&(a>>=16,b+=16),0==(255&a)&&(a>>=8,b+=8),0==(15&a)&&(a>>=4,b+=4),0==(3&a)&&(a>>=2,b+=2),0==(1&a)&&++b,b}function qa(){for(var a=0;a=this.t?0!=this.s:0!=(this[b]&1<d;)e+=c[d]+a[d],b[d++]=e&c.DM,e>>=c.DB;if(a.t>=c.DB;e+=c.s}else{for(e+=c.s;d>=c.DB;e+=a.s}b.s=0>e?-1:0,e>0?b[d++]=e:-1>e&&(b[d++]=c.DV+e),b.t=d,b.clamp()}function za(a){var b=new d;return this.addTo(a,b),b}function Aa(a){var b=new d;return this.subTo(a,b),b}function Ba(a){var b=new d;return this.multiplyTo(a,b),b}function Ca(){var a=new d;return this.squareTo(a),a}function Da(a){var b=new d;return this.divRemTo(a,b,null),b}function Ea(a){var b=new d;return this.divRemTo(a,null,b),b}function Fa(a){var b=new d,c=new d;return this.divRemTo(a,b,c),new Array(b,c)}function Ga(a){this[this.t]=this.am(0,a-1,this,0,0,this.t),++this.t,this.clamp()}function Ha(a,b){if(0!=a){for(;this.t<=b;)this[this.t++]=0;for(this[b]+=a;this[b]>=this.DV;)this[b]-=this.DV,++b>=this.t&&(this[this.t++]=0),++this[b]}}function Ia(){}function Ja(a){return a}function Ka(a,b,c){a.multiplyTo(b,c)}function La(a,b){a.squareTo(b)}function Ma(a){return this.exp(a,new Ia)}function Na(a,b,c){var d=Math.min(this.t+a.t,b);for(c.s=0,c.t=d;d>0;)c[--d]=0;var e;for(e=c.t-this.t;e>d;++d)c[d+this.t]=this.am(0,a[d],c,d,0,this.t);for(e=Math.min(a.t,b);e>d;++d)this.am(0,a[d],c,d,0,b-d);c.clamp()}function Oa(a,b,c){--b;var d=c.t=this.t+a.t-b;for(c.s=0;--d>=0;)c[d]=0;for(d=Math.max(b-this.t,0);d2*this.m.t)return a.mod(this.m);if(a.compareTo(this.m)<0)return a;var b=new d;return a.copyTo(b), this.reduce(b),b}function Ra(a){return a}function Sa(a){var b=this;for(a.drShiftTo(b.m.t-1,b.r2),a.t>b.m.t+1&&(a.t=b.m.t+1,a.clamp()),b.mu.multiplyUpperTo(b.r2,b.m.t+1,b.q3),b.m.multiplyLowerTo(b.q3,b.m.t+1,b.r2);a.compareTo(b.r2)<0;)a.dAddOffset(1,b.m.t+1);for(a.subTo(b.r2,a);a.compareTo(b.m)>=0;)a.subTo(b.m,a)}function Ta(a,b){a.squareTo(b),this.reduce(b)}function Ua(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function Va(a,b){var c,e,f=a.bitLength(),g=j(1);if(0>=f)return g;c=18>f?1:48>f?3:144>f?4:768>f?5:6,e=8>f?new C(b):b.isEven()?new Pa(b):new J(b);var h=new Array,i=3,k=c-1,l=(1<1){var m=new d;for(e.sqrTo(h[1],m);l>=i;)h[i]=new d,e.mulTo(m,h[i-2],h[i]),i+=2}var n,o,p=a.t-1,r=!0,s=new d;for(f=q(a[p])-1;p>=0;){for(f>=k?n=a[p]>>f-k&l:(n=(a[p]&(1<0&&(n|=a[p-1]>>this.DB+f-k)),i=c;0==(1&n);)n>>=1,--i;if((f-=i)<0&&(f+=this.DB,--p),r)h[n].copyTo(g),r=!1;else{for(;i>1;)e.sqrTo(g,s),e.sqrTo(s,g),i-=2;i>0?e.sqrTo(g,s):(o=g,g=s,s=o),e.mulTo(s,h[n],g)}for(;p>=0&&0==(a[p]&1<f)return b;for(f>e&&(f=e),f>0&&(b.rShiftTo(f,b),c.rShiftTo(f,c));b.signum()>0;)(e=b.getLowestSetBit())>0&&b.rShiftTo(e,b),(e=c.getLowestSetBit())>0&&c.rShiftTo(e,c),b.compareTo(c)>=0?(b.subTo(c,b),b.rShiftTo(1,b)):(c.subTo(b,c),c.rShiftTo(1,c));return f>0&&c.lShiftTo(f,c),c}function Xa(a){if(0>=a)return 0;var b=this.DV%a,c=this.s<0?a-1:0;if(this.t>0)if(0==b)c=this[0]%a;else for(var d=this.t-1;d>=0;--d)c=(b*c+this[d])%a;return c}function Ya(a){var b=a.isEven();if(0===this.signum())throw new Error("division by zero");if(this.isEven()&&b||0==a.signum())return d.ZERO;for(var c=a.clone(),e=this.clone(),f=j(1),g=j(0),h=j(0),i=j(1);0!=c.signum();){for(;c.isEven();)c.rShiftTo(1,c),b?(f.isEven()&&g.isEven()||(f.addTo(this,f),g.subTo(a,g)),f.rShiftTo(1,f)):g.isEven()||g.subTo(a,g),g.rShiftTo(1,g);for(;e.isEven();)e.rShiftTo(1,e),b?(h.isEven()&&i.isEven()||(h.addTo(this,h),i.subTo(a,i)),h.rShiftTo(1,h)):i.isEven()||i.subTo(a,i),i.rShiftTo(1,i);c.compareTo(e)>=0?(c.subTo(e,c),b&&f.subTo(h,f),g.subTo(i,g)):(e.subTo(c,e),b&&h.subTo(f,h),i.subTo(g,i))}if(0!=e.compareTo(d.ONE))return d.ZERO;for(;i.compareTo(a)>=0;)i.subTo(a,i);for(;i.signum()<0;)i.addTo(a,i);return i}function Za(a){var b,c=this.abs();if(1==c.t&&c[0]<=hb[hb.length-1]){for(b=0;bd;)d*=hb[e++];for(d=c.modInt(d);e>b;)if(d%hb[b++]==0)return!1}return c.millerRabin(a)}function $a(a){var b=this.subtract(d.ONE),c=b.getLowestSetBit();if(0>=c)return!1;var e=b.shiftRight(c);a=a+1>>1,a>hb.length&&(a=hb.length);for(var f,g=new d(null),h=[],i=0;a>i;++i){for(;f=hb[Math.floor(Math.random()*hb.length)],-1!=h.indexOf(f););h.push(f),g.fromInt(f);var j=g.modPow(e,this);if(0!=j.compareTo(d.ONE)&&0!=j.compareTo(b)){for(var f=1;f++=eb;++eb)gb[db++]=eb;for(db="a".charCodeAt(0),eb=10;36>eb;++eb)gb[db++]=eb;for(db="A".charCodeAt(0),eb=10;36>eb;++eb)gb[db++]=eb;C.prototype.convert=D,C.prototype.revert=E,C.prototype.reduce=F,C.prototype.mulTo=G,C.prototype.sqrTo=H,J.prototype.convert=K,J.prototype.revert=L,J.prototype.reduce=M,J.prototype.mulTo=O,J.prototype.sqrTo=N,_a.copyTo=h,_a.fromInt=i,_a.fromString=k,_a.clamp=l,_a.dlShiftTo=t,_a.drShiftTo=u,_a.lShiftTo=v,_a.rShiftTo=w,_a.subTo=x,_a.multiplyTo=y,_a.squareTo=z,_a.divRemTo=A,_a.invDigit=I,_a.isEven=P,_a.exp=Q,_a.toString=m,_a.negate=n,_a.abs=o,_a.compareTo=p,_a.bitLength=r,_a.byteLength=s,_a.mod=B,_a.modPowInt=R,Ia.prototype.convert=Ja,Ia.prototype.revert=Ja,Ia.prototype.mulTo=Ka,Ia.prototype.sqrTo=La,Pa.prototype.convert=Qa,Pa.prototype.revert=Ra,Pa.prototype.reduce=Sa,Pa.prototype.mulTo=Ua,Pa.prototype.sqrTo=Ta;var hb=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],ib=(1<<26)/hb[hb.length-1];_a.chunkSize=W,_a.toRadix=Y,_a.fromRadix=Z,_a.fromNumber=$,_a.bitwiseTo=da,_a.changeBit=ua,_a.addTo=ya,_a.dMultiply=Ga,_a.dAddOffset=Ha,_a.multiplyLowerTo=Na,_a.multiplyUpperTo=Oa,_a.modInt=Xa,_a.millerRabin=$a,_a.clone=S,_a.intValue=T,_a.byteValue=U,_a.shortValue=V,_a.signum=X,_a.toByteArray=_,_a.equals=aa,_a.min=ba,_a.max=ca,_a.and=fa,_a.or=ha,_a.xor=ja,_a.andNot=la,_a.not=ma,_a.shiftLeft=na,_a.shiftRight=oa,_a.getLowestSetBit=qa,_a.bitCount=sa,_a.testBit=ta,_a.setBit=va,_a.clearBit=wa,_a.flipBit=xa,_a.add=za,_a.subtract=Aa,_a.multiply=Ba,_a.divide=Da,_a.remainder=Ea,_a.divideAndRemainder=Fa,_a.modPow=Va,_a.modInverse=Ya,_a.pow=Ma,_a.gcd=Wa,_a.isProbablePrime=Za,_a.square=Ca,d.ZERO=j(0),d.ONE=j(1),d.valueOf=j,b.exports=d},{"../package.json":36}],34:[function(a,b,c){(function(b){var c=a("assert"),d=a("./bigi");d.fromByteArrayUnsigned=function(a){return new d(128&a[0]?[0].concat(a):a)},d.prototype.toByteArrayUnsigned=function(){var a=this.toByteArray();return 0===a[0]?a.slice(1):a},d.fromDERInteger=function(a){return new d(a)},d.prototype.toDERInteger=d.prototype.toByteArray,d.fromBuffer=function(a){if(128&a[0]){var b=Array.prototype.slice.call(a);return new d([0].concat(b))}return new d(a)},d.fromHex=function(a){return""===a?d.ZERO:(c.equal(a,a.match(/^[A-Fa-f0-9]+/),"Invalid hex string"),c.equal(a.length%2,0,"Incomplete hex"),new d(a,16))},d.prototype.toBuffer=function(a){for(var c=this.toByteArrayUnsigned(),d=[],e=a-c.length;d.lengthd;++d)b.push(a.and(c).toNumber()),a=a.shrn(5);return b.reverse()}function h(a){for(var b=new q(1),c=new q(34359738367),d=0;d"},d.prototype.toCashBuffer=function(){var a=new c([this.network[this.type]]),b=c.concat([a,this.hashBuffer]);return b},d.prototype.toCashAddress=function(){function a(a){switch(a){case"pubkeyhash":return 0;case"scripthash":return 8;default:throw new Error("Invalid type:"+a)}}function b(a){switch(8*a.length){case 160:return 0;case 192:return 1;case 224:return 2;case 256:return 3;case 320:return 4;case 384:return 5;case 448:return 6;case 512:return 7;default:throw new Error("Invalid hash size:"+a.length)}}var c=[0,0,0,0,0,0,0,0],d=this.network.prefixArray.concat([0]),e=a(this.type)+b(this.hashBuffer),f=Array.prototype.slice.call(this.hashBuffer,0),i=s([e].concat(f),8,5),j=d.concat(i).concat(c),k=i.concat(g(h(j)));return this.network.prefix+":"+r.encode(k)};var t=i.map([656907472481,522768456162,0xf33e5fb3c4,748107326120,130178868336],function(a){return new q(a)});b.exports=d;var u=a("./script")}).call(this,a("buffer").Buffer)},{"./crypto/bn":44,"./crypto/hash":46,"./encoding/base58check":51,"./errors":55,"./networks":59,"./publickey":62,"./script":63,"./util/base32":80,"./util/convertBits":82,"./util/js":83,"./util/preconditions":84,buffer:187,lodash:87}],40:[function(a,b,c){(function(c){"use strict";function d(a){return this instanceof d?(e.extend(this,d._from(a)),this):new d(a)}var e=a("lodash"),f=a("./blockheader"),g=a("../crypto/bn"),h=a("../util/buffer"),i=a("../encoding/bufferreader"),j=a("../encoding/bufferwriter"),k=a("../crypto/hash"),l=a("../transaction"),m=a("../util/preconditions");d.MAX_BLOCK_SIZE=1e6,d._from=function(a){var b={};if(h.isBuffer(a))b=d._fromBufferReader(i(a));else{if(!e.isObject(a))throw new TypeError("Unrecognized argument for Block");b=d._fromObject(a)}return b},d._fromObject=function(a){var b=[];a.transactions.forEach(function(a){a instanceof l?b.push(a):b.push(l().fromObject(a))});var c={header:f.fromObject(a.header),transactions:b};return c},d.fromObject=function(a){var b=d._fromObject(a);return new d(b)},d._fromBufferReader=function(a){var b={};m.checkState(!a.finished(),"No block data received"),b.header=f.fromBufferReader(a);var c=a.readVarintNum();b.transactions=[];for(var d=0;c>d;d++)b.transactions.push(l().fromBufferReader(a));return b},d.fromBufferReader=function(a){m.checkArgument(a,"br is required");var b=d._fromBufferReader(a);return new d(b)},d.fromBuffer=function(a){return d.fromBufferReader(new i(a))},d.fromString=function(a){var b=new c(a,"hex");return d.fromBuffer(b)},d.fromRawBlock=function(a){h.isBuffer(a)||(a=new c(a,"binary"));var b=i(a);b.pos=d.Values.START_OF_BLOCK;var e=d._fromBufferReader(b);return new d(e)},d.prototype.toObject=d.prototype.toJSON=function(){var a=[];return this.transactions.forEach(function(b){a.push(b.toObject())}),{header:this.header.toObject(),transactions:a}},d.prototype.toBuffer=function(){return this.toBufferWriter().concat()},d.prototype.toString=function(){return this.toBuffer().toString("hex")},d.prototype.toBufferWriter=function(a){a||(a=new j),a.write(this.header.toBuffer()),a.writeVarintNum(this.transactions.length);for(var b=0;b1;d=Math.floor((d+1)/2)){for(var e=0;d>e;e+=2){var f=Math.min(e+1,d-1),g=c.concat([a[b+e],a[b+f]]);a.push(k.sha256sha256(g))}b+=d}return a},d.prototype.getMerkleRoot=function(){var a=this.getMerkleTree();return a[a.length-1]},d.prototype.validMerkleRoot=function(){var a=new g(this.header.merkleRoot.toString("hex"),"hex"),b=new g(this.getMerkleRoot().toString("hex"),"hex");return 0!==a.cmp(b)?!1:!0},d.prototype._getHash=function(){return this.header._getHash()};var n={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=this.header.id),this._id},set:e.noop};Object.defineProperty(d.prototype,"id",n),Object.defineProperty(d.prototype,"hash",n),d.prototype.inspect=function(){return""},d.Values={START_OF_BLOCK:8,NULL_HASH:new c("0000000000000000000000000000000000000000000000000000000000000000","hex")},b.exports=d}).call(this,a("buffer").Buffer)},{"../crypto/bn":44,"../crypto/hash":46,"../encoding/bufferreader":52,"../encoding/bufferwriter":53,"../transaction":66,"../util/buffer":81,"../util/preconditions":84,"./blockheader":41,buffer:187,lodash:87}],41:[function(a,b,c){(function(c){"use strict";var d=a("lodash"),e=a("../crypto/bn"),f=a("../util/buffer"),g=a("../encoding/bufferreader"),h=a("../encoding/bufferwriter"),i=a("../crypto/hash"),j=(a("../util/js"),a("../util/preconditions")),k=486604799,l=function n(a){if(!(this instanceof n))return new n(a);var b=n._from(a);return this.version=b.version,this.prevHash=b.prevHash,this.merkleRoot=b.merkleRoot,this.time=b.time,this.timestamp=b.time,this.bits=b.bits,this.nonce=b.nonce,b.hash&&j.checkState(this.hash===b.hash,"Argument object hash property does not match block hash."),this};l._from=function(a){var b={};if(f.isBuffer(a))b=l._fromBufferReader(g(a));else{if(!d.isObject(a))throw new TypeError("Unrecognized argument for BlockHeader");b=l._fromObject(a)}return b},l._fromObject=function(a){j.checkArgument(a,"data is required");var b=a.prevHash,e=a.merkleRoot;d.isString(a.prevHash)&&(b=f.reverse(new c(a.prevHash,"hex"))),d.isString(a.merkleRoot)&&(e=f.reverse(new c(a.merkleRoot,"hex")));var g={hash:a.hash,version:a.version,prevHash:b,merkleRoot:e,time:a.time,timestamp:a.time,bits:a.bits,nonce:a.nonce};return g},l.fromObject=function(a){var b=l._fromObject(a);return new l(b)},l.fromRawBlock=function(a){f.isBuffer(a)||(a=new c(a,"binary"));var b=g(a);b.pos=l.Constants.START_OF_HEADER;var d=l._fromBufferReader(b);return new l(d)},l.fromBuffer=function(a){var b=l._fromBufferReader(g(a));return new l(b)},l.fromString=function(a){var b=new c(a,"hex");return l.fromBuffer(b)},l._fromBufferReader=function(a){var b={};return b.version=a.readInt32LE(),b.prevHash=a.read(32),b.merkleRoot=a.read(32),b.time=a.readUInt32LE(),b.bits=a.readUInt32LE(),b.nonce=a.readUInt32LE(),b},l.fromBufferReader=function(a){var b=l._fromBufferReader(a);return new l(b)},l.prototype.toObject=l.prototype.toJSON=function(){return{hash:this.hash,version:this.version,prevHash:f.reverse(this.prevHash).toString("hex"),merkleRoot:f.reverse(this.merkleRoot).toString("hex"),time:this.time,bits:this.bits,nonce:this.nonce}},l.prototype.toBuffer=function(){return this.toBufferWriter().concat()},l.prototype.toString=function(){return this.toBuffer().toString("hex")},l.prototype.toBufferWriter=function(a){return a||(a=new h),a.writeInt32LE(this.version),a.write(this.prevHash),a.write(this.merkleRoot),a.writeUInt32LE(this.time),a.writeUInt32LE(this.bits),a.writeUInt32LE(this.nonce),a},l.prototype.getTargetDifficulty=function(a){a=a||this.bits;for(var b=new e(16777215&a),c=8*((a>>>24)-3);c-->0;)b=b.mul(new e(2));return b},l.prototype.getDifficulty=function(){var a=this.getTargetDifficulty(k).mul(new e(Math.pow(10,8))),b=this.getTargetDifficulty(),c=a.div(b).toString(10),d=c.length-8;return c=c.slice(0,d)+"."+c.slice(d),parseFloat(c)},l.prototype._getHash=function(){var a=this.toBuffer();return i.sha256sha256(a)};var m={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=g(this._getHash()).readReverse().toString("hex")),this._id},set:d.noop};Object.defineProperty(l.prototype,"id",m),Object.defineProperty(l.prototype,"hash",m),l.prototype.validTimestamp=function(){var a=Math.round((new Date).getTime()/1e3);return this.time>a+l.Constants.MAX_TIME_OFFSET?!1:!0},l.prototype.validProofOfWork=function(){var a=new e(this.id,"hex"),b=this.getTargetDifficulty();return a.cmp(b)>0?!1:!0},l.prototype.inspect=function(){return""},l.Constants={START_OF_HEADER:8,MAX_TIME_OFFSET:7200,LARGEST_HASH:new e("10000000000000000000000000000000000000000000000000000000000000000","hex")},b.exports=l}).call(this,a("buffer").Buffer)},{"../crypto/bn":44,"../crypto/hash":46,"../encoding/bufferreader":52,"../encoding/bufferwriter":53,"../util/buffer":81,"../util/js":83,"../util/preconditions":84,buffer:187,lodash:87}],42:[function(a,b,c){b.exports=a("./block"),b.exports.BlockHeader=a("./blockheader"),b.exports.MerkleBlock=a("./merkleblock")},{"./block":40,"./blockheader":41,"./merkleblock":43}],43:[function(a,b,c){(function(c){"use strict";function d(a){if(!(this instanceof d))return new d(a);var b={};if(g.isBuffer(a))b=d._fromBufferReader(h(a));else{if(!e.isObject(a))throw new TypeError("Unrecognized argument for MerkleBlock");var c;c=a.header instanceof f?a.header:f.fromObject(a.header),b={header:c,numTransactions:a.numTransactions,hashes:a.hashes,flags:a.flags}}return e.extend(this,b),this._flagBitsUsed=0,this._hashesUsed=0,this}var e=a("lodash"),f=a("./blockheader"),g=a("../util/buffer"),h=a("../encoding/bufferreader"),i=a("../encoding/bufferwriter"),j=a("../crypto/hash"),k=(a("../util/js"),a("../transaction")),l=a("../errors"),m=a("../util/preconditions");d.fromBuffer=function(a){return d.fromBufferReader(h(a))},d.fromBufferReader=function(a){return new d(d._fromBufferReader(a))},d.prototype.toBuffer=function(){return this.toBufferWriter().concat()},d.prototype.toBufferWriter=function(a){a||(a=new i),a.write(this.header.toBuffer()),a.writeUInt32LE(this.numTransactions),a.writeVarintNum(this.hashes.length);for(var b=0;bthis.numTransactions)return!1;if(8*this.flags.length",'"',"`"," ","\r","\n"," "],o=["{","}","|","\\","^","`"].concat(n),p=["'"].concat(o),q=["%","/","?",";","#"].concat(p),r=["/","?","#"],s=255,t=/^[+a-z0-9A-Z_-]{0,63}$/,u=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,v={javascript:!0,"javascript:":!0},w={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=a("querystring");d.prototype.parse=function(a,b,c){if(!j.isString(a))throw new TypeError("Parameter 'url' must be a string, not "+typeof a);var d=a.indexOf("?"),e=-1!==d&&dC)&&(A=C)}var D,E;E=-1===A?h.lastIndexOf("@"):h.lastIndexOf("@",A),-1!==E&&(D=h.slice(0,E),h=h.slice(E+1),this.auth=decodeURIComponent(D)),A=-1;for(var B=0;BC)&&(A=C)}-1===A&&(A=h.length),this.host=h.slice(0,A),h=h.slice(A),this.parseHost(),this.hostname=this.hostname||"";var F="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!F)for(var G=this.hostname.split(/\./),B=0,H=G.length;H>B;B++){var I=G[B];if(I&&!I.match(t)){for(var J="",K=0,L=I.length;L>K;K++)J+=I.charCodeAt(K)>127?"x":I[K];if(!J.match(t)){var M=G.slice(0,B),N=G.slice(B+1),O=I.match(u);O&&(M.push(O[1]),N.unshift(O[2])),N.length&&(h="/"+N.join(".")+h),this.hostname=M.join(".");break}}}this.hostname.length>s?this.hostname="":this.hostname=this.hostname.toLowerCase(),F||(this.hostname=i.toASCII(this.hostname));var P=this.port?":"+this.port:"",Q=this.hostname||"";this.host=Q+P,this.href+=this.host,F&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==h[0]&&(h="/"+h))}if(!v[o])for(var B=0,H=p.length;H>B;B++){var R=p[B];if(-1!==h.indexOf(R)){var S=encodeURIComponent(R);S===R&&(S=escape(R)),h=h.split(R).join(S)}}var T=h.indexOf("#");-1!==T&&(this.hash=h.substr(T),h=h.slice(0,T));var U=h.indexOf("?");if(-1!==U?(this.search=h.substr(U),this.query=h.substr(U+1),b&&(this.query=y.parse(this.query)),h=h.slice(0,U)):b&&(this.search="",this.query={}),h&&(this.pathname=h),x[o]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var P=this.pathname||"",V=this.search||"";this.path=P+V}return this.href=this.format(),this},d.prototype.format=function(){var a=this.auth||"";a&&(a=encodeURIComponent(a),a=a.replace(/%3A/i,":"),a+="@");var b=this.protocol||"",c=this.pathname||"",d=this.hash||"",e=!1,f="";this.host?e=a+this.host:this.hostname&&(e=a+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(e+=":"+this.port)),this.query&&j.isObject(this.query)&&Object.keys(this.query).length&&(f=y.stringify(this.query));var g=this.search||f&&"?"+f||"";return b&&":"!==b.substr(-1)&&(b+=":"),this.slashes||(!b||x[b])&&e!==!1?(e="//"+(e||""),c&&"/"!==c.charAt(0)&&(c="/"+c)):e||(e=""),d&&"#"!==d.charAt(0)&&(d="#"+d),g&&"?"!==g.charAt(0)&&(g="?"+g),c=c.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),g=g.replace("#","%23"),b+e+c+g+d},d.prototype.resolve=function(a){return this.resolveObject(e(a,!1,!0)).format()},d.prototype.resolveObject=function(a){if(j.isString(a)){var b=new d;b.parse(a,!1,!0),a=b}for(var c=new d,e=Object.keys(this),f=0;f0?c.host.split("@"):!1;z&&(c.auth=z.shift(),c.host=c.hostname=z.shift())}return c.search=a.search,c.query=a.query,j.isNull(c.pathname)&&j.isNull(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.href=c.format(),c}if(!v.length)return c.pathname=null,c.search?c.path="/"+c.search:c.path=null,c.href=c.format(),c;for(var A=v.slice(-1)[0],B=(c.host||a.host||v.length>1)&&("."===A||".."===A)||""===A,C=0,D=v.length;D>=0;D--)A=v[D],"."===A?v.splice(D,1):".."===A?(v.splice(D,1),C++):C&&(v.splice(D,1),C--);if(!t&&!u)for(;C--;C)v.unshift("..");!t||""===v[0]||v[0]&&"/"===v[0].charAt(0)||v.unshift(""),B&&"/"!==v.join("/").substr(-1)&&v.push("");var E=""===v[0]||v[0]&&"/"===v[0].charAt(0);if(y){c.hostname=c.host=E?"":v.length?v.shift():"";var z=c.host&&c.host.indexOf("@")>0?c.host.split("@"):!1;z&&(c.auth=z.shift(),c.host=c.hostname=z.shift())}return t=t||c.host&&v.length,t&&!E&&v.unshift(""),v.length?c.pathname=v.join("/"):(c.pathname=null,c.path=null),j.isNull(c.pathname)&&j.isNull(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.auth=a.auth||c.auth,c.slashes=c.slashes||a.slashes,c.href=c.format(),c},d.prototype.parseHost=function(){var a=this.host,b=l.exec(a);b&&(b=b[0],":"!==b&&(this.port=b.substr(1)),a=a.substr(0,a.length-b.length)),a&&(this.hostname=a)}},{"./util":336,punycode:290,querystring:293}],336:[function(a,b,c){"use strict";b.exports={isString:function(a){return"string"==typeof a},isObject:function(a){return"object"==typeof a&&null!==a},isNull:function(a){return null===a},isNullOrUndefined:function(a){return null==a}}},{}],337:[function(a,b,c){(function(a){function c(a,b){function c(){if(!e){if(d("throwDeprecation"))throw new Error(b);d("traceDeprecation")?console.trace(b):console.warn(b),e=!0}return a.apply(this,arguments)}if(d("noDeprecation"))return a;var e=!1;return c}function d(b){try{if(!a.localStorage)return!1}catch(c){return!1}var d=a.localStorage[b];return null==d?!1:"true"===String(d).toLowerCase()}b.exports=c}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],338:[function(a,b,c){arguments[4][86][0].apply(c,arguments)},{dup:86}],339:[function(a,b,c){b.exports=function(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.readUInt8}},{}],340:[function(a,b,c){(function(b,d){function e(a,b){var d={seen:[],stylize:g};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),p(b)?d.showHidden=b:b&&c._extend(d,b),v(d.showHidden)&&(d.showHidden=!1),v(d.depth)&&(d.depth=2),v(d.colors)&&(d.colors=!1),v(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=f),i(d,a,d.depth)}function f(a,b){var c=e.styles[b];return c?"["+e.colors[c][0]+"m"+a+"["+e.colors[c][1]+"m":a}function g(a,b){return a}function h(a){var b={};return a.forEach(function(a,c){b[a]=!0}),b}function i(a,b,d){if(a.customInspect&&b&&A(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d,a);return t(e)||(e=i(a,e,d)),e}var f=j(a,b);if(f)return f;var g=Object.keys(b),p=h(g);if(a.showHidden&&(g=Object.getOwnPropertyNames(b)),z(b)&&(g.indexOf("message")>=0||g.indexOf("description")>=0))return k(b);if(0===g.length){if(A(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(w(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(y(b))return a.stylize(Date.prototype.toString.call(b),"date");if(z(b))return k(b)}var r="",s=!1,u=["{","}"];if(o(b)&&(s=!0,u=["[","]"]),A(b)){var v=b.name?": "+b.name:"";r=" [Function"+v+"]"}if(w(b)&&(r=" "+RegExp.prototype.toString.call(b)),y(b)&&(r=" "+Date.prototype.toUTCString.call(b)),z(b)&&(r=" "+k(b)),0===g.length&&(!s||0==b.length))return u[0]+r+u[1];if(0>d)return w(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var x;return x=s?l(a,b,d,p,g):g.map(function(c){return m(a,b,d,p,c,s)}),a.seen.pop(),n(x,r,u)}function j(a,b){if(v(b))return a.stylize("undefined","undefined");if(t(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return s(b)?a.stylize(""+b,"number"):p(b)?a.stylize(""+b,"boolean"):q(b)?a.stylize("null","null"):void 0}function k(a){return"["+Error.prototype.toString.call(a)+"]"}function l(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)F(b,String(g))?f.push(m(a,b,c,d,String(g),!0)):f.push("");return e.forEach(function(e){e.match(/^\d+$/)||f.push(m(a,b,c,d,e,!0))}),f}function m(a,b,c,d,e,f){var g,h,j;if(j=Object.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?h=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(h=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),h||(a.seen.indexOf(j.value)<0?(h=q(c)?i(a,j.value,null):i(a,j.value,c-1),h.indexOf("\n")>-1&&(h=f?h.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+h.split("\n").map(function(a){return" "+a}).join("\n"))):h=a.stylize("[Circular]","special")),v(g)){if(f&&e.match(/^\d+$/))return h;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+h}function n(a,b,c){var d=0,e=a.reduce(function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function o(a){return Array.isArray(a)}function p(a){return"boolean"==typeof a}function q(a){return null===a}function r(a){return null==a}function s(a){return"number"==typeof a}function t(a){return"string"==typeof a}function u(a){return"symbol"==typeof a}function v(a){return void 0===a}function w(a){return x(a)&&"[object RegExp]"===C(a)}function x(a){return"object"==typeof a&&null!==a}function y(a){return x(a)&&"[object Date]"===C(a)}function z(a){return x(a)&&("[object Error]"===C(a)||a instanceof Error)}function A(a){return"function"==typeof a}function B(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),J[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=/%[sdj%]/g;c.format=function(a){if(!t(a)){for(var b=[],c=0;c=f)return a;switch(a){case"%s":return String(d[c++]);case"%d":return Number(d[c++]);case"%j":try{return JSON.stringify(d[c++])}catch(b){return"[Circular]"}default:return a}}),h=d[c];f>c;h=d[++c])g+=q(h)||!x(h)?" "+h:" "+e(h);return g},c.deprecate=function(a,e){function f(){if(!g){if(b.throwDeprecation)throw new Error(e);b.traceDeprecation?console.trace(e):console.error(e),g=!0}return a.apply(this,arguments)}if(v(d.process))return function(){return c.deprecate(a,e).apply(this,arguments)};if(b.noDeprecation===!0)return a;var g=!1;return f};var H,I={};c.debuglog=function(a){if(v(H)&&(H=b.env.NODE_DEBUG||""),a=a.toUpperCase(),!I[a])if(new RegExp("\\b"+a+"\\b","i").test(H)){var d=b.pid;I[a]=function(){var b=c.format.apply(c,arguments);console.error("%s %d: %s",a,d,b)}}else I[a]=function(){};return I[a]},c.inspect=e,e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=o,c.isBoolean=p,c.isNull=q,c.isNullOrUndefined=r,c.isNumber=s,c.isString=t,c.isSymbol=u,c.isUndefined=v,c.isRegExp=w,c.isObject=x,c.isDate=y,c.isError=z,c.isFunction=A,c.isPrimitive=B,c.isBuffer=a("./support/isBuffer");var J=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=a("inherits"),c._extend=function(a,b){if(!b||!x(b))return a;for(var c=Object.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}}).call(this,a("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":339,_process:282,inherits:338}],341:[function(require,module,exports){function Context(){}var indexOf=require("indexof"),Object_keys=function(a){if(Object.keys)return Object.keys(a);var b=[];for(var c in a)b.push(c);return b},forEach=function(a,b){if(a.forEach)return a.forEach(b);for(var c=0;c= 8.0.0",main:"index.js",repository:{url:"git@github.com:bitpay/bitcore-wallet-client.git",type:"git"},bugs:{url:"https://github.com/bitpay/bitcore-wallet-client/issues"},dependencies:{async:"^0.9.0",bip38:"^1.3.0","bitcore-lib":"^0.15.0","bitcore-lib-cash":"^0.16.1","bitcore-mnemonic":"^1.3.0","bitcore-payment-protocol":"^1.7.0","json-stable-stringify":"^1.0.0",lodash:"^4.17.4",preconditions:"^1.0.8",sjcl:"1.0.3",superagent:"^3.4.1"},devDependencies:{"bitcore-wallet-service":"2.3.0",browserify:"^13.1.0",chai:"^1.9.1",coveralls:"^2.11.2",istanbul:"*",mocha:"^1.18.2",sinon:"^1.10.3",supertest:"^3.0.0",tingodb:"^0.3.4",uglify:"^0.1.1",uuid:"^2.0.1","grunt-jsdox":"matiu/grunt-jsdox#update/jsdoc-4.10"},scripts:{start:"node app.js",coverage:"./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter spec test",test:"./node_modules/.bin/mocha",coveralls:"./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",docs:"./node_modules/.bin/jsdox lib/* lib/common lib/errors -o docs && cat README.header.md docs/*.md LICENSE > README.md"}}},{}]},{},[1]); \ No newline at end of file +};Script.prototype.runInContext=function(a){if(!(a instanceof Context))throw new TypeError("needs a 'context' argument.");var b=document.createElement("iframe");b.style||(b.style={}),b.style.display="none",document.body.appendChild(b);var c=b.contentWindow,d=c.eval,e=c.execScript;!d&&e&&(e.call(c,"null"),d=c.eval),forEach(Object_keys(a),function(b){c[b]=a[b]}),forEach(globals,function(b){a[b]&&(c[b]=a[b])});var f=Object_keys(c),g=d.call(c,this.code);return forEach(Object_keys(c),function(b){(b in a||-1===indexOf(f,b))&&(a[b]=c[b])}),forEach(globals,function(b){b in a||defineProp(a,b,c[b])}),document.body.removeChild(b),g},Script.prototype.runInThisContext=function(){return eval(this.code)},Script.prototype.runInNewContext=function(a){var b=Script.createContext(a),c=this.runInContext(b);return forEach(Object_keys(b),function(c){a[c]=b[c]}),c},forEach(Object_keys(Script.prototype),function(a){exports[a]=Script[a]=function(b){var c=Script(b);return c[a].apply(c,[].slice.call(arguments,1))}}),exports.createScript=function(a){return exports.Script(a)},exports.createContext=Script.createContext=function(a){var b=new Context;return"object"==typeof a&&forEach(Object_keys(a),function(c){b[c]=a[c]}),b}},{indexof:250}],342:[function(a,b,c){function d(){for(var a={},b=0;b= 8.0.0",main:"index.js",repository:{url:"git@github.com:bitpay/bitcore-wallet-client.git",type:"git"},bugs:{url:"https://github.com/bitpay/bitcore-wallet-client/issues"},dependencies:{async:"^0.9.0",bip38:"^1.3.0","bitcore-lib":"^0.15.0","bitcore-lib-cash":"^0.16.1","bitcore-mnemonic":"^1.3.0","bitcore-payment-protocol":"^1.7.0","json-stable-stringify":"^1.0.0",lodash:"^4.17.4",preconditions:"^1.0.8",sjcl:"1.0.3",superagent:"^3.4.1"},devDependencies:{"bitcore-wallet-service":"2.3.0",browserify:"^13.1.0",chai:"^1.9.1",coveralls:"^2.11.2",istanbul:"*",mocha:"^1.18.2",sinon:"^1.10.3",supertest:"^3.0.0",tingodb:"^0.3.4",uglify:"^0.1.1",uuid:"^2.0.1","grunt-jsdox":"matiu/grunt-jsdox#update/jsdoc-4.10"},scripts:{start:"node app.js",coverage:"./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter spec test",test:"./node_modules/.bin/mocha",coveralls:"./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",docs:"./node_modules/.bin/jsdox lib/* lib/common lib/errors -o docs && cat README.header.md docs/*.md LICENSE > README.md"}}},{}]},{},[1]); \ No newline at end of file diff --git a/package.json b/package.json index f6a10c61..0d733371 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "bitcore-wallet-client", "description": "Client for bitcore-wallet-service", "author": "BitPay Inc", - "version": "6.7.3", + "version": "6.7.4", "license": "MIT", "keywords": [ "bitcoin",