/*! For license information please see index.min.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Libp2p=t():e.Libp2p=t()}(self,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=127)}([function(e,t,r){"use strict";e.exports={options:{usePureJavaScript:!1}}},function(e,t,r){"use strict";function n(e,t){for(const r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}e.exports=function(e,t,r){if(!e||"string"==typeof e)throw new TypeError("Please pass an Error to err-code");r||(r={}),"object"==typeof t&&(r=t,t=void 0),null!=t&&(r.code=t);try{return n(e,r)}catch(i){r.message=e.message,r.stack=e.stack;const t=function(){};return t.prototype=Object.create(Object.getPrototypeOf(e)),n(new t,r)}}},function(e,t,r){"use strict";(function(n){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))}),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(r){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(r){}!e&&void 0!==n&&"env"in n&&(e={NODE_ENV:"production"}.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(129)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}).call(this,r(34))},function(e,t,r){"use strict";(function(t,n,i){var s=r(0),o=r(174),a=e.exports=s.util=s.util||{};function c(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function u(e){if(this.data="",this.read=0,"string"==typeof e)this.data=e;else if(a.isArrayBuffer(e)||a.isArrayBufferView(e))if(void 0!==i&&e instanceof i)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch(n){for(var r=0;r15?(n=Date.now(),o(e)):(r.push(e),1===r.length&&s.setAttribute("a",i=!i))}}a.nextTick=a.setImmediate}(),a.isNodejs=void 0!==t&&t.versions&&t.versions.node,a.globalScope=a.isNodejs?n:"undefined"==typeof self?window:self,a.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},a.isArrayBuffer=function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer},a.isArrayBufferView=function(e){return e&&a.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},a.ByteBuffer=u,a.ByteStringBuffer=u;a.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},a.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},a.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},a.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},a.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},a.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},a.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(a.encodeUtf8(e))},a.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},a.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},a.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},a.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},a.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},a.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},a.ByteStringBuffer.prototype.putInt=function(e,t){c(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},a.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<0);return t},a.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},a.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},a.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},a.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},a.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},a.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},a.ByteStringBuffer.prototype.copy=function(){var e=a.createBuffer(this.data);return e.read=this.read,e},a.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},a.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},a.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},a.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},a.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},a.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},a.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},a.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},a.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},a.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},a.DataBuffer.prototype.putInt=function(e,t){c(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},a.DataBuffer.prototype.putSignedInt=function(e,t){return c(t),this.accommodate(t/8),e<0&&(e+=2<0);return t},a.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},a.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},a.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},a.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},a.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},a.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},a.DataBuffer.prototype.copy=function(){return new a.DataBuffer(this)},a.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},a.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},a.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},a.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},a.xorBytes=function(e,t,r){for(var n="",i="",s="",o=0,a=0;r>0;--r,++o)i=e.charCodeAt(o)^t.charCodeAt(o),a>=10&&(n+=s,s="",a=0),s+=String.fromCharCode(i),++a;return n+=s},a.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],d="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";a.encode64=function(e,t){for(var r,n,i,s="",o="",a=0;a>2),s+=f.charAt((3&r)<<4|n>>4),isNaN(n)?s+="==":(s+=f.charAt((15&n)<<2|i>>6),s+=isNaN(i)?"=":f.charAt(63&i)),t&&s.length>t&&(o+=s.substr(0,t)+"\r\n",s=s.substr(t));return o+=s},a.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,s="",o=0;o>4),64!==n&&(s+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(s+=String.fromCharCode((3&n)<<6|i)));return s},a.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},a.decodeUtf8=function(e){return decodeURIComponent(escape(e))},a.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:o.encode,decode:o.decode}},a.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},a.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,s=0;s>2),s+=f.charAt((3&r)<<4|n>>4),isNaN(n)?s+="==":(s+=f.charAt((15&n)<<2|i>>6),s+=isNaN(i)?"=":f.charAt(63&i)),t&&s.length>t&&(o+=s.substr(0,t)+"\r\n",s=s.substr(t));return o+=s},a.binary.base64.decode=function(e,t,r){var n,i,s,o,a=t;a||(a=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var c=0,u=r=r||0;c>4,64!==s&&(a[u++]=(15&i)<<4|s>>2,64!==o&&(a[u++]=(3&s)<<6|o));return t?u-r:a.subarray(0,u)},a.binary.base58.encode=function(e,t){return a.binary.baseN.encode(e,d,t)},a.binary.base58.decode=function(e,t){return a.binary.baseN.decode(e,d,t)},a.text={utf8:{},utf16:{}},a.text.utf8.encode=function(e,t,r){e=a.encodeUtf8(e);var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,s=0;s0?(i=r[n].substring(0,o),s=r[n].substring(o+1)):(i=r[n],s=null),i in t||(t[i]=[]),i in Object.prototype||null===s||t[i].push(unescape(s))}return t};return void 0===e?(null===w&&(w="undefined"!=typeof window&&window.location&&window.location.search?r(window.location.search.substring(1)):{}),t=w):t=r(e),t},a.parseFragment=function(e){var t=e,r="",n=e.indexOf("?");n>0&&(t=e.substring(0,n),r=e.substring(n+1));var i=t.split("/");return i.length>0&&""===i[0]&&i.shift(),{pathString:t,queryString:r,path:i,query:""===r?{}:a.getQueryVariables(r)}},a.makeRequest=function(e){var t=a.parseFragment(e),r={path:t.pathString,query:t.queryString,getPath:function(e){return void 0===e?t.path:t.path[e]},getQuery:function(e,r){var n;return void 0===e?n=t.query:(n=t.query[e])&&void 0!==r&&(n=n[r]),n},getQueryLast:function(e,t){var n=r.getQuery(e);return n?n[n.length-1]:t}};return r},a.makeLink=function(e,t,r){e=jQuery.isArray(e)?e.join("/"):e;var n=jQuery.param(t||{});return r=r||"",e+(n.length>0?"?"+n:"")+(r.length>0?"#"+r:"")},a.setPath=function(e,t,r){if("object"==typeof e&&null!==e)for(var n=0,i=t.length;n0&&s.push(r),o=n.lastIndex;var a=t[0][1];switch(a){case"s":case"o":i");break;case"%":s.push("%");break;default:s.push("<%"+a+"?>")}}return s.push(e.substring(o)),s.join("")},a.formatNumber=function(e,t,r,n){var i=e,s=isNaN(t=Math.abs(t))?2:t,o=void 0===r?",":r,a=void 0===n?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(s),10)+"",f=u.length>3?u.length%3:0;return c+(f?u.substr(0,f)+a:"")+u.substr(f).replace(/(\d{3})(?=\d)/g,"$1"+a)+(s?o+Math.abs(i-u).toFixed(s).slice(2):"")},a.formatSize=function(e){return e=e>=1073741824?a.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?a.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?a.formatNumber(e/1024,0)+" KiB":a.formatNumber(e,0)+" bytes"},a.bytesFromIP=function(e){return-1!==e.indexOf(".")?a.bytesFromIPv4(e):-1!==e.indexOf(":")?a.bytesFromIPv6(e):null},a.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=a.createBuffer(),r=0;rr[n].end-r[n].start&&(n=r.length-1)):r.push({start:c,end:c})}t.push(s)}if(r.length>0){var u=r[n];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),0===u.start&&t.unshift(""),7===u.end&&t.push(""))}return t.join(":")},a.estimateCores=function(e,t){if("function"==typeof e&&(t=e,e={}),e=e||{},"cores"in a&&!e.update)return t(null,a.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return a.cores=navigator.hardwareConcurrency,t(null,a.cores);if("undefined"==typeof Worker)return a.cores=1,t(null,a.cores);if("undefined"==typeof Blob)return a.cores=2,t(null,a.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){for(var t=Date.now(),r=t+4;Date.now()a.st&&i.sti.st&&a.st"}toJSON(){return{id:this.toB58String(),privKey:p(this.marshalPrivKey()),pubKey:p(this.marshalPubKey())}}toHexString(){return n.toHexString(this.id)}toBytes(){return this.id}toB58String(){return this._idB58String}toString(){if(!this._idCIDString){const e=new i(1,"libp2p-key",this.id,"base32");this._idCIDString=e.toBaseEncodedString("base32")}return this._idCIDString}equals(e){if(e instanceof Uint8Array)return c(this.id,e);if(e.id)return c(this.id,e.id);throw new Error("not valid Id")}isEqual(e){return this.equals(e)}isValid(){return Boolean(this.privKey&&this.privKey.public&&this.privKey.public.bytes&&this.pubKey.bytes instanceof Uint8Array&&c(this.privKey.public.bytes,this.pubKey.bytes))}hasInlinePublicKey(){try{if("identity"===n.decode(this.id).name)return!0}catch(e){}return!1}},{className:"PeerId",symbolName:"@libp2p/js-peer-id/PeerId"});t=e.exports=h;const d=e=>e.bytes.length<=42?n.encode(e.bytes,"identity"):e.hash(),l=async(e,t)=>{const r=await d(t);return new h(r,e,t)};t.create=async e=>{(e=e||{}).bits=e.bits||2048,e.keyType=e.keyType||"RSA";const t=await s.generateKeyPair(e.keyType,e.bits);return l(t,t.public)},t.createFromHexString=e=>new h(n.fromHexString(e)),t.createFromBytes=e=>new h(e),t.createFromB58String=e=>t.createFromCID(e);function p(e){if(e)return f(e,"base64pad")}t.createFromCID=e=>{if(!(e=>"libp2p-key"===e.codec||"dag-pb"===e.codec)(e=i.isCID(e)?e:new i(e)))throw new Error("Supplied PeerID CID has invalid multicodec: "+e.codec);return new h(e.multihash)},t.createFromPubKey=async e=>{let t=e;if("string"==typeof t&&(t=u(e,"base64pad")),!(t instanceof Uint8Array))throw new Error("Supplied key is neither a base64 string nor a Uint8Array");const r=await s.unmarshalPublicKey(t);return l(null,r)},t.createFromPrivKey=async e=>{if("string"==typeof e&&(e=u(e,"base64pad")),!(e instanceof Uint8Array))throw new Error("Supplied key is neither a base64 string nor a Uint8Array");const t=await s.unmarshalPrivateKey(e);return l(t,t.public)},t.createFromJSON=async e=>{const t=n.fromB58String(e.id),r=e.privKey&&u(e.privKey,"base64pad"),i=e.pubKey&&u(e.pubKey,"base64pad"),o=i&&await s.unmarshalPublicKey(i);if(!r)return new h(t,null,o);const a=await s.unmarshalPrivateKey(r),f=await d(a.public);let l;if(o&&(l=await d(o)),o&&!c(f,l))throw new Error("Public and private key do not match");if(t&&!c(f,t))throw new Error("Id and private key do not match");return new h(t,a,o)},t.createFromProtobuf=async e=>{"string"==typeof e&&(e=u(e,"base16"));let t,r,{id:n,privKey:i,pubKey:o}=a.decode(e);if(i=!!i&&await s.unmarshalPrivateKey(i),o=!!o&&await s.unmarshalPublicKey(o),i&&(r=await d(i.public)),o&&(t=await d(o)),i){if(o&&!c(r,t))throw new Error("Public and private key do not match");return new h(r,i,i.public)}if(o)return new h(t,null,o);if(n)return new h(n);throw new Error("Protobuf did not contain any usable key material")},t.isPeerId=e=>Boolean("object"==typeof e&&e._id&&e._idB58String)},function(e,t,r){"use strict";t.messages={NOT_STARTED_YET:"The libp2p node is not started yet",DHT_DISABLED:"DHT is not available",CONN_ENCRYPTION_REQUIRED:"At least one connection encryption module is required"},t.codes={DHT_DISABLED:"ERR_DHT_DISABLED",PUBSUB_NOT_STARTED:"ERR_PUBSUB_NOT_STARTED",DHT_NOT_STARTED:"ERR_DHT_NOT_STARTED",CONN_ENCRYPTION_REQUIRED:"ERR_CONN_ENCRYPTION_REQUIRED",ERR_CONNECTION_ENDED:"ERR_CONNECTION_ENDED",ERR_CONNECTION_FAILED:"ERR_CONNECTION_FAILED",ERR_NODE_NOT_STARTED:"ERR_NODE_NOT_STARTED",ERR_ALREADY_ABORTED:"ERR_ALREADY_ABORTED",ERR_NO_VALID_ADDRESSES:"ERR_NO_VALID_ADDRESSES",ERR_DIALED_SELF:"ERR_DIALED_SELF",ERR_DISCOVERED_SELF:"ERR_DISCOVERED_SELF",ERR_DUPLICATE_TRANSPORT:"ERR_DUPLICATE_TRANSPORT",ERR_ENCRYPTION_FAILED:"ERR_ENCRYPTION_FAILED",ERR_HOP_REQUEST_FAILED:"ERR_HOP_REQUEST_FAILED",ERR_INVALID_KEY:"ERR_INVALID_KEY",ERR_INVALID_MESSAGE:"ERR_INVALID_MESSAGE",ERR_INVALID_PARAMETERS:"ERR_INVALID_PARAMETERS",ERR_INVALID_PEER:"ERR_INVALID_PEER",ERR_MUXER_UNAVAILABLE:"ERR_MUXER_UNAVAILABLE",ERR_TIMEOUT:"ERR_TIMEOUT",ERR_TRANSPORT_UNAVAILABLE:"ERR_TRANSPORT_UNAVAILABLE",ERR_TRANSPORT_DIAL_FAILED:"ERR_TRANSPORT_DIAL_FAILED",ERR_UNSUPPORTED_PROTOCOL:"ERR_UNSUPPORTED_PROTOCOL",ERR_INVALID_MULTIADDR:"ERR_INVALID_MULTIADDR",ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID"}},function(e,t,r){"use strict";e.exports={encode:r(153),decode:r(154),encodingLength:r(155)}},function(e,t,r){"use strict";const n=r(231),i=r(44),s=r(8),o=r(36),a=r(37),c=r(1),u=Symbol.for("nodejs.util.inspect.custom"),f=r(4),h=r(13),d=new Map,l=a.proto((function(e){if(!(this instanceof l))return new l(e);if(null==e&&(e=""),e instanceof Uint8Array)this.bytes=n.fromBytes(e);else if("string"==typeof e||e instanceof String){if(e.length>0&&"/"!==e.charAt(0))throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=n.fromString(e)}else{if(!(e.bytes&&e.protos&&e.protoCodes))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=n.fromBytes(e.bytes)}}),{className:"Multiaddr",symbolName:"@multiformats/js-multiaddr/multiaddr"});l.prototype.toString=function(){return n.bytesToString(this.bytes)},l.prototype.toJSON=l.prototype.toString,l.prototype.toOptions=function(){const e={},t=this.toString().split("/");return e.family="ip4"===t[1]?"ipv4":"ipv6",e.host=t[2],e.transport=t[3],e.port=parseInt(t[4]),e},l.prototype[u]=function(){return""},l.prototype.inspect=function(){return""},l.prototype.protos=function(){return this.protoCodes().map(e=>Object.assign({},i(e)))},l.prototype.protoCodes=function(){const e=[],t=this.bytes;let r=0;for(;re.name)},l.prototype.tuples=function(){return n.bytesToTuples(this.bytes)},l.prototype.stringTuples=function(){const e=n.bytesToTuples(this.bytes);return n.tuplesToStringTuples(e)},l.prototype.encapsulate=function(e){return e=l(e),l(this.toString()+e.toString())},l.prototype.decapsulate=function(e){e=e.toString();const t=this.toString(),r=t.lastIndexOf(e);if(r<0)throw new Error("Address "+this+" does not contain subaddress: "+e);return l(t.slice(0,r))},l.prototype.decapsulateCode=function(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return l(n.tuplesToBytes(t.slice(0,r)));return this},l.prototype.getPeerId=function(){let e=null;try{e=this.stringTuples().filter(e=>{if(e[0]===i.names.ipfs.code)return!0}).pop()[1],e=f(new o(e).multihash,"base58btc")}catch(t){e=null}return e},l.prototype.getPath=function(){let e=null;try{e=this.stringTuples().filter(e=>{if(i(e[0]).path)return!0})[0][1]}catch(t){e=null}return e},l.prototype.equals=function(e){return h(this.bytes,e.bytes)},l.prototype.resolve=async function(){const e=this.protos().find(e=>e.resolvable);if(!e)return[this];const t=d.get(e.name);if(!t)throw c(new Error("no available resolver for "+e.name),"ERR_NO_AVAILABLE_RESOLVER");return(await t(this)).map(e=>l(e))},l.prototype.nodeAddress=function(){const e=this.protoCodes(),t=this.protoNames(),r=this.toString().split("/").slice(1);if(r.length<4)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6}/{address}/{tcp, udp}/{port}".');if(4!==e[0]&&41!==e[0]&&54!==e[0]&&55!==e[0])throw new Error(`no protocol with name: "'${t[0]}'". Must have a valid family name: "{ip4, ip6, dns4, dns6}".`);if("tcp"!==r[2]&&"udp"!==r[2])throw new Error(`no protocol with name: "'${t[1]}'". Must have a valid transport protocol: "{tcp, udp}".`);return{family:41===e[0]||55===e[0]?6:4,address:r[1],port:parseInt(r[3])}},l.fromNodeAddress=function(e,t){if(!e)throw new Error("requires node address object");if(!t)throw new Error("requires transport protocol");let r;switch(e.family){case"IPv4":r="ip4";break;case"IPv6":r="ip6";break;default:throw Error(`Invalid addr family. Got '${e.family}' instead of 'IPv4' or 'IPv6'`)}return l("/"+[r,e.address,t,e.port].join("/"))},l.prototype.isThinWaistAddress=function(e){const t=(e||this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))},l.protocols=i,l.isName=function(e){return!!l.isMultiaddr(e)&&e.protos().some(e=>e.resolvable)},l.resolve=function(e){return l.isMultiaddr(e)&&l.isName(e)?Promise.reject(new Error("not implemented yet")):Promise.reject(Error("not a valid name"))},l.resolvers=d,e.exports=l},function(e,t,r){"use strict";e.exports=function(e,t,r,n){return t.bytes=r.bytes=0,{type:e,encode:t,decode:r,encodingLength:n}}},function(e,t,r){"use strict";(function(e){var n=r(171),i=r(172),s=r(173);function o(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function p(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return V(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return j(e).length;default:if(n)return V(e).length;t=(""+t).toLowerCase(),n=!0}}function y(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return R(this,t,r);case"utf8":case"utf-8":return k(this,t,r);case"ascii":return I(this,t,r);case"latin1":case"binary":return T(this,t,r);case"base64":return C(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function g(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,i){var s,o=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,r/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var f=-1;for(s=r;sa&&(r=a-c),s=r;s>=0;s--){for(var h=!0,d=0;di&&(n=i):n=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o>8,i=r%256,s.push(i),s.push(n);return s}(t,e.length-r),e,r,n)}function C(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function k(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(f=u);break;case 2:128==(192&(s=e[i+1]))&&(c=(31&u)<<6|63&s)>127&&(f=c);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(c=(15&u)<<12|(63&s)<<6|63&o)>2047&&(c<55296||c>57343)&&(f=c);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(f=c)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},c.prototype.compare=function(e,t,r,n,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),a=Math.min(s,o),u=this.slice(n,i),f=e.slice(t,r),h=0;hi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":return E(this,e,t,r);case"latin1":case"binary":return S(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",s=t;sr)throw new RangeError("Trying to access beyond buffer length")}function P(e,t,r,n,i,s){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function M(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function x(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function L(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(e,t,r,n,s){return s||L(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function O(e,t,r,n,s){return s||L(e,0,r,8),i.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},c.prototype.readUInt8=function(e,t){return t||N(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||N(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||N(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||N(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=this[e],i=1,s=0;++s=(i*=128)&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=t,i=1,s=this[e+--n];n>0&&(i*=256);)s+=this[e+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},c.prototype.readInt8=function(e,t){return t||N(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||N(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){t||N(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||N(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||N(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||N(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||N(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||P(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[t]=255&e;++s=0&&(s*=256);)this[t+i]=e/s&255;return t+r},c.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):M(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):M(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):x(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s>0)-a&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):M(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):M(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):x(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):x(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,r){return D(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return D(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return O(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return O(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(s<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function j(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(U,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(38))},function(e,t,r){"use strict";var n=t,i=r(17),s=r(22),o=r(85);n.assert=s,n.toArray=o.toArray,n.zero2=o.zero2,n.toHex=o.toHex,n.encode=o.encode,n.getNAF=function(e,t,r){var n=new Array(Math.max(e.bitLength(),r)+1);n.fill(0);for(var i=1<(i>>1)-1?(i>>1)-c:c,s.isubn(a)):a=0,n[o]=a,s.iushrn(1)}return n},n.getJSF=function(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var n=0,i=0;e.cmpn(-n)>0||t.cmpn(-i)>0;){var s,o,a,c=e.andln(3)+n&3,u=t.andln(3)+i&3;if(3===c&&(c=-1),3===u&&(u=-1),0==(1&c))s=0;else s=3!==(a=e.andln(7)+n&7)&&5!==a||2!==u?c:-c;if(r[0].push(s),0==(1&u))o=0;else o=3!==(a=t.andln(7)+i&7)&&5!==a||2!==c?u:-u;r[1].push(o),2*n===s+1&&(n=1-n),2*i===o+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},function(e,t,r){"use strict";e.exports=function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;re+t.length,0));const r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}},function(e,t,r){"use strict";var n=r(146),i=r(150);e.exports=function(e,t){if(t||(t={}),!e)throw new Error("Pass in a .proto string or a protobuf-schema parsed object");var r="object"!=typeof e||e instanceof Uint8Array?n.parse(e):e,s=function(){var e=this;i(r,t.encodings||{}).forEach((function(t){e[t.name]=function(e){if(!e)return null;var t={};return Object.keys(e).forEach((function(r){t[r]=e[r].value})),t}(t.values)||t}))};return s.prototype.toString=function(){return n.stringify(r)},s.prototype.toJSON=function(){return r},new s}},function(e,t,r){"use strict";var n=r(22),i=r(43);function s(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function c(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=i,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i>6|192,r[n++]=63&o|128):s(e,i)?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++i)),r[n++]=o>>18|240,r[n++]=o>>12&63|128,r[n++]=o>>6&63|128,r[n++]=63&o|128):(r[n++]=o>>12|224,r[n++]=o>>6&63|128,r[n++]=63&o|128)}else for(i=0;i>>0}return o},t.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=s>>>16&255,r[i+2]=s>>>8&255,r[i+3]=255&s):(r[i+3]=s>>>24,r[i+2]=s>>>16&255,r[i+1]=s>>>8&255,r[i]=255&s)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},t.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},t.sum64=function(e,t,r,n){var i=e[t],s=n+e[t+1]>>>0,o=(s>>0,e[t+1]=s},t.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},t.sum64_lo=function(e,t,r,n){return t+n>>>0},t.sum64_4_hi=function(e,t,r,n,i,s,o,a){var c=0,u=t;return c+=(u=u+n>>>0)>>0)>>0)>>0},t.sum64_4_lo=function(e,t,r,n,i,s,o,a){return t+n+s+a>>>0},t.sum64_5_hi=function(e,t,r,n,i,s,o,a,c,u){var f=0,h=t;return f+=(h=h+n>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(e,t,r,n,i,s,o,a,c,u){return t+n+s+a+u>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},function(e,t,r){"use strict";(function(e){!function(e,t){function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function s(e,t,r){if(s.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"==typeof e?e.exports=s:(void 0).BN=s,s.BN=s,s.wordSize=26;try{o=r(199).Buffer}catch(_){}function a(e,t,r){for(var n=0,i=Math.min(e.length,r),s=t;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function c(e,t,r,n){for(var i=0,s=Math.min(e.length,r),o=t;o=49?a-49+10:a>=17?a-17+10:a}return i}s.isBN=function(e){return e instanceof s||null!==e&&"object"==typeof e&&e.constructor.wordSize===s.wordSize&&Array.isArray(e.words)},s.max=function(e,t){return e.cmp(t)>0?e:t},s.min=function(e,t){return e.cmp(t)<0?e:t},s.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},s.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},s.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)o=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(i=0,s=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=a(e,r,r+6),this.words[n]|=i<>>26-s&4194303,(s+=24)>=26&&(s-=26,n++);r+6!==t&&(i=a(e,t,r+6),this.words[n]|=i<>>26-s&4194303),this.strip()},s.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var s=e.length-r,o=s%n,a=Math.min(s,s-o)+r,u=0,f=r;f1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],s=0|t.words[0],o=i*s,a=67108863&o,c=o/67108864|0;r.words[0]=a;for(var u=1;u>>26,h=67108863&c,d=Math.min(u,t.length-1),l=Math.max(0,u-e.length+1);l<=d;l++){var p=u-l|0;f+=(o=(i=0|e.words[p])*(s=0|t.words[l])+h)/67108864|0,h=67108863&o}r.words[u]=0|h,c=0|f}return 0!==c?r.words[u]=0|c:r.length--,r.strip()}s.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,s=0,o=0;o>>24-i&16777215)||o!==this.length-1?u[6-c.length]+c+r:c+r,(i+=2)>=26&&(i-=26,o--)}for(0!==s&&(r=s.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var d=f[e],l=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modn(l).toString(e);r=(p=p.idivn(l)).isZero()?y+r:u[d-y.length]+y+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(e,t){return n(void 0!==o),this.toArrayLike(o,e,t)},s.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},s.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),s=r||Math.max(1,i);n(i<=s,"byte array longer than desired length"),n(s>0,"Requested array length <= 0"),this.strip();var o,a,c="le"===t,u=new e(s),f=this.clone();if(c){for(a=0;!f.isZero();a++)o=f.andln(255),f.iushrn(8),u[a]=o;for(;a=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},s.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},s.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},s.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},s.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},s.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},s.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},s.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},s.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},s.prototype.notn=function(e){return this.clone().inotn(e)},s.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,s=0;s>>26;for(;0!==i&&s>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;se.length?this.clone().iadd(e):e.clone().iadd(this)},s.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var s=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==s&&o>26,this.words[o]=67108863&t;if(0===s&&o>>13,l=0|o[1],p=8191&l,y=l>>>13,g=0|o[2],b=8191&g,m=g>>>13,v=0|o[3],w=8191&v,E=v>>>13,S=0|o[4],A=8191&S,_=S>>>13,C=0|o[5],k=8191&C,I=C>>>13,T=0|o[6],R=8191&T,B=T>>>13,N=0|o[7],P=8191&N,M=N>>>13,x=0|o[8],L=8191&x,D=x>>>13,O=0|o[9],U=8191&O,K=O>>>13,V=0|a[0],j=8191&V,F=V>>>13,q=0|a[1],z=8191&q,H=q>>>13,G=0|a[2],Y=8191&G,$=G>>>13,Q=0|a[3],W=8191&Q,X=Q>>>13,Z=0|a[4],J=8191&Z,ee=Z>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],se=8191&ie,oe=ie>>>13,ae=0|a[7],ce=8191&ae,ue=ae>>>13,fe=0|a[8],he=8191&fe,de=fe>>>13,le=0|a[9],pe=8191&le,ye=le>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(u+(n=Math.imul(h,j))|0)+((8191&(i=(i=Math.imul(h,F))+Math.imul(d,j)|0))<<13)|0;u=((s=Math.imul(d,F))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(p,j),i=(i=Math.imul(p,F))+Math.imul(y,j)|0,s=Math.imul(y,F);var be=(u+(n=n+Math.imul(h,z)|0)|0)+((8191&(i=(i=i+Math.imul(h,H)|0)+Math.imul(d,z)|0))<<13)|0;u=((s=s+Math.imul(d,H)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(b,j),i=(i=Math.imul(b,F))+Math.imul(m,j)|0,s=Math.imul(m,F),n=n+Math.imul(p,z)|0,i=(i=i+Math.imul(p,H)|0)+Math.imul(y,z)|0,s=s+Math.imul(y,H)|0;var me=(u+(n=n+Math.imul(h,Y)|0)|0)+((8191&(i=(i=i+Math.imul(h,$)|0)+Math.imul(d,Y)|0))<<13)|0;u=((s=s+Math.imul(d,$)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(w,j),i=(i=Math.imul(w,F))+Math.imul(E,j)|0,s=Math.imul(E,F),n=n+Math.imul(b,z)|0,i=(i=i+Math.imul(b,H)|0)+Math.imul(m,z)|0,s=s+Math.imul(m,H)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(y,Y)|0,s=s+Math.imul(y,$)|0;var ve=(u+(n=n+Math.imul(h,W)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(d,W)|0))<<13)|0;u=((s=s+Math.imul(d,X)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(A,j),i=(i=Math.imul(A,F))+Math.imul(_,j)|0,s=Math.imul(_,F),n=n+Math.imul(w,z)|0,i=(i=i+Math.imul(w,H)|0)+Math.imul(E,z)|0,s=s+Math.imul(E,H)|0,n=n+Math.imul(b,Y)|0,i=(i=i+Math.imul(b,$)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,$)|0,n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,X)|0)+Math.imul(y,W)|0,s=s+Math.imul(y,X)|0;var we=(u+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(d,J)|0))<<13)|0;u=((s=s+Math.imul(d,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,F))+Math.imul(I,j)|0,s=Math.imul(I,F),n=n+Math.imul(A,z)|0,i=(i=i+Math.imul(A,H)|0)+Math.imul(_,z)|0,s=s+Math.imul(_,H)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,$)|0,n=n+Math.imul(b,W)|0,i=(i=i+Math.imul(b,X)|0)+Math.imul(m,W)|0,s=s+Math.imul(m,X)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(y,J)|0,s=s+Math.imul(y,ee)|0;var Ee=(u+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(d,re)|0))<<13)|0;u=((s=s+Math.imul(d,ne)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(R,j),i=(i=Math.imul(R,F))+Math.imul(B,j)|0,s=Math.imul(B,F),n=n+Math.imul(k,z)|0,i=(i=i+Math.imul(k,H)|0)+Math.imul(I,z)|0,s=s+Math.imul(I,H)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,$)|0)+Math.imul(_,Y)|0,s=s+Math.imul(_,$)|0,n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,X)|0)+Math.imul(E,W)|0,s=s+Math.imul(E,X)|0,n=n+Math.imul(b,J)|0,i=(i=i+Math.imul(b,ee)|0)+Math.imul(m,J)|0,s=s+Math.imul(m,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(y,re)|0,s=s+Math.imul(y,ne)|0;var Se=(u+(n=n+Math.imul(h,se)|0)|0)+((8191&(i=(i=i+Math.imul(h,oe)|0)+Math.imul(d,se)|0))<<13)|0;u=((s=s+Math.imul(d,oe)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(P,j),i=(i=Math.imul(P,F))+Math.imul(M,j)|0,s=Math.imul(M,F),n=n+Math.imul(R,z)|0,i=(i=i+Math.imul(R,H)|0)+Math.imul(B,z)|0,s=s+Math.imul(B,H)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(I,Y)|0,s=s+Math.imul(I,$)|0,n=n+Math.imul(A,W)|0,i=(i=i+Math.imul(A,X)|0)+Math.imul(_,W)|0,s=s+Math.imul(_,X)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(E,J)|0,s=s+Math.imul(E,ee)|0,n=n+Math.imul(b,re)|0,i=(i=i+Math.imul(b,ne)|0)+Math.imul(m,re)|0,s=s+Math.imul(m,ne)|0,n=n+Math.imul(p,se)|0,i=(i=i+Math.imul(p,oe)|0)+Math.imul(y,se)|0,s=s+Math.imul(y,oe)|0;var Ae=(u+(n=n+Math.imul(h,ce)|0)|0)+((8191&(i=(i=i+Math.imul(h,ue)|0)+Math.imul(d,ce)|0))<<13)|0;u=((s=s+Math.imul(d,ue)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(L,j),i=(i=Math.imul(L,F))+Math.imul(D,j)|0,s=Math.imul(D,F),n=n+Math.imul(P,z)|0,i=(i=i+Math.imul(P,H)|0)+Math.imul(M,z)|0,s=s+Math.imul(M,H)|0,n=n+Math.imul(R,Y)|0,i=(i=i+Math.imul(R,$)|0)+Math.imul(B,Y)|0,s=s+Math.imul(B,$)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,X)|0)+Math.imul(I,W)|0,s=s+Math.imul(I,X)|0,n=n+Math.imul(A,J)|0,i=(i=i+Math.imul(A,ee)|0)+Math.imul(_,J)|0,s=s+Math.imul(_,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(E,re)|0,s=s+Math.imul(E,ne)|0,n=n+Math.imul(b,se)|0,i=(i=i+Math.imul(b,oe)|0)+Math.imul(m,se)|0,s=s+Math.imul(m,oe)|0,n=n+Math.imul(p,ce)|0,i=(i=i+Math.imul(p,ue)|0)+Math.imul(y,ce)|0,s=s+Math.imul(y,ue)|0;var _e=(u+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,de)|0)+Math.imul(d,he)|0))<<13)|0;u=((s=s+Math.imul(d,de)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(U,j),i=(i=Math.imul(U,F))+Math.imul(K,j)|0,s=Math.imul(K,F),n=n+Math.imul(L,z)|0,i=(i=i+Math.imul(L,H)|0)+Math.imul(D,z)|0,s=s+Math.imul(D,H)|0,n=n+Math.imul(P,Y)|0,i=(i=i+Math.imul(P,$)|0)+Math.imul(M,Y)|0,s=s+Math.imul(M,$)|0,n=n+Math.imul(R,W)|0,i=(i=i+Math.imul(R,X)|0)+Math.imul(B,W)|0,s=s+Math.imul(B,X)|0,n=n+Math.imul(k,J)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,ee)|0,n=n+Math.imul(A,re)|0,i=(i=i+Math.imul(A,ne)|0)+Math.imul(_,re)|0,s=s+Math.imul(_,ne)|0,n=n+Math.imul(w,se)|0,i=(i=i+Math.imul(w,oe)|0)+Math.imul(E,se)|0,s=s+Math.imul(E,oe)|0,n=n+Math.imul(b,ce)|0,i=(i=i+Math.imul(b,ue)|0)+Math.imul(m,ce)|0,s=s+Math.imul(m,ue)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,de)|0)+Math.imul(y,he)|0,s=s+Math.imul(y,de)|0;var Ce=(u+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ye)|0)+Math.imul(d,pe)|0))<<13)|0;u=((s=s+Math.imul(d,ye)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(U,z),i=(i=Math.imul(U,H))+Math.imul(K,z)|0,s=Math.imul(K,H),n=n+Math.imul(L,Y)|0,i=(i=i+Math.imul(L,$)|0)+Math.imul(D,Y)|0,s=s+Math.imul(D,$)|0,n=n+Math.imul(P,W)|0,i=(i=i+Math.imul(P,X)|0)+Math.imul(M,W)|0,s=s+Math.imul(M,X)|0,n=n+Math.imul(R,J)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(B,J)|0,s=s+Math.imul(B,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(I,re)|0,s=s+Math.imul(I,ne)|0,n=n+Math.imul(A,se)|0,i=(i=i+Math.imul(A,oe)|0)+Math.imul(_,se)|0,s=s+Math.imul(_,oe)|0,n=n+Math.imul(w,ce)|0,i=(i=i+Math.imul(w,ue)|0)+Math.imul(E,ce)|0,s=s+Math.imul(E,ue)|0,n=n+Math.imul(b,he)|0,i=(i=i+Math.imul(b,de)|0)+Math.imul(m,he)|0,s=s+Math.imul(m,de)|0;var ke=(u+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ye)|0)+Math.imul(y,pe)|0))<<13)|0;u=((s=s+Math.imul(y,ye)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(U,Y),i=(i=Math.imul(U,$))+Math.imul(K,Y)|0,s=Math.imul(K,$),n=n+Math.imul(L,W)|0,i=(i=i+Math.imul(L,X)|0)+Math.imul(D,W)|0,s=s+Math.imul(D,X)|0,n=n+Math.imul(P,J)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(M,J)|0,s=s+Math.imul(M,ee)|0,n=n+Math.imul(R,re)|0,i=(i=i+Math.imul(R,ne)|0)+Math.imul(B,re)|0,s=s+Math.imul(B,ne)|0,n=n+Math.imul(k,se)|0,i=(i=i+Math.imul(k,oe)|0)+Math.imul(I,se)|0,s=s+Math.imul(I,oe)|0,n=n+Math.imul(A,ce)|0,i=(i=i+Math.imul(A,ue)|0)+Math.imul(_,ce)|0,s=s+Math.imul(_,ue)|0,n=n+Math.imul(w,he)|0,i=(i=i+Math.imul(w,de)|0)+Math.imul(E,he)|0,s=s+Math.imul(E,de)|0;var Ie=(u+(n=n+Math.imul(b,pe)|0)|0)+((8191&(i=(i=i+Math.imul(b,ye)|0)+Math.imul(m,pe)|0))<<13)|0;u=((s=s+Math.imul(m,ye)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(U,W),i=(i=Math.imul(U,X))+Math.imul(K,W)|0,s=Math.imul(K,X),n=n+Math.imul(L,J)|0,i=(i=i+Math.imul(L,ee)|0)+Math.imul(D,J)|0,s=s+Math.imul(D,ee)|0,n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(M,re)|0,s=s+Math.imul(M,ne)|0,n=n+Math.imul(R,se)|0,i=(i=i+Math.imul(R,oe)|0)+Math.imul(B,se)|0,s=s+Math.imul(B,oe)|0,n=n+Math.imul(k,ce)|0,i=(i=i+Math.imul(k,ue)|0)+Math.imul(I,ce)|0,s=s+Math.imul(I,ue)|0,n=n+Math.imul(A,he)|0,i=(i=i+Math.imul(A,de)|0)+Math.imul(_,he)|0,s=s+Math.imul(_,de)|0;var Te=(u+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ye)|0)+Math.imul(E,pe)|0))<<13)|0;u=((s=s+Math.imul(E,ye)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(U,J),i=(i=Math.imul(U,ee))+Math.imul(K,J)|0,s=Math.imul(K,ee),n=n+Math.imul(L,re)|0,i=(i=i+Math.imul(L,ne)|0)+Math.imul(D,re)|0,s=s+Math.imul(D,ne)|0,n=n+Math.imul(P,se)|0,i=(i=i+Math.imul(P,oe)|0)+Math.imul(M,se)|0,s=s+Math.imul(M,oe)|0,n=n+Math.imul(R,ce)|0,i=(i=i+Math.imul(R,ue)|0)+Math.imul(B,ce)|0,s=s+Math.imul(B,ue)|0,n=n+Math.imul(k,he)|0,i=(i=i+Math.imul(k,de)|0)+Math.imul(I,he)|0,s=s+Math.imul(I,de)|0;var Re=(u+(n=n+Math.imul(A,pe)|0)|0)+((8191&(i=(i=i+Math.imul(A,ye)|0)+Math.imul(_,pe)|0))<<13)|0;u=((s=s+Math.imul(_,ye)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(U,re),i=(i=Math.imul(U,ne))+Math.imul(K,re)|0,s=Math.imul(K,ne),n=n+Math.imul(L,se)|0,i=(i=i+Math.imul(L,oe)|0)+Math.imul(D,se)|0,s=s+Math.imul(D,oe)|0,n=n+Math.imul(P,ce)|0,i=(i=i+Math.imul(P,ue)|0)+Math.imul(M,ce)|0,s=s+Math.imul(M,ue)|0,n=n+Math.imul(R,he)|0,i=(i=i+Math.imul(R,de)|0)+Math.imul(B,he)|0,s=s+Math.imul(B,de)|0;var Be=(u+(n=n+Math.imul(k,pe)|0)|0)+((8191&(i=(i=i+Math.imul(k,ye)|0)+Math.imul(I,pe)|0))<<13)|0;u=((s=s+Math.imul(I,ye)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(U,se),i=(i=Math.imul(U,oe))+Math.imul(K,se)|0,s=Math.imul(K,oe),n=n+Math.imul(L,ce)|0,i=(i=i+Math.imul(L,ue)|0)+Math.imul(D,ce)|0,s=s+Math.imul(D,ue)|0,n=n+Math.imul(P,he)|0,i=(i=i+Math.imul(P,de)|0)+Math.imul(M,he)|0,s=s+Math.imul(M,de)|0;var Ne=(u+(n=n+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,ye)|0)+Math.imul(B,pe)|0))<<13)|0;u=((s=s+Math.imul(B,ye)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(U,ce),i=(i=Math.imul(U,ue))+Math.imul(K,ce)|0,s=Math.imul(K,ue),n=n+Math.imul(L,he)|0,i=(i=i+Math.imul(L,de)|0)+Math.imul(D,he)|0,s=s+Math.imul(D,de)|0;var Pe=(u+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,ye)|0)+Math.imul(M,pe)|0))<<13)|0;u=((s=s+Math.imul(M,ye)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(U,he),i=(i=Math.imul(U,de))+Math.imul(K,he)|0,s=Math.imul(K,de);var Me=(u+(n=n+Math.imul(L,pe)|0)|0)+((8191&(i=(i=i+Math.imul(L,ye)|0)+Math.imul(D,pe)|0))<<13)|0;u=((s=s+Math.imul(D,ye)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863;var xe=(u+(n=Math.imul(U,pe))|0)+((8191&(i=(i=Math.imul(U,ye))+Math.imul(K,pe)|0))<<13)|0;return u=((s=Math.imul(K,ye))+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,c[0]=ge,c[1]=be,c[2]=me,c[3]=ve,c[4]=we,c[5]=Ee,c[6]=Se,c[7]=Ae,c[8]=_e,c[9]=Ce,c[10]=ke,c[11]=Ie,c[12]=Te,c[13]=Re,c[14]=Be,c[15]=Ne,c[16]=Pe,c[17]=Me,c[18]=xe,0!==u&&(c[19]=u,r.length++),r};function p(e,t,r){return(new y).mulp(e,t,r)}function y(e,t){this.x=e,this.y=t}Math.imul||(l=d),s.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?l(this,e,t):r<63?d(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,s=0;s>>26)|0)>>>26,o&=67108863}r.words[s]=a,n=o,o=i}return 0!==n?r.words[s]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},y.prototype.makeRBT=function(e){for(var t=new Array(e),r=s.prototype._countBits(e)-1,n=0;n>=1;return n},y.prototype.permute=function(e,t,r,n,i,s){for(var o=0;o>>=1)i++;return 1<>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*t;o>=26,t+=i/67108864|0,t+=s>>>26,this.words[r]=67108863&s}return 0!==t&&(this.words[r]=t,this.length++),this},s.prototype.muln=function(e){return this.clone().imuln(e)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new s(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(t=0;t>>26-r}o&&(this.words[t]=o,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var s=e%26,o=Math.min((e-s)/26,this.length),a=67108863^67108863>>>s<o)for(this.length-=o,u=0;u=0&&(0!==f||u>=i);u--){var h=0|this.words[u];this.words[u]=f<<26-s|h>>>s,f=h&a}return c&&0!==f&&(c.words[c.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},s.prototype.shln=function(e){return this.clone().ishln(e)},s.prototype.ushln=function(e){return this.clone().iushln(e)},s.prototype.shrn=function(e){return this.clone().ishrn(e)},s.prototype.ushrn=function(e){return this.clone().iushrn(e)},s.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},s.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(c/67108864|0),this.words[i+r]=67108863&s}for(;i>26,this.words[i+r]=67108863&s;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>26,this.words[i]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,o=0|i.words[i.length-1];0!==(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var a,c=n.length-i.length;if("mod"!==t){(a=new s(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;h--){var d=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(d=Math.min(d/o|0,67108863),n._ishlnsubmul(i,d,h);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=d)}return a&&a.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},s.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(e)),{div:i,mod:o}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(e)),{div:a.div,mod:o}):e.length>this.length||this.cmp(e)<0?{div:new s(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new s(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new s(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,o,a},s.prototype.div=function(e){return this.divmod(e,"div",!1).div},s.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},s.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},s.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),s=r.cmp(n);return s<0||1===i&&0===s?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},s.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},s.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},s.prototype.divn=function(e){return this.clone().idivn(e)},s.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new s(1),o=new s(0),a=new s(0),c=new s(1),u=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),h=t.clone();!t.isZero();){for(var d=0,l=1;0==(t.words[0]&l)&&d<26;++d,l<<=1);if(d>0)for(t.iushrn(d);d-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(f),o.isub(h)),i.iushrn(1),o.iushrn(1);for(var p=0,y=1;0==(r.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(f),c.isub(h)),a.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(a),o.isub(c)):(r.isub(t),a.isub(i),c.isub(o))}return{a:a,b:c,gcd:r.iushln(u)}},s.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,o=new s(1),a=new s(0),c=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0==(t.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(t.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);for(var h=0,d=1;0==(r.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),o.isub(a)):(r.isub(t),a.isub(o))}return(i=0===t.cmpn(1)?o:a).cmpn(0)<0&&i.iadd(e),i},s.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var s=t;t=r,r=s}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},s.prototype.invm=function(e){return this.egcd(e).a.umod(e)},s.prototype.isEven=function(){return 0==(1&this.words[0])},s.prototype.isOdd=function(){return 1==(1&this.words[0])},s.prototype.andln=function(e){return this.words[0]&e},s.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},s.prototype.gtn=function(e){return 1===this.cmpn(e)},s.prototype.gt=function(e){return 1===this.cmp(e)},s.prototype.gten=function(e){return this.cmpn(e)>=0},s.prototype.gte=function(e){return this.cmp(e)>=0},s.prototype.ltn=function(e){return-1===this.cmpn(e)},s.prototype.lt=function(e){return-1===this.cmp(e)},s.prototype.lten=function(e){return this.cmpn(e)<=0},s.prototype.lte=function(e){return this.cmp(e)<=0},s.prototype.eqn=function(e){return 0===this.cmpn(e)},s.prototype.eq=function(e){return 0===this.cmp(e)},s.red=function(e){return new S(e)},s.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},s.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(e){return this.red=e,this},s.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},s.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},s.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},s.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},s.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},s.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},s.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},s.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},s.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function b(e,t){this.name=e,this.p=new s(t,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function m(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function v(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(e){if("string"==typeof e){var t=s._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function A(e){S.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var e=new s(null);return e.words=new Array(Math.ceil(this.n/13)),e},b.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(e,t){e.iushrn(this.n,0,t)},b.prototype.imulK=function(e){return e.imul(this.k)},i(m,b),m.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=s}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},m.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},s._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new m;else if("p224"===e)t=new v;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new E}return g[e]=t,t},S.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},S.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new s(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);n(!i.isZero());var a=new s(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new s(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,i),d=this.pow(e,i.addn(1).iushrn(1)),l=this.pow(e,i),p=o;0!==l.cmp(a);){for(var y=l,g=0;0!==y.cmp(a);g++)y=y.redSqr();n(g=0;n--){for(var u=t.words[n],f=c-1;f>=0;f--){var h=u>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==o?(o<<=1,o|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[o]),a=0,o=0)):a=0}c=26}return i},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},s.mont=function(e){return new A(e)},i(A,S),A.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},A.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},A.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},A.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new s(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},A.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e)}).call(this,r(198)(e))},function(e,t,r){"use strict";var n=r(0);r(3),r(28);var i=e.exports=n.asn1=n.asn1||{};function s(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}i.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},i.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},i.create=function(e,t,r,s,o){if(n.util.isArray(s)){for(var a=[],c=0;cr){if(o.strict){var p=new Error("Too few bytes to read ASN.1 value.");throw p.available=t.length(),p.remaining=r,p.requested=l,p}l=r}var y=32==(32&c);if(y)if(h=[],void 0===l)for(;;){if(s(t,r,2),t.bytes(2)===String.fromCharCode(0,0)){t.getBytes(2),r-=2;break}a=t.length(),h.push(e(t,r,n+1,o)),r-=a-t.length()}else for(;l>0;)a=t.length(),h.push(e(t,l,n+1,o)),r-=a-t.length(),l-=a-t.length();void 0===h&&u===i.Class.UNIVERSAL&&f===i.Type.BITSTRING&&(d=t.bytes(l));if(void 0===h&&o.decodeBitStrings&&u===i.Class.UNIVERSAL&&f===i.Type.BITSTRING&&l>1){var g=t.read,b=r,m=0;if(f===i.Type.BITSTRING&&(s(t,r,1),m=t.getByte(),r--),0===m)try{a=t.length();var v={verbose:o.verbose,strict:!0,decodeBitStrings:!0},w=e(t,r,n+1,v),E=a-t.length();r-=E,f==i.Type.BITSTRING&&E++;var S=w.tagClass;E!==l||S!==i.Class.UNIVERSAL&&S!==i.Class.CONTEXT_SPECIFIC||(h=[w])}catch(_){}void 0===h&&(t.read=g,r=b)}if(void 0===h){if(void 0===l){if(o.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");l=r}if(f===i.Type.BMPSTRING)for(h="";l>0;l-=2)s(t,r,2),h+=String.fromCharCode(t.getInt16()),r-=2;else h=t.getBytes(l)}var A=void 0===d?null:{bitStringContents:d};return i.create(u,f,y,h,A)}(e,e.length(),0,t)},i.toDer=function(e){var t=n.util.createBuffer(),r=e.tagClass|e.type,s=n.util.createBuffer(),o=!1;if("bitStringContents"in e&&(o=!0,e.original&&(o=i.equals(e,e.original))),o)s.putBytes(e.bitStringContents);else if(e.composed){e.constructed?r|=32:s.putByte(0);for(var a=0;a1&&(0===e.value.charCodeAt(0)&&0==(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128==(128&e.value.charCodeAt(1)))?s.putBytes(e.value.substr(1)):s.putBytes(e.value);if(t.putByte(r),s.length()<=127)t.putByte(127&s.length());else{var c=s.length(),u="";do{u+=String.fromCharCode(255&c),c>>>=8}while(c>0);t.putByte(128|u.length);for(a=u.length-1;a>=0;--a)t.putByte(u.charCodeAt(a))}return t.putBuffer(s),t},i.oidToDer=function(e){var t,r,i,s,o=e.split("."),a=n.util.createBuffer();a.putByte(40*parseInt(o[0],10)+parseInt(o[1],10));for(var c=2;c>>=7,t||(s|=128),r.push(s),t=!1}while(i>0);for(var u=r.length-1;u>=0;--u)a.putByte(r[u])}return a},i.derToOid=function(e){var t;"string"==typeof e&&(e=n.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var i=0;e.length()>0;)i<<=7,128&(r=e.getByte())?i+=127&r:(t+="."+(i+r),i=0);return t},i.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,i=parseInt(e.substr(4,2),10),s=parseInt(e.substr(6,2),10),o=parseInt(e.substr(8,2),10),a=0;if(e.length>11){var c=e.charAt(10),u=10;"+"!==c&&"-"!==c&&(a=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(s,o,a,0),u&&("+"===(c=e.charAt(u))||"-"===c)){var f=60*parseInt(e.substr(u+1,2),10)+parseInt(e.substr(u+4,2),10);f*=6e4,"+"===c?t.setTime(+t-f):t.setTime(+t+f)}return t},i.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),o=parseInt(e.substr(10,2),10),a=parseInt(e.substr(12,2),10),c=0,u=0,f=!1;"Z"===e.charAt(e.length-1)&&(f=!0);var h=e.length-5,d=e.charAt(h);"+"!==d&&"-"!==d||(u=60*parseInt(e.substr(h+1,2),10)+parseInt(e.substr(h+4,2),10),u*=6e4,"+"===d&&(u*=-1),f=!0);return"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),f?(t.setUTCFullYear(r,n,i),t.setUTCHours(s,o,a,c),t.setTime(+t+u)):(t.setFullYear(r,n,i),t.setHours(s,o,a,c)),t},i.dateToUtcTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},i.derToInteger=function(e){"string"==typeof e&&(e=n.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},i.validate=function(e,t,r,s){var o=!1;if(e.tagClass!==t.tagClass&&void 0!==t.tagClass||e.type!==t.type&&void 0!==t.type)s&&(e.tagClass!==t.tagClass&&s.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&s.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));else if(e.constructed===t.constructed||void 0===t.constructed){if(o=!0,t.value&&n.util.isArray(t.value))for(var a=0,c=0;o&&c0&&(s+="\n");for(var a="",c=0;c1?s+="0x"+n.util.bytesToHex(e.value.slice(1)):s+="(none)",e.value.length>0){var d=e.value.charCodeAt(0);1==d?s+=" (1 unused bit shown)":d>1&&(s+=" ("+d+" unused bits shown)")}}else e.type===i.Type.OCTETSTRING?(o.test(e.value)||(s+="("+e.value+") "),s+="0x"+n.util.bytesToHex(e.value)):e.type===i.Type.UTF8?s+=n.util.decodeUtf8(e.value):e.type===i.Type.PRINTABLESTRING||e.type===i.Type.IA5String?s+=e.value:o.test(e.value)?s+="0x"+n.util.bytesToHex(e.value):0===e.value.length?s+="[null]":s+=e.value}return s}},function(e,t,r){"use strict";var n,i="object"==typeof Reflect?Reflect:null,s=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};n=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function a(){a.init.call(this)}e.exports=a,e.exports.once=function(e,t){return new Promise((function(r,n){function i(){void 0!==s&&e.removeListener("error",s),r([].slice.call(arguments))}var s;"error"!==t&&(s=function(r){e.removeListener(t,i),n(r)},e.once("error",s)),e.once(t,i)}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function f(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function h(e,t,r,n){var i,s,o,a;if(u(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(i=f(e))>0&&o.length>i&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,a=c,console&&console.warn&&console.warn(a)}return e}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=d.bind(n);return i.listener=r,n.wrapFn=i,i}function p(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)s(c,this,t);else{var u=c.length,f=g(c,u);for(r=0;r=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},a.prototype.listeners=function(e){return p(this,e,!0)},a.prototype.rawListeners=function(e){return p(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):y.call(e,t)},a.prototype.listenerCount=y,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,r){"use strict";var n=r(0);e.exports=n.md=n.md||{},n.md.algorithms=n.md.algorithms||{}},function(e,t,r){"use strict";var n=r(0);r(29),r(176),r(177),r(3),n.random&&n.random.getBytes?e.exports=n.random:function(t){var r={},i=new Array(4),s=n.util.createBuffer();function o(){var e=n.prng.create(r);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}r.formatKey=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),n.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return n.aes._updateBlock(e,t,i,!1),s.putInt32(i[0]),s.putInt32(i[1]),s.putInt32(i[2]),s.putInt32(i[3]),s.getBytes()},r.increment=function(e){return++e[3],e},r.md=n.md.sha256;var a=o(),c=null,u=n.util.globalScope,f=u.crypto||u.msCrypto;if(f&&f.getRandomValues&&(c=function(e){return f.getRandomValues(e)}),n.options.usePureJavaScript||!n.util.isNodejs&&!c){if("undefined"==typeof window||window.document,a.collectInt(+new Date,32),"undefined"!=typeof navigator){var h="";for(var d in navigator)try{"string"==typeof navigator[d]&&(h+=navigator[d])}catch(l){}a.collect(h),h=null}t&&(t().mousemove((function(e){a.collectInt(e.clientX,16),a.collectInt(e.clientY,16)})),t().keypress((function(e){a.collectInt(e.charCode,8)})))}if(n.random)for(var d in a)n.random[d]=a[d];else n.random=a;n.random.createInstance=o,e.exports=n.random}("undefined"!=typeof jQuery?jQuery:null)},function(e,t,r){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=n,n.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},function(e,t,r){"use strict";const n=(...e)=>{let t;for(;e.length;)t=e.shift()(t);return t},i=e=>e&&("function"==typeof e[Symbol.asyncIterator]||"function"==typeof e[Symbol.iterator]||"function"==typeof e.next),s=e=>e&&"function"==typeof e.sink&&i(e.source),o=e=>t=>(e.sink(t),e.source),a=(...e)=>{if(s(e[0])){const t=e[0];e[0]=()=>t.source}else if(i(e[0])){const t=e[0];e[0]=()=>t}if(e.length>1&&s(e[e.length-1])&&(e[e.length-1]=e[e.length-1].sink),e.length>2)for(let t=1;tthis.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},s.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},s.prototype.copy=function(e,t,r,i){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof i||i>this.length)&&(i=this.length),r>=this.length)return e||n.alloc(0);if(i<=0)return e||n.alloc(0);const s=!!e,o=this._offset(r),a=i-r;let c=a,u=s&&t||0,f=o[1];if(0===r&&i===this.length){if(!s)return 1===this._bufs.length?this._bufs[0]:n.concat(this._bufs,this.length);for(let t=0;tt)){this._bufs[n].copy(e,u,f,f+c),u+=t;break}this._bufs[n].copy(e,u,f),u+=t,c-=t,f&&(f=0)}return e.length>u?e.slice(0,u):e},s.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const r=this._offset(e),n=this._offset(t),i=this._bufs.slice(r[0],n[0]+1);return 0===n[1]?i.pop():i[i.length-1]=i[i.length-1].slice(0,n[1]),0!==r[1]&&(i[0]=i[0].slice(r[1])),this._new(i)},s.prototype.toString=function(e,t,r){return this.slice(t,r).toString(e)},s.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},s.prototype.duplicate=function(){const e=this._new();for(let t=0;tthis.length?this.length:t;const i=this._offset(t);let s=i[0],o=i[1];for(;s=e.length){const r=t.indexOf(e,o);if(-1!==r)return this._reverseOffset([s,r]);o=t.length-e.length+1}else{const t=this._reverseOffset([s,o]);if(this._match(t,e))return t;o++}}o=0}return-1},s.prototype._match=function(e,t){if(this.length-e 2 bytes.");const t=i.decode(e);if(!l(t))throw new Error("multihash unknown function code: 0x"+t.toString(16));e=e.slice(i.decode.bytes);const r=i.decode(e);if(r<0)throw new Error("multihash invalid length: "+r);if((e=e.slice(i.decode.bytes)).length!==r)throw new Error("multihash length inconsistent: 0x"+o(e,"base16"));return{code:t,name:u[t],length:r,digest:e}}function h(e){let t=e;if("string"==typeof e){if(void 0===s[e])throw new Error("Unrecognized hash function named: "+e);t=s[e]}if("number"!=typeof t)throw new Error("Hash function code should be a number. Got: "+t);if(void 0===u[t]&&!d(t))throw new Error("Unrecognized function code: "+t);return t}function d(e){return e>0&&e<16}function l(e){return!!d(e)||!!u[e]}function p(e){f(e)}e.exports={names:s,codes:Object.freeze(u),toHexString:function(e){if(!(e instanceof Uint8Array))throw new Error("must be passed a Uint8Array");return o(e,"base16")},fromHexString:function(e){return a(e,"base16")},toB58String:function(e){if(!(e instanceof Uint8Array))throw new Error("must be passed a Uint8Array");return o(n.encode("base58btc",e)).slice(1)},fromB58String:function(e){const t=e instanceof Uint8Array?o(e):e;return n.decode("z"+t)},decode:f,encode:function(e,t,r){if(!e||void 0===t)throw new Error("multihash encode requires at least two args: digest, code");const n=h(t);if(!(e instanceof Uint8Array))throw new Error("digest should be a Uint8Array");if(null==r&&(r=e.length),r&&e.length!==r)throw new Error("digest length should be equal to specified length.");const s=i.encode(n),o=i.encode(r);return c([s,o,e],s.length+o.length+e.length)},coerceCode:h,isAppCode:d,validate:p,prefix:function(e){return p(e),e.subarray(0,2)},isValidCode:l}},function(e){e.exports=JSON.parse('{"identity":0,"cidv1":1,"cidv2":2,"cidv3":3,"ip4":4,"tcp":6,"sha1":17,"sha2-256":18,"sha2-512":19,"sha3-512":20,"sha3-384":21,"sha3-256":22,"sha3-224":23,"shake-128":24,"shake-256":25,"keccak-224":26,"keccak-256":27,"keccak-384":28,"keccak-512":29,"blake3":30,"dccp":33,"murmur3-128":34,"murmur3-32":35,"ip6":41,"ip6zone":42,"path":47,"multicodec":48,"multihash":49,"multiaddr":50,"multibase":51,"dns":53,"dns4":54,"dns6":55,"dnsaddr":56,"protobuf":80,"cbor":81,"raw":85,"dbl-sha2-256":86,"rlp":96,"bencode":99,"dag-pb":112,"dag-cbor":113,"libp2p-key":114,"git-raw":120,"torrent-info":123,"torrent-file":124,"leofcoin-block":129,"leofcoin-tx":130,"leofcoin-pr":131,"sctp":132,"dag-jose":133,"dag-cose":134,"eth-block":144,"eth-block-list":145,"eth-tx-trie":146,"eth-tx":147,"eth-tx-receipt-trie":148,"eth-tx-receipt":149,"eth-state-trie":150,"eth-account-snapshot":151,"eth-storage-trie":152,"bitcoin-block":176,"bitcoin-tx":177,"bitcoin-witness-commitment":178,"zcash-block":192,"zcash-tx":193,"docid":206,"stellar-block":208,"stellar-tx":209,"md4":212,"md5":213,"bmt":214,"decred-block":224,"decred-tx":225,"ipld-ns":226,"ipfs-ns":227,"swarm-ns":228,"ipns-ns":229,"zeronet":230,"secp256k1-pub":231,"bls12_381-g1-pub":234,"bls12_381-g2-pub":235,"x25519-pub":236,"ed25519-pub":237,"bls12_381-g1g2-pub":238,"dash-block":240,"dash-tx":241,"swarm-manifest":250,"swarm-feed":251,"udp":273,"p2p-webrtc-star":275,"p2p-webrtc-direct":276,"p2p-stardust":277,"p2p-circuit":290,"dag-json":297,"udt":301,"utp":302,"unix":400,"p2p":421,"ipfs":421,"https":443,"onion":444,"onion3":445,"garlic64":446,"garlic32":447,"tls":448,"quic":460,"ws":477,"wss":478,"p2p-websocket-star":479,"http":480,"json":512,"messagepack":513,"libp2p-peer-record":769,"sha2-256-trunc254-padded":4114,"ripemd-128":4178,"ripemd-160":4179,"ripemd-256":4180,"ripemd-320":4181,"x11":4352,"p256-pub":4608,"p384-pub":4609,"p521-pub":4610,"ed448-pub":4611,"x448-pub":4612,"ed25519-priv":4864,"kangarootwelve":7425,"sm3-256":21325,"blake2b-8":45569,"blake2b-16":45570,"blake2b-24":45571,"blake2b-32":45572,"blake2b-40":45573,"blake2b-48":45574,"blake2b-56":45575,"blake2b-64":45576,"blake2b-72":45577,"blake2b-80":45578,"blake2b-88":45579,"blake2b-96":45580,"blake2b-104":45581,"blake2b-112":45582,"blake2b-120":45583,"blake2b-128":45584,"blake2b-136":45585,"blake2b-144":45586,"blake2b-152":45587,"blake2b-160":45588,"blake2b-168":45589,"blake2b-176":45590,"blake2b-184":45591,"blake2b-192":45592,"blake2b-200":45593,"blake2b-208":45594,"blake2b-216":45595,"blake2b-224":45596,"blake2b-232":45597,"blake2b-240":45598,"blake2b-248":45599,"blake2b-256":45600,"blake2b-264":45601,"blake2b-272":45602,"blake2b-280":45603,"blake2b-288":45604,"blake2b-296":45605,"blake2b-304":45606,"blake2b-312":45607,"blake2b-320":45608,"blake2b-328":45609,"blake2b-336":45610,"blake2b-344":45611,"blake2b-352":45612,"blake2b-360":45613,"blake2b-368":45614,"blake2b-376":45615,"blake2b-384":45616,"blake2b-392":45617,"blake2b-400":45618,"blake2b-408":45619,"blake2b-416":45620,"blake2b-424":45621,"blake2b-432":45622,"blake2b-440":45623,"blake2b-448":45624,"blake2b-456":45625,"blake2b-464":45626,"blake2b-472":45627,"blake2b-480":45628,"blake2b-488":45629,"blake2b-496":45630,"blake2b-504":45631,"blake2b-512":45632,"blake2s-8":45633,"blake2s-16":45634,"blake2s-24":45635,"blake2s-32":45636,"blake2s-40":45637,"blake2s-48":45638,"blake2s-56":45639,"blake2s-64":45640,"blake2s-72":45641,"blake2s-80":45642,"blake2s-88":45643,"blake2s-96":45644,"blake2s-104":45645,"blake2s-112":45646,"blake2s-120":45647,"blake2s-128":45648,"blake2s-136":45649,"blake2s-144":45650,"blake2s-152":45651,"blake2s-160":45652,"blake2s-168":45653,"blake2s-176":45654,"blake2s-184":45655,"blake2s-192":45656,"blake2s-200":45657,"blake2s-208":45658,"blake2s-216":45659,"blake2s-224":45660,"blake2s-232":45661,"blake2s-240":45662,"blake2s-248":45663,"blake2s-256":45664,"skein256-8":45825,"skein256-16":45826,"skein256-24":45827,"skein256-32":45828,"skein256-40":45829,"skein256-48":45830,"skein256-56":45831,"skein256-64":45832,"skein256-72":45833,"skein256-80":45834,"skein256-88":45835,"skein256-96":45836,"skein256-104":45837,"skein256-112":45838,"skein256-120":45839,"skein256-128":45840,"skein256-136":45841,"skein256-144":45842,"skein256-152":45843,"skein256-160":45844,"skein256-168":45845,"skein256-176":45846,"skein256-184":45847,"skein256-192":45848,"skein256-200":45849,"skein256-208":45850,"skein256-216":45851,"skein256-224":45852,"skein256-232":45853,"skein256-240":45854,"skein256-248":45855,"skein256-256":45856,"skein512-8":45857,"skein512-16":45858,"skein512-24":45859,"skein512-32":45860,"skein512-40":45861,"skein512-48":45862,"skein512-56":45863,"skein512-64":45864,"skein512-72":45865,"skein512-80":45866,"skein512-88":45867,"skein512-96":45868,"skein512-104":45869,"skein512-112":45870,"skein512-120":45871,"skein512-128":45872,"skein512-136":45873,"skein512-144":45874,"skein512-152":45875,"skein512-160":45876,"skein512-168":45877,"skein512-176":45878,"skein512-184":45879,"skein512-192":45880,"skein512-200":45881,"skein512-208":45882,"skein512-216":45883,"skein512-224":45884,"skein512-232":45885,"skein512-240":45886,"skein512-248":45887,"skein512-256":45888,"skein512-264":45889,"skein512-272":45890,"skein512-280":45891,"skein512-288":45892,"skein512-296":45893,"skein512-304":45894,"skein512-312":45895,"skein512-320":45896,"skein512-328":45897,"skein512-336":45898,"skein512-344":45899,"skein512-352":45900,"skein512-360":45901,"skein512-368":45902,"skein512-376":45903,"skein512-384":45904,"skein512-392":45905,"skein512-400":45906,"skein512-408":45907,"skein512-416":45908,"skein512-424":45909,"skein512-432":45910,"skein512-440":45911,"skein512-448":45912,"skein512-456":45913,"skein512-464":45914,"skein512-472":45915,"skein512-480":45916,"skein512-488":45917,"skein512-496":45918,"skein512-504":45919,"skein512-512":45920,"skein1024-8":45921,"skein1024-16":45922,"skein1024-24":45923,"skein1024-32":45924,"skein1024-40":45925,"skein1024-48":45926,"skein1024-56":45927,"skein1024-64":45928,"skein1024-72":45929,"skein1024-80":45930,"skein1024-88":45931,"skein1024-96":45932,"skein1024-104":45933,"skein1024-112":45934,"skein1024-120":45935,"skein1024-128":45936,"skein1024-136":45937,"skein1024-144":45938,"skein1024-152":45939,"skein1024-160":45940,"skein1024-168":45941,"skein1024-176":45942,"skein1024-184":45943,"skein1024-192":45944,"skein1024-200":45945,"skein1024-208":45946,"skein1024-216":45947,"skein1024-224":45948,"skein1024-232":45949,"skein1024-240":45950,"skein1024-248":45951,"skein1024-256":45952,"skein1024-264":45953,"skein1024-272":45954,"skein1024-280":45955,"skein1024-288":45956,"skein1024-296":45957,"skein1024-304":45958,"skein1024-312":45959,"skein1024-320":45960,"skein1024-328":45961,"skein1024-336":45962,"skein1024-344":45963,"skein1024-352":45964,"skein1024-360":45965,"skein1024-368":45966,"skein1024-376":45967,"skein1024-384":45968,"skein1024-392":45969,"skein1024-400":45970,"skein1024-408":45971,"skein1024-416":45972,"skein1024-424":45973,"skein1024-432":45974,"skein1024-440":45975,"skein1024-448":45976,"skein1024-456":45977,"skein1024-464":45978,"skein1024-472":45979,"skein1024-480":45980,"skein1024-488":45981,"skein1024-496":45982,"skein1024-504":45983,"skein1024-512":45984,"skein1024-520":45985,"skein1024-528":45986,"skein1024-536":45987,"skein1024-544":45988,"skein1024-552":45989,"skein1024-560":45990,"skein1024-568":45991,"skein1024-576":45992,"skein1024-584":45993,"skein1024-592":45994,"skein1024-600":45995,"skein1024-608":45996,"skein1024-616":45997,"skein1024-624":45998,"skein1024-632":45999,"skein1024-640":46000,"skein1024-648":46001,"skein1024-656":46002,"skein1024-664":46003,"skein1024-672":46004,"skein1024-680":46005,"skein1024-688":46006,"skein1024-696":46007,"skein1024-704":46008,"skein1024-712":46009,"skein1024-720":46010,"skein1024-728":46011,"skein1024-736":46012,"skein1024-744":46013,"skein1024-752":46014,"skein1024-760":46015,"skein1024-768":46016,"skein1024-776":46017,"skein1024-784":46018,"skein1024-792":46019,"skein1024-800":46020,"skein1024-808":46021,"skein1024-816":46022,"skein1024-824":46023,"skein1024-832":46024,"skein1024-840":46025,"skein1024-848":46026,"skein1024-856":46027,"skein1024-864":46028,"skein1024-872":46029,"skein1024-880":46030,"skein1024-888":46031,"skein1024-896":46032,"skein1024-904":46033,"skein1024-912":46034,"skein1024-920":46035,"skein1024-928":46036,"skein1024-936":46037,"skein1024-944":46038,"skein1024-952":46039,"skein1024-960":46040,"skein1024-968":46041,"skein1024-976":46042,"skein1024-984":46043,"skein1024-992":46044,"skein1024-1000":46045,"skein1024-1008":46046,"skein1024-1016":46047,"skein1024-1024":46048,"poseidon-bls12_381-a2-fc1":46081,"poseidon-bls12_381-a2-fc1-sc":46082,"zeroxcert-imprint-256":52753,"fil-commitment-unsealed":61697,"fil-commitment-sealed":61698,"holochain-adr-v0":8417572,"holochain-adr-v1":8483108,"holochain-key-v0":9728292,"holochain-key-v1":9793828,"holochain-sig-v0":10645796,"holochain-sig-v1":10711332,"skynet-ns":11639056}')},function(e,t,r){"use strict";var n=r(0);n.pki=n.pki||{};var i=e.exports=n.pki.oids=n.oids=n.oids||{};function s(e,t){i[e]=t,i[t]=e}function o(e,t){i[e]=t}s("1.2.840.113549.1.1.1","rsaEncryption"),s("1.2.840.113549.1.1.4","md5WithRSAEncryption"),s("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),s("1.2.840.113549.1.1.7","RSAES-OAEP"),s("1.2.840.113549.1.1.8","mgf1"),s("1.2.840.113549.1.1.9","pSpecified"),s("1.2.840.113549.1.1.10","RSASSA-PSS"),s("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),s("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),s("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),s("1.3.101.112","EdDSA25519"),s("1.2.840.10040.4.3","dsa-with-sha1"),s("1.3.14.3.2.7","desCBC"),s("1.3.14.3.2.26","sha1"),s("2.16.840.1.101.3.4.2.1","sha256"),s("2.16.840.1.101.3.4.2.2","sha384"),s("2.16.840.1.101.3.4.2.3","sha512"),s("1.2.840.113549.2.5","md5"),s("1.2.840.113549.1.7.1","data"),s("1.2.840.113549.1.7.2","signedData"),s("1.2.840.113549.1.7.3","envelopedData"),s("1.2.840.113549.1.7.4","signedAndEnvelopedData"),s("1.2.840.113549.1.7.5","digestedData"),s("1.2.840.113549.1.7.6","encryptedData"),s("1.2.840.113549.1.9.1","emailAddress"),s("1.2.840.113549.1.9.2","unstructuredName"),s("1.2.840.113549.1.9.3","contentType"),s("1.2.840.113549.1.9.4","messageDigest"),s("1.2.840.113549.1.9.5","signingTime"),s("1.2.840.113549.1.9.6","counterSignature"),s("1.2.840.113549.1.9.7","challengePassword"),s("1.2.840.113549.1.9.8","unstructuredAddress"),s("1.2.840.113549.1.9.14","extensionRequest"),s("1.2.840.113549.1.9.20","friendlyName"),s("1.2.840.113549.1.9.21","localKeyId"),s("1.2.840.113549.1.9.22.1","x509Certificate"),s("1.2.840.113549.1.12.10.1.1","keyBag"),s("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),s("1.2.840.113549.1.12.10.1.3","certBag"),s("1.2.840.113549.1.12.10.1.4","crlBag"),s("1.2.840.113549.1.12.10.1.5","secretBag"),s("1.2.840.113549.1.12.10.1.6","safeContentsBag"),s("1.2.840.113549.1.5.13","pkcs5PBES2"),s("1.2.840.113549.1.5.12","pkcs5PBKDF2"),s("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),s("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),s("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),s("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),s("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),s("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),s("1.2.840.113549.2.7","hmacWithSHA1"),s("1.2.840.113549.2.8","hmacWithSHA224"),s("1.2.840.113549.2.9","hmacWithSHA256"),s("1.2.840.113549.2.10","hmacWithSHA384"),s("1.2.840.113549.2.11","hmacWithSHA512"),s("1.2.840.113549.3.7","des-EDE3-CBC"),s("2.16.840.1.101.3.4.1.2","aes128-CBC"),s("2.16.840.1.101.3.4.1.22","aes192-CBC"),s("2.16.840.1.101.3.4.1.42","aes256-CBC"),s("2.5.4.3","commonName"),s("2.5.4.5","serialName"),s("2.5.4.6","countryName"),s("2.5.4.7","localityName"),s("2.5.4.8","stateOrProvinceName"),s("2.5.4.9","streetAddress"),s("2.5.4.10","organizationName"),s("2.5.4.11","organizationalUnitName"),s("2.5.4.13","description"),s("2.5.4.15","businessCategory"),s("2.5.4.17","postalCode"),s("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),s("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),s("2.16.840.1.113730.1.1","nsCertType"),s("2.16.840.1.113730.1.13","nsComment"),o("2.5.29.1","authorityKeyIdentifier"),o("2.5.29.2","keyAttributes"),o("2.5.29.3","certificatePolicies"),o("2.5.29.4","keyUsageRestriction"),o("2.5.29.5","policyMapping"),o("2.5.29.6","subtreesConstraint"),o("2.5.29.7","subjectAltName"),o("2.5.29.8","issuerAltName"),o("2.5.29.9","subjectDirectoryAttributes"),o("2.5.29.10","basicConstraints"),o("2.5.29.11","nameConstraints"),o("2.5.29.12","policyConstraints"),o("2.5.29.13","basicConstraints"),s("2.5.29.14","subjectKeyIdentifier"),s("2.5.29.15","keyUsage"),o("2.5.29.16","privateKeyUsagePeriod"),s("2.5.29.17","subjectAltName"),s("2.5.29.18","issuerAltName"),s("2.5.29.19","basicConstraints"),o("2.5.29.20","cRLNumber"),o("2.5.29.21","cRLReason"),o("2.5.29.22","expirationDate"),o("2.5.29.23","instructionCode"),o("2.5.29.24","invalidityDate"),o("2.5.29.25","cRLDistributionPoints"),o("2.5.29.26","issuingDistributionPoint"),o("2.5.29.27","deltaCRLIndicator"),o("2.5.29.28","issuingDistributionPoint"),o("2.5.29.29","certificateIssuer"),o("2.5.29.30","nameConstraints"),s("2.5.29.31","cRLDistributionPoints"),s("2.5.29.32","certificatePolicies"),o("2.5.29.33","policyMappings"),o("2.5.29.34","policyConstraints"),s("2.5.29.35","authorityKeyIdentifier"),o("2.5.29.36","policyConstraints"),s("2.5.29.37","extKeyUsage"),o("2.5.29.46","freshestCRL"),o("2.5.29.54","inhibitAnyPolicy"),s("1.3.6.1.4.1.11129.2.4.2","timestampList"),s("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),s("1.3.6.1.5.5.7.3.1","serverAuth"),s("1.3.6.1.5.5.7.3.2","clientAuth"),s("1.3.6.1.5.5.7.3.3","codeSigning"),s("1.3.6.1.5.5.7.3.4","emailProtection"),s("1.3.6.1.5.5.7.3.8","timeStamping")},function(e,t,r){"use strict";var n=r(0);function i(e,t){n.cipher.registerAlgorithm(e,(function(){return new n.aes.Algorithm(e,t)}))}r(80),r(81),r(3),e.exports=n.aes=n.aes||{},n.aes.startEncrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!1,mode:n});return i.start(t),i},n.aes.createEncryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!1,mode:t})},n.aes.startDecrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!0,mode:n});return i.start(t),i},n.aes.createDecryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!0,mode:t})},n.aes.Algorithm=function(e,t){f||h();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return l(r._w,e,t,!1)},decrypt:function(e,t){return l(r._w,e,t,!0)}}}),r._init=!1},n.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!=typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(n.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=n.util.createBuffer();for(var i=0;i>>=2;for(i=0;i>8^255&h^99,s[y]=h,o[h]=y,l=(d=e[h])<<24^h<<16^h<<8^h^d,p=((r=e[y])^(n=e[r])^(i=e[n]))<<24^(y^i)<<16^(y^n^i)<<8^y^r^i;for(var b=0;b<4;++b)c[b][y]=l,u[b][h]=p,l=l<<24|l>>>8,p=p<<24|p>>>8;0===y?y=g=1:(y=r^e[e[e[r^i]]],g^=e[e[g]])}}function d(e,t){for(var r,n=e.slice(0),i=1,o=n.length,c=4*(o+6+1),f=o;f>>16&255]<<24^s[r>>>8&255]<<16^s[255&r]<<8^s[r>>>24]^a[i]<<24,i++):o>6&&f%o==4&&(r=s[r>>>24]<<24^s[r>>>16&255]<<16^s[r>>>8&255]<<8^s[255&r]),n[f]=n[f-o]^r;if(t){for(var h,d=u[0],l=u[1],p=u[2],y=u[3],g=n.slice(0),b=(f=0,(c=n.length)-4);f>>24]]^l[s[h>>>16&255]]^p[s[h>>>8&255]]^y[s[255&h]];n=g}return n}function l(e,t,r,n){var i,a,f,h,d,l,p,y,g,b,m,v,w=e.length/4-1;n?(i=u[0],a=u[1],f=u[2],h=u[3],d=o):(i=c[0],a=c[1],f=c[2],h=c[3],d=s),l=t[0]^e[0],p=t[n?3:1]^e[1],y=t[2]^e[2],g=t[n?1:3]^e[3];for(var E=3,S=1;S>>24]^a[p>>>16&255]^f[y>>>8&255]^h[255&g]^e[++E],m=i[p>>>24]^a[y>>>16&255]^f[g>>>8&255]^h[255&l]^e[++E],v=i[y>>>24]^a[g>>>16&255]^f[l>>>8&255]^h[255&p]^e[++E],g=i[g>>>24]^a[l>>>16&255]^f[p>>>8&255]^h[255&y]^e[++E],l=b,p=m,y=v;r[0]=d[l>>>24]<<24^d[p>>>16&255]<<16^d[y>>>8&255]<<8^d[255&g]^e[++E],r[n?3:1]=d[p>>>24]<<24^d[y>>>16&255]<<16^d[g>>>8&255]<<8^d[255&l]^e[++E],r[2]=d[y>>>24]<<24^d[g>>>16&255]<<16^d[l>>>8&255]<<8^d[255&p]^e[++E],r[n?1:3]=d[g>>>24]<<24^d[l>>>16&255]<<16^d[p>>>8&255]<<8^d[255&y]^e[++E]}function p(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var s=null;r instanceof n.util.ByteBuffer&&(s=r,r={}),(r=r||{}).output=s,r.iv=e,i.call(t,r)},t}},function(e,t,r){"use strict";const n=r(26),i=self.crypto||self.msCrypto,s=async(e,t)=>{if("undefined"==typeof self||!self.crypto&&!self.msCrypto)throw new Error("Please use a browser with webcrypto support and ensure the code has been delivered securely via HTTPS/TLS and run within a Secure Context");switch(t){case"sha1":return new Uint8Array(await i.subtle.digest({name:"SHA-1"},e));case"sha2-256":return new Uint8Array(await i.subtle.digest({name:"SHA-256"},e));case"sha2-512":return new Uint8Array(await i.subtle.digest({name:"SHA-512"},e));case"dbl-sha2-256":{const t=await i.subtle.digest({name:"SHA-256"},e);return new Uint8Array(await i.subtle.digest({name:"SHA-256"},t))}default:throw new Error(t+" is not a supported algorithm")}};e.exports={factory:e=>async t=>s(t,e),digest:s,multihashing:async(e,t,r)=>{const i=await s(e,t);return n.encode(i,t,r)}}},function(e,t,r){"use strict";var n=r(16),i=r(22);function s(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=s,s.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,s=8;s1)for(var r=1;r(e[o[t]]=t,e),{});class l{constructor(e,t,r,o){if(p.isCID(e)){const t=e;return this.version=t.version,this.codec=t.codec,this.multihash=t.multihash,void(this.multibaseName=t.multibaseName||(0===t.version?"base58btc":"base32"))}if("string"==typeof e){const t=i.isEncoded(e);if(t){const r=i.decode(e);this.version=parseInt(r.slice(0,1).toString("hex"),16),this.codec=s.getCodec(r.slice(1)),this.multihash=s.rmPrefix(r.slice(1)),this.multibaseName=t}else this.version=0,this.codec="dag-pb",this.multihash=n.fromB58String(e),this.multibaseName="base58btc";return l.validateCID(this),void Object.defineProperty(this,"string",{value:e})}if(e instanceof Uint8Array){const t=e.slice(0,1),r=parseInt(t.toString("hex"),16);if(1===r){const t=e;this.version=r,this.codec=s.getCodec(t.slice(1)),this.multihash=s.rmPrefix(t.slice(1)),this.multibaseName="base32"}else this.version=0,this.codec="dag-pb",this.multihash=e,this.multibaseName="base58btc";l.validateCID(this)}else this.version=e,"number"==typeof t&&(t=d[t]),this.codec=t,this.multihash=r,this.multibaseName=o||(0===e?"base58btc":"base32"),l.validateCID(this)}get bytes(){let e=this._bytes;if(!e){if(0===this.version)e=this.multihash;else{if(1!==this.version)throw new Error("unsupported version");{const t=s.getCodeVarint(this.codec);e=u([[1],t,this.multihash],1+t.byteLength+this.multihash.byteLength)}}Object.defineProperty(this,"_bytes",{value:e})}return e}get prefix(){const e=s.getCodeVarint(this.codec),t=n.prefix(this.multihash);return u([[this.version],e,t],1+e.byteLength+t.byteLength)}get code(){return o[this.codec]}toV0(){if("dag-pb"!==this.codec)throw new Error("Cannot convert a non dag-pb CID to CIDv0");const{name:e,length:t}=n.decode(this.multihash);if("sha2-256"!==e)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");if(32!==t)throw new Error("Cannot convert non 32 byte multihash CID to CIDv0");return new p(0,this.codec,this.multihash)}toV1(){return new p(1,this.codec,this.multihash)}toBaseEncodedString(e=this.multibaseName){if(this.string&&e===this.multibaseName)return this.string;let t=null;if(0===this.version){if("base58btc"!==e)throw new Error("not supported with CIDv0, to support different bases, please migrate the instance do CIDv1, you can do that through cid.toV1()");t=n.toB58String(this.multihash)}else{if(1!==this.version)throw new Error("unsupported version");t=f(i.encode(e,this.bytes))}return e===this.multibaseName&&Object.defineProperty(this,"string",{value:t}),t}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}toString(e){return this.toBaseEncodedString(e)}toJSON(){return{codec:this.codec,version:this.version,hash:this.multihash}}equals(e){return this.codec===e.codec&&this.version===e.version&&h(this.multihash,e.multihash)}static validateCID(e){const t=a.checkCIDComponents(e);if(t)throw new Error(t)}}const p=c(l,{className:"CID",symbolName:"@ipld/js-cid/CID"});p.codecs=o,e.exports=p},function(e,t,r){"use strict";e.exports=function(e,{className:t,symbolName:r}){const n=Symbol.for(r),i={[t]:class extends e{constructor(...e){super(...e),Object.defineProperty(this,n,{value:!0})}get[Symbol.toStringTag](){return t}}}[t];return i["is"+t]=e=>!(!e||!e[n]),i},e.exports.proto=function(e,{className:t,symbolName:r,withoutNew:n}){const i=Symbol.for(r),s={[t]:function(...t){if(n&&!(this instanceof s))return new s(...t);const r=e.call(this,...t)||this;return r&&!r[i]&&Object.defineProperty(r,i,{value:!0}),r}}[t];return s.prototype=Object.create(e.prototype),s.prototype.constructor=s,Object.defineProperty(s.prototype,Symbol.toStringTag,{get:()=>t}),s["is"+t]=e=>!(!e||!e[i]),s}},function(e,t,r){"use strict";var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(i){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,r){"use strict";var n=r(0);if(r(18),r(40),r(28),r(179),r(181),r(21),r(3),void 0===i)var i=n.jsbn.BigInteger;var s=n.util.isNodejs?r(56):null,o=n.asn1,a=n.util;n.pki=n.pki||{},e.exports=n.pki.rsa=n.rsa=n.rsa||{};var c=n.pki,u=[6,4,2,4,2,4,6,2],f={name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},h={name:"RSAPrivateKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},d={name:"RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},l=n.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},p=function(e){var t;if(!(e.algorithm in c.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=c.oids[e.algorithm];var n=o.oidToDer(t).getBytes(),i=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),s=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]);s.value.push(o.create(o.Class.UNIVERSAL,o.Type.OID,!1,n)),s.value.push(o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,""));var a=o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(s),i.value.push(a),o.toDer(i).getBytes()},y=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var s;t.dP||(t.dP=t.d.mod(t.p.subtract(i.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(i.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{s=new i(n.util.bytesToHex(n.random.getBytes(t.n.bitLength()/8)),16)}while(s.compareTo(t.n)>=0||!s.gcd(t.n).equals(i.ONE));for(var o=(e=e.multiply(s.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),a=e.mod(t.q).modPow(t.dQ,t.q);o.compareTo(a)<0;)o=o.add(t.p);var c=o.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return c=c.multiply(s.modInverse(t.n)).mod(t.n)};function g(e,t,r){var i=n.util.createBuffer(),s=Math.ceil(t.n.bitLength()/8);if(e.length>s-11){var o=new Error("Message is too long for PKCS#1 v1.5 padding.");throw o.length=e.length,o.max=s-11,o}i.putByte(0),i.putByte(r);var a,c=s-3-e.length;if(0===r||1===r){a=0===r?0:255;for(var u=0;u0;){var f=0,h=n.random.getBytes(c);for(u=0;u1;){if(255!==o.getByte()){--o.read;break}++u}else if(2===c)for(u=0;o.length()>1;){if(0===o.getByte()){--o.read;break}++u}if(0!==o.getByte()||u!==s-3-o.length())throw new Error("Encryption block is invalid.");return o.getBytes()}function m(e,t,r){"function"==typeof t&&(r=t,t={});var s={algorithm:{name:(t=t||{}).algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};function o(){a(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?u(t,e.q):void a(e.qBits,u))}))}function a(e,t){n.prime.generateProbablePrime(e,s,t)}function u(t,n){if(t)return r(t);if(e.q=n,e.p.compareTo(e.q)<0){var s=e.p;e.p=e.q,e.q=s}if(0!==e.p.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.p=null,void o();if(0!==e.q.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.q=null,void a(e.qBits,u);if(e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(i.ONE))return e.p=e.q=null,void o();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void a(e.qBits,u);var f=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,f,e.p,e.q,f.mod(e.p1),f.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}"prng"in t&&(s.prng=t.prng),o()}function v(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=n.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0==(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128==(128&r.charCodeAt(1)))?r.substr(1):r}function w(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function E(e){return n.util.isNodejs&&"function"==typeof s[e]}function S(e){return void 0!==a.globalScope&&"object"==typeof a.globalScope.crypto&&"object"==typeof a.globalScope.crypto.subtle&&"function"==typeof a.globalScope.crypto.subtle[e]}function A(e){return void 0!==a.globalScope&&"object"==typeof a.globalScope.msCrypto&&"object"==typeof a.globalScope.msCrypto.subtle&&"function"==typeof a.globalScope.msCrypto.subtle[e]}function _(e){for(var t=n.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),i=0;i0;)f.putByte(0),--h;return f.putBytes(n.util.hexToBytes(u)),f.getBytes()},c.rsa.decrypt=function(e,t,r,s){var o=Math.ceil(t.n.bitLength()/8);if(e.length!==o){var a=new Error("Encrypted message length is invalid.");throw a.length=e.length,a.expected=o,a}var c=new i(n.util.createBuffer(e).toHex(),16);if(c.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var u=y(c,t,r).toString(16),f=n.util.createBuffer(),h=o-Math.ceil(u.length/2);h>0;)f.putByte(0),--h;return f.putBytes(n.util.hexToBytes(u)),!1!==s?b(f.getBytes(),t,r):f.getBytes()},c.rsa.createKeyPairGenerationState=function(e,t,r){"string"==typeof e&&(e=parseInt(e,10)),e=e||2048;var s,o=(r=r||{}).prng||n.random,a={nextBytes:function(e){for(var t=o.getBytesSync(e.length),r=0;r>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(s.eInt),s},c.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new i(null);r.fromInt(30);for(var n,s=0,o=function(e,t){return e|t},a=+new Date,f=0;null===e.keys&&(t<=0||fh?e.pqState=0:e.num.isProbablePrime(w(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(u[s++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(i.ONE).gcd(e.e).compareTo(i.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(i.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var l=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)}}f+=(n=+new Date)-a,a=n}return null!==e.keys},c.rsa.generateKeyPair=function(e,t,r,i){if(1===arguments.length?"object"==typeof e?(r=e,e=void 0):"function"==typeof e&&(i=e,e=void 0):2===arguments.length?"number"==typeof e?"function"==typeof t?(i=t,t=void 0):"number"!=typeof t&&(r=t,t=void 0):(r=e,i=t,e=void 0,t=void 0):3===arguments.length&&("number"==typeof t?"function"==typeof r&&(i=r,r=void 0):(i=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!n.options.usePureJavaScript&&!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(i){if(E("generateKeyPair"))return s.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return i(e);i(null,{privateKey:c.privateKeyFromPem(r),publicKey:c.publicKeyFromPem(t)})}));if(S("generateKey")&&S("exportKey"))return a.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:_(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return a.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){i(e)})).then((function(e){if(e){var t=c.privateKeyFromAsn1(o.fromDer(n.util.createBuffer(e)));i(null,{privateKey:t,publicKey:c.setRsaPublicKey(t.n,t.e)})}}));if(A("generateKey")&&A("exportKey")){var u=a.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:_(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return u.oncomplete=function(e){var t=e.target.result,r=a.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=c.privateKeyFromAsn1(o.fromDer(n.util.createBuffer(t)));i(null,{privateKey:r,publicKey:c.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){i(e)}},void(u.onerror=function(e){i(e)})}}else if(E("generateKeyPairSync")){var f=s.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:c.privateKeyFromPem(f.privateKey),publicKey:c.publicKeyFromPem(f.publicKey)}}var h=c.rsa.createKeyPairGenerationState(e,t,r);if(!i)return c.rsa.stepKeyPairGenerationState(h,0),h.keys;m(h,r,i)},c.setRsaPublicKey=c.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,i){if("string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return g(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return n.pkcs1.encode_rsa_oaep(t,e,i)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"==typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var s=t.encode(e,r,!0);return c.rsa.encrypt(s,r,!0)},verify:function(e,t,n){"string"==typeof n?n=n.toUpperCase():void 0===n&&(n="RSASSA-PKCS1-V1_5"),"RSASSA-PKCS1-V1_5"===n?n={verify:function(e,t){return t=b(t,r,!0),e===o.fromDer(t).value[1].value}}:"NONE"!==n&&"NULL"!==n&&null!==n||(n={verify:function(e,t){return e===(t=b(t,r,!0))}});var i=c.rsa.decrypt(t,r,!0,!1);return n.verify(e,i,r.n.bitLength())}};return r},c.setRsaPrivateKey=c.rsa.setPrivateKey=function(e,t,r,i,s,o,a,u){var f={n:e,e:t,d:r,p:i,q:s,dP:o,dQ:a,qInv:u,decrypt:function(e,t,r){"string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var i=c.rsa.decrypt(e,f,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:b};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return n.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(i,f,!1)},sign:function(e,t){var r=!1;"string"==typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:p},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,f.n.bitLength());return c.rsa.encrypt(n,f,r)}};return f},c.wrapRsaPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,o.toDer(e).getBytes())])},c.privateKeyFromAsn1=function(e){var t,r,s,a,u,d,l,p,y={},g=[];if(o.validate(e,f,y,g)&&(e=o.fromDer(n.util.createBuffer(y.privateKey))),y={},g=[],!o.validate(e,h,y,g)){var b=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw b.errors=g,b}return t=n.util.createBuffer(y.privateKeyModulus).toHex(),r=n.util.createBuffer(y.privateKeyPublicExponent).toHex(),s=n.util.createBuffer(y.privateKeyPrivateExponent).toHex(),a=n.util.createBuffer(y.privateKeyPrime1).toHex(),u=n.util.createBuffer(y.privateKeyPrime2).toHex(),d=n.util.createBuffer(y.privateKeyExponent1).toHex(),l=n.util.createBuffer(y.privateKeyExponent2).toHex(),p=n.util.createBuffer(y.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new i(t,16),new i(r,16),new i(s,16),new i(a,16),new i(u,16),new i(d,16),new i(l,16),new i(p,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.e)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.d)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.p)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.q)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.dP)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.dQ)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.qInv))])},c.publicKeyFromAsn1=function(e){var t={},r=[];if(o.validate(e,l,t,r)){var s,a=o.derToOid(t.publicKeyOid);if(a!==c.oids.rsaEncryption)throw(s=new Error("Cannot read public key. Unknown OID.")).oid=a,s;e=t.rsaPublicKey}if(r=[],!o.validate(e,d,t,r))throw(s=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,s;var u=n.util.createBuffer(t.publicKeyModulus).toHex(),f=n.util.createBuffer(t.publicKeyExponent).toHex();return c.setRsaPublicKey(new i(u,16),new i(f,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(e)])])},c.publicKeyToRSAPublicKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.e))])}},function(e,t,r){"use strict";var n,i=r(0);e.exports=i.jsbn=i.jsbn||{};function s(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function o(){return new s(null)}function a(e,t,r,n,i,s){for(var o=16383&t,a=t>>14;--s>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,f=a*c+u*o;i=((c=o*c+((16383&f)<<14)+r.data[n]+i)>>28)+(f>>14)+a*u,r.data[n++]=268435455&c}return i}i.jsbn.BigInteger=s,"undefined"==typeof navigator?(s.prototype.am=a,n=28):"Microsoft Internet Explorer"==navigator.appName?(s.prototype.am=function(e,t,r,n,i,s){for(var o=32767&t,a=t>>15;--s>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,f=a*c+u*o;i=((c=o*c+((32767&f)<<15)+r.data[n]+(1073741823&i))>>>30)+(f>>>15)+a*u+(i>>>30),r.data[n++]=1073741823&c}return i},n=30):"Netscape"!=navigator.appName?(s.prototype.am=function(e,t,r,n,i,s){for(;--s>=0;){var o=t*this.data[e++]+r.data[n]+i;i=Math.floor(o/67108864),r.data[n++]=67108863&o}return i},n=26):(s.prototype.am=a,n=28),s.prototype.DB=n,s.prototype.DM=(1<>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function y(e){this.m=e}function g(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function S(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function A(){}function _(e){return e}function C(e){this.r2=o(),this.q3=o(),s.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}y.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},y.prototype.revert=function(e){return e},y.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},y.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},y.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},g.prototype.convert=function(e){var t=o();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(s.ZERO)>0&&this.m.subTo(t,t),t},g.prototype.revert=function(e){var t=o();return e.copyTo(t),this.reduce(t),t},g.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},g.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},g.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},s.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},s.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},s.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,o=0;--n>=0;){var a=8==r?255&e[n]:d(e,n);a<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==o?this.data[this.t++]=a:o+r>this.DB?(this.data[this.t-1]|=(a&(1<>this.DB-o):this.data[this.t-1]|=a<=this.DB&&(o-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,o>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==e;)--this.t},s.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},s.prototype.drShiftTo=function(e,t){for(var r=e;r=0;--r)t.data[r+o+1]=this.data[r]>>i|a,a=(this.data[r]&s)<=0;--r)t.data[r]=0;t.data[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()},s.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,s=(1<>n;for(var o=r+1;o>n;n>0&&(t.data[this.t-r-1]|=(this.s&s)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},s.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t.data[i]=0;for(i=0;i=0;)e.data[r]=0;for(r=0;r=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},s.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(f,a),i.lShiftTo(f,r)):(n.copyTo(a),i.copyTo(r));var h=a.t,d=a.data[h-1];if(0!=d){var l=d*(1<1?a.data[h-2]>>this.F2:0),y=this.FV/l,g=(1<=0&&(r.data[r.t++]=1,r.subTo(w,r)),s.ONE.dlShiftTo(h,w),w.subTo(a,a);a.t=0;){var E=r.data[--m]==d?this.DM:Math.floor(r.data[m]*y+(r.data[m-1]+b)*g);if((r.data[m]+=a.am(0,E,r,v,0,h))0&&r.rShiftTo(f,r),c<0&&s.ZERO.subTo(r,r)}}},s.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},s.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},s.prototype.exp=function(e,t){if(e>4294967295||e<1)return s.ONE;var r=o(),n=o(),i=t.convert(this),a=p(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var c=r;r=n,n=c}return t.revert(r)},s.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<0)for(a>a)>0&&(i=!0,s=h(r));o>=0;)a>(a+=this.DB-t)):(r=this.data[o]>>(a-=t)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=h(r));return i?s:"0"},s.prototype.negate=function(){var e=o();return s.ZERO.subTo(this,e),e},s.prototype.abs=function(){return this.s<0?this.negate():this},s.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},s.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+p(this.data[this.t-1]^this.s&this.DM)},s.prototype.mod=function(e){var t=o();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(s.ZERO)>0&&e.subTo(t,t),t},s.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new y(t):new g(t),this.exp(e,r)},s.ZERO=l(0),s.ONE=l(1),A.prototype.convert=_,A.prototype.revert=_,A.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},A.prototype.sqrTo=function(e,t){e.squareTo(t)},C.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=o();return e.copyTo(t),this.reduce(t),t},C.prototype.revert=function(e){return e},C.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},C.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},C.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var k=[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],I=(1<<26)/k[k.length-1];s.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},s.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=l(r),i=o(),s=o(),a="";for(this.divRemTo(n,i,s);i.signum()>0;)a=(r+s.intValue()).toString(e).substr(1)+a,i.divRemTo(n,i,s);return s.intValue().toString(e)+a},s.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,o=0,a=0,c=0;c=r&&(this.dMultiply(n),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(a,0)),i&&s.ZERO.subTo(this,this)},s.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(s.ONE.shiftLeft(e-1),m,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(s.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},s.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},s.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},s.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},s.prototype.millerRabin=function(e){var t=this.subtract(s.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n,i=t.shiftRight(r),o={nextBytes:function(e){for(var t=0;t=0);var c=n.modPow(i,this);if(0!=c.compareTo(s.ONE)&&0!=c.compareTo(t)){for(var u=1;u++>24},s.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},s.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},s.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<=0;)n<8?(r=(this.data[e]&(1<>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},s.prototype.equals=function(e){return 0==this.compareTo(e)},s.prototype.min=function(e){return this.compareTo(e)<0?this:e},s.prototype.max=function(e){return this.compareTo(e)>0?this:e},s.prototype.and=function(e){var t=o();return this.bitwiseTo(e,b,t),t},s.prototype.or=function(e){var t=o();return this.bitwiseTo(e,m,t),t},s.prototype.xor=function(e){var t=o();return this.bitwiseTo(e,v,t),t},s.prototype.andNot=function(e){var t=o();return this.bitwiseTo(e,w,t),t},s.prototype.not=function(){for(var e=o(),t=0;t=this.t?0!=this.s:0!=(this.data[t]&1<1){var h=o();for(n.sqrTo(a[1],h);c<=f;)a[c]=o(),n.mulTo(h,a[c-2],a[c]),c+=2}var d,b,m=e.t-1,v=!0,w=o();for(i=p(e.data[m])-1;m>=0;){for(i>=u?d=e.data[m]>>i-u&f:(d=(e.data[m]&(1<0&&(d|=e.data[m-1]>>this.DB+i-u)),c=r;0==(1&d);)d>>=1,--c;if((i-=c)<0&&(i+=this.DB,--m),v)a[d].copyTo(s),v=!1;else{for(;c>1;)n.sqrTo(s,w),n.sqrTo(w,s),c-=2;c>0?n.sqrTo(s,w):(b=s,s=w,w=b),n.mulTo(w,a[d],s)}for(;m>=0&&0==(e.data[m]&1<=0?(r.subTo(n,r),t&&i.subTo(a,i),o.subTo(c,o)):(n.subTo(r,n),t&&a.subTo(i,a),c.subTo(o,c))}return 0!=n.compareTo(s.ONE)?s.ZERO:c.compareTo(e)>=0?c.subtract(e):c.signum()<0?(c.addTo(e,c),c.signum()<0?c.add(e):c):c},s.prototype.pow=function(e){return this.exp(e,new A)},s.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return t;for(i0&&(t.rShiftTo(s,t),r.rShiftTo(s,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},s.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=k[k.length-1]){for(t=0;t{const t=e.crypto||e.msCrypto;if(!t||!t.subtle)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p-crypto/blob/master/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return t}},function(e,t,r){"use strict";var n=r(17),i=r(12),s=i.getNAF,o=i.getJSF,a=i.assert;function c(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(e,t){a(e.precomputed);var r=e._getDoubles(),n=s(t,1,this._bitLength),i=(1<=c;t--)u=(u<<1)+n[t];o.push(u)}for(var f=this.jpoint(null,null,null),h=this.jpoint(null,null,null),d=i;d>0;d--){for(c=0;c=0;u--){for(t=0;u>=0&&0===o[u];u--)t++;if(u>=0&&t++,c=c.dblp(t),u<0)break;var f=o[u];a(0!==f),c="affine"===e.type?f>0?c.mixedAdd(i[f-1>>1]):c.mixedAdd(i[-f-1>>1].neg()):f>0?c.add(i[f-1>>1]):c.add(i[-f-1>>1].neg())}return"affine"===e.type?c.toP():c},c.prototype._wnafMulAdd=function(e,t,r,n,i){for(var a=this._wnafT1,c=this._wnafT2,u=this._wnafT3,f=0,h=0;h=1;h-=2){var l=h-1,p=h;if(1===a[l]&&1===a[p]){var y=[t[l],null,null,t[p]];0===t[l].y.cmp(t[p].y)?(y[1]=t[l].add(t[p]),y[2]=t[l].toJ().mixedAdd(t[p].neg())):0===t[l].y.cmp(t[p].y.redNeg())?(y[1]=t[l].toJ().mixedAdd(t[p]),y[2]=t[l].add(t[p].neg())):(y[1]=t[l].toJ().mixedAdd(t[p]),y[2]=t[l].toJ().mixedAdd(t[p].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],b=o(r[l],r[p]);f=Math.max(b[0].length,f),u[l]=new Array(f),u[p]=new Array(f);for(var m=0;m=0;h--){for(var A=0;h>=0;){var _=!0;for(m=0;m=0&&A++,E=E.dblp(A),h<0)break;for(m=0;m0?C=c[m][k-1>>1]:k<0&&(C=c[m][-k-1>>1].neg()),E="affine"===C.type?E.mixedAdd(C):E.add(C))}}for(h=0;h=Math.ceil((e.bitLength()+1)/t.step)},u.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i{const t=s.apply(null,e);n.codes[t.code]=t,n.names[t.name]=t}),n.object=s,e.exports=n},function(e,t,r){"use strict";const n=r(236),{hasOwnProperty:i}=Object.prototype,{propertyIsEnumerable:s}=Object,o=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),a={concatArrays:!1,ignoreUndefined:!1},c=e=>{const t=[];for(const r in e)i.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(const n of r)s.call(e,n)&&t.push(n)}return t};function u(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return c(e).forEach(r=>{o(t,r,u(e[r]))}),t}(e):n(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return c(e).forEach(r=>{o(t,r,u(e[r]))}),t}(e):e}const f=(e,t,r,n)=>(r.forEach(r=>{void 0===t[r]&&n.ignoreUndefined||(r in e&&e[r]!==Object.getPrototypeOf(e)?o(e,r,h(e[r],t[r],n)):o(e,r,u(t[r])))}),e);function h(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?((e,t,r)=>{let n=e.slice(0,0),s=0;return[e,t].forEach(t=>{const a=[];for(let r=0;r!a.includes(e)),r)}),n})(e,t,r):n(t)&&n(e)?f(e,t,c(t),r):u(t)}e.exports=function(...e){const t=h(u(a),void 0!==this&&this||{},a);let r={_:{}};for(const i of e)if(void 0!==i){if(!n(i))throw new TypeError("`"+i+"` is not an Option Object");r=h(r,{_:i},t)}return r._}},function(e,t,r){"use strict";e.exports={relay:"/libp2p/circuit/relay/0.1.0"}},function(e,t,r){"use strict";const n=r(108),i=r(278),s=r(110);e.exports=e=>{const t=i(),r=n(e.source),o=s();let a;const c=e.sink(async function*(){yield*t;const e=await o.promise;yield*e}());c.catch(e=>{a=e});return{reader:r,writer:t,stream:{sink:e=>a?Promise.reject(a):(o.resolve(e),c),source:r},rest:()=>t.end(),write:t.push,read:async()=>(await r.next()).value}}},function(e,t,r){"use strict";const n=r(1),i=r(6),{codes:{ERR_INVALID_PARAMETERS:s}}=r(7),o=e=>e;e.exports=class{constructor({peerStore:e,eventName:t,eventProperty:r,eventTransformer:n=o}){this._ps=e,this.eventName=t,this.eventProperty=r,this.eventTransformer=n,this.data=new Map}set(e,t){throw n(new Error("set must be implemented by the subclass"),"ERR_NOT_IMPLEMENTED")}_setData(e,t,{emit:r=!0}={}){const n=e.toB58String();this.data.set(n,t),r&&this._emit(e,t)}_emit(e,t){this._ps.emit(this.eventName,{peerId:e,[this.eventProperty]:this.eventTransformer(t)})}get(e){if(!i.isPeerId(e))throw n(new Error("peerId must be an instance of peer-id"),s);const t=this.data.get(e.toB58String());return t?[...t]:void 0}delete(e){if(!i.isPeerId(e))throw n(new Error("peerId must be an instance of peer-id"),s);return!!this.data.delete(e.toB58String())&&(this._emit(e,[]),!0)}}},function(e,t,r){"use strict";const n=r(130),i=r(131),{rfc4648:s}=r(132),{decodeText:o,encodeText:a}=r(50),c=[["identity","\0",()=>({encode:o,decode:a}),""],["base2","0",s(1),"01"],["base8","7",s(3),"01234567"],["base10","9",n,"0123456789"],["base16","f",s(4),"0123456789abcdef"],["base16upper","F",s(4),"0123456789ABCDEF"],["base32hex","v",s(5),"0123456789abcdefghijklmnopqrstuv"],["base32hexupper","V",s(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV"],["base32hexpad","t",s(5),"0123456789abcdefghijklmnopqrstuv="],["base32hexpadupper","T",s(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV="],["base32","b",s(5),"abcdefghijklmnopqrstuvwxyz234567"],["base32upper","B",s(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],["base32pad","c",s(5),"abcdefghijklmnopqrstuvwxyz234567="],["base32padupper","C",s(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="],["base32z","h",s(5),"ybndrfg8ejkmcpqxot1uwisza345h769"],["base36","k",n,"0123456789abcdefghijklmnopqrstuvwxyz"],["base36upper","K",n,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["base58btc","z",n,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base58flickr","Z",n,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base64","m",s(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",s(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",s(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",s(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],u=c.reduce((e,t)=>(e[t[0]]=new i(t[0],t[1],t[2],t[3]),e),{}),f=c.reduce((e,t)=>(e[t[1]]=u[t[0]],e),{});e.exports={names:u,codes:f}},function(e,t,r){"use strict";const{TextEncoder:n,TextDecoder:i}=r(51),s=new i,o=new n;e.exports={decodeText:e=>s.decode(e),encodeText:e=>o.encode(e),concat:function(e,t){const r=new Uint8Array(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}}},function(e,t,r){"use strict";t.TextEncoder=TextEncoder,t.TextDecoder=TextDecoder},function(e,t,r){"use strict";const n=r(15)(r(54));r(18),r(79);const i=r(0),s=r(1),o=r(5),a=r(182);t=e.exports;const c={rsa:r(183),ed25519:r(189),secp256k1:r(191)(n,r(59))};t.supportedKeys=c,t.keysPBM=n;const u="secp256k1 support requires libp2p-crypto-secp256k1 package",f="ERR_MISSING_PACKAGE";function h(e){const t=c[e.toLowerCase()];if(!t){const t=Object.keys(c).join(" / ");throw s(new Error(`invalid or unsupported key type ${e}. Must be ${t}`),"ERR_UNSUPPORTED_KEY_TYPE")}return t}t.keyStretcher=r(218),t.generateEphemeralKeyPair=r(220),t.generateKeyPair=async(e,t)=>h(e).generateKeyPair(t),t.generateKeyPairFromSeed=async(e,t,r)=>{const n=h(e);if("ed25519"!==e.toLowerCase())throw s(new Error("Seed key derivation is unimplemented for RSA or secp256k1"),"ERR_UNSUPPORTED_KEY_DERIVATION_TYPE");return n.generateKeyPairFromSeed(t,r)},t.unmarshalPublicKey=e=>{const t=n.PublicKey.decode(e),r=t.Data;switch(t.Type){case n.KeyType.RSA:return c.rsa.unmarshalRsaPublicKey(r);case n.KeyType.Ed25519:return c.ed25519.unmarshalEd25519PublicKey(r);case n.KeyType.Secp256k1:if(c.secp256k1)return c.secp256k1.unmarshalSecp256k1PublicKey(r);throw s(new Error(u),f);default:h(t.Type)}},t.marshalPublicKey=(e,t)=>(h(t=(t||"rsa").toLowerCase()),e.bytes),t.unmarshalPrivateKey=async e=>{const t=n.PrivateKey.decode(e),r=t.Data;switch(t.Type){case n.KeyType.RSA:return c.rsa.unmarshalRsaPrivateKey(r);case n.KeyType.Ed25519:return c.ed25519.unmarshalEd25519PrivateKey(r);case n.KeyType.Secp256k1:if(c.secp256k1)return c.secp256k1.unmarshalSecp256k1PrivateKey(r);throw s(new Error(u),f);default:h(t.Type)}},t.marshalPrivateKey=(e,t)=>(h(t=(t||"rsa").toLowerCase()),e.bytes),t.import=async(e,r)=>{try{const n=await a.import(e,r);return t.unmarshalPrivateKey(n)}catch(f){}const n=i.pki.decryptRsaPrivateKey(e,r);if(null===n)throw s(new Error("Cannot read the key, most likely the password is wrong or not a RSA key"),"ERR_CANNOT_DECRYPT_PEM");let u=i.asn1.toDer(i.pki.privateKeyToAsn1(n));return u=o(u.getBytes(),"ascii"),c.rsa.unmarshalRsaPrivateKey(u)}},function(e,t,r){"use strict";t.defined=function(e){return null!=e&&("number"!=typeof e||!isNaN(e))}},function(e,t,r){"use strict";e.exports="enum KeyType {\n RSA = 0;\n Ed25519 = 1;\n Secp256k1 = 2;\n}\nmessage PublicKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}\nmessage PrivateKey {\n required KeyType Type = 1;\n required bytes Data = 2;\n}"},function(e,t,r){"use strict";var n=r(0);function i(e,t){n.cipher.registerAlgorithm(e,(function(){return new n.des.Algorithm(e,t)}))}r(80),r(81),r(3),e.exports=n.des=n.des||{},n.des.startEncrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createEncryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!1,mode:t})},n.des.startDecrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createDecryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!0,mode:t})},n.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return l(r._keys,e,t,!1)},decrypt:function(e,t){return l(r._keys,e,t,!0)}}}),r._init=!1},n.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=n.util.createBuffer(e.key);if(0===this.name.indexOf("3DES")&&24!==t.length())throw new Error("Invalid Triple-DES key size: "+8*t.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],i=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],s=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],o=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],a=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],c=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],f=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],h=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],d=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],l=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],y=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],g=e.length()>8?3:1,b=[],m=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],v=0,w=0;w>>4^S))<<4,E^=t=65535&((S^=t)>>>-16^E),E^=(t=858993459&(E>>>2^(S^=t<<-16)))<<2,E^=t=65535&((S^=t)>>>-16^E),E^=(t=1431655765&(E>>>1^(S^=t<<-16)))<<1,E^=t=16711935&((S^=t)>>>8^E),t=(E^=(t=1431655765&(E>>>1^(S^=t<<8)))<<1)<<8|(S^=t)>>>20&240,E=S<<24|S<<8&16711680|S>>>8&65280|S>>>24&240,S=t;for(var A=0;A>>26,S=S<<2|S>>>26):(E=E<<1|E>>>27,S=S<<1|S>>>27);var _=r[(E&=-15)>>>28]|n[E>>>24&15]|i[E>>>20&15]|s[E>>>16&15]|o[E>>>12&15]|a[E>>>8&15]|c[E>>>4&15],C=u[(S&=-15)>>>28]|f[S>>>24&15]|h[S>>>20&15]|d[S>>>16&15]|l[S>>>12&15]|p[S>>>8&15]|y[S>>>4&15];t=65535&(C>>>16^_),b[v++]=_^t,b[v++]=C^t<<16}}return b}(t),this._init=!0}},i("DES-ECB",n.cipher.modes.ecb),i("DES-CBC",n.cipher.modes.cbc),i("DES-CFB",n.cipher.modes.cfb),i("DES-OFB",n.cipher.modes.ofb),i("DES-CTR",n.cipher.modes.ctr),i("3DES-ECB",n.cipher.modes.ecb),i("3DES-CBC",n.cipher.modes.cbc),i("3DES-CFB",n.cipher.modes.cfb),i("3DES-OFB",n.cipher.modes.ofb),i("3DES-CTR",n.cipher.modes.ctr);var s=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],o=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],a=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],c=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],u=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],f=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],h=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],d=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function l(e,t,r,n){var i,l,p=32===e.length?3:9;i=3===p?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var y=t[0],g=t[1];y^=(l=252645135&(y>>>4^g))<<4,y^=(l=65535&(y>>>16^(g^=l)))<<16,y^=l=858993459&((g^=l)>>>2^y),y^=l=16711935&((g^=l<<2)>>>8^y),y=(y^=(l=1431655765&(y>>>1^(g^=l<<8)))<<1)<<1|y>>>31,g=(g^=l)<<1|g>>>31;for(var b=0;b>>4|g<<28)^e[w+1];l=y,y=g,g=l^(o[E>>>24&63]|c[E>>>16&63]|f[E>>>8&63]|d[63&E]|s[S>>>24&63]|a[S>>>16&63]|u[S>>>8&63]|h[63&S])}l=y,y=g,g=l}g=g>>>1|g<<31,g^=l=1431655765&((y=y>>>1|y<<31)>>>1^g),g^=(l=16711935&(g>>>8^(y^=l<<1)))<<8,g^=(l=858993459&(g>>>2^(y^=l)))<<2,g^=l=65535&((y^=l)>>>16^g),g^=l=252645135&((y^=l<<16)>>>4^g),y^=l<<4,r[0]=y,r[1]=g}function p(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var s=null;r instanceof n.util.ByteBuffer&&(s=r,r={}),(r=r||{}).output=s,r.iv=e,i.call(t,r)},t}},function(e,t){},function(e,t,r){"use strict";var n=r(0);r(3);var i=e.exports=n.pem=n.pem||{};function s(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},i=0;i65&&-1!==o){var a=t[o];","===a?(++o,t=t.substr(0,o)+"\r\n "+t.substr(o)):t=t.substr(0,o)+"\r\n"+a+t.substr(o+1),s=i-o-1,o=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(o=i);return t}function o(e){return e.replace(/^\s+/,"")}i.encode=function(e,t){t=t||{};var r,i="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(i+=s(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(i+=s(r={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),i+=s(r)),e.headers)for(var o=0;o>>0,o>>>0];for(var a=l.fullMessageLength.length-1;a>=0;--a)l.fullMessageLength[a]+=o[1],o[1]=o[0]+(l.fullMessageLength[a]/4294967296>>>0),l.fullMessageLength[a]=l.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return i.putBytes(e),f(r,s,i),(i.read>2048||0===i.length())&&i.compact(),l},l.digest=function(){var t=n.util.createBuffer();t.putBytes(i.bytes());var a,c=l.fullMessageLength[l.fullMessageLength.length-1]+l.messageLengthSize&l.blockLength-1;t.putBytes(o.substr(0,l.blockLength-c));for(var u=8*l.fullMessageLength[0],h=0;h>>0,t.putInt32(u>>>0),u=a>>>0;t.putInt32(u);var d=new Array(r.length);for(h=0;h=128;){for(B=0;B<16;++B)t[B][0]=r.getInt32()>>>0,t[B][1]=r.getInt32()>>>0;for(;B<80;++B)n=(((N=(M=t[B-2])[0])>>>19|(P=M[1])<<13)^(P>>>29|N<<3)^N>>>6)>>>0,i=((N<<13|P>>>19)^(P<<3|N>>>29)^(N<<26|P>>>6))>>>0,s=(((N=(L=t[B-15])[0])>>>1|(P=L[1])<<31)^(N>>>8|P<<24)^N>>>7)>>>0,o=((N<<31|P>>>1)^(N<<24|P>>>8)^(N<<25|P>>>7))>>>0,x=t[B-7],D=t[B-16],P=i+x[1]+o+D[1],t[B][0]=n+x[0]+s+D[0]+(P/4294967296>>>0)>>>0,t[B][1]=P>>>0;for(p=e[0][0],y=e[0][1],g=e[1][0],b=e[1][1],m=e[2][0],v=e[2][1],w=e[3][0],E=e[3][1],S=e[4][0],A=e[4][1],_=e[5][0],C=e[5][1],k=e[6][0],I=e[6][1],T=e[7][0],R=e[7][1],B=0;B<80;++B)f=((S>>>14|A<<18)^(S>>>18|A<<14)^(A>>>9|S<<23))>>>0,h=(k^S&(_^k))>>>0,a=((p>>>28|y<<4)^(y>>>2|p<<30)^(y>>>7|p<<25))>>>0,u=((p<<4|y>>>28)^(y<<30|p>>>2)^(y<<25|p>>>7))>>>0,d=(p&g|m&(p^g))>>>0,l=(y&b|v&(y^b))>>>0,P=R+(((S<<18|A>>>14)^(S<<14|A>>>18)^(A<<23|S>>>9))>>>0)+((I^A&(C^I))>>>0)+c[B][1]+t[B][1],n=T+f+h+c[B][0]+t[B][0]+(P/4294967296>>>0)>>>0,i=P>>>0,s=a+d+((P=u+l)/4294967296>>>0)>>>0,o=P>>>0,T=k,R=I,k=_,I=C,_=S,C=A,S=w+n+((P=E+i)/4294967296>>>0)>>>0,A=P>>>0,w=m,E=v,m=g,v=b,g=p,b=y,p=n+s+((P=i+o)/4294967296>>>0)>>>0,y=P>>>0;P=e[0][1]+y,e[0][0]=e[0][0]+p+(P/4294967296>>>0)>>>0,e[0][1]=P>>>0,P=e[1][1]+b,e[1][0]=e[1][0]+g+(P/4294967296>>>0)>>>0,e[1][1]=P>>>0,P=e[2][1]+v,e[2][0]=e[2][0]+m+(P/4294967296>>>0)>>>0,e[2][1]=P>>>0,P=e[3][1]+E,e[3][0]=e[3][0]+w+(P/4294967296>>>0)>>>0,e[3][1]=P>>>0,P=e[4][1]+A,e[4][0]=e[4][0]+S+(P/4294967296>>>0)>>>0,e[4][1]=P>>>0,P=e[5][1]+C,e[5][0]=e[5][0]+_+(P/4294967296>>>0)>>>0,e[5][1]=P>>>0,P=e[6][1]+I,e[6][0]=e[6][0]+k+(P/4294967296>>>0)>>>0,e[6][1]=P>>>0,P=e[7][1]+R,e[7][0]=e[7][0]+T+(P/4294967296>>>0)>>>0,e[7][1]=P>>>0,O-=128}}},function(e,t,r){"use strict";const n=r(186),i=r(1);e.exports=function(e){if(isNaN(e)||e<=0)throw i(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return n(e)}},function(e,t,r){"use strict";r(3),r(40);const n=r(0),i=r(5),s=r(4),o=r(14);t.bigIntegerToUintBase64url=(e,t)=>{let r=Uint8Array.from(e.abs().toByteArray());if(r=0===r[0]?r.slice(1):r,null!=t){if(r.length>t)throw new Error("byte array longer than desired length");r=o([new Uint8Array(t-r.length),r])}return s(r,"base64url")},t.base64urlToBigInteger=e=>{const r=t.base64urlToBuffer(e);return new n.jsbn.BigInteger(s(r,"base16"),16)},t.base64urlToBuffer=(e,t)=>{let r=i(e,"base64urlpad");if(null!=t){if(r.length>t)throw new Error("byte array longer than desired length");r=o([new Uint8Array(t-r.length),r])}return r}},function(e,t,r){"use strict";const n=r(24),i=r(83);e.exports={export:async function(e,t){const r=i.create(),s=await r.encrypt(e,t);return n.names.base64.encode(s)}}},function(e,t,r){"use strict";var n,i=t,s=r(63),o=r(87),a=r(12).assert;function c(e){"short"===e.type?this.curve=new o.short(e):"edwards"===e.type?this.curve=new o.edwards(e):this.curve=new o.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new c(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=c,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:s.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:s.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:s.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:s.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:s.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:s.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:s.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=r(210)}catch(f){n=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:s.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},function(e,t,r){"use strict";var n=t;n.utils=r(16),n.common=r(31),n.sha=r(204),n.ripemd=r(208),n.hmac=r(209),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},function(e,t,r){"use strict";const n=r(225),i=r(93);e.exports=(e,t)=>{const r=n(e,{...t,count:1});return i.fn(async e=>{e(()=>{r.cancel()});const[t]=await r;return t})()},e.exports.AggregateError=n.AggregateError},function(e,t,r){"use strict";e.exports={DIAL_TIMEOUT:3e4,MAX_PARALLEL_DIALS:100,MAX_PER_PEER_DIALS:4,METRICS:{computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[6e4,3e5,9e5],maxOldPeersRetention:50}}},function(e,t,r){"use strict";e.exports={ADVERTISE_BOOT_DELAY:9e5,ADVERTISE_TTL:18e5,CIRCUIT_PROTO_CODE:290,HOP_METADATA_KEY:"hop_relay",HOP_METADATA_VALUE:"true",RELAY_RENDEZVOUS_NS:"/libp2p/relay"}},function(e,t,r){"use strict";const n=r(1),i=r(14),s=r(5),o=r(52),a=r(6),c=r(8),u=r(13),{codes:f}=r(7),h=r(258);class d{constructor({peerId:e,payloadType:t,payload:r,signature:n}){this.peerId=e,this.payloadType=t,this.payload=r,this.signature=n,this._marshal=void 0}marshal(){if(this._marshal)return this._marshal;const e=o.marshalPublicKey(this.peerId.pubKey);return this._marshal=h.Envelope.encode({public_key:e,payload_type:this.payloadType,payload:this.payload,signature:this.signature}),this._marshal}equals(e){return u(this.peerId.pubKey.bytes,e.peerId.pubKey.bytes)&&u(this.payloadType,e.payloadType)&&u(this.payload,e.payload)&&u(this.signature,e.signature)}validate(e){const t=l(e,this.payloadType,this.payload);return this.peerId.pubKey.verify(t,this.signature)}}const l=(e,t,r)=>{const n=s(e),o=c.encode(n.byteLength),a=c.encode(t.length),u=c.encode(r.length);return i([new Uint8Array(o),n,new Uint8Array(a),t,new Uint8Array(u),r])};d.createFromProtobuf=async e=>{const t=h.Envelope.decode(e),r=await a.createFromPubKey(t.public_key);return new d({peerId:r,payloadType:t.payload_type,payload:t.payload,signature:t.signature})},d.seal=async(e,t)=>{const r=e.domain,n=e.codec,i=e.marshal(),s=l(r,n,i),o=await t.privKey.sign(s);return new d({peerId:t,payloadType:n,payload:i,signature:o})},d.openAndCertify=async(e,t)=>{const r=await d.createFromProtobuf(e);if(!await r.validate(t))throw n(new Error("envelope signature is not valid for the given domain"),f.ERR_SIGNATURE_NOT_VALID);return r},e.exports=d},function(e,t,r){"use strict";const n=r(9),i=r(6),s=r(259),o=r(260),{ENVELOPE_DOMAIN_PEER_RECORD:a,ENVELOPE_PAYLOAD_TYPE_PEER_RECORD:c}=r(261);class u{constructor({peerId:e,multiaddrs:t=[],seqNumber:r=Date.now()}){this.domain=a,this.codec=c,this.peerId=e,this.multiaddrs=t,this.seqNumber=r,this._marshal=void 0}marshal(){return this._marshal||(this._marshal=o.PeerRecord.encode({peer_id:this.peerId.toBytes(),seq:this.seqNumber,addresses:this.multiaddrs.map(e=>({multiaddr:e.bytes}))})),this._marshal}equals(e){return e instanceof u&&(!!this.peerId.equals(e.peerId)&&(this.seqNumber===e.seqNumber&&!!s(this.multiaddrs,e.multiaddrs)))}}u.createFromProtobuf=e=>{const t=o.PeerRecord.decode(e),r=i.createFromBytes(t.peer_id),s=(t.addresses||[]).map(e=>n(e.multiaddr)),a=t.seq;return new u({peerId:r,multiaddrs:s,seqNumber:a})},u.DOMAIN=a,e.exports=u},function(e,t,r){"use strict";var n=r(266);function i(e,t,r){var i=this;this._started=n(),this._rescheduled=0,this._scheduled=t,this._args=r,this._timer=setTimeout((function t(){i._rescheduled>0?(i._scheduled=i._rescheduled-(n()-i._started),i._timer=setTimeout(t,i._scheduled),i._rescheduled=0):e.apply(null,i._args)}),t)}i.prototype.reschedule=function(e){var t=n();return!(t+e-(this._started+this._scheduled)<0)&&(this._started=t,this._rescheduled=e,!0)},i.prototype.clear=function(){clearTimeout(this._timer)},e.exports=function(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("timeout needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;tasync function*(){for await(const r of e){await t(r)&&(yield r)}}(),t.sortAll=(e,t)=>async function*(){let r=[];for await(const t of e)r.push(t);r=await t(r);for(const e of r)yield e}(),t.take=(e,t)=>async function*(){if(t<=0)return;let r=0;for await(const n of e)if(yield n,r++,r>=t)return}(),t.map=(e,t)=>async function*(){for await(const r of e)yield t(r)}(),t.replaceStartWith=function(e,t){const r=new RegExp("^"+t);return e.replace(r,"")},t.tmpdir=n},function(e,t,r){"use strict";function n(e,t){return void 0===t?t=>n(e,t):t[Symbol.asyncIterator]?async function*(e,t){let r=[];for await(const n of t)r.push(n),r.length===e&&(yield r,r=[]);r.length>0&&(yield r)}(e,t):function*(e,t){let r=[];for(const n of t)r.push(n),r.length===e&&(yield r,r=[]);r.length>0&&(yield r)}(e,t)}function i(e){if("function"==typeof e.next)return e;if("function"==typeof e[Symbol.iterator])return e[Symbol.iterator]();if("function"==typeof e[Symbol.asyncIterator])return e[Symbol.asyncIterator]();throw new TypeError('"values" does not to conform to any of the iterator or iterable protocols')}function s(){let e,t;return{promise:new Promise((r,n)=>{t=r,e=n}),reject:e,resolve:t}}function o(e,t){const r=i(t),n=[],o=[];let a=!1,c=!1;async function u(){if(!c&&!(a||n.length>=e)){a=!0;try{const{done:e,value:t}=await r.next();e?c=!0:n.push({value:t})}catch(t){c=!0,n.push({error:t})}!function(){for(;o.length>0&&n.length>0;){const e=o.shift(),{error:t,value:r}=n.shift();t?e.reject(t):e.resolve({done:!1,value:r})}for(;o.length>0&&c;){const{resolve:e}=o.shift();e({done:!0,value:void 0})}}(),a=!1,u()}}const f={next:async function(){if(n.length>0){const{error:e,value:t}=n.shift();if(e)throw e;return u(),{done:!1,value:t}}if(c)return{done:!0,value:void 0};const e=s();return o.push(e),u(),e.promise},[Symbol.asyncIterator]:()=>f};return f}function a(e,t){return void 0===t?t=>a(e,t):0===e?t:t[Symbol.asyncIterator]?o(e,t):function*(e,t){const r=[];let n;try{for(const n of t)r.push(n),r.length<=e||(yield r.shift())}catch(i){n=i}for(const s of r)yield s;if(n)throw n}(e,t)}function c(e){return e[Symbol.asyncIterator]?async function(e){const t=[];for await(const r of e)t.push(r);return t}(e):Array.from(e)}function u(...e){return e.find(e=>void 0!==e[Symbol.asyncIterator])?async function*(e){for await(const t of e)yield*t}(e):function*(e){for(const t of e)yield*t}(e)}function f(e){if(e[Symbol.asyncIterator])return async function(e){for await(const t of e);}(e);for(const t of e);}async function*h(e,t){for await(const r of t)await e(r)&&(yield r)}function d(e,t){return void 0===t?t=>h(e,t):h(e,t)}async function*l(e){for await(const t of e)t&&"string"!=typeof t&&(t[Symbol.iterator]||t[Symbol.asyncIterator])?yield*l(t):yield t}async function*p(e,t){for await(const r of t)yield await e(r)}function y(e,t){return void 0===t?t=>p(e,t):p(e,t)}function g(e,t){return void 0===t?t=>g(e,t):d(e=>null!=e,l(y(e,t)))}function b(e,t,r){const n=i(r),o=[],a=[];let c=!1,u=!1,f=0,h=null;function d(){for(;a.length>0&&o.length>0;){const{resolve:e}=a.shift();e({done:!1,value:o.shift()})}for(;a.length>0&&0===f&&c;){const{resolve:e,reject:t}=a.shift();h?(t(h),h=null):e({done:!0,value:void 0})}}async function l(){if(c)d();else if(!(u||f+o.length>=e)){u=!0,f++;try{const{done:e,value:r}=await n.next();e?(c=!0,f--,d()):async function(e){try{const r=await t(e);if(r&&r[Symbol.asyncIterator])for await(const e of r)o.push(e);else o.push(r)}catch(r){c=!0,h=r}f--,d(),l()}(r)}catch(r){c=!0,f--,h=r,d()}u=!1,l()}}const p={next:async function(){if(0===o.length){const e=s();return a.push(e),l(),e.promise}const e=o.shift();return l(),{done:!1,value:e}},[Symbol.asyncIterator]:()=>p};return p}function m(e,t,r){return void 0===t?(t,r)=>r?m(e,t,r):m(e,t):void 0===r?r=>m(e,t,r):d(e=>null!=e,l(b(e,t,r)))}async function v(e){return new Promise(t=>{e.once("readable",()=>{t()})})}function w(e){return"function"==typeof e[Symbol.asyncIterator]?e:async function*(e){for(;;){const t=e.read();if(null===t){if(e._readableState.ended)break;await v(e)}else yield t}}(e)}async function*E(...e){const t=new Set(e.map(i));for(;t.size>0;)for(const e of t){const r=await e.next();r.done?t.delete(e):yield r.value}}function S(e,...t){let r=e();for(const n of t)r=n(r);return r}function A(e,t,r){return void 0===t?(t,r)=>A(e,t,r):void 0===r?r=>A(e,t,r):1===e?y(t,r):async function*(e,t,r){let n=null;const s=i(S(()=>r,a(1),(async function*(e){for await(const t of e){if(n)return;yield t}}),y(e=>({value:t(e)})),a(e-1)));for(;;){const{value:e,done:t}=await s.next();if(t)break;try{const t=await e.value;n||(yield t)}catch(o){n=o}}if(n)throw n}(e,t,r)}function _(e,t,r){return void 0===t?(t,r)=>r?_(e,t,r):_(e,t):void 0===r?r=>_(e,t,r):d(e=>null!=e,l(A(e,t,r)))}async function*C(...e){const t=e.map(i),r=new Set,n=new Map;let s=null,o=null,a=null;const c=e=>{s=e,o&&o(e)},u=e=>{a&&a(e)},f=e=>{const t=Promise.resolve(e.next()).then(async({done:i,value:s})=>{i||n.set(e,s),r.delete(t)});r.add(t),t.then(u,c)};for(const i of t)f(i);for(;;){if(0===r.size&&0===n.size)return;await new Promise((e,t)=>{if(s&&t(s),n.size>0)return e();a=e,o=t});for(const[e,t]of n)n.delete(e),yield t,f(e)}}async function k(e,t,r){let n=t;for await(const i of r)n=await e(n,i);return n}function I(e,t,r){return void 0===t?(t,r)=>r?k(e,t,r):I(e,t):void 0===r?r=>I(e,t,r):k(e,t,r)}function T(e,t){return void 0===t?t=>T(e,t):t[Symbol.asyncIterator]?async function*(e,t){let r=0;for await(const n of t)if(yield await n,r++,r>=e)break}(e,t):function*(e,t){let r=0;for(const n of t)if(yield n,r++,r>=e)break}(e,t)}async function*R(e,t){for await(const r of t)await e(r),yield r}function B(e,t){return void 0===t?t=>R(e,t):R(e,t)}function N(e,t){let r=e[0]+t[0],n=e[1]+t[1];if(n>=1e9){const e=n%1e9;r+=(n-e)/1e9,n=e}return[r,n]}function P(e={},t){return void 0===t?t=>P(e,t):void 0!==t[Symbol.asyncIterator]?async function*(e,t){const r=t[Symbol.asyncIterator]();let n=[0,0];for(;;){const t=process.hrtime(),{value:i,done:s}=await r.next(),o=process.hrtime(t);if(n=N(n,o),e.progress&&e.progress(o,n),s)return e.total&&e.total(n),i;yield i}}(e,t):function*(e,t){const r=t[Symbol.iterator]();let n=[0,0];for(;;){const t=process.hrtime(),{value:i,done:s}=r.next(),o=process.hrtime(t);if(n=N(n,o),e.progress&&e.progress(o,n),s)return e.total&&e.total(n),i;yield i}}(e,t)}function M(e,t,r){const n=i(r),o=[],a=[];let c=!1,u=!1,f=0,h=null;function d(){for(;a.length>0&&o.length>0;){const{resolve:e}=a.shift();e({done:!1,value:o.shift()})}for(;a.length>0&&0===f&&c;){const{resolve:e,reject:t}=a.shift();h?(t(h),h=null):e({done:!0,value:void 0})}}async function l(){if(c)d();else if(!(u||f+o.length>=e)){u=!0,f++;try{const{done:e,value:r}=await n.next();e?(c=!0,f--,d()):async function(e){try{const r=await t(e);o.push(r)}catch(r){c=!0,h=r}f--,d(),l()}(r)}catch(r){c=!0,f--,h=r,d()}u=!1,l()}}const p={next:async function(){if(0===o.length){const e=s();return a.push(e),l(),e.promise}const e=o.shift();return l(),{done:!1,value:e}},[Symbol.asyncIterator]:()=>p};return p}function x(e,t,r){return void 0===t?(t,r)=>r?x(e,t,r):x(e,t):void 0===r?r=>x(e,t,r):M(e,t,r)}async function L(e,t){let r=null,n=null,i=null;const s=e=>{r=e,n&&n(e)},o=()=>{i&&i()};e.once("error",s);for await(const a of t)if(!1===e.write(a)&&await new Promise((t,s)=>{if(r)return s(r);e.once("drain",o),i=t,n=s}),r)break;if(e.removeListener("error",s),e.removeListener("drain",o),r)throw r}function D(e,t){return void 0===t?t=>L(e,t):L(e,t)}r.r(t),r.d(t,"batch",(function(){return n})),r.d(t,"buffer",(function(){return a})),r.d(t,"collect",(function(){return c})),r.d(t,"concat",(function(){return u})),r.d(t,"consume",(function(){return f})),r.d(t,"filter",(function(){return d})),r.d(t,"flatMap",(function(){return g})),r.d(t,"flatTransform",(function(){return m})),r.d(t,"flatten",(function(){return l})),r.d(t,"fromStream",(function(){return w})),r.d(t,"getIterator",(function(){return i})),r.d(t,"map",(function(){return y})),r.d(t,"merge",(function(){return E})),r.d(t,"parallelFlatMap",(function(){return _})),r.d(t,"parallelMap",(function(){return A})),r.d(t,"parallelMerge",(function(){return C})),r.d(t,"pipeline",(function(){return S})),r.d(t,"reduce",(function(){return I})),r.d(t,"take",(function(){return T})),r.d(t,"tap",(function(){return B})),r.d(t,"time",(function(){return P})),r.d(t,"transform",(function(){return x})),r.d(t,"writeToStream",(function(){return D}))},function(e,t,r){"use strict";const n=r(25),i=r(33),s=r(23),o=r(1),a=r(5)("\n");async function c(e){for await(const t of e)return t}t.encode=e=>i.encode.single(new n([e,a])),t.write=(e,r)=>e.push(t.encode(r)),t.writeAll=(e,r)=>{e.push(r.reduce((e,r)=>e.append(t.encode(r)),new n))},t.read=async e=>{let t=1;const r={[Symbol.asyncIterator](){return this},next:()=>e.next(t)},n=await s(r,i.decode({onLength:e=>{t=e}}),c);if(n.get(n.length-1)!==a[0])throw o(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return n.shallowSlice(0,-1)}},function(e,t,r){"use strict";const{Buffer:n}=r(11),i=r(25);e.exports=async function*(e){for await(const t of e)n.isBuffer(t)?yield t:i.isBufferList(t)?yield t.slice():yield n.from(t)},e.exports.toBuffer=e.exports,e.exports.toList=async function*(e){for await(const t of e)n.isBuffer(t)?yield(new i).append(t):i.isBufferList(t)?yield t:yield(new i).append(n.from(t))}},function(e,t,r){"use strict";var n=1e3,i=6e4,s=60*i,o=24*s;function a(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,t){t=t||{};var r=typeof e;if("string"===r&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*o;case"hours":case"hour":case"hrs":case"hr":case"h":return r*s;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=o)return a(e,t,o,"day");if(t>=s)return a(e,t,s,"hour");if(t>=i)return a(e,t,i,"minute");if(t>=n)return a(e,t,n,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=o)return Math.round(e/o)+"d";if(t>=s)return Math.round(e/s)+"h";if(t>=i)return Math.round(e/i)+"m";if(t>=n)return Math.round(e/n)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){"use strict";const n=r(77),i=r(141),s=r(142),o=r(78),a=r(14);(t=e.exports).addPrefix=(e,t)=>{let r;if(e instanceof Uint8Array)r=o.varintUint8ArrayEncode(e);else{if(!s[e])throw new Error("multicodec not recognized");r=s[e]}return a([r,t],r.length+t.length)},t.rmPrefix=e=>(n.decode(e),e.slice(n.decode.bytes)),t.getCodec=e=>{const t=n.decode(e),r=i.get(t);if(void 0===r)throw new Error(`Code ${t} not found`);return r},t.getName=e=>i.get(e),t.getNumber=e=>{const t=s[e];if(void 0===t)throw new Error("Codec `"+e+"` not found");return n.decode(t)},t.getCode=e=>n.decode(e),t.getCodeVarint=e=>{const t=s[e];if(void 0===t)throw new Error("Codec `"+e+"` not found");return t},t.getVarint=e=>n.encode(e);const c=r(143);Object.assign(t,c),t.print=r(144)},function(e,t,r){"use strict";e.exports={encode:r(138),decode:r(139),encodingLength:r(140)}},function(e,t,r){"use strict";const n=r(77),i=r(4),s=r(5);function o(e){return parseInt(i(e,"base16"),16)}e.exports={numberToUint8Array:function(e){let t=e.toString(16);t.length%2==1&&(t="0"+t);return s(t,"base16")},uint8ArrayToNumber:o,varintUint8ArrayEncode:function(e){return Uint8Array.from(n.encode(o(e)))},varintEncode:function(e){return Uint8Array.from(n.encode(e))}}},function(e,t,r){"use strict";var n=r(0);if(r(29),r(18),r(55),r(20),r(28),r(82),r(57),r(21),r(178),r(39),r(3),void 0===i)var i=n.jsbn.BigInteger;var s=n.asn1,o=n.pki=n.pki||{};e.exports=o.pbe=n.pbe=n.pbe||{};var a=o.oids,c={name:"EncryptedPrivateKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},u={name:"PBES2Algorithms",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},f={name:"pkcs-12PbeParams",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"iterations"}]};function h(e,t){return e.start().update(t).digest().getBytes()}function d(e){var t;if(e){if(!(t=o.oids[s.derToOid(e)])){var r=new Error("Unsupported PRF OID.");throw r.oid=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}}else t="hmacWithSHA1";return l(t)}function l(e){var t=n.md;switch(e){case"hmacWithSHA224":t=n.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}o.encryptPrivateKeyInfo=function(e,t,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var i,c,u,f=n.random.getBytesSync(r.saltSize),h=r.count,d=s.integerToDer(h);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var p,y,g;switch(r.algorithm){case"aes128":i=16,p=16,y=a["aes128-CBC"],g=n.aes.createEncryptionCipher;break;case"aes192":i=24,p=16,y=a["aes192-CBC"],g=n.aes.createEncryptionCipher;break;case"aes256":i=32,p=16,y=a["aes256-CBC"],g=n.aes.createEncryptionCipher;break;case"des":i=8,p=8,y=a.desCBC,g=n.des.createEncryptionCipher;break;default:throw(S=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,S}var b="hmacWith"+r.prfAlgorithm.toUpperCase(),m=l(b),v=n.pkcs5.pbkdf2(t,f,h,i,m),w=n.random.getBytesSync(p);(A=g(v)).start(w),A.update(s.toDer(e)),A.finish(),u=A.output.getBytes();var E=function(e,t,r,i){var a=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,e),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,t.getBytes())]);"hmacWithSHA1"!==i&&a.value.push(s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,n.util.hexToBytes(r.toString(16))),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(o.oids[i]).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,"")]));return a}(f,d,i,b);c=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(a.pkcs5PBES2).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(a.pkcs5PBKDF2).getBytes()),E]),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(y).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,w)])])])}else{var S;if("3des"!==r.algorithm)throw(S=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,S;i=24;var A,_=new n.util.ByteBuffer(f);v=o.pbe.generatePkcs12Key(t,_,1,h,i),w=o.pbe.generatePkcs12Key(t,_,2,h,i);(A=n.des.createEncryptionCipher(v)).start(w),A.update(s.toDer(e)),A.finish(),u=A.output.getBytes(),c=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(a["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,f),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,d.getBytes())])])}return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[c,s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,u)])},o.decryptPrivateKeyInfo=function(e,t){var r=null,i={},a=[];if(!s.validate(e,c,i,a)){var u=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw u.errors=a,u}var f=s.derToOid(i.encryptionOid),h=o.pbe.getCipher(f,i.encryptionParams,t),d=n.util.createBuffer(i.encryptedData);return h.update(d),h.finish()&&(r=s.fromDer(h.output)),r},o.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:s.toDer(e).getBytes()};return n.pem.encode(r,{maxline:t})},o.encryptedPrivateKeyFromPem=function(e){var t=n.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==t.type){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return s.fromDer(t.body)},o.encryptRsaPrivateKey=function(e,t,r){if(!(r=r||{}).legacy){var i=o.wrapRsaPrivateKey(o.privateKeyToAsn1(e));return i=o.encryptPrivateKeyInfo(i,t,r),o.encryptedPrivateKeyToPem(i)}var a,c,u,f;switch(r.algorithm){case"aes128":a="AES-128-CBC",u=16,c=n.random.getBytesSync(16),f=n.aes.createEncryptionCipher;break;case"aes192":a="AES-192-CBC",u=24,c=n.random.getBytesSync(16),f=n.aes.createEncryptionCipher;break;case"aes256":a="AES-256-CBC",u=32,c=n.random.getBytesSync(16),f=n.aes.createEncryptionCipher;break;case"3des":a="DES-EDE3-CBC",u=24,c=n.random.getBytesSync(8),f=n.des.createEncryptionCipher;break;case"des":a="DES-CBC",u=8,c=n.random.getBytesSync(8),f=n.des.createEncryptionCipher;break;default:var h=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw h.algorithm=r.algorithm,h}var d=f(n.pbe.opensslDeriveBytes(t,c.substr(0,8),u));d.start(c),d.update(s.toDer(o.privateKeyToAsn1(e))),d.finish();var l={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:a,parameters:n.util.bytesToHex(c).toUpperCase()},body:d.output.getBytes()};return n.pem.encode(l)},o.decryptRsaPrivateKey=function(e,t){var r=null,i=n.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==i.type&&"PRIVATE KEY"!==i.type&&"RSA PRIVATE KEY"!==i.type)throw(u=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=u,u;if(i.procType&&"ENCRYPTED"===i.procType.type){var a,c;switch(i.dekInfo.algorithm){case"DES-CBC":a=8,c=n.des.createDecryptionCipher;break;case"DES-EDE3-CBC":a=24,c=n.des.createDecryptionCipher;break;case"AES-128-CBC":a=16,c=n.aes.createDecryptionCipher;break;case"AES-192-CBC":a=24,c=n.aes.createDecryptionCipher;break;case"AES-256-CBC":a=32,c=n.aes.createDecryptionCipher;break;case"RC2-40-CBC":a=5,c=function(e){return n.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":a=8,c=function(e){return n.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":a=16,c=function(e){return n.rc2.createDecryptionCipher(e,128)};break;default:var u;throw(u=new Error('Could not decrypt private key; unsupported encryption algorithm "'+i.dekInfo.algorithm+'".')).algorithm=i.dekInfo.algorithm,u}var f=n.util.hexToBytes(i.dekInfo.parameters),h=c(n.pbe.opensslDeriveBytes(t,f.substr(0,8),a));if(h.start(f),h.update(n.util.createBuffer(i.body)),!h.finish())return r;r=h.output.getBytes()}else r=i.body;return null!==(r="ENCRYPTED PRIVATE KEY"===i.type?o.decryptPrivateKeyInfo(s.fromDer(r),t):s.fromDer(r))&&(r=o.privateKeyFromAsn1(r)),r},o.pbe.generatePkcs12Key=function(e,t,r,i,s,o){var a,c;if(null==o){if(!("sha1"in n.md))throw new Error('"sha1" hash algorithm unavailable.');o=n.md.sha1.create()}var u=o.digestLength,f=o.blockLength,h=new n.util.ByteBuffer,d=new n.util.ByteBuffer;if(null!=e){for(c=0;c=0;c--)R>>=8,R+=C.at(c)+T.at(c),T.setAt(c,255&R);I.putBuffer(T)}w=I,h.putBuffer(A)}return h.truncate(h.length()-s),h},o.pbe.getCipher=function(e,t,r){switch(e){case o.oids.pkcs5PBES2:return o.pbe.getCipherForPBES2(e,t,r);case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case o.oids["pbewithSHAAnd40BitRC2-CBC"]:return o.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},o.pbe.getCipherForPBES2=function(e,t,r){var i,a={},c=[];if(!s.validate(t,u,a,c))throw(i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=c,i;if((e=s.derToOid(a.kdfOid))!==o.oids.pkcs5PBKDF2)throw(i=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,i.supportedOids=["pkcs5PBKDF2"],i;if((e=s.derToOid(a.encOid))!==o.oids["aes128-CBC"]&&e!==o.oids["aes192-CBC"]&&e!==o.oids["aes256-CBC"]&&e!==o.oids["des-EDE3-CBC"]&&e!==o.oids.desCBC)throw(i=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,i.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],i;var f,h,l=a.kdfSalt,p=n.util.createBuffer(a.kdfIterationCount);switch(p=p.getInt(p.length()<<3),o.oids[e]){case"aes128-CBC":f=16,h=n.aes.createDecryptionCipher;break;case"aes192-CBC":f=24,h=n.aes.createDecryptionCipher;break;case"aes256-CBC":f=32,h=n.aes.createDecryptionCipher;break;case"des-EDE3-CBC":f=24,h=n.des.createDecryptionCipher;break;case"desCBC":f=8,h=n.des.createDecryptionCipher}var y=d(a.prfOid),g=n.pkcs5.pbkdf2(r,l,p,f,y),b=a.encIv,m=h(g);return m.start(b),m},o.pbe.getCipherForPKCS12PBE=function(e,t,r){var i={},a=[];if(!s.validate(t,f,i,a))throw(y=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,y;var c,u,h,l=n.util.createBuffer(i.salt),p=n.util.createBuffer(i.iterations);switch(p=p.getInt(p.length()<<3),e){case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,h=n.des.startDecrypting;break;case o.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,h=function(e,t){var r=n.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var y;throw(y=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,y}var g=d(i.prfOid),b=o.pbe.generatePkcs12Key(r,l,1,p,c,g);return g.start(),h(b,o.pbe.generatePkcs12Key(r,l,2,p,u,g))},o.pbe.opensslDeriveBytes=function(e,t,r,i){if(null==i){if(!("md5"in n.md))throw new Error('"md5" hash algorithm unavailable.');i=n.md.md5.create()}null===t&&(t="");for(var s=[h(i,e+t)],o=16,a=1;o4){var r=e;e=n.util.createBuffer();for(var i=0;i0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},i.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},i.cbc.prototype.encrypt=function(e,t,r){if(e.length()0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb.prototype.decrypt=i.ofb.prototype.encrypt,i.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ctr.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}o(this._inBlock)},i.ctr.prototype.decrypt=i.ctr.prototype.encrypt,i.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0,this._R=3774873600},i.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=n.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?n.util.createBuffer(e.additionalData):n.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=n.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var i=r.length();if(12===i)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(a(8*i)))}this._inBlock=this._j0.slice(0),o(this._inBlock),this._partialBytes=0,t=n.util.createBuffer(t),this._aDataLength=a(8*t.length());var s=t.length()%this.blockSize;for(s&&t.fillWithByte(0,this.blockSize-s),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},i.gcm.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize){for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),o(this._inBlock)},i.gcm.prototype.decrypt=function(e,t,r){var n=e.length();if(n0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),o(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},i.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},i.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},i.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,i=16*r,s=new Array(i),o=0;o>>1,i=new Array(r);i[n]=e.slice(0);for(var s=n>>>1;s>0;)this.pow(i[2*s],i[s]=[]),s>>=1;for(s=2;s4||!a||"sha1"===a))return"string"!=typeof a&&(a="sha1"),e=t.from(e,"binary"),r=t.from(r,"binary"),c?4===i.pbkdf2Sync.length?i.pbkdf2(e,r,s,o,(function(e,t){if(e)return c(e);c(null,t.toString("binary"))})):i.pbkdf2(e,r,s,o,a,(function(e,t){if(e)return c(e);c(null,t.toString("binary"))})):4===i.pbkdf2Sync.length?i.pbkdf2Sync(e,r,s,o).toString("binary"):i.pbkdf2Sync(e,r,s,o,a).toString("binary");if(null==a&&(a="sha1"),"string"==typeof a){if(!(a in n.md.algorithms))throw new Error("Unknown hash algorithm: "+a);a=n.md[a].create()}var u=a.digestLength;if(o>4294967295*u){var f=new Error("Derived key is too long.");if(c)return c(f);throw f}var h=Math.ceil(o/u),d=o-(h-1)*u,l=n.hmac.create();l.start(a,e);var p,y,g,b="";if(!c){for(var m=1;m<=h;++m){l.start(null,null),l.update(r),l.update(n.util.int32ToBytes(m)),p=g=l.digest().getBytes();for(var v=2;v<=s;++v)l.start(null,null),l.update(g),y=l.digest().getBytes(),p=n.util.xorBytes(p,y,u),g=y;b+=mh)return c(null,b);l.start(null,null),l.update(r),l.update(n.util.int32ToBytes(m)),p=g=l.digest().getBytes(),v=2,E()}function E(){if(v<=s)return l.start(null,null),l.update(g),y=l.digest().getBytes(),p=n.util.xorBytes(p,y,u),g=y,++v,n.util.setImmediate(E);b+=m=0;--r)U(n,n),1!==r&&K(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(r,r),K(r,r,i),K(r,r,s),K(r,r,s),K(e[0],r,s),U(n,e[0]),K(n,n,s),I(n,i)&&K(e[0],e[0],v);if(U(n,e[0]),K(n,n,s),I(n,i))return-1;R(e[0])===t[31]>>7&&O(e[0],d,e[0]);return K(e[3],e[0],e[1]),0}(a,n))return-1;for(i=0;i=0};var d=L(),l=L([1]),p=L([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),y=L([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),g=L([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),b=L([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),m=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),v=L([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function w(e,r){var i=n.md.sha512.create(),s=new c(e);i.update(s.getBytes(r),"binary");var o=i.digest().getBytes();if(void 0!==t)return t.from(o,"binary");for(var a=new u(f.constants.HASH_BYTE_LENGTH),h=0;h<64;++h)a[h]=o.charCodeAt(h);return a}function E(e,t){var r,n,i,s;for(n=63;n>=32;--n){for(r=0,i=n-32,s=n-12;i>8,t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;++i)t[i]+=r-(t[31]>>4)*m[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;++i)t[i]-=r*m[i];for(n=0;n<32;++n)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function S(e){for(var t=new Float64Array(64),r=0;r<64;++r)t[r]=e[r],e[r]=0;E(e,t)}function A(e,t){var r=L(),n=L(),i=L(),s=L(),o=L(),a=L(),c=L(),u=L(),f=L();O(r,e[1],e[0]),O(f,t[1],t[0]),K(r,r,f),D(n,e[0],e[1]),D(f,t[0],t[1]),K(n,n,f),K(i,e[3],t[3]),K(i,i,y),K(s,e[2],t[2]),D(s,s,s),O(o,n,r),O(a,s,i),D(c,s,i),D(u,n,r),K(e[0],o,a),K(e[1],u,c),K(e[2],c,a),K(e[3],o,u)}function _(e,t,r){for(var n=0;n<4;++n)x(e[n],t[n],r)}function C(e,t){var r=L(),n=L(),i=L();!function(e,t){var r,n=L();for(r=0;r<16;++r)n[r]=t[r];for(r=253;r>=0;--r)U(n,n),2!==r&&4!==r&&K(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(i,t[2]),K(r,t[0],i),K(n,t[1],i),k(e,n),e[31]^=R(r)<<7}function k(e,t){var r,n,i,s=L(),o=L();for(r=0;r<16;++r)o[r]=t[r];for(M(o),M(o),M(o),n=0;n<2;++n){for(s[0]=o[0]-65517,r=1;r<15;++r)s[r]=o[r]-65535-(s[r-1]>>16&1),s[r-1]&=65535;s[15]=o[15]-32767-(s[14]>>16&1),i=s[15]>>16&1,s[14]&=65535,x(o,s,1-i)}for(r=0;r<16;r++)e[2*r]=255&o[r],e[2*r+1]=o[r]>>8}function I(e,t){var r=new u(32),n=new u(32);return k(r,e),k(n,t),T(r,0,n,0)}function T(e,t,r,n){return function(e,t,r,n,i){var s,o=0;for(s=0;s>>8)-1}(e,t,r,n,32)}function R(e){var t=new u(32);return k(t,e),1&t[0]}function B(e,t,r){var n,i;for(P(e[0],d),P(e[1],l),P(e[2],l),P(e[3],d),i=255;i>=0;--i)_(e,t,n=r[i/8|0]>>(7&i)&1),A(t,e),A(e,e),_(e,t,n)}function N(e,t){var r=[L(),L(),L(),L()];P(r[0],g),P(r[1],b),P(r[2],l),K(r[3],g,b),B(e,r,t)}function P(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function M(e){var t,r,n=1;for(t=0;t<16;++t)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function x(e,t,r){for(var n,i=~(r-1),s=0;s<16;++s)n=i&(e[s]^t[s]),e[s]^=n,t[s]^=n}function L(e){var t,r=new Float64Array(16);if(e)for(t=0;t>8,o=255&i;s?r.push(s,o):r.push(o)}return r},n.zero2=i,n.toHex=s,n.encode=function(e,t){return"hex"===t?s(e):e}},function(e,t,r){"use strict";var n;function i(e){this.rand=e}if(e.exports=function(e){return n||(n=new i(null)),n.generate(e)},e.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r>>3},t.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},function(e,t,r){"use strict";var n=r(16),i=r(31),s=r(88),o=r(22),a=n.sum32,c=n.sum32_4,u=n.sum32_5,f=s.ch32,h=s.maj32,d=s.s0_256,l=s.s1_256,p=s.g0_256,y=s.g1_256,g=i.BlockHash,b=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function m(){if(!(this instanceof m))return new m;g.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=b,this.W=new Array(64)}n.inherits(m,g),e.exports=m,m.blockSize=512,m.outSize=256,m.hmacStrength=192,m.padLength=64,m.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n(async(e,t)=>{const r=await n.get().subtle.sign({name:"HMAC"},e,t);return new Uint8Array(r,r.byteOffset,r.byteLength)})(o,e),length:i[e]}}},function(e,t,r){"use strict";e.exports=async e=>{const t=[];for await(const r of e)t.push(r);return t}},function(e,t,r){"use strict";class n extends Error{constructor(e){super(e||"Promise was canceled"),this.name="CancelError"}get isCanceled(){return!0}}class i{static fn(e){return(...t)=>new i((r,n,i)=>{t.push(i),e(...t).then(r,n)})}constructor(e){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise((t,r)=>{this._reject=r;const n=e=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(e)};return Object.defineProperties(n,{shouldReject:{get:()=>this._rejectOnCancel,set:e=>{this._rejectOnCancel=e}}}),e(e=>{this._isPending=!1,t(e)},e=>{this._isPending=!1,r(e)},n)})}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}cancel(e){if(this._isPending&&!this._isCanceled){if(this._cancelHandlers.length>0)try{for(const e of this._cancelHandlers)e()}catch(t){this._reject(t)}this._isCanceled=!0,this._rejectOnCancel&&this._reject(new n(e))}}get isCanceled(){return this._isCanceled}}Object.setPrototypeOf(i.prototype,Promise.prototype),e.exports=i,e.exports.CancelError=n},function(e,t,r){"use strict";const n=new Map;e.exports={setDelayedInterval:function(e,t,r){r=r||t;const i=`${Date.now()}:${Math.floor(1e6*Math.random())}`,s=setTimeout(()=>{!async function(e,t,r){for(;n.get(r);){try{await e()}catch(i){setTimeout(()=>{throw i},1);break}if(!n.get(r))break;await new Promise(e=>{const i=setTimeout(e,t);n.set(r,i)})}}(e,t,i)},r);return n.set(i,s),i},clearDelayedInterval:function(e){const t=n.get(e);t&&(clearTimeout(t),n.delete(e))}}},function(e,t,r){"use strict";const n=r(6),i=r(9),s=r(1),{codes:o}=r(7);e.exports=function(e){let t;if("string"==typeof e&&(e=i(e)),i.isMultiaddr(e)){t=e;try{e=n.createFromB58String(e.getPeerId())}catch(r){throw s(new Error(e+" is not a valid peer type"),o.ERR_INVALID_MULTIADDR)}}return{id:e,multiaddrs:t?[t]:void 0}}},function(e,t,r){"use strict";const n=r(234),i=e=>n({exact:!0}).test(e);i.v4=e=>n.v4({exact:!0}).test(e),i.v6=e=>n.v6({exact:!0}).test(e),i.version=e=>i(e)?i.v4(e)?4:6:void 0,e.exports=i},function(e,t,r){"use strict";var n=r(244),i="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),s=Object.prototype.toString,o=Array.prototype.concat,a=Object.defineProperty,c=a&&function(){var e={};try{for(var t in a(e,"x",{enumerable:!1,value:e}),e)return!1;return e.x===e}catch(r){return!1}}(),u=function(e,t,r,n){var i;(!(t in e)||"function"==typeof(i=n)&&"[object Function]"===s.call(i)&&n())&&(c?a(e,t,{configurable:!0,enumerable:!1,value:r,writable:!0}):e[t]=r)},f=function(e,t){var r=arguments.length>2?arguments[2]:{},s=n(t);i&&(s=o.call(s,Object.getOwnPropertySymbols(t)));for(var a=0;a=0&&"[object Function]"===n.call(e.callee)),r}},function(e,t,r){"use strict";"undefined"!=typeof self?e.exports=self:"undefined"!=typeof window?e.exports=window:e.exports=Function("return this")()},function(e,t,r){"use strict";(function(t){var n=r(99);e.exports=function(){return"object"==typeof t&&t&&t.Math===Math&&t.Array===Array?t:n}}).call(this,r(38))},function(e,t,r){"use strict";const n=r(248).version;e.exports.PROTOCOL_VERSION="ipfs/0.1.0",e.exports.AGENT_VERSION="js-libp2p/"+n,e.exports.MULTICODEC_IDENTIFY="/ipfs/id/1.0.0",e.exports.MULTICODEC_IDENTIFY_PUSH="/ipfs/id/push/1.0.0"},function(e,t,r){"use strict";const n=r(249);function i(e,t){const r=n(e.multiaddr),i=n(t.multiaddr);return r&&!i?1:!r&&i||e.isCertified&&!t.isCertified?-1:!e.isCertified&&t.isCertified?1:0}e.exports.publicAddressesFirst=function(e){return[...e].sort(i)}},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:transports"),{error:n("libp2p:transports:err")}),s=r(253),{codes:o}=r(7),a=r(1),{updateSelfPeerRecord:c}=r(257);class u{constructor({libp2p:e,upgrader:t,faultTolerance:r=f.FATAL_ALL}){this.libp2p=e,this.upgrader=t,this._transports=new Map,this._listeners=new Map,this._listenerOptions=new Map,this.faultTolerance=r}add(e,t,r={}){if(i("adding %s",e),!e)throw a(new Error(`Transport must have a valid key, was given '${e}'`),o.ERR_INVALID_KEY);if(this._transports.has(e))throw a(new Error("There is already a transport with this key"),o.ERR_DUPLICATE_TRANSPORT);const n=new t({...r,libp2p:this.libp2p,upgrader:this.upgrader});this._transports.set(e,n),this._listenerOptions.set(e,r.listenerOptions||{}),this._listeners.has(e)||this._listeners.set(e,[])}async close(){const e=[];for(const[t,r]of this._listeners)for(i("closing listeners for %s",t);r.length;){const t=r.pop();t.removeAllListeners("listening"),t.removeAllListeners("close"),e.push(t.close())}await Promise.all(e),i("all listeners closed");for(const t of this._listeners.keys())this._listeners.set(t,[])}async dial(e,t){const r=this.transportForMultiaddr(e);if(!r)throw a(new Error("No transport available for address "+String(e)),o.ERR_TRANSPORT_UNAVAILABLE);try{return await r.dial(e,t)}catch(n){throw n.code||(n.code=o.ERR_TRANSPORT_DIAL_FAILED),n}}getAddrs(){let e=[];for(const t of this._listeners.values())for(const r of t)e=[...e,...r.getAddrs()];return e}getTransports(){return this._transports.values()}transportForMultiaddr(e){for(const t of this._transports.values()){if(t.filter([e]).length)return t}return null}async listen(e){if(!e||0===e.length)return void i("no addresses were provided for listening, this node is dial only");const t=[];for(const[r,n]of this._transports.entries()){const u=n.filter(e),f=[];for(const e of u){i("creating listener for %s on %s",r,e);const t=n.createListener(this._listenerOptions.get(r));this._listeners.get(r).push(t),t.on("listening",()=>c(this.libp2p)),t.on("close",()=>c(this.libp2p)),f.push(t.listen(e))}if(0===f.length){t.push(r);continue}if(!(await s(f)).find(e=>!0===e.isFulfilled))throw a(new Error(`Transport (${r}) could not listen on any available address`),o.ERR_NO_VALID_ADDRESSES)}if(t.length===this._transports.size){const e=`no valid addresses were provided for transports [${t}]`;if(this.faultTolerance===f.FATAL_ALL)throw a(new Error(e),o.ERR_NO_VALID_ADDRESSES);i("libp2p in dial mode only: "+e)}}async remove(e){if(i("removing %s",e),this._listeners.has(e))for(const t of this._listeners.get(e))t.removeAllListeners("listening"),t.removeAllListeners("close"),await t.close();this._transports.delete(e),this._listeners.delete(e)}async removeAll(){const e=[];for(const t of this._transports.keys())e.push(this.remove(t));await Promise.all(e)}}const f={FATAL_ALL:0,NO_FATAL:1};u.FaultTolerance=f,e.exports=u},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:circuit:hop"),{error:n("libp2p:circuit:hop:err")}),s=r(1),o=r(6),{validateAddrs:a}=r(105),c=r(70),{CircuitRelay:u}=r(32),{pipe:f}=r(23),{codes:h}=r(7),{stop:d}=r(111),l=r(46);e.exports={handleHop:async function({connection:e,request:t,streamHandler:r,circuit:n}){if(!n._options.hop.enabled)return i("HOP request received but we are not acting as a relay"),r.end({type:u.Type.STATUS,code:u.Status.HOP_CANT_SPEAK_RELAY});try{a(t,r)}catch(y){return i.error("invalid hop request via peer %s",e.remotePeer.toB58String(),y)}const s=new o(t.dstPeer.id),c=n._connectionManager.get(s);if(!c&&!n._options.hop.active)return i("HOP request received but we are not connected to the destination peer"),r.end({type:u.Type.STATUS,code:u.Status.HOP_NO_CONN_TO_DST});if(!c)return;const h={type:u.Type.STOP,dstPeer:t.dstPeer,srcPeer:t.srcPeer};let l;try{l=await d({connection:c,request:h})}catch(y){return i.error(y)}i("hop request from %s is valid",e.remotePeer.toB58String()),r.write({type:u.Type.STATUS,code:u.Status.SUCCESS});const p=r.rest();return f(p,l,p)},hop:async function({connection:e,request:t}){const{stream:r}=await e.newStream([l.relay]),n=new c({stream:r});n.write(t);const o=await n.read();if(o.code===u.Status.SUCCESS)return i("hop request was successful"),n.rest();throw i("hop request failed with code %d, closing stream",o.code),n.close(),s(new Error("HOP request failed with code "+o.code),h.ERR_HOP_REQUEST_FAILED)},canHop:async function({connection:e}){const{stream:t}=await e.newStream([l.relay]),r=new c({stream:t});r.write({type:u.Type.CAN_HOP});const n=await r.read();return await r.close(),n.code===u.Status.SUCCESS},handleCanHop:function({connection:e,streamHandler:t,circuit:r}){const n=r._options.hop.enabled;i("can hop (%s) request from %s",n,e.remotePeer.toB58String()),t.end({type:u.Type.STATUS,code:n?u.Status.SUCCESS:u.Status.HOP_CANT_SPEAK_RELAY})}}},function(e,t,r){"use strict";const n=r(9),{CircuitRelay:i}=r(32);function s(e,t){e.write({type:i.Type.STATUS,code:t})}e.exports={validateAddrs:function(e,t){try{e.dstPeer.addrs.forEach(e=>n(e))}catch(r){throw s(t,e.type===i.Type.HOP?i.Status.HOP_DST_MULTIADDR_INVALID:i.Status.STOP_DST_MULTIADDR_INVALID),r}try{e.srcPeer.addrs.forEach(e=>n(e))}catch(r){throw s(t,e.type===i.Type.HOP?i.Status.HOP_SRC_MULTIADDR_INVALID:i.Status.STOP_SRC_MULTIADDR_INVALID),r}}}},function(e,t,r){"use strict";const n=r(8),{Buffer:i}=r(11),s=(e,t,r)=>{const o=n.encode(e,t,r);return s.bytes=n.encode.bytes,t||i.from(o)};e.exports=s},function(e,t,r){"use strict";const{Buffer:n}=r(11),i=r(8),s=e=>{const t=i.decode(n.isBuffer(e)?e:(r=e,new Proxy({},{get:(e,t)=>"l"===t[0]?r[t]:r.get(parseInt(t))})));var r;return s.bytes=i.decode.bytes,t};e.exports=s},function(e,t,r){"use strict";const n=r(25);e.exports=e=>{const t=async function*(){let t=yield,r=new n;for await(const i of e)if(t)for(r.append(i);r.length>=t;){const e=r.shallowSlice(0,t);if(r.consume(t),t=yield e,!t){r.length&&(t=yield r,r=new n);break}}else t=yield r.append(i),r=new n;if(t)throw Object.assign(new Error(`stream ended before ${t} bytes became available`),{code:"ERR_UNDER_READ",buffer:r})}();return t.next(),t}},function(e,t,r){"use strict";const n=r(279);e.exports=class{constructor(e){this.hwm=e||16,this.head=new n(this.hwm),this.tail=this.head}push(e){if(!this.head.push(e)){const t=this.head;this.head=t.next=new n(2*this.head.buffer.length),this.head.push(e)}}shift(){const e=this.tail.shift();if(void 0===e&&this.tail.next){const e=this.tail.next;return this.tail.next=null,this.tail=e,this.tail.shift()}return e}isEmpty(){return this.head.isEmpty()}}},function(e,t,r){"use strict";e.exports=()=>{const e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:circuit:stop"),{error:n("libp2p:circuit:stop:err")}),{CircuitRelay:s}=r(32),o=r(46),a=r(70),{validateAddrs:c}=r(105);e.exports.handleStop=function({connection:e,request:t,streamHandler:r}){try{c(t,r)}catch(n){return i.error("invalid stop request via peer %s",e.remotePeer.toB58String(),n)}return i("stop request is valid"),r.write({type:s.Type.STATUS,code:s.Status.SUCCESS}),r.rest()},e.exports.stop=async function({connection:e,request:t}){const{stream:r}=await e.newStream([o.relay]);i("starting stop request to %s",e.remotePeer.toB58String());const n=new a({stream:r});n.write(t);const c=await n.read();if(c.code===s.Status.SUCCESS)return i("stop request to %s was successful",e.remotePeer.toB58String()),n.rest();i("stop request failed with code %d",c.code),n.close()}},function(e,t,r){"use strict";const n=r(36),i=r(282),s=r(293);e.exports.namespaceToCid=async e=>{const t=new s("utf8").encode(e),r=await i(t,"sha2-256");return new n(r)}},function(e,t,r){"use strict";(function(t){function r(e){return(4294967296+e).toString(16).substring(1)}e.exports={normalizeInput:function(e){var r;if(e instanceof Uint8Array)r=e;else if(e instanceof t)r=new Uint8Array(e);else{if("string"!=typeof e)throw new Error("Input must be an string, Buffer or Uint8Array");r=new Uint8Array(t.from(e,"utf8"))}return r},toHex:function(e){return Array.prototype.map.call(e,(function(e){return(e<16?"0":"")+e.toString(16)})).join("")},debugPrint:function(e,t,n){for(var i="\n"+e+" = ",s=0;s1&&this._buf[this._buf.byteLength-1]===u;)this._buf=this._buf.subarray(0,-1)}less(e){const t=this.list(),r=e.list();for(let n=0;ni)return!1}return t.lengthe.namespaces()),[].concat(...t))]);var t}}const h=i(f,{className:"Key",symbolName:"@ipfs/interface-datastore/key"});e.exports=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"urlAlphabet",{enumerable:!0,get:function(){return n.urlAlphabet}}),t.random=t.customRandom=t.customAlphabet=t.nanoid=void 0;var n=r(308);let i=e=>crypto.getRandomValues(new Uint8Array(e));t.random=i;let s=(e,t,r)=>{let n=(2<{let s="";for(;;){let o=r(i),a=i;for(;a--;)if(s+=e[o[a]&n]||"",s.length===t)return s}}};t.customRandom=s;t.customAlphabet=(e,t)=>s(e,t,i);t.nanoid=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e));for(;e--;){let n=63&r[e];t+=n<36?n.toString(36):n<62?(n-26).toString(36).toUpperCase():n<63?"_":"-"}return t}},function(e,t,r){"use strict";"object"!=typeof globalThis&&(Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__),e.exports=globalThis},function(e,t,r){"use strict";e.exports=r(120).TextDecoder},function(e,t,r){"use strict";const{filter:n,sortAll:i,take:s,map:o}=r(71),a=r(312);e.exports=class{async open(){}async close(){}async put(e,t,r={}){}async*putMany(e,t={}){for await(const{key:r,value:n}of e)await this.put(r,n,t),yield{key:r,value:n}}async get(e,t={}){}async*getMany(e,t={}){for await(const r of e)yield this.get(r,t)}async has(e){}async delete(e,t={}){}async*deleteMany(e,t={}){for await(const r of e)await this.delete(r,t),yield r}batch(){let e=[],t=[];return{put(t,r){e.push({key:t,value:r})},delete(e){t.push(e)},commit:async r=>{await a(this.putMany(e,r)),e=[],await a(this.deleteMany(t,r)),t=[]}}}async*_all(e,t){}async*query(e,t){let r=this._all(e,t);if(null!=e.prefix&&(r=n(r,t=>t.key.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((e,t)=>n(e,t),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((e,t)=>i(e,t),r)),null!=e.offset){let t=0;r=n(r,()=>t++>=e.offset)}null!=e.limit&&(r=s(r,e.limit)),!0===e.keysOnly&&(r=o(r,e=>({key:e.key}))),yield*r}}},function(e,t,r){"use strict";const n=r(1);e.exports.dbOpenFailedError=e=>(e=e||new Error("Cannot open database"),n(e,"ERR_DB_OPEN_FAILED")),e.exports.dbDeleteFailedError=e=>(e=e||new Error("Delete failed"),n(e,"ERR_DB_DELETE_FAILED")),e.exports.dbWriteFailedError=e=>(e=e||new Error("Write failed"),n(e,"ERR_DB_WRITE_FAILED")),e.exports.notFoundError=e=>(e=e||new Error("Not Found"),n(e,"ERR_NOT_FOUND")),e.exports.abortedError=e=>(e=e||new Error("Aborted"),n(e,"ERR_ABORTED"))},function(e,t,r){"use strict";var n=r(0);r(29),r(18),r(55),r(20),r(316),r(28),r(57),r(318),r(39),r(3);var i=n.asn1,s=e.exports=n.pki=n.pki||{},o=s.oids,a={};a.CN=o.commonName,a.commonName="CN",a.C=o.countryName,a.countryName="C",a.L=o.localityName,a.localityName="L",a.ST=o.stateOrProvinceName,a.stateOrProvinceName="ST",a.O=o.organizationName,a.organizationName="O",a.OU=o.organizationalUnitName,a.organizationalUnitName="OU",a.E=o.emailAddress,a.emailAddress="E";var c=n.pki.rsa.publicKeyValidator,u={name:"Certificate",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:i.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:i.Class.UNIVERSAL,type:i.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:i.Class.UNIVERSAL,type:i.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:i.Class.UNIVERSAL,type:i.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:i.Class.UNIVERSAL,type:i.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},c,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:i.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:i.Class.UNIVERSAL,type:i.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:i.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:i.Class.UNIVERSAL,type:i.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:i.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:i.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:i.Class.UNIVERSAL,type:i.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},f={name:"rsapss",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:i.Class.UNIVERSAL,type:i.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:i.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:i.Class.UNIVERSAL,type:i.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:i.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:i.Class.UNIVERSAL,type:i.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:i.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:i.Class.UNIVERSAL,type:i.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},h={name:"CertificationRequestInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},c,{name:"CertificationRequestInfo.attributes",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0}]}]}]},d={name:"CertificationRequest",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[h,{name:"CertificationRequest.signatureAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:i.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:i.Class.UNIVERSAL,type:i.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function l(e,t){"string"==typeof t&&(t={shortName:t});for(var r,n=null,i=0;null===n&&i128)throw new Error('Invalid "nsComment" content.');e.value=i.create(i.Class.UNIVERSAL,i.Type.IA5STRING,!1,e.comment)}else if("subjectKeyIdentifier"===e.name&&t.cert){var l=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=l.toHex(),e.value=i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,l.getBytes())}else if("authorityKeyIdentifier"===e.name&&t.cert){e.value=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);f=e.value.value;if(e.keyIdentifier){var p=!0===e.keyIdentifier?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;f.push(i.create(i.Class.CONTEXT_SPECIFIC,0,!1,p))}if(e.authorityCertIssuer){var g=[i.create(i.Class.CONTEXT_SPECIFIC,4,!0,[y(!0===e.authorityCertIssuer?t.cert.issuer:e.authorityCertIssuer)])];f.push(i.create(i.Class.CONTEXT_SPECIFIC,1,!0,g))}if(e.serialNumber){var b=n.util.hexToBytes(!0===e.serialNumber?t.cert.serialNumber:e.serialNumber);f.push(i.create(i.Class.CONTEXT_SPECIFIC,2,!1,b))}}else if("cRLDistributionPoints"===e.name){e.value=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);f=e.value.value;var m,v=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]),w=i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[]);for(d=0;d2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(h.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(c.validity.notBefore=h[0],c.validity.notAfter=h[1],c.tbsCertificate=r.tbsCertificate,t){var d;if(c.md=null,c.signatureOid in o)switch(o[c.signatureOid]){case"sha1WithRSAEncryption":c.md=n.md.sha1.create();break;case"md5WithRSAEncryption":c.md=n.md.md5.create();break;case"sha256WithRSAEncryption":c.md=n.md.sha256.create();break;case"sha384WithRSAEncryption":c.md=n.md.sha384.create();break;case"sha512WithRSAEncryption":c.md=n.md.sha512.create();break;case"RSASSA-PSS":c.md=n.md.sha256.create()}if(null===c.md)throw(d=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=c.signatureOid,d;var y=i.toDer(c.tbsCertificate);c.md.update(y.getBytes())}var b=n.md.sha1.create();c.issuer.getField=function(e){return l(c.issuer,e)},c.issuer.addField=function(e){g([e]),c.issuer.attributes.push(e)},c.issuer.attributes=s.RDNAttributesAsArray(r.certIssuer,b),r.certIssuerUniqueId&&(c.issuer.uniqueId=r.certIssuerUniqueId),c.issuer.hash=b.digest().toHex();var m=n.md.sha1.create();return c.subject.getField=function(e){return l(c.subject,e)},c.subject.addField=function(e){g([e]),c.subject.attributes.push(e)},c.subject.attributes=s.RDNAttributesAsArray(r.certSubject,m),r.certSubjectUniqueId&&(c.subject.uniqueId=r.certSubjectUniqueId),c.subject.hash=m.digest().toHex(),r.certExtensions?c.extensions=s.certificateExtensionsFromAsn1(r.certExtensions):c.extensions=[],c.publicKey=s.publicKeyFromAsn1(r.subjectPublicKeyInfo),c},s.certificateExtensionsFromAsn1=function(e){for(var t=[],r=0;r1&&(r=c.value.charCodeAt(1),s=c.value.length>2?c.value.charCodeAt(2):0),t.digitalSignature=128==(128&r),t.nonRepudiation=64==(64&r),t.keyEncipherment=32==(32&r),t.dataEncipherment=16==(16&r),t.keyAgreement=8==(8&r),t.keyCertSign=4==(4&r),t.cRLSign=2==(2&r),t.encipherOnly=1==(1&r),t.decipherOnly=128==(128&s)}else if("basicConstraints"===t.name){(c=i.fromDer(t.value)).value.length>0&&c.value[0].type===i.Type.BOOLEAN?t.cA=0!==c.value[0].value.charCodeAt(0):t.cA=!1;var a=null;c.value.length>0&&c.value[0].type===i.Type.INTEGER?a=c.value[0].value:c.value.length>1&&(a=c.value[1].value),null!==a&&(t.pathLenConstraint=i.derToInteger(a))}else if("extKeyUsage"===t.name)for(var c=i.fromDer(t.value),u=0;u1&&(r=c.value.charCodeAt(1)),t.client=128==(128&r),t.server=64==(64&r),t.email=32==(32&r),t.objsign=16==(16&r),t.reserved=8==(8&r),t.sslCA=4==(4&r),t.emailCA=2==(2&r),t.objCA=1==(1&r)}else if("subjectAltName"===t.name||"issuerAltName"===t.name){var h;t.altNames=[];c=i.fromDer(t.value);for(var d=0;d=w&&e0&&o.value.push(s.certificateExtensionsToAsn1(e.extensions)),o},s.getCertificationRequestInfo=function(e){return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(e.version).getBytes()),y(e.subject),s.publicKeyToAsn1(e.publicKey),v(e)])},s.distinguishedNameToAsn1=function(e){return y(e)},s.certificateToAsn1=function(e){var t=e.tbsCertificate||s.getTBSCertificate(e);return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[t,i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(e.signatureOid).getBytes()),m(e.signatureOid,e.signatureParameters)]),i.create(i.Class.UNIVERSAL,i.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},s.certificateExtensionsToAsn1=function(e){var t=i.create(i.Class.CONTEXT_SPECIFIC,3,!0,[]),r=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);t.value.push(r);for(var n=0;nf.validity.notAfter)&&(c={message:"Certificate is not valid yet or has expired.",error:s.certificateError.certificate_expired,notBefore:f.validity.notBefore,notAfter:f.validity.notAfter,now:o}),null===c){if(null===(h=t[0]||e.getIssuer(f))&&f.isIssuer(f)&&(d=!0,h=f),h){var l=h;n.util.isArray(l)||(l=[l]);for(var p=!1;!p&&l.length>0;){h=l.shift();try{p=h.verify(f)}catch(S){}}p||(c={message:"Certificate signature is invalid.",error:s.certificateError.bad_certificate})}null!==c||h&&!d||e.hasCertificate(f)||(c={message:"Certificate is not trusted.",error:s.certificateError.unknown_ca})}if(null===c&&h&&!f.isIssuer(h)&&(c={message:"Certificate issuer is invalid.",error:s.certificateError.bad_certificate}),null===c)for(var y={keyUsage:!0,basicConstraints:!0},g=0;null===c&&gm.pathLenConstraint&&(c={message:"Certificate basicConstraints pathLenConstraint violated.",error:s.certificateError.bad_certificate})}var w=null===c||c.error,E=r.verify?r.verify(w,u,i):w;if(!0!==E)throw!0===w&&(c={message:"The application rejected the certificate.",error:s.certificateError.bad_certificate}),(E||0===E)&&("object"!=typeof E||n.util.isArray(E)?"string"==typeof E&&(c.error=E):(E.message&&(c.message=E.message),E.error&&(c.error=E.error))),c;c=null,a=!1,++u}while(t.length>0);return!0}},function(e,t,r){"use strict";t.PROTOCOL_ID="/multistream/1.0.0"},function(e,t,r){"use strict";const n=r(1),{EventEmitter:i}=r(19),s=r(6),o=r(335),a=r(336),c=r(337),u=r(338),{codes:{ERR_INVALID_PARAMETERS:f}}=r(7);e.exports=class extends i{constructor({peerId:e}){super(),this._peerId=e,this.addressBook=new o(this),this.keyBook=new a(this),this.metadataBook=new c(this),this.protoBook=new u(this)}start(){}stop(){}get peers(){const e=new Set([...this.addressBook.data.keys(),...this.keyBook.data.keys(),...this.protoBook.data.keys(),...this.metadataBook.data.keys()]);this._peerId&&e.delete(this._peerId.toB58String());const t=new Map;return e.forEach(e=>{t.set(e,this.get(s.createFromCID(e)))}),t}delete(e){const t=this.addressBook.delete(e),r=this.keyBook.delete(e),n=this.protoBook.delete(e),i=this.metadataBook.delete(e);return t||r||n||i}get(e){if(!s.isPeerId(e))throw n(new Error("peerId must be an instance of peer-id"),f);const t=this.keyBook.data.get(e.toB58String()),r=this.addressBook.get(e),i=this.metadataBook.get(e),o=this.protoBook.get(e);if(t||r||i||o)return{id:t||e,addresses:r||[],protocols:o||[],metadata:i}}}},function(e,t,r){e.exports=r(128)},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p"),{error:n("libp2p:err")}),{EventEmitter:s}=r(19),o=r(35),a=r(1),c=r(6),u=r(224),f=r(230),h=r(95),{validate:d}=r(235),{codes:l,messages:p}=r(7),y=r(262),g=r(263),b=r(267),m=r(280),v=r(294),w=r(299),E=r(320),S=r(103),A=r(326),_=r(126),C=r(339),k=r(340),I=r(344),T=r(346),R=r(348),B=R.multicodecs;class N extends s{static async create(e){if(e.peerId)return new N(e);const t=await c.create();return e.peerId=t,new N(e)}constructor(e){if(super(),this._options=d(e),this.peerId=this._options.peerId,this.datastore=this._options.datastore,this.peerStore=this.datastore&&this._options.peerStore.persistence?new k({peerId:this.peerId,datastore:this.datastore,...this._options.peerStore}):new _({peerId:this.peerId}),this.addresses=this._options.addresses,this.addressManager=new y(this._options.addresses),this._modules=this._options.modules,this._config=this._options.config,this._transport=[],this._discovery=new Map,this._options.connectionManager.minPeers&&(this._options.connectionManager.minConnections=this._options.connectionManager.minPeers),this.connectionManager=new g(this,{autoDial:this._config.peerDiscovery.autoDial,...this._options.connectionManager}),this._options.metrics.enabled&&(this.metrics=new E({...this._options.metrics,connectionManager:this.connectionManager})),this._options.keychain&&this._options.keychain.datastore){i("creating keychain");const e=w.generateOptions();this.keychain=new w(this._options.keychain.datastore,{passPhrase:this._options.keychain.pass,...e,...this._options.keychain}),i("keychain constructed")}if(this.upgrader=new A({localPeer:this.peerId,metrics:this.metrics,onConnection:e=>this.connectionManager.onConnect(e),onConnectionEnd:e=>this.connectionManager.onDisconnect(e)}),this.transportManager=new S({libp2p:this,upgrader:this.upgrader,faultTolerance:this._options.transportManager.faultTolerance}),this.registrar=new I({peerStore:this.peerStore,connectionManager:this.connectionManager}),this.handle=this.handle.bind(this),this.registrar.handle=this.handle,!this._modules.connEncryption||!this._modules.connEncryption.length)throw a(new Error(p.CONN_ENCRYPTION_REQUIRED),l.CONN_ENCRYPTION_REQUIRED);if(this._modules.connEncryption.forEach(e=>{this.upgrader.cryptos.set(e.protocol,e)}),this.dialer=new v({transportManager:this.transportManager,peerStore:this.peerStore,concurrency:this._options.dialer.maxParallelDials,perPeerLimit:this._options.dialer.maxDialsPerPeer,timeout:this._options.dialer.dialTimeout,resolvers:this._options.dialer.resolvers,addressSorter:this._options.dialer.addressSorter}),this._modules.transport.forEach(e=>{const t=e.prototype[Symbol.toStringTag],r=this._config.transport[t];this.transportManager.add(t,e,r)}),this._config.relay.enabled&&(this.transportManager.add(b.prototype[Symbol.toStringTag],b),this.relay=new m(this)),this._modules.streamMuxer){this._modules.streamMuxer.forEach(e=>{this.upgrader.muxers.set(e.multicodec,e)}),this.identifyService=new R({libp2p:this}),this.handle(Object.values(B),this.identifyService.handleMessage)}if(this._modules.connProtector)this.upgrader.protector=this._modules.connProtector;else if(void 0!==o.process&&o.process.env&&o.process.env.LIBP2P_FORCE_PNET)throw new Error("Private network is enforced, but no protector was provided");if(this._modules.dht){const e=this._modules.dht;this._dht=new e({libp2p:this,dialer:this.dialer,peerId:this.peerId,peerStore:this.peerStore,registrar:this.registrar,datastore:this.datastore,...this._config.dht})}if(this._modules.pubsub){const e=this._modules.pubsub;this.pubsub=C(e,this,this._config.pubsub)}this.peerRouting=new u(this),this.contentRouting=new f(this),T.mount(this),this._onDiscoveryPeer=this._onDiscoveryPeer.bind(this)}emit(e,...t){return"error"!==e||this._events.error?super.emit(e,...t):(i.error(t),!1)}async start(){i("libp2p is starting");try{await this._onStarting(),await this._onDidStart(),i("libp2p has started")}catch(e){throw this.emit("error",e),i.error("An error occurred starting libp2p",e),await this.stop(),e}}async stop(){i("libp2p is stopping");try{this._isStarted=!1,this.relay&&this.relay.stop(),this.peerRouting.stop();for(const e of this._discovery.values())e.removeListener("peer",this._onDiscoveryPeer);await Promise.all(Array.from(this._discovery.values(),e=>e.stop())),this._discovery=new Map,await this.peerStore.stop(),await this.connectionManager.stop(),await Promise.all([this.pubsub&&this.pubsub.stop(),this._dht&&this._dht.stop(),this.metrics&&this.metrics.stop()]),await this.transportManager.close(),T.unmount(this),this.dialer.destroy()}catch(e){e&&(i.error(e),this.emit("error",e))}i("libp2p has stopped")}async loadKeychain(){if(this.keychain)try{await this.keychain.findKeyByName("self")}catch(e){await this.keychain.importPeer("self",this.peerId)}}isStarted(){return this._isStarted}get connections(){return this.connectionManager.connections}dial(e,t){return this.dialProtocol(e,[],t)}async dialProtocol(e,t,r){const{id:n,multiaddrs:i}=h(e);if(n.equals(this.peerId))throw a(new Error("Cannot dial self"),l.ERR_DIALED_SELF);let s=this.connectionManager.get(n);return s?i&&this.peerStore.addressBook.add(n,i):s=await this.dialer.connectToPeer(e,r),t&&t.length?s.newStream(t):s}get multiaddrs(){const e=this.addressManager.getAnnounceAddrs();if(e.length)return e;return(this._options.addresses.announceFilter||(e=>e))(this.transportManager.getAddrs())}async hangUp(e){const{id:t}=h(e),r=this.connectionManager.connections.get(t.toB58String());r&&await Promise.all(r.map(e=>e.close()))}ping(e){const{id:t,multiaddrs:r}=h(e);return T(this,r?r[0]:t)}handle(e,t){(e=Array.isArray(e)?e:[e]).forEach(e=>{this.upgrader.protocols.set(e,t)}),this.peerStore.protoBook.add(this.peerId,e)}unhandle(e){(e=Array.isArray(e)?e:[e]).forEach(e=>{this.upgrader.protocols.delete(e)}),this.peerStore.protoBook.remove(this.peerId,e)}async _onStarting(){const e=this.addressManager.getListenAddrs();await this.transportManager.listen(e),await this.peerStore.start(),this._config.pubsub.enabled&&this.pubsub&&this.pubsub.start(),this._config.dht.enabled&&(this._dht&&this._dht.start(),this._dht.on("peer",this._onDiscoveryPeer)),this.metrics&&this.metrics.start()}async _onDidStart(){this._isStarted=!0,this.peerStore.on("peer",e=>{this.emit("peer:discovery",e),this._maybeConnect(e)});for(const e of this.peerStore.peers.values())this.emit("peer:discovery",e.id);this.connectionManager.start(),await this._setupPeerDiscovery(),this.relay&&this.relay.start(),this.peerRouting.start()}_onDiscoveryPeer(e){e.id.toB58String()!==this.peerId.toB58String()?(e.multiaddrs&&this.peerStore.addressBook.add(e.id,e.multiaddrs),e.protocols&&this.peerStore.protoBook.set(e.id,e.protocols)):i.error(new Error(l.ERR_DISCOVERED_SELF))}async _maybeConnect(e){if(!0===this._config.peerDiscovery.autoDial&&!this.connectionManager.get(e)){if((this._options.connectionManager.minConnections||0)>this.connectionManager.size){i("connecting to discovered peer %s",e.toB58String());try{await this.dialer.connectToPeer(e)}catch(t){i.error("could not connect to discovered peer",t)}}}}async _setupPeerDiscovery(){const e=e=>{let t={enabled:!0};if(e.tag&&this._config.peerDiscovery&&this._config.peerDiscovery[e.tag]&&(t={...t,...this._config.peerDiscovery[e.tag]}),t.enabled&&!this._discovery.has(e.tag)){let r;r="function"==typeof e?new e(Object.assign({},t,{peerId:this.peerId,libp2p:this})):e,r.on("peer",this._onDiscoveryPeer),this._discovery.set(e.tag,r)}};for(const t of this._modules.peerDiscovery||[])e(t);for(const t of this.transportManager.getTransports())t.discovery&&e(t.discovery);await Promise.all(Array.from(this._discovery.values(),e=>e.start()))}}e.exports=N},function(e,t,r){"use strict";e.exports=function(e){function t(e){let r,i=null;function s(...e){if(!s.enabled)return;const n=s,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,i)=>{if("%%"===r)return"%";a++;const s=t.formatters[i];if("function"==typeof s){const t=e[a];r=s.call(n,t),e.splice(a,1),a--}return r}),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=n,s.destroy=t.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null===i?t.enabled(e):i,set:e=>{i=e}}),"function"==typeof t.init&&t.init(s),s}function n(e,r){const n=t(this.namespace+(void 0===r?":":r)+e);return n.log=this.log,n}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(i),...t.skips.map(i).map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.names=[],t.skips=[];const n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r{t[r]=e[r]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,u=new Uint8Array(s);e[r];){var f=t[e.charCodeAt(r)];if(255===f)return;for(var h=0,d=s-1;(0!==f||h>>0,u[d]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");i=h,r++}if(" "!==e[r]){for(var l=s-i;l!==s&&0===u[l];)l++;for(var p=new Uint8Array(n+(s-l)),y=n;l!==s;)p[y++]=u[l++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var c=(s-i)*u+1>>>0,f=new Uint8Array(c);i!==s;){for(var h=t[i],d=0,l=c-1;(0!==h||d>>0,f[l]=h%o>>>0,h=h/o>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=c-n;p!==c&&0===f[p];)p++;for(var y=a.repeat(r);pt=>({encode:r=>((e,t,r)=>{const n="="===t[t.length-1],i=(1<r;)o-=r,s+=t[i&a>>o];if(o&&(s+=t[i&a<((e,t,r)=>{const n={};for(let u=0;u=8&&(o-=8,s[c++]=255&a>>o)}if(o>=r||255&a<<8-o)throw new SyntaxError("Unexpected end of data");return s})(r,t,e)})}},function(e,t,r){"use strict";e.exports={encode:r(134),decode:r(135),encodingLength:r(136)}},function(e,t,r){"use strict";e.exports=function e(t,r,i){if(Number.MAX_SAFE_INTEGER&&t>Number.MAX_SAFE_INTEGER)throw e.bytes=0,new RangeError("Could not encode varint");r=r||[];var s=i=i||0;for(;t>=n;)r[i++]=255&t|128,t/=128;for(;-128&t;)r[i++]=255&t|128,t>>>=7;return r[i]=0|t,e.bytes=i-s+1,r};var n=Math.pow(2,31)},function(e,t,r){"use strict";e.exports=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a||s>49)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(127&n)<=128);return e.bytes=o-r,i}},function(e,t,r){"use strict";var n=Math.pow(2,7),i=Math.pow(2,14),s=Math.pow(2,21),o=Math.pow(2,28),a=Math.pow(2,35),c=Math.pow(2,42),u=Math.pow(2,49),f=Math.pow(2,56),h=Math.pow(2,63);e.exports=function(e){return eNumber.MAX_SAFE_INTEGER)throw e.bytes=0,new RangeError("Could not encode varint");r=r||[];var s=i=i||0;for(;t>=n;)r[i++]=255&t|128,t/=128;for(;-128&t;)r[i++]=255&t|128,t>>>=7;return r[i]=0|t,e.bytes=i-s+1,r};var n=Math.pow(2,31)},function(e,t,r){"use strict";e.exports=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a||s>49)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(127&n)<=128);return e.bytes=o-r,i}},function(e,t,r){"use strict";var n=Math.pow(2,7),i=Math.pow(2,14),s=Math.pow(2,21),o=Math.pow(2,28),a=Math.pow(2,35),c=Math.pow(2,42),u=Math.pow(2,49),f=Math.pow(2,56),h=Math.pow(2,63);e.exports=function(e){return e"!==e[0])throw new Error("Unexpected token in map type: "+e[0]);e.shift(),t.name=e.shift();break;case"repeated":case"required":case"optional":var r=e.shift();t.required="required"===r,t.repeated="repeated"===r,t.type=e.shift(),t.name=e.shift();break;case"[":t.options=s(e);break;case";":if(null===t.name)throw new Error("Missing field name");if(null===t.type)throw new Error("Missing type in message field: "+t.name);if(-1===t.tag)throw new Error("Missing tag number in message field: "+t.name);return e.shift(),t;default:throw new Error("Unexpected token in message field: "+e[0])}throw new Error("No ; found for message field")},a=function(e){for(var t={enums:[],options:{},messages:[],fields:[],extends:[],extensions:null};e.length;)switch(e[0]){case"map":case"repeated":case"optional":case"required":t.fields.push(o(e));break;case"enum":t.enums.push(p(e));break;case"message":t.messages.push(f(e));break;case"extensions":t.extensions=u(e);break;case"oneof":e.shift();var r=e.shift();if("{"!==e[0])throw new Error("Unexpected token in oneof: "+e[0]);for(e.shift();"}"!==e[0];){e.unshift("optional");var n=o(e);n.oneof=r,t.fields.push(n)}e.shift();break;case"extend":t.extends.push(c(e));break;case";":e.shift();break;case"reserved":for(e.shift();";"!==e[0];)e.shift();break;case"option":var i=y(e);if(void 0!==t.options[i.name])throw new Error("Duplicate option "+i.name);t.options[i.name]=i.value;break;default:e.unshift("optional"),t.fields.push(o(e))}return t},c=function(e){return{name:e[1],message:f(e)}},u=function(e){e.shift();var t=Number(e.shift());if(isNaN(t))throw new Error("Invalid from in extensions definition");if("to"!==e.shift())throw new Error("Expected keyword 'to' in extensions definition");var r=e.shift();if("max"===r&&(r=536870911),r=Number(r),isNaN(r))throw new Error("Invalid to in extensions definition");if(";"!==e.shift())throw new Error("Missing ; in extensions definition");return{from:t,to:r}},f=function(e){e.shift();var t=1,r=[],n={name:e.shift(),options:{},enums:[],extends:[],messages:[],fields:[]};if("{"!==e[0])throw new Error("Expected { but found "+e[0]);for(e.shift();e.length;){if("{"===e[0]?t++:"}"===e[0]&&t--,!t)return e.shift(),r=a(r),n.enums=r.enums,n.messages=r.messages,n.fields=r.fields,n.extends=r.extends,n.extensions=r.extensions,n.options=r.options,n;r.push(e.shift())}if(t)throw new Error("No closing tag for message")},h=function(e){e.shift();var t=e.shift();if(";"!==e[0])throw new Error("Expected ; but found "+e[0]);return e.shift(),t},d=function(e){if(e.shift(),"="!==e[0])throw new Error("Expected = but found "+e[0]);e.shift();var t=e.shift();switch(t){case'"proto2"':t=2;break;case'"proto3"':t=3;break;default:throw new Error("Expected protobuf syntax version but found "+t)}if(";"!==e[0])throw new Error("Expected ; but found "+e[0]);return e.shift(),t},l=function(e){if(e.length<4)throw new Error("Invalid enum value: "+e.slice(0,3).join(" "));if("="!==e[1])throw new Error("Expected = but found "+e[1]);if(";"!==e[3]&&"["!==e[3])throw new Error("Expected ; or [ but found "+e[1]);var t=e.shift();e.shift();var r={value:null,options:{}};return r.value=Number(e.shift()),"["===e[0]&&(r.options=s(e)),e.shift(),{name:t,val:r}},p=function(e){e.shift();var t={},r={name:e.shift(),values:{},options:{}};if("{"!==e[0])throw new Error("Expected { but found "+e[0]);for(e.shift();e.length;){if("}"===e[0])return e.shift(),";"===e[0]&&e.shift(),r;if("option"!==e[0]){var n=l(e);r.values[n.name]=n.val}else t=y(e),r.options[t.name]=t.value}throw new Error("No closing tag for enum")},y=function(e){for(var t=null,r=null,n=function(e){return"true"===e||"false"!==e&&e.replace(/^"+|"+$/gm,"")};e.length;){if(";"===e[0])return e.shift(),{name:t,value:r};switch(e[0]){case"option":e.shift();var i="("===e[0];if(i&&e.shift(),t=e.shift(),i){if(")"!==e[0])throw new Error("Expected ) but found "+e[0]);e.shift()}"."===e[0][0]&&(t+=e.shift());break;case"=":if(e.shift(),null===t)throw new Error("Expected key for option with value: "+e[0]);if(r=n(e.shift()),"optimize_for"===t&&!/^(SPEED|CODE_SIZE|LITE_RUNTIME)$/.test(r))throw new Error("Unexpected value for option optimize_for: "+r);"{"===r&&(r=g(e));break;default:throw new Error("Unexpected token in option: "+e[0])}}},g=function(e){for(var t=function(e){return"true"===e||"false"!==e&&e.replace(/^"+|"+$/gm,"")},r={};e.length;){if("}"===e[0])return e.shift(),r;var n="("===e[0];n&&e.shift();var i=e.shift();if(n){if(")"!==e[0])throw new Error("Expected ) but found "+e[0]);e.shift()}var s=null;switch(e[0]){case":":if(void 0!==r[i])throw new Error("Duplicate option map key "+i);e.shift(),"{"===(s=t(e.shift()))&&(s=g(e)),r[i]=s,";"===e[0]&&e.shift();break;case"{":if(e.shift(),s=g(e),void 0===r[i]&&(r[i]=[]),!Array.isArray(r[i]))throw new Error("Duplicate option map key "+i);r[i].push(s);break;default:throw new Error("Unexpected token in option map: "+e[0])}}throw new Error("No closing tag for option map")},b=function(e){e.shift();var t=e.shift().replace(/^"+|"+$/gm,"");if(";"!==e[0])throw new Error("Unexpected token: "+e[0]+'. Expected ";"');return e.shift(),t},m=function(e){e.shift();var t={name:e.shift(),methods:[],options:{}};if("{"!==e[0])throw new Error("Expected { but found "+e[0]);for(e.shift();e.length;){if("}"===e[0])return e.shift(),";"===e[0]&&e.shift(),t;switch(e[0]){case"option":var r=y(e);if(void 0!==t.options[r.name])throw new Error("Duplicate option "+r.name);t.options[r.name]=r.value;break;case"rpc":t.methods.push(v(e));break;default:throw new Error("Unexpected token in service: "+e[0])}}throw new Error("No closing tag for service")},v=function(e){e.shift();var t={name:e.shift(),input_type:null,output_type:null,client_streaming:!1,server_streaming:!1,options:{}};if("("!==e[0])throw new Error("Expected ( but found "+e[0]);if(e.shift(),"stream"===e[0]&&(e.shift(),t.client_streaming=!0),t.input_type=e.shift(),")"!==e[0])throw new Error("Expected ) but found "+e[0]);if(e.shift(),"returns"!==e[0])throw new Error("Expected returns but found "+e[0]);if(e.shift(),"("!==e[0])throw new Error("Expected ( but found "+e[0]);if(e.shift(),"stream"===e[0]&&(e.shift(),t.server_streaming=!0),t.output_type=e.shift(),")"!==e[0])throw new Error("Expected ) but found "+e[0]);if(e.shift(),";"===e[0])return e.shift(),t;if("{"!==e[0])throw new Error("Expected { but found "+e[0]);for(e.shift();e.length;){if("}"===e[0])return e.shift(),";"===e[0]&&e.shift(),t;if("option"!==e[0])throw new Error("Unexpected token in rpc options: "+e[0]);var r=y(e);if(void 0!==t.options[r.name])throw new Error("Duplicate option "+r.name);t.options[r.name]=r.value}throw new Error("No closing tag for rpc")};e.exports=function(e){for(var t=n(e.toString()),r=0;rt.extensions.to)throw new Error(t.name+" does not declare "+e.tag+" as an extension number");t.fields.push(e)}))}))})),o.messages.forEach((function(e){e.fields.forEach((function(t){var r,n,s,a;if(t.options&&"true"===t.options.packed&&-1===i.indexOf(t.type)){if(-1===t.type.indexOf(".")){if(e.enums&&e.enums.some((function(e){return e.name===t.type})))return}else{if((r=t.type.split(".")).length>2)throw new Error("what is this?");if(n=r[0],s=r[1],o.messages.some((function(e){if(e.name===n)return a=e,e})),a&&a.enums&&a.enums.some((function(e){return e.name===s})))return}throw new Error("Fields of type "+t.type+' cannot be declared [packed=true]. Only repeated fields of primitive numeric types (types which use the varint, 32-bit, or 64-bit wire types) can be declared "packed". See https://developers.google.com/protocol-buffers/docs/encoding#optional')}}))})),o}},function(e,t,r){"use strict";e.exports=function(e){var t,r=function(e){return e.trim()};return e.replace(/([;,{}()=:[\]<>]|\/\*|\*\/)/g," $1 ").split(/\n/).map(r).filter(Boolean).map((function(e){var t=e.indexOf("//");return t>-1?e.slice(0,t):e})).map(r).filter(Boolean).join("\n").split(/\s+|\n+/gm).filter((t=!1,function(e){return"/*"===e?(t=!0,!1):"*/"===e?(t=!1,!1):!t}))}},function(e,t,r){"use strict";var n=function(e,t){var r=e.repeated?"repeated":e.required?"required":"optional";"map"===e.type&&(r="map<"+e.map.from+","+e.map.to+">"),e.oneof&&(r="");var n=Object.keys(e.options||{}).map((function(t){return t+" = "+e.options[t]})).join(",");return n&&(n=" ["+n+"]"),t.push((r?r+" ":"")+("map"===e.map?"":e.type+" ")+e.name+" = "+e.tag+n+";"),t},i=function(e,t){t.push("message "+e.name+" {"),e.options||(e.options={}),a(e.options,t),e.enums||(e.enums=[]),e.enums.forEach((function(e){t.push(s(e,[]))})),e.messages||(e.messages=[]),e.messages.forEach((function(e){t.push(i(e,[]))}));var r={};return e.fields||(e.fields=[]),e.fields.forEach((function(e){e.oneof?(r[e.oneof]||(r[e.oneof]=[]),r[e.oneof].push(n(e,[]))):t.push(n(e,[]))})),Object.keys(r).forEach((function(e){r[e].unshift("oneof "+e+" {"),r[e].push("}"),t.push(r[e])})),t.push("}",""),t},s=function(e,t){t.push("enum "+e.name+" {"),e.options||(e.options={});var r=a(e.options,[]);return r.length>1&&t.push(r.slice(0,-1)),Object.keys(e.values).map((function(r){var n=o(e.values[r]);t.push([r+" = "+n+";"])})),t.push("}",""),t},o=function(e,t){var r=Object.keys(e.options||{}).map((function(t){return t+" = "+e.options[t]})).join(",");return r&&(r=" ["+r+"]"),e.value+r},a=function(e,t){var r=Object.keys(e);return r.forEach((function(r){var n=e[r];~r.indexOf(".")&&(r="("+r+")");var i=typeof n;"object"===i?(n=c(n,[])).length&&t.push("option "+r+" = {",n,"};"):("string"===i&&"optimize_for"!==r&&(n='"'+n+'"'),t.push("option "+r+" = "+n+";"))})),r.length>0&&t.push(""),t},c=function(e,t){return Object.keys(e).forEach((function(r){var n=e[r],i=typeof n;"object"===i?Array.isArray(n)?n.forEach((function(e){(e=c(e,[])).length&&t.push(r+" {",e,"}")})):(n=c(n,[])).length&&t.push(r+" {",n,"}"):("string"===i&&(n='"'+n+'"'),t.push(r+": "+n))})),t},u=function(e,t){var r="rpc "+e.name+"(";e.client_streaming&&(r+="stream "),r+=e.input_type+") returns (",e.server_streaming&&(r+="stream "),r+=e.output_type+")",e.options||(e.options={});var n=a(e.options,[]);return n.length>1?t.push(r+" {",n.slice(0,-1),"}"):t.push(r+";"),t},f=function(e){return function(t){return Array.isArray(t)?t.map(f(e+" ")).join("\n"):e+t}};e.exports=function(e){var t=[];return t.push('syntax = "proto'+e.syntax+'";',""),e.package&&t.push("package "+e.package+";",""),e.options||(e.options={}),a(e.options,t),e.enums||(e.enums=[]),e.enums.forEach((function(e){s(e,t)})),e.messages||(e.messages=[]),e.messages.forEach((function(e){i(e,t)})),e.services&&e.services.forEach((function(e){!function(e,t){t.push("service "+e.name+" {"),e.options||(e.options={}),a(e.options,t),e.methods||(e.methods=[]),e.methods.forEach((function(e){t.push(u(e,[]))})),t.push("}","")}(e,t)})),t.map(f("")).join("\n")}},function(e,t,r){"use strict";const n=r(151),i=r(168),s=r(169),o=r(170),a=r(8);e.exports=function(e,t){const r={},c={},u={},f=function(e,t){e.enums&&e.enums.forEach((function(e){e.id=t+(t?".":"")+e.name,c[e.id]=e,f(e,e.id)})),e.messages&&e.messages.forEach((function(n){n.id=t+(t?".":"")+n.name,r[n.id]=n,n.fields.forEach((function(n){if(!n.map)return;const i="Map_"+n.map.from+"_"+n.map.to,s={name:i,enums:[],messages:[],fields:[{name:"key",type:n.map.from,tag:1,repeated:!1,required:!0},{name:"value",type:n.map.to,tag:2,repeated:!1,required:!1}],extensions:null,id:t+(t?".":"")+i};r[s.id]||(r[s.id]=s,e.messages.push(s)),n.type=i,n.repeated=!0})),f(n,n.id)}))};f(e,"");const h=function(e,t){e.messages.forEach((function(r){t[r.name]=d(r.name,e.id)})),e.enums.forEach((function(e){t[e.name]=function(e){if(!e)return null;const t={};return Object.keys(e).forEach((function(r){t[r]=e[r].value})),t}(e.values)})),t.type=2,t.message=!0,t.name=e.name;const r={};e.fields.forEach((function(e){e.oneof&&(r[e.oneof]||(r[e.oneof]=[]),r[e.oneof].push(e.name))}));const n=e.fields.map((function(t){return d(t.type,e.id)})),a=o(e,n,r),c=s(e,d,n,r,a),u=i(e,d,n);return c.bytes=u.bytes=0,t.buffer=!0,t.encode=c,t.decode=u,t.encodingLength=a,t},d=function(e,i,s){if(t&&t[e])return t[e];if(n[e])return n[e];const o=(i?i+"."+e:e).split(".").map((function(t,r,n){return n.slice(0,r).concat(e).join(".")})).reverse().reduce((function(e,t){return e||r[t]||c[t]}),null);if(!1===s)return o;if(!o)throw new Error("Could not resolve "+e);if(o.values)return function(e){const t=Object.keys(e.values||[]).map((function(t){return parseInt(e.values[t].value,10)}));return n.make(0,(function e(r,n,i,s){if(!t.length||-1===t.indexOf(r))throw new Error("Invalid enum value: "+r);return a.encode(r,n,s),e.bytes=a.encode.bytes,n}),(function e(r,n,i){var s=a.decode(r,i);if(!t.length||-1===t.indexOf(s))throw new Error("Invalid enum value: "+s);return e.bytes=a.decode.bytes,s}),a.encodingLength)}(o);return u[o.id]||h(o,u[o.id]={})};return(e.enums||[]).concat((e.messages||[]).map((function(e){return d(e.id)})))}},function(e,t,r){"use strict";t.make=r(10),t.bytes=r(152),t.string=r(156),t.bool=r(157),t.int32=r(158),t.int64=r(159),t.sint32=t.sint64=r(160),t.uint32=t.uint64=t.enum=t.varint=r(162),t.fixed64=t.sfixed64=r(163),t.double=r(164),t.fixed32=r(165),t.sfixed32=r(166),t.float=r(167)},function(e,t,r){"use strict";const n=r(8),i=r(10);function s(e){return e.byteLength}e.exports=i(2,(function e(t,r,i,o){const a=o,c=s(t);n.encode(c,r,o),o+=n.encode.bytes,r.set(t,o),e.bytes=(o+=c)-a}),(function e(t,r,i){const s=i,o=n.decode(t,i);i+=n.decode.bytes;const a=t.slice(i,i+o);return i+=a.length,e.bytes=i-s,a}),(function(e){const t=s(e);return n.encodingLength(t)+t}))},function(e,t,r){"use strict";e.exports=function e(t,r,i){r=r||[];var s=i=i||0;for(;t>=n;)r[i++]=255&t|128,t/=128;for(;-128&t;)r[i++]=255&t|128,t>>>=7;return r[i]=0|t,e.bytes=i-s+1,r};var n=Math.pow(2,31)},function(e,t,r){"use strict";e.exports=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(127&n)<=128);return e.bytes=o-r,i}},function(e,t,r){"use strict";var n=Math.pow(2,7),i=Math.pow(2,14),s=Math.pow(2,21),o=Math.pow(2,28),a=Math.pow(2,35),c=Math.pow(2,42),u=Math.pow(2,49),f=Math.pow(2,56),h=Math.pow(2,63);e.exports=function(e){return e0;return e.bytes=1,i}),(function(){return 1}))},function(e,t,r){"use strict";const n=r(8),i=r(10);e.exports=i(0,(function e(t,r,i,s){n.encode(t<0?t+4294967296:t,r,s),e.bytes=n.encode.bytes}),(function e(t,r,i){const s=n.decode(t,i);return e.bytes=n.decode.bytes,s>2147483647?s-4294967296:s}),(function(e){return n.encodingLength(e<0?e+4294967296:e)}))},function(e,t,r){"use strict";const n=r(8),i=r(10);e.exports=i(0,(function e(t,r,i,s){if(t<0){const i=s+9;for(n.encode(-1*t,r,s),r[s+=n.encode.bytes-1]=128|r[s];s=Math.pow(2,63)){let r=9;for(;255===t[i+r-1];)r--;r=r||9;const o=t.subarray(i,i+r);o[r-1]=127&o[r-1],s=-1*n.decode(o,0),e.bytes=10}else e.bytes=n.decode.bytes;return s}),(function(e){return e<0?10:n.encodingLength(e)}))},function(e,t,r){"use strict";const n=r(161),i=r(10);e.exports=i(0,(function e(t,r,i,s){n.encode(t,r,s),e.bytes=n.encode.bytes}),(function e(t,r,i){const s=n.decode(t,i);return e.bytes=n.decode.bytes,s}),n.encodingLength)},function(e,t,r){"use strict";var n=r(8);t.encode=function e(t,r,i){t=t>=0?2*t:-2*t-1;var s=n.encode(t,r,i);return e.bytes=n.encode.bytes,s},t.decode=function e(t,r){var i=n.decode(t,r);return e.bytes=n.decode.bytes,1&i?(i+1)/-2:i/2},t.encodingLength=function(e){return n.encodingLength(e>=0?2*e:-2*e-1)}},function(e,t,r){"use strict";const n=r(8),i=r(10);e.exports=i(0,(function e(t,r,i,s){n.encode(t,r,s),e.bytes=n.encode.bytes}),(function e(t,r,i){const s=n.decode(t,i);return e.bytes=n.decode.bytes,s}),n.encodingLength)},function(e,t,r){"use strict";const n=r(10);e.exports=n(1,(function e(t,r,n,i){for(const s of t)r[i]=s,i++;e.bytes=8}),(function e(t,r,n){const i=t.slice(n,n+8);return e.bytes=8,i}),(function(){return 8}))},function(e,t,r){"use strict";const n=r(10);e.exports=n(1,(function e(t,r,n,i){n.setFloat64(i,t,!0),e.bytes=8}),(function e(t,r,n){const i=r.getFloat64(n,!0);return e.bytes=8,i}),(function(){return 8}))},function(e,t,r){"use strict";const n=r(10);e.exports=n(5,(function e(t,r,n,i){n.setUint32(i,t,!0),e.bytes=4}),(function e(t,r,n){const i=r.getUint32(n,!0);return e.bytes=4,i}),(function(e){return 4}))},function(e,t,r){"use strict";const n=r(10);e.exports=n(5,(function e(t,r,n,i){n.setInt32(i,t,!0),e.bytes=4}),(function e(t,r,n){const i=r.getInt32(n,!0);return e.bytes=4,i}),(function(e){return 4}))},function(e,t,r){"use strict";const n=r(10);e.exports=n(5,(function e(t,r,n,i){n.setFloat32(i,t,!0),e.bytes=4}),(function e(t,r,n){const i=r.getFloat32(n,!0);return e.bytes=4,i}),(function(){return 4}))},function(e,t,r){"use strict";const n=r(8),i=r(53).defined;function s(e){return`${e.substring(0,1).toUpperCase()}${e.substring(1)}`}function o(e,t,r,n){if(Object.prototype.hasOwnProperty.call(e,t))return;const i=s(t);Object.defineProperties(e,{[t]:{enumerable:!0,configurable:!0,set:e=>{r=e},get:()=>void 0===r?n:r},["has"+i]:{configurable:!0,value:()=>void 0!==r},["set"+i]:{configurable:!0,value:e=>{r=e}},["get"+i]:{configurable:!0,value:()=>r},["clear"+i]:{configurable:!0,value:()=>{r=void 0,e[t]=void 0}}})}var a=function(e,t,r,i){switch(e){case 0:return n.decode(t,i),i+n.decode.bytes;case 1:return i+8;case 2:var s=n.decode(t,i);return i+n.decode.bytes+s;case 3:case 4:throw new Error("Groups are not supported");case 5:return i+4;default:throw new Error("Unknown wire type: "+e)}},c=function(e){if(e.map)return{};if(e.repeated)return[];switch(e.type){case"string":return"";case"bool":return!1;case"float":case"double":case"sfixed32":case"fixed32":case"varint":case"enum":case"uint64":case"uint32":case"int64":case"int32":case"sint64":case"sint32":return 0;default:return null}},u=function(e,t){if(void 0===t)return t;switch(e.type){case"bool":return"true"===t;case"float":case"double":case"sfixed32":case"fixed32":case"varint":case"enum":case"uint64":case"uint32":case"int64":case"int32":case"sint64":case"sint32":return parseInt(t,10);default:return t}};e.exports=function(e,t,r){const f=[],h={},d=[],l=[];for(var p=0;p-1){const t=s(e[h]);delete r["has"+t],delete r["get"+t],delete r["set"+t],delete r["clear"+t],delete r[e[h]]}}let l;if(e.message){const s=n.decode(i,c);c+=n.decode.bytes;const o=e.decode(i,a,c,c+s);t.map?(l=r[f]||{},l[o.key]=o.value):t.repeated?(l=r[f]||[],l.push(o)):l=o}else t.repeated?(l=r[f]||[],l.push(e.decode(i,a,c))):l=e.decode(i,a,c);return o(r,f,l),c+=e.decode.bytes}return function t(s,p,g,b){if(null==g&&(g=0),null==b&&(b=s.length),!(b<=s.length&&g<=s.length))throw new Error("Decoded message is not valid");p||(p=new DataView(s.buffer,s.byteOffset,s.byteLength));for(var m,v=g,w={};;){if(b<=g){var E,S,A="",_=0;for(_=0;_-1){C=!0;break}C||(E?m.repeated?S=[]:(S=S&&E[S]?E[S].value:E[Object.keys(E)[0]].value,S=parseInt(S||0,10)):(t=c(m),S=u(m,S)),o(w,A,S,t))}}return t.bytes=g-v,w}var T=n.decode(s,g);g+=n.decode.bytes;var R=h[T>>3];if(null!=R){var B=r[R];if((m=e.fields[R]).packed){var N=n.decode(s,g);for(N+=g+=n.decode.bytes;g-1){if(m)throw new Error("only one of the properties defined in oneof "+e+" can be set");m=!0}}for(b=0;b0?o-4:o;for(r=0;r>16&255,c[f++]=t>>8&255,c[f++]=255&t;2===a&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,c[f++]=255&t);1===a&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,c[f++]=t>>8&255,c[f++]=255&t);return c},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,s=[],o=0,a=r-i;oa?a:o+16383));1===i?(t=e[r-1],s.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],s.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return s.join("")};for(var n=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function f(e,t,r){for(var i,s,o=[],a=t;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t,r){"use strict";t.read=function(e,t,r,n,i){var s,o,a=8*i-n-1,c=(1<>1,f=-7,h=r?i-1:0,d=r?-1:1,l=e[t+h];for(h+=d,s=l&(1<<-f)-1,l>>=-f,f+=a;f>0;s=256*s+e[t+h],h+=d,f-=8);for(o=s&(1<<-f)-1,s>>=-f,f+=n;f>0;o=256*o+e[t+h],h+=d,f-=8);if(0===s)s=1-u;else{if(s===c)return o?NaN:1/0*(l?-1:1);o+=Math.pow(2,n),s-=u}return(l?-1:1)*o*Math.pow(2,s-n)},t.write=function(e,t,r,n,i,s){var o,a,c,u=8*s-i-1,f=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:s-1,p=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=f):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(o++,c/=2),o+h>=f?(a=0,o=f):o+h>=1?(a=(t*c-1)*Math.pow(2,i),o+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[r+l]=255&a,l+=p,a/=256,i-=8);for(o=o<0;e[r+l]=255&o,l+=p,o/=256,u-=8);e[r+l-p]|=128*y}},function(e,t,r){"use strict";var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,r){"use strict";(function(t){var r={};e.exports=r;var n={};r.encode=function(e,t,r){if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var i=0,s=t.length,o=t.charAt(0),a=[0];for(i=0;i0;)a.push(u%s),u=u/s|0}for(i=0;0===e[i]&&i=0;--i)n+=t[a[i]]}else n=function(e,t){var r=0,n=t.length,i=t.charAt(0),s=[0];for(r=0;r0;)s.push(a%n),a=a/n|0}var c="";for(r=0;0===e.at(r)&&r=0;--r)c+=t[s[r]];return c}(e,t);if(r){var f=new RegExp(".{1,"+r+"}","g");n=n.match(f).join("\r\n")}return n},r.decode=function(e,r){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if("string"!=typeof r)throw new TypeError('"alphabet" must be a string.');var i=n[r];if(!i){i=n[r]=[];for(var s=0;s>=8;for(;h>0;)c.push(255&h),h>>=8}for(var d=0;e[d]===a&&dt.blockLength&&(t.start(),t.update(o.bytes()),o=t.digest()),r=n.util.createBuffer(),i=n.util.createBuffer(),u=o.length();for(c=0;c>>0,a>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=a[1],a[1]=a[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(s),c(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var o=n.util.createBuffer();o.putBytes(t.bytes());var a,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;o.putBytes(s.substr(0,i.blockLength-u));for(var f=8*i.fullMessageLength[0],h=0;h>>0,o.putInt32(f>>>0),f=a>>>0;o.putInt32(f);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};c(d,r,o);var l=n.util.createBuffer();return l.putInt32(d.h0),l.putInt32(d.h1),l.putInt32(d.h2),l.putInt32(d.h3),l.putInt32(d.h4),l.putInt32(d.h5),l.putInt32(d.h6),l.putInt32(d.h7),l},i};var s=null,o=!1,a=null;function c(e,t,r){for(var n,i,s,o,c,u,f,h,d,l,p,y,g,b=r.length();b>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)n=((n=t[c-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=t[c-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[c]=n+t[c-7]+i+t[c-16]|0;for(u=e.h0,f=e.h1,h=e.h2,d=e.h3,l=e.h4,p=e.h5,y=e.h6,g=e.h7,c=0;c<64;++c)s=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),o=u&f|h&(u^f),n=g+((l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(y^l&(p^y))+a[c]+t[c],g=y,y=p,p=l,l=d+n>>>0,d=h,h=f,f=u,u=n+(i=s+o)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+f|0,e.h2=e.h2+h|0,e.h3=e.h3+d|0,e.h4=e.h4+l|0,e.h5=e.h5+p|0,e.h6=e.h6+y|0,e.h7=e.h7+g|0,b-=64}}},function(e,t,r){"use strict";(function(t){var n=r(0);r(3);var i=null;!n.util.isNodejs||n.options.usePureJavaScript||t.versions["node-webkit"]||(i=r(56)),(e.exports=n.prng=n.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=e.md,s=new Array(32),o=0;o<32;++o)s[o]=r.create();function a(){if(t.pools[0].messageLength>=32)return c();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),c()}function c(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,n=0;n<32;++n)t.reseeds%r==0&&(e.update(t.pools[n].digest().getBytes()),t.pools[n].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var i=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(i),t.generated=0}function u(e){var t=null,r=n.util.globalScope,i=r.crypto||r.msCrypto;i&&i.getRandomValues&&(t=function(e){return i.getRandomValues(e)});var s=n.util.createBuffer();if(t)for(;s.length()>16)))<<16,d=4294967295&(f=(2147483647&(f+=u>>15))+(f>>31));for(c=0;c<3;++c)h=d>>>(c<<3),h^=Math.floor(256*Math.random()),s.putByte(String.fromCharCode(255&h))}return s.getBytes(e)}return t.pools=s,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var i=t.plugin.cipher,s=t.plugin.increment,o=t.plugin.formatKey,a=t.plugin.formatSeed,u=n.util.createBuffer();t.key=null,function f(h){if(h)return r(h);if(u.length()>=e)return r(null,u.getBytes(e));t.generated>1048575&&(t.key=null);if(null===t.key)return n.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return c(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,n){if(r)return e(r);t.collect(n),c(),e()}))}(f)}));var d=i(t.key,t.seed);t.generated+=d.length,u.putBytes(d),t.key=o(i(t.key,s(t.seed))),t.seed=a(i(t.key,t.seed)),n.util.setImmediate(f)}()},t.generateSync=function(e){var r=t.plugin.cipher,i=t.plugin.increment,s=t.plugin.formatKey,o=t.plugin.formatSeed;t.key=null;for(var c=n.util.createBuffer();c.length()1048575&&(t.key=null),null===t.key&&a();var u=r(t.key,t.seed);t.generated+=u.length,c.putBytes(u),t.key=s(r(t.key,i(t.seed))),t.seed=o(r(t.key,t.seed))}return c.getBytes(e)},i?(t.seedFile=function(e,t){i.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return i.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,u(e))}catch(r){t(r)}},t.seedFileSync=u),t.collect=function(e){for(var r=e.length,n=0;n>i&255);t.collect(n)},t.registerWorker=function(e){if(e===self)t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&t.seedFile(n.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))}},t}}).call(this,r(34))},function(e,t,r){"use strict";var n=r(0);r(3);var i=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],s=[1,2,3,5],o=function(e,t){return e<>16-t},a=function(e,t){return(65535&e)>>t|e<<16-t&65535};e.exports=n.rc2=n.rc2||{},n.rc2.expandKey=function(e,t){"string"==typeof e&&(e=n.util.createBuffer(e)),t=t||128;var r,s=e,o=e.length(),a=t,c=Math.ceil(a/8),u=255>>(7&a);for(r=o;r<128;r++)s.putByte(i[s.at(r-1)+s.at(r-o)&255]);for(s.setAt(128-c,i[s.at(128-c)&u]),r=127-c;r>=0;r--)s.setAt(r,i[s.at(r+1)^s.at(r+c)]);return s};var c=function(e,t,r){var i,c,u,f,h=!1,d=null,l=null,p=null,y=[];for(e=n.rc2.expandKey(e,t),u=0;u<64;u++)y.push(e.getInt16Le());r?(i=function(e){for(u=0;u<4;u++)e[u]+=y[f]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),e[u]=o(e[u],s[u]),f++},c=function(e){for(u=0;u<4;u++)e[u]+=y[63&e[(u+3)%4]]}):(i=function(e){for(u=3;u>=0;u--)e[u]=a(e[u],s[u]),e[u]-=y[f]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),f--},c=function(e){for(u=3;u>=0;u--)e[u]-=y[63&e[(u+3)%4]]});var g=function(e){var t=[];for(u=0;u<4;u++){var n=d.getInt16Le();null!==p&&(r?n^=p.getInt16Le():p.putInt16Le(n)),t.push(65535&n)}f=r?0:63;for(var i=0;i=8;)g([[5,i],[1,c],[6,i],[1,c],[5,i]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,d,!r);else{var n=8===d.length()?8:8-d.length();d.fillWithByte(n,n)}if(t&&(h=!0,b.update()),!r&&(t=0===d.length()))if(e)t=e(8,l,!r);else{var i=l.length(),s=l.at(i-1);s>i?t=!1:l.truncate(s)}return t}}};n.rc2.startEncrypting=function(e,t,r){var i=n.rc2.createEncryptionCipher(e,128);return i.start(t,r),i},n.rc2.createEncryptionCipher=function(e,t){return c(e,t,!0)},n.rc2.startDecrypting=function(e,t,r){var i=n.rc2.createDecryptionCipher(e,128);return i.start(t,r),i},n.rc2.createDecryptionCipher=function(e,t){return c(e,t,!1)}},function(e,t,r){"use strict";var n=r(0);r(3),r(21),r(180);var i=e.exports=n.pkcs1=n.pkcs1||{};function s(e,t,r){r||(r=n.md.sha1.create());for(var i="",s=Math.ceil(t/r.digestLength),o=0;o>24&255,o>>16&255,o>>8&255,255&o);r.start(),r.update(e+a),i+=r.digest().getBytes()}return i.substring(0,t)}i.encode_rsa_oaep=function(e,t,r){var i,o,a,c;"string"==typeof r?(i=r,o=arguments[3]||void 0,a=arguments[4]||void 0):r&&(i=r.label||void 0,o=r.seed||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(c=r.mgf1.md)),a?a.start():a=n.md.sha1.create(),c||(c=a);var u=Math.ceil(e.n.bitLength()/8),f=u-2*a.digestLength-2;if(t.length>f)throw(g=new Error("RSAES-OAEP input message length is too long.")).length=t.length,g.maxLength=f,g;i||(i=""),a.update(i,"raw");for(var h=a.digest(),d="",l=f-t.length,p=0;p>>0,c>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=c[1],c[1]=c[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,c[0]=c[1]/4294967296>>>0;return t.putBytes(s),a(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var o=n.util.createBuffer();o.putBytes(t.bytes());var c,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;o.putBytes(s.substr(0,i.blockLength-u));for(var f=8*i.fullMessageLength[0],h=0;h>>0,o.putInt32(f>>>0),f=c>>>0;o.putInt32(f);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};a(d,r,o);var l=n.util.createBuffer();return l.putInt32(d.h0),l.putInt32(d.h1),l.putInt32(d.h2),l.putInt32(d.h3),l.putInt32(d.h4),l},i};var s=null,o=!1;function a(e,t,r){for(var n,i,s,o,a,c,u,f=r.length();f>=64;){for(i=e.h0,s=e.h1,o=e.h2,a=e.h3,c=e.h4,u=0;u<16;++u)n=r.getInt32(),t[u]=n,n=(i<<5|i>>>27)+(a^s&(o^a))+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<20;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(a^s&(o^a))+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<32;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(s^o^a)+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<40;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(s^o^a)+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<60;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(s&o|a&(s^o))+c+2400959708+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<80;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(s^o^a)+c+3395469782+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+s|0,e.h2=e.h2+o|0,e.h3=e.h3+a|0,e.h4=e.h4+c|0,f-=64}}},function(e,t,r){"use strict";var n=r(0);r(3),r(40),r(21),function(){if(n.prime)e.exports=n.prime;else{var t=e.exports=n.prime=n.prime||{},r=n.jsbn.BigInteger,i=[6,4,2,4,2,4,6,2],s=new r(null);s.fromInt(30);var o=function(e,t){return e|t};t.generateProbablePrime=function(e,t,i){"function"==typeof t&&(i=t,t={});var s=(t=t||{}).algorithm||"PRIMEINC";"string"==typeof s&&(s={name:s}),s.options=s.options||{};var o=t.prng||n.random,u={nextBytes:function(e){for(var t=o.getBytesSync(e.length),r=0;re&&(o=c(e,t));var l=o.toString(16);i.target.postMessage({hex:l,workLoad:f}),o.dAddOffset(h,0)}}}l()}(e,t,i,s);return a(e,t,i,s)}(e,u,s.options,i);throw new Error("Invalid prime generation algorithm: "+s.name)}}function a(e,t,r,s){var o=c(e,t),a=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(o.bitLength());"millerRabinTests"in r&&(a=r.millerRabinTests);var u=10;"maxBlockTime"in r&&(u=r.maxBlockTime),function e(t,r,s,o,a,u,f){var h=+new Date;do{if(t.bitLength()>r&&(t=c(r,s)),t.isProbablePrime(a))return f(null,t);t.dAddOffset(i[o++%8],0)}while(u<0||+new Date-ht.encrypt(e))},t.decrypt=function(e,t){return f(e,!1,t,(e,t)=>t.decrypt(e))}},function(e,t,r){"use strict";const n=self.crypto||self.msCrypto,{Buffer:i}=r(11);n&&n.getRandomValues?e.exports=function(e){const t=new Uint8Array(e);let r=0;if(e>0)if(e>65536)for(;re?(n.getRandomValues(t.subarray(r,r+(e-r))),r+=e-r):(n.getRandomValues(t.subarray(r,r+65536)),r+=65536);else n.getRandomValues(t);return i.from(t)}:e.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}},function(e,t,r){"use strict";r(18),r(39);const n=r(0),{bigIntegerToUintBase64url:i,base64urlToBigInteger:s}=r(60),o=r(5),a=r(4);t.pkcs1ToJwk=function(e){const t=n.asn1.fromDer(a(e,"ascii")),r=n.pki.privateKeyFromAsn1(t);return{kty:"RSA",n:i(r.n),e:i(r.e),d:i(r.d),p:i(r.p),q:i(r.q),dp:i(r.dP),dq:i(r.dQ),qi:i(r.qInv),alg:"RS256",kid:"2011-04-29"}},t.jwkToPkcs1=function(e){const t=n.pki.privateKeyToAsn1({n:s(e.n),e:s(e.e),d:s(e.d),p:s(e.p),q:s(e.q),dP:s(e.dp),dQ:s(e.dq),qInv:s(e.qi)});return o(n.asn1.toDer(t).getBytes(),"ascii")},t.pkixToJwk=function(e){const t=n.asn1.fromDer(a(e,"ascii")),r=n.pki.publicKeyFromAsn1(t);return{kty:"RSA",n:i(r.n),e:i(r.e),alg:"RS256",kid:"2011-04-29"}},t.jwkToPkix=function(e){const t=n.pki.publicKeyToAsn1({n:s(e.n),e:s(e.e)});return o(n.asn1.toDer(t).getBytes(),"ascii")}},function(e,t,r){"use strict";r(39);const n=r(0),{base64urlToBigInteger:i}=r(60);function s(e,t){return t.map(t=>i(e[t]))}e.exports={jwk2pub:function(e){return n.pki.setRsaPublicKey(...s(e,["n","e"]))},jwk2priv:function(e){return n.pki.setRsaPrivateKey(...s(e,["n","e","d","p","q","dp","dq","qi"]))}}},function(e,t,r){"use strict";const n=r(30),i=r(15),s=r(24),o=r(1),a=r(13),c=r(190),u=i(r(54)),f=r(61);class h{constructor(e){this._key=l(e,c.publicKeyLength)}async verify(e,t){return c.hashAndVerify(this._key,t,e)}marshal(){return this._key}get bytes(){return u.PublicKey.encode({Type:u.KeyType.Ed25519,Data:this.marshal()})}equals(e){return a(this.bytes,e.bytes)}async hash(){return n.multihashing(this.bytes,"sha2-256")}}class d{constructor(e,t){this._key=l(e,c.privateKeyLength),this._publicKey=l(t,c.publicKeyLength)}async sign(e){return c.hashAndSign(this._key,e)}get public(){return new h(this._publicKey)}marshal(){return this._key}get bytes(){return u.PrivateKey.encode({Type:u.KeyType.Ed25519,Data:this.marshal()})}equals(e){return a(this.bytes,e.bytes)}async hash(){return n.multihashing(this.bytes,"sha2-256")}async id(){const e=await this.public.hash();return s.encode("base58btc",e).toString().slice(1)}async export(e,t="libp2p-key"){if("libp2p-key"===t)return f.export(this.bytes,e);throw o(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}}function l(e,t){if((e=Uint8Array.from(e||[])).length!==t)throw o(new Error(`Key must be a Uint8Array of length ${t}, got ${e.length}`),"ERR_INVALID_KEY_TYPE");return e}e.exports={Ed25519PublicKey:h,Ed25519PrivateKey:d,unmarshalEd25519PrivateKey:function(e){if(e.length>c.privateKeyLength){const t=(e=l(e,c.privateKeyLength+c.publicKeyLength)).slice(0,c.privateKeyLength),r=e.slice(c.privateKeyLength,e.length);return new d(t,r)}const t=(e=l(e,c.privateKeyLength)).slice(0,c.privateKeyLength),r=e.slice(c.publicKeyLength);return new d(t,r)},unmarshalEd25519PublicKey:function(e){return e=l(e,c.publicKeyLength),new h(e)},generateKeyPair:async function(){const{privateKey:e,publicKey:t}=await c.generateKey();return new d(e,t)},generateKeyPairFromSeed:async function(e){const{privateKey:t,publicKey:r}=await c.generateKeyFromSeed(e);return new d(t,r)}}},function(e,t,r){"use strict";r(84);const n=r(0);t.publicKeyLength=n.pki.ed25519.constants.PUBLIC_KEY_BYTE_LENGTH,t.privateKeyLength=n.pki.ed25519.constants.PRIVATE_KEY_BYTE_LENGTH,t.generateKey=async function(){return n.pki.ed25519.generateKeyPair()},t.generateKeyFromSeed=async function(e){return n.pki.ed25519.generateKeyPair({seed:e})},t.hashAndSign=async function(e,t){return n.pki.ed25519.sign({message:t,privateKey:e})},t.hashAndVerify=async function(e,t,r){return n.pki.ed25519.verify({signature:t,message:r,publicKey:e})}},function(e,t,r){"use strict";const n=r(30),i=r(1),s=r(13),o=r(4),a=r(61);e.exports=(e,t,c)=>{c=c||r(192)(t);class u{constructor(e){c.validatePublicKey(e),this._key=e}verify(e,t){return c.hashAndVerify(this._key,t,e)}marshal(){return c.compressPublicKey(this._key)}get bytes(){return e.PublicKey.encode({Type:e.KeyType.Secp256k1,Data:this.marshal()})}equals(e){return s(this.bytes,e.bytes)}hash(){return n.multihashing(this.bytes,"sha2-256")}}class f{constructor(e,t){this._key=e,this._publicKey=t||c.computePublicKey(e),c.validatePrivateKey(this._key),c.validatePublicKey(this._publicKey)}sign(e){return c.hashAndSign(this._key,e)}get public(){return new u(this._publicKey)}marshal(){return this._key}get bytes(){return e.PrivateKey.encode({Type:e.KeyType.Secp256k1,Data:this.marshal()})}equals(e){return s(this.bytes,e.bytes)}hash(){return n.multihashing(this.bytes,"sha2-256")}async id(){const e=await this.public.hash();return o(e,"base58btc")}async export(e,t="libp2p-key"){if("libp2p-key"===t)return a.export(this.bytes,e);throw i(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}}return{Secp256k1PublicKey:u,Secp256k1PrivateKey:f,unmarshalSecp256k1PrivateKey:function(e){return new f(e)},unmarshalSecp256k1PublicKey:function(e){return new u(e)},generateKeyPair:async function(){const e=await c.generateKey();return new f(e)}}}},function(e,t,r){"use strict";const n=r(193),i=r(30);e.exports=e=>{function t(e){if(!n.privateKeyVerify(e))throw new Error("Invalid private key")}return{generateKey:function(){let t;do{t=e(32)}while(!n.privateKeyVerify(t));return t},privateKeyLength:32,hashAndSign:async function(e,t){const r=await i.digest(t,"sha2-256"),s=n.ecdsaSign(r,e);return n.signatureExport(s.signature)},hashAndVerify:async function(e,t,r){const s=await i.digest(r,"sha2-256");return t=n.signatureImport(t),n.ecdsaVerify(t,s,e)},compressPublicKey:function(e){if(!n.publicKeyVerify(e))throw new Error("Invalid public key");return n.publicKeyConvert(e,!0)},decompressPublicKey:function(e){return n.publicKeyConvert(e,!1)},validatePrivateKey:t,validatePublicKey:function(e){if(!n.publicKeyVerify(e))throw new Error("Invalid public key")},computePublicKey:function(e){return t(e),n.publicKeyCreate(e)}}}},function(e,t,r){"use strict";e.exports=r(194)(r(195))},function(e,t,r){"use strict";const n="Impossible case. Please create issue.",i="The tweak was out of range or the resulted private key is invalid",s="The tweak was out of range or equal to zero",o="Unknow error on context randomization",a="Private Key is invalid",c="Public Key could not be parsed",u="Public Key serialization error",f="The sum of the public keys is not valid",h="Signature could not be parsed",d="The nonce generation function failed, or the private key was invalid",l="Public key could not be recover",p="Scalar was invalid (zero or overflow)";function y(e,t){if(!e)throw new Error(t)}function g(e,t,r){if(y(t instanceof Uint8Array,`Expected ${e} to be an Uint8Array`),void 0!==r)if(Array.isArray(r)){const n=`Expected ${e} to be an Uint8Array with length [${r.join(", ")}]`;y(r.includes(t.length),n)}else{const n=`Expected ${e} to be an Uint8Array with length ${r}`;y(t.length===r,n)}}function b(e){y("Boolean"===v(e),"Expected compressed to be a Boolean")}function m(e=(e=>new Uint8Array(e)),t){return"function"==typeof e&&(e=e(t)),g("output",e,t),e}function v(e){return Object.prototype.toString.call(e).slice(8,-1)}e.exports=e=>({contextRandomize(t){switch(y(null===t||t instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==t&&g("seed",t,32),e.contextRandomize(t)){case 1:throw new Error(o)}},privateKeyVerify:t=>(g("private key",t,32),0===e.privateKeyVerify(t)),privateKeyNegate(t){switch(g("private key",t,32),e.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(n)}},privateKeyTweakAdd(t,r){switch(g("private key",t,32),g("tweak",r,32),e.privateKeyTweakAdd(t,r)){case 0:return t;case 1:throw new Error(i)}},privateKeyTweakMul(t,r){switch(g("private key",t,32),g("tweak",r,32),e.privateKeyTweakMul(t,r)){case 0:return t;case 1:throw new Error(s)}},publicKeyVerify:t=>(g("public key",t,[33,65]),0===e.publicKeyVerify(t)),publicKeyCreate(t,r=!0,n){switch(g("private key",t,32),b(r),n=m(n,r?33:65),e.publicKeyCreate(n,t)){case 0:return n;case 1:throw new Error(a);case 2:throw new Error(u)}},publicKeyConvert(t,r=!0,n){switch(g("public key",t,[33,65]),b(r),n=m(n,r?33:65),e.publicKeyConvert(n,t)){case 0:return n;case 1:throw new Error(c);case 2:throw new Error(u)}},publicKeyNegate(t,r=!0,i){switch(g("public key",t,[33,65]),b(r),i=m(i,r?33:65),e.publicKeyNegate(i,t)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(n);case 3:throw new Error(u)}},publicKeyCombine(t,r=!0,n){y(Array.isArray(t),"Expected public keys to be an Array"),y(t.length>0,"Expected public keys array will have more than zero items");for(const e of t)g("public key",e,[33,65]);switch(b(r),n=m(n,r?33:65),e.publicKeyCombine(n,t)){case 0:return n;case 1:throw new Error(c);case 2:throw new Error(f);case 3:throw new Error(u)}},publicKeyTweakAdd(t,r,n=!0,s){switch(g("public key",t,[33,65]),g("tweak",r,32),b(n),s=m(s,n?33:65),e.publicKeyTweakAdd(s,t,r)){case 0:return s;case 1:throw new Error(c);case 2:throw new Error(i)}},publicKeyTweakMul(t,r,n=!0,i){switch(g("public key",t,[33,65]),g("tweak",r,32),b(n),i=m(i,n?33:65),e.publicKeyTweakMul(i,t,r)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(s)}},signatureNormalize(t){switch(g("signature",t,64),e.signatureNormalize(t)){case 0:return t;case 1:throw new Error(h)}},signatureExport(t,r){g("signature",t,64);const i={output:r=m(r,72),outputlen:72};switch(e.signatureExport(i,t)){case 0:return r.slice(0,i.outputlen);case 1:throw new Error(h);case 2:throw new Error(n)}},signatureImport(t,r){switch(g("signature",t),r=m(r,64),e.signatureImport(r,t)){case 0:return r;case 1:throw new Error(h);case 2:throw new Error(n)}},ecdsaSign(t,r,i={},s){g("message",t,32),g("private key",r,32),y("Object"===v(i),"Expected options to be an Object"),void 0!==i.data&&g("options.data",i.data),void 0!==i.noncefn&&y("Function"===v(i.noncefn),"Expected options.noncefn to be a Function");const o={signature:s=m(s,64),recid:null};switch(e.ecdsaSign(o,t,r,i.data,i.noncefn)){case 0:return o;case 1:throw new Error(d);case 2:throw new Error(n)}},ecdsaVerify(t,r,n){switch(g("signature",t,64),g("message",r,32),g("public key",n,[33,65]),e.ecdsaVerify(t,r,n)){case 0:return!0;case 3:return!1;case 1:throw new Error(h);case 2:throw new Error(c)}},ecdsaRecover(t,r,i,s=!0,o){switch(g("signature",t,64),y("Number"===v(r)&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),g("message",i,32),b(s),o=m(o,s?33:65),e.ecdsaRecover(o,t,r,i)){case 0:return o;case 1:throw new Error(h);case 2:throw new Error(l);case 3:throw new Error(n)}},ecdh(t,r,n={},i){switch(g("public key",t,[33,65]),g("private key",r,32),y("Object"===v(n),"Expected options to be an Object"),void 0!==n.data&&g("options.data",n.data),void 0!==n.hashfn?(y("Function"===v(n.hashfn),"Expected options.hashfn to be a Function"),void 0!==n.xbuf&&g("options.xbuf",n.xbuf,32),void 0!==n.ybuf&&g("options.ybuf",n.ybuf,32),g("output",i)):i=m(i,32),e.ecdh(i,t,r,n.data,n.hashfn,n.xbuf,n.ybuf)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(p)}}})},function(e,t,r){"use strict";const n=new(0,r(196).ec)("secp256k1"),i=n.curve,s=i.n.constructor;function o(e){const t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){let r=new s(t);if(r.cmp(i.p)>=0)return null;r=r.toRed(i.red);let o=r.redSqr().redIMul(r).redIAdd(i.b).redSqrt();return 3===e!==o.isOdd()&&(o=o.redNeg()),n.keyPair({pub:{x:r,y:o}})}(t,e.subarray(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){let o=new s(t),a=new s(r);if(o.cmp(i.p)>=0||a.cmp(i.p)>=0)return null;if(o=o.toRed(i.red),a=a.toRed(i.red),(6===e||7===e)&&a.isOdd()!==(7===e))return null;const c=o.redSqr().redIMul(o);return a.redSqr().redISub(c.redIAdd(i.b)).isZero()?n.keyPair({pub:{x:o,y:a}}):null}(t,e.subarray(1,33),e.subarray(33,65));default:return null}}function a(e,t){const r=t.encode(null,33===e.length);for(let n=0;n0,privateKeyVerify(e){const t=new s(e);return t.cmp(i.n)<0&&!t.isZero()?0:1},privateKeyNegate(e){const t=new s(e),r=i.n.sub(t).umod(i.n).toArrayLike(Uint8Array,"be",32);return e.set(r),0},privateKeyTweakAdd(e,t){const r=new s(t);if(r.cmp(i.n)>=0)return 1;if(r.iadd(new s(e)),r.cmp(i.n)>=0&&r.isub(i.n),r.isZero())return 1;const n=r.toArrayLike(Uint8Array,"be",32);return e.set(n),0},privateKeyTweakMul(e,t){let r=new s(t);if(r.cmp(i.n)>=0||r.isZero())return 1;r.imul(new s(e)),r.cmp(i.n)>=0&&(r=r.umod(i.n));const n=r.toArrayLike(Uint8Array,"be",32);return e.set(n),0},publicKeyVerify:e=>null===o(e)?1:0,publicKeyCreate(e,t){const r=new s(t);if(r.cmp(i.n)>=0||r.isZero())return 1;return a(e,n.keyFromPrivate(t).getPublic()),0},publicKeyConvert(e,t){const r=o(t);if(null===r)return 1;return a(e,r.getPublic()),0},publicKeyNegate(e,t){const r=o(t);if(null===r)return 1;const n=r.getPublic();return n.y=n.y.redNeg(),a(e,n),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let i=0;i=0)return 2;const c=n.getPublic().add(i.g.mul(r));return c.isInfinity()?2:(a(e,c),0)},publicKeyTweakMul(e,t,r){const n=o(t);if(null===n)return 1;if((r=new s(r)).cmp(i.n)>=0||r.isZero())return 2;return a(e,n.getPublic().mul(r)),0},signatureNormalize(e){const t=new s(e.subarray(0,32)),r=new s(e.subarray(32,64));return t.cmp(i.n)>=0||r.cmp(i.n)>=0?1:(1===r.cmp(n.nh)&&e.set(i.n.sub(r).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(e,t){const r=t.subarray(0,32),n=t.subarray(32,64);if(new s(r).cmp(i.n)>=0)return 1;if(new s(n).cmp(i.n)>=0)return 1;const{output:o}=e;let a=o.subarray(4,37);a[0]=0,a.set(r,1);let c=33,u=0;for(;c>1&&0===a[u]&&!(128&a[u+1]);--c,++u);if(a=a.subarray(u),128&a[0])return 1;if(c>1&&0===a[0]&&!(128&a[1]))return 1;let f=o.subarray(39,72);f[0]=0,f.set(n,1);let h=33,d=0;for(;h>1&&0===f[d]&&!(128&f[d+1]);--h,++d);return f=f.subarray(d),128&f[0]||h>1&&0===f[0]&&!(128&f[1])?1:(e.outputlen=6+c+h,o[0]=48,o[1]=e.outputlen-2,o[2]=2,o[3]=a.length,o.set(a,4),o[4+c]=2,o[5+c]=f.length,o.set(f,6+c),0)},signatureImport(e,t){if(t.length<8)return 1;if(t.length>72)return 1;if(48!==t[0])return 1;if(t[1]!==t.length-2)return 1;if(2!==t[2])return 1;const r=t[3];if(0===r)return 1;if(5+r>=t.length)return 1;if(2!==t[4+r])return 1;const n=t[5+r];if(0===n)return 1;if(6+r+n!==t.length)return 1;if(128&t[4])return 1;if(r>1&&0===t[4]&&!(128&t[5]))return 1;if(128&t[r+6])return 1;if(n>1&&0===t[r+6]&&!(128&t[r+7]))return 1;let o=t.subarray(4,4+r);if(33===o.length&&0===o[0]&&(o=o.subarray(1)),o.length>32)return 1;let a=t.subarray(6+r);if(33===a.length&&0===a[0]&&(a=a.slice(1)),a.length>32)throw new Error("S length is too long");let c=new s(o);c.cmp(i.n)>=0&&(c=new s(0));let u=new s(t.subarray(6+r));return u.cmp(i.n)>=0&&(u=new s(0)),e.set(c.toArrayLike(Uint8Array,"be",32),0),e.set(u.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(e,t,r,o,a){if(a){const e=a;a=n=>{const i=e(t,r,null,o,n);if(!(i instanceof Uint8Array&&32===i.length))throw new Error("This is the way");return new s(i)}}const c=new s(r);if(c.cmp(i.n)>=0||c.isZero())return 1;let u;try{u=n.sign(t,r,{canonical:!0,k:a,pers:o})}catch(f){return 1}return e.signature.set(u.r.toArrayLike(Uint8Array,"be",32),0),e.signature.set(u.s.toArrayLike(Uint8Array,"be",32),32),e.recid=u.recoveryParam,0},ecdsaVerify(e,t,r){const a={r:e.subarray(0,32),s:e.subarray(32,64)},c=new s(a.r),u=new s(a.s);if(c.cmp(i.n)>=0||u.cmp(i.n)>=0)return 1;if(1===u.cmp(n.nh)||c.isZero()||u.isZero())return 3;const f=o(r);if(null===f)return 2;const h=f.getPublic();return n.verify(t,a,h)?0:3},ecdsaRecover(e,t,r,o){const c={r:t.slice(0,32),s:t.slice(32,64)},u=new s(c.r),f=new s(c.s);if(u.cmp(i.n)>=0||f.cmp(i.n)>=0)return 1;if(u.isZero()||f.isZero())return 2;let h;try{h=n.recoverPubKey(o,c,r)}catch(d){return 2}return a(e,h),0},ecdh(e,t,r,a,c,u,f){const h=o(t);if(null===h)return 1;const d=new s(r);if(d.cmp(i.n)>=0||d.isZero())return 2;const l=h.getPublic().mul(d);if(void 0===c){const t=l.encode(null,!0),r=n.hash().update(t).digest();for(let n=0;n<32;++n)e[n]=r[n]}else{u||(u=new Uint8Array(32));const t=l.getX().toArray("be",32);for(let e=0;e<32;++e)u[e]=t[e];f||(f=new Uint8Array(32));const r=l.getY().toArray("be",32);for(let e=0;e<32;++e)f[e]=r[e];const n=c(u,f,a);if(!(n instanceof Uint8Array&&n.length===e.length))return 2;e.set(n)}return 0}}},function(e,t,r){"use strict";var n=t;n.version=r(197).version,n.utils=r(12),n.rand=r(86),n.curve=r(87),n.curves=r(62),n.ec=r(211),n.eddsa=r(215)},function(e){e.exports=JSON.parse('{"_from":"elliptic@^6.5.2","_id":"elliptic@6.5.3","_inBundle":false,"_integrity":"sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==","_location":"/elliptic","_phantomChildren":{},"_requested":{"type":"range","registry":true,"raw":"elliptic@^6.5.2","name":"elliptic","escapedName":"elliptic","rawSpec":"^6.5.2","saveSpec":null,"fetchSpec":"^6.5.2"},"_requiredBy":["/browserify-sign","/create-ecdh","/secp256k1"],"_resolved":"https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz","_shasum":"cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6","_spec":"elliptic@^6.5.2","_where":"/Users/vsantos/work/pl/gh/libp2p/js-libp2p/node_modules/secp256k1","author":{"name":"Fedor Indutny","email":"fedor@indutny.com"},"bugs":{"url":"https://github.com/indutny/elliptic/issues"},"bundleDependencies":false,"dependencies":{"bn.js":"^4.4.0","brorand":"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0","inherits":"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"},"deprecated":false,"description":"EC cryptography","devDependencies":{"brfs":"^1.4.3","coveralls":"^3.0.8","grunt":"^1.0.4","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^9.0.1","istanbul":"^0.4.2","jscs":"^3.0.7","jshint":"^2.10.3","mocha":"^6.2.2"},"files":["lib"],"homepage":"https://github.com/indutny/elliptic","keywords":["EC","Elliptic","curve","Cryptography"],"license":"MIT","main":"lib/elliptic.js","name":"elliptic","repository":{"type":"git","url":"git+ssh://git@github.com/indutny/elliptic.git"},"scripts":{"jscs":"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js","jshint":"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js","lint":"npm run jscs && npm run jshint","test":"npm run lint && npm run unit","unit":"istanbul test _mocha --reporter=spec test/index.js","version":"grunt dist && git add dist/"},"version":"6.5.3"}')},function(e,t,r){"use strict";e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){},function(e,t){},function(e,t,r){"use strict";var n=r(12),i=r(17),s=r(43),o=r(42),a=n.assert;function c(e){o.call(this,"short",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(e,t,r,n){o.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(t,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function f(e,t,r,n){o.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(t,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}s(c,o),e.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new i(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new i(e.lambda,16);else{var s=this._getEndoRoots(this.n);0===this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))?r=s[0]:(r=s[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map((function(e){return{a:new i(e.a,16),b:new i(e.b,16)}})):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:i.mont(e),r=new i(2).toRed(t).redInvm(),n=r.redNeg(),s=new i(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(s).fromRed(),n.redSub(s).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,r,n,s,o,a,c,u,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),d=e,l=this.n.clone(),p=new i(1),y=new i(0),g=new i(0),b=new i(1),m=0;0!==d.cmpn(0);){var v=l.div(d);u=l.sub(v.mul(d)),f=g.sub(v.mul(p));var w=b.sub(v.mul(y));if(!n&&u.cmp(h)<0)t=c.neg(),r=p,n=u.neg(),s=f;else if(n&&2==++m)break;c=u,l=d,d=u,g=p,p=f,b=y,y=w}o=u.neg(),a=f;var E=n.sqr().add(s.sqr());return o.sqr().add(a.sqr()).cmp(E)>=0&&(o=t,a=r),n.negative&&(n=n.neg(),s=s.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:s},{a:o,b:a}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),s=r.b.neg().mul(e).divRound(this.n),o=i.mul(r.a),a=s.mul(n.a),c=i.mul(r.b),u=s.mul(n.b);return{k1:e.sub(o).sub(a),k2:c.add(u).neg()}},c.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,s=0;s":""},u.prototype.isInfinity=function(){return this.inf},u.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},u.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),s=i.redSqr().redISub(this.x.redAdd(this.x)),o=i.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(e){return e=new i(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},u.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},u.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},u.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(f,o.BasePoint),c.prototype.jpoint=function(e,t,r){return new f(this,e,t,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),s=this.y.redMul(t.redMul(e.z)),o=e.y.redMul(r.redMul(this.z)),a=n.redSub(i),c=s.redSub(o);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),h=n.redMul(u),d=c.redSqr().redIAdd(f).redISub(h).redISub(h),l=c.redMul(h.redISub(d)).redISub(s.redMul(f)),p=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(d,l,p)},f.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,s=e.y.redMul(t).redMul(this.z),o=r.redSub(n),a=i.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=o.redSqr(),u=c.redMul(o),f=r.redMul(c),h=a.redSqr().redIAdd(u).redISub(f).redISub(f),d=a.redMul(f.redISub(h)).redISub(i.redMul(u)),l=this.z.redMul(o);return this.curve.jpoint(h,d,l)},f.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(e,t,r){"use strict";var n=r(17),i=r(43),s=r(42),o=r(12);function a(e){s.call(this,"mont",e),this.a=new n(e.a,16).toRed(this.red),this.b=new n(e.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){s.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(t,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,s),e.exports=a,a.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},i(c,s.BasePoint),a.prototype.decodePoint=function(e,t){return this.point(o.toArray(e,t),1)},a.prototype.point=function(e,t){return new c(this,e,t)},a.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),s=e.x.redSub(e.z).redMul(r),o=i.redMul(n),a=t.z.redMul(s.redAdd(o).redSqr()),c=t.x.redMul(s.redISub(o).redSqr());return this.curve.point(a,c)},c.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var s=i.length-1;s>=0;s--)0===i[s]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(e,t,r){"use strict";var n=r(12),i=r(17),s=r(43),o=r(42),a=n.assert;function c(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,o.call(this,"edwards",e),this.a=new i(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new i(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new i(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),a(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function u(e,t,r,n,s){o.BasePoint.call(this,e,"projective"),null===t&&null===r&&null===n?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new i(t,16),this.y=new i(r,16),this.z=n?new i(n,16):this.curve.one,this.t=s&&new i(s,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}s(c,o),e.exports=c,c.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},c.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},c.prototype.jpoint=function(e,t,r,n){return this.point(e,t,r,n)},c.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=this.c2.redSub(this.a.redMul(r)),s=this.one.redSub(this.c2.redMul(this.d).redMul(r)),o=n.redMul(s.redInvm()),a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error("invalid point");var c=a.fromRed().isOdd();return(t&&!c||!t&&c)&&(a=a.redNeg()),this.point(e,a)},c.prototype.pointFromY=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=r.redSub(this.c2),s=r.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(0===o.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error("invalid point");return a.fromRed().isOdd()!==t&&(a=a.redNeg()),this.point(a,e)},c.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),r=e.y.redSqr(),n=t.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(r)));return 0===n.cmp(i)},s(u,o.BasePoint),c.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},c.prototype.point=function(e,t,r,n){return new u(this,e,t,r,n)},u.fromJSON=function(e,t){return new u(e,t[0],t[1],t[2])},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},u.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),s=n.redAdd(t),o=s.redSub(r),a=n.redSub(t),c=i.redMul(o),u=s.redMul(a),f=i.redMul(a),h=o.redMul(s);return this.curve.point(c,u,h,f)},u.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),s=this.y.redSqr();if(this.curve.twisted){var o=(u=this.curve._mulA(i)).redAdd(s);if(this.zOne)e=n.redSub(i).redSub(s).redMul(o.redSub(this.curve.two)),t=o.redMul(u.redSub(s)),r=o.redSqr().redSub(o).redSub(o);else{var a=this.z.redSqr(),c=o.redSub(a).redISub(a);e=n.redSub(i).redISub(s).redMul(c),t=o.redMul(u.redSub(s)),r=o.redMul(c)}}else{var u=i.redAdd(s);a=this.curve._mulC(this.z).redSqr(),c=u.redSub(a).redSub(a);e=this.curve._mulC(n.redISub(u)).redMul(c),t=this.curve._mulC(u).redMul(i.redISub(s)),r=u.redMul(c)}return this.curve.point(e,t,r)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),s=r.redSub(t),o=i.redSub(n),a=i.redAdd(n),c=r.redAdd(t),u=s.redMul(o),f=a.redMul(c),h=s.redMul(c),d=o.redMul(a);return this.curve.point(u,f,d,h)},u.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),s=this.x.redMul(e.x),o=this.y.redMul(e.y),a=this.curve.d.redMul(s).redMul(o),c=i.redSub(a),u=i.redAdd(a),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(s).redISub(o),h=n.redMul(c).redMul(f);return this.curve.twisted?(t=n.redMul(u).redMul(o.redSub(this.curve._mulA(s))),r=c.redMul(u)):(t=n.redMul(u).redMul(o.redSub(s)),r=this.curve._mulC(c).redMul(u)),this.curve.point(h,t,r)},u.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},u.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},u.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},u.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()},u.prototype.getY=function(){return this.normalize(),this.y.fromRed()},u.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},u.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},function(e,t,r){"use strict";t.sha1=r(205),t.sha224=r(206),t.sha256=r(89),t.sha384=r(207),t.sha512=r(90)},function(e,t,r){"use strict";var n=r(16),i=r(31),s=r(88),o=n.rotl32,a=n.sum32,c=n.sum32_5,u=s.ft_1,f=i.BlockHash,h=[1518500249,1859775393,2400959708,3395469782];function d(){if(!(this instanceof d))return new d;f.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(d,f),e.exports=d,d.blockSize=512,d.outSize=160,d.hmacStrength=80,d.padLength=64,d.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;nthis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t0))return o.iaddn(1),this.keyFromPrivate(o)}},h.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},h.prototype.sign=function(e,t,r,s){"object"==typeof r&&(s=r,r=null),s||(s={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var o=this.n.byteLength(),a=t.getPrivate().toArray("be",o),c=e.toArray("be",o),u=new i({hash:this.hash,entropy:a,nonce:c,pers:s.pers,persEnc:s.persEnc||"utf8"}),h=this.n.sub(new n(1)),d=0;;d++){var l=s.k?s.k(d):new n(u.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(h)>=0)){var p=this.g.mul(l);if(!p.isInfinity()){var y=p.getX(),g=y.umod(this.n);if(0!==g.cmpn(0)){var b=l.invm(this.n).mul(g.mul(t.getPrivate()).iadd(e));if(0!==(b=b.umod(this.n)).cmpn(0)){var m=(p.getY().isOdd()?1:0)|(0!==y.cmp(g)?2:0);return s.canonical&&b.cmp(this.nh)>0&&(b=this.n.sub(b),m^=1),new f({r:g,s:b,recoveryParam:m})}}}}}},h.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var s=(t=new f(t,"hex")).r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,c=o.invm(this.n),u=c.mul(e).umod(this.n),h=c.mul(s).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),h)).isInfinity()&&a.eqXToP(s):!(a=this.g.mulAdd(u,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(s)},h.prototype.recoverPubKey=function(e,t,r,i){c((3&r)===r,"The recovery param is more than two bits"),t=new f(t,i);var s=this.n,o=new n(e),a=t.r,u=t.s,h=1&r,d=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");a=d?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var l=t.r.invm(s),p=s.sub(o).mul(l).umod(s),y=u.mul(l).umod(s);return this.g.mulAdd(p,a,y)},h.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new f(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(e,t,i)}catch(e){continue}if(s.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},function(e,t,r){"use strict";var n=r(63),i=r(85),s=r(22);function o(e){if(!(this instanceof o))return new o(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");s(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}e.exports=o,o.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},o.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var s=[];s.length"}},function(e,t,r){"use strict";var n=r(17),i=r(12),s=i.assert;function o(e,t){if(e instanceof o)return e;this._importDER(e,t)||(s(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function a(){this.place=0}function c(e,t){var r=e[t.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,s=0,o=t.place;s>>=0;return!(i<=127)&&(t.place=o,i)}function u(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}e.exports=o,o.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new a;if(48!==e[r.place++])return!1;var s=c(e,r);if(!1===s)return!1;if(s+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=c(e,r);if(!1===o)return!1;var u=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var f=c(e,r);if(!1===f)return!1;if(e.length!==f+r.place)return!1;var h=e.slice(r.place,f+r.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===h[0]){if(!(128&h[1]))return!1;h=h.slice(1)}return this.r=new n(u),this.s=new n(h),this.recoveryParam=null,!0},o.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=u(t),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];f(n,t.length),(n=n.concat(t)).push(2),f(n,r.length);var s=n.concat(r),o=[48];return f(o,s.length),o=o.concat(s),i.encode(o,e)}},function(e,t,r){"use strict";var n=r(63),i=r(62),s=r(12),o=s.assert,a=s.parseBytes,c=r(216),u=r(217);function f(e){if(o("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}e.exports=f,f.prototype.sign=function(e,t){e=a(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),s=this.encodePoint(i),o=this.hashInt(s,r.pubBytes(),e).mul(r.priv()),c=n.add(o).umod(this.curve.n);return this.makeSignature({R:i,S:c,Rencoded:s})},f.prototype.verify=function(e,t,r){e=a(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),s=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(s)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{const c=a[e];if(!c){const t=Object.keys(a).join(" / ");throw n(new Error(`unknown cipher type '${e}'. Must be ${t}`),"ERR_INVALID_CIPHER_TYPE")}if(!t)throw n(new Error("missing hash type"),"ERR_MISSING_HASH_TYPE");const u=c.keySize,f=c.ivSize,h=s("key expansion"),d=2*(f+u+20),l=await o.create(t,r);let p=await l.digest(h);const y=[];let g=0;for(;gd&&(t=d-g),y.push(e),g+=t,p=await l.digest(p)}const b=d/2,m=i(y),v=m.slice(0,b),w=m.slice(b,d),E=e=>({iv:e.slice(0,f),cipherKey:e.slice(f,f+u),macKey:e.slice(f+u)});return{k1:E(v),k2:E(w)}}},function(e,t,r){"use strict";e.exports={SHA1:20,SHA256:32,SHA512:64}},function(e,t,r){"use strict";const n=r(221);e.exports=async e=>n.generateEphmeralKeyPair(e)},function(e,t,r){"use strict";const n=r(1),i=r(41),{base64urlToBuffer:s}=r(60),o=r(222),a=r(4),c=r(14),u=r(13),f={"P-256":256,"P-384":384,"P-521":521};t.generateEphmeralKeyPair=async function(e){o(Object.keys(f),e);const t=await i.get().subtle.generateKey({name:"ECDH",namedCurve:e},!0,["deriveBits"]);return{key:d(await i.get().subtle.exportKey("jwk",t.publicKey)),genSharedKey:async(r,n)=>{let s;s=n?await i.get().subtle.importKey("jwk",p(e,n),{name:"ECDH",namedCurve:e},!1,["deriveBits"]):t.privateKey;const o=[await i.get().subtle.importKey("jwk",l(e,r),{name:"ECDH",namedCurve:e},!1,[]),s],a=await i.get().subtle.deriveBits({name:"ECDH",namedCurve:e,public:o[0]},o[1],f[e]);return new Uint8Array(a,a.byteOffset,a.byteLength)}}};const h={"P-256":32,"P-384":48,"P-521":66};function d(e){const t=h[e.crv];return c([Uint8Array.from([4]),s(e.x,t),s(e.y,t)],1+2*t)}function l(e,t){const r=h[e];if(u(!t.slice(0,1),Uint8Array.from([4])))throw n(new Error("Cannot unmarshal public key - invalid key format"),"ERR_INVALID_KEY_FORMAT");return{kty:"EC",crv:e,x:a(t.slice(1,r+1),"base64url"),y:a(t.slice(1+r),"base64url"),ext:!0}}const p=(e,t)=>({...l(e,t.public),d:a(t.private,"base64url")})},function(e,t,r){"use strict";const n=r(1);e.exports=function(e,t){if(!e.includes(t)){const r=e.join(" / ");throw n(new Error(`Unknown curve: ${t}. Must be ${r}`),"ERR_INVALID_CURVE")}}},function(e,t,r){"use strict";const n=r(15);e.exports=n("\n\nmessage PeerIdProto {\n required bytes id = 1;\n bytes pubKey = 2;\n bytes privKey = 3;\n}\n\n")},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:peer-routing"),{error:n("libp2p:peer-routing:err")}),s=r(1),o=r(92),a=r(64),{setDelayedInterval:c,clearDelayedInterval:u}=r(94);e.exports=class{constructor(e){this._peerId=e.peerId,this._peerStore=e.peerStore,this._routers=e._modules.peerRouting||[],e._dht&&this._routers.unshift(e._dht),this._refreshManagerOptions=e._options.peerRouting.refreshManager,this._findClosestPeersTask=this._findClosestPeersTask.bind(this)}start(){this._routers.length&&!this._timeoutId&&this._refreshManagerOptions.enabled&&(this._timeoutId=c(this._findClosestPeersTask,this._refreshManagerOptions.interval,this._refreshManagerOptions.bootDelay))}async _findClosestPeersTask(){try{for await(const{id:e,multiaddrs:t}of this.getClosestPeers(this._peerId.id))this._peerStore.addressBook.add(e,t)}catch(e){i.error(e)}}stop(){u(this._timeoutId)}async findPeer(e,t){if(!this._routers.length)throw s(new Error("No peer routers available"),"NO_ROUTERS_AVAILABLE");return a(this._routers.map(async r=>{const n=await r.findPeer(e,t);if(!n||0===Object.keys(n).length)throw s(new Error("not found"),"NOT_FOUND");return n}))}async*getClosestPeers(e,t={timeout:3e4}){if(!this._routers.length)throw s(new Error("No peer routers available"),"NO_ROUTERS_AVAILABLE");const r=await a(this._routers.map(async r=>{const n=await o(r.getClosestPeers(e,t));if(!n||!n.length)throw s(new Error("not found"),"NOT_FOUND");return n}));for(const n of r)yield n}}},function(e,t,r){"use strict";const n=r(226),i=r(93);class s extends Error{}e.exports=(e,t)=>new i((r,i,o)=>{const{count:a,filter:c=(()=>!0)}=t;if(!Number.isFinite(a))return void i(new TypeError("Expected a finite number, got "+typeof t.count));const u=[],f=[];let h=0,d=!1;const l=new Set,p=()=>{for(const t of e)l.has(t)||"function"!=typeof t.cancel||t.cancel()};o(p);for(const t of e)h++,(async()=>{try{const e=await t;if(d)return;if(!c(e))throw new s("Value does not satisfy filter");u.push(e)}catch(e){f.push(e)}finally{l.add(t),!d&&(u.length===a&&(r(u),d=!0),h-f.lengthh&&(i(new RangeError(`Expected input to contain at least ${t.count} items, but contains ${h} items`)),p())}),e.exports.AggregateError=n,e.exports.FilterError=s},function(e,t,r){"use strict";const n=r(227),i=r(228);class s extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError("Expected input to be an Array, got "+typeof e);let t=(e=[...e].map(e=>e instanceof Error?e:null!==e&&"object"==typeof e?Object.assign(new Error(e.message),e):new Error(e))).map(e=>"string"==typeof e.stack?i(e.stack).replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,""):String(e)).join("\n");t="\n"+n(t,4),super(t),this.name="AggregateError",Object.defineProperty(this,"_errors",{value:e})}*[Symbol.iterator](){for(const e of this._errors)yield e}}e.exports=s},function(e,t,r){"use strict";e.exports=(e,t=1,r)=>{if(r={indent:" ",includeEmptyLines:!1,...r},"string"!=typeof e)throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof e}\``);if("number"!=typeof t)throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof t}\``);if("string"!=typeof r.indent)throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof r.indent}\``);if(0===t)return e;const n=r.includeEmptyLines?/^/gm:/^(?!\s*$)/gm;return e.replace(n,r.indent.repeat(t))}},function(e,t,r){"use strict";const n=r(229),i=/\s+at.*(?:\(|\s)(.*)\)?/,s=/^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/,o=void 0===n.homedir?"":n.homedir();e.exports=(e,t)=>(t=Object.assign({pretty:!1},t),e.replace(/\\/g,"/").split("\n").filter(e=>{const t=e.match(i);if(null===t||!t[1])return!0;const r=t[1];return!r.includes(".app/Contents/Resources/electron.asar")&&!r.includes(".app/Contents/Resources/default_app.asar")&&!s.test(r)}).filter(e=>""!==e.trim()).map(e=>t.pretty?e.replace(i,(e,t)=>e.replace(t,t.replace(o,"~"))):e).join("\n"))},function(e,t){},function(e,t,r){"use strict";const n=r(1),{messages:i,codes:s}=r(7),o=r(92),a=r(64);e.exports=class{constructor(e){this.libp2p=e,this.routers=e._modules.contentRouting||[],this.dht=e._dht,this.dht&&this.routers.unshift(this.dht)}async*findProviders(e,t){if(!this.routers.length)throw n(new Error("No content this.routers available"),"NO_ROUTERS_AVAILABLE");const r=await a(this.routers.map(async r=>{const i=await o(r.findProviders(e,t));if(!i||!i.length)throw n(new Error("not found"),"NOT_FOUND");return i}));for(const n of r)yield n}async provide(e){if(!this.routers.length)throw n(new Error("No content routers available"),"NO_ROUTERS_AVAILABLE");await Promise.all(this.routers.map(t=>t.provide(e)))}put(e,t,r){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw n(new Error(i.NOT_STARTED_YET),s.DHT_NOT_STARTED);return this.dht.put(e,t,r)}get(e,t){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw n(new Error(i.NOT_STARTED_YET),s.DHT_NOT_STARTED);return this.dht.get(e,t)}async getMany(e,t,r){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw n(new Error(i.NOT_STARTED_YET),s.DHT_NOT_STARTED);return this.dht.getMany(e,t,r)}}},function(e,t,r){"use strict";const n=r(232),i=r(44),s=r(8),o=r(14),a=r(4);function c(e){const t=[],r=e.split("/").slice(1);if(1===r.length&&""===r[0])return[];for(let n=0;n=r.length)throw v("invalid address: "+e);if(o.path){t.push([s,m(r.slice(n).join("/"))]);break}t.push([s,r[n]])}else t.push([s])}return t}function u(e){const t=[];return e.map(e=>{const r=w(e);t.push(r.name),e.length>1&&t.push(e[1])}),m(t.join("/"))}function f(e){return e.map(e=>{Array.isArray(e)||(e=[e]);const t=w(e);return e.length>1?[t.code,n.toBytes(t.code,e[1])]:[t.code]})}function h(e){return e.map(e=>{const t=w(e);return e.length>1?[t.code,n.toString(t.code,e[1])]:[t.code]})}function d(e){return g(o(e.map(e=>{const t=w(e);let r=Uint8Array.from(s.encode(t.code));return e.length>1&&(r=o([r,e[1]])),r})))}function l(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;return s.decode(t)+s.decode.bytes}function p(e){const t=[];let r=0;for(;re.length)throw v("Invalid address Uint8Array: "+a(e,"base16"));t.push([n,u])}return t}function y(e){return d(f(c(e=m(e))))}function g(e){const t=b(e);if(t)throw t;return Uint8Array.from(e)}function b(e){try{p(e)}catch(t){return t}}function m(e){return"/"+e.trim().split("/").filter(e=>e).join("/")}function v(e){return new Error("Error parsing address: "+e)}function w(e){return i(e[0])}e.exports={stringToStringTuples:c,stringTuplesToString:u,tuplesToStringTuples:h,stringTuplesToTuples:f,bytesToTuples:p,tuplesToBytes:d,bytesToString:function(e){const t=p(e);return u(h(t))},stringToBytes:y,fromString:function(e){return y(e)},fromBytes:g,validateBytes:b,isValidBytes:function(e){return void 0===b(e)},cleanPath:m,ParseError:v,protoFromTuple:w,sizeForAddr:l}},function(e,t,r){"use strict";const n=r(233),i=r(44),s=r(36),o=r(24),a=r(8),c=r(4),u=r(5),f=r(14);function h(e,t){return t instanceof Uint8Array?h.toString(e,t):h.toBytes(e,t)}function d(e){if(!n.isIP(e))throw new Error("invalid ip address");return n.toBytes(e)}function l(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function p(e){return new DataView(e.buffer).getUint16(0)}function y(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2);return c(t,"base32")+":"+p(r)}e.exports=h,h.toString=function(e,t){switch((e=i(e)).code){case 4:case 41:return function(e){const t=n.toString(e);if(!t||!n.isIP(t))throw new Error("invalid ip address");return t}(t);case 6:case 273:case 33:case 132:return p(t);case 53:case 54:case 55:case 56:case 400:case 777:return function(e){const t=a.decode(e);if((e=e.slice(a.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return c(e)}(t);case 421:return function(e){const t=a.decode(e),r=e.slice(a.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return c(r,"base58btc")}(t);case 444:case 445:return y(t);default:return c(t,"base16")}},h.toBytes=function(e,t){switch((e=i(e)).code){case 4:case 41:return d(t);case 6:case 273:case 33:case 132:return l(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 777:return function(e){const t=u(e),r=Uint8Array.from(a.encode(t.length));return f([r,t],r.length+t.length)}(t);case 421:return function(e){const t=new s(e).multihash,r=Uint8Array.from(a.encode(t.length));return f([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: "+t+" does not contain a port number");if(16!==t[0].length)throw new Error("failed to parse onion addr: "+t[0]+" not a Tor onion address.");const r=o.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=l(n);return f([r,i],r.length+i.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: "+t+" does not contain a port number");if(56!==t[0].length)throw new Error("failed to parse onion addr: "+t[0]+" not a Tor onion3 address.");const r=o.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=l(n);return f([r,i],r.length+i.length)}(t);default:return u(t,"base16")}}},function(e,t,r){"use strict";const n=r(96),i=r(4),s=n,o=n.v4,a=n.v6,c=function(e,t,r){var n;if(r=~~r,o(e))n=t||new Uint8Array(r+4),e.split(/\./g).map((function(e){n[r++]=255&parseInt(e,10)}));else if(a(e)){var s,u=e.split(":",8);for(s=0;s0;s--)h.push("0");u.splice.apply(u,h)}for(n=t||new Uint8Array(r+16),s=0;s>8&255,n[r++]=255&d}}if(!n)throw Error("Invalid ip address: "+e);return n};e.exports={isIP:s,isV4:o,isV6:a,toBytes:c,toString:function(e,t,r){t=~~t,r=r||e.length-t;var n,i=[];const s=new DataView(e.buffer);if(4===r){for(let n=0;ne&&e.includeBoundaries?"(?:(?<=\\s|^)(?=[a-fA-F\\d:])|(?<=[a-fA-F\\d:])(?=\\s|$))":"",i="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",s="[a-fA-F\\d]{1,4}",o=`\n(\n(?:${s}:){7}(?:${s}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${s}:){6}(?:${i}|:${s}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:${s}:){5}(?::${i}|(:${s}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:${s}:){4}(?:(:${s}){0,1}:${i}|(:${s}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:${s}:){3}(?:(:${s}){0,2}:${i}|(:${s}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:${s}:){2}(?:(:${s}){0,3}:${i}|(:${s}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${s}:){1}(?:(:${s}){0,4}:${i}|(:${s}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::((?::${s}){0,5}:${i}|(?::${s}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),a=new RegExp(`(?:^${i}$)|(?:^${o}$)`),c=new RegExp(`^${i}$`),u=new RegExp(`^${o}$`),f=e=>e&&e.exact?a:new RegExp(`(?:${n(e)}${i}${n(e)})|(?:${n(e)}${o}${n(e)})`,"g");f.v4=e=>e&&e.exact?c:new RegExp(`${n(e)}${i}${n(e)}`,"g"),f.v6=e=>e&&e.exact?u:new RegExp(`${n(e)}${o}${n(e)}`,"g"),e.exports=f},function(e,t,r){"use strict";const n=r(45),{dnsaddrResolver:i}=r(237),s=r(65),{AGENT_VERSION:o}=r(101),a=r(66),{publicAddressesFirst:c}=r(102),{FaultTolerance:u}=r(103),f={addresses:{listen:[],announce:[],noAnnounce:[]},connectionManager:{minConnections:25},transportManager:{faultTolerance:u.FATAL_ALL},dialer:{maxParallelDials:s.MAX_PARALLEL_DIALS,maxDialsPerPeer:s.MAX_PER_PEER_DIALS,dialTimeout:s.DIAL_TIMEOUT,resolvers:{dnsaddr:i},addressSorter:c},host:{agentVersion:o},metrics:{enabled:!1},peerStore:{persistence:!1,threshold:5},peerRouting:{refreshManager:{enabled:!0,interval:6e5,bootDelay:1e4}},config:{dht:{enabled:!1,kBucketSize:20,randomWalk:{enabled:!1,queriesPerPeriod:1,interval:3e5,timeout:1e4}},peerDiscovery:{autoDial:!0},pubsub:{enabled:!0},relay:{enabled:!0,advertise:{bootDelay:a.ADVERTISE_BOOT_DELAY,enabled:!1,ttl:a.ADVERTISE_TTL},hop:{enabled:!1,active:!1},autoRelay:{enabled:!1,maxListeners:2}},transport:{}}};e.exports.validate=e=>{if((e=n(f,e)).modules.transport.length<1)throw new Error("'options.modules.transport' must contain at least 1 transport");return e}},function(e,t,r){"use strict";e.exports=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}},function(e,t,r){"use strict";r(9);const n=r(44),{code:i}=n("dnsaddr");e.exports={dnsaddrResolver:async function(e){const{Resolver:t}=r(238),n=new t,s=e.getPeerId(),[,o]=e.stringTuples().find(([e])=>e===i)||[];let a=(await n.resolveTxt("_dnsaddr."+o)).flat().map(e=>e.split("=")[1]);return s&&(a=a.filter(e=>e.includes(s))),a}}},function(e,t,r){"use strict";let n;try{if(n=r(!function(){var e=new Error("Cannot find module 'dns'");throw e.code="MODULE_NOT_FOUND",e}()).promises,!n)throw new Error("no dns available")}catch(i){n=r(239)}e.exports=n},function(e,t,r){"use strict";const n=r(2),i=n("dns-over-http-resolver");i.error=n("dns-over-http-resolver:error");const s=r(240),{buildResource:o,fetch:a,getCacheKey:c}=r(241);class u{constructor({maxCache:e=100}={}){this._cache=new s({max:e}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"]}getServers(){return this._servers}_getShuffledServers(){const e=[].concat(this._servers);for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*t),n=e[t];e[t]=e[r],e[r]=n}return e}setServers(e){this._servers=e}resolve(e,t="A"){switch(t){case"A":return this.resolve4(e);case"AAAA":return this.resolve6(e);case"TXT":return this.resolveTxt(e);default:throw new Error(t+" is not supported")}}async resolve4(e){const t=this._cache.get(c(e,"A"));if(t)return t;for(const n of this._getShuffledServers())try{const t=await a(o({serverResolver:n,hostname:e,recordType:"A"})),r=await t.json(),i=r.Answer.map(e=>e.data),s=Math.min(r.Answer.map(e=>e.TTL));return this._cache.set(c(e,"A"),i,{ttl:s}),i}catch(r){i.error(`${n} could not resolve ${e} record A`)}throw new Error(`Could not resolve ${e} record A`)}async resolve6(e){const t=this._cache.get(c(e,"AAAA"));if(t)return t;for(const n of this._getShuffledServers())try{const t=await a(o({serverResolver:n,hostname:e,recordType:"AAAA"})),r=await t.json(),i=r.Answer.map(e=>e.data),s=Math.min(r.Answer.map(e=>e.TTL));return this._cache.set(c(e,"AAAA"),i,{ttl:s}),i}catch(r){i.error(`${n} could not resolve ${e} record AAAA`)}throw new Error(`Could not resolve ${e} record AAAA`)}async resolveTxt(e){const t=this._cache.get(c(e,"TXT"));if(t)return t;for(const n of this._getShuffledServers())try{const t=await a(o({serverResolver:n,hostname:e,recordType:"TXT"})),r=await t.json(),i=r.Answer.map(e=>[e.data.replace(/['"]+/g,"")]),s=Math.min(r.Answer.map(e=>e.TTL));return this._cache.set(c(e,"TXT"),i,{ttl:s}),i}catch(r){i.error(`${n} could not resolve ${e} record TXT`)}throw new Error(`Could not resolve ${e} record TXT`)}}u.Resolver=u,e.exports=u},function(e,t,r){"use strict";e.exports=o;var n=r(75),i=o.prototype,s=new Date%1e9;function o(e){e=e||{},this.id=e.id||(1e9*Math.random()>>>0)+s++,this.max=e.max||1/0,this.items=e.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(e.lastModified||new Date);for(var t,r,n=this.items.length;n--;)t=this.items[n],r=new Date(t.expires)-new Date,this._lookup[t.key]=t,r>0?this.expire(t.key,r):r<=0&&this.delete(t.key)}i.has=function(e){return e in this._lookup},i.get=function(e){if(!this.has(e))return null;var t=this._lookup[e];return t.refresh&&this.expire(e,t.refresh),this.items.splice(this.items.indexOf(t),1),this.items.push(t),t.value},i.meta=function(e){if(!this.has(e))return null;var t=this._lookup[e];return"meta"in t?t.meta:null},i.set=function(e,t,r){var n=this._lookup[e],i=this._lookup[e]={key:e,value:t};return this.lastModified=new Date,n?(clearTimeout(n.timeout),this.items.splice(this.items.indexOf(n),1,i)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(i),this.size++),r&&("ttl"in r&&this.expire(e,r.ttl),"meta"in r&&(i.meta=r.meta),r.refresh&&(i.refresh=r.ttl)),this},i.delete=function(e){var t=this._lookup[e];return!!t&&(this.lastModified=new Date,this.items.splice(this.items.indexOf(t),1),clearTimeout(t.timeout),delete this._lookup[e],this.size--,this)},i.expire=function(e,t){var r=t||0,i=this._lookup[e];if(!i)return this;if("string"==typeof r&&(r=n(t)),"number"!=typeof r)throw new TypeError("Expiration time must be a string or number.");return clearTimeout(i.timeout),i.timeout=setTimeout(this.delete.bind(this,i.key),r),i.expires=Number(new Date)+r,this},i.clear=function(){for(var e=this.items.length;e--;)this.delete(this.items[e].key);return this},i.toJSON=function(){for(var e,t=new Array(this.items.length),r=t.length;r--;)e=this.items[r],t[r]={key:e.key,meta:e.meta,value:e.value,expires:e.expires,refresh:e.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:t}}},function(e,t,r){"use strict";const{default:n,Headers:i}=r(242);e.exports.buildResource=function({serverResolver:e,hostname:t,recordType:r}){return`${e}?name=${t}&type=${r}`},e.exports.fetch=function(e){return n(e,{headers:new i({accept:"application/dns-json"})})},e.exports.getCacheKey=function(e,t){return`${t}_${e}`}},function(e,t,r){"use strict";const n=r(243)();n.fetch&&n.Headers&&n.Request&&n.Response?(e.exports=function(...e){return n.fetch(...e)},e.exports.Headers=n.Headers,e.exports.Request=n.Request,e.exports.Response=n.Response,e.exports.default=e.exports):e.exports=r(247)},function(e,t,r){"use strict";var n=r(97),i=r(99),s=r(100),o=r(246),a=s(),c=function(){return a};n(c,{getPolyfill:s,implementation:i,shim:o}),e.exports=c},function(e,t,r){"use strict";var n=Array.prototype.slice,i=r(98),s=Object.keys,o=s?function(e){return s(e)}:r(245),a=Object.keys;o.shim=function(){Object.keys?function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2)||(Object.keys=function(e){return i(e)?a(n.call(e)):a(e)}):Object.keys=o;return Object.keys||o},e.exports=o},function(e,t,r){"use strict";var n;if(!Object.keys){var i=Object.prototype.hasOwnProperty,s=Object.prototype.toString,o=r(98),a=Object.prototype.propertyIsEnumerable,c=!a.call({toString:null},"toString"),u=a.call((function(){}),"prototype"),f=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],h=function(e){var t=e.constructor;return t&&t.prototype===e},d={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},l=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!d["$"+e]&&i.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{h(window[e])}catch(t){return!0}}catch(t){return!0}return!1}();n=function(e){var t=null!==e&&"object"==typeof e,r="[object Function]"===s.call(e),n=o(e),a=t&&"[object String]"===s.call(e),d=[];if(!t&&!r&&!n)throw new TypeError("Object.keys called on a non-object");var p=u&&r;if(a&&e.length>0&&!i.call(e,0))for(var y=0;y0)for(var g=0;g","main":"src/index.js","types":"dist/src/index.d.ts","typesVersions":{"*":{"src/*":["dist/src/*","dist/src/*/index"]}},"files":["dist","src"],"scripts":{"lint":"aegir lint","build":"aegir build","test":"npm run test:node && npm run test:browser","test:node":"aegir test -t node -f \\"./test/**/*.{node,spec}.js\\"","test:browser":"aegir test -t browser","test:examples":"cd examples && npm run test:all","release":"aegir release -t node -t browser","release-minor":"aegir release --type minor -t node -t browser","release-major":"aegir release --type major -t node -t browser","coverage":"nyc --reporter=text --reporter=lcov npm run test:node"},"repository":{"type":"git","url":"https://github.com/libp2p/js-libp2p.git"},"keywords":["libp2p","network","p2p","peer","peer-to-peer","IPFS"],"bugs":{"url":"https://github.com/libp2p/js-libp2p/issues"},"homepage":"https://libp2p.io","license":"MIT","engines":{"node":">=12.0.0","npm":">=6.0.0"},"dependencies":{"abort-controller":"^3.0.0","aggregate-error":"^3.0.1","any-signal":"^1.1.0","bignumber.js":"^9.0.0","cids":"^1.0.0","class-is":"^1.1.0","debug":"^4.1.1","err-code":"^2.0.0","events":"^3.1.0","hashlru":"^2.3.0","interface-datastore":"^2.0.0","ipfs-utils":"^5.0.1","it-all":"^1.0.1","it-buffer":"^0.1.2","it-handshake":"^1.0.1","it-length-prefixed":"^3.0.1","it-pipe":"^1.1.0","it-protocol-buffers":"^0.2.0","libp2p-crypto":"^0.18.0","libp2p-interfaces":"^0.8.0","libp2p-utils":"^0.2.2","mafmt":"^8.0.0","merge-options":"^2.0.0","moving-average":"^1.0.0","multiaddr":"^8.1.0","multicodec":"^2.0.0","multihashing-async":"^2.0.1","multistream-select":"^1.0.0","mutable-proxy":"^1.0.0","node-forge":"^0.9.1","p-any":"^3.0.0","p-fifo":"^1.0.0","p-settle":"^4.0.1","peer-id":"^0.14.2","protons":"^2.0.0","retimer":"^2.0.0","sanitize-filename":"^1.6.3","set-delayed-interval":"^1.0.0","streaming-iterables":"^5.0.2","timeout-abort-controller":"^1.1.1","varint":"^5.0.0","xsalsa20":"^1.0.2"},"devDependencies":{"@nodeutils/defaults-deep":"^1.1.0","abortable-iterator":"^3.0.0","aegir":"^29.2.0","chai-bytes":"^0.1.2","chai-string":"^1.5.0","delay":"^4.3.0","interop-libp2p":"^0.3.0","into-stream":"^6.0.0","ipfs-http-client":"^47.0.1","it-concat":"^1.0.0","it-pair":"^1.0.0","it-pushable":"^1.4.0","libp2p":".","libp2p-bootstrap":"^0.12.0","libp2p-delegated-content-routing":"^0.8.0","libp2p-delegated-peer-routing":"^0.8.0","libp2p-floodsub":"^0.24.0","libp2p-gossipsub":"^0.7.0","libp2p-kad-dht":"^0.20.0","libp2p-mdns":"^0.15.0","libp2p-mplex":"^0.10.1","libp2p-noise":"^2.0.0","libp2p-secio":"^0.13.1","libp2p-tcp":"^0.15.1","libp2p-webrtc-star":"^0.20.0","libp2p-websockets":"^0.15.0","multihashes":"^3.0.1","nock":"^13.0.3","p-defer":"^3.0.0","p-times":"^3.0.0","p-wait-for":"^3.1.0","promisify-es6":"^1.0.3","rimraf":"^3.0.2","sinon":"^9.0.2","uint8arrays":"^1.1.0"},"contributors":["David Dias ","Jacob Heun ","Vasco Santos ","Alan Shaw ","Alex Potsides ","Cayman ","Pedro Teixeira ","Friedel Ziegelmayer ","Maciej Krüger ","Hugo Dias ","dirkmc ","Volker Mische ","Richard Littauer ","a1300 ","Elven ","Andrew Nesbitt ","Giovanni T. Parra ","Ryan Bell ","Thomas Eizinger ","ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ ","Didrik Nordström ","Irakli Gozalishvili ","Ethan Lam ","Joel Gustafson ","Julien Bouquillon ","Kevin Kwok ","Nuno Nogueira ","Dmitriy Ryajov ","RasmusErik Voel Jensen ","Diogo Silva ","Samlior ","Smite Chow ","Soeren ","Sönke Hahn ","robertkiel ","Tiago Alves ","Daijiro Wachi ","Yusef Napora ","Zane Starr ","Cindy Wu ","Chris Bratlien ","ebinks ","Bernd Strehl ","Florian-Merle ","Francis Gulotta ","Felipe Martins ","isan_rivkin ","Henrique Dias ","Fei Liu "]}')},function(e,t,r){"use strict";const n=r(250);e.exports=function(e){const{address:t}=e.nodeAddress();return n(t)}},function(e,t,r){"use strict";e.exports=r(251).default},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(252).Netmask,i=r(96);t.default=function(e){return i.v4(e)||e.startsWith("0")?function(e){var t=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"].map((function(e){return new n(e)})),r=!0,i=!1,s=void 0;try{for(var o,a=t[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){if(o.value.contains(e))return!0}}catch(c){i=!0,s=c}finally{try{!r&&a.return&&a.return()}finally{if(i)throw s}}return!1}(e):/^::$/.test(t=e)||/^::1$/.test(t)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(t)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(t)||/^ff([0-9a-fA-F]{2,2}):/i.test(t);var t}},function(e,t,r){"use strict";(function(){var e,r,n;n=function(e){return[(e&255<<24)>>>24,(e&255<<16)>>>16,(65280&e)>>>8,255&e].join(".")},r=function(e){var t,r,n,i,s;if(0===(t=(e+"").split(".")).length||t.length>4)throw new Error("Invalid IP");for(n=i=0,s=t.length;i255)throw new Error("Invalid byte: "+r)}return((t[0]||0)<<24|(t[1]||0)<<16|(t[2]||0)<<8|(t[3]||0))>>>0},e=function(){function e(e,t){var i,s,o,a,c;if("string"!=typeof e)throw new Error("Missing `net' parameter");if(t||(c=e.split("/",2),e=c[0],t=c[1]),!t)switch(e.split(".").length){case 1:t=8;break;case 2:t=16;break;case 3:t=24;break;case 4:t=32;break;default:throw new Error("Invalid net address: "+e)}if("string"==typeof t&&t.indexOf(".")>-1){try{this.maskLong=r(t)}catch(i){throw i,new Error("Invalid mask: "+t)}for(o=a=32;a>=0;o=--a)if(this.maskLong===4294967295<<32-o>>>0){this.bitmask=o;break}}else{if(!t)throw new Error("Invalid mask: empty");this.bitmask=parseInt(t,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0)}try{this.netLong=(r(e)&this.maskLong)>>>0}catch(s){throw s,new Error("Invalid net address: "+e)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+t);this.size=Math.pow(2,32-this.bitmask),this.base=n(this.netLong),this.mask=n(this.maskLong),this.hostmask=n(~this.maskLong),this.first=this.bitmask<=30?n(this.netLong+1):this.base,this.last=this.bitmask<=30?n(this.netLong+this.size-2):n(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?n(this.netLong+this.size-1):void 0}return e.prototype.contains=function(t){return"string"==typeof t&&(t.indexOf("/")>0||4!==t.split(".").length)&&(t=new e(t)),t instanceof e?this.contains(t.base)&&this.contains(t.broadcast||t.last):(r(t)&this.maskLong)>>>0==(this.netLong&this.maskLong)>>>0},e.prototype.next=function(t){return null==t&&(t=1),new e(n(this.netLong+this.size*t),this.mask)},e.prototype.forEach=function(e){var t,i,s,o,a,c,u,f;for(f=[],t=i=0,s=(a=function(){u=[];for(var e=c=r(this.first),t=r(this.last);c<=t?e<=t:e>=t;c<=t?e++:e--)u.push(e);return u}.apply(this)).length;i{const{concurrency:r=1/0}=t,s=i(r);return Promise.all(e.map(e=>e&&"function"==typeof e.then?n(e):n("function"==typeof e?s(()=>e()):Promise.resolve(e))))}},function(e,t,r){"use strict";const n=async e=>{try{return{isFulfilled:!0,isRejected:!1,value:await e}}catch(t){return{isFulfilled:!1,isRejected:!0,reason:t}}};e.exports=n,e.exports.default=n},function(e,t,r){"use strict";const n=r(256),i=e=>{if(!Number.isInteger(e)&&e!==1/0||!(e>0))return Promise.reject(new TypeError("Expected `concurrency` to be a number from 1 and up"));const t=[];let r=0;const i=()=>{r--,t.length>0&&t.shift()()},s=(e,t,...s)=>{r++;const o=n(e,...s);t(o),o.then(i,i)},o=(n,...i)=>new Promise(o=>((n,i,...o)=>{rr},pendingCount:{get:()=>t.length},clearQueue:{value:()=>{t.length=0}}}),o};e.exports=i,e.exports.default=i},function(e,t,r){"use strict";const n=(e,...t)=>new Promise(r=>{r(e(...t))});e.exports=n,e.exports.default=n},function(e,t,r){"use strict";const n=r(67),i=r(68);e.exports.updateSelfPeerRecord=async function(e){const t=new i({peerId:e.peerId,multiaddrs:e.multiaddrs}),r=await n.seal(t,e.peerId);e.peerStore.addressBook.consumePeerRecord(r)}},function(e,t,r){"use strict";const n=r(15);e.exports=n("\nmessage Envelope {\n // public_key is the public key of the keypair the enclosed payload was\n // signed with.\n bytes public_key = 1;\n\n // payload_type encodes the type of payload, so that it can be deserialized\n // deterministically.\n bytes payload_type = 2;\n\n // payload is the actual payload carried inside this envelope.\n bytes payload = 3;\n\n // signature is the signature produced by the private key corresponding to\n // the enclosed public key, over the payload, prefixing a domain string for\n // additional security.\n bytes signature = 5;\n}\n")},function(e,t,r){"use strict";e.exports=function(e,t){return e.length===t.length&&t.sort()&&e.sort().every((e,r)=>t[r].equals(e))}},function(e,t,r){"use strict";const n=r(15);e.exports=n("\nmessage PeerRecord {\n // AddressInfo is a wrapper around a binary multiaddr. It is defined as a\n // separate message to allow us to add per-address metadata in the future.\n message AddressInfo {\n bytes multiaddr = 1;\n }\n\n // peer_id contains a libp2p peer id in its binary representation.\n bytes peer_id = 1;\n\n // seq contains a monotonically-increasing sequence counter to order PeerRecords in time.\n uint64 seq = 2;\n\n // addresses is a list of public listen addresses for the peer.\n repeated AddressInfo addresses = 3;\n}\n")},function(e,t,r){"use strict";const n=r(76);e.exports.ENVELOPE_DOMAIN_PEER_RECORD=n.getName(n.LIBP2P_PEER_RECORD),e.exports.ENVELOPE_PAYLOAD_TYPE_PEER_RECORD=Uint8Array.from([3,1])},function(e,t,r){"use strict";const n=r(9);e.exports=class{constructor({listen:e=[],announce:t=[]}={}){this.listen=new Set(e),this.announce=new Set(t)}getListenAddrs(){return Array.from(this.listen).map(e=>n(e))}getAnnounceAddrs(){return Array.from(this.announce).map(e=>n(e))}}},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:connection-manager"),{error:n("libp2p:connection-manager:err")}),s=r(1),o=r(45),a=r(264),c=r(69),{EventEmitter:u}=r(19),f=r(6),{codes:{ERR_INVALID_PARAMETERS:h}}=r(7),d={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4,defaultPeerValue:1};function l(e,t){return e[1]-t[1]}e.exports=class extends u{constructor(e,t={}){if(super(),this._libp2p=e,this._peerId=e.peerId.toB58String(),this._options=o.call({ignoreUndefined:!0},d,t),this._options.maxConnectionse+t.length,0)}start(){this._libp2p.metrics&&(this._timer=this._timer||c(this._checkMetrics,this._options.pollInterval)),this._latencyMonitor=new a({latencyCheckIntervalMs:this._options.pollInterval,dataEmitIntervalMs:this._options.pollInterval}),this._onLatencyMeasure=this._onLatencyMeasure.bind(this),this._latencyMonitor.on("data",this._onLatencyMeasure),this._started=!0,i("started"),this._options.autoDial&&this._autoDial()}async stop(){this._autoDialTimeout&&this._autoDialTimeout.clear(),this._timer&&this._timer.clear(),this._latencyMonitor&&this._latencyMonitor.removeListener("data",this._onLatencyMeasure),this._started=!1,await this._close(),i("stopped")}async _close(){const e=[];for(const t of this.connections.values())for(const r of t)e.push(r.close());await e,this.connections.clear()}setPeerValue(e,t){if(t<0||t>1)throw new Error("value should be a number between 0 and 1");this._peerValues.set(e.toB58String(),t)}_checkMetrics(){if(this._libp2p.metrics){const e=this._libp2p.metrics.global.movingAverages,t=e.dataReceived[this._options.movingAverageInterval].movingAverage();this._checkMaxLimit("maxReceivedData",t);const r=e.dataSent[this._options.movingAverageInterval].movingAverage();this._checkMaxLimit("maxSentData",r);const n=t+r;this._checkMaxLimit("maxData",n),i("metrics update",n),this._timer=c(this._checkMetrics,this._options.pollInterval)}}onConnect(e){const t=e.remotePeer,r=t.toB58String(),n=this.connections.get(r);this.emit("peer:connect",e),n?n.push(e):this.connections.set(r,[e]),this._libp2p.peerStore.keyBook.set(t,t.pubKey),this._peerValues.has(r)||this._peerValues.set(r,this._options.defaultPeerValue),this._checkMaxLimit("maxConnections",this.size)}onDisconnect(e){const t=e.remotePeer.toB58String();let r=this.connections.get(t);r&&r.length>1?(r=r.filter(t=>t.id!==e.id),this.connections.set(t,r)):r&&(this.connections.delete(t),this._peerValues.delete(e.remotePeer.toB58String()),this.emit("peer:disconnect",e))}get(e){const t=this.getAll(e);return t.length?t[0]:null}getAll(e){if(!f.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),h);const t=e.toB58String(),r=this.connections.get(t);return r?r.filter(e=>"open"===e.stat.status):[]}_onLatencyMeasure(e){this._checkMaxLimit("maxEventLoopDelay",e.avgMs)}_checkMaxLimit(e,t){const r=this._options[e];i("checking limit of %s. current value: %d of %d",e,t,r),t>r&&(i("%s: limit exceeded: %s, %d",this._peerId,e,t),this._maybeDisconnectOne())}async _autoDial(){const e=this._options.minConnections;if(this.size>=e)return void(this._autoDialTimeout=c(this._autoDial,this._options.autoDialInterval));const t=Array.from(this._libp2p.peerStore.peers.values()).sort((e,t)=>!t.protocols||!t.protocols.length||e.protocols&&e.protocols.length?t.id.pubKey&&!e.id.pubKey?1:-1:1);for(let n=0;n{const t=a.now(e);return 1e3*t[0]+t[1]/1e6}):"undefined"!=typeof window&&window.performance&&window.performance.now?(o("Using performance.now for timing"),a.now=window.performance.now.bind(window.performance),a.getDeltaMS=e=>Math.round(a.now()-e)):(o("Using Date.now for timing"),a.now=Date.now,a.getDeltaMS=e=>a.now()-e),a._latencyData=a._initLatencyData(),"undefined"!=typeof window&&(a._visibilityChangeEmitter=new s,a._visibilityChangeEmitter.on("visibilityChange",e=>{e?a._startTimers():(a._emitSummary(),a._stopTimers())})),a._visibilityChangeEmitter&&!a._visibilityChangeEmitter.isVisible()||a._startTimers()}_startTimers(){this._checkLatencyID||(this._checkLatency(),this.dataEmitIntervalMs&&(this._emitIntervalID=setInterval(()=>this._emitSummary(),this.dataEmitIntervalMs),"function"==typeof this._emitIntervalID.unref&&this._emitIntervalID.unref()))}_stopTimers(){this._checkLatencyID&&(clearTimeout(this._checkLatencyID),this._checkLatencyID=void 0),this._emitIntervalID&&(clearInterval(this._emitIntervalID),this._emitIntervalID=void 0)}_emitSummary(){const e=this.getSummary();e.events>0&&this.emit("data",e)}getSummary(){const e={events:this._latencyData.events,minMs:this._latencyData.minMs,maxMs:this._latencyData.maxMs,avgMs:this._latencyData.events?this._latencyData.totalMs/this._latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this._latencyData.startTime)};return this._latencyData=this._initLatencyData(),o("Summary: %O",e),e}_checkLatency(){const e=this,t=Math.random()*e._latecyCheckMultiply-e._latecyCheckSubtract,r={deltaOffset:Math.ceil(e.latencyCheckIntervalMs+t),startTime:e.now()},n=()=>{if(!this._checkLatencyID)return;const t=e.getDeltaMS(r.startTime)-r.deltaOffset;e._checkLatency(),e._latencyData.events++,e._latencyData.minMs=Math.min(e._latencyData.minMs,t),e._latencyData.maxMs=Math.max(e._latencyData.maxMs,t),e._latencyData.totalMs+=t,o("MS: %s Data: %O",t,e._latencyData)};o("localData: %O",r),this._checkLatencyID=setTimeout(()=>{e.asyncTestFn?(r.deltaOffset=0,r.startTime=e.now(),e.asyncTestFn(n)):(r.deltaOffset-=1,n())},r.deltaOffset),"function"==typeof this._checkLatencyID.unref&&this._checkLatencyID.unref()}_initLatencyData(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}}},function(e,t,r){"use strict";const{EventEmitter:n}=r(19),i=r(2)("latency-monitor:VisibilityChangeEmitter");e.exports=class extends n{constructor(){super(),"undefined"!=typeof document?(this._initializeVisibilityVarNames(),this._addVisibilityChangeListener()):i('This is not a browser, no "document" found. Stopping.')}_initializeVisibilityVarNames(){let e,t;void 0!==document.hidden?(e="hidden",t="visibilitychange"):void 0!==document.mozHidden?(e="mozHidden",t="mozvisibilitychange"):void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden&&(e="webkitHidden",t="webkitvisibilitychange"),this._hidden=e,this._visibilityChange=t}_addVisibilityChangeListener(){void 0===document.addEventListener||void 0===document[this._hidden]?i("Checking page visibility requires a browser that supports the Page Visibility API."):document.addEventListener(this._visibilityChange,this._handleVisibilityChange.bind(this),!1)}isVisible(){if(void 0!==this._hidden&&void 0!==document[this._hidden])return!document[this._hidden]}_handleVisibilityChange(){const e=!document[this._hidden];i(e?"Page Visible":"Page Hidden"),this.emit("visibilityChange",e)}}},function(e,t,r){"use strict";e.exports=function(){return Date.now()}},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:circuit"),{error:n("libp2p:circuit:err")}),s=r(268),o=r(9),a=r(6),{CircuitRelay:c}=r(32),u=r(269),{relay:f}=r(46),h=r(273),{handleCanHop:d,handleHop:l,hop:p}=r(104),{handleStop:y}=r(111),g=r(70),b=Symbol.for("@libp2p/js-libp2p-circuit/circuit");class m{constructor({libp2p:e,upgrader:t}){this._dialer=e.dialer,this._registrar=e.registrar,this._connectionManager=e.connectionManager,this._upgrader=t,this._options=e._config.relay,this._libp2p=e,this.peerId=e.peerId,this._registrar.handle(f,this._onProtocol.bind(this))}async _onProtocol({connection:e,stream:t}){const r=new g({stream:t}),n=await r.read();if(!n)return;const s=this;let a;switch(n.type){case c.Type.CAN_HOP:i("received CAN_HOP request from %s",e.remotePeer.toB58String()),await d({circuit:s,connection:e,streamHandler:r});break;case c.Type.HOP:i("received HOP request from %s",e.remotePeer.toB58String()),a=await l({connection:e,request:n,streamHandler:r,circuit:s});break;case c.Type.STOP:i("received STOP request from %s",e.remotePeer.toB58String()),a=await y({connection:e,request:n,streamHandler:r});break;default:i("Request of type %s not supported",n.type)}if(a){const e=o(n.dstPeer.addrs[0]),t=o(n.srcPeer.addrs[0]),r=u({stream:a,remoteAddr:e,localAddr:t}),s=n.type===c.Type.HOP?"relay":"inbound";i("new %s connection %s",s,r.remoteAddr);const f=await this._upgrader.upgradeInbound(r);i("%s connection %s upgraded",s,r.remoteAddr),this.handler&&this.handler(f)}}async dial(e,t){const r=e.toString().split("/p2p-circuit"),n=o(r[0]),s=o(r[r.length-1]),f=a.createFromCID(n.getPeerId()),h=a.createFromCID(s.getPeerId());let d=!1,l=this._connectionManager.get(f);l||(l=await this._dialer.connectToPeer(n,t),d=!0);try{const t=await p({connection:l,request:{type:c.Type.HOP,srcPeer:{id:this.peerId.toBytes(),addrs:this._libp2p.multiaddrs.map(e=>e.bytes)},dstPeer:{id:h.toBytes(),addrs:[o(s).bytes]}}}),r=n.encapsulate("/p2p-circuit/p2p/"+this.peerId.toB58String()),a=u({stream:t,remoteAddr:e,localAddr:r});return i("new outbound connection %s",a.remoteAddr),this._upgrader.upgradeOutbound(a)}catch(y){throw i.error("Circuit relay dial failed",y),d&&await l.close(),y}}createListener(e,t){return"function"==typeof e&&(t=e,e={}),this.handler=t,h(this._libp2p)}filter(e){return(e=Array.isArray(e)?e:[e]).filter(e=>s.Circuit.matches(e))}get[Symbol.toStringTag](){return"Circuit"}static isTransport(e){return Boolean(e&&e[b])}}e.exports=m},function(e,t,r){"use strict";const n=r(9),i=R("dns4"),s=R("dns6"),o=R("dnsaddr"),a=T(R("dns"),o,i,s),c=T(R("ip4"),R("ip6")),u=T(I(c,R("tcp")),I(a,R("tcp"))),f=I(c,R("udp")),h=I(f,R("utp")),d=T(I(u,R("ws")),I(a,R("ws"))),l=T(I(u,R("wss")),I(a,R("wss"))),p=T(I(u,R("http")),I(c,R("http")),I(a,R("http"))),y=T(I(u,R("https")),I(c,R("https")),I(a,R("https"))),g=T(I(d,R("p2p-webrtc-star"),R("p2p")),I(l,R("p2p-webrtc-star"),R("p2p")),I(d,R("p2p-webrtc-star")),I(l,R("p2p-webrtc-star"))),b=T(I(d,R("p2p-websocket-star"),R("p2p")),I(l,R("p2p-websocket-star"),R("p2p")),I(d,R("p2p-websocket-star")),I(l,R("p2p-websocket-star"))),m=T(I(p,R("p2p-webrtc-direct")),I(y,R("p2p-webrtc-direct"))),v=T(d,l,p,y,g,m,u,h,a),w=T(I(v,R("p2p-stardust"),R("p2p")),I(v,R("p2p-stardust"))),E=T(I(v,R("p2p")),g,R("p2p")),S=T(I(E,R("p2p-circuit"),E),I(E,R("p2p-circuit")),I(R("p2p-circuit"),E),I(v,R("p2p-circuit")),I(R("p2p-circuit"),v),R("p2p-circuit")),A=()=>T(I(S,A),S),_=A(),C=T(I(_,E,_),I(E,_),I(_,E),_,E);function k(e){return function(t){if(!n.isMultiaddr(t))try{t=n(t)}catch(i){return!1}const r=e(t.protoNames());return null!==r&&0===r.length}}function I(){const e=Array.from(arguments);function t(t){return t.length{if(null===(t="function"==typeof e?e().partialMatch(t):e.partialMatch(t)))return!0}),t)}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:k(t),partialMatch:t}}function T(){const e=Array.from(arguments);function t(t){let r=null;return e.some(e=>{const n="function"==typeof e?e().partialMatch(t):e.partialMatch(t);if(n)return r=n,!0}),r}const r={toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:k(t),partialMatch:t};return r}function R(e){const t=e;return{toString:function(){return t},matches:function(e){if("string"==typeof e)try{e=n(e)}catch(i){return!1}const r=e.protoNames();return 1===r.length&&r[0]===t},partialMatch:function(e){return 0===e.length?null:e[0]===t?e.slice(1):null}}}t.DNS=a,t.DNS4=i,t.DNS6=s,t.DNSADDR=o,t.IP=c,t.TCP=u,t.UDP=f,t.UTP=h,t.HTTP=p,t.HTTPS=y,t.WebSockets=d,t.WebSocketsSecure=l,t.WebSocketStar=b,t.WebRTCStar=g,t.WebRTCDirect=m,t.Reliable=v,t.Stardust=w,t.Circuit=_,t.P2P=C,t.IPFS=C},function(e,t,r){"use strict";const n=r(270),i=r(2)("libp2p:stream:converter");e.exports=function({stream:e,remoteAddr:t,localAddr:r},s={}){const{sink:o,source:a}=e,c={async sink(e){s.signal&&(e=n(e,s.signal));try{await o(e)}catch(t){"aborted"!==t.type&&i(t)}u()},source:s.signal?n(a,s.signal):a,conn:e,localAddr:r,remoteAddr:t,timeline:{open:Date.now()},close(){o([]),u()}};function u(){c.timeline.close||(c.timeline.close=Date.now())}return c}},function(e,t,r){"use strict";const n=r(271),i=r(272),s=(e,t,r)=>o(e,Array.isArray(t)?t:[{signal:t,options:r}]),o=(e,t)=>(e=n(e),t=t.map(({signal:e,options:t})=>({signal:e,options:t||{}})),async function*(){let r;const n=()=>{r&&r()};for(const{signal:e}of t)e.addEventListener("abort",n);for(;;){let o;try{for(const{signal:e,options:r}of t)if(e.aborted){const{abortMessage:e,abortCode:t}=r;throw new i(e,t)}const n=new Promise((e,n)=>{r=()=>{const{options:e}=t.find(({signal:e})=>e.aborted),{abortMessage:r,abortCode:s}=e;n(new i(r,s))}});o=await Promise.race([n,e.next()]),r=null}catch(s){for(const{signal:e}of t)e.removeEventListener("abort",n);const r=t.find(({signal:e})=>e.aborted),i="aborted"===s.type&&r;if(i&&r.options.onAbort&&await r.options.onAbort(e),"function"==typeof e.return&&await e.return(),i&&r.options.returnOnAbort)return;throw s}if(o.done)break;yield o.value}for(const{signal:e}of t)e.removeEventListener("abort",n)}()),a=(e,t,r)=>c(e,Array.isArray(t)?t:[{signal:t,options:r}]),c=(e,t)=>r=>e(o(r,t)),u=(e,t)=>({sink:c(e.sink,t),source:o(e.source,t)});e.exports=s,e.exports.AbortError=i,e.exports.source=s,e.exports.sink=a,e.exports.transform=a,e.exports.duplex=(e,t,r)=>u(e,Array.isArray(t)?t:[{signal:t,options:r}])},function(e,t,r){"use strict";e.exports=function(e){if(e){if("function"==typeof e[Symbol.iterator])return e[Symbol.iterator]();if("function"==typeof e[Symbol.asyncIterator])return e[Symbol.asyncIterator]();if("function"==typeof e.next)return e}throw new Error("argument is not an iterator or iterable")}},function(e,t,r){"use strict";e.exports=class extends Error{constructor(e,t){super(e||"The operation was aborted"),this.type="aborted",this.code=t||"ABORT_ERR"}}},function(e,t,r){"use strict";const{EventEmitter:n}=r(19),i=r(9);e.exports=e=>{const t=new Map;const r=Object.assign(new n,{close:()=>Promise.resolve(),listen:async function(n){const s=String(n).split("/p2p-circuit").find(e=>""!==e),o=await e.dial(i(s)),a=o.remoteAddr.encapsulate("/p2p-circuit");t.set(o.remotePeer.toB58String(),a),r.emit("listening")},getAddrs:function(){const e=[];for(const r of t.values())e.push(r);return e}});return e.connectionManager.on("peer:disconnect",e=>{t.delete(e.remotePeer.toB58String())&&r.emit("close")}),r}},function(e,t,r){"use strict";const{Buffer:n}=r(11),i=r(25),s=r(106);function o(e){e=e||{};const t=Math.max(e.poolSize||10240,e.minPoolSize||8),r=e.lengthEncoder||s;return e=>async function*(){let s=n.alloc(t),o=0;for await(const a of e){r(a.length,s,o);const e=s.slice(o,o+r.bytes);o+=r.bytes,s.length-o<8&&(s=n.alloc(t),o=0),yield(new i).append(e).append(a)}}()}o.single=(e,t)=>{const r=(t=t||{}).lengthEncoder||s;return new i([r(e.length),e])},e.exports=o,e.exports.MIN_POOL_SIZE=8,e.exports.DEFAULT_POOL_SIZE=10240},function(e,t,r){"use strict";const{Buffer:n}=r(11),i=r(25),s=r(107),o=n.alloc(0),a="readLength",c="readData",u={[a]:(e,t,r,n)=>{let s;t=t.append(e);try{s=n.lengthDecoder(t)}catch(u){if(t.length>n.maxLengthLength)throw Object.assign(u,{message:"message length too long",code:"ERR_MSG_LENGTH_TOO_LONG"});if(u instanceof RangeError)return{mode:a,buffer:t};throw u}if(s>n.maxDataLength)throw Object.assign(new Error("message data too long"),{code:"ERR_MSG_DATA_TOO_LONG"});return e=t.shallowSlice(n.lengthDecoder.bytes),t=new i,n.onLength&&n.onLength(s),s<=0?(n.onData&&n.onData(o),{mode:a,chunk:e,buffer:t,data:o}):{mode:c,chunk:e,buffer:t,state:{dataLength:s}}},[c]:(e,t,r,n)=>{if((t=t.append(e)).lengths?t.shallowSlice(s):null,t=new i,n.onData&&n.onData(o),{mode:a,chunk:e,buffer:t,data:o}}};function f(e){return(e=e||{}).lengthDecoder=e.lengthDecoder||s,e.maxLengthLength=e.maxLengthLength||8,e.maxDataLength=e.maxDataLength||4194304,t=>async function*(){let r,n=new i,s=a;for await(let i of t)for(;i;){const t=u[s](i,n,r,e);({mode:s,chunk:i,buffer:n,state:r}=t),t.data&&(yield t.data)}if(n.length)throw Object.assign(new Error("unexpected end of input"),{code:"ERR_UNEXPECTED_EOF"})}()}f.fromReader=(e,t)=>{t=t||{};let r=1;const n={[Symbol.asyncIterator](){return this},next:async()=>{try{return await e.next(r)}catch(t){if("ERR_UNDER_READ"===t.code)return{done:!0,value:null};throw t}finally{r=1}}};return t.onLength=e=>{r=e},f(t)(n)},e.exports=f,e.exports.MAX_LENGTH_LENGTH=8,e.exports.MAX_DATA_LENGTH=4194304},function(e,t,r){"use strict";const{Buffer:n}=r(11),i=(e,t,r)=>((t=t||n.allocUnsafe(4)).writeInt32BE(e,r),t);i.bytes=4,e.exports=i},function(e,t,r){"use strict";const n=e=>{if(e.length<4)throw RangeError("Could not decode int32BE");return e.readInt32BE(0)};n.bytes=4,e.exports=n},function(e,t,r){"use strict";const n=r(109);e.exports=e=>{let t;"function"==typeof(e=e||{})?(t=e,e={}):t=e.onEnd;let r,i,s,o=new n;const a=e=>i?i(e):(o.push(e),r),c=e=>s?r:a({done:!1,value:e}),u=e=>s?r:(s=!0,e?(e=>(o=new n,i?i({error:e}):(o.push({error:e}),r)))(e):a({done:!0}));if(r={[Symbol.asyncIterator](){return this},next:()=>{if(!o.isEmpty()){if(e.writev){let e;const t=[];for(;!o.isEmpty();){if(e=o.shift(),e.error)throw e.error;t.push(e.value)}return{done:e.done,value:t}}const t=o.shift();if(t.error)throw t.error;return t}return s?{done:!0}:new Promise((t,n)=>{i=s=>(i=null,s.error?n(s.error):e.writev&&!s.done?t({done:s.done,value:[s.value]}):t(s),r)})},return:()=>(o=new n,u(),{done:!0}),throw:e=>(u(e),{done:!0}),push:c,end:u},!t)return r;const f=r;return r={[Symbol.asyncIterator](){return this},next:()=>f.next(),throw:e=>(f.throw(e),t&&(t(e),t=null),{done:!0}),return:()=>(f.return(),t&&(t(),t=null),{done:!0}),push:c,end:e=>(f.end(e),t&&(t(e),t=null),r)},r}},function(e,t,r){"use strict";e.exports=class{constructor(e){if(!(e>0)||0!=(e-1&e))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){const e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return void 0===this.buffer[this.btm]}}},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:relay"),{error:n("libp2p:relay:err")}),{setDelayedInterval:s,clearDelayedInterval:o}=r(94),a=r(281),{namespaceToCid:c}=r(112),{ADVERTISE_BOOT_DELAY:u,ADVERTISE_TTL:f,RELAY_RENDEZVOUS_NS:h}=r(66);e.exports=class{constructor(e){this._libp2p=e,this._options={advertise:{bootDelay:u,enabled:!0,ttl:f,...e._config.relay.advertise},...e._config.relay},this._autoRelay=this._options.autoRelay.enabled&&new a({libp2p:e,...this._options.autoRelay}),this._advertiseService=this._advertiseService.bind(this)}start(){this._options.hop.enabled&&this._options.advertise.enabled&&(this._timeout=s(this._advertiseService,this._options.advertise.ttl,this._options.advertise.bootDelay))}stop(){o(this._timeout)}async _advertiseService(){try{const e=await c(h);await this._libp2p.contentRouting.provide(e)}catch(e){"NO_ROUTERS_AVAILABLE"===e.code?(i.error("a content router, such as a DHT, must be provided in order to advertise the relay service",e),this.stop()):i.error(e)}}}},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:auto-relay"),{error:n("libp2p:auto-relay:err")}),s=r(5),o=r(4),a=r(9),c=r(6),{relay:u}=r(46),{canHop:f}=r(104),{namespaceToCid:h}=r(112),{CIRCUIT_PROTO_CODE:d,HOP_METADATA_KEY:l,HOP_METADATA_VALUE:p,RELAY_RENDEZVOUS_NS:y}=r(66);e.exports=class{constructor({libp2p:e,maxListeners:t=1}){this._libp2p=e,this._peerId=e.peerId,this._peerStore=e.peerStore,this._connectionManager=e.connectionManager,this._transportManager=e.transportManager,this._addressSorter=e.dialer.addressSorter,this.maxListeners=t,this._listenRelays=new Set,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this),this._peerStore.on("change:protocols",this._onProtocolChange),this._connectionManager.on("peer:disconnect",this._onPeerDisconnected)}async _onProtocolChange({peerId:e,protocols:t}){const r=e.toB58String(),n=t.find(e=>e===u);if(n||!this._listenRelays.has(r)){if(n&&!this._listenRelays.has(r))try{const t=this._connectionManager.get(e);if(!t)return;if(t.remoteAddr.protoCodes().includes(d))return void i(`relayed connection to ${r} will not be used to hop on`);await f({connection:t})&&(this._peerStore.metadataBook.set(e,l,s(p)),await this._addListenRelay(t,r))}catch(o){i.error(o)}}else this._removeListenRelay(r)}_onPeerDisconnected(e){const t=e.remotePeer.toB58String();this._listenRelays.has(t)&&this._removeListenRelay(t)}async _addListenRelay(e,t){if(this._listenRelays.size>=this.maxListeners)return;const r=this._peerStore.addressBook.getMultiaddrsForPeer(e.remotePeer,this._addressSorter);if(!r||!r.length)return;const n=r[0].toString()+"/p2p-circuit";this._listenRelays.add(t);try{await this._transportManager.listen([a(n)])}catch(s){i.error(s),this._listenRelays.delete(t)}}_removeListenRelay(e){this._listenRelays.delete(e)&&this._listenOnAvailableHopRelays([e])}async _listenOnAvailableHopRelays(e=[]){if(this._listenRelays.size>=this.maxListeners)return;const t=[];for(const[n,i]of this._peerStore.metadataBook.data.entries()){if(this._listenRelays.has(n)||e.includes(n))continue;const r=i.get(l);if(!r||o(r)!==p)continue;const s=c.createFromCID(n),a=this._connectionManager.get(s);if(a){if(await this._addListenRelay(a,n),this._listenRelays.size>=this.maxListeners)return}else t.push(s)}for(const n of t){const e=await this._libp2p.dial(n);if(await this._addListenRelay(e,n.toB58String()),this._listenRelays.size>=this.maxListeners)return}try{const e=await h(y);for await(const t of this._libp2p.contentRouting.findProviders(e)){if(!t.multiaddrs.length)continue;const e=t.id;this._peerStore.addressBook.add(e,t.multiaddrs);const r=await this._libp2p.dial(e);if(await this._addListenRelay(r,e.toB58String()),this._listenRelays.size>=this.maxListeners)return}}catch(r){i.error(r)}}}},function(e,t,r){"use strict";const n=r(1),i=r(26),s=r(283),o=r(13);async function a(e,t,r){const n=await a.digest(e,t,r);return i.encode(n,t,r)}a.multihash=i,a.digest=async(e,t,r)=>{const n=a.createHash(t),i=await n(e);return r?i.slice(0,r):i},a.createHash=function(e){if(!e)throw n(new Error("hash algorithm must be specified"),"ERR_HASH_ALGORITHM_NOT_SPECIFIED");if(e=i.coerceCode(e),!a.functions[e])throw n(new Error(`multihash function '${e}' not yet supported`),"ERR_HASH_ALGORITHM_NOT_SUPPORTED");return a.functions[e]},a.functions={0:s.identity,17:s.sha1,18:s.sha2256,19:s.sha2512,20:s.sha3512,21:s.sha3384,22:s.sha3256,23:s.sha3224,24:s.shake128,25:s.shake256,26:s.keccak224,27:s.keccak256,28:s.keccak384,29:s.keccak512,34:s.murmur3128,35:s.murmur332,86:s.dblSha2256},s.addBlake(a.functions),a.validate=async(e,t)=>{const r=await a(e,i.decode(t).name);return o(t,r)},e.exports=a},function(e,t,r){"use strict";const n=r(284),i=r(286),{factory:s}=r(30),{fromNumberTo32BitBuf:o}=r(288),a=r(5),c=e=>async t=>{switch(e){case"sha3-224":return new Uint8Array(n.sha3_224.arrayBuffer(t));case"sha3-256":return new Uint8Array(n.sha3_256.arrayBuffer(t));case"sha3-384":return new Uint8Array(n.sha3_384.arrayBuffer(t));case"sha3-512":return new Uint8Array(n.sha3_512.arrayBuffer(t));case"shake-128":return new Uint8Array(n.shake128.create(128).update(t).arrayBuffer());case"shake-256":return new Uint8Array(n.shake256.create(256).update(t).arrayBuffer());case"keccak-224":return new Uint8Array(n.keccak224.arrayBuffer(t));case"keccak-256":return new Uint8Array(n.keccak256.arrayBuffer(t));case"keccak-384":return new Uint8Array(n.keccak384.arrayBuffer(t));case"keccak-512":return new Uint8Array(n.keccak512.arrayBuffer(t));case"murmur3-128":return a(i.x64.hash128(t),"base16");case"murmur3-32":return o(i.x86.hash32(t));default:throw new TypeError(e+" is not a supported algorithm")}};e.exports={identity:e=>e,sha1:s("sha1"),sha2256:s("sha2-256"),sha2512:s("sha2-512"),dblSha2256:s("dbl-sha2-256"),sha3224:c("sha3-224"),sha3256:c("sha3-256"),sha3384:c("sha3-384"),sha3512:c("sha3-512"),shake128:c("shake-128"),shake256:c("shake-256"),keccak224:c("keccak-224"),keccak256:c("keccak-256"),keccak384:c("keccak-384"),keccak512:c("keccak-512"),murmur3128:c("murmur3-128"),murmur332:c("murmur3-32"),addBlake:r(289)}},function(e,t,r){"use strict";(function(n,i){var s;!function(){var o="input is invalid type",a="object"==typeof window,c=a?window:{};c.JS_SHA3_NO_WINDOW&&(a=!1);var u=!a&&"object"==typeof self;!c.JS_SHA3_NO_NODE_JS&&"object"==typeof n&&n.versions&&n.versions.node?c=i:u&&(c=self);var f=!c.JS_SHA3_NO_COMMON_JS&&"object"==typeof e&&e.exports,h=r(285),d=!c.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,l="0123456789abcdef".split(""),p=[4,1024,262144,67108864],y=[0,8,16,24],g=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],b=[224,256,384,512],m=[128,256],v=["hex","buffer","arrayBuffer","array","digest"],w={128:168,256:136};!c.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!d||!c.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"==typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var E=function(e,t,r){return function(n){return new D(e,t,e).update(n)[r]()}},S=function(e,t,r){return function(n,i){return new D(e,t,i).update(n)[r]()}},A=function(e,t,r){return function(t,n,i,s){return T["cshake"+e].update(t,n,i,s)[r]()}},_=function(e,t,r){return function(t,n,i,s){return T["kmac"+e].update(t,n,i,s)[r]()}},C=function(e,t,r,n){for(var i=0;i>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function O(e,t,r){D.call(this,e,t,r)}D.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(o);if(null===e)throw new Error(o);if(d&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||d&&ArrayBuffer.isView(e)))throw new Error(o);t=!0}for(var n,i,s=this.blocks,a=this.byteCount,c=e.length,u=this.blockCount,f=0,h=this.s;f>2]|=e[f]<>2]|=i<>2]|=(192|i>>6)<>2]|=(128|63&i)<=57344?(s[n>>2]|=(224|i>>12)<>2]|=(128|i>>6&63)<>2]|=(128|63&i)<>2]|=(240|i>>18)<>2]|=(128|i>>12&63)<>2]|=(128|i>>6&63)<>2]|=(128|63&i)<=a){for(this.start=n-a,this.block=s[u],n=0;n>=8);r>0;)i.unshift(r),r=255&(e>>=8),++n;return t?i.push(n):i.unshift(n),this.update(i),i.length},D.prototype.encodeString=function(e){var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(o);if(null===e)throw new Error(o);if(d&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!(Array.isArray(e)||d&&ArrayBuffer.isView(e)))throw new Error(o);t=!0}var n=0,i=e.length;if(t)n=i;else for(var s=0;s=57344?n+=3:(a=65536+((1023&a)<<10|1023&e.charCodeAt(++s)),n+=4)}return n+=this.encode(8*n),this.update(e),n},D.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+l[15&e]+l[e>>12&15]+l[e>>8&15]+l[e>>20&15]+l[e>>16&15]+l[e>>28&15]+l[e>>24&15];o%t==0&&(U(r),s=0)}return i&&(e=r[s],a+=l[e>>4&15]+l[15&e],i>1&&(a+=l[e>>12&15]+l[e>>8&15]),i>2&&(a+=l[e>>20&15]+l[e>>16&15])),a},D.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,s=0,o=0,a=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var c=new Uint32Array(e);o>8&255,c[e+2]=t>>16&255,c[e+3]=t>>24&255;a%r==0&&U(n)}return s&&(e=a<<2,t=n[o],c[e]=255&t,s>1&&(c[e+1]=t>>8&255),s>2&&(c[e+2]=t>>16&255)),c},O.prototype=new D,O.prototype.finalize=function(){return this.encode(this.outputBits,!0),D.prototype.finalize.call(this)};var U=function(e){var t,r,n,i,s,o,a,c,u,f,h,d,l,p,y,b,m,v,w,E,S,A,_,C,k,I,T,R,B,N,P,M,x,L,D,O,U,K,V,j,F,q,z,H,G,Y,$,Q,W,X,Z,J,ee,te,re,ne,ie,se,oe,ae,ce,ue,fe;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],s=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],a=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],f=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(o<<1|a>>>31),r=(l=e[9]^e[19]^e[29]^e[39]^e[49])^(a<<1|o>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|u>>>31),r=s^(u<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=o^(f<<1|h>>>31),r=a^(h<<1|f>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|l>>>31),r=u^(l<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=f^(i<<1|s>>>31),r=h^(s<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,p=e[0],y=e[1],Y=e[11]<<4|e[10]>>>28,$=e[10]<<4|e[11]>>>28,R=e[20]<<3|e[21]>>>29,B=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,ce=e[30]<<9|e[31]>>>23,q=e[40]<<18|e[41]>>>14,z=e[41]<<18|e[40]>>>14,L=e[2]<<1|e[3]>>>31,D=e[3]<<1|e[2]>>>31,b=e[13]<<12|e[12]>>>20,m=e[12]<<12|e[13]>>>20,Q=e[22]<<10|e[23]>>>22,W=e[23]<<10|e[22]>>>22,N=e[33]<<13|e[32]>>>19,P=e[32]<<13|e[33]>>>19,ue=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,O=e[14]<<6|e[15]>>>26,U=e[15]<<6|e[14]>>>26,v=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,X=e[34]<<15|e[35]>>>17,Z=e[35]<<15|e[34]>>>17,M=e[45]<<29|e[44]>>>3,x=e[44]<<29|e[45]>>>3,C=e[6]<<28|e[7]>>>4,k=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,K=e[26]<<25|e[27]>>>7,V=e[27]<<25|e[26]>>>7,E=e[36]<<21|e[37]>>>11,S=e[37]<<21|e[36]>>>11,J=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,H=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,I=e[18]<<20|e[19]>>>12,T=e[19]<<20|e[18]>>>12,se=e[29]<<7|e[28]>>>25,oe=e[28]<<7|e[29]>>>25,j=e[38]<<8|e[39]>>>24,F=e[39]<<8|e[38]>>>24,A=e[48]<<14|e[49]>>>18,_=e[49]<<14|e[48]>>>18,e[0]=p^~b&v,e[1]=y^~m&w,e[10]=C^~I&R,e[11]=k^~T&B,e[20]=L^~O&K,e[21]=D^~U&V,e[30]=H^~Y&Q,e[31]=G^~$&W,e[40]=te^~ne&se,e[41]=re^~ie&oe,e[2]=b^~v&E,e[3]=m^~w&S,e[12]=I^~R&N,e[13]=T^~B&P,e[22]=O^~K&j,e[23]=U^~V&F,e[32]=Y^~Q&X,e[33]=$^~W&Z,e[42]=ne^~se&ae,e[43]=ie^~oe&ce,e[4]=v^~E&A,e[5]=w^~S&_,e[14]=R^~N&M,e[15]=B^~P&x,e[24]=K^~j&q,e[25]=V^~F&z,e[34]=Q^~X&J,e[35]=W^~Z&ee,e[44]=se^~ae&ue,e[45]=oe^~ce&fe,e[6]=E^~A&p,e[7]=S^~_&y,e[16]=N^~M&C,e[17]=P^~x&k,e[26]=j^~q&L,e[27]=F^~z&D,e[36]=X^~J&H,e[37]=Z^~ee&G,e[46]=ae^~ue&te,e[47]=ce^~fe&re,e[8]=A^~p&b,e[9]=_^~y&m,e[18]=M^~C&I,e[19]=x^~k&T,e[28]=q^~L&O,e[29]=z^~D&U,e[38]=J^~H&Y,e[39]=ee^~G&$,e[48]=ue^~te&ne,e[49]=fe^~re&ie,e[0]^=g[n],e[1]^=g[n+1]};if(f)e.exports=T;else{for(B=0;B255)return!1;return!0}function o(e,t){return(65535&e)*t+(((e>>>16)*t&65535)<<16)}function a(e,t){return e<>>32-t}function c(e){return e=o(e^=e>>>16,2246822507),e=o(e^=e>>>13,3266489909),e^=e>>>16}function u(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]+t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]+t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]+t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]+t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]}function f(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]*t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]*t[3],r[1]+=r[2]>>>16,r[2]&=65535,r[2]+=e[3]*t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]*t[3],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[2]*t[2],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[3]*t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]}function h(e,t){return 32===(t%=64)?[e[1],e[0]]:t<32?[e[0]<>>32-t,e[1]<>>32-t]:(t-=32,[e[1]<>>32-t,e[0]<>>32-t])}function d(e,t){return 0===(t%=64)?e:t<32?[e[0]<>>32-t,e[1]<>>1]),e=l(e=f(e,[4283543511,3981806797]),[0,e[0]>>>1]),e=l(e=f(e,[3301882366,444984403]),[0,e[0]>>>1])}i.x86.hash32=function(e,t){if(!i.inputValidation||s(e)){t=t||0;for(var r=e.length%4,n=e.length-r,u=t,f=0,h=3432918353,d=461845907,l=0;l>>0}},i.x86.hash128=function(e,t){if(!i.inputValidation||s(e)){t=t||0;for(var r=e.length%16,n=e.length-r,u=t,f=t,h=t,d=t,l=0,p=0,y=0,g=0,b=597399067,m=2869860233,v=951274213,w=2716044179,E=0;E>>0).toString(16)).slice(-8)+("00000000"+(f>>>0).toString(16)).slice(-8)+("00000000"+(h>>>0).toString(16)).slice(-8)+("00000000"+(d>>>0).toString(16)).slice(-8)}},i.x64.hash128=function(e,t){if(!i.inputValidation||s(e)){t=t||0;for(var r=e.length%16,n=e.length-r,o=[0,t],a=[0,t],c=[0,0],y=[0,0],g=[2277735313,289559509],b=[1291169091,658871167],m=0;m>>0).toString(16)).slice(-8)+("00000000"+(o[1]>>>0).toString(16)).slice(-8)+("00000000"+(a[0]>>>0).toString(16)).slice(-8)+("00000000"+(a[1]>>>0).toString(16)).slice(-8)}},e.exports&&(t=e.exports=i),t.murmurHash3=i}()},function(e,t,r){"use strict";e.exports={fromNumberTo32BitBuf:e=>{const t=new Uint8Array(4);for(let r=0;r<4;r++)t[r]=255&e,e>>=8;return t}}},function(e,t,r){"use strict";const n=r(290),i={init:n.blake2bInit,update:n.blake2bUpdate,digest:n.blake2bFinal},s={init:n.blake2sInit,update:n.blake2sUpdate,digest:n.blake2sFinal},o=(e,t)=>async r=>{const n=t.init(e,null);return t.update(n,r),t.digest(n)};e.exports=e=>{for(let t=0;t<64;t++)e[45569+t]=o(t+1,i);for(let t=0;t<32;t++)e[45633+t]=o(t+1,s)}},function(e,t,r){"use strict";var n=r(291),i=r(292);e.exports={blake2b:n.blake2b,blake2bHex:n.blake2bHex,blake2bInit:n.blake2bInit,blake2bUpdate:n.blake2bUpdate,blake2bFinal:n.blake2bFinal,blake2s:i.blake2s,blake2sHex:i.blake2sHex,blake2sInit:i.blake2sInit,blake2sUpdate:i.blake2sUpdate,blake2sFinal:i.blake2sFinal}},function(e,t,r){"use strict";var n=r(113);function i(e,t,r){var n=e[t]+e[r],i=e[t+1]+e[r+1];n>=4294967296&&i++,e[t]=n,e[t+1]=i}function s(e,t,r,n){var i=e[t]+r;r<0&&(i+=4294967296);var s=e[t+1]+n;i>=4294967296&&s++,e[t]=i,e[t+1]=s}function o(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function a(e,t,r,n,o,a){var c=h[o],u=h[o+1],d=h[a],l=h[a+1];i(f,e,t),s(f,e,c,u);var p=f[n]^f[e],y=f[n+1]^f[e+1];f[n]=y,f[n+1]=p,i(f,r,n),p=f[t]^f[r],y=f[t+1]^f[r+1],f[t]=p>>>24^y<<8,f[t+1]=y>>>24^p<<8,i(f,e,t),s(f,e,d,l),p=f[n]^f[e],y=f[n+1]^f[e+1],f[n]=p>>>16^y<<16,f[n+1]=y>>>16^p<<16,i(f,r,n),p=f[t]^f[r],y=f[t+1]^f[r+1],f[t]=y>>>31^p<<1,f[t+1]=p>>>31^y<<1}var c=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),u=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map((function(e){return 2*e}))),f=new Uint32Array(32),h=new Uint32Array(32);function d(e,t){var r=0;for(r=0;r<16;r++)f[r]=e.h[r],f[r+16]=c[r];for(f[24]=f[24]^e.t,f[25]=f[25]^e.t/4294967296,t&&(f[28]=~f[28],f[29]=~f[29]),r=0;r<32;r++)h[r]=o(e.b,4*r);for(r=0;r<12;r++)a(0,8,16,24,u[16*r+0],u[16*r+1]),a(2,10,18,26,u[16*r+2],u[16*r+3]),a(4,12,20,28,u[16*r+4],u[16*r+5]),a(6,14,22,30,u[16*r+6],u[16*r+7]),a(0,10,20,30,u[16*r+8],u[16*r+9]),a(2,12,22,24,u[16*r+10],u[16*r+11]),a(4,14,16,26,u[16*r+12],u[16*r+13]),a(6,8,18,28,u[16*r+14],u[16*r+15]);for(r=0;r<16;r++)e.h[r]=e.h[r]^f[r]^f[r+16]}function l(e,t){if(0===e||e>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(t&&t.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");for(var r={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:e},n=0;n<16;n++)r.h[n]=c[n];var i=t?t.length:0;return r.h[0]^=16842752^i<<8^e,t&&(p(r,t),r.c=128),r}function p(e,t){for(var r=0;r>2]>>8*(3&r);return t}function g(e,t,r){r=r||64,e=n.normalizeInput(e);var i=l(r,t);return p(i,e),y(i)}e.exports={blake2b:g,blake2bHex:function(e,t,r){var i=g(e,t,r);return n.toHex(i)},blake2bInit:l,blake2bUpdate:p,blake2bFinal:y}},function(e,t,r){"use strict";var n=r(113);function i(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function s(e,t,r,n,i,s){u[e]=u[e]+u[t]+i,u[n]=o(u[n]^u[e],16),u[r]=u[r]+u[n],u[t]=o(u[t]^u[r],12),u[e]=u[e]+u[t]+s,u[n]=o(u[n]^u[e],8),u[r]=u[r]+u[n],u[t]=o(u[t]^u[r],7)}function o(e,t){return e>>>t^e<<32-t}var a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),c=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),u=new Uint32Array(16),f=new Uint32Array(16);function h(e,t){var r=0;for(r=0;r<8;r++)u[r]=e.h[r],u[r+8]=a[r];for(u[12]^=e.t,u[13]^=e.t/4294967296,t&&(u[14]=~u[14]),r=0;r<16;r++)f[r]=i(e.b,4*r);for(r=0;r<10;r++)s(0,4,8,12,f[c[16*r+0]],f[c[16*r+1]]),s(1,5,9,13,f[c[16*r+2]],f[c[16*r+3]]),s(2,6,10,14,f[c[16*r+4]],f[c[16*r+5]]),s(3,7,11,15,f[c[16*r+6]],f[c[16*r+7]]),s(0,5,10,15,f[c[16*r+8]],f[c[16*r+9]]),s(1,6,11,12,f[c[16*r+10]],f[c[16*r+11]]),s(2,7,8,13,f[c[16*r+12]],f[c[16*r+13]]),s(3,4,9,14,f[c[16*r+14]],f[c[16*r+15]]);for(r=0;r<8;r++)e.h[r]^=u[r]^u[r+8]}function d(e,t){if(!(e>0&&e<=32))throw new Error("Incorrect output length, should be in [1, 32]");var r=t?t.length:0;if(t&&!(r>0&&r<=32))throw new Error("Incorrect key length, should be in [1, 32]");var n={h:new Uint32Array(a),b:new Uint32Array(64),c:0,t:0,outlen:e};return n.h[0]^=16842752^r<<8^e,r>0&&(l(n,t),n.c=64),n}function l(e,t){for(var r=0;r>2]>>8*(3&r)&255;return t}function y(e,t,r){r=r||32,e=n.normalizeInput(e);var i=d(r,t);return l(i,e),p(i)}e.exports={blake2s:y,blake2sHex:function(e,t,r){var i=y(e,t,r);return n.toHex(i)},blake2sInit:d,blake2sUpdate:l,blake2sFinal:p}},function(e,t,r){"use strict";e.exports=r(35).TextEncoder},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:dialer"),{error:n("libp2p:dialer:err")}),s=r(1),o=r(9),a=r(295),c=r(115),u=r(297),{publicAddressesFirst:f}=r(102),h=r(95),{codes:d}=r(7),{DIAL_TIMEOUT:l,MAX_PARALLEL_DIALS:p,MAX_PER_PEER_DIALS:y}=r(65);e.exports=class{constructor({transportManager:e,peerStore:t,addressSorter:r=f,concurrency:n=p,timeout:i=l,perPeerLimit:s=y,resolvers:a={}}){this.transportManager=e,this.peerStore=t,this.addressSorter=r,this.concurrency=n,this.timeout=i,this.perPeerLimit=s,this.tokens=[...new Array(n)].map((e,t)=>t),this._pendingDials=new Map;for(const[c,u]of Object.entries(a))o.resolvers.set(c,u)}destroy(){for(const t of this._pendingDials.values())try{t.controller.abort()}catch(e){i.error(e)}this._pendingDials.clear()}async connectToPeer(e,t={}){const r=await this._createDialTarget(e);if(!r.addrs.length)throw s(new Error("The dial request has no addresses"),d.ERR_NO_VALID_ADDRESSES);const n=this._pendingDials.get(r.id)||this._createPendingDial(r,t);try{const e=await n.promise;return i("dial succeeded to %s",r.id),e}catch(o){throw n.controller.signal.aborted&&(o.code=d.ERR_TIMEOUT),i.error(o),o}finally{n.destroy()}}async _createDialTarget(e){const{id:t,multiaddrs:r}=h(e);r&&this.peerStore.addressBook.add(t,r);let n=this.peerStore.addressBook.getMultiaddrsForPeer(t,this.addressSorter)||[];o.isMultiaddr(e)&&(n=n.filter(t=>!e.equals(t)),n.unshift(e));const i=[];for(const s of n){(await this._resolve(s)).forEach(e=>i.push(e))}return{id:t.toB58String(),addrs:i}}_createPendingDial(e,t={}){const r=new u({addrs:e.addrs,dialAction:(e,t)=>{if(t.signal.aborted)throw s(new Error("already aborted"),d.ERR_ALREADY_ABORTED);return this.transportManager.dial(e,t)},dialer:this}),n=new a(this.timeout),i=[n.signal];t.signal&&i.push(t.signal);const o=c(i),f={dialRequest:r,controller:n,promise:r.run({...t,signal:o}),destroy:()=>{n.clear(),this._pendingDials.delete(e.id)}};return this._pendingDials.set(e.id,f),f}getTokens(e){const t=Math.min(e,this.perPeerLimit,this.tokens.length),r=this.tokens.splice(0,t);return i("%d tokens request, returning %d, %d remaining",e,t,this.tokens.length),r}releaseToken(e){this.tokens.indexOf(e)>-1||(i("token %d released",e),this.tokens.push(e))}async _resolve(e){if(!e.protoNames().includes("dnsaddr"))return[e];const t=await this._resolveRecord(e);return(await Promise.all(t.map(e=>this._resolve(e)))).flat().reduce((e,t)=>(e.find(e=>e.equals(t))||e.push(t),e),[])}async _resolveRecord(e){try{e=o(e.toString());return await e.resolve()}catch(t){return i.error(`multiaddr ${e} could not be resolved`),[]}}}},function(e,t,r){"use strict";const{AbortController:n}="undefined"!=typeof self?self:"undefined"!=typeof window?window:r(114),i=r(69);class s extends n{constructor(e){super(),this._ms=e,this._timer=i(()=>this.abort(),e),Object.setPrototypeOf(this,s.prototype)}abort(){return this._timer.clear(),super.abort()}clear(){this._timer.clear()}reset(){this._timer.clear(),this._timer=i(()=>this.abort(),this._ms)}}e.exports=s,e.exports.TimeoutController=s},function(e,t,r){"use strict";e.exports=AbortController},function(e,t,r){"use strict";const n=r(1),i=r(114).default,s=r(115),o=r(298),a=r(64);e.exports=class{constructor({addrs:e,dialAction:t,dialer:r}){this.addrs=e,this.dialer=r,this.dialAction=t}async run(e={}){const t=this.dialer.getTokens(this.addrs.length);if(t.length<1)throw n(new Error("No dial tokens available"),"ERR_NO_DIAL_TOKENS");const r=new o;t.forEach(e=>r.push(e));const c=this.addrs.map(()=>new i);let u=0;try{return await a(this.addrs.map(async(n,i)=>{const o=await r.shift();let a;try{const f=c[i].signal;a=await this.dialAction(n,{...e,signal:s([f,e.signal])}),c.splice(i,1)}finally{u++,this.addrs.length-u>=t.length?r.push(o):this.dialer.releaseToken(t.splice(t.indexOf(o),1)[0])}return a}))}finally{c.map(e=>e.abort()),t.forEach(e=>this.dialer.releaseToken(e))}}}},function(e,t,r){"use strict";const n=r(109),i=r(110);e.exports=class{constructor(){this._buffer=new n,this._waitingConsumers=new n}push(e){const{promise:t,resolve:r}=i();return this._buffer.push({chunk:e,resolve:r}),this._consume(),t}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){const e=this._waitingConsumers.shift(),t=this._buffer.shift();e.resolve(t.chunk),t.resolve()}}shift(){const{promise:e,resolve:t}=i();return this._waitingConsumers.push({resolve:t}),this._consume(),e}isEmpty(){return this._buffer.isEmpty()}}},function(e,t,r){"use strict";const n=r(300),i=r(45),s=r(116),o=r(117),a=r(313),c=r(1),{Number:u}=r(35),f=r(4),h=r(5);r(58);const d=new WeakMap,l=14,p=16,y=1e3,g={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function b(e){return!!e&&("string"==typeof e&&e===n(e.trim()))}async function m(e){const t=800*Math.random()+200;throw await new Promise(e=>setTimeout(e,t)),e}function v(e){return new o.Key("/pkcs8/"+e)}function w(e){return new o.Key("/info/"+e)}e.exports=class{constructor(e,t){if(!e)throw new Error("store is required");if(this.store=e,this.opts=i(g,t),this.opts.passPhrase&&this.opts.passPhrase.length<20)throw new Error("passPhrase must be least 20 characters");if(this.opts.dek.keyLengtht.id===e)}catch(t){return m(t)}}async findKeyByName(e){if(!b(e))return m(c(new Error(`Invalid key name '${e}'`),"ERR_INVALID_KEY_NAME"));const t=w(e);try{const e=await this.store.get(t);return JSON.parse(f(e))}catch(r){return m(c(new Error(`Key '${e}' does not exist. ${r.message}`),"ERR_KEY_NOT_FOUND"))}}async removeKey(e){if(!b(e)||"self"===e)return m(c(new Error(`Invalid key name '${e}'`),"ERR_INVALID_KEY_NAME"));const t=v(e),r=await this.findKeyByName(e),n=this.store.batch();return n.delete(t),n.delete(w(e)),await n.commit(),r}async renameKey(e,t){const r=this;if(!b(e)||"self"===e)return m(c(new Error(`Invalid old key name '${e}'`),"ERR_OLD_KEY_NAME_INVALID"));if(!b(t)||"self"===t)return m(c(new Error(`Invalid new key name '${t}'`),"ERR_NEW_KEY_NAME_INVALID"));const n=v(e),i=v(t),s=w(e),o=w(t);if(await r.store.has(i))return m(c(new Error(`Key '${t}' already exists`),"ERR_KEY_ALREADY_EXISTS"));try{const e=await r.store.get(n),a=await r.store.get(s),c=JSON.parse(f(a));c.name=t;const u=r.store.batch();return u.put(i,e),u.put(o,h(JSON.stringify(c))),u.delete(n),u.delete(s),await u.commit(),c}catch(a){return m(a)}}async exportKey(e,t){if(!b(e))return m(c(new Error(`Invalid key name '${e}'`),"ERR_INVALID_KEY_NAME"));if(!t)return m(c(new Error("Password is required"),"ERR_PASSWORD_REQUIRED"));const r=v(e);try{const e=await this.store.get(r),n=f(e),i=d.get(this).dek;return(await s.keys.import(n,i)).export(t)}catch(n){return m(n)}}async importKey(e,t,r){if(!b(e)||"self"===e)return m(c(new Error(`Invalid key name '${e}'`),"ERR_INVALID_KEY_NAME"));if(!t)return m(c(new Error("PEM encoded key is required"),"ERR_PEM_REQUIRED"));const n=v(e);if(await this.store.has(n))return m(c(new Error(`Key '${e}' already exists`),"ERR_KEY_ALREADY_EXISTS"));let i,o;try{i=await s.keys.import(t,r)}catch(f){return m(c(new Error("Cannot read the key, most likely the password is wrong"),"ERR_CANNOT_READ_KEY"))}try{o=await i.id();const e=d.get(this).dek;t=await i.export(e)}catch(f){return m(f)}const a={name:e,id:o},u=this.store.batch();return u.put(n,h(t)),u.put(w(e),h(JSON.stringify(a))),await u.commit(),a}async importPeer(e,t){const r=this;if(!b(e))return m(c(new Error(`Invalid key name '${e}'`),"ERR_INVALID_KEY_NAME"));if(!t||!t.privKey)return m(c(new Error("Peer.privKey is required"),"ERR_MISSING_PRIVATE_KEY"));const n=t.privKey,i=v(e);if(await r.store.has(i))return m(c(new Error(`Key '${e}' already exists`),"ERR_KEY_ALREADY_EXISTS"));try{const t=await n.id(),s=d.get(this).dek,o=await n.export(s),a={name:e,id:t},c=r.store.batch();return c.put(i,h(o)),c.put(w(e),h(JSON.stringify(a))),await c.commit(),a}catch(s){return m(s)}}async _getPrivateKey(e){if(!b(e))return m(c(new Error(`Invalid key name '${e}'`),"ERR_INVALID_KEY_NAME"));try{const t=v(e),r=await this.store.get(t);return f(r)}catch(t){return m(c(new Error(`Key '${e}' does not exist. ${t.message}`),"ERR_KEY_NOT_FOUND"))}}}},function(e,t,r){"use strict";var n=r(301),i=/[\/\?<>\\:\*\|"]/g,s=/[\x00-\x1f\x80-\x9f]/g,o=/^\.+$/,a=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,c=/[\. ]+$/;function u(e,t){if("string"!=typeof e)throw new Error("Input must be string");var r=e.replace(i,t).replace(s,t).replace(o,t).replace(a,t).replace(c,t);return n(r,255)}e.exports=function(e,t){var r=t&&t.replacement||"",n=u(e,r);return""===r?n:u(n,"")}},function(e,t,r){"use strict";var n=r(302),i=r(303);e.exports=n.bind(null,i)},function(e,t,r){"use strict";function n(e){return e>=55296&&e<=56319}function i(e){return e>=56320&&e<=57343}e.exports=function(e,t,r){if("string"!=typeof t)throw new Error("Input must be string");for(var s,o,a=t.length,c=0,u=0;ur)return t.slice(0,u-o.length+1)}return t}},function(e,t,r){"use strict";function n(e){return e>=55296&&e<=56319}function i(e){return e>=56320&&e<=57343}e.exports=function(e){if("string"!=typeof e)throw new Error("Input must be string");for(var t=e.length,r=0,s=null,o=null,a=0;a=128&&s<=2047?r+=2:s>=2048&&s<=65535&&(r+=3),o=s;return r}},function(e,t,r){"use strict";const n=r(305),i=r(306);t.create=async function(e,t){const r=i(e),s=n.createCipheriv(r,e,t),o=n.createDecipheriv(r,e,t);return{encrypt:async e=>s.update(e),decrypt:async e=>o.update(e)}}},function(e,t,r){"use strict";r(29);const n=r(0),i=r(4),s=r(5);e.exports={createCipheriv:(e,t,r)=>{const o=n.cipher.createCipher("AES-CTR",i(t,"ascii"));return o.start({iv:i(r,"ascii")}),{update:e=>(o.update(n.util.createBuffer(i(e,"ascii"))),s(o.output.getBytes(),"ascii"))}},createDecipheriv:(e,t,r)=>{const o=n.cipher.createDecipher("AES-CTR",i(t,"ascii"));return o.start({iv:i(r,"ascii")}),{update:e=>(o.update(n.util.createBuffer(i(e,"ascii"))),s(o.output.getBytes(),"ascii"))}}}},function(e,t,r){"use strict";const n=r(1),i={16:"aes-128-ctr",32:"aes-256-ctr"};e.exports=function(e){const t=i[e.length];if(!t){const t=Object.entries(i).map(([e,t])=>`${e} (${t})`).join(" / ");throw n(new Error(`Invalid key length ${e.length} bytes. Must be ${t}`),"ERR_INVALID_KEY_LENGTH")}return t}},function(e,t,r){"use strict";const n=r(82),i=r(3),s=r(1),o={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};e.exports=function(e,t,r,a,c){const u=o[c];if(!u){const e=Object.keys(o).join(" / ");throw s(new Error(`Hash '${c}' is unknown or not supported. Must be ${e}`),"ERR_UNSUPPORTED_HASH_TYPE")}const f=n(e,t,r,a,u);return i.encode64(f)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.urlAlphabet=void 0;t.urlAlphabet="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW"},function(e,t,r){"use strict";const{nanoid:n}=r(119);e.exports=(e=(e=>e))=>e(n())},function(e,t,r){"use strict";e.exports=r(120).TextEncoder},function(e,t,r){"use strict";const n=r(118),i=r(122),s=r(123);e.exports=class extends i{constructor(){super(),this.data={}}async put(e,t){this.data[e.toString()]=t}async get(e){if(!await this.has(e))throw s.notFoundError();return this.data[e.toString()]}async has(e){return void 0!==this.data[e.toString()]}async delete(e){delete this.data[e.toString()]}*_all(){yield*Object.entries(this.data).map(([e,t])=>({key:new n(e),value:t}))}}},function(e,t,r){"use strict";e.exports=async e=>{for await(const t of e);}},function(e,t,r){"use strict";r(314),r(79);const n=r(0),{certificateForKey:i,findAsync:s}=r(319),o=r(1),a=r(5),c=r(4),u=new WeakMap;e.exports=class{constructor(e,t){if(!e)throw o(new Error("keychain is required"),"ERR_KEYCHAIN_REQUIRED");this.keychain=e,u.set(this,{dek:t})}async encrypt(e,t){if(!(t instanceof Uint8Array))throw o(new Error("Plain data must be a Uint8Array"),"ERR_INVALID_PARAMS");const r=await this.keychain.findKeyByName(e),s=await this.keychain._getPrivateKey(e),c=u.get(this).dek,f=n.pki.decryptRsaPrivateKey(s,c),h=await i(r,f),d=n.pkcs7.createEnvelopedData();d.addRecipient(h),d.content=n.util.createBuffer(t),d.encrypt();const l=n.asn1.toDer(d.toAsn1()).getBytes();return a(l,"ascii")}async decrypt(e){if(!(e instanceof Uint8Array))throw o(new Error("CMS data is required"),"ERR_INVALID_PARAMS");let t;try{const r=n.util.createBuffer(c(e,"ascii")),i=n.asn1.fromDer(r);t=n.pkcs7.messageFromAsn1(i)}catch(p){throw o(new Error("Invalid CMS: "+p.message),"ERR_INVALID_CMS")}const r=t.recipients.filter(e=>e.issuer.find(e=>"O"===e.shortName&&"ipfs"===e.value)).filter(e=>e.issuer.find(e=>"CN"===e.shortName)).map(e=>({recipient:e,keyId:e.issuer.find(e=>"CN"===e.shortName).value})),i=await s(r,async e=>{try{if(await this.keychain.findKeyById(e.keyId))return!0}catch(p){return!1}return!1});if(!i){const e=r.map(e=>e.keyId);throw o(new Error("Decryption needs one of the key(s): "+e.join(", ")),"ERR_MISSING_KEYS",{missingKeys:e})}const f=await this.keychain.findKeyById(i.keyId);if(!f)throw o(new Error("No key available to decrypto"),"ERR_NO_KEY");const h=await this.keychain._getPrivateKey(f.name),d=u.get(this).dek,l=n.pki.decryptRsaPrivateKey(h,d);return t.decrypt(i.recipient,l),a(t.content.getBytes(),"ascii")}}},function(e,t,r){"use strict";var n=r(0);r(29),r(18),r(55),r(28),r(57),r(315),r(21),r(3),r(124);var i=n.asn1,s=e.exports=n.pkcs7=n.pkcs7||{};function o(e){var t={},r=[];if(!i.validate(e,s.asn1.recipientInfoValidator,t,r)){var o=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw o.errors=r,o}return{version:t.version.charCodeAt(0),issuer:n.pki.RDNAttributesAsArray(t.issuer),serialNumber:n.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:i.derToOid(t.encAlgorithm),parameter:t.encParameter.value,content:t.encKey}}}function a(e){for(var t,r=[],s=0;s0){for(var r=i.create(i.Class.CONTEXT_SPECIFIC,1,!0,[]),s=0;s=r&&o0&&o.value[0].value.push(i.create(i.Class.CONTEXT_SPECIFIC,0,!0,t)),s.length>0&&o.value[0].value.push(i.create(i.Class.CONTEXT_SPECIFIC,1,!0,s)),o.value[0].value.push(i.create(i.Class.UNIVERSAL,i.Type.SET,!0,e.signerInfos)),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(e.type).getBytes()),o])},addSigner:function(t){var r=t.issuer,i=t.serialNumber;if(t.certificate){var s=t.certificate;"string"==typeof s&&(s=n.pki.certificateFromPem(s)),r=s.issuer.attributes,i=s.serialNumber}var o=t.key;if(!o)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof o&&(o=n.pki.privateKeyFromPem(o));var a=t.digestAlgorithm||n.pki.oids.sha1;switch(a){case n.pki.oids.sha1:case n.pki.oids.sha256:case n.pki.oids.sha384:case n.pki.oids.sha512:case n.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+a)}var c=t.authenticatedAttributes||[];if(c.length>0){for(var u=!1,f=!1,h=0;h>8*d-h&255;return(w=String.fromCharCode(w.charCodeAt(0)&~E)+w.substr(1))+y+String.fromCharCode(188)},verify:function(e,o,a){var c,u=a-1,f=Math.ceil(u/8);if(o=o.substr(-f),f>8*f-u&255;if(0!=(d.charCodeAt(0)&p))throw new Error("Bits beyond keysize not zero as expected.");var y=i.generate(l,h),g="";for(c=0;c{const r=n.setRsaPublicKey(t.n,t.e),i=n.createCertificate();i.publicKey=r,i.serialNumber="01",i.validity.notBefore=new Date,i.validity.notAfter=new Date,i.validity.notAfter.setFullYear(i.validity.notBefore.getFullYear()+10);const s=[{name:"organizationName",value:"ipfs"},{shortName:"OU",value:"keystore"},{name:"commonName",value:e.id}];return i.setSubject(s),i.setIssuer(s),i.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0,codeSigning:!0,emailProtection:!0,timeStamping:!0},{name:"nsCertType",client:!0,server:!0,email:!0,objsign:!0,sslCA:!0,emailCA:!0,objCA:!0}]),i.sign(t),i},e.exports.findAsync=async function(e,t){const r=e.map(t);return e[(await Promise.all(r)).findIndex(e=>e)]}},function(e,t,r){"use strict";const n=r(45),{pipe:i}=r(23),{tap:s}=r(72),o=r(321),{METRICS:a}=r(65),c=r(323),u=["dataReceived","dataSent"],f={in:"dataReceived",out:"dataSent"};class h{constructor(e){this._options=n(a,e),this._globalStats=new c(u,this._options),this._peerStats=new Map,this._protocolStats=new Map,this._oldPeers=o(this._options.maxOldPeersRetention),this._running=!1,this._onMessage=this._onMessage.bind(this),this._connectionManager=e.connectionManager,this._connectionManager.on("peer:disconnect",e=>{this.onPeerDisconnected(e.remotePeer)})}start(){this._running=!0}stop(){this._running=!1,this._globalStats.stop();for(const e of this._peerStats.values())e.stop();for(const e of this._protocolStats.values())e.stop()}get global(){return this._globalStats}get peers(){return Array.from(this._peerStats.keys())}forPeer(e){const t=e.toB58String();return this._peerStats.get(t)||this._oldPeers.get(t)}get protocols(){return Array.from(this._protocolStats.keys())}forProtocol(e){return this._protocolStats.get(e)}onPeerDisconnected(e){const t=e.toB58String(),r=this._peerStats.get(t);r&&(r.stop(),this._peerStats.delete(t),this._oldPeers.set(t,r))}_onMessage({remotePeer:e,protocol:t,direction:r,dataLength:n}){if(!this._running)return;const i=f[r];let s=this.forPeer(e);if(s||(s=new c(u,this._options),this._peerStats.set(e.toB58String(),s)),s.push(i,n),this._globalStats.push(i,n),t){let e=this.forProtocol(t);e||(e=new c(u,this._options),this._protocolStats.set(t,e)),e.push(i,n)}}updatePlaceholder(e,t){if(!this._running)return;const r=this.forPeer(e),n=t.toB58String(),i=this.forPeer(t);let s=r;i&&(s=h.mergeStats(i,s),this._oldPeers.delete(n)),this._peerStats.delete(e.toB58String()),this._peerStats.set(n,s),s.start()}trackStream({stream:e,remotePeer:t,protocol:r}){const n=this,o=e.source;e.source=s(e=>n._onMessage({remotePeer:t,protocol:r,direction:"in",dataLength:e.length}))(o);const a=e.sink;return e.sink=e=>i(e,s(e=>n._onMessage({remotePeer:t,protocol:r,direction:"out",dataLength:e.length})),a),e}static mergeStats(e,t){return e.stop(),t.stop(),e._queue=[...e._queue,...t._queue],e}}e.exports=h},function(e,t,r){"use strict";const n=r(322);e.exports=e=>{const t=n(e);return t.delete=t.remove,t}},function(e,t,r){"use strict";e.exports=function(e){if(!e)throw Error("hashlru must have a max value, of type number, greater than 0");var t=0,r=Object.create(null),n=Object.create(null);function i(i,s){r[i]=s,++t>=e&&(t=0,n=r,r=Object.create(null))}return{has:function(e){return void 0!==r[e]||void 0!==n[e]},remove:function(e){void 0!==r[e]&&(r[e]=void 0),void 0!==n[e]&&(n[e]=void 0)},get:function(e){var t=r[e];return void 0!==t?t:void 0!==(t=n[e])?(i(e,t),t):void 0},set:function(e,t){void 0!==r[e]?r[e]=t:i(e,t)},clear:function(){r=Object.create(null),n=Object.create(null)}}}},function(e,t,r){"use strict";const{EventEmitter:n}=r(19),i=r(324),s=r(325),o=r(69);e.exports=class extends n{constructor(e,t){super(),this._options=t,this._queue=[],this._stats={},this._frequencyLastTime=Date.now(),this._frequencyAccumulators={},this._movingAverages={},this._update=this._update.bind(this);const r=this._options.movingAverageIntervals;for(var n=0;n{this._updateFrequencyFor(r,t,e)}),this._frequencyLastTime=e}_updateFrequencyFor(e,t,r){const n=this._frequencyAccumulators[e]||0;this._frequencyAccumulators[e]=0;const i=n/(t||1)*1e3;let o=this._movingAverages[e];o||(o=this._movingAverages[e]={});const a=this._options.movingAverageIntervals;for(var c=0;c0||e===t?t:t-1}function y(e){for(var t,r,n=1,i=e.length,s=e[0]+"";nu^r?1:-1;for(a=(c=i.length)<(u=s.length)?c:u,o=0;os[o]^r?1:-1;return c==u?0:c>u^r?1:-1}function b(e,t,r,n){if(er||e!==c(e))throw Error(u+(n||"Argument")+("number"==typeof e?er?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function m(e){var t=e.c.length-1;return p(e.e/14)==t&&e.c[t]%2!=0}function v(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function w(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else tM?y.c=y.e=null:e.e=10;h/=10,u++);return void(u>M?y.c=y.e=null:(y.e=u,y.c=[e]))}p=String(e)}else{if(!o.test(p=String(e)))return i(y,p,d);y.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(u=p.indexOf("."))>-1&&(p=p.replace(".","")),(h=p.search(/e/i))>0?(u<0&&(u=h),u+=+p.slice(h+1),p=p.substring(0,h)):u<0&&(u=p.length)}else{if(b(t,2,U.length,"Base"),10==t)return q(y=new K(e),T+y.e+1,R);if(p=String(e),d="number"==typeof e){if(0*e!=0)return i(y,p,d,t);if(y.s=1/e<0?(p=p.slice(1),-1):1,K.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(f+e)}else y.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(r=U.slice(0,t),u=h=0,l=p.length;hu){u=l;continue}}else if(!a&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){a=!0,h=-1,u=0;continue}return i(y,String(e),d,t)}d=!1,(u=(p=n(p,t,10,y.s)).indexOf("."))>-1?p=p.replace(".",""):u=p.length}for(h=0;48===p.charCodeAt(h);h++);for(l=p.length;48===p.charCodeAt(--l););if(p=p.slice(h,++l)){if(l-=h,d&&K.DEBUG&&l>15&&(e>9007199254740991||e!==c(e)))throw Error(f+y.s*e);if((u=u-h-1)>M)y.c=y.e=null;else if(u=N)?v(c,o):w(c,o,"0");else if(s=(e=q(new K(e),t,r)).e,a=(c=y(e.c)).length,1==n||2==n&&(t<=s||s<=B)){for(;aa){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=s-a)>0)for(s+1==a&&(c+=".");t--;c+="0");return e.s<0&&i?"-"+c:c}function j(e,t){for(var r,n=1,i=new K(e[0]);n=10;i/=10,n++);return(r=n+14*r-1)>M?e.c=e.e=null:r=10;u/=10,i++);if((s=t-i)<0)s+=14,o=t,p=(f=y[l=0])/g[i-o-1]%10|0;else if((l=a((s+1)/14))>=y.length){if(!n)break e;for(;y.length<=l;y.push(0));f=p=0,i=1,o=(s%=14)-14+1}else{for(f=u=y[l],i=1;u>=10;u/=10,i++);p=(o=(s%=14)-14+i)<0?0:f/g[i-o-1]%10|0}if(n=n||t<0||null!=y[l+1]||(o<0?f:f%g[i-o-1]),n=r<4?(p||n)&&(0==r||r==(e.s<0?3:2)):p>5||5==p&&(4==r||n||6==r&&(s>0?o>0?f/g[i-o]:0:y[l-1])%10&1||r==(e.s<0?8:7)),t<1||!y[0])return y.length=0,n?(t-=e.e+1,y[0]=g[(14-t%14)%14],e.e=-t||0):y[0]=e.e=0,e;if(0==s?(y.length=l,u=1,l--):(y.length=l+1,u=g[14-s],y[l]=o>0?c(f/g[i-o]%g[o])*u:0),n)for(;;){if(0==l){for(s=1,o=y[0];o>=10;o/=10,s++);for(o=y[0]+=u,u=1;o>=10;o/=10,u++);s!=u&&(e.e++,y[0]==h&&(y[0]=1));break}if(y[l]+=u,y[l]!=h)break;y[l--]=0,u=1}for(s=y.length;0===y[--s];y.pop());}e.e>M?e.c=e.e=null:e.e=N?v(t,r):w(t,r,"0"),e.s<0?"-"+t:t)}return K.clone=e,K.ROUND_UP=0,K.ROUND_DOWN=1,K.ROUND_CEIL=2,K.ROUND_FLOOR=3,K.ROUND_HALF_UP=4,K.ROUND_HALF_DOWN=5,K.ROUND_HALF_EVEN=6,K.ROUND_HALF_CEIL=7,K.ROUND_HALF_FLOOR=8,K.EUCLID=9,K.config=K.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(u+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(b(r=e[t],0,l,t),T=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(b(r=e[t],0,8,t),R=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(b(r[0],-l,0,t),b(r[1],0,l,t),B=r[0],N=r[1]):(b(r,-l,l,t),B=-(N=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)b(r[0],-l,-1,t),b(r[1],1,l,t),P=r[0],M=r[1];else{if(b(r,-l,l,t),!r)throw Error(u+t+" cannot be zero: "+r);P=-(M=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(u+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw x=!r,Error(u+"crypto unavailable");x=r}else x=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(b(r=e[t],0,9,t),L=r),e.hasOwnProperty(t="POW_PRECISION")&&(b(r=e[t],0,l,t),D=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(u+t+" not an object: "+r);O=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(u+t+" invalid: "+r);U=r}}return{DECIMAL_PLACES:T,ROUNDING_MODE:R,EXPONENTIAL_AT:[B,N],RANGE:[P,M],CRYPTO:x,MODULO_MODE:L,POW_PRECISION:D,FORMAT:O,ALPHABET:U}},K.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!K.DEBUG)return!0;var t,r,n=e.c,i=e.e,s=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===s||-1===s)&&i>=-l&&i<=l&&i===c(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((t=(i+1)%14)<1&&(t+=14),String(n[0]).length==t){for(t=0;t=h||r!==c(r))break e;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===s||1===s||-1===s))return!0;throw Error(u+"Invalid BigNumber: "+e)},K.maximum=K.max=function(){return j(arguments,k.lt)},K.minimum=K.min=function(){return j(arguments,k.gt)},K.random=(s=9007199254740992*Math.random()&2097151?function(){return c(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,i,o,f=0,h=[],p=new K(I);if(null==e?e=T:b(e,0,l),i=a(e/14),x)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));f>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[f]=r[0],t[f+1]=r[1]):(h.push(o%1e14),f+=2);f=i/2}else{if(!crypto.randomBytes)throw x=!1,Error(u+"crypto unavailable");for(t=crypto.randomBytes(i*=7);f=9e15?crypto.randomBytes(7).copy(t,f):(h.push(o%1e14),f+=7);f=i/7}if(!x)for(;f=10;o/=10,f++);f<14&&(n-=14-f)}return p.e=n,p.c=h,p}),K.sum=function(){for(var e=1,t=arguments,r=new K(t[0]);er-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}return function(t,n,i,s,o){var a,c,u,f,h,d,l,p,g=t.indexOf("."),b=T,m=R;for(g>=0&&(f=D,D=0,t=t.replace(".",""),d=(p=new K(n)).pow(t.length-g),D=f,p.c=e(w(y(d.c),d.e,"0"),10,i,"0123456789"),p.e=p.c.length),u=f=(l=e(t,n,i,o?(a=U,"0123456789"):(a="0123456789",U))).length;0==l[--f];l.pop());if(!l[0])return a.charAt(0);if(g<0?--u:(d.c=l,d.e=u,d.s=s,l=(d=r(d,p,b,m,i)).c,h=d.r,u=d.e),g=l[c=u+b+1],f=i/2,h=h||c<0||null!=l[c+1],h=m<4?(null!=g||h)&&(0==m||m==(d.s<0?3:2)):g>f||g==f&&(4==m||h||6==m&&1&l[c-1]||m==(d.s<0?8:7)),c<1||!l[0])t=h?w(a.charAt(1),-b,a.charAt(0)):a.charAt(0);else{if(l.length=c,h)for(--i;++l[--c]>i;)l[c]=0,c||(++u,l=[1].concat(l));for(f=l.length;!l[--f];);for(g=0,t="";g<=f;t+=a.charAt(l[g++]));t=w(t,u,a.charAt(0))}return t}}(),r=function(){function e(e,t,r){var n,i,s,o,a=0,c=e.length,u=t%1e7,f=t/1e7|0;for(e=e.slice();c--;)a=((i=u*(s=e[c]%1e7)+(n=f*s+(o=e[c]/1e7|0)*u)%1e7*1e7+a)/r|0)+(n/1e7|0)+f*o,e[c]=i%r;return a&&(e=[a].concat(e)),e}function t(e,t,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;it[i]?1:-1;break}return s}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;e.splice(0,1));}return function(n,i,s,o,a){var u,f,d,l,y,g,b,m,v,w,E,S,A,_,C,k,I,T=n.s==i.s?1:-1,R=n.c,B=i.c;if(!(R&&R[0]&&B&&B[0]))return new K(n.s&&i.s&&(R?!B||R[0]!=B[0]:B)?R&&0==R[0]||!B?0*T:T/0:NaN);for(v=(m=new K(T)).c=[],T=s+(f=n.e-i.e)+1,a||(a=h,f=p(n.e/14)-p(i.e/14),T=T/14|0),d=0;B[d]==(R[d]||0);d++);if(B[d]>(R[d]||0)&&f--,T<0)v.push(1),l=!0;else{for(_=R.length,k=B.length,d=0,T+=2,(y=c(a/(B[0]+1)))>1&&(B=e(B,y,a),R=e(R,y,a),k=B.length,_=R.length),A=k,E=(w=R.slice(0,k)).length;E=a/2&&C++;do{if(y=0,(u=t(B,w,k,E))<0){if(S=w[0],k!=E&&(S=S*a+(w[1]||0)),(y=c(S/C))>1)for(y>=a&&(y=a-1),b=(g=e(B,y,a)).length,E=w.length;1==t(g,w,b,E);)y--,r(g,k=10;T/=10,d++);q(m,s+(m.e=d+14*f-1)+1,o,l)}else m.e=f,m.r=+l;return m}}(),E=/^(-?)0([xbo])(?=\w[\w.]*$)/i,S=/^([^.]+)\.$/,A=/^\.([^.]+)$/,_=/^-?(Infinity|NaN)$/,C=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(e,t,r,n){var i,s=r?t:t.replace(C,"");if(_.test(s))e.s=isNaN(s)?null:s<0?-1:1;else{if(!r&&(s=s.replace(E,(function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t})),n&&(i=n,s=s.replace(S,"$1").replace(A,"0.$1")),t!=s))return new K(s,i);if(K.DEBUG)throw Error(u+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},k.absoluteValue=k.abs=function(){var e=new K(this);return e.s<0&&(e.s=1),e},k.comparedTo=function(e,t){return g(this,new K(e,t))},k.decimalPlaces=k.dp=function(e,t){var r,n,i,s=this;if(null!=e)return b(e,0,l),null==t?t=R:b(t,0,8),q(new K(s),e+s.e+1,t);if(!(r=s.c))return null;if(n=14*((i=r.length-1)-p(this.e/14)),i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},k.dividedBy=k.div=function(e,t){return r(this,new K(e,t),T,R)},k.dividedToIntegerBy=k.idiv=function(e,t){return r(this,new K(e,t),0,1)},k.exponentiatedBy=k.pow=function(e,t){var r,n,i,s,o,f,h,d,l=this;if((e=new K(e)).c&&!e.isInteger())throw Error(u+"Exponent not an integer: "+z(e));if(null!=t&&(t=new K(t)),o=e.e>14,!l.c||!l.c[0]||1==l.c[0]&&!l.e&&1==l.c.length||!e.c||!e.c[0])return d=new K(Math.pow(+z(l),o?2-m(e):+z(e))),t?d.mod(t):d;if(f=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new K(NaN);(n=!f&&l.isInteger()&&t.isInteger())&&(l=l.mod(t))}else{if(e.e>9&&(l.e>0||l.e<-1||(0==l.e?l.c[0]>1||o&&l.c[1]>=24e7:l.c[0]<8e13||o&&l.c[0]<=9999975e7)))return s=l.s<0&&m(e)?-0:0,l.e>-1&&(s=1/s),new K(f?1/s:s);D&&(s=a(D/14+2))}for(o?(r=new K(.5),f&&(e.s=1),h=m(e)):h=(i=Math.abs(+z(e)))%2,d=new K(I);;){if(h){if(!(d=d.times(l)).c)break;s?d.c.length>s&&(d.c.length=s):n&&(d=d.mod(t))}if(i){if(0===(i=c(i/2)))break;h=i%2}else if(q(e=e.times(r),e.e+1,1),e.e>14)h=m(e);else{if(0===(i=+z(e)))break;h=i%2}l=l.times(l),s?l.c&&l.c.length>s&&(l.c.length=s):n&&(l=l.mod(t))}return n?d:(f&&(d=I.div(d)),t?d.mod(t):s?q(d,D,R,void 0):d)},k.integerValue=function(e){var t=new K(this);return null==e?e=R:b(e,0,8),q(t,t.e+1,e)},k.isEqualTo=k.eq=function(e,t){return 0===g(this,new K(e,t))},k.isFinite=function(){return!!this.c},k.isGreaterThan=k.gt=function(e,t){return g(this,new K(e,t))>0},k.isGreaterThanOrEqualTo=k.gte=function(e,t){return 1===(t=g(this,new K(e,t)))||0===t},k.isInteger=function(){return!!this.c&&p(this.e/14)>this.c.length-2},k.isLessThan=k.lt=function(e,t){return g(this,new K(e,t))<0},k.isLessThanOrEqualTo=k.lte=function(e,t){return-1===(t=g(this,new K(e,t)))||0===t},k.isNaN=function(){return!this.s},k.isNegative=function(){return this.s<0},k.isPositive=function(){return this.s>0},k.isZero=function(){return!!this.c&&0==this.c[0]},k.minus=function(e,t){var r,n,i,s,o=this,a=o.s;if(t=(e=new K(e,t)).s,!a||!t)return new K(NaN);if(a!=t)return e.s=-t,o.plus(e);var c=o.e/14,u=e.e/14,f=o.c,d=e.c;if(!c||!u){if(!f||!d)return f?(e.s=-t,e):new K(d?o:NaN);if(!f[0]||!d[0])return d[0]?(e.s=-t,e):new K(f[0]?o:3==R?-0:0)}if(c=p(c),u=p(u),f=f.slice(),a=c-u){for((s=a<0)?(a=-a,i=f):(u=c,i=d),i.reverse(),t=a;t--;i.push(0));i.reverse()}else for(n=(s=(a=f.length)<(t=d.length))?a:t,a=t=0;t0)for(;t--;f[r++]=0);for(t=h-1;n>a;){if(f[--n]=0;){for(r=0,l=w[i]%1e7,y=w[i]/1e7|0,s=i+(o=c);s>i;)r=((u=l*(u=v[--o]%1e7)+(a=y*u+(f=v[o]/1e7|0)*l)%1e7*1e7+g[s]+r)/b|0)+(a/1e7|0)+y*f,g[s--]=u%b;g[s]=r}return r?++n:g.splice(0,1),F(e,g,n)},k.negated=function(){var e=new K(this);return e.s=-e.s||null,e},k.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new K(e,t)).s,!i||!t)return new K(NaN);if(i!=t)return e.s=-t,n.minus(e);var s=n.e/14,o=e.e/14,a=n.c,c=e.c;if(!s||!o){if(!a||!c)return new K(i/0);if(!a[0]||!c[0])return c[0]?e:new K(a[0]?n:0*i)}if(s=p(s),o=p(o),a=a.slice(),i=s-o){for(i>0?(o=s,r=c):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(t=c.length)<0&&(r=c,c=a,a=r,t=i),i=0;t;)i=(a[--t]=a[t]+c[t]+i)/h|0,a[t]=h===a[t]?0:a[t]%h;return i&&(a=[i].concat(a),++o),F(e,a,o)},k.precision=k.sd=function(e,t){var r,n,i,s=this;if(null!=e&&e!==!!e)return b(e,1,l),null==t?t=R:b(t,0,8),q(new K(s),e,t);if(!(r=s.c))return null;if(n=14*(i=r.length-1)+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&s.e+1>n&&(n=s.e+1),n},k.shiftedBy=function(e){return b(e,-9007199254740991,9007199254740991),this.times("1e"+e)},k.squareRoot=k.sqrt=function(){var e,t,n,i,s,o=this,a=o.c,c=o.s,u=o.e,f=T+4,h=new K("0.5");if(1!==c||!a||!a[0])return new K(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(c=Math.sqrt(+z(o)))||c==1/0?(((t=y(a)).length+u)%2==0&&(t+="0"),c=Math.sqrt(+t),u=p((u+1)/2)-(u<0||u%2),n=new K(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new K(c+""),n.c[0])for((c=(u=n.e)+f)<3&&(c=0);;)if(s=n,n=h.times(s.plus(r(o,s,f,1))),y(s.c).slice(0,c)===(t=y(n.c)).slice(0,c)){if(n.e0&&y>0){for(s=y%a||a,h=p.substr(0,s);s0&&(h+=f+p.slice(s)),l&&(h="-"+h)}n=d?h+(r.decimalSeparator||"")+((c=+r.fractionGroupSize)?d.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):d):h}return(r.prefix||"")+n+(r.suffix||"")},k.toFraction=function(e){var t,n,i,s,o,a,c,f,h,l,p,g,b=this,m=b.c;if(null!=e&&(!(c=new K(e)).isInteger()&&(c.c||1!==c.s)||c.lt(I)))throw Error(u+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+z(c));if(!m)return new K(b);for(t=new K(I),h=n=new K(I),i=f=new K(I),g=y(m),o=t.e=g.length-b.e-1,t.c[0]=d[(a=o%14)<0?14+a:a],e=!e||c.comparedTo(t)>0?o>0?t:h:c,a=M,M=1/0,c=new K(g),f.c[0]=0;l=r(c,t,0,1),1!=(s=n.plus(l.times(i))).comparedTo(e);)n=i,i=s,h=f.plus(l.times(s=h)),f=s,t=c.minus(l.times(s=t)),c=s;return s=r(e.minus(n),i,0,1),f=f.plus(s.times(h)),n=n.plus(s.times(i)),f.s=h.s=b.s,p=r(h,i,o*=2,R).minus(b).abs().comparedTo(r(f,n,o,R).minus(b).abs())<1?[h,i]:[f,n],M=a,p},k.toNumber=function(){return+z(this)},k.toPrecision=function(e,t){return null!=e&&b(e,1,l),V(this,e,t,2)},k.toString=function(e){var t,r=this,i=r.s,s=r.e;return null===s?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=s<=B||s>=N?v(y(r.c),s):w(y(r.c),s,"0"):10===e?t=w(y((r=q(new K(r),T+s+1,R)).c),r.e,"0"):(b(e,2,U.length,"Base"),t=n(w(y(r.c),s,"0"),10,e,i,!0)),i<0&&r.c[0]&&(t="-"+t)),t},k.valueOf=k.toJSON=function(){return z(this)},k._isBigNumber=!0,null!=t&&K.set(t),K}()).default=s.BigNumber=s,void 0===(n=function(){return s}.call(t,r,t,e))||(e.exports=n)}()},function(e,t,r){"use strict";const n=Math.exp;e.exports=function(e){if("number"!=typeof e)throw new Error("must provide a timespan to the moving average constructor");if(e<=0)throw new Error("must provide a timespan > 0 to the moving average constructor");let t,r,i=0,s=0,o=0,a={};return a.push=function(a,c){if(r){const u=1-n(-(a-r)/e),f=c-t;t=u*c+(1-u)*t,i=(1-u)*(i+f*(u*f)),s=Math.sqrt(i),o=t+u*f}else t=c;r=a},a.movingAverage=function(){return t},a.variance=function(){return i},a.deviation=function(){return s},a.forecast=function(){return o},a}},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:upgrader"),{error:n("libp2p:upgrader:err")}),s=r(1),o=r(327),{Connection:a}=r(331),c=r(6),{pipe:u}=r(23),f=r(334),{codes:h}=r(7);e.exports=class{constructor({localPeer:e,metrics:t,cryptos:r=new Map,muxers:n=new Map,onConnectionEnd:i=(()=>{}),onConnection:s=(()=>{})}){this.localPeer=e,this.metrics=t,this.cryptos=r,this.muxers=n,this.protector=null,this.protocols=new Map,this.onConnection=s,this.onConnectionEnd=i}async upgradeInbound(e){let t,r,n,s,o,a,c;if(this.metrics){({setTarget:a,proxy:c}=f());const t=(1e9*Math.random()).toString(36)+Date.now();a({toB58String:()=>t}),e=this.metrics.trackStream({stream:e,remotePeer:c})}i("Starting the inbound connection upgrade");let u=e;this.protector&&(u=await this.protector.protect(e));try{({conn:t,remotePeer:r,protocol:o}=await this._encryptInbound(this.localPeer,u,this.cryptos)),this.muxers.size?({stream:n,Muxer:s}=await this._multiplexInbound(t,this.muxers)):n=t}catch(h){throw i.error("Failed to upgrade inbound connection",h),await e.close(h),h}return this.metrics&&(this.metrics.updatePlaceholder(c,r),a(r)),i("Successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:o,direction:"inbound",maConn:e,upgradedConn:n,Muxer:s,remotePeer:r})}async upgradeOutbound(e){const t=c.createFromB58String(e.remoteAddr.getPeerId());let r,n,s,o,a,u,h;if(this.metrics){({setTarget:u,proxy:h}=f());const t=(1e9*Math.random()).toString(36)+Date.now();u({toB58String:()=>t}),e=this.metrics.trackStream({stream:e,remotePeer:h})}i("Starting the outbound connection upgrade");let d=e;this.protector&&(d=await this.protector.protect(e));try{({conn:r,remotePeer:n,protocol:o}=await this._encryptOutbound(this.localPeer,d,t,this.cryptos)),this.muxers.size?({stream:s,Muxer:a}=await this._multiplexOutbound(r,this.muxers)):s=r}catch(l){throw i.error("Failed to upgrade outbound connection",l),await e.close(l),l}return this.metrics&&(this.metrics.updatePlaceholder(h,n),u(n)),i("Successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:o,direction:"outbound",maConn:e,upgradedConn:s,Muxer:a,remotePeer:n})}_createConnection({cryptoProtocol:e,direction:t,maConn:r,upgradedConn:n,Muxer:c,remotePeer:f}){let d,l,p;c&&(d=new c({onStream:async e=>{const r=new o.Listener(e);try{const{stream:n,protocol:s}=await r.handle(Array.from(this.protocols.keys()));i("%s: incoming stream opened on %s",t,s),this.metrics&&this.metrics.trackStream({stream:n,remotePeer:f,protocol:s}),p.addStream(e,{protocol:s}),this._onStream({connection:p,stream:{...e,...n},protocol:s})}catch(n){i.error(n)}},onStreamEnd:e=>{p.removeStream(e.id)}}),l=async e=>{i("%s: starting new stream on %s",t,e);const r=d.newStream(),n=new o.Dialer(r);try{const{stream:t,protocol:i}=await n.select(e);return this.metrics&&this.metrics.trackStream({stream:t,remotePeer:f,protocol:i}),{stream:{...r,...t},protocol:i}}catch(a){throw i.error("could not create new stream",a),s(a,h.ERR_UNSUPPORTED_PROTOCOL)}},u(n,d,n).catch(i.error));const y=r.timeline;r.timeline=new Proxy(y,{set:(...e)=>(p&&"close"===e[1]&&e[2]&&!y.close&&(async()=>{try{"open"===p.stat.status&&await p.close()}catch(e){i.error(e)}finally{this.onConnectionEnd(p)}})(),Reflect.set(...e))}),r.timeline.upgraded=Date.now();const g=()=>{throw s(new Error("connection is not multiplexed"),"ERR_CONNECTION_NOT_MULTIPLEXED")};return p=new a({localAddr:r.localAddr,remoteAddr:r.remoteAddr,localPeer:this.localPeer,remotePeer:f,stat:{direction:t,timeline:r.timeline,multiplexer:c&&c.multicodec,encryption:e},newStream:l||g,getStreams:()=>d?d.streams:g,close:async e=>{await r.close(e),d&&d.streams.map(t=>t.abort(e))}}),this.onConnection(p),p}_onStream({connection:e,stream:t,protocol:r}){this.protocols.get(r)({connection:e,stream:t,protocol:r})}async _encryptInbound(e,t,r){const n=new o.Listener(t),a=Array.from(r.keys());i("handling inbound crypto protocol selection",a);try{const{stream:t,protocol:s}=await n.handle(a),o=r.get(s);if(i("encrypting inbound connection..."),!o)throw new Error("no crypto module found for "+s);return{...await o.secureInbound(e,t),protocol:s}}catch(c){throw s(c,h.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,t,r,n){const a=new o.Dialer(t),c=Array.from(n.keys());i("selecting outbound crypto protocol",c);try{const{stream:t,protocol:s}=await a.select(c),o=n.get(s);if(i("encrypting outbound connection to %j",r),!o)throw new Error("no crypto module found for "+s);return{...await o.secureOutbound(e,t,r),protocol:s}}catch(u){throw s(u,h.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,t){const r=new o.Dialer(e),n=Array.from(t.keys());i("outbound selecting muxer %s",n);try{const{stream:e,protocol:s}=await r.select(n);i("%s selected as muxer protocol",s);return{stream:e,Muxer:t.get(s)}}catch(a){throw s(a,h.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,t){const r=new o.Listener(e),n=Array.from(t.keys());i("inbound handling muxers %s",n);try{const{stream:e,protocol:i}=await r.handle(n);return{stream:e,Muxer:t.get(i)}}catch(a){throw s(a,h.ERR_MUXER_UNAVAILABLE)}}}},function(e,t,r){"use strict";const n=r(328),i=r(329),s=r(330),{PROTOCOL_ID:o}=r(125);t.PROTOCOL_ID=o;class a{constructor(e){this._stream=e,this._shaken=!1}async _handshake(){if(this._shaken)return;const{stream:e}=await n(this._stream,o);this._stream=e,this._shaken=!0}}t.Dialer=class extends a{select(e){return n(this._stream,e,this._shaken?null:o)}async ls(){await this._handshake();const{stream:e,protocols:t}=await s(this._stream);return this._stream=e,t}};t.Listener=class extends a{handle(e){return i(this._stream,e)}}},function(e,t,r){"use strict";const n=r(2)("mss:select"),i=r(1),s=r(73),o=r(47);e.exports=async(e,t,r)=>{t=Array.isArray(t)?[...t]:[t];const{reader:a,writer:c,rest:u,stream:f}=o(e),h=t.shift();r?(n('select: write ["%s", "%s"]',r,h),s.writeAll(c,[r,h])):(n('select: write "%s"',h),s.write(c,h));let d=(await s.read(a)).toString();if(n('select: read "%s"',d),d===r&&(d=(await s.read(a)).toString(),n('select: read "%s"',d)),d===h)return u(),{stream:f,protocol:h};for(const i of t){n('select: write "%s"',i),s.write(c,i);const e=(await s.read(a)).toString();if(n('select: read "%s" for "%s"',e,i),e===i)return u(),{stream:f,protocol:i}}throw u(),i(new Error("protocol selection failed"),"ERR_UNSUPPORTED_PROTOCOL")}},function(e,t,r){"use strict";const n=r(2)("mss:handle"),i=r(25),s=r(73),o=r(47),{PROTOCOL_ID:a}=r(125);e.exports=async(e,t)=>{t=Array.isArray(t)?t:[t];const{writer:r,reader:c,rest:u,stream:f}=o(e);for(;;){const e=(await s.read(c)).toString();if(n('read "%s"',e),e!==a){if(t.includes(e))return s.write(r,e),n('respond with "%s" for "%s"',e,e),u(),{stream:f,protocol:e};"ls"!==e?(s.write(r,"na"),n('respond with "na" for "%s"',e)):(s.write(r,new i(t.map(e=>s.encode(e)))),n('respond with "%s" for %s',t,e))}else n('respond with "%s" for "%s"',a,e),s.write(r,a)}}},function(e,t,r){"use strict";const n=r(108),i=r(2)("it-multistream-select:ls"),s=r(73),o=r(47),a=r(33),c=r(23);e.exports=async e=>{const{reader:t,writer:r,rest:u,stream:f}=o(e);i('write "ls"'),s.write(r,"ls"),u();const h=await s.read(t),d=n([h]),l=[];return await c(d,a.decode(),async e=>{for await(const t of e)l.push(t.shallowSlice(0,-1).toString())}),{stream:f,protocols:l}}},function(e,t,r){"use strict";t.Connection=r(332)},function(e,t,r){"use strict";const n=r(6),i=r(9),s=r(1),{OPEN:o,CLOSING:a,CLOSED:c}=r(333),u=Symbol.for("@libp2p/interface-connection/connection");class f{constructor({localAddr:e,remoteAddr:t,localPeer:r,remotePeer:a,newStream:c,close:u,getStreams:f,stat:h}){!function(e,t,r,o,a,c,u){if(e&&!i.isMultiaddr(e))throw s(new Error("localAddr must be an instance of multiaddr"),"ERR_INVALID_PARAMETERS");if(!n.isPeerId(t))throw s(new Error("localPeer must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");if(!n.isPeerId(r))throw s(new Error("remotePeer must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");if("function"!=typeof o)throw s(new Error("new stream must be a function"),"ERR_INVALID_PARAMETERS");if("function"!=typeof a)throw s(new Error("close must be a function"),"ERR_INVALID_PARAMETERS");if("function"!=typeof c)throw s(new Error("getStreams must be a function"),"ERR_INVALID_PARAMETERS");if(!u)throw s(new Error("connection metadata object must be provided"),"ERR_INVALID_PARAMETERS");if("inbound"!==u.direction&&"outbound"!==u.direction)throw s(new Error('direction must be "inbound" or "outbound"'),"ERR_INVALID_PARAMETERS");if(!u.timeline)throw s(new Error("connection timeline object must be provided in the stat object"),"ERR_INVALID_PARAMETERS");if(!u.timeline.open)throw s(new Error("connection open timestamp must be provided"),"ERR_INVALID_PARAMETERS");if(!u.timeline.upgraded)throw s(new Error("connection upgraded timestamp must be provided"),"ERR_INVALID_PARAMETERS")}(e,r,a,c,u,f,h),this.id=parseInt(String(1e9*Math.random())).toString(36)+Date.now(),this.localAddr=e,this.remoteAddr=t,this.localPeer=r,this.remotePeer=a,this._stat={...h,status:o},this._newStream=c,this._close=u,this._getStreams=f,this.registry=new Map,this.tags=[]}get[Symbol.toStringTag](){return"Connection"}get[u](){return!0}static isConnection(e){return Boolean(e&&e[u])}get stat(){return this._stat}get streams(){return this._getStreams()}async newStream(e){if(this.stat.status===a)throw s(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(this.stat.status===c)throw s(new Error("the connection is closed"),"ERR_CONNECTION_CLOSED");Array.isArray(e)||(e=[e]);const{stream:t,protocol:r}=await this._newStream(e);return this.addStream(t,{protocol:r}),{stream:t,protocol:r}}addStream(e,{protocol:t,metadata:r={}}){this.registry.set(e.id,{protocol:t,...r})}removeStream(e){this.registry.delete(e)}async close(){if(this.stat.status!==c){if(this._closing)return this._closing;this.stat.status=a,this._closing=await this._close(),this._stat.timeline.close=Date.now(),this.stat.status=c}}}e.exports=f},function(e,t,r){"use strict";e.exports={OPEN:"open",CLOSING:"closing",CLOSED:"closed"}},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);te.addresses?e.addresses.map(e=>e.multiaddr):[]}),this.data=new Map}consumePeerRecord(e){let t;try{t=u.createFromProtobuf(e.payload)}catch(a){return i.error("invalid peer record received"),!1}if(!t.peerId.equals(e.peerId))return i("signing key does not match PeerId in the PeerRecord"),!1;if(!t.multiaddrs||!t.multiaddrs.length)return!1;const r=t.peerId,n=r.toB58String(),s=(this.data.get(n)||{record:void 0}).record;if(s&&s.seqNumber>=t.seqNumber)return!1;const o=this._toAddresses(t.multiaddrs,!0);return this._setData(r,{addresses:o,record:{raw:e.marshal(),seqNumber:t.seqNumber}}),i("stored provided peer record for "+n),!0}getRawEnvelope(e){const t=this.data.get(e.toB58String());if(t&&t.record&&t.record.raw)return t.record.raw}getPeerRecord(e){const t=this.getRawEnvelope(e);if(t)return h.createFromProtobuf(t)}set(e,t){if(!a.isPeerId(e))throw i.error("peerId must be an instance of peer-id to store data"),s(new Error("peerId must be an instance of peer-id"),f);const r=this._toAddresses(t);if(!r.length)return this;const n=e.toB58String(),o=this.data.get(n);if(o&&o.addresses&&o.addresses.length===r.length){if(o.addresses.filter(e=>r.some(t=>e.multiaddr.equals(t.multiaddr))).length===o.addresses.length)return i("the addresses provided to store are equal to the already stored for "+n),this}return this._setData(e,{addresses:r,record:o&&o.record}),i("stored provided multiaddrs for "+n),o||this._ps.emit("peer",e),this}add(e,t){if(!a.isPeerId(e))throw i.error("peerId must be an instance of peer-id to store data"),s(new Error("peerId must be an instance of peer-id"),f);const r=this._toAddresses(t),n=e.toB58String(),o=this.data.get(n);return o&&o.addresses&&(o.addresses.forEach(e=>{r.find(t=>t.multiaddr.equals(e.multiaddr))||r.push(e)}),o.addresses.length===r.length)?(i("the addresses provided to store are already stored for "+n),this):(this._setData(e,{addresses:r,record:o&&o.record}),i("added provided multiaddrs for "+n),o&&o.addresses||this._ps.emit("peer",e),this)}get(e){if(!a.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),f);const t=this.data.get(e.toB58String());return t&&t.addresses?[...t.addresses]:void 0}_toAddresses(e,t=!1){if(!e)throw i.error("multiaddrs must be provided to store data"),s(new Error("multiaddrs must be provided"),f);const r=[];return e.forEach(e=>{if(!o.isMultiaddr(e))throw i.error(`multiaddr ${e} must be an instance of multiaddr`),s(new Error(`multiaddr ${e} must be an instance of multiaddr`),f);r.push({multiaddr:e,isCertified:t})}),r}getMultiaddrsForPeer(e,t=(e=>e)){if(!a.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),f);const r=this.data.get(e.toB58String());if(r&&r.addresses)return t(r.addresses||[]).map(t=>{const r=t.multiaddr,n=r.getPeerId();return n&&n===e.toB58String()?r:r.encapsulate("/p2p/"+e.toB58String())})}}},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:peer-store:key-book"),{error:n("libp2p:peer-store:key-book:err")}),s=r(1),o=r(6),a=r(48),{codes:{ERR_INVALID_PARAMETERS:c}}=r(7);e.exports=class extends a{constructor(e){super({peerStore:e,eventName:"change:pubkey",eventProperty:"pubkey",eventTransformer:e=>e.pubKey}),this.data=new Map}set(e,t){if(!o.isPeerId(e))throw i.error("peerId must be an instance of peer-id to store data"),s(new Error("peerId must be an instance of peer-id"),c);const r=e.toB58String();return!this.data.get(r)&&t&&(e.pubKey=t,this._setData(e,e),i("stored provided public key for "+r)),this}get(e){if(!o.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),c);const t=this.data.get(e.toB58String());return t?t.pubKey:void 0}}},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:peer-store:proto-book"),{error:n("libp2p:peer-store:proto-book:err")}),s=r(1),o=r(13),a=r(6),c=r(48),{codes:{ERR_INVALID_PARAMETERS:u}}=r(7);e.exports=class extends c{constructor(e){super({peerStore:e,eventName:"change:metadata",eventProperty:"metadata"}),this.data=new Map}set(e,t,r){if(!a.isPeerId(e))throw i.error("peerId must be an instance of peer-id to store data"),s(new Error("peerId must be an instance of peer-id"),u);if("string"!=typeof t||!(r instanceof Uint8Array))throw i.error("valid key and value must be provided to store data"),s(new Error("valid key and value must be provided"),u);return this._setValue(e,t,r),this}_setValue(e,t,r,{emit:n=!0}={}){const s=e.toB58String(),a=this.data.get(s)||new Map,c=a.get(t);c&&o(r,c)?i(`the metadata provided to store is equal to the already stored for ${s} on ${t}`):(a.set(t,r),this.data.set(s,a),n&&this._emit(e,t))}get(e){if(!a.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),u);return this.data.get(e.toB58String())}getValue(e,t){if(!a.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),u);const r=this.data.get(e.toB58String());return r&&r.get(t)}delete(e){if(!a.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),u);return!!this.data.delete(e.toB58String())&&(this._emit(e),!0)}deleteValue(e,t){if(!a.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),u);const r=this.data.get(e.toB58String());return!(!r||!r.delete(t))&&(this._emit(e,t),!0)}}},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:peer-store:proto-book"),{error:n("libp2p:peer-store:proto-book:err")}),s=r(1),o=r(6),a=r(48),{codes:{ERR_INVALID_PARAMETERS:c}}=r(7);e.exports=class extends a{constructor(e){super({peerStore:e,eventName:"change:protocols",eventProperty:"protocols",eventTransformer:e=>Array.from(e)}),this.data=new Map}set(e,t){if(!o.isPeerId(e))throw i.error("peerId must be an instance of peer-id to store data"),s(new Error("peerId must be an instance of peer-id"),c);if(!t)throw i.error("protocols must be provided to store data"),s(new Error("protocols must be provided"),c);const r=e.toB58String(),n=this.data.get(r),a=new Set(t);return n&&(f=a,(u=n).size===f.size&&[...u].every(e=>f.has(e)))?(i("the protocols provided to store are equal to the already stored for "+r),this):(this._setData(e,a),i("stored provided protocols for "+r),this);var u,f}add(e,t){if(!o.isPeerId(e))throw i.error("peerId must be an instance of peer-id to store data"),s(new Error("peerId must be an instance of peer-id"),c);if(!t)throw i.error("protocols must be provided to store data"),s(new Error("protocols must be provided"),c);const r=e.toB58String(),n=this.data.get(r)||new Set,a=new Set([...n,...t]);return n.size===a.size?(i("the protocols provided to store are already stored for "+r),this):(this._setData(e,a),i("added provided protocols for "+r),this)}remove(e,t){if(!o.isPeerId(e))throw i.error("peerId must be an instance of peer-id to store data"),s(new Error("peerId must be an instance of peer-id"),c);if(!t)throw i.error("protocols must be provided to store data"),s(new Error("protocols must be provided"),c);const r=e.toB58String(),n=this.data.get(r);if(n){const s=new Set([...n].filter(e=>!t.includes(e)));if(n.size===s.size)return this;this._setData(e,s),i("removed provided protocols for "+r)}return this}}},function(e,t,r){"use strict";e.exports=function(e,t,r){const n=new e(t,r);return n._subscribeAdapter=n.subscribe,n._unsubscribeAdapter=n.unsubscribe,n.subscribe=function(e,t){t&&n.on(e,t),n._subscribeAdapter(e)},n.unsubscribe=function(e,t){t?n.removeListener(e,t):n.removeAllListeners(e),0===n.listenerCount(e)&&n._unsubscribeAdapter(e)},n}},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:persistent-peer-store"),{error:n("libp2p:persistent-peer-store:err")}),{Key:s}=r(117),o=r(9),a=r(6),c=r(126),{NAMESPACE_ADDRESS:u,NAMESPACE_COMMON:f,NAMESPACE_KEYS:h,NAMESPACE_METADATA:d,NAMESPACE_PROTOCOL:l}=r(341),p=r(342),y=r(343);e.exports=class extends c{constructor({peerId:e,datastore:t,threshold:r=5}){super({peerId:e}),this._datastore=t,this._dirtyPeers=new Set,this._dirtyMetadata=new Map,this.threshold=r,this._addDirtyPeer=this._addDirtyPeer.bind(this)}async start(){i("PeerStore is starting"),this.on("change:protocols",this._addDirtyPeer),this.on("change:multiaddrs",this._addDirtyPeer),this.on("change:pubkey",this._addDirtyPeerKey),this.on("change:metadata",this._addDirtyPeerMetadata);for await(const e of this._datastore.query({prefix:f}))await this._processDatastoreEntry(e);i("PeerStore started")}async stop(){i("PeerStore is stopping"),this.removeAllListeners(),await this._commitData(),i("PeerStore stopped")}_addDirtyPeer({peerId:e}){const t=e.toB58String();i("add dirty peer",t),this._dirtyPeers.add(t),this._dirtyPeers.size>=this.threshold&&this._commitData().catch(e=>{i.error("error committing data",e)})}_addDirtyPeerKey({peerId:e}){if(e.hasInlinePublicKey())return;const t=e.toB58String();i("add dirty peer key",t),this._dirtyPeers.add(t),this._dirtyPeers.size>=this.threshold&&this._commitData().catch(e=>{i.error("error committing data",e)})}_addDirtyPeerMetadata({peerId:e,metadata:t}){const r=e.toB58String();i("add dirty metadata peer",r),this._dirtyPeers.add(r);const n=this._dirtyMetadata.get(r)||new Set;n.add(t),this._dirtyMetadata.set(r,n),this._dirtyPeers.size>=this.threshold&&this._commitData().catch(e=>{i.error("error committing data",e)})}async _commitData(){const e=Array.from(this._dirtyPeers);if(!e.length)return;this._dirtyPeers.clear(),i("create batch commit");const t=this._datastore.batch();for(const r of e){const e=this.keyBook.data.get(r)||a.createFromCID(r);this._batchAddressBook(e,t),!e.hasInlinePublicKey()&&this._batchKeyBook(e,t),this._batchMetadataBook(e,t),this._batchProtoBook(e,t)}await t.commit(),i("batch committed")}_batchAddressBook(e,t){const r=e.toString(),n=new s(`${u}${r}`),o=this.addressBook.data.get(e.toB58String());try{if(!o)return void t.delete(n);const e=p.encode({addrs:o.addresses.map(e=>({multiaddr:e.multiaddr.bytes,isCertified:e.isCertified})),certified_record:o.record?{seq:o.record.seqNumber,raw:o.record.raw}:void 0});t.put(n,e)}catch(a){i.error(a)}}_batchKeyBook(e,t){const r=e.toString(),n=new s(`${h}${r}`);try{if(!e.pubKey)return void t.delete(n);const r=e.marshalPubKey();t.put(n,r)}catch(o){i.error(o)}}_batchMetadataBook(e,t){const r=e.toString(),n=this._dirtyMetadata.get(e.toB58String())||[];try{n.forEach(n=>{const i=new s(`${d}${r}/${n}`),o=this.metadataBook.getValue(e,n);o?t.put(i,o):t.delete(i)})}catch(o){i.error(o)}}_batchProtoBook(e,t){const r=e.toString(),n=new s(`${l}${r}`),o=this.protoBook.get(e);try{if(!o)return void t.delete(n);const e=y.encode({protocols:o});t.put(n,e)}catch(a){i.error(a)}}async _processDatastoreEntry({key:e,value:t}){try{const r=e.toString().split("/"),n=a.createFromCID(r[3]);let s;switch(r[2]){case"addrs":s=p.decode(t),this.addressBook._setData(n,{addresses:s.addrs.map(e=>({multiaddr:o(e.multiaddr),isCertified:Boolean(e.isCertified)})),record:s.certified_record?{raw:s.certified_record.raw,seqNumber:s.certified_record.seq}:void 0},{emit:!1});break;case"keys":s=await a.createFromPubKey(t),this.keyBook._setData(s,s,{emit:!1});break;case"metadata":this.metadataBook._setValue(n,r[4],t,{emit:!1});break;case"protos":s=y.decode(t),this.protoBook._setData(n,new Set(s.protocols),{emit:!1});break;default:i("invalid data persisted for: ",e.toString())}}catch(r){i.error(r)}}}},function(e,t,r){"use strict";e.exports.NAMESPACE_COMMON="/peers/",e.exports.NAMESPACE_ADDRESS="/peers/addrs/",e.exports.NAMESPACE_KEYS="/peers/keys/",e.exports.NAMESPACE_METADATA="/peers/metadata/",e.exports.NAMESPACE_PROTOCOL="/peers/protos/"},function(e,t,r){"use strict";const n=r(15);e.exports=n("\nmessage Addresses {\n // Address represents a single multiaddr.\n message Address {\n required bytes multiaddr = 1;\n\n // Flag to indicate if the address comes from a certified source.\n optional bool isCertified = 2;\n }\n\n // CertifiedRecord contains a serialized signed PeerRecord used to\n // populate the signedAddrs list.\n message CertifiedRecord {\n // The Seq counter from the signed PeerRecord envelope\n uint64 seq = 1;\n\n // The serialized bytes of the SignedEnvelope containing the PeerRecord.\n bytes raw = 2;\n }\n\n // The known multiaddrs.\n repeated Address addrs = 1;\n\n // The most recently received signed PeerRecord.\n CertifiedRecord certified_record = 2;\n}\n").Addresses},function(e,t,r){"use strict";const n=r(15);e.exports=n("\nmessage Protocols {\n repeated string protocols = 1;\n}\n").Protocols},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:peer-store"),{error:n("libp2p:peer-store:err")}),s=r(1),{codes:{ERR_INVALID_PARAMETERS:o}}=r(7),a=r(345);e.exports=class{constructor({peerStore:e,connectionManager:t}){this.peerStore=e,this.connectionManager=t,this.topologies=new Map,this._handle=void 0,this._onDisconnect=this._onDisconnect.bind(this),this.connectionManager.on("peer:disconnect",this._onDisconnect)}get handle(){return this._handle}set handle(e){this._handle=e}getConnection(e){return this.connectionManager.get(e)}register(e){if(!a.isTopology(e))throw i.error("topology must be an instance of interfaces/topology"),s(new Error("topology must be an instance of interfaces/topology"),o);const t=(1e9*Math.random()).toString(36)+Date.now();return this.topologies.set(t,e),e.registrar=this,t}unregister(e){return this.topologies.delete(e)}_onDisconnect(e,t){for(const[,r]of this.topologies)r.disconnect(e.remotePeer,t)}}},function(e,t,r){"use strict";const n=()=>{},i=Symbol.for("@libp2p/js-interfaces/topology");class s{constructor({min:e=0,max:t=1/0,handlers:r={}}){this.min=e,this.max=t,this._onConnect=r.onConnect||n,this._onDisconnect=r.onDisconnect||n,this.peers=new Set}get[Symbol.toStringTag](){return"Topology"}get[i](){return!0}static isTopology(e){return Boolean(e&&e[i])}set registrar(e){this._registrar=e}disconnect(e){this._onDisconnect(e)}}e.exports=s},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:ping"),{error:n("libp2p:ping:err")}),s=r(1),o=r(116),{pipe:a}=r(23),{toBuffer:c}=r(74),{collect:u,take:f}=r(72),h=r(13),{PROTOCOL:d,PING_LENGTH:l}=r(347);(t=e.exports=async function(e,t){i("dialing %s to %s",d,t.toB58String?t.toB58String():t);const{stream:r}=await e.dialProtocol(t,d),n=Date.now(),p=o.randomBytes(l),[y]=await a([p],r,e=>f(1,e),c,u),g=Date.now();if(!h(p,y))throw s(new Error("Received wrong ping ack"),"ERR_WRONG_PING_ACK");return g-n}).mount=function(e){e.handle(d,({stream:e})=>a(e,e))},t.unmount=function(e){e.unhandle(d)}},function(e,t,r){"use strict";e.exports={PROTOCOL:"/ipfs/ping/1.0.0",PING_LENGTH:32}},function(e,t,r){"use strict";const n=r(2),i=Object.assign(n("libp2p:identify"),{error:n("libp2p:identify:err")}),s=r(1),o=r(349),a=r(33),{pipe:c}=r(23),{collect:u,take:f,consume:h}=r(72),d=r(5),l=r(6),p=r(9),{toBuffer:y}=r(74),g=r(351),b=r(67),m=r(68),{MULTICODEC_IDENTIFY:v,MULTICODEC_IDENTIFY_PUSH:w,AGENT_VERSION:E,PROTOCOL_VERSION:S}=r(101),{codes:A}=r(7);class _{constructor({libp2p:e}){this._libp2p=e,this.peerStore=e.peerStore,this.connectionManager=e.connectionManager,this.peerId=e.peerId,this.handleMessage=this.handleMessage.bind(this),this._host={agentVersion:E,protocolVersion:S,...e._options.host},this.peerStore.metadataBook.set(this.peerId,"AgentVersion",d(this._host.agentVersion)),this.peerStore.metadataBook.set(this.peerId,"ProtocolVersion",d(this._host.protocolVersion)),this.connectionManager.on("peer:connect",e=>{this.identify(e).catch(i.error)}),this.peerStore.on("change:multiaddrs",({peerId:e})=>{e.toString()===this.peerId.toString()&&this.pushToPeerStore()}),this.peerStore.on("change:protocols",({peerId:e})=>{e.toString()===this.peerId.toString()&&this.pushToPeerStore()})}async push(e){const t=await this.peerStore.addressBook.getRawEnvelope(this.peerId),r=this._libp2p.multiaddrs.map(e=>e.bytes),n=this.peerStore.protoBook.get(this.peerId)||[],s=e.map(async e=>{try{const{stream:i}=await e.newStream(w);await c([{listenAddrs:r,signedPeerRecord:t,protocols:n}],o.encode(g),i,h)}catch(s){i.error("could not push identify update to peer",s)}});return Promise.all(s)}pushToPeerStore(){if(!this._libp2p.isStarted())return;const e=[];let t;for(const r of this.peerStore.peers.values())r.protocols.includes(w)&&(t=this.connectionManager.get(r.id))&&e.push(t);this.push(e)}async identify(e){const{stream:t}=await e.newStream(v),[r]=await c([],t,a.decode(),f(1),y,u);if(!r)throw s(new Error("No data could be retrieved"),A.ERR_CONNECTION_ENDED);let n;try{n=g.decode(r)}catch(k){throw s(k,A.ERR_INVALID_MESSAGE)}let{publicKey:o,listenAddrs:h,protocols:w,observedAddr:E,signedPeerRecord:S}=n;const C=await l.createFromPubKey(o);if(e.remotePeer.toB58String()!==C.toB58String())throw s(new Error("identified peer does not match the expected peer"),A.ERR_INVALID_PEER);E=_.getCleanMultiaddr(E);try{const e=await b.openAndCertify(S,m.DOMAIN);if(this.peerStore.addressBook.consumePeerRecord(e))return void this.peerStore.protoBook.set(C,w)}catch(k){i("received invalid envelope, discard it and fallback to listenAddrs is available",k)}try{this.peerStore.addressBook.set(C,h.map(e=>p(e)))}catch(k){i.error("received invalid addrs",k)}this.peerStore.protoBook.set(C,w),this.peerStore.metadataBook.set(C,"AgentVersion",d(n.agentVersion)),i("received observed address of %s",E)}handleMessage({connection:e,stream:t,protocol:r}){switch(r){case v:return this._handleIdentify({connection:e,stream:t});case w:return this._handlePush({connection:e,stream:t});default:i.error("cannot handle unknown protocol %s",r)}}async _handleIdentify({connection:e,stream:t}){let r=new Uint8Array(0);this.peerId.pubKey&&(r=this.peerId.pubKey.bytes);const n=await this.peerStore.addressBook.getRawEnvelope(this.peerId),s=this.peerStore.protoBook.get(this.peerId)||[],o=g.encode({protocolVersion:this._host.protocolVersion,agentVersion:this._host.agentVersion,publicKey:r,listenAddrs:this._libp2p.multiaddrs.map(e=>e.bytes),signedPeerRecord:n,observedAddr:e.remoteAddr.bytes,protocols:s});try{await c([o],a.encode(),t,h)}catch(u){i.error("could not respond to identify request",u)}}async _handlePush({connection:e,stream:t}){let r;try{const[e]=await c([],t,a.decode(),f(1),y,u);r=g.decode(e)}catch(s){return i.error("received invalid message",s)}const n=e.remotePeer;try{const e=await b.openAndCertify(r.signedPeerRecord,m.DOMAIN);if(this.peerStore.addressBook.consumePeerRecord(e))return void this.peerStore.protoBook.set(n,r.protocols)}catch(s){i("received invalid envelope, discard it and fallback to listenAddrs is available",s)}try{this.peerStore.addressBook.set(n,r.listenAddrs.map(e=>p(e)))}catch(s){i.error("received invalid addrs",s)}this.peerStore.protoBook.set(n,r.protocols)}static getCleanMultiaddr(e){if(e&&e.length>0)try{return p(e)}catch(t){return null}return null}}const C={IDENTIFY:v,IDENTIFY_PUSH:w};_.multicodecs=C,_.Messsage=g,e.exports=_},function(e,t,r){"use strict";const n=r(33),i=r(350),s=r(74);e.exports.encode=e=>t=>n.encode()(i.encode(e)(t)),e.exports.decode=e=>t=>i.decode(e)(s(n.decode()(t))),e.exports.it=i},function(e,t,r){"use strict";e.exports.encode=e=>t=>async function*(){for await(const r of t)yield e.encode(r)}(),e.exports.decode=e=>t=>async function*(){for await(const r of t)yield e.decode(r)}()},function(e,t,r){"use strict";const n=r(15);e.exports=n("\nmessage Identify {\n // protocolVersion determines compatibility between peers\n optional string protocolVersion = 5; // e.g. ipfs/1.0.0\n\n // agentVersion is like a UserAgent string in browsers, or client version in bittorrent\n // includes the client name and client.\n optional string agentVersion = 6; // e.g. go-ipfs/0.1.0\n\n // publicKey is this node's public key (which also gives its node.ID)\n // - may not need to be sent, as secure channel implies it has been sent.\n // - then again, if we change / disable secure channel, may still want it.\n optional bytes publicKey = 1;\n\n // listenAddrs are the multiaddrs the sender node listens for open connections on\n repeated bytes listenAddrs = 2;\n\n // oservedAddr is the multiaddr of the remote endpoint that the sender node perceives\n // this is useful information to convey to the other side, as it helps the remote endpoint\n // determine whether its connection to the local peer goes through NAT.\n optional bytes observedAddr = 4;\n\n repeated string protocols = 3;\n\n // signedPeerRecord contains a serialized SignedEnvelope containing a PeerRecord,\n // signed by the sending node. It contains the same addresses as the listenAddrs field, but\n // in a form that lets us share authenticated addrs with other peers.\n optional bytes signedPeerRecord = 8;\n}\n").Identify}])}));