├── .gitignore ├── README.md ├── bitcoinlogo.png ├── browser.html ├── btc.png ├── format.js ├── handshakelogo.png ├── hns.png ├── hsd.js ├── index.html ├── logger.js ├── package-lock.json ├── package.json ├── proxysocket.js ├── server-local.js ├── server.js ├── sha3.js ├── worker.js └── wsproxy.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Run a Handshake SPV node in a web browser 2 | 3 | This is an experimental fork of https://github.com/pinheadmz/mobilebcoin 4 | 5 | See that repo's README for more details. 6 | 7 | hsd is compiled with this command: 8 | 9 | ``` 10 | cd 11 | bpkg --browser --umd --plugin [ uglify-es --toplevel ] --name HSD --output /hsd.js lib/hsd.js 12 | ``` 13 | 14 | ### Installation & usage 15 | 16 | ``` 17 | git clone 18 | cd mobilehsd 19 | npm install 20 | node server.js 21 | ``` 22 | 23 | A local websocket proxy server is now running on your local machine, which will serve the web interface as well as connect the browser to the open Internet via TCP. 24 | 25 | Then you can open a web browser to `http://localhost:8080` 26 | 27 | ### DISCLAIMER 28 | 29 | This is experimental. Browsers are bad places for crypto. 30 | 31 | Also - this SPV node connects initially to the [HNScan](https://hnscan.com/status) node, which serves BIP37 light clients. 32 | This peer is hard-coded because, again, this is just a proof-of-concept for testing. 33 | -------------------------------------------------------------------------------- /bitcoinlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pinheadmz/mobilehsd/bbd6808df5750297c5f6c4710da858991d9a2965/bitcoinlogo.png -------------------------------------------------------------------------------- /browser.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | hsd SPV Node 9 | 10 | 11 |

hsd SPV Node

12 | 29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | Name:

37 |
38 | 39 |
40 |
41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 230 | 231 | 232 | -------------------------------------------------------------------------------- /btc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pinheadmz/mobilehsd/bbd6808df5750297c5f6c4710da858991d9a2965/btc.png -------------------------------------------------------------------------------- /format.js: -------------------------------------------------------------------------------- 1 | !function(t){var e=void 0,r=t.console,n=[["bcoin","/browser/src/format.js",function(t,r,n,o,i,u){"use strict";const f={showHidden:!1,depth:20,colors:!1,customInspect:!0,showProxy:!1,maxArrayLength:1e4,breakLength:60,compact:!0};function s(t){try{return JSON.stringify(t)}catch(t){return"[error]"}}function a(t,r){if(null==t)return"null";if(!e.isBuffer(t))return"[error]";const n=t.toString("hex");return r?function(t){let e="";for(let r=t.length-2;r>=0;r-=2)e+=t[r]+t[r+1];return e}(n):n}function c(t){if(void 0===t)return"undefined";if(t!=t)return"NaN";try{return JSON.stringify(t,null,2)}catch(t){return"{}"}}n.exports=function(t,e){if(0===t.length)return"";const r=t[0];if(f.colors=e,"string"!=typeof r)return c(r);if(1===t.length)return r;let n,o="",i=1,u=0;for(let e=0;ec)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=p.prototype,e}function p(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return g(t)}return h(t,e,r)}function h(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!p.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|w(t,e),n=l(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return d(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=c)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+c.toString(16)+" bytes");return 0|t}function w(t,e){if(p.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return J(t).length;default:if(o)return n?-1:q(t).length;e=(""+e).toLowerCase(),o=!0}}function v(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function m(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),G(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=p.from(e,n)),p.isBuffer(e))return 0===e.length?-1:E(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):E(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function E(t,e,r,n,o){var i,u=1,f=t.length,s=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;u=2,f/=2,s/=2,r/=2}function a(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(o){var c=-1;for(i=r;if&&(r=f-s),i=r;i>=0;i--){for(var l=!0,p=0;po&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var u=0;u>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function _(t,e,r){return 0===e&&r===t.length?f.fromByteArray(t):f.fromByteArray(t.slice(e,r))}function U(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:a>223?3:a>191?2:1;if(o+l<=r)switch(l){case 1:a<128&&(c=a);break;case 2:128==(192&(i=t[o+1]))&&(s=(31&a)<<6|63&i)>127&&(c=s);break;case 3:i=t[o+1],u=t[o+2],128==(192&i)&&128==(192&u)&&(s=(15&a)<<12|(63&i)<<6|63&u)>2047&&(s<55296||s>57343)&&(c=s);break;case 4:i=t[o+1],u=t[o+2],f=t[o+3],128==(192&i)&&128==(192&u)&&128==(192&f)&&(s=(15&a)<<18|(63&i)<<12|(63&u)<<6|63&f)>65535&&s<1114112&&(c=s)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,e,r);case"utf8":case"utf-8":return U(this,e,r);case"ascii":return k(this,e,r);case"latin1":case"binary":return D(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},p.prototype.toLocaleString=p.prototype.toString,p.prototype.equals=function(t){if(!p.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===p.compare(this,t)},p.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),""},p.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=p.from(t,t.offset,t.byteLength)),!p.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,u=r-e,f=Math.min(i,u),s=this.slice(n,o),a=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return O(this,t,e,r);case"utf8":case"utf-8":return x(this,t,e,r);case"ascii":return A(this,t,e,r);case"latin1":case"binary":return j(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function k(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function z(t,e,r,n,o,i){if(!p.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function N(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function R(t,e,r,n,o){return e=+e,r>>>=0,o||N(t,0,r,4),s.write(t,e,r,n,23,4),r+4}function P(t,e,r,n,o){return e=+e,r>>>=0,o||N(t,0,r,8),s.write(t,e,r,n,52,8),r+8}p.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||M(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||M(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},p.prototype.readUInt8=function(t,e){return t>>>=0,e||M(t,1,this.length),this[t]},p.prototype.readUInt16LE=function(t,e){return t>>>=0,e||M(t,2,this.length),this[t]|this[t+1]<<8},p.prototype.readUInt16BE=function(t,e){return t>>>=0,e||M(t,2,this.length),this[t]<<8|this[t+1]},p.prototype.readUInt32LE=function(t,e){return t>>>=0,e||M(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},p.prototype.readUInt32BE=function(t,e){return t>>>=0,e||M(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},p.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||M(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},p.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||M(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},p.prototype.readInt8=function(t,e){return t>>>=0,e||M(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},p.prototype.readInt16LE=function(t,e){t>>>=0,e||M(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},p.prototype.readInt16BE=function(t,e){t>>>=0,e||M(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},p.prototype.readInt32LE=function(t,e){return t>>>=0,e||M(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},p.prototype.readInt32BE=function(t,e){return t>>>=0,e||M(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},p.prototype.readFloatLE=function(t,e){return t>>>=0,e||M(t,4,this.length),s.read(this,t,!0,23,4)},p.prototype.readFloatBE=function(t,e){return t>>>=0,e||M(t,4,this.length),s.read(this,t,!1,23,4)},p.prototype.readDoubleLE=function(t,e){return t>>>=0,e||M(t,8,this.length),s.read(this,t,!0,52,8)},p.prototype.readDoubleBE=function(t,e){return t>>>=0,e||M(t,8,this.length),s.read(this,t,!1,52,8)},p.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||z(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||z(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},p.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,1,255,0),this[e]=255&t,e+1},p.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},p.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},p.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},p.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},p.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);z(this,t,e,r,o-1,-o)}var i=0,u=1,f=0;for(this[e]=255&t;++i>0)-f&255;return e+r},p.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);z(this,t,e,r,o-1,-o)}var i=r-1,u=1,f=0;for(this[e+i]=255&t;--i>=0&&(u*=256);)t<0&&0===f&&0!==this[e+i+1]&&(f=1),this[e+i]=(t/u>>0)-f&255;return e+r},p.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},p.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},p.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},p.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},p.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||z(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},p.prototype.writeFloatLE=function(t,e,r){return R(this,t,e,!0,r)},p.prototype.writeFloatBE=function(t,e,r){return R(this,t,e,!1,r)},p.prototype.writeDoubleLE=function(t,e,r){return P(this,t,e,!0,r)},p.prototype.writeDoubleBE=function(t,e,r){return P(this,t,e,!1,r)},p.prototype.copy=function(t,e,r,n){if(!p.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},p.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!p.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(u+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function J(t){return f.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function $(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function G(t){return t!=t}}],["base64-js","/index.js",function(t,e,r,n,o,i){"use strict";t.byteLength=function(t){var e=p(t),r=e[0],n=e[1];return 3*(r+n)/4-n},t.toByteArray=function(t){for(var e,r=p(t),n=r[0],o=r[1],i=new s(function(t,e,r){return 3*(e+r)/4-r}(0,n,o)),u=0,a=o>0?n-4:n,c=0;c>16&255,i[u++]=e>>8&255,i[u++]=255&e;2===o&&(e=f[t.charCodeAt(c)]<<2|f[t.charCodeAt(c+1)]>>4,i[u++]=255&e);1===o&&(e=f[t.charCodeAt(c)]<<10|f[t.charCodeAt(c+1)]<<4|f[t.charCodeAt(c+2)]>>2,i[u++]=e>>8&255,i[u++]=255&e);return i},t.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],i=0,f=r-n;if?f:i+16383));1===n?(e=t[r-1],o.push(u[e>>2]+u[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(u[e>>10]+u[e>>4&63]+u[e<<2&63]+"="));return o.join("")};for(var u=[],f=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=a.length;c0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var n,o,i=[],f=e;f>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63}],["ieee754","/index.js",function(t,e,r,n,o,i){t.read=function(t,e,r,n,o){var i,u,f=8*o-n-1,s=(1<>1,c=-7,l=r?o-1:0,p=r?-1:1,h=t[e+l];for(l+=p,i=h&(1<<-c)-1,h>>=-c,c+=f;c>0;i=256*i+t[e+l],l+=p,c-=8);for(u=i&(1<<-c)-1,i>>=-c,c+=n;c>0;u=256*u+t[e+l],l+=p,c-=8);if(0===i)i=1-a;else{if(i===s)return u?NaN:1/0*(h?-1:1);u+=Math.pow(2,n),i-=a}return(h?-1:1)*u*Math.pow(2,i-n)},t.write=function(t,e,r,n,o,i){var u,f,s,a=8*i-o-1,c=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:i-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(f=isNaN(e)?1:0,u=c):(u=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-u))<1&&(u--,s*=2),(e+=u+l>=1?p/s:p*Math.pow(2,1-l))*s>=2&&(u++,s/=2),u+l>=c?(f=0,u=c):u+l>=1?(f=(e*s-1)*Math.pow(2,o),u+=l):(f=e*Math.pow(2,l-1)*Math.pow(2,o),u=0));o>=8;t[r+h]=255&f,h+=y,f/=256,o-=8);for(u=u<0;t[r+h]=255&u,h+=y,u/=256,a-=8);t[r+h-y]|=128*g}}]],s=[];function a(r){if(r>>>0!==r||r>f.length)return function(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}(r);for(;s.length<=r;)s.push(null);var u=s[r];if(u)return u.exports;var a=f[r],c=a[0],l=a[1],p=a[2],h=o,y=i,g=e,d=t,b=n;0!==r&&(b={id:"/"+c+l,exports:d={},parent:n,filename:h,loaded:!1,children:n.children,paths:n.paths,require:n.require}),s[r]=b;try{p.call(d,d,g,b,h,y,void 0)}catch(t){throw delete s[r],t}return 0!==r&&(b.loaded=!0),b.exports}a(0)}],["bpkg","/lib/builtins/console.js",function(e,r,n,o,i,u){var s=[["console-browserify","/index.js",function(e,r,n,o,i,u){var s,a=f(3,n),l=f(4,n),p=c(1),h=Array.prototype.slice,y={};s=void 0!==t&&t.console?t.console:"undefined"!=typeof window&&window.console?window.console:{};for(var g=[[function(){},"log"],[function(){s.log.apply(s,arguments)},"info"],[function(){s.log.apply(s,arguments)},"warn"],[function(){s.warn.apply(s,arguments)},"error"],[function(t){y[t]=p()},"time"],[function(t){var e=y[t];if(!e)throw new Error("No such label: "+t);var r=p()-e;s.log(t+": "+r+"ms")},"timeEnd"],[function(){var t=new Error;t.name="Trace",t.message=a.format.apply(null,arguments),s.error(t.stack)},"trace"],[function(t){s.log(a.inspect(t)+"\n")},"dir"],[function(t){if(!t){var e=h.call(arguments,1);l.ok(!1,a.format.apply(null,e))}},"assert"]],d=0;d>>0!==t||t>s.length)return function(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}(t);for(;a.length<=t;)a.push(null);var u=a[t];if(u)return u.exports;var f=s[t],c=f[0],l=f[1],p=f[2],h=o,y=i,g=r,d=e,b=n;0!==t&&(b={id:"/"+c+l,exports:d={},parent:n,filename:h,loaded:!1,children:n.children,paths:n.paths,require:n.require}),a[t]=b;try{p.call(d,d,g,b,h,y,void 0)}catch(e){throw delete a[t],e}return 0!==t&&(b.loaded=!0),b.exports}c(0)}],["bpkg","/lib/builtins/util.js",function(t,e,n,o,i,u){var f=[["util","/util.js",function(t,e,n,o,i,u){var f=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},n=0;n=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),v(r)?n.showHidden=r:r&&t._extend(n,r),x(n.showHidden)&&(n.showHidden=!1),x(n.depth)&&(n.depth=2),x(n.colors)&&(n.colors=!1),x(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=h),g(n,e,n.depth)}function h(t,e){var r=p.styles[e];return r?"["+p.colors[r][0]+"m"+t+"["+p.colors[r][1]+"m":t}function y(t,e){return t}function g(e,r,n){if(e.customInspect&&r&&_(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var o=r.inspect(n,e);return O(o)||(o=g(e,o,n)),o}var i=function(t,e){if(x(e))return t.stylize("undefined","undefined");if(O(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(E(e))return t.stylize(""+e,"number");if(v(e))return t.stylize(""+e,"boolean");if(m(e))return t.stylize("null","null")}(e,r);if(i)return i;var u=Object.keys(r),f=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(u);if(e.showHidden&&(u=Object.getOwnPropertyNames(r)),B(r)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return d(r);if(0===u.length){if(_(r)){var s=r.name?": "+r.name:"";return e.stylize("[Function"+s+"]","special")}if(A(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(S(r))return e.stylize(Date.prototype.toString.call(r),"date");if(B(r))return d(r)}var a,c="",l=!1,p=["{","}"];(w(r)&&(l=!0,p=["[","]"]),_(r))&&(c=" [Function"+(r.name?": "+r.name:"")+"]");return A(r)&&(c=" "+RegExp.prototype.toString.call(r)),S(r)&&(c=" "+Date.prototype.toUTCString.call(r)),B(r)&&(c=" "+d(r)),0!==u.length||l&&0!=r.length?n<0?A(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),a=l?function(t,e,r,n,o){for(var i=[],u=0,f=e.length;u=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(a,c,p)):p[0]+c+p[1]}function d(t){return"["+Error.prototype.toString.call(t)+"]"}function b(t,e,r,n,o,i){var u,f,s;if((s=Object.getOwnPropertyDescriptor(e,o)||{value:e[o]}).get?f=s.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):s.set&&(f=t.stylize("[Setter]","special")),D(n,o)||(u="["+o+"]"),f||(t.seen.indexOf(s.value)<0?(f=m(r)?g(t,s.value,null):g(t,s.value,r-1)).indexOf("\n")>-1&&(f=i?f.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+f.split("\n").map(function(t){return" "+t}).join("\n")):f=t.stylize("[Circular]","special")),x(u)){if(i&&o.match(/^\d+$/))return f;(u=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=t.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=t.stylize(u,"string"))}return u+": "+f}function w(t){return Array.isArray(t)}function v(t){return"boolean"==typeof t}function m(t){return null===t}function E(t){return"number"==typeof t}function O(t){return"string"==typeof t}function x(t){return void 0===t}function A(t){return j(t)&&"[object RegExp]"===U(t)}function j(t){return"object"==typeof t&&null!==t}function S(t){return j(t)&&"[object Date]"===U(t)}function B(t){return j(t)&&("[object Error]"===U(t)||t instanceof Error)}function _(t){return"function"==typeof t}function U(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}t.debuglog=function(e){if(x(c)&&(c=process.env.NODE_DEBUG||""),e=e.toUpperCase(),!l[e])if(new RegExp("\\b"+e+"\\b","i").test(c)){var n=process.pid;l[e]=function(){var o=t.format.apply(t,arguments);r.error("%s %d: %s",e,n,o)}}else l[e]=function(){};return l[e]},t.inspect=p,p.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},p.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=w,t.isBoolean=v,t.isNull=m,t.isNullOrUndefined=function(t){return null==t},t.isNumber=E,t.isString=O,t.isSymbol=function(t){return"symbol"==typeof t},t.isUndefined=x,t.isRegExp=A,t.isObject=j,t.isDate=S,t.isError=B,t.isFunction=_,t.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},t.isBuffer=a(1);var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function D(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.log=function(){var e,n;r.log("%s - %s",(e=new Date,n=[T(e.getHours()),T(e.getMinutes()),T(e.getSeconds())].join(":"),[e.getDate(),k[e.getMonth()],n].join(" ")),t.format.apply(t,arguments))},t.inherits=a(2),t._extend=function(t,e){if(!e||!j(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t};var I="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function C(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}t.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(I&&t[I]){var e;if("function"!=typeof(e=t[I]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,I,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,n=new Promise(function(t,n){e=t,r=n}),o=[],i=0;i>>0!==r||r>f.length)return function(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}(r);for(;s.length<=r;)s.push(null);var u=s[r];if(u)return u.exports;var a=f[r],c=a[0],l=a[1],p=a[2],h=o,y=i,g=e,d=t,b=n;0!==r&&(b={id:"/"+c+l,exports:d={},parent:n,filename:h,loaded:!1,children:n.children,paths:n.paths,require:n.require}),s[r]=b;try{p.call(d,d,g,b,h,y,void 0)}catch(t){throw delete s[r],t}return 0!==r&&(b.loaded=!0),b.exports}a(0)}],["bpkg","/lib/builtins/assert.js",function(e,n,o,i,u,f){var s=[["assert","/assert.js",function(e,r,n,o,i,u){"use strict";function f(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o=0;f--)if(s[f]!==c[f])return!1;for(f=s.length-1;f>=0;f--)if(u=s[f],!x(t[u],e[u],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function A(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function j(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function S(t,e,r,n){var o;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),o=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!o&&E(o,r,"Missing expected exception"+n);var i="string"==typeof n,u=!t&&a.isError(o),f=!t&&o&&!r;if((u&&i&&j(o,r)||f)&&E(o,r,"Got unwanted exception"+n),t&&o&&r&&!j(o,r)||!t&&o)throw o}d.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=v(m((e=this).actual),128)+" "+e.operator+" "+v(m(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||E;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var o=n.stack,i=w(r),u=o.indexOf("\n"+i);if(u>=0){var f=o.indexOf("\n",u+1);o=o.substring(f+1)}this.stack=o}}},a.inherits(d.AssertionError,Error),d.fail=E,d.ok=O,d.equal=function(t,e,r){t!=e&&E(t,e,r,"==",d.equal)},d.notEqual=function(t,e,r){t==e&&E(t,e,r,"!=",d.notEqual)},d.deepEqual=function(t,e,r){x(t,e,!1)||E(t,e,r,"deepEqual",d.deepEqual)},d.deepStrictEqual=function(t,e,r){x(t,e,!0)||E(t,e,r,"deepStrictEqual",d.deepStrictEqual)},d.notDeepEqual=function(t,e,r){x(t,e,!1)&&E(t,e,r,"notDeepEqual",d.notDeepEqual)},d.notDeepStrictEqual=function t(e,r,n){x(e,r,!0)&&E(e,r,n,"notDeepStrictEqual",t)},d.strictEqual=function(t,e,r){t!==e&&E(t,e,r,"===",d.strictEqual)},d.notStrictEqual=function(t,e,r){t===e&&E(t,e,r,"!==",d.notStrictEqual)},d.throws=function(t,e,r){S(!0,t,e,r)},d.doesNotThrow=function(t,e,r){S(!1,t,e,r)},d.ifError=function(t){if(t)throw t};var B=Object.keys||function(t){var e=[];for(var r in t)l.call(t,r)&&e.push(r);return e}}],["util","/util.js",function(e,n,o,i,u,f){var s=/%[sdj%]/g;e.format=function(t){if(!O(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),v(r)?n.showHidden=r:r&&e._extend(n,r),x(n.showHidden)&&(n.showHidden=!1),x(n.depth)&&(n.depth=2),x(n.colors)&&(n.colors=!1),x(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=h),g(n,t,n.depth)}function h(t,e){var r=p.styles[e];return r?"["+p.colors[r][0]+"m"+t+"["+p.colors[r][1]+"m":t}function y(t,e){return t}function g(t,r,n){if(t.customInspect&&r&&_(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var o=r.inspect(n,t);return O(o)||(o=g(t,o,n)),o}var i=function(t,e){if(x(e))return t.stylize("undefined","undefined");if(O(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(E(e))return t.stylize(""+e,"number");if(v(e))return t.stylize(""+e,"boolean");if(m(e))return t.stylize("null","null")}(t,r);if(i)return i;var u=Object.keys(r),f=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(u);if(t.showHidden&&(u=Object.getOwnPropertyNames(r)),B(r)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return d(r);if(0===u.length){if(_(r)){var s=r.name?": "+r.name:"";return t.stylize("[Function"+s+"]","special")}if(A(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(S(r))return t.stylize(Date.prototype.toString.call(r),"date");if(B(r))return d(r)}var a,c="",l=!1,p=["{","}"];(w(r)&&(l=!0,p=["[","]"]),_(r))&&(c=" [Function"+(r.name?": "+r.name:"")+"]");return A(r)&&(c=" "+RegExp.prototype.toString.call(r)),S(r)&&(c=" "+Date.prototype.toUTCString.call(r)),B(r)&&(c=" "+d(r)),0!==u.length||l&&0!=r.length?n<0?A(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),a=l?function(t,e,r,n,o){for(var i=[],u=0,f=e.length;u=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(a,c,p)):p[0]+c+p[1]}function d(t){return"["+Error.prototype.toString.call(t)+"]"}function b(t,e,r,n,o,i){var u,f,s;if((s=Object.getOwnPropertyDescriptor(e,o)||{value:e[o]}).get?f=s.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):s.set&&(f=t.stylize("[Setter]","special")),D(n,o)||(u="["+o+"]"),f||(t.seen.indexOf(s.value)<0?(f=m(r)?g(t,s.value,null):g(t,s.value,r-1)).indexOf("\n")>-1&&(f=i?f.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+f.split("\n").map(function(t){return" "+t}).join("\n")):f=t.stylize("[Circular]","special")),x(u)){if(i&&o.match(/^\d+$/))return f;(u=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=t.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=t.stylize(u,"string"))}return u+": "+f}function w(t){return Array.isArray(t)}function v(t){return"boolean"==typeof t}function m(t){return null===t}function E(t){return"number"==typeof t}function O(t){return"string"==typeof t}function x(t){return void 0===t}function A(t){return j(t)&&"[object RegExp]"===U(t)}function j(t){return"object"==typeof t&&null!==t}function S(t){return j(t)&&"[object Date]"===U(t)}function B(t){return j(t)&&("[object Error]"===U(t)||t instanceof Error)}function _(t){return"function"==typeof t}function U(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(t){if(x(a)&&(a=process.env.NODE_DEBUG||""),t=t.toUpperCase(),!l[t])if(new RegExp("\\b"+t+"\\b","i").test(a)){var n=process.pid;l[t]=function(){var o=e.format.apply(e,arguments);r.error("%s %d: %s",t,n,o)}}else l[t]=function(){};return l[t]},e.inspect=p,p.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},p.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=w,e.isBoolean=v,e.isNull=m,e.isNullOrUndefined=function(t){return null==t},e.isNumber=E,e.isString=O,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=x,e.isRegExp=A,e.isObject=j,e.isDate=S,e.isError=B,e.isFunction=_,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=c(2);var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function D(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){var t,n;r.log("%s - %s",(t=new Date,n=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":"),[t.getDate(),k[t.getMonth()],n].join(" ")),e.format.apply(e,arguments))},e.inherits=c(3),e._extend=function(t,e){if(!e||!j(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}],["util","/support/isBufferBrowser.js",function(t,e,r,n,o,i){r.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}}],["inherits","/inherits_browser.js",function(t,e,r,n,o,i){"function"==typeof Object.create?r.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:r.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}]],a=[];function c(t){if(t>>>0!==t||t>s.length)return function(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}(t);for(;a.length<=t;)a.push(null);var r=a[t];if(r)return r.exports;var f=s[t],c=f[0],l=f[1],p=f[2],h=i,y=u,g=n,d=e,b=o;0!==t&&(b={id:"/"+c+l,exports:d={},parent:o,filename:h,loaded:!1,children:o.children,paths:o.paths,require:o.require}),a[t]=b;try{p.call(d,d,g,b,h,y,void 0)}catch(e){throw delete a[t],e}return 0!==t&&(b.loaded=!0),b.exports}c(0)}]],o=[];function i(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}function u(t){i(t)}function f(t,e){if(t>>>0!==t||t>n.length)return i(t);if(null!=e&&!e.children)return i(t);for(;o.length<=t;)o.push(null);var r=o[t];if(r)return r.exports;var f=n[t],s=f[0],a=f[1],c=f[2],l=a,p=l.split("/").slice(0,-1).join("/")||"/",h=u,y={},g={id:"/"+s+a,exports:y,parent:e,filename:l,loaded:!1,children:[],paths:["/"],require:h};e&&e.children.push(g),0===t&&(h.main=g),o[t]=g;try{c.call(y,y,h,g,l,p,void 0)}catch(e){throw delete o[t],e}return g.loaded=!0,g.exports}u.resolve=i,u.main=null,u.extensions={__proto__:null},u.cache={__proto__:null},e=f(1,null).Buffer,r=f(2,null);var s=f(0,null);"function"==typeof define&&define.amd?define("FORMAT",[],function(){return s}):"object"==typeof module&&module&&"object"==typeof module.exports&&module.exports?module.exports=s:t.FORMAT=s}("undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")()); 2 | -------------------------------------------------------------------------------- /handshakelogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pinheadmz/mobilehsd/bbd6808df5750297c5f6c4710da858991d9a2965/handshakelogo.png -------------------------------------------------------------------------------- /hns.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pinheadmz/mobilehsd/bbd6808df5750297c5f6c4710da858991d9a2965/hns.png -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Easyhandshake 9 | 10 | 11 |
12 |

13 |

🤝 easyhandshake.com 🤝

14 |

15 | This server provides these services to the Handshake network:
16 |

hsd full node
17 |
18 | This full node is one of the network seed nodes, meaning its location 19 | is hard-coded in the software. It supports up to 128 incoming connections 20 | and BIP37 (SPV) connections.
21 | 22 | aonetsezqp4m52w4jpfq2gv3dggy2wqfwqtkfjyttgdidbvhgp5as@165.22.151.242 23 | 24 |
25 |
26 |
DNS-over-HTTPS server
27 |
28 | You can use this server as a trusted resolver, making DNS requests over 29 | HTTPS that resolve to the local Handshake full node. You can try it out 30 | by configuring Firefox's 31 | TRR Settings 32 | in 33 | about:config

34 | 35 | 36 | 37 | 38 | 39 |
network.trr.mode  3
network.trr.uri  https://easyhandshake.com:8053/dns-query
network.trr.bootstrapAddress  165.22.151.242
40 |
41 |
42 |
43 |
Handshake DNS seeder
44 |
45 | easyhandshake.com runs an authoritative nameserver over the subdomain 46 | seed 47 | anchored by NS Records in the ICANN DNS system. It returns A and AAAA 48 | records generated from the hostlist of the local full node, so bootstrapping 49 | nodes can find more peers on the network. You can request those records 50 | from any legacy DNS resolver:

51 | dig seed.easyhandshake.com 52 |
53 |
54 |
Web browser SPV node
55 |
56 | Because hsd is written in JavaScript, it can be repackaged for use in a 57 | web browser. The entire SPV node runs in the browser, storing block 58 | header data in the browser's application storage. Easyhandshake provides 59 | a proxy server to connect the webapp to the p2p network. Some explanation 60 | is provided in this 61 | bcoin guide. 62 | Remember, the web browser is not a secure environment for crypto 63 | operations. It's just a proof-of-concept for now, but it does allow 64 | web clients to make DNS requests to the live Handshake network.

65 | Launch the in-browser SPV Handshake node! 66 |
67 |
68 |
Support
69 |
70 | This website is maintained by 71 | Matthew Zipkin
72 | pinheadmz@gmail.com
73 | Source code is available 74 | on GitHub
75 |
76 |
77 | Help keep this site running by contributing: 78 |

79 | BTC: bc1qq4hhuusn3m8fzd47w3tjvltvr9klv88rpt6ssq 80 |

81 | 82 | 83 |
84 |

85 |


86 | HNS: hs1qde7jaw6qgzzfu83upn3twvsyhh0zrshg76qe0x 87 |
88 | 89 | 90 |
91 |
92 |
93 |
94 |
95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /logger.js: -------------------------------------------------------------------------------- 1 | !function(e){var t,r=e.setTimeout,n=e.clearTimeout,o=(e.setInterval,e.clearInterval,e.setImmediate,e.clearImmediate,void 0),i=void 0,s=e.console,u=[["blgr","/lib/logger.js",function(e,t,u,a,l,f){"use strict";const p=c(1,u),h=c(2,u),g=c(4,u);class y{constructor(e){this.level=y.levels.NONE,this.colors=y.HAS_TTY,this.console=!0,this.shrink=!0,this.closed=!0,this.closing=!1,this.filename=null,this.stream=null,this.contexts=Object.create(null),e&&this.set(e)}set(e){p(e),p(this.closed),"string"!=typeof e?(null!=e.level&&(p("string"==typeof e.level),this.setLevel(e.level)),null!=e.colors&&y.HAS_TTY&&(p("boolean"==typeof e.colors),this.colors=e.colors),null!=e.console&&(p("boolean"==typeof e.console),this.console=e.console),null!=e.shrink&&(p("boolean"==typeof e.shrink),this.shrink=e.shrink),null!=e.filename&&(p("string"==typeof e.filename,"Bad file."),this.filename=e.filename)):this.setLevel(e)}async open(){this.filename?this.stream?this.closed=!1:g.unsupported?this.closed=!1:(this.shrink&&await this.truncate(),this.stream=await v(this.filename),this.stream.once("error",this.handleError.bind(this)),this.closed=!1):this.closed=!1}async close(){if(null!=this.timer&&(n(this.timer),this.timer=null),g.unsupported)return this.closed=!0,void(this.stream=null);if(this.stream){try{this.closing=!0,await(e=this.stream,new Promise((t,r)=>{const n=()=>{e.removeListener("error",o),e.removeListener("close",i)},o=e=>{n(),r(e)},i=()=>{n(),t(e)};e.removeAllListeners("error"),e.removeAllListeners("close"),e.once("error",o),e.once("close",i),e.close()}))}finally{this.closing=!1}this.stream=null}var e;this.closed=!0}async truncate(){if(!this.filename)return;if(g.unsupported)return;let e;p(!this.stream);try{e=await g.stat(this.filename)}catch(e){if("ENOENT"===e.code)return;throw e}const t=y.MAX_FILE_SIZE;if(e.size<=t+t/10)return;this.debug("Truncating log file to %dmb.",m(t));const r=await g.open(this.filename,"r+"),n=i.allocUnsafe(t);await g.read(r,n,0,t,e.size-t),await g.ftruncate(r,t),await g.write(r,n,0,t,0),await g.close(r)}handleError(e){try{this.stream.close()}catch(e){}this.stream=null,this.retry()}async reopen(){if(!this.stream&&!this.closed&&!g.unsupported){try{this.stream=await v(this.filename)}catch(e){return void this.retry()}this.stream.once("error",e=>this.handleError(e))}}retry(){null==this.timer&&(this.timer=r(()=>{this.timer=null,this.reopen()},1e4))}setFile(e){p("string"==typeof e),p(!this.stream,"Log stream has already been created."),this.filename=e}setLevel(e){const t=y.levels[e.toUpperCase()];p(null!=t,"Invalid log level."),this.level=t}error(...e){if(this.level0){const[t]=r;if(t&&"object"==typeof t)return e===y.levels.ERROR?s.error(o,t):s.log(o,t)}return o+=h(r,!1),e===y.levels.ERROR?s.error(o):s.log(o),!0}let i;if(this.colors){const t=y.styles[e];p(t),i=`[${t}m[${n}] `}else i=`[${n}] `;return t&&(i+=`(${t}) `),i+=h(r,this.colors),i+="\n",e===y.levels.ERROR?o.stderr.write(i):o.stdout.write(i)}writeStream(e,t,r){const n=y.prefixByVal[e];if(p(n,"Invalid log level."),!this.stream)return;if(this.closing)return;let o=`[${n}:${(new Date).toISOString().slice(0,-5)+"Z"}] `;t&&(o+=`(${t}) `),o+=h(r,!1),o+="\n",this.stream.write(o)}logError(e,t,r){if(this.closed)return;g.unsupported&&this.console&&e<=y.levels.WARNING&&s.error(r);let n=String(r.message).replace(/^ *Error: */,"");e!==y.levels.ERROR&&(n=`Error: ${n}`),this.log(e,t,[n]),e<=y.levels.WARNING&&this.stream&&this.stream.write(r.stack+"\n")}memoryUsage(){if(!o.memoryUsage)return{total:0,jsHeap:0,jsHeapTotal:0,nativeHeap:0,external:0};const e=o.memoryUsage();return{total:m(e.rss),jsHeap:m(e.heapUsed),jsHeapTotal:m(e.heapTotal),nativeHeap:m(e.rss-e.heapTotal),external:m(e.external)}}memory(e){const t=this.memoryUsage();this.log(y.levels.DEBUG,e,["Memory: rss=%dmb, js-heap=%d/%dmb native-heap=%dmb",t.total,t.jsHeap,t.jsHeapTotal,t.nativeHeap])}}class d{constructor(e,t){p("string"==typeof t),this.logger=e,this.module=t}open(){return this.logger.open()}close(){return this.logger.close()}setFile(e){this.logger.setFile(e)}setLevel(e){this.logger.setLevel(e)}error(...e){if(this.logger.level{const n=g.createWriteStream(e,{flags:"a"}),o=()=>{n.removeListener("error",i),n.removeListener("open",s)},i=e=>{try{n.close()}catch(e){}o(),r(e)},s=()=>{o(),t(n)};n.once("error",i),n.once("open",s)})}y.HAS_TTY=Boolean(o.stdout&&o.stdout.isTTY),y.MAX_FILE_SIZE=20<<20,y.levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4,SPAM:5},y.levelsByVal=["none","error","warning","info","debug","spam"],y.prefixByVal=["N","E","W","I","D","S"],y.styles=["0","1;31","1;33","94","90","90"],y.global=new y,u.exports=y}],["bsert","/lib/assert.js",function(e,t,r,n,o,i){"use strict";class s extends Error{constructor(e){"string"==typeof e&&(e={message:e}),null!==e&&"object"==typeof e||(e={});let t=null,r="fail",n=Boolean(e.generatedMessage);var o;if(null!=e.message&&(t="string"==typeof(o=e.message)?o:S(o)?String(o):O(o)?String(o.message||""):d(o)),"string"==typeof e.operator&&(r=e.operator),null==t){if("fail"===r)t="Assertion failed.";else{t=`${d(e.actual)} ${r} ${d(e.expected)}`}n=!0}super(t);let i=this.constructor;"function"==typeof e.stackStartFunction?i=e.stackStartFunction:"function"==typeof e.stackStartFn&&(i=e.stackStartFn),this.type="AssertionError",this.name="AssertionError [ERR_ASSERTION]",this.code="ERR_ASSERTION",this.generatedMessage=n,this.actual=e.actual,this.expected=e.expected,this.operator=r,Error.captureStackTrace&&Error.captureStackTrace(this,i)}}function u(e,t){if(!e){let r=!1;if(0===arguments.length)t="No value argument passed to `assert()`.",r=!0;else if(null==t)t="Assertion failed.",r=!0;else if(O(t))throw t;throw new s({message:t,actual:e,expected:!0,operator:"==",generatedMessage:r,stackStartFn:u})}}function a(e,t,r){if(!Object.is(e,t)){if(O(r))throw r;throw new s({message:r,actual:e,expected:t,operator:"strictEqual",stackStartFn:a})}}function l(e,t,r){if(Object.is(e,t)){if(O(r))throw r;throw new s({message:r,actual:e,expected:t,operator:"notStrictEqual",stackStartFn:l})}}function f(e,t,r){"string"==typeof t&&(r=t,t=void 0);let n=!1,o=null;y("function"==typeof e,"func","function");try{e()}catch(e){n=!0,o=e}if(n){if(m(o,t,r,f)){let e=!1;throw null==r&&(r="Got unwanted exception.",e=!0),new s({message:r,actual:o,expected:t,operator:"doesNotThrow",generatedMessage:e,stackStartFn:f})}throw o}}async function c(e,t,r){"string"==typeof t&&(r=t,t=void 0);let n=!1,o=null;"function"!=typeof e&&y(A(e),"func","promise");try{A(e)?await e:await e()}catch(e){n=!0,o=e}if(!n){let e=!1;throw null==r&&(r="Missing expected rejection.",e=!0),new s({message:r,actual:void 0,expected:t,operator:"rejects",generatedMessage:e,stackStartFn:c})}if(!m(o,t,r,c))throw o}async function p(e,t,r){"string"==typeof t&&(r=t,t=void 0);let n=!1,o=null;"function"!=typeof e&&y(A(e),"func","promise");try{A(e)?await e:await e()}catch(e){n=!0,o=e}if(n){if(m(o,t,r,p)){let e=!1;throw null==r&&(r="Got unwanted rejection.",e=!0),new s({message:r,actual:void 0,expected:t,operator:"doesNotReject",generatedMessage:e,stackStartFn:p})}throw o}}function h(e,t,r){if(!v(e,t)){if(O(r))throw r;throw new s({message:r,actual:e,expected:t,operator:"deepStrictEqual",stackStartFn:h})}}function g(e,t,r){if(v(e,t)){if(O(r))throw r;throw new s({message:r,actual:e,expected:t,operator:"notDeepStrictEqual",stackStartFn:g})}}function y(e,t,r){if(!e){let e;e=null==t?"Invalid type for parameter.":null==r?`Invalid type for "${t}".`:`"${t}" must be a(n) ${r}.`;const n=new TypeError(e);throw Error.captureStackTrace&&Error.captureStackTrace(n,y),n}}function d(e){switch(typeof e){case"undefined":return"undefined";case"object":return null===e?"null":`[${E(e)}]`;case"boolean":case"number":return e.toString();case"string":return e.length>80&&(e=`${e.substring(0,77)}...`),JSON.stringify(e);case"symbol":return e.toString();case"function":return`[${E(e)}]`;case"bigint":return`${e.toString()}n`;default:return`[${typeof e}]`}}function m(e,t,r,n){if(null==t)return!0;if(T(t))return t.test(e);if("function"!=typeof t){if(n===f||n===p)throw new TypeError('"expected" must not be an object.');if("object"!=typeof t)throw new TypeError('"expected" must be an object.');let o=!1;if(null==r){r=`Missing expected ${n===c?"rejection":"exception"}.`,o=!0}if(null==e||"object"!=typeof e)throw new s({actual:e,expected:t,message:r,operator:n.name,generatedMessage:o,stackStartFn:n});const i=Object.keys(t);if(O(t)&&i.push("name","message"),0===i.length)throw new TypeError('"expected" may not be an empty object.');for(const u of i){const i=t[u],a=e[u];if(("string"!=typeof a||!T(i)||!i.test(a))&&!(u in e&&v(a,i)))throw new s({actual:e,expected:t,message:r,operator:n.name,generatedMessage:o,stackStartFn:n})}return!0}return void 0!==t.prototype&&e instanceof t||!Error.isPrototypeOf(t)&&!0===t.call({},e)}function v(e,t){return w(e,t,null)}function w(e,t,r){if(Object.is(e,t))return!0;if(!j(e)||!j(t))return!1;if(b(e)!==b(t))return!1;if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(x(e)&&x(t))return e.equals(t);if(S(e))return Object.is(e.getTime(),t.getTime());if(T(e))return e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase;if(O(e)&&e.message!==t.message)return!1;if(e instanceof ArrayBuffer&&(e=new Uint8Array(e),t=new Uint8Array(t)),function(e){return ArrayBuffer.isView(e)}(e)&&!x(e)){if(x(t))return!1;const r=new Uint8Array(e.buffer),n=new Uint8Array(t.buffer);if(r.length!==n.length)return!1;for(let e=0;e>>1?null:o}return t}u.AssertionError=s,u.assert=u,u.strict=u,u.ok=u,u.equal=a,u.notEqual=l,u.strictEqual=a,u.notStrictEqual=l,u.fail=function e(t){let r=!1;if(O(t))throw t;throw null==t&&(t="Assertion failed.",r=!0),new s({message:t,actual:!1,expected:!0,operator:"fail",generatedMessage:r,stackStartFn:e})},u.throws=function e(t,r,n){"string"==typeof r&&(n=r,r=void 0);let o=!1,i=null;y("function"==typeof t,"func","function");try{t()}catch(e){o=!0,i=e}if(!o){let t=!1;throw null==n&&(n="Missing expected exception.",t=!0),new s({message:n,actual:void 0,expected:r,operator:"throws",generatedMessage:t,stackStartFn:e})}if(!m(i,r,n,e))throw i},u.doesNotThrow=f,u.rejects=c,u.doesNotReject=p,u.ifError=function e(t){if(null!=t){let r="ifError got unwanted exception: ";throw"object"==typeof t&&"string"==typeof t.message?0===t.message.length&&t.constructor?r+=t.constructor.name:r+=t.message:r+=d(t),new s({message:r,actual:t,expected:null,operator:"ifError",generatedMessage:!0,stackStartFn:e})}},u.deepEqual=h,u.notDeepEqual=g,u.deepStrictEqual=h,u.notDeepStrictEqual=g,u.bufferEqual=function e(t,r,n,o){if(I(n)||(o=n,n=null),null==n&&(n="hex"),r=B(t,r,n),y(x(t),"actual","buffer"),y(x(r),"expected","buffer"),t!==r&&!t.equals(r)){if(O(o))throw o;throw new s({message:o,actual:t.toString(n),expected:r.toString(n),operator:"bufferEqual",stackStartFn:e})}},u.notBufferEqual=function e(t,r,n,o){if(I(n)||(o=n,n=null),null==n&&(n="hex"),r=B(t,r,n),y(x(t),"actual","buffer"),y(x(r),"expected","buffer"),t===r||t.equals(r)){if(O(o))throw o;throw new s({message:o,actual:t.toString(n),expected:r.toString(n),operator:"notBufferEqual",stackStartFn:e})}},u.enforce=y,u.range=function e(t,r){if(!t){const t=null!=r?`"${r}" is out of range.`:"Parameter is out of range.",n=new RangeError(t);throw Error.captureStackTrace&&Error.captureStackTrace(n,e),n}},r.exports=u}],["blgr","/lib/format.js",function(e,t,r,n,o,s){"use strict";const u=c(3,r),a={showHidden:!1,depth:20,colors:!1,customInspect:!0,showProxy:!1,maxArrayLength:1e4,breakLength:60,compact:!0};function l(e){try{return JSON.stringify(e)}catch(e){return"[error]"}}function f(e,t){if(null==e)return"null";if(!i.isBuffer(e)){let r=(e>>>0).toString(16);for(;r.length<8;)r="0"+r;return t&&(r=p(r)),`0x${r}`}const r=e.toString("hex");return t?p(r):r}function p(e){let t="";for(let r=e.length-2;r>=0;r-=2)t+=e[r]+e[r+1];return t}function h(e){return"bigint"==typeof e?`${e}n`:`${parseInt(e)}`}r.exports=function(e,t){if(0===e.length)return"";const r=e[0];if(a.colors=t,"string"!=typeof r)return u(r,a);if(1===e.length)return r;let n,o="",i=1,s=0;for(let t=0;t=0&&(e._idleTimeoutId=l(function(){e._onTimeout&&e._onTimeout()},t))},c(1),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}],["setimmediate","/setImmediate.js",function(t,n,i,s,u,a){!function(e,t){"use strict";if(!e.setImmediate){var n,i,s,u,a,l=1,f={},c=!1,p=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?n=function(e){o.nextTick(function(){y(e)})}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((s=new MessageChannel).port1.onmessage=function(e){y(e.data)},n=function(e){s.port2.postMessage(e)}):p&&"onreadystatechange"in p.createElement("script")?(i=p.documentElement,n=function(e){var t=p.createElement("script");t.onreadystatechange=function(){y(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):n=function(e){r(y,0,e)}:(u="setImmediate$"+Math.random()+"$",a=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(u)&&y(+t.data.slice(u.length))},e.addEventListener?e.addEventListener("message",a,!1):e.attachEvent("onmessage",a),n=function(t){e.postMessage(u+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r>>0!==e||e>l.length)return function(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}(e);for(;f.length<=e;)f.push(null);var r=f[e];if(r)return r.exports;var o=l[e],a=o[0],c=o[1],p=o[2],h=s,g=u,y=n,d=t,m=i;0!==e&&(m={id:"/"+a+c,exports:d={},parent:i,filename:h,loaded:!1,children:i.children,paths:i.paths,require:i.require}),f[e]=m;try{p.call(d,d,y,m,h,g,void 0)}catch(t){throw delete f[e],t}return 0!==e&&(m.loaded=!0),m.exports}c(0)}],["bpkg","/lib/builtins/process.js",function(e,t,o,i,s,u){var a,l,f=o.exports={};function c(){throw new Error("setTimeout has not been defined")}function p(){throw new Error("clearTimeout has not been defined")}function h(e){if(a===r)return r(e,0);if((a===c||!a)&&r)return a=r,r(e,0);try{return a(e,0)}catch(t){try{return a.call(null,e,0)}catch(t){return a.call(this,e,0)}}}!function(){try{a="function"==typeof r?r:c}catch(e){a=c}try{l="function"==typeof n?n:p}catch(e){l=p}}();var g,y=[],d=!1,m=-1;function v(){d&&g&&(d=!1,g.length?y=g.concat(y):m=-1,y.length&&w())}function w(){if(!d){var e=h(v);d=!0;for(var t=y.length;t;){for(g=y,y=[];++m1)for(var r=1;rf)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=p.prototype,t}function p(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return y(e)}return h(e,t,r)}function h(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!p.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|v(e,t),n=c(r),o=n.write(e,t);o!==r&&(n=n.slice(0,o));return n}(e,t);if(ArrayBuffer.isView(e))return d(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(H(e,ArrayBuffer)||e&&H(e.buffer,ArrayBuffer))return function(e,t,r){if(t<0||e.byteLength=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return 0|e}function v(e,t){if(p.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||H(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return $(e).length;default:if(o)return n?-1:q(e).length;t=(""+t).toLowerCase(),o=!0}}function w(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=p.from(t,n)),p.isBuffer(t))return 0===t.length?-1:E(e,t,r,n,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):E(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function E(e,t,r,n,o){var i,s=1,u=e.length,a=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;s=2,u/=2,a/=2,r/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){var f=-1;for(i=r;iu&&(r=u-a),i=r;i>=0;i--){for(var c=!0,p=0;po&&(n=o):n=o;var i=t.length;n>i/2&&(n=i/2);for(var s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function I(e,t,r){return 0===t&&r===e.length?u.fromByteArray(e):u.fromByteArray(e.slice(t,r))}function B(e,t,r){r=Math.min(e.length,r);for(var n=[],o=t;o239?4:l>223?3:l>191?2:1;if(o+c<=r)switch(c){case 1:l<128&&(f=l);break;case 2:128==(192&(i=e[o+1]))&&(a=(31&l)<<6|63&i)>127&&(f=a);break;case 3:i=e[o+1],s=e[o+2],128==(192&i)&&128==(192&s)&&(a=(15&l)<<12|(63&i)<<6|63&s)>2047&&(a<55296||a>57343)&&(f=a);break;case 4:i=e[o+1],s=e[o+2],u=e[o+3],128==(192&i)&&128==(192&s)&&128==(192&u)&&(a=(15&l)<<18|(63&i)<<12|(63&s)<<6|63&u)>65535&&a<1114112&&(f=a)}null===f?(f=65533,c=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),o+=c}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.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 U(this,t,r);case"utf8":case"utf-8":return B(this,t,r);case"ascii":return R(this,t,r);case"latin1":case"binary":return _(this,t,r);case"base64":return I(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},p.prototype.toLocaleString=p.prototype.toString,p.prototype.equals=function(e){if(!p.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===p.compare(this,e)},p.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),""},p.prototype.compare=function(e,t,r,n,o){if(H(e,Uint8Array)&&(e=p.from(e,e.offset,e.byteLength)),!p.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,o>>>=0,this===e)return 0;for(var i=o-n,s=r-t,u=Math.min(i,s),a=this.slice(n,o),l=e.slice(t,r),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return x(this,e,t,r);case"utf8":case"utf-8":return S(this,e,t,r);case"ascii":return O(this,e,t,r);case"latin1":case"binary":return j(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function R(e,t,r){var n="";r=Math.min(e.length,r);for(var o=t;on)&&(r=n);for(var o="",i=t;ir)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,r,n,o,i){if(!p.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function F(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(e,t,r,n,o){return t=+t,r>>>=0,o||F(e,0,r,4),a.write(e,t,r,n,23,4),r+4}function z(e,t,r,n,o){return t=+t,r>>>=0,o||F(e,0,r,8),a.write(e,t,r,n,52,8),r+8}p.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||M(e,t,this.length);for(var n=this[e],o=1,i=0;++i>>=0,t>>>=0,r||M(e,t,this.length);for(var n=this[e+--t],o=1;t>0&&(o*=256);)n+=this[e+--t]*o;return n},p.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},p.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},p.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},p.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},p.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},p.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);for(var n=this[e],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*t)),n},p.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);for(var n=t,o=1,i=this[e+--n];n>0&&(o*=256);)i+=this[e+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*t)),i},p.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},p.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},p.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},p.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},p.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},p.prototype.readFloatLE=function(e,t){return e>>>=0,t||M(e,4,this.length),a.read(this,e,!0,23,4)},p.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),a.read(this,e,!1,23,4)},p.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),a.read(this,e,!0,52,8)},p.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),a.read(this,e,!1,52,8)},p.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||D(this,e,t,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[t]=255&e;++i>>=0,r>>>=0,n)||D(this,e,t,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},p.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,1,255,0),this[t]=255&e,t+1},p.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},p.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},p.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},p.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},p.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var o=Math.pow(2,8*r-1);D(this,e,t,r,o-1,-o)}var i=0,s=1,u=0;for(this[t]=255&e;++i>0)-u&255;return t+r},p.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var o=Math.pow(2,8*r-1);D(this,e,t,r,o-1,-o)}var i=r-1,s=1,u=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===u&&0!==this[t+i+1]&&(u=1),this[t+i]=(e/s>>0)-u&255;return t+r},p.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},p.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},p.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},p.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},p.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},p.prototype.writeFloatLE=function(e,t,r){return L(this,e,t,!0,r)},p.prototype.writeFloatBE=function(e,t,r){return L(this,e,t,!1,r)},p.prototype.writeDoubleLE=function(e,t,r){return z(this,e,t,!0,r)},p.prototype.writeDoubleBE=function(e,t,r){return z(this,e,t,!1,r)},p.prototype.copy=function(e,t,r,n){if(!p.isBuffer(e))throw new TypeError("argument should be a Buffer");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("Index out of range");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 Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return o},p.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!p.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var o=e.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(e=o)}}else"number"==typeof e&&(e&=255);if(t<0||this.length>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.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;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function $(e){return u.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(C,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function G(e,t,r,n){for(var o=0;o=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function H(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function J(e){return e!=e}}],["base64-js","/index.js",function(e,t,r,n,o,i){"use strict";e.byteLength=function(e){var t=p(e),r=t[0],n=t[1];return 3*(r+n)/4-n},e.toByteArray=function(e){for(var t,r=p(e),n=r[0],o=r[1],i=new a(function(e,t,r){return 3*(t+r)/4-r}(0,n,o)),s=0,l=o>0?n-4:n,f=0;f>16&255,i[s++]=t>>8&255,i[s++]=255&t;2===o&&(t=u[e.charCodeAt(f)]<<2|u[e.charCodeAt(f+1)]>>4,i[s++]=255&t);1===o&&(t=u[e.charCodeAt(f)]<<10|u[e.charCodeAt(f+1)]<<4|u[e.charCodeAt(f+2)]>>2,i[s++]=t>>8&255,i[s++]=255&t);return i},e.fromByteArray=function(e){for(var t,r=e.length,n=r%3,o=[],i=0,u=r-n;iu?u:i+16383));1===n?(t=e[r-1],o.push(s[t>>2]+s[t<<4&63]+"==")):2===n&&(t=(e[r-2]<<8)+e[r-1],o.push(s[t>>10]+s[t>>4&63]+s[t<<2&63]+"="));return o.join("")};for(var s=[],u=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,c=l.length;f0)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 h(e,t,r){for(var n,o,i=[],u=t;u>18&63]+s[o>>12&63]+s[o>>6&63]+s[63&o]);return i.join("")}u["-".charCodeAt(0)]=62,u["_".charCodeAt(0)]=63}],["ieee754","/index.js",function(e,t,r,n,o,i){e.read=function(e,t,r,n,o){var i,s,u=8*o-n-1,a=(1<>1,f=-7,c=r?o-1:0,p=r?-1:1,h=e[t+c];for(c+=p,i=h&(1<<-f)-1,h>>=-f,f+=u;f>0;i=256*i+e[t+c],c+=p,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=n;f>0;s=256*s+e[t+c],c+=p,f-=8);if(0===i)i=1-l;else{if(i===a)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,n),i-=l}return(h?-1:1)*s*Math.pow(2,i-n)},e.write=function(e,t,r,n,o,i){var s,u,a,l=8*i-o-1,f=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:i-1,g=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-s))<1&&(s--,a*=2),(t+=s+c>=1?p/a:p*Math.pow(2,1-c))*a>=2&&(s++,a/=2),s+c>=f?(u=0,s=f):s+c>=1?(u=(t*a-1)*Math.pow(2,o),s+=c):(u=t*Math.pow(2,c-1)*Math.pow(2,o),s=0));o>=8;e[r+h]=255&u,h+=g,u/=256,o-=8);for(s=s<0;e[r+h]=255&s,h+=g,s/=256,l-=8);e[r+h-g]|=128*y}}]],a=[];function l(i){if(i>>>0!==i||i>u.length)return function(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}(i);for(;a.length<=i;)a.push(null);var s=a[i];if(s)return s.exports;var l=u[i],f=l[0],c=l[1],p=l[2],h=n,g=o,y=t,d=e,m=r;0!==i&&(m={id:"/"+f+c,exports:d={},parent:r,filename:h,loaded:!1,children:r.children,paths:r.paths,require:r.require}),a[i]=m;try{p.call(d,d,y,m,h,g,void 0)}catch(e){throw delete a[i],e}return 0!==i&&(m.loaded=!0),m.exports}l(0)}],["bpkg","/lib/builtins/console.js",function(t,r,n,o,i,s){var u=[["console-browserify","/index.js",function(t,r,n,o,i,s){var u,a=c(9,n),f=c(10,n),p=l(1),h=Array.prototype.slice,g={};u=void 0!==e&&e.console?e.console:"undefined"!=typeof window&&window.console?window.console:{};for(var y=[[function(){},"log"],[function(){u.log.apply(u,arguments)},"info"],[function(){u.log.apply(u,arguments)},"warn"],[function(){u.warn.apply(u,arguments)},"error"],[function(e){g[e]=p()},"time"],[function(e){var t=g[e];if(!t)throw new Error("No such label: "+e);var r=p()-t;u.log(e+": "+r+"ms")},"timeEnd"],[function(){var e=new Error;e.name="Trace",e.message=a.format.apply(null,arguments),u.error(e.stack)},"trace"],[function(e){u.log(a.inspect(e)+"\n")},"dir"],[function(e){if(!e){var t=h.call(arguments,1);f.ok(!1,a.format.apply(null,t))}},"assert"]],d=0;d>>0!==e||e>u.length)return function(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}(e);for(;a.length<=e;)a.push(null);var s=a[e];if(s)return s.exports;var l=u[e],f=l[0],c=l[1],p=l[2],h=o,g=i,y=r,d=t,m=n;0!==e&&(m={id:"/"+f+c,exports:d={},parent:n,filename:h,loaded:!1,children:n.children,paths:n.paths,require:n.require}),a[e]=m;try{p.call(d,d,y,m,h,g,void 0)}catch(t){throw delete a[e],t}return 0!==e&&(m.loaded=!0),m.exports}l(0)}],["bpkg","/lib/builtins/util.js",function(e,t,r,n,i,u){var a=[["util","/util.js",function(e,t,r,n,i,u){var a=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),r={},n=0;n=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),s=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),b(r)?n.showHidden=r:r&&e._extend(n,r),O(n.showHidden)&&(n.showHidden=!1),O(n.depth)&&(n.depth=2),O(n.colors)&&(n.colors=!1),O(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=g),d(n,t,n.depth)}function g(e,t){var r=h.styles[t];return r?"["+h.colors[r][0]+"m"+e+"["+h.colors[r][1]+"m":e}function y(e,t){return e}function d(t,r,n){if(t.customInspect&&r&&B(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var o=r.inspect(n,t);return S(o)||(o=d(t,o,n)),o}var i=function(e,t){if(O(t))return e.stylize("undefined","undefined");if(S(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(x(t))return e.stylize(""+t,"number");if(b(t))return e.stylize(""+t,"boolean");if(E(t))return e.stylize("null","null")}(t,r);if(i)return i;var s=Object.keys(r),u=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(r)),I(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return m(r);if(0===s.length){if(B(r)){var a=r.name?": "+r.name:"";return t.stylize("[Function"+a+"]","special")}if(j(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(T(r))return t.stylize(Date.prototype.toString.call(r),"date");if(I(r))return m(r)}var l,f="",c=!1,p=["{","}"];(w(r)&&(c=!0,p=["[","]"]),B(r))&&(f=" [Function"+(r.name?": "+r.name:"")+"]");return j(r)&&(f=" "+RegExp.prototype.toString.call(r)),T(r)&&(f=" "+Date.prototype.toUTCString.call(r)),I(r)&&(f=" "+m(r)),0!==s.length||c&&0!=r.length?n<0?j(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),l=c?function(e,t,r,n,o){for(var i=[],s=0,u=t.length;s=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(l,f,p)):p[0]+f+p[1]}function m(e){return"["+Error.prototype.toString.call(e)+"]"}function v(e,t,r,n,o,i){var s,u,a;if((a=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?u=a.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):a.set&&(u=e.stylize("[Setter]","special")),U(n,o)||(s="["+o+"]"),u||(e.seen.indexOf(a.value)<0?(u=E(r)?d(e,a.value,null):d(e,a.value,r-1)).indexOf("\n")>-1&&(u=i?u.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+u.split("\n").map(function(e){return" "+e}).join("\n")):u=e.stylize("[Circular]","special")),O(s)){if(i&&o.match(/^\d+$/))return u;(s=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+u}function w(e){return Array.isArray(e)}function b(e){return"boolean"==typeof e}function E(e){return null===e}function x(e){return"number"==typeof e}function S(e){return"string"==typeof e}function O(e){return void 0===e}function j(e){return A(e)&&"[object RegExp]"===k(e)}function A(e){return"object"==typeof e&&null!==e}function T(e){return A(e)&&"[object Date]"===k(e)}function I(e){return A(e)&&("[object Error]"===k(e)||e instanceof Error)}function B(e){return"function"==typeof e}function k(e){return Object.prototype.toString.call(e)}function R(e){return e<10?"0"+e.toString(10):e.toString(10)}e.debuglog=function(t){if(O(c)&&(c=o.env.NODE_DEBUG||""),t=t.toUpperCase(),!p[t])if(new RegExp("\\b"+t+"\\b","i").test(c)){var r=o.pid;p[t]=function(){var n=e.format.apply(e,arguments);s.error("%s %d: %s",t,r,n)}}else p[t]=function(){};return p[t]},e.inspect=h,h.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},h.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=w,e.isBoolean=b,e.isNull=E,e.isNullOrUndefined=function(e){return null==e},e.isNumber=x,e.isString=S,e.isSymbol=function(e){return"symbol"==typeof e},e.isUndefined=O,e.isRegExp=j,e.isObject=A,e.isDate=T,e.isError=I,e.isFunction=B,e.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},e.isBuffer=f(1);var _=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function U(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.log=function(){var t,r;s.log("%s - %s",(t=new Date,r=[R(t.getHours()),R(t.getMinutes()),R(t.getSeconds())].join(":"),[t.getDate(),_[t.getMonth()],r].join(" ")),e.format.apply(e,arguments))},e.inherits=f(2),e._extend=function(e,t){if(!t||!A(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};var N="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function M(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}e.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(N&&e[N]){var t;if("function"!=typeof(t=e[N]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,N,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,r,n=new Promise(function(e,n){t=e,r=n}),o=[],i=0;i>>0!==o||o>a.length)return function(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}(o);for(;l.length<=o;)l.push(null);var s=l[o];if(s)return s.exports;var u=a[o],f=u[0],c=u[1],p=u[2],h=n,g=i,y=t,d=e,m=r;0!==o&&(m={id:"/"+f+c,exports:d={},parent:r,filename:h,loaded:!1,children:r.children,paths:r.paths,require:r.require}),l[o]=m;try{p.call(d,d,y,m,h,g,void 0)}catch(e){throw delete l[o],e}return 0!==o&&(m.loaded=!0),m.exports}f(0)}],["bpkg","/lib/builtins/assert.js",function(t,r,n,i,u,a){var l=[["assert","/assert.js",function(t,r,n,o,i,s){"use strict";function u(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,o=0,i=Math.min(r,n);o=0;u--)if(a[u]!==f[u])return!1;for(u=a.length-1;u>=0;u--)if(s=a[u],!S(e[s],t[s],r,n))return!1;return!0}(e,t,r,n))}return r?e===t:e==t}function O(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function j(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function A(e,t,r,n){var o;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),o=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!o&&E(o,r,"Missing expected exception"+n);var i="string"==typeof n,s=!e&&l.isError(o),u=!e&&o&&!r;if((s&&i&&j(o,r)||u)&&E(o,r,"Got unwanted exception"+n),e&&o&&r&&!j(o,r)||!e&&o)throw o}d.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=w(b((t=this).actual),128)+" "+t.operator+" "+w(b(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||E;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var o=n.stack,i=v(r),s=o.indexOf("\n"+i);if(s>=0){var u=o.indexOf("\n",s+1);o=o.substring(u+1)}this.stack=o}}},l.inherits(d.AssertionError,Error),d.fail=E,d.ok=x,d.equal=function(e,t,r){e!=t&&E(e,t,r,"==",d.equal)},d.notEqual=function(e,t,r){e==t&&E(e,t,r,"!=",d.notEqual)},d.deepEqual=function(e,t,r){S(e,t,!1)||E(e,t,r,"deepEqual",d.deepEqual)},d.deepStrictEqual=function(e,t,r){S(e,t,!0)||E(e,t,r,"deepStrictEqual",d.deepStrictEqual)},d.notDeepEqual=function(e,t,r){S(e,t,!1)&&E(e,t,r,"notDeepEqual",d.notDeepEqual)},d.notDeepStrictEqual=function e(t,r,n){S(t,r,!0)&&E(t,r,n,"notDeepStrictEqual",e)},d.strictEqual=function(e,t,r){e!==t&&E(e,t,r,"===",d.strictEqual)},d.notStrictEqual=function(e,t,r){e===t&&E(e,t,r,"!==",d.notStrictEqual)},d.throws=function(e,t,r){A(!0,e,t,r)},d.doesNotThrow=function(e,t,r){A(!1,e,t,r)},d.ifError=function(e){if(e)throw e};var T=Object.keys||function(e){var t=[];for(var r in e)f.call(e,r)&&t.push(r);return t}}],["util","/util.js",function(t,r,n,i,u,a){var l=/%[sdj%]/g;t.format=function(e){if(!S(e)){for(var t=[],r=0;r=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),s=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),b(r)?n.showHidden=r:r&&t._extend(n,r),O(n.showHidden)&&(n.showHidden=!1),O(n.depth)&&(n.depth=2),O(n.colors)&&(n.colors=!1),O(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=g),d(n,e,n.depth)}function g(e,t){var r=h.styles[t];return r?"["+h.colors[r][0]+"m"+e+"["+h.colors[r][1]+"m":e}function y(e,t){return e}function d(e,r,n){if(e.customInspect&&r&&B(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var o=r.inspect(n,e);return S(o)||(o=d(e,o,n)),o}var i=function(e,t){if(O(t))return e.stylize("undefined","undefined");if(S(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(x(t))return e.stylize(""+t,"number");if(b(t))return e.stylize(""+t,"boolean");if(E(t))return e.stylize("null","null")}(e,r);if(i)return i;var s=Object.keys(r),u=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(r)),I(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return m(r);if(0===s.length){if(B(r)){var a=r.name?": "+r.name:"";return e.stylize("[Function"+a+"]","special")}if(j(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(T(r))return e.stylize(Date.prototype.toString.call(r),"date");if(I(r))return m(r)}var l,f="",c=!1,p=["{","}"];(w(r)&&(c=!0,p=["[","]"]),B(r))&&(f=" [Function"+(r.name?": "+r.name:"")+"]");return j(r)&&(f=" "+RegExp.prototype.toString.call(r)),T(r)&&(f=" "+Date.prototype.toUTCString.call(r)),I(r)&&(f=" "+m(r)),0!==s.length||c&&0!=r.length?n<0?j(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),l=c?function(e,t,r,n,o){for(var i=[],s=0,u=t.length;s=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(l,f,p)):p[0]+f+p[1]}function m(e){return"["+Error.prototype.toString.call(e)+"]"}function v(e,t,r,n,o,i){var s,u,a;if((a=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?u=a.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):a.set&&(u=e.stylize("[Setter]","special")),U(n,o)||(s="["+o+"]"),u||(e.seen.indexOf(a.value)<0?(u=E(r)?d(e,a.value,null):d(e,a.value,r-1)).indexOf("\n")>-1&&(u=i?u.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+u.split("\n").map(function(e){return" "+e}).join("\n")):u=e.stylize("[Circular]","special")),O(s)){if(i&&o.match(/^\d+$/))return u;(s=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+u}function w(e){return Array.isArray(e)}function b(e){return"boolean"==typeof e}function E(e){return null===e}function x(e){return"number"==typeof e}function S(e){return"string"==typeof e}function O(e){return void 0===e}function j(e){return A(e)&&"[object RegExp]"===k(e)}function A(e){return"object"==typeof e&&null!==e}function T(e){return A(e)&&"[object Date]"===k(e)}function I(e){return A(e)&&("[object Error]"===k(e)||e instanceof Error)}function B(e){return"function"==typeof e}function k(e){return Object.prototype.toString.call(e)}function R(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(O(f)&&(f=o.env.NODE_DEBUG||""),e=e.toUpperCase(),!p[e])if(new RegExp("\\b"+e+"\\b","i").test(f)){var r=o.pid;p[e]=function(){var n=t.format.apply(t,arguments);s.error("%s %d: %s",e,r,n)}}else p[e]=function(){};return p[e]},t.inspect=h,h.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},h.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=w,t.isBoolean=b,t.isNull=E,t.isNullOrUndefined=function(e){return null==e},t.isNumber=x,t.isString=S,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=O,t.isRegExp=j,t.isObject=A,t.isDate=T,t.isError=I,t.isFunction=B,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=c(2);var _=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function U(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,r;s.log("%s - %s",(e=new Date,r=[R(e.getHours()),R(e.getMinutes()),R(e.getSeconds())].join(":"),[e.getDate(),_[e.getMonth()],r].join(" ")),t.format.apply(t,arguments))},t.inherits=c(3),t._extend=function(e,t){if(!t||!A(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}}],["util","/support/isBufferBrowser.js",function(e,t,r,n,o,i){r.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}}],["inherits","/inherits_browser.js",function(e,t,r,n,o,i){"function"==typeof Object.create?r.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:r.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}]],f=[];function c(e){if(e>>>0!==e||e>l.length)return function(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}(e);for(;f.length<=e;)f.push(null);var o=f[e];if(o)return o.exports;var s=l[e],a=s[0],c=s[1],p=s[2],h=i,g=u,y=r,d=t,m=n;0!==e&&(m={id:"/"+a+c,exports:d={},parent:n,filename:h,loaded:!1,children:n.children,paths:n.paths,require:n.require}),f[e]=m;try{p.call(d,d,y,m,h,g,void 0)}catch(t){throw delete f[e],t}return 0!==e&&(m.loaded=!0),m.exports}c(0)}]],a=[];function l(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}function f(e){l(e)}function c(e,t){if(e>>>0!==e||e>u.length)return l(e);if(null!=t&&!t.children)return l(e);for(;a.length<=e;)a.push(null);var r=a[e];if(r)return r.exports;var n=u[e],o=n[0],i=n[1],s=n[2],c=i,p=c.split("/").slice(0,-1).join("/")||"/",h=f,g={},y={id:"/"+o+i,exports:g,parent:t,filename:c,loaded:!1,children:[],paths:["/"],require:h};t&&t.children.push(y),0===e&&(h.main=y),a[e]=y;try{s.call(g,g,h,y,c,p,void 0)}catch(t){throw delete a[e],t}return y.loaded=!0,y.exports}f.resolve=l,f.main=null,f.extensions={__proto__:null},f.cache={__proto__:null},t=c(5,null),r=t.setTimeout,n=t.clearTimeout,t.setInterval,t.clearInterval,t.setImmediate,t.clearImmediate,o=c(6,null),i=c(7,null).Buffer,s=c(8,null);var p=c(0,null);"function"==typeof define&&define.amd?define("LOGGER",[],function(){return p}):"object"==typeof module&&module&&"object"==typeof module.exports&&module.exports?module.exports=p:e.LOGGER=p}("undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")()); 2 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mobilebcoin", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "bfile": { 8 | "version": "0.1.4", 9 | "resolved": "https://registry.npmjs.org/bfile/-/bfile-0.1.4.tgz", 10 | "integrity": "sha512-pqeG3lJbWAlYlphNzMQA/VeUNGaq7Zopvzl8hbYXzIXLIFdPqC2h2hCbZHzRlLnnaUfipmuqwWYr3qbulbuu6Q==" 11 | }, 12 | "binet": { 13 | "version": "0.3.5", 14 | "resolved": "https://registry.npmjs.org/binet/-/binet-0.3.5.tgz", 15 | "integrity": "sha512-suogkqXrt63Z76ABvwJjI28w+LWrRE53nwItDPz1VwNjHEuh1+rxudGYtoewFmMhkJ9pW/VGGnjoxP+AGzHgLQ==", 16 | "requires": { 17 | "bs32": "~0.1.5", 18 | "bsert": "~0.0.10" 19 | }, 20 | "dependencies": { 21 | "bsert": { 22 | "version": "0.0.10", 23 | "resolved": "https://registry.npmjs.org/bsert/-/bsert-0.0.10.tgz", 24 | "integrity": "sha512-NHNwlac+WPy4t2LoNh8pXk8uaIGH3NSaIUbTTRXGpE2WEbq0te/tDykYHkFK57YKLPjv/aGHmbqvnGeVWDz57Q==" 25 | } 26 | } 27 | }, 28 | "bs32": { 29 | "version": "0.1.5", 30 | "resolved": "https://registry.npmjs.org/bs32/-/bs32-0.1.5.tgz", 31 | "integrity": "sha512-YR9OXFjx8qmW/TpuJKc1RSdzRogpCYh1ygCSMi5Z3fG2QkP+Ra1IfcHsICqd/I/tmFAtc7ov8BpEyN8HJD7jlw==", 32 | "requires": { 33 | "bsert": "~0.0.10" 34 | }, 35 | "dependencies": { 36 | "bsert": { 37 | "version": "0.0.10", 38 | "resolved": "https://registry.npmjs.org/bsert/-/bsert-0.0.10.tgz", 39 | "integrity": "sha512-NHNwlac+WPy4t2LoNh8pXk8uaIGH3NSaIUbTTRXGpE2WEbq0te/tDykYHkFK57YKLPjv/aGHmbqvnGeVWDz57Q==" 40 | } 41 | } 42 | }, 43 | "bsert": { 44 | "version": "0.0.8", 45 | "resolved": "https://registry.npmjs.org/bsert/-/bsert-0.0.8.tgz", 46 | "integrity": "sha512-MzSxGNGymvJ2wAJ0lrC2cT+Irq2q+EMz5ijt8qXIxt02VoO+ZFWPNrmzNHGq6F8RJnIzzRmKz8mv1/j2xU1TQg==" 47 | }, 48 | "bsock": { 49 | "version": "0.1.5", 50 | "resolved": "https://registry.npmjs.org/bsock/-/bsock-0.1.5.tgz", 51 | "integrity": "sha512-Q41VI1jX3hVbv8NBz+/HCvJXEN2/WVeXUJzooLE69LmVdsdwbN77v0pd5Efvz5+JNASV8iESfxitvdx/uknfNQ==", 52 | "requires": { 53 | "bsert": "~0.0.8" 54 | } 55 | }, 56 | "bval": { 57 | "version": "0.1.5", 58 | "resolved": "https://registry.npmjs.org/bval/-/bval-0.1.5.tgz", 59 | "integrity": "sha512-PN7Ps7MHrFk7H1cT/mvRsa8J3bx1MrApxDXZx3kee4hCjDns2v89rWO8wnuEcLEVZvNqayjKm6ATia9FRtd2aw==", 60 | "requires": { 61 | "bsert": "~0.0.8" 62 | } 63 | }, 64 | "bweb": { 65 | "version": "0.1.7", 66 | "resolved": "https://registry.npmjs.org/bweb/-/bweb-0.1.7.tgz", 67 | "integrity": "sha512-mvjXvyvbe3TPQ5AW0K4kgfAMgkyCj3/JhTzl5+pJsOv+SvdXNeJsafruVubfj28PTXfVD08SH9EEuKrtsUYCHA==", 68 | "requires": { 69 | "bsert": "~0.0.8", 70 | "bsock": "~0.1.5" 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mobilebcoin", 3 | "version": "1.0.0", 4 | "description": "bcoin full node in a mobile browser", 5 | "main": "index.html", 6 | "dependencies": { 7 | "bval": "^0.1.5", 8 | "bfile": "^0.1.4", 9 | "bweb": "^0.1.7", 10 | "binet": "^0.3.4", 11 | "bsock": "^0.1.5" 12 | }, 13 | "devDependencies": {}, 14 | "scripts": { 15 | "test": "echo \"Error: no test specified\" && exit 1", 16 | "start": "node server.js" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/pinheadmz/mobilebcoin.git" 21 | }, 22 | "author": "Matthew Zipkin", 23 | "license": "MIT", 24 | "bugs": { 25 | "url": "https://github.com/pinheadmz/mobilebcoin/issues" 26 | }, 27 | "homepage": "https://github.com/pinheadmz/mobilebcoin#readme" 28 | } 29 | -------------------------------------------------------------------------------- /server-local.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const bweb = require('bweb'); 4 | const fs = require('bfile'); 5 | const Validator = require('bval'); 6 | const WSProxy = require('./wsproxy'); 7 | 8 | const index = fs.readFileSync(`${__dirname}/index.html`); 9 | 10 | const proxy = new WSProxy({ 11 | ports: [12038, 13038, 14038, 15038, 44806, 45806, 46806, 47806] 12 | }); 13 | 14 | const server = bweb.server({ 15 | host: '0.0.0.0', 16 | port: 80, 17 | sockets: false, 18 | ssl: false 19 | }); 20 | 21 | // redirect.use(redirect.router()); 22 | // redirect.get('*', (req, res) => { 23 | // res.redirect('https://easyhandshake.com/'); 24 | // }); 25 | 26 | // const server = bweb.server({ 27 | // host: '0.0.0.0', 28 | // port: 443, 29 | // sockets: false, 30 | // ssl: true, 31 | // keyFile: '/etc/letsencrypt/live/easyhandshake.com/privkey.pem', 32 | // certFile: '/etc/letsencrypt/live/easyhandshake.com/fullchain.pem' 33 | // }); 34 | 35 | server.use(server.router()); 36 | 37 | server.on('error', (err) => { 38 | console.error(err.stack); 39 | }); 40 | 41 | server.get('/', (req, res) => { 42 | res.send(200, index, 'html'); 43 | }); 44 | 45 | server.get('/favicon.ico', (req, res) => { 46 | res.send(404); 47 | }); 48 | 49 | server.get('/:file', (req, res) => { 50 | const valid = Validator.fromRequest(req); 51 | const file = valid.str('file'); 52 | res.send(200, getFile(file)); 53 | }); 54 | 55 | proxy.attach(server.http); 56 | 57 | // redirect.open(); 58 | server.open(); 59 | 60 | function getFile(file) { 61 | return fs.readFileSync(`${__dirname}/${file}`); 62 | } 63 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const bweb = require('bweb'); 4 | const fs = require('bfile'); 5 | const Validator = require('bval'); 6 | const WSProxy = require('./wsproxy'); 7 | 8 | const index = fs.readFileSync(`${__dirname}/index.html`); 9 | 10 | const proxy = new WSProxy({ 11 | ports: [12038, 13038, 14038, 15038, 44806, 45806, 46806, 47806] 12 | }); 13 | 14 | const redirect = bweb.server({ 15 | host: '0.0.0.0', 16 | port: 80, 17 | sockets: false, 18 | ssl: false 19 | }); 20 | 21 | redirect.use(redirect.router()); 22 | redirect.get('*', (req, res) => { 23 | res.redirect('https://easyhandshake.com/'); 24 | }); 25 | 26 | const server = bweb.server({ 27 | host: '0.0.0.0', 28 | port: 443, 29 | sockets: false, 30 | ssl: true, 31 | keyFile: '/etc/letsencrypt/live/easyhandshake.com/privkey.pem', 32 | certFile: '/etc/letsencrypt/live/easyhandshake.com/fullchain.pem' 33 | }); 34 | 35 | server.use(server.router()); 36 | 37 | server.on('error', (err) => { 38 | console.error('Server error:', err.stack); 39 | }); 40 | 41 | redirect.on('error', (err) => { 42 | console.error('Redirect error:', err.stack); 43 | }); 44 | 45 | server.get('/', (req, res) => { 46 | res.send(200, index, 'html'); 47 | }); 48 | 49 | server.get('/favicon.ico', (req, res) => { 50 | res.send(404); 51 | }); 52 | 53 | server.get('/:file', (req, res) => { 54 | const valid = Validator.fromRequest(req); 55 | const file = valid.str('file'); 56 | res.send(200, getFile(file)); 57 | }); 58 | 59 | proxy.attach(server.http); 60 | 61 | redirect.open(); 62 | server.open(); 63 | 64 | function getFile(file) { 65 | return fs.readFileSync(`${__dirname}/${file}`); 66 | } 67 | -------------------------------------------------------------------------------- /sha3.js: -------------------------------------------------------------------------------- 1 | !function(t){var e=void 0,r=t.console,n=[["bcrypto","/lib/js/sha3.js",function(t,r,n,o,i,u){"use strict";const f=s(1,n);class a extends f{constructor(){super()}final(){return super.final(6,null)}static hash(){return new a}static hmac(t=256){return super.hmac(t,6,null)}static digest(t,e=256){return super.digest(t,e,6,null)}static root(t,e,r=256){return super.root(t,e,r,6,null)}static multi(t,e,r,n=256){return super.multi(t,e,r,n,6,null)}static mac(t,e,r=256){return super.mac(t,e,r,6,null)}}a.native=0,a.id="SHA3_256",a.size=32,a.bits=256,a.blockSize=136,a.zero=e.alloc(32,0),a.ctx=new a,n.exports=a}],["bcrypto","/lib/js/keccak.js",function(t,r,n,o,i,u){"use strict";const f=s(2,n),a=s(3,n),c=2147483648,l=new Uint32Array([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]);class p{constructor(){this.state=new Uint32Array(50),this.block=e.allocUnsafe(168),this.bs=136,this.pos=c}init(t=256){f((65535&t)===t),f(t>=128),f(t<=512);const e=1600-2*t;return f(e>=0&&0==(63&e)),this.bs=e/8,this.pos=0,this}update(t){f(e.isBuffer(t)),f(!(this.pos&c),"Context already finalized.");let r=t.length,n=this.pos,o=0;if(this.pos=(this.pos+r)%this.bs,n>0){let e=this.bs-n;if(e>r&&(e=r),t.copy(this.block,n,o,o+e),r-=e,o+=e,(n+=e)=this.bs;)this.transform(t,o),o+=this.bs,r-=this.bs;return r>0&&t.copy(this.block,0,o,o+r),this}final(t=1,r){null==r&&(r=0),0===r&&(r=100-this.bs/2),f((255&t)===t),f(r>>>0===r),f(!(this.pos&c),"Context already finalized."),this.block.fill(0,this.pos,this.bs),this.block[this.pos]|=t,this.block[this.bs-1]|=128,this.transform(this.block,0),this.pos=c,f(r>>2]>>>8*(3&t);for(let t=0;t<50;t++)this.state[t]=0;for(let t=0;t>>31),y=p^(i<<1|o>>>31),n[0]^=h,n[1]^=y,n[10]^=h,n[11]^=y,n[20]^=h,n[21]^=y,n[30]^=h,n[31]^=y,n[40]^=h,n[41]^=y,h=e^(u<<1|s>>>31),y=r^(s<<1|u>>>31),n[2]^=h,n[3]^=y,n[12]^=h,n[13]^=y,n[22]^=h,n[23]^=y,n[32]^=h,n[33]^=y,n[42]^=h,n[43]^=y,h=o^(f<<1|a>>>31),y=i^(a<<1|f>>>31),n[4]^=h,n[5]^=y,n[14]^=h,n[15]^=y,n[24]^=h,n[25]^=y,n[34]^=h,n[35]^=y,n[44]^=h,n[45]^=y,h=u^(c<<1|p>>>31),y=s^(p<<1|c>>>31),n[6]^=h,n[7]^=y,n[16]^=h,n[17]^=y,n[26]^=h,n[27]^=y,n[36]^=h,n[37]^=y,n[46]^=h,n[47]^=y,h=f^(e<<1|r>>>31),y=a^(r<<1|e>>>31),n[8]^=h,n[9]^=y,n[18]^=h,n[19]^=y,n[28]^=h,n[29]^=y,n[38]^=h,n[39]^=y,n[48]^=h,n[49]^=y;const g=n[0],d=n[1],w=n[11]<<4|n[10]>>>28,b=n[10]<<4|n[11]>>>28,m=n[20]<<3|n[21]>>>29,v=n[21]<<3|n[20]>>>29,E=n[31]<<9|n[30]>>>23,x=n[30]<<9|n[31]>>>23,S=n[40]<<18|n[41]>>>14,O=n[41]<<18|n[40]>>>14,j=n[2]<<1|n[3]>>>31,A=n[3]<<1|n[2]>>>31,B=n[13]<<12|n[12]>>>20,k=n[12]<<12|n[13]>>>20,U=n[22]<<10|n[23]>>>22,T=n[23]<<10|n[22]>>>22,_=n[33]<<13|n[32]>>>19,z=n[32]<<13|n[33]>>>19,M=n[42]<<2|n[43]>>>30,D=n[43]<<2|n[42]>>>30,I=n[5]<<30|n[4]>>>2,R=n[4]<<30|n[5]>>>2,C=n[14]<<6|n[15]>>>26,N=n[15]<<6|n[14]>>>26,F=n[25]<<11|n[24]>>>21,q=n[24]<<11|n[25]>>>21,P=n[34]<<15|n[35]>>>17,L=n[35]<<15|n[34]>>>17,$=n[45]<<29|n[44]>>>3,J=n[44]<<29|n[45]>>>3,H=n[6]<<28|n[7]>>>4,G=n[7]<<28|n[6]>>>4,V=n[17]<<23|n[16]>>>9,Y=n[16]<<23|n[17]>>>9,Z=n[26]<<25|n[27]>>>7,K=n[27]<<25|n[26]>>>7,W=n[36]<<21|n[37]>>>11,X=n[37]<<21|n[36]>>>11,Q=n[47]<<24|n[46]>>>8,tt=n[46]<<24|n[47]>>>8,et=n[8]<<27|n[9]>>>5,rt=n[9]<<27|n[8]>>>5,nt=n[18]<<20|n[19]>>>12,ot=n[19]<<20|n[18]>>>12,it=n[29]<<7|n[28]>>>25,ut=n[28]<<7|n[29]>>>25,st=n[38]<<8|n[39]>>>24,ft=n[39]<<8|n[38]>>>24,at=n[48]<<14|n[49]>>>18,ct=n[49]<<14|n[48]>>>18;n[0]=g^~B&F,n[1]=d^~k&q,n[10]=H^~nt&m,n[11]=G^~ot&v,n[20]=j^~C&Z,n[21]=A^~N&K,n[30]=et^~w&U,n[31]=rt^~b&T,n[40]=I^~V&it,n[41]=R^~Y&ut,n[2]=B^~F&W,n[3]=k^~q&X,n[12]=nt^~m&_,n[13]=ot^~v&z,n[22]=C^~Z&st,n[23]=N^~K&ft,n[32]=w^~U&P,n[33]=b^~T&L,n[42]=V^~it&E,n[43]=Y^~ut&x,n[4]=F^~W&at,n[5]=q^~X&ct,n[14]=m^~_&$,n[15]=v^~z&J,n[24]=Z^~st&S,n[25]=K^~ft&O,n[34]=U^~P&Q,n[35]=T^~L&tt,n[44]=it^~E&M,n[45]=ut^~x&D,n[6]=W^~at&g,n[7]=X^~ct&d,n[16]=_^~$&H,n[17]=z^~J&G,n[26]=st^~S&j,n[27]=ft^~O&A,n[36]=P^~Q&et,n[37]=L^~tt&rt,n[46]=E^~M&I,n[47]=x^~D&R,n[8]=at^~g&B,n[9]=ct^~d&k,n[18]=$^~H&nt,n[19]=J^~G&ot,n[28]=S^~j&C,n[29]=O^~A&N,n[38]=Q^~et&w,n[39]=tt^~rt&b,n[48]=M^~I&V,n[49]=D^~R&Y,n[0]^=l[t],n[1]^=l[t+1]}}static hash(){return new p}static hmac(t=256,e=1,r){return f(t>>>0===t),new a(p,(1600-2*t)/8,[t],[e,r])}static digest(t,e=256,r=1,n){return p.ctx.init(e).update(t).final(r,n)}static root(t,r,n=256,o=1,i){return null==i&&(i=0),0===i&&(f(n>>>0===n),i=n>>>3),f(i>>>0===i),f(e.isBuffer(t)&&t.length===i),f(e.isBuffer(r)&&r.length===i),p.ctx.init(n).update(t).update(r).final(o,i)}static multi(t,e,r,n=256,o=1,i){const u=p.ctx;return u.init(n),u.update(t),u.update(e),r&&u.update(r),u.final(o,i)}static mac(t,e,r=256,n=1,o){return p.hmac(r,n,o).init(e).update(t).final()}}function h(t,e){return t[e++]+256*t[e++]+65536*t[e++]+16777216*t[e]}p.native=0,p.id="KECCAK256",p.size=32,p.bits=256,p.blockSize=136,p.zero=e.alloc(32,0),p.ctx=new p,n.exports=p}],["bsert","/lib/assert.js",function(t,e,r,n,o,i){"use strict";class u extends Error{constructor(t){"string"==typeof t&&(t={message:t}),null!==t&&"object"==typeof t||(t={});let e=null,r="fail",n=Boolean(t.generatedMessage);var o;if(null!=t.message&&(e="string"==typeof(o=t.message)?o:O(o)?w(o):d(o)),"string"==typeof t.operator&&(r=t.operator),null==e){if("fail"===r)e="Assertion failed.";else{e=`${d(t.actual)} ${r} ${d(t.expected)}`}n=!0}super(e);let i=this.constructor;"function"==typeof t.stackStartFunction?i=t.stackStartFunction:"function"==typeof t.stackStartFn&&(i=t.stackStartFn),this.type="AssertionError",this.name="AssertionError [ERR_ASSERTION]",this.code="ERR_ASSERTION",this.generatedMessage=n,this.actual=t.actual,this.expected=t.expected,this.operator=r,Error.captureStackTrace&&Error.captureStackTrace(this,i)}}function s(t,e){if(!t){let r=!1;if(0===arguments.length)e="No value argument passed to `assert()`.",r=!0;else if(null==e)e="Assertion failed.",r=!0;else if(O(e))throw e;throw new u({message:e,actual:t,expected:!0,operator:"==",generatedMessage:r,stackStartFn:s})}}function f(t,e,r){if(!Object.is(t,e)){if(O(r))throw r;throw new u({message:r,actual:t,expected:e,operator:"strictEqual",stackStartFn:f})}}function a(t,e,r){if(Object.is(t,e)){if(O(r))throw r;throw new u({message:r,actual:t,expected:e,operator:"notStrictEqual",stackStartFn:a})}}function c(t,e,r){"string"==typeof e&&(r=e,e=void 0);let n=!1,o=null;g("function"==typeof t,"func","function");try{t()}catch(t){n=!0,o=t}if(n){if(b(o,e,r,c)){let t=!1;throw null==r&&(r="Got unwanted exception.",t=!0),new u({message:r,actual:o,expected:e,operator:"doesNotThrow",generatedMessage:t,stackStartFn:c})}throw o}}async function l(t,e,r){"string"==typeof e&&(r=e,e=void 0);let n=!1,o=null;"function"!=typeof t&&g(A(t),"func","promise");try{A(t)?await t:await t()}catch(t){n=!0,o=t}if(!n){let t=!1;throw null==r&&(r="Missing expected rejection.",t=!0),new u({message:r,actual:void 0,expected:e,operator:"rejects",generatedMessage:t,stackStartFn:l})}if(!b(o,e,r,l))throw o}async function p(t,e,r){"string"==typeof e&&(r=e,e=void 0);let n=!1,o=null;"function"!=typeof t&&g(A(t),"func","promise");try{A(t)?await t:await t()}catch(t){n=!0,o=t}if(n){if(b(o,e,r,p)){let t=!1;throw null==r&&(r="Got unwanted rejection.",t=!0),new u({message:r,actual:void 0,expected:e,operator:"doesNotReject",generatedMessage:t,stackStartFn:p})}throw o}}function h(t,e,r){if(!m(t,e,!1)){if(O(r))throw r;throw new u({message:r,actual:t,expected:e,operator:"deepStrictEqual",stackStartFn:h})}}function y(t,e,r){if(m(t,e,!0)){if(O(r))throw r;throw new u({message:r,actual:t,expected:e,operator:"notDeepStrictEqual",stackStartFn:y})}}function g(t,e,r){if(!t){let t;t=null==e?"Invalid type for parameter.":null==r?`Invalid type for "${e}".`:`"${e}" must be a(n) ${r}.`;const n=new TypeError(t);throw Error.captureStackTrace&&Error.captureStackTrace(n,g),n}}function d(t){switch(typeof t){case"undefined":return"undefined";case"object":return null===t?"null":`[${function(t){const e=function(t){return x(t).slice(8,-1)}(t);if(null==t)return e;if("Object"!==e&&"Error"!==e)return e;let r,n;try{r=t.constructor}catch(t){}if(null==r)return e;try{n=r.name}catch(t){return e}return"string"!=typeof n||0===n.length?e:n}(t)}]`;case"boolean":case"number":return`${t}`;case"string":return t.length>80&&(t=`${t.substring(0,77)}...`),JSON.stringify(t);case"symbol":return w(t);case"function":return`[${function(t){let e;try{e=t.name}catch(t){}return"string"!=typeof e||0===e.length?"Function":`Function: ${e}`}(t)}]`;case"bigint":return`${t}n`;default:return`[${typeof t}]`}}function w(t){try{return String(t)}catch(t){return"Object"}}function b(t,e,r,n){if(null==e)return!0;if(B(e))return e.test(t);if("function"!=typeof e){if(n===c||n===p)throw new TypeError('"expected" must not be an object.');if("object"!=typeof e)throw new TypeError('"expected" must be an object.');let o=!1;if(null==r){r=`Missing expected ${n===l?"rejection":"exception"}.`,o=!0}if(null==t||"object"!=typeof t)throw new u({actual:t,expected:e,message:r,operator:n.name,generatedMessage:o,stackStartFn:n});const i=Object.keys(e);if(O(e)&&i.push("name","message"),0===i.length)throw new TypeError('"expected" may not be an empty object.');for(const s of i){const i=e[s],f=t[s];if(("string"!=typeof f||!B(i)||!i.test(f))&&!(s in t&&m(f,i,!1)))throw new u({actual:t,expected:e,message:r,operator:n.name,generatedMessage:o,stackStartFn:n})}return!0}return void 0!==e.prototype&&t instanceof e||!Error.isPrototypeOf(e)&&!0===e.call({},t)}function m(t,e,r){try{return v(t,e,null)}catch(t){return r}}function v(t,e,r){if(Object.is(t,e))return!0;if(!j(t)||!j(e))return!1;if(x(t)!==x(e))return!1;if(Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;if(S(t)&&S(e))return t.equals(e);if(t instanceof Date)return Object.is(t.getTime(),e.getTime());if(B(t))return t.source===e.source&&t.global===e.global&&t.multiline===e.multiline&&t.lastIndex===e.lastIndex&&t.ignoreCase===e.ignoreCase;if(O(t)&&t.message!==e.message)return!1;if(function(t){return t instanceof ArrayBuffer}(t)&&(t=new Uint8Array(t),e=new Uint8Array(e)),function(t){return ArrayBuffer.isView(t)}(t)&&!S(t)){if(S(e))return!1;const r=new Uint8Array(t.buffer),n=new Uint8Array(e.buffer);if(r.length!==n.length)return!1;for(let t=0;t>>1?null:o}return e}s.AssertionError=u,s.assert=s,s.strict=s,s.ok=s,s.equal=f,s.notEqual=a,s.strictEqual=f,s.notStrictEqual=a,s.fail=function t(e){let r=!1;if(O(e))throw e;throw null==e&&(e="Assertion failed.",r=!0),new u({message:e,actual:!1,expected:!0,operator:"fail",generatedMessage:r,stackStartFn:t})},s.throws=function t(e,r,n){"string"==typeof r&&(n=r,r=void 0);let o=!1,i=null;g("function"==typeof e,"func","function");try{e()}catch(t){o=!0,i=t}if(!o){let e=!1;throw null==n&&(n="Missing expected exception.",e=!0),new u({message:n,actual:void 0,expected:r,operator:"throws",generatedMessage:e,stackStartFn:t})}if(!b(i,r,n,t))throw i},s.doesNotThrow=c,s.rejects=l,s.doesNotReject=p,s.ifError=function t(e){if(null!=e){let r="ifError got unwanted exception: ";throw"object"==typeof e&&"string"==typeof e.message?0===e.message.length&&e.constructor?r+=e.constructor.name:r+=e.message:r+=d(e),new u({message:r,actual:e,expected:null,operator:"ifError",generatedMessage:!0,stackStartFn:t})}},s.deepEqual=h,s.notDeepEqual=y,s.deepStrictEqual=h,s.notDeepStrictEqual=y,s.bufferEqual=function t(e,r,n,o){if(k(n)||(o=n,n=null),null==n&&(n="hex"),r=U(e,r,n),g(S(e),"actual","buffer"),g(S(r),"expected","buffer"),e!==r&&!e.equals(r)){if(O(o))throw o;throw new u({message:o,actual:e.toString(n),expected:r.toString(n),operator:"bufferEqual",stackStartFn:t})}},s.notBufferEqual=function t(e,r,n,o){if(k(n)||(o=n,n=null),null==n&&(n="hex"),r=U(e,r,n),g(S(e),"actual","buffer"),g(S(r),"expected","buffer"),e===r||e.equals(r)){if(O(o))throw o;throw new u({message:o,actual:e.toString(n),expected:r.toString(n),operator:"notBufferEqual",stackStartFn:t})}},s.enforce=g,s.range=function t(e,r){if(!e){const e=null!=r?`"${r}" is out of range.`:"Parameter is out of range.",n=new RangeError(e);throw Error.captureStackTrace&&Error.captureStackTrace(n,t),n}},r.exports=s}],["bcrypto","/lib/internal/hmac.js",function(t,r,n,o,i,u){"use strict";const f=s(2,n);n.exports=class{constructor(t,e,r=[],n=[]){f("function"==typeof t),f(e>>>0===e),f(Array.isArray(r)),f(Array.isArray(n)),this.hash=t,this.size=e,this.x=r,this.y=n,this.inner=new t,this.outer=new t}init(t){if(f(e.isBuffer(t)),t.length>this.size){const e=new(0,this.hash);e.init(...this.x),e.update(t),t=e.final(...this.y),f(t.length<=this.size)}const r=e.allocUnsafe(this.size);for(let e=0;ec)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return e.__proto__=p.prototype,e}function p(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return g(t)}return h(t,e,r)}function h(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!p.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|b(t,e),n=l(r),o=n.write(t,e);o!==r&&(n=n.slice(0,o));return n}(t,e);if(ArrayBuffer.isView(t))return d(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(H(t,ArrayBuffer)||t&&H(t.buffer,ArrayBuffer))return function(t,e,r){if(e<0||t.byteLength=c)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+c.toString(16)+" bytes");return 0|t}function b(t,e){if(p.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||H(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return L(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return $(t).length;default:if(o)return n?-1:L(t).length;e=(""+e).toLowerCase(),o=!0}}function m(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),G(r=+r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=p.from(e,n)),p.isBuffer(e))return 0===e.length?-1:E(t,e,r,n,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):E(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function E(t,e,r,n,o){var i,u=1,s=t.length,f=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;u=2,s/=2,f/=2,r/=2}function a(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(o){var c=-1;for(i=r;is&&(r=s-f),i=r;i>=0;i--){for(var l=!0,p=0;po&&(n=o):n=o;var i=e.length;n>i/2&&(n=i/2);for(var u=0;u>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function k(t,e,r){return 0===e&&r===t.length?s.fromByteArray(t):s.fromByteArray(t.slice(e,r))}function U(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o239?4:a>223?3:a>191?2:1;if(o+l<=r)switch(l){case 1:a<128&&(c=a);break;case 2:128==(192&(i=t[o+1]))&&(f=(31&a)<<6|63&i)>127&&(c=f);break;case 3:i=t[o+1],u=t[o+2],128==(192&i)&&128==(192&u)&&(f=(15&a)<<12|(63&i)<<6|63&u)>2047&&(f<55296||f>57343)&&(c=f);break;case 4:i=t[o+1],u=t[o+2],s=t[o+3],128==(192&i)&&128==(192&u)&&128==(192&s)&&(f=(15&a)<<18|(63&i)<<12|(63&u)<<6|63&s)>65535&&f<1114112&&(c=f)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),o+=l}return function(t){var e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return M(this,e,r);case"utf8":case"utf-8":return U(this,e,r);case"ascii":return _(this,e,r);case"latin1":case"binary":return z(this,e,r);case"base64":return k(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},p.prototype.toLocaleString=p.prototype.toString,p.prototype.equals=function(t){if(!p.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===p.compare(this,t)},p.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),""},p.prototype.compare=function(t,e,r,n,o){if(H(t,Uint8Array)&&(t=p.from(t,t.offset,t.byteLength)),!p.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,n>>>=0,o>>>=0,this===t)return 0;for(var i=o-n,u=r-e,s=Math.min(i,u),f=this.slice(n,o),a=t.slice(e,r),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return x(this,t,e,r);case"utf8":case"utf-8":return S(this,t,e,r);case"ascii":return O(this,t,e,r);case"latin1":case"binary":return j(this,t,e,r);case"base64":return A(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function _(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;on)&&(r=n);for(var o="",i=e;ir)throw new RangeError("Trying to access beyond buffer length")}function R(t,e,r,n,o,i){if(!p.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||et.length)throw new RangeError("Index out of range")}function C(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(t,e,r,n,o){return e=+e,r>>>=0,o||C(t,0,r,4),f.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||C(t,0,r,8),f.write(t,e,r,n,52,8),r+8}p.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||I(t,e,this.length);for(var n=this[t],o=1,i=0;++i>>=0,e>>>=0,r||I(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},p.prototype.readUInt8=function(t,e){return t>>>=0,e||I(t,1,this.length),this[t]},p.prototype.readUInt16LE=function(t,e){return t>>>=0,e||I(t,2,this.length),this[t]|this[t+1]<<8},p.prototype.readUInt16BE=function(t,e){return t>>>=0,e||I(t,2,this.length),this[t]<<8|this[t+1]},p.prototype.readUInt32LE=function(t,e){return t>>>=0,e||I(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},p.prototype.readUInt32BE=function(t,e){return t>>>=0,e||I(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},p.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);for(var n=this[t],o=1,i=0;++i=(o*=128)&&(n-=Math.pow(2,8*e)),n},p.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||I(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},p.prototype.readInt8=function(t,e){return t>>>=0,e||I(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},p.prototype.readInt16LE=function(t,e){t>>>=0,e||I(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},p.prototype.readInt16BE=function(t,e){t>>>=0,e||I(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},p.prototype.readInt32LE=function(t,e){return t>>>=0,e||I(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},p.prototype.readInt32BE=function(t,e){return t>>>=0,e||I(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},p.prototype.readFloatLE=function(t,e){return t>>>=0,e||I(t,4,this.length),f.read(this,t,!0,23,4)},p.prototype.readFloatBE=function(t,e){return t>>>=0,e||I(t,4,this.length),f.read(this,t,!1,23,4)},p.prototype.readDoubleLE=function(t,e){return t>>>=0,e||I(t,8,this.length),f.read(this,t,!0,52,8)},p.prototype.readDoubleBE=function(t,e){return t>>>=0,e||I(t,8,this.length),f.read(this,t,!1,52,8)},p.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||R(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i>>=0,r>>>=0,n)||R(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},p.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,1,255,0),this[e]=255&t,e+1},p.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},p.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},p.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},p.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},p.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);R(this,t,e,r,o-1,-o)}var i=0,u=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+r},p.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var o=Math.pow(2,8*r-1);R(this,t,e,r,o-1,-o)}var i=r-1,u=1,s=0;for(this[e+i]=255&t;--i>=0&&(u*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/u>>0)-s&255;return e+r},p.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},p.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},p.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},p.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},p.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},p.prototype.writeFloatLE=function(t,e,r){return N(this,t,e,!0,r)},p.prototype.writeFloatBE=function(t,e,r){return N(this,t,e,!1,r)},p.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},p.prototype.writeDoubleBE=function(t,e,r){return F(this,t,e,!1,r)},p.prototype.copy=function(t,e,r,n){if(!p.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return o},p.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!p.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var o=t.charCodeAt(0);("utf8"===n&&o<128||"latin1"===n)&&(t=o)}}else"number"==typeof t&&(t&=255);if(e<0||this.length>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(u+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function $(t){return s.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(q,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function J(t,e,r,n){for(var o=0;o=e.length||o>=t.length);++o)e[o+r]=t[o];return o}function H(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function G(t){return t!=t}}],["base64-js","/index.js",function(t,e,r,n,o,i){"use strict";t.byteLength=function(t){var e=p(t),r=e[0],n=e[1];return 3*(r+n)/4-n},t.toByteArray=function(t){for(var e,r=p(t),n=r[0],o=r[1],i=new f(function(t,e,r){return 3*(e+r)/4-r}(0,n,o)),u=0,a=o>0?n-4:n,c=0;c>16&255,i[u++]=e>>8&255,i[u++]=255&e;2===o&&(e=s[t.charCodeAt(c)]<<2|s[t.charCodeAt(c+1)]>>4,i[u++]=255&e);1===o&&(e=s[t.charCodeAt(c)]<<10|s[t.charCodeAt(c+1)]<<4|s[t.charCodeAt(c+2)]>>2,i[u++]=e>>8&255,i[u++]=255&e);return i},t.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],i=0,s=r-n;is?s:i+16383));1===n?(e=t[r-1],o.push(u[e>>2]+u[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(u[e>>10]+u[e>>4&63]+u[e<<2&63]+"="));return o.join("")};for(var u=[],s=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=0,l=a.length;c0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var n,o,i=[],s=e;s>18&63]+u[o>>12&63]+u[o>>6&63]+u[63&o]);return i.join("")}s["-".charCodeAt(0)]=62,s["_".charCodeAt(0)]=63}],["ieee754","/index.js",function(t,e,r,n,o,i){t.read=function(t,e,r,n,o){var i,u,s=8*o-n-1,f=(1<>1,c=-7,l=r?o-1:0,p=r?-1:1,h=t[e+l];for(l+=p,i=h&(1<<-c)-1,h>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=p,c-=8);for(u=i&(1<<-c)-1,i>>=-c,c+=n;c>0;u=256*u+t[e+l],l+=p,c-=8);if(0===i)i=1-a;else{if(i===f)return u?NaN:1/0*(h?-1:1);u+=Math.pow(2,n),i-=a}return(h?-1:1)*u*Math.pow(2,i-n)},t.write=function(t,e,r,n,o,i){var u,s,f,a=8*i-o-1,c=(1<>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:i-1,y=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,u=c):(u=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-u))<1&&(u--,f*=2),(e+=u+l>=1?p/f:p*Math.pow(2,1-l))*f>=2&&(u++,f/=2),u+l>=c?(s=0,u=c):u+l>=1?(s=(e*f-1)*Math.pow(2,o),u+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),u=0));o>=8;t[r+h]=255&s,h+=y,s/=256,o-=8);for(u=u<0;t[r+h]=255&u,h+=y,u/=256,a-=8);t[r+h-y]|=128*g}}]],f=[];function a(r){if(r>>>0!==r||r>s.length)return function(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}(r);for(;f.length<=r;)f.push(null);var u=f[r];if(u)return u.exports;var a=s[r],c=a[0],l=a[1],p=a[2],h=o,y=i,g=e,d=t,w=n;0!==r&&(w={id:"/"+c+l,exports:d={},parent:n,filename:h,loaded:!1,children:n.children,paths:n.paths,require:n.require}),f[r]=w;try{p.call(d,d,g,w,h,y,void 0)}catch(t){throw delete f[r],t}return 0!==r&&(w.loaded=!0),w.exports}a(0)}],["bpkg","/lib/builtins/console.js",function(e,r,n,o,i,u){var f=[["console-browserify","/index.js",function(e,r,n,o,i,u){var f,a=s(6,n),l=s(7,n),p=c(1),h=Array.prototype.slice,y={};f=void 0!==t&&t.console?t.console:"undefined"!=typeof window&&window.console?window.console:{};for(var g=[[function(){},"log"],[function(){f.log.apply(f,arguments)},"info"],[function(){f.log.apply(f,arguments)},"warn"],[function(){f.warn.apply(f,arguments)},"error"],[function(t){y[t]=p()},"time"],[function(t){var e=y[t];if(!e)throw new Error("No such label: "+t);var r=p()-e;f.log(t+": "+r+"ms")},"timeEnd"],[function(){var t=new Error;t.name="Trace",t.message=a.format.apply(null,arguments),f.error(t.stack)},"trace"],[function(t){f.log(a.inspect(t)+"\n")},"dir"],[function(t){if(!t){var e=h.call(arguments,1);l.ok(!1,a.format.apply(null,e))}},"assert"]],d=0;d>>0!==t||t>f.length)return function(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}(t);for(;a.length<=t;)a.push(null);var u=a[t];if(u)return u.exports;var s=f[t],c=s[0],l=s[1],p=s[2],h=o,y=i,g=r,d=e,w=n;0!==t&&(w={id:"/"+c+l,exports:d={},parent:n,filename:h,loaded:!1,children:n.children,paths:n.paths,require:n.require}),a[t]=w;try{p.call(d,d,g,w,h,y,void 0)}catch(e){throw delete a[t],e}return 0!==t&&(w.loaded=!0),w.exports}c(0)}],["bpkg","/lib/builtins/util.js",function(t,e,n,o,i,u){var s=[["util","/util.js",function(t,e,n,o,i,u){var s=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},n=0;n=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),m(r)?n.showHidden=r:r&&t._extend(n,r),S(n.showHidden)&&(n.showHidden=!1),S(n.depth)&&(n.depth=2),S(n.colors)&&(n.colors=!1),S(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=h),g(n,e,n.depth)}function h(t,e){var r=p.styles[e];return r?"["+p.colors[r][0]+"m"+t+"["+p.colors[r][1]+"m":t}function y(t,e){return t}function g(e,r,n){if(e.customInspect&&r&&k(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var o=r.inspect(n,e);return x(o)||(o=g(e,o,n)),o}var i=function(t,e){if(S(e))return t.stylize("undefined","undefined");if(x(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(E(e))return t.stylize(""+e,"number");if(m(e))return t.stylize(""+e,"boolean");if(v(e))return t.stylize("null","null")}(e,r);if(i)return i;var u=Object.keys(r),s=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(u);if(e.showHidden&&(u=Object.getOwnPropertyNames(r)),B(r)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return d(r);if(0===u.length){if(k(r)){var f=r.name?": "+r.name:"";return e.stylize("[Function"+f+"]","special")}if(O(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(A(r))return e.stylize(Date.prototype.toString.call(r),"date");if(B(r))return d(r)}var a,c="",l=!1,p=["{","}"];(b(r)&&(l=!0,p=["[","]"]),k(r))&&(c=" [Function"+(r.name?": "+r.name:"")+"]");return O(r)&&(c=" "+RegExp.prototype.toString.call(r)),A(r)&&(c=" "+Date.prototype.toUTCString.call(r)),B(r)&&(c=" "+d(r)),0!==u.length||l&&0!=r.length?n<0?O(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),a=l?function(t,e,r,n,o){for(var i=[],u=0,s=e.length;u=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(a,c,p)):p[0]+c+p[1]}function d(t){return"["+Error.prototype.toString.call(t)+"]"}function w(t,e,r,n,o,i){var u,s,f;if((f=Object.getOwnPropertyDescriptor(e,o)||{value:e[o]}).get?s=f.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):f.set&&(s=t.stylize("[Setter]","special")),z(n,o)||(u="["+o+"]"),s||(t.seen.indexOf(f.value)<0?(s=v(r)?g(t,f.value,null):g(t,f.value,r-1)).indexOf("\n")>-1&&(s=i?s.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n")):s=t.stylize("[Circular]","special")),S(u)){if(i&&o.match(/^\d+$/))return s;(u=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=t.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=t.stylize(u,"string"))}return u+": "+s}function b(t){return Array.isArray(t)}function m(t){return"boolean"==typeof t}function v(t){return null===t}function E(t){return"number"==typeof t}function x(t){return"string"==typeof t}function S(t){return void 0===t}function O(t){return j(t)&&"[object RegExp]"===U(t)}function j(t){return"object"==typeof t&&null!==t}function A(t){return j(t)&&"[object Date]"===U(t)}function B(t){return j(t)&&("[object Error]"===U(t)||t instanceof Error)}function k(t){return"function"==typeof t}function U(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}t.debuglog=function(e){if(S(c)&&(c=process.env.NODE_DEBUG||""),e=e.toUpperCase(),!l[e])if(new RegExp("\\b"+e+"\\b","i").test(c)){var n=process.pid;l[e]=function(){var o=t.format.apply(t,arguments);r.error("%s %d: %s",e,n,o)}}else l[e]=function(){};return l[e]},t.inspect=p,p.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},p.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=b,t.isBoolean=m,t.isNull=v,t.isNullOrUndefined=function(t){return null==t},t.isNumber=E,t.isString=x,t.isSymbol=function(t){return"symbol"==typeof t},t.isUndefined=S,t.isRegExp=O,t.isObject=j,t.isDate=A,t.isError=B,t.isFunction=k,t.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},t.isBuffer=a(1);var _=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function z(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.log=function(){var e,n;r.log("%s - %s",(e=new Date,n=[T(e.getHours()),T(e.getMinutes()),T(e.getSeconds())].join(":"),[e.getDate(),_[e.getMonth()],n].join(" ")),t.format.apply(t,arguments))},t.inherits=a(2),t._extend=function(t,e){if(!e||!j(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t};var M="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function D(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}t.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(M&&t[M]){var e;if("function"!=typeof(e=t[M]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,M,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,n=new Promise(function(t,n){e=t,r=n}),o=[],i=0;i>>0!==r||r>s.length)return function(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}(r);for(;f.length<=r;)f.push(null);var u=f[r];if(u)return u.exports;var a=s[r],c=a[0],l=a[1],p=a[2],h=o,y=i,g=e,d=t,w=n;0!==r&&(w={id:"/"+c+l,exports:d={},parent:n,filename:h,loaded:!1,children:n.children,paths:n.paths,require:n.require}),f[r]=w;try{p.call(d,d,g,w,h,y,void 0)}catch(t){throw delete f[r],t}return 0!==r&&(w.loaded=!0),w.exports}a(0)}],["bpkg","/lib/builtins/assert.js",function(e,n,o,i,u,s){var f=[["assert","/assert.js",function(e,r,n,o,i,u){"use strict";function s(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o=0;s--)if(f[s]!==c[s])return!1;for(s=f.length-1;s>=0;s--)if(u=f[s],!S(t[u],e[u],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function O(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function j(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function A(t,e,r,n){var o;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),o=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!o&&E(o,r,"Missing expected exception"+n);var i="string"==typeof n,u=!t&&a.isError(o),s=!t&&o&&!r;if((u&&i&&j(o,r)||s)&&E(o,r,"Got unwanted exception"+n),t&&o&&r&&!j(o,r)||!t&&o)throw o}d.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=m(v((e=this).actual),128)+" "+e.operator+" "+m(v(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||E;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var o=n.stack,i=b(r),u=o.indexOf("\n"+i);if(u>=0){var s=o.indexOf("\n",u+1);o=o.substring(s+1)}this.stack=o}}},a.inherits(d.AssertionError,Error),d.fail=E,d.ok=x,d.equal=function(t,e,r){t!=e&&E(t,e,r,"==",d.equal)},d.notEqual=function(t,e,r){t==e&&E(t,e,r,"!=",d.notEqual)},d.deepEqual=function(t,e,r){S(t,e,!1)||E(t,e,r,"deepEqual",d.deepEqual)},d.deepStrictEqual=function(t,e,r){S(t,e,!0)||E(t,e,r,"deepStrictEqual",d.deepStrictEqual)},d.notDeepEqual=function(t,e,r){S(t,e,!1)&&E(t,e,r,"notDeepEqual",d.notDeepEqual)},d.notDeepStrictEqual=function t(e,r,n){S(e,r,!0)&&E(e,r,n,"notDeepStrictEqual",t)},d.strictEqual=function(t,e,r){t!==e&&E(t,e,r,"===",d.strictEqual)},d.notStrictEqual=function(t,e,r){t===e&&E(t,e,r,"!==",d.notStrictEqual)},d.throws=function(t,e,r){A(!0,t,e,r)},d.doesNotThrow=function(t,e,r){A(!1,t,e,r)},d.ifError=function(t){if(t)throw t};var B=Object.keys||function(t){var e=[];for(var r in t)l.call(t,r)&&e.push(r);return e}}],["util","/util.js",function(e,n,o,i,u,s){var f=/%[sdj%]/g;e.format=function(t){if(!x(t)){for(var e=[],r=0;r=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),m(r)?n.showHidden=r:r&&e._extend(n,r),S(n.showHidden)&&(n.showHidden=!1),S(n.depth)&&(n.depth=2),S(n.colors)&&(n.colors=!1),S(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=h),g(n,t,n.depth)}function h(t,e){var r=p.styles[e];return r?"["+p.colors[r][0]+"m"+t+"["+p.colors[r][1]+"m":t}function y(t,e){return t}function g(t,r,n){if(t.customInspect&&r&&k(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var o=r.inspect(n,t);return x(o)||(o=g(t,o,n)),o}var i=function(t,e){if(S(e))return t.stylize("undefined","undefined");if(x(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(E(e))return t.stylize(""+e,"number");if(m(e))return t.stylize(""+e,"boolean");if(v(e))return t.stylize("null","null")}(t,r);if(i)return i;var u=Object.keys(r),s=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(u);if(t.showHidden&&(u=Object.getOwnPropertyNames(r)),B(r)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return d(r);if(0===u.length){if(k(r)){var f=r.name?": "+r.name:"";return t.stylize("[Function"+f+"]","special")}if(O(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(A(r))return t.stylize(Date.prototype.toString.call(r),"date");if(B(r))return d(r)}var a,c="",l=!1,p=["{","}"];(b(r)&&(l=!0,p=["[","]"]),k(r))&&(c=" [Function"+(r.name?": "+r.name:"")+"]");return O(r)&&(c=" "+RegExp.prototype.toString.call(r)),A(r)&&(c=" "+Date.prototype.toUTCString.call(r)),B(r)&&(c=" "+d(r)),0!==u.length||l&&0!=r.length?n<0?O(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),a=l?function(t,e,r,n,o){for(var i=[],u=0,s=e.length;u=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(a,c,p)):p[0]+c+p[1]}function d(t){return"["+Error.prototype.toString.call(t)+"]"}function w(t,e,r,n,o,i){var u,s,f;if((f=Object.getOwnPropertyDescriptor(e,o)||{value:e[o]}).get?s=f.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):f.set&&(s=t.stylize("[Setter]","special")),z(n,o)||(u="["+o+"]"),s||(t.seen.indexOf(f.value)<0?(s=v(r)?g(t,f.value,null):g(t,f.value,r-1)).indexOf("\n")>-1&&(s=i?s.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+s.split("\n").map(function(t){return" "+t}).join("\n")):s=t.stylize("[Circular]","special")),S(u)){if(i&&o.match(/^\d+$/))return s;(u=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=t.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=t.stylize(u,"string"))}return u+": "+s}function b(t){return Array.isArray(t)}function m(t){return"boolean"==typeof t}function v(t){return null===t}function E(t){return"number"==typeof t}function x(t){return"string"==typeof t}function S(t){return void 0===t}function O(t){return j(t)&&"[object RegExp]"===U(t)}function j(t){return"object"==typeof t&&null!==t}function A(t){return j(t)&&"[object Date]"===U(t)}function B(t){return j(t)&&("[object Error]"===U(t)||t instanceof Error)}function k(t){return"function"==typeof t}function U(t){return Object.prototype.toString.call(t)}function T(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(t){if(S(a)&&(a=process.env.NODE_DEBUG||""),t=t.toUpperCase(),!l[t])if(new RegExp("\\b"+t+"\\b","i").test(a)){var n=process.pid;l[t]=function(){var o=e.format.apply(e,arguments);r.error("%s %d: %s",t,n,o)}}else l[t]=function(){};return l[t]},e.inspect=p,p.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},p.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=b,e.isBoolean=m,e.isNull=v,e.isNullOrUndefined=function(t){return null==t},e.isNumber=E,e.isString=x,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=S,e.isRegExp=O,e.isObject=j,e.isDate=A,e.isError=B,e.isFunction=k,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=c(2);var _=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function z(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){var t,n;r.log("%s - %s",(t=new Date,n=[T(t.getHours()),T(t.getMinutes()),T(t.getSeconds())].join(":"),[t.getDate(),_[t.getMonth()],n].join(" ")),e.format.apply(e,arguments))},e.inherits=c(3),e._extend=function(t,e){if(!e||!j(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}],["util","/support/isBufferBrowser.js",function(t,e,r,n,o,i){r.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}}],["inherits","/inherits_browser.js",function(t,e,r,n,o,i){"function"==typeof Object.create?r.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:r.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}]],a=[];function c(t){if(t>>>0!==t||t>f.length)return function(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}(t);for(;a.length<=t;)a.push(null);var r=a[t];if(r)return r.exports;var s=f[t],c=s[0],l=s[1],p=s[2],h=i,y=u,g=n,d=e,w=o;0!==t&&(w={id:"/"+c+l,exports:d={},parent:o,filename:h,loaded:!1,children:o.children,paths:o.paths,require:o.require}),a[t]=w;try{p.call(d,d,g,w,h,y,void 0)}catch(e){throw delete a[t],e}return 0!==t&&(w.loaded=!0),w.exports}c(0)}]],o=[];function i(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}function u(t){i(t)}function s(t,e){if(t>>>0!==t||t>n.length)return i(t);if(null!=e&&!e.children)return i(t);for(;o.length<=t;)o.push(null);var r=o[t];if(r)return r.exports;var s=n[t],f=s[0],a=s[1],c=s[2],l=a,p=l.split("/").slice(0,-1).join("/")||"/",h=u,y={},g={id:"/"+f+a,exports:y,parent:e,filename:l,loaded:!1,children:[],paths:["/"],require:h};e&&e.children.push(g),0===t&&(h.main=g),o[t]=g;try{c.call(y,y,h,g,l,p,void 0)}catch(e){throw delete o[t],e}return g.loaded=!0,g.exports}u.resolve=i,u.main=null,u.extensions={__proto__:null},u.cache={__proto__:null},e=s(4,null).Buffer,r=s(5,null);var f=s(0,null);"function"==typeof define&&define.amd?define("SHA3",[],function(){return f}):"object"==typeof module&&module&&"object"==typeof module.exports&&module.exports?module.exports=f:t.SHA3=f}("undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")()); 2 | -------------------------------------------------------------------------------- /wsproxy.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const assert = require('assert'); 4 | const net = require('net'); 5 | const EventEmitter = require('events'); 6 | const bsock = require('bsock'); 7 | const IP = require('binet'); 8 | 9 | class WSProxy extends EventEmitter { 10 | constructor(options) { 11 | super(); 12 | 13 | if (!options) 14 | options = {}; 15 | 16 | this.options = options; 17 | this.ports = new Set(); 18 | this.io = bsock.server(); 19 | this.sockets = new WeakMap(); 20 | 21 | if (options.ports) { 22 | for (const port of options.ports) 23 | this.ports.add(port); 24 | } 25 | 26 | this.init(); 27 | } 28 | 29 | init() { 30 | this.io.on('error', (err) => { 31 | this.emit('error', err); 32 | }); 33 | 34 | this.io.on('socket', (ws) => { 35 | this.handleSocket(ws); 36 | }); 37 | } 38 | 39 | handleSocket(ws) { 40 | const state = new SocketState(this, ws); 41 | 42 | // Use a weak map to avoid 43 | // mutating the websocket object. 44 | this.sockets.set(ws, state); 45 | 46 | ws.on('error', (err) => { 47 | this.emit('error', err); 48 | }); 49 | 50 | ws.bind('tcp connect', (port, host) => { 51 | this.handleConnect(ws, port, host); 52 | }); 53 | } 54 | 55 | handleConnect(ws, port, host) { 56 | const state = this.sockets.get(ws); 57 | assert(state); 58 | 59 | if (state.socket) { 60 | this.log('Client is trying to reconnect (%s).', state.host); 61 | return; 62 | } 63 | 64 | if ((port & 0xffff) !== port 65 | || typeof host !== 'string' 66 | || host.length === 0) { 67 | this.log('Client gave bad arguments (%s).', state.host); 68 | ws.fire('tcp close'); 69 | ws.destroy(); 70 | return; 71 | } 72 | 73 | let raw, addr; 74 | try { 75 | raw = IP.toBuffer(host); 76 | addr = IP.toString(raw); 77 | } catch (e) { 78 | this.log('Client gave a bad host: %s (%s).', host, state.host); 79 | ws.fire('tcp error', { 80 | message: 'EHOSTUNREACH', 81 | code: 'EHOSTUNREACH' 82 | }); 83 | ws.destroy(); 84 | return; 85 | } 86 | 87 | if (false) { 88 | this.log( 89 | 'Client is trying to connect to a bad ip: %s (%s).', 90 | addr, state.host); 91 | ws.fire('tcp error', { 92 | message: 'ENETUNREACH', 93 | code: 'ENETUNREACH' 94 | }); 95 | ws.destroy(); 96 | return; 97 | } 98 | 99 | if (!this.ports.has(port)) { 100 | this.log('Client is connecting to non-whitelist port (%s).', state.host); 101 | ws.fire('tcp error', { 102 | message: 'ENETUNREACH', 103 | code: 'ENETUNREACH' 104 | }); 105 | ws.destroy(); 106 | return; 107 | } 108 | 109 | let socket; 110 | try { 111 | socket = state.connect(port, addr); 112 | this.log('Connecting to %s (%s).', state.remoteHost, state.host); 113 | } catch (e) { 114 | this.log(e.message); 115 | this.log('Closing %s (%s).', state.remoteHost, state.host); 116 | ws.fire('tcp error', { 117 | message: 'ENETUNREACH', 118 | code: 'ENETUNREACH' 119 | }); 120 | ws.destroy(); 121 | return; 122 | } 123 | 124 | socket.on('connect', () => { 125 | ws.fire('tcp connect', socket.remoteAddress, socket.remotePort); 126 | }); 127 | 128 | socket.on('data', (data) => { 129 | ws.fire('tcp data', data.toString('hex')); 130 | }); 131 | 132 | socket.on('error', (err) => { 133 | ws.fire('tcp error', { 134 | message: err.message, 135 | code: err.code || null 136 | }); 137 | }); 138 | 139 | socket.on('timeout', () => { 140 | ws.fire('tcp timeout'); 141 | }); 142 | 143 | socket.on('close', () => { 144 | this.log('Closing %s (%s).', state.remoteHost, state.host); 145 | ws.fire('tcp close'); 146 | ws.destroy(); 147 | }); 148 | 149 | ws.bind('tcp data', (data) => { 150 | if (typeof data !== 'string') 151 | return; 152 | socket.write(Buffer.from(data, 'hex')); 153 | }); 154 | 155 | ws.bind('tcp keep alive', (enable, delay) => { 156 | socket.setKeepAlive(enable, delay); 157 | }); 158 | 159 | ws.bind('tcp no delay', (enable) => { 160 | socket.setNoDelay(enable); 161 | }); 162 | 163 | ws.bind('tcp set timeout', (timeout) => { 164 | socket.setTimeout(timeout); 165 | }); 166 | 167 | ws.bind('tcp pause', () => { 168 | socket.pause(); 169 | }); 170 | 171 | ws.bind('tcp resume', () => { 172 | socket.resume(); 173 | }); 174 | 175 | ws.on('disconnect', () => { 176 | socket.destroy(); 177 | }); 178 | } 179 | 180 | log(...args) { 181 | process.stdout.write('wsproxy: '); 182 | console.log(...args); 183 | } 184 | 185 | attach(server) { 186 | this.io.attach(server); 187 | } 188 | } 189 | 190 | class SocketState { 191 | constructor(server, socket) { 192 | this.socket = null; 193 | this.host = socket.host; 194 | this.remoteHost = null; 195 | } 196 | 197 | connect(port, host) { 198 | this.socket = net.connect(port, host); 199 | this.remoteHost = IP.toHostname(host, port); 200 | return this.socket; 201 | } 202 | } 203 | 204 | module.exports = WSProxy; 205 | --------------------------------------------------------------------------------