easy-devops 1.2.1 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +97 -6
- package/dist/ui/assets/index-CMRzkIKj.css +1 -0
- package/dist/ui/assets/index-DEouL3IK.js +452 -0
- package/dist/ui/assets/socket-DwLPrgsr.js +1 -0
- package/dist/ui/assets/socket-K5ttLD2q.js +65 -0
- package/dist/ui/brand/apple-touch-icon.png +0 -0
- package/dist/ui/brand/favicon-16.png +0 -0
- package/dist/ui/brand/favicon-32.png +0 -0
- package/dist/ui/brand/favicon-light-16.png +0 -0
- package/dist/ui/brand/favicon-light-32.png +0 -0
- package/dist/ui/brand/favicon.ico +0 -0
- package/dist/ui/brand/icon-192.png +0 -0
- package/dist/ui/brand/icon-48.png +0 -0
- package/dist/ui/brand/icon-512.png +0 -0
- package/dist/ui/brand/icon-64-light.png +0 -0
- package/dist/ui/brand/icon-64.png +0 -0
- package/dist/ui/brand/logo-dark.png +0 -0
- package/dist/ui/brand/logo-light.png +0 -0
- package/dist/ui/brand/mark-dark.png +0 -0
- package/dist/ui/brand/mark-light.png +0 -0
- package/dist/ui/index.html +71 -0
- package/install.ps1 +188 -1
- package/install.sh +254 -29
- package/package.json +15 -4
- package/src/cli/dash.js +110 -0
- package/src/cli/index.js +237 -106
- package/src/cli/managers/domain-manager.js +60 -40
- package/src/cli/managers/ssl-manager.js +47 -330
- package/src/cli/menu.js +156 -0
- package/src/cli/menus/cleanup.js +205 -0
- package/src/cli/menus/dashboard.js +92 -1
- package/src/cli/menus/runtime.js +236 -0
- package/src/cli/menus/service.js +764 -0
- package/src/cli/menus/settings.js +176 -8
- package/src/cli/menus/uninstall.js +167 -0
- package/src/cli/menus/update.js +222 -47
- package/src/core/acme-challenge.js +273 -0
- package/src/core/cert-operations.js +189 -0
- package/src/{dashboard/lib → core}/cert-reader.js +2 -2
- package/src/core/cert-renewal.js +494 -0
- package/src/core/cleanup.js +600 -0
- package/src/core/config.js +169 -2
- package/src/core/daemon/ipc.js +292 -0
- package/src/core/daemon/lock.js +294 -0
- package/src/core/daemon/run.js +241 -0
- package/src/core/daemon/stopRequest.js +162 -0
- package/src/core/db.js +37 -8
- package/src/core/deploy/apps.js +491 -0
- package/src/core/deploy/domainLink.js +200 -0
- package/src/core/deploy/engine.js +973 -0
- package/src/core/deploy/ezfile.js +361 -0
- package/src/core/deploy/github.js +239 -0
- package/src/core/deploy/githubApi.js +261 -0
- package/src/core/deploy/hookServer.js +325 -0
- package/src/core/deploy/hubCommands.js +267 -0
- package/src/core/deploy/launcher.js +57 -0
- package/src/core/deploy/status.js +91 -0
- package/src/core/deploy/store.js +398 -0
- package/src/core/domainNotifier.js +94 -28
- package/src/core/domains-db.js +234 -0
- package/src/core/events.js +94 -2
- package/src/core/hub/agent.js +842 -0
- package/src/core/hubLink.js +306 -0
- package/src/core/hubPermissions.js +430 -0
- package/src/core/installSource.js +162 -0
- package/src/core/jobs/bus.js +120 -0
- package/src/core/jobs/index.js +371 -0
- package/src/core/jobs/monitors.js +368 -0
- package/src/core/jobs/owner.js +217 -0
- package/src/core/jobs/revisionWatcher.js +106 -0
- package/src/core/nginx-apply.js +213 -0
- package/src/core/nginx-conf-generator.js +253 -17
- package/src/{dashboard/lib → core}/nginx-service.js +18 -9
- package/src/core/notifications/claim.js +214 -0
- package/src/core/notifications/dispatch.js +154 -0
- package/src/core/notifier.js +31 -1
- package/src/core/passwords.js +172 -0
- package/src/core/permissions.js +8 -4
- package/src/core/platform.js +709 -2
- package/src/core/probeCache.js +258 -0
- package/src/core/purge.js +372 -0
- package/src/core/runner.js +488 -0
- package/src/core/service/acl.js +226 -0
- package/src/core/service/dataDir.js +345 -0
- package/src/core/service/index.js +1128 -0
- package/src/core/service/legacy.js +218 -0
- package/src/core/service/runtime.js +446 -0
- package/src/core/service/runtimeUpdate.js +800 -0
- package/src/core/service/systemd.js +458 -0
- package/src/core/service/windowsPersonal.js +530 -0
- package/src/core/service/windowsService.js +576 -0
- package/src/core/service/winsw.js +260 -0
- package/src/core/setupCode.js +331 -0
- package/src/core/shell.js +70 -7
- package/src/core/ssl-issuer.js +627 -0
- package/src/core/updater.js +295 -0
- package/src/core/validators.js +99 -0
- package/src/dashboard/controllers/authController.js +302 -15
- package/src/dashboard/controllers/deploymentsController.js +479 -0
- package/src/dashboard/controllers/domainsController.js +80 -61
- package/src/dashboard/controllers/hubController.js +135 -0
- package/src/dashboard/controllers/nginxController.js +21 -3
- package/src/dashboard/controllers/processesController.js +368 -0
- package/src/dashboard/controllers/settingsController.js +180 -12
- package/src/dashboard/controllers/sslController.js +288 -10
- package/src/dashboard/lib/daemonBridge.js +163 -0
- package/src/dashboard/lib/localRequest.js +235 -0
- package/src/dashboard/lib/loginRateLimit.js +119 -0
- package/src/dashboard/lib/requireAuth.js +80 -0
- package/src/dashboard/public/js/app.js +489 -19
- package/src/dashboard/routes/auth.js +10 -10
- package/src/dashboard/routes/deployments.js +46 -0
- package/src/dashboard/routes/domains.js +9 -0
- package/src/dashboard/routes/hub.js +22 -0
- package/src/dashboard/routes/nginx.js +9 -0
- package/src/dashboard/routes/processes.js +29 -0
- package/src/dashboard/routes/settings.js +9 -0
- package/src/dashboard/routes/ssl.js +10 -0
- package/src/dashboard/server.js +288 -21
- package/src/dashboard/socketManager.js +171 -207
- package/src/dashboard/views/index.ejs +1 -0
- package/src/dashboard/views/partials/login.ejs +68 -7
- package/src/dashboard/views/partials/processes-panel.ejs +261 -0
- package/src/dashboard/views/partials/settings-panel.ejs +287 -0
- package/src/dashboard/views/partials/sidebar.ejs +2 -0
- package/src/dashboard/lib/domains-db.js +0 -51
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const y=Object.create(null);y.open="0";y.close="1";y.ping="2";y.pong="3";y.message="4";y.upgrade="5";y.noop="6";const T=Object.create(null);Object.keys(y).forEach(n=>{T[y[n]]=n});const P={type:"error",data:"parser error"},Q=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",j=typeof ArrayBuffer=="function",G=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,V=({type:n,data:e},t,s)=>Q&&e instanceof Blob?t?s(e):$(e,s):j&&(e instanceof ArrayBuffer||G(e))?t?s(e):$(new Blob([e]),s):s(y[n]+(e||"")),$=(n,e)=>{const t=new FileReader;return t.onload=function(){const s=t.result.split(",")[1];e("b"+(s||""))},t.readAsDataURL(n)};function Y(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let x;function ue(n,e){if(Q&&n.data instanceof Blob)return n.data.arrayBuffer().then(Y).then(e);if(j&&(n.data instanceof ArrayBuffer||G(n.data)))return e(Y(n.data));V(n,!1,t=>{x||(x=new TextEncoder),e(x.encode(t))})}const z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",E=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<z.length;n++)E[z.charCodeAt(n)]=n;const fe=n=>{let e=n.length*.75,t=n.length,s,i=0,r,o,a,h;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const m=new ArrayBuffer(e),f=new Uint8Array(m);for(s=0;s<t;s+=4)r=E[n.charCodeAt(s)],o=E[n.charCodeAt(s+1)],a=E[n.charCodeAt(s+2)],h=E[n.charCodeAt(s+3)],f[i++]=r<<2|o>>4,f[i++]=(o&15)<<4|a>>2,f[i++]=(a&3)<<6|h&63;return m},le=typeof ArrayBuffer=="function",M=(n,e)=>{if(typeof n!="string")return{type:"message",data:Z(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:pe(n.substring(1),e)}:T[t]?n.length>1?{type:T[t],data:n.substring(1)}:{type:T[t]}:P},pe=(n,e)=>{if(le){const t=fe(n);return Z(t,e)}else return{base64:!0,data:n}},Z=(n,e)=>{switch(e){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},ee="",de=(n,e)=>{const t=n.length,s=new Array(t);let i=0;n.forEach((r,o)=>{V(r,!1,a=>{s[o]=a,++i===t&&e(s.join(ee))})})},ye=(n,e)=>{const t=n.split(ee),s=[];for(let i=0;i<t.length;i++){const r=M(t[i],e);if(s.push(r),r.type==="error")break}return s};function me(){return new TransformStream({transform(n,e){ue(n,t=>{const s=t.length;let i;if(s<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,s);else if(s<65536){i=new Uint8Array(3);const r=new DataView(i.buffer);r.setUint8(0,126),r.setUint16(1,s)}else{i=new Uint8Array(9);const r=new DataView(i.buffer);r.setUint8(0,127),r.setBigUint64(1,BigInt(s))}n.data&&typeof n.data!="string"&&(i[0]|=128),e.enqueue(i),e.enqueue(t)})}})}let L;function k(n){return n.reduce((e,t)=>e+t.length,0)}function A(n,e){if(n[0].length===e)return n.shift();const t=new Uint8Array(e);let s=0;for(let i=0;i<e;i++)t[i]=n[0][s++],s===n[0].length&&(n.shift(),s=0);return n.length&&s<n[0].length&&(n[0]=n[0].slice(s)),t}function ge(n,e){L||(L=new TextDecoder);const t=[];let s=0,i=-1,r=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(s===0){if(k(t)<1)break;const h=A(t,1);r=(h[0]&128)===128,i=h[0]&127,i<126?s=3:i===126?s=1:s=2}else if(s===1){if(k(t)<2)break;const h=A(t,2);i=new DataView(h.buffer,h.byteOffset,h.length).getUint16(0),s=3}else if(s===2){if(k(t)<8)break;const h=A(t,8),m=new DataView(h.buffer,h.byteOffset,h.length),f=m.getUint32(0);if(f>Math.pow(2,21)-1){a.enqueue(P);break}i=f*Math.pow(2,32)+m.getUint32(4),s=3}else{if(k(t)<i)break;const h=A(t,i);a.enqueue(M(r?h:L.decode(h),e)),s=0}if(i===0||i>n){a.enqueue(P);break}}}})}const te=4;function u(n){if(n)return _e(n)}function _e(n){for(var e in u.prototype)n[e]=u.prototype[e];return n}u.prototype.on=u.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this};u.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this};u.prototype.off=u.prototype.removeListener=u.prototype.removeAllListeners=u.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var s,i=0;i<t.length;i++)if(s=t[i],s===e||s.fn===e){t.splice(i,1);break}return t.length===0&&delete this._callbacks["$"+n],this};u.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],s=1;s<arguments.length;s++)e[s-1]=arguments[s];if(t){t=t.slice(0);for(var s=0,i=t.length;s<i;++s)t[s].apply(this,e)}return this};u.prototype.emitReserved=u.prototype.emit;u.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]};u.prototype.hasListeners=function(n){return!!this.listeners(n).length};const B=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),l=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),be="arraybuffer";function se(n,...e){return e.reduce((t,s)=>(n.hasOwnProperty(s)&&(t[s]=n[s]),t),{})}const we=l.setTimeout,ve=l.clearTimeout;function N(n,e){e.useNativeTimers?(n.setTimeoutFn=we.bind(l),n.clearTimeoutFn=ve.bind(l)):(n.setTimeoutFn=l.setTimeout.bind(l),n.clearTimeoutFn=l.clearTimeout.bind(l))}const Ee=1.33;function ke(n){return typeof n=="string"?Ae(n):Math.ceil((n.byteLength||n.size)*Ee)}function Ae(n){let e=0,t=0;for(let s=0,i=n.length;s<i;s++)e=n.charCodeAt(s),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(s++,t+=4);return t}function ne(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Te(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function Re(n){let e={},t=n.split("&");for(let s=0,i=t.length;s<i;s++){let r=t[s].split("=");e[decodeURIComponent(r[0])]=decodeURIComponent(r.slice(1).join("="))}return e}class Oe extends Error{constructor(e,t,s){super(e),this.description=t,this.context=s,this.type="TransportError"}}class H extends u{constructor(e){super(),this.writable=!1,N(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,s){return super.emitReserved("error",new Oe(e,t,s)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=M(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const t=Te(e);return t.length?"?"+t:""}}class Se extends H{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||t()})),this.writable||(s++,this.once("drain",function(){--s||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};ye(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,de(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=ne()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}}let ie=!1;try{ie=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Ce=ie;function Be(){}class Ne extends Se{constructor(e){if(super(e),typeof location<"u"){const t=location.protocol==="https:";let s=location.port;s||(s=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||s!==e.port}}doWrite(e,t){const s=this.request({method:"POST",data:e});s.on("success",t),s.on("error",(i,r)=>{this.onError("xhr post error",i,r)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,s)=>{this.onError("xhr poll error",t,s)}),this.pollXhr=e}}class d extends u{constructor(e,t,s){super(),this.createRequest=e,N(this,s),this._opts=s,this._method=s.method||"GET",this._uri=t,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var e;const t=se(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(t);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&s.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var i;s.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=d.requestsCount++,d.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Be,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete d.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}d.requestsCount=0;d.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",J);else if(typeof addEventListener=="function"){const n="onpagehide"in l?"pagehide":"unload";addEventListener(n,J,!1)}}function J(){for(let n in d.requests)d.requests.hasOwnProperty(n)&&d.requests[n].abort()}const xe=(function(){const n=re({xdomain:!1});return n&&n.responseType!==null})();class Le extends Ne{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=xe&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new d(re,this.uri(),e)}}function re(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||Ce))return new XMLHttpRequest}catch{}if(!e)try{return new l[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const oe=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class qe extends H{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,s=oe?{}:se(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,s)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],i=t===e.length-1;V(s,this.supportsBinary,r=>{try{this.doWrite(s,r)}catch{}i&&B(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=ne()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const q=l.WebSocket||l.MozWebSocket;class Pe extends qe{createSocket(e,t,s){return oe?new q(e,t,s):t?new q(e,t):new q(e)}doWrite(e,t){this.ws.send(t)}}class Ie extends H{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=ge(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=e.readable.pipeThrough(t).getReader(),i=me();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();const r=()=>{s.read().then(({done:a,value:h})=>{a||(this.onPacket(h),r())}).catch(a=>{})};r();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const s=e[t],i=t===e.length-1;this._writer.write(s).then(()=>{i&&B(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const De={websocket:Pe,webtransport:Ie,polling:Le},Ue=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Fe=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function I(n){if(n.length>8e3)throw"URI too long";const e=n,t=n.indexOf("["),s=n.indexOf("]");t!=-1&&s!=-1&&(n=n.substring(0,t)+n.substring(t,s).replace(/:/g,";")+n.substring(s,n.length));let i=Ue.exec(n||""),r={},o=14;for(;o--;)r[Fe[o]]=i[o]||"";return t!=-1&&s!=-1&&(r.source=e,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=Ve(r,r.path),r.queryKey=Me(r,r.query),r}function Ve(n,e){const t=/\/{2,9}/g,s=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&s.splice(0,1),e.slice(-1)=="/"&&s.splice(s.length-1,1),s}function Me(n,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,i,r){i&&(t[i]=r)}),t}const D=typeof addEventListener=="function"&&typeof removeEventListener=="function",R=[];D&&addEventListener("offline",()=>{R.forEach(n=>n())},!1);let ae=class _ extends u{constructor(e,t={}){var s,i;if(super(),this.binaryType=be,this.writeBuffer=[],this._prevBufferLen=0,this._upgrades=[],this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(t=e,e=null),e){const r=I(e);t.hostname=r.host,t.secure=r.protocol==="https"||r.protocol==="wss",t.port=r.port,r.query&&(t.query=r.query)}else t.host&&(t.hostname=I(t.host).host);if(N(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),t.transportImplementations&&t.transports)throw new Error("specifying both 'transportImplementations' and 'transports' options is not supported");t.transportImplementations||!((s=t.transports)===null||s===void 0)&&s.length&&typeof t.transports[0]=="function"?(this.transports=[],this._transportsByName=Object.create(null),((i=t.transportImplementations)!==null&&i!==void 0?i:t.transports).forEach(r=>{const o=r.prototype.name;this.transports.push(o),this._transportsByName[o]=r})):(this.transports=t.transports?[...t.transports]:["polling","websocket","webtransport"],this._transportsByName=De),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Re(this.opts.query)),D&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},R.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=te,t.transport=e,this.id&&(t.sid=this.id);const s=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&_.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}_probe(e){let t=this.createTransport(e),s=!1;_.priorWebsocketSuccess=!1;const i=()=>{s||(t.send([{type:"ping",data:"probe"}]),t.once("packet",g=>{if(!s)if(g.type==="pong"&&g.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;_.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(f(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const w=new Error("probe error");w.transport=t.name,this.emitReserved("upgradeError",w)}}))};function r(){s||(s=!0,f(),t.close(),t=null)}const o=g=>{const w=new Error("probe error: "+g);w.transport=t.name,r(),this.emitReserved("upgradeError",w)};function a(){o("transport closed")}function h(){o("socket closed")}function m(g){t&&g.name!==t.name&&r()}const f=()=>{t.removeListener("open",i),t.removeListener("error",o),t.removeListener("close",a),this.off("close",h),this.off("upgrading",m)};t.once("open",i),t.once("error",o),t.once("close",a),this.once("close",h),this.once("upgrading",m),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{s||t.open()},200):t.open()}onOpen(){if(this.readyState="open",_.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._upgrades=this._filterUpgrades(e.upgrades),this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let s=0;s<this.writeBuffer.length;s++){const i=this.writeBuffer[s].data;if(i&&(t+=ke(i)),s>0&&t>this._maxPayload)return this.writeBuffer.slice(0,s);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,B(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,s){return this._sendPacket("message",e,t,s),this}send(e,t,s){return this._sendPacket("message",e,t,s),this}_sendPacket(e,t,s,i){if(typeof t=="function"&&(i=t,t=void 0),typeof s=="function"&&(i=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const r={type:e,data:t,options:s};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},s=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():e()}):this.upgrading?s():e()),this}_onError(e){if(_.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),D&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=R.indexOf(this._offlineEventListener);s!==-1&&R.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}_filterUpgrades(e){const t=[];for(let s=0;s<e.length;s++)~this.transports.indexOf(e[s])&&t.push(e[s]);return t}};ae.protocol=te;function He(n,e="",t){let s=n;t=t||typeof location<"u"&&location,n==null&&(n=t.protocol+"//"+t.host),typeof n=="string"&&(n.charAt(0)==="/"&&(n.charAt(1)==="/"?n=t.protocol+n:n=t.host+n),/^(https?|wss?):\/\//.test(n)||(typeof t<"u"?n=t.protocol+"//"+n:n="https://"+n),s=I(n)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const r=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+r+":"+s.port+e,s.href=s.protocol+"://"+r+(t&&t.port===s.port?"":":"+s.port),s}const Ke=typeof ArrayBuffer=="function",We=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n.buffer instanceof ArrayBuffer,ce=Object.prototype.toString,$e=typeof Blob=="function"||typeof Blob<"u"&&ce.call(Blob)==="[object BlobConstructor]",Ye=typeof File=="function"||typeof File<"u"&&ce.call(File)==="[object FileConstructor]";function K(n){return Ke&&(n instanceof ArrayBuffer||We(n))||$e&&n instanceof Blob||Ye&&n instanceof File}function O(n,e){if(!n||typeof n!="object")return!1;if(Array.isArray(n)){for(let t=0,s=n.length;t<s;t++)if(O(n[t]))return!0;return!1}if(K(n))return!0;if(n.toJSON&&typeof n.toJSON=="function"&&arguments.length===1)return O(n.toJSON(),!0);for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&O(n[t]))return!0;return!1}function ze(n){const e=[],t=n.data,s=n;return s.data=S(t,e),s.attachments=e.length,{packet:s,buffers:e}}function S(n,e,t){if(!n)return n;if(K(n)){const s={_placeholder:!0,num:e.length};return e.push(n),s}else if(Array.isArray(n)){const s=new Array(n.length);for(let i=0;i<n.length;i++)s[i]=S(n[i],e);return s}else if(typeof n=="object"&&!(n instanceof Date)){if(n.toJSON&&typeof n.toJSON=="function"&&!t)return S(n.toJSON(),e,!0);const s={};for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s[i]=S(n[i],e));return s}return n}function Je(n,e){return n.data=U(n.data,e),delete n.attachments,n}function U(n,e){if(!n)return n;if(n&&n._placeholder===!0){if(typeof n.num=="number"&&n.num>=0&&n.num<e.length)return e[n.num];throw new Error("illegal attachments")}else if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t]=U(n[t],e);else if(typeof n=="object")for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(n[t]=U(n[t],e));return n}const Xe=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var c;(function(n){n[n.CONNECT=0]="CONNECT",n[n.DISCONNECT=1]="DISCONNECT",n[n.EVENT=2]="EVENT",n[n.ACK=3]="ACK",n[n.CONNECT_ERROR=4]="CONNECT_ERROR",n[n.BINARY_EVENT=5]="BINARY_EVENT",n[n.BINARY_ACK=6]="BINARY_ACK"})(c||(c={}));class Qe{constructor(e){this.replacer=e}encode(e){return(e.type===c.EVENT||e.type===c.ACK)&&O(e)?this.encodeAsBinary({type:e.type===c.EVENT?c.BINARY_EVENT:c.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===c.BINARY_EVENT||e.type===c.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=ze(e),s=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(s),i}}class W extends u{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e=="function"?{reviver:e}:e)}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const s=t.type===c.BINARY_EVENT;s||t.type===c.BINARY_ACK?(t.type=s?c.EVENT:c.ACK,this.reconstructor=new je(t)):super.emitReserved("decoded",t)}else if(K(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0;const s={type:Number(e.charAt(0))};if(c[s.type]===void 0)throw new Error("unknown packet type "+s.type);if(s.type===c.BINARY_EVENT||s.type===c.BINARY_ACK){const r=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);const o=e.substring(r,t);if(o!=Number(o)||e.charAt(t)!=="-")throw new Error("Illegal attachments");const a=Number(o);if(!Ge(a)||a<1)throw new Error("Illegal attachments");if(a>this.opts.maxAttachments)throw new Error("too many attachments");s.attachments=a}if(e.charAt(t+1)==="/"){const r=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););s.nsp=e.substring(r,t)}else s.nsp="/";const i=e.charAt(t+1);if(i!==""&&Number(i)==i){const r=t+1;for(;++t;){const o=e.charAt(t);if(o==null||Number(o)!=o){--t;break}if(t===e.length)break}s.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(W.isPayloadValid(s.type,r))s.data=r;else throw new Error("invalid payload")}return s}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case c.CONNECT:return X(t);case c.DISCONNECT:return t===void 0;case c.CONNECT_ERROR:return typeof t=="string"||X(t);case c.EVENT:case c.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Xe.indexOf(t[0])===-1);case c.ACK:case c.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class je{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const t=Je(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Ge=Number.isInteger||function(n){return typeof n=="number"&&isFinite(n)&&Math.floor(n)===n};function X(n){return Object.prototype.toString.call(n)==="[object Object]"}const Ze=Object.freeze(Object.defineProperty({__proto__:null,Decoder:W,Encoder:Qe,get PacketType(){return c}},Symbol.toStringTag,{value:"Module"}));function p(n,e,t){return n.on(e,t),function(){n.off(e,t)}}const et=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class he extends u{constructor(e,t,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[p(e,"open",this.onopen.bind(this)),p(e,"packet",this.onpacket.bind(this)),p(e,"error",this.onerror.bind(this)),p(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var s,i,r;if(et.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const o={type:c.EVENT,data:t};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const f=this.ids++,g=t.pop();this._registerAckCallback(f,g),o.id=f}const a=(i=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||i===void 0?void 0:i.writable,h=this.connected&&!(!((r=this.io.engine)===null||r===void 0)&&r._hasPingExpired());return this.flags.volatile&&!a||(h?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(e,t){var s;const i=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(i===void 0){this.acks[e]=t;return}const r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===e&&this.sendBuffer.splice(a,1);t.call(this,new Error("operation has timed out"))},i),o=(...a)=>{this.io.clearTimeoutFn(r),t.apply(this,a)};o.withError=!0,this.acks[e]=o}emitWithAck(e,...t){return new Promise((s,i)=>{const r=(o,a)=>o?i(o):s(a);r.withError=!0,t.push(r),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((i,...r)=>(this._queue[0],i!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(i)):(this._queue.shift(),t&&t(null,...r)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:c.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(s=>String(s.id)===e)){const s=this.acks[e];delete this.acks[e],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case c.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case c.EVENT:case c.BINARY_EVENT:this.onevent(e);break;case c.ACK:case c.BINARY_ACK:this.onack(e);break;case c.DISCONNECT:this.ondisconnect();break;case c.CONNECT_ERROR:this.destroy();const s=new Error(e.data.message);s.data=e.data.data,this.emitReserved("connect_error",s);break}}onevent(e){const t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const s of t)s.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let s=!1;return function(...i){s||(s=!0,t.packet({type:c.ACK,id:e,data:i}))}}onack(e){const t=this.acks[e.id];typeof t=="function"&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:c.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let s=0;s<t.length;s++)if(e===t[s])return t.splice(s,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const s of t)s.apply(this,e.data)}}}function b(n){n=n||{},this.ms=n.min||100,this.max=n.max||1e4,this.factor=n.factor||2,this.jitter=n.jitter>0&&n.jitter<=1?n.jitter:0,this.attempts=0}b.prototype.duration=function(){var n=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*n);n=(Math.floor(e*10)&1)==0?n-t:n+t}return Math.min(n,this.max)|0};b.prototype.reset=function(){this.attempts=0};b.prototype.setMin=function(n){this.ms=n};b.prototype.setMax=function(n){this.max=n};b.prototype.setJitter=function(n){this.jitter=n};class F extends u{constructor(e,t){var s;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,N(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((s=t.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new b({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;const i=t.parser||Ze;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new ae(this.uri,this.opts);const t=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const i=p(t,"open",function(){s.onopen(),e&&e()}),r=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),e?e(a):this.maybeReconnectOnOpen()},o=p(t,"error",r);if(this._timeout!==!1){const a=this._timeout,h=this.setTimeoutFn(()=>{i(),r(new Error("timeout")),t.close()},a);this.opts.autoUnref&&h.unref(),this.subs.push(()=>{this.clearTimeoutFn(h)})}return this.subs.push(i),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(p(e,"ping",this.onping.bind(this)),p(e,"data",this.ondata.bind(this)),p(e,"error",this.onerror.bind(this)),p(e,"close",this.onclose.bind(this)),p(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){B(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let s=this.nsps[e];return s?this._autoConnect&&!s.active&&s.connect():(s=new he(this,e,t),this.nsps[e]=s),s}_destroy(e){const t=Object.keys(this.nsps);for(const s of t)if(this.nsps[s].active)return;this._close()}_packet(e){const t=this.encoder.encode(e);for(let s=0;s<t.length;s++)this.engine.write(t[s],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(i=>{i?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",i)):e.onreconnect()}))},t);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const v={};function C(n,e){typeof n=="object"&&(e=n,n=void 0),e=e||{};const t=He(n,e.path||"/socket.io"),s=t.source,i=t.id,r=t.path,o=v[i]&&r in v[i].nsps,a=e.forceNew||e["force new connection"]||e.multiplex===!1||o;let h;return a?h=new F(s,e):(v[i]||(v[i]=new F(s,e)),h=v[i]),t.query&&!e.query&&(e.query=t.queryKey),h.socket(t.path,e)}Object.assign(C,{Manager:F,Socket:he,io:C,connect:C});function tt(){const n=C({withCredentials:!0,autoConnect:!1,extraHeaders:{"X-EZ-Request":"1"}});return{get connected(){return n.connected},on(e,t){n.on(e,t)},off(e,t){n.off(e,t)},emit(e,t){e==="logs:subscribe"?n.emit("logs:subscribe",t??{logFile:"error"}):n.emit("logs:unsubscribe")},connect(){n.connect()},disconnect(){n.disconnect()}}}export{tt as createRealtimeClient};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const m=e=>new Date(Date.now()+e*864e5).toISOString(),A=()=>({nginx_down:{enabled:!0,channelIds:[]},cert_expiry:{enabled:!0,channelIds:[]},domain_health:{enabled:!0,channelIds:[]}});function g(e){const t=m(-40);return{backendHost:"127.0.0.1",upstreamType:"http",www:!1,wildcard:!1,enabled:!0,configFile:`/etc/nginx/conf.d/${e.name}.conf`,createdAt:t,updatedAt:t,ssl:{enabled:!1,certPath:"",keyPath:"",redirect:!0,hsts:!1,hstsMaxAge:31536e3},performance:{maxBodySize:"10m",readTimeout:60,connectTimeout:10,proxyBuffers:!1,gzip:!0,gzipTypes:"text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript"},security:{rateLimit:!1,rateLimitRate:10,rateLimitBurst:20,securityHeaders:!1,custom404:!1,custom50x:!1},advanced:{accessLog:!0,customLocations:""},certExpiry:null,daysLeft:null,notifications:A(),...e}}const y=e=>({certPath:`/etc/easy-devops/ssl/${e}/fullchain.pem`,keyPath:`/etc/easy-devops/ssl/${e}/privkey.pem`});function P(){return[g({name:"app.example.com",port:3e3,www:!0,ssl:{enabled:!0,...y("app.example.com"),redirect:!0,hsts:!0,hstsMaxAge:31536e3},certExpiry:m(95),daysLeft:95,security:{rateLimit:!0,rateLimitRate:10,rateLimitBurst:20,securityHeaders:!0,custom404:!1,custom50x:!1},notifications:{nginx_down:{enabled:!0,channelIds:["ch-discord-ops"]},cert_expiry:{enabled:!0,channelIds:["ch-discord-ops","ch-telegram-oncall"]},domain_health:{enabled:!1,channelIds:[]}}}),g({name:"api.example.com",port:8080,upstreamType:"https",ssl:{enabled:!0,...y("api.example.com"),redirect:!1,hsts:!1,hstsMaxAge:31536e3},certExpiry:m(12),daysLeft:12,notifications:{nginx_down:{enabled:!1,channelIds:[]},cert_expiry:{enabled:!0,channelIds:["ch-telegram-oncall"]},domain_health:{enabled:!0,channelIds:["ch-telegram-oncall"]}}}),g({name:"blog.example.com",port:4e3,backendHost:"10.0.0.12",security:{rateLimit:!1,rateLimitRate:10,rateLimitBurst:20,securityHeaders:!1,custom404:!0,custom50x:!1},notifications:{nginx_down:{enabled:!1,channelIds:[]},cert_expiry:{enabled:!1,channelIds:[]},domain_health:{enabled:!0,channelIds:["ch-discord-ops"]}}}),g({name:"staging.example.com",port:5e3,enabled:!1,configFile:"/etc/nginx/conf.d/staging.example.com.conf.disabled"})]}function O(){return[{domain:"app.example.com",expiry:m(95),daysLeft:95,status:"valid",autoRenew:"auto",autoRenewDays:7},{domain:"api.example.com",expiry:m(12),daysLeft:12,status:"expiring",autoRenew:"manual",autoRenewDays:7},{domain:"legacy.example.com",expiry:m(-3),daysLeft:-3,status:"expired"},{domain:"broken.example.com",expiry:null,daysLeft:null,status:"error"}]}function M(){return[{id:"ch-discord-ops",name:"Ops Discord",type:"discord",webhookUrl:"https://discord.com/api/webhooks/123456789012345678/example-token",message:"Easy DevOps alert"},{id:"ch-telegram-oncall",name:"On-call Telegram",type:"telegram",botToken:"7123456789:AAExampleTokenForMockOnly",chatId:"-1001234567890"}]}function E(){return{running:!0,version:"1.24.0",pid:1421}}function H(){return{"app.example.com.conf":`# Generated by Easy DevOps — manual edits are preserved on save only.
|
|
2
|
+
server {
|
|
3
|
+
listen 80;
|
|
4
|
+
server_name app.example.com www.app.example.com;
|
|
5
|
+
|
|
6
|
+
location /.well-known/acme-challenge/ {
|
|
7
|
+
root /var/www/easy-devops;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return 301 https://$host$request_uri;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
server {
|
|
14
|
+
listen 443 ssl http2;
|
|
15
|
+
server_name app.example.com www.app.example.com;
|
|
16
|
+
|
|
17
|
+
ssl_certificate /etc/easy-devops/ssl/app.example.com/fullchain.pem;
|
|
18
|
+
ssl_certificate_key /etc/easy-devops/ssl/app.example.com/privkey.pem;
|
|
19
|
+
|
|
20
|
+
client_max_body_size 10m;
|
|
21
|
+
gzip on;
|
|
22
|
+
|
|
23
|
+
add_header Strict-Transport-Security "max-age=31536000" always;
|
|
24
|
+
|
|
25
|
+
location / {
|
|
26
|
+
proxy_pass http://127.0.0.1:3000;
|
|
27
|
+
proxy_http_version 1.1;
|
|
28
|
+
proxy_set_header Host $host;
|
|
29
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
30
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
31
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`,"api.example.com.conf":`server {
|
|
35
|
+
listen 80;
|
|
36
|
+
server_name api.example.com;
|
|
37
|
+
|
|
38
|
+
location /.well-known/acme-challenge/ {
|
|
39
|
+
root /var/www/easy-devops;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
location / {
|
|
43
|
+
proxy_pass https://127.0.0.1:8080;
|
|
44
|
+
proxy_set_header Host $host;
|
|
45
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`,"blog.example.com.conf":`server {
|
|
49
|
+
listen 80;
|
|
50
|
+
server_name blog.example.com;
|
|
51
|
+
|
|
52
|
+
location / {
|
|
53
|
+
proxy_pass http://10.0.0.12:4000;
|
|
54
|
+
proxy_set_header Host $host;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`,"default.conf":`server {
|
|
58
|
+
listen 80 default_server;
|
|
59
|
+
server_name _;
|
|
60
|
+
|
|
61
|
+
location / {
|
|
62
|
+
return 404;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
`}}function L(){const e=Date.now(),t=n=>new Date(e-n).toISOString().replace("T"," ").slice(0,19);return['2026/11/13 09:12:02 [notice] 1#1: using the "epoll" event method',"2026/11/13 09:12:02 [notice] 1#1: nginx/1.24.0","2026/11/13 09:12:02 [notice] 1#1: OS: Linux 6.8.0-45-generic",`${t(36e5)} [warn] 1421#1421: *241 an upstream response is buffered to a temporary file`,`${t(9e5)} [error] 1421#1421: *318 connect() failed (111: Connection refused) while connecting to upstream, client: 10.0.0.5, server: blog.example.com, request: "GET / HTTP/1.1", upstream: "http://10.0.0.12:4000/", host: "blog.example.com"`,`${t(24e4)} [warn] 1421#1421: *322 conflicting server name "staging.example.com" on 0.0.0.0:80, ignored`,`${t(3e4)} [error] 1421#1421: *330 open() "/var/www/easy-devops/.well-known/acme-challenge/test" failed (2: No such file or directory)`]}function $(){const e=Date.now(),t=n=>new Date(e-n).toISOString().replace("T"," ").replace("Z","");return[`10.0.0.5 - - [${t(12e4)}] "GET / HTTP/1.1" 200 4321 "-" "Mozilla/5.0"`,`10.0.0.8 - - [${t(9e4)}] "GET /api/health HTTP/1.1" 200 32 "-" "curl/8.5.0"`,`10.0.0.5 - - [${t(45e3)}] "POST /api/orders HTTP/1.1" 201 512 "-" "Mozilla/5.0"`,`10.0.0.9 - - [${t(2e4)}] "GET /assets/app.js HTTP/1.1" 200 18234 "https://app.example.com/" "Mozilla/5.0"`]}function T(){return[{name:"ez-dashboard",pmId:0,pid:2190,status:"online",cpu:1.2,memoryBytes:96468992,startedAt:Date.now()-2*864e5,uptimeMs:2*864e5,restarts:0,unstableRestarts:0,execPath:"/opt/easy-devops/src/cli/index.js",cwd:"/opt/easy-devops",user:"deploy",managed:!0,dataDir:"/var/lib/easy-devops"},{name:"api-worker",pmId:1,pid:2401,status:"online",cpu:2.4,memoryBytes:134217728,startedAt:Date.now()-6*36e5,uptimeMs:6*36e5,restarts:2,unstableRestarts:0,execPath:"/srv/api/worker.js",cwd:"/srv/api",user:"deploy",managed:!1,dataDir:null},{name:"legacy-app",pmId:2,pid:null,status:"stopped",cpu:null,memoryBytes:null,startedAt:null,uptimeMs:null,restarts:14,unstableRestarts:1,execPath:"/srv/legacy/server.js",cwd:"/srv/legacy",user:"deploy",managed:!1,dataDir:null},{name:"pm2-logrotate",pmId:3,pid:2502,status:"online",cpu:0,memoryBytes:0,startedAt:Date.now()-12*36e5,uptimeMs:12*36e5,restarts:1,unstableRestarts:0,execPath:"/home/deploy/.pm2/modules/pm2-logrotate/pm2-logrotate.js",cwd:"/home/deploy/.pm2/modules/pm2-logrotate",user:"deploy",managed:!1,dataDir:null}]}function j(){return{pm2:{installed:!0,version:"5.4.2",path:"/usr/local/bin/pm2"},apps:T(),currentUser:"deploy",pm2Home:"/home/deploy/.pm2"}}function N(){return{pm2:{installed:!0,version:"6.0.14",path:"/usr/local/bin/pm2"},dev:!1,dataDir:"/var/lib/easy-devops",backgroundService:{running:!0,connected:!0,pid:2190,version:"1.2.1",startedAt:Date.now()-2*864e5,heartbeatAgeMs:4e3,jobsRunningHere:!1,jobsOwnerPid:2190,jobsOwnerRole:"daemon",mechanism:"systemd",mode:null,installed:!0,startsAt:"boot",stoppedByUser:!1,stoppedAt:null,dataDir:"/var/lib/easy-devops",serverMode:!1,detail:null,state:"active",enabledOnBoot:!0,restarts:0,crashLooping:!1,warnings:[],runtime:{systemNode:{path:"/usr/bin/node",version:"v22.11.0",abi:"127"},pinned:{kind:"symlink",path:"/var/lib/easy-devops/runtime/node",target:"/usr/bin/node",version:"v22.11.0",exists:!0,broken:!1,differsFromSystem:!1},manager:{managed:!1,manager:null},mixed:{mixed:!1,msiPath:null,managed:null},warnings:[]}},install:{command:"ezz service install",needsElevation:!1,shell:null}}}function C(){return{dashboardPort:6443,nginxDir:"/etc/nginx",sslDir:"/etc/easy-devops/ssl",acmeEmail:"ops@example.com",sslAutoRenew:!0,sslAutoRenewDays:7,sslAutoRenewDaysMin:1,sslAutoRenewDaysMax:30,deployDir:"/home/ops/.config/easy-devops/ez_deploys",deployDirDefault:"/home/ops/.config/easy-devops/ez_deploys",deployDirIsDefault:!0,dashboardBindAddress:"127.0.0.1",bindsToLoopbackOnly:!0,dashboardAuth:"password",canUseNoPassword:!0,hasPassword:!0,platform:"linux"}}const h=[{id:"nginx",label:"Nginx",description:"Control the nginx service and its configuration files.",children:[{id:"nginx.start",label:"Start",description:"Start nginx when it is stopped."},{id:"nginx.stop",label:"Stop",description:"Stop nginx. Your sites go offline until it is started again."},{id:"nginx.restart",label:"Restart",description:"Full restart. Briefly drops connections."},{id:"nginx.reload",label:"Reload",description:"Graceful reload. Picks up config changes without dropping connections."},{id:"nginx.test",label:"Test config",description:"Run nginx -t. Read-only, changes nothing."},{id:"nginx.config.view",label:"View configs",description:"Read the generated nginx config files."},{id:"nginx.config.edit",label:"Edit configs",description:"Edit a config file. Always tested before it is kept, and rolled back if nginx rejects it."},{id:"nginx.logs.view",label:"View logs",description:"Read recent nginx access and error log lines."}]},{id:"domains",label:"Domains",description:"Manage reverse proxy domains and their nginx configs.",children:[{id:"domains.create",label:"Create",description:"Add a new domain and generate its nginx config."},{id:"domains.edit",label:"Edit",description:"Change an existing domain and regenerate its config."},{id:"domains.toggle",label:"Enable / disable",description:"Take a domain in or out of service without deleting it."},{id:"domains.delete",label:"Delete",description:"Remove a domain and its nginx config."}]},{id:"ssl",label:"SSL certificates",description:"Issue, renew and remove Let’s Encrypt certificates.",children:[{id:"ssl.renew",label:"Renew one",description:"Renew a single certificate. nginx keeps running."},{id:"ssl.renewAll",label:"Renew all expiring",description:"Renew every certificate expiring within 30 days."},{id:"ssl.issue",label:"Issue new",description:"Request a new certificate over HTTP-01. nginx keeps running."},{id:"ssl.delete",label:"Delete",description:"Delete certificate files. Refused while an enabled domain still uses them."},{id:"ssl.issueDns",label:"Issue wildcard (DNS-01)",description:"Wildcard certificates need a DNS TXT record you add by hand, so they cannot be driven from the Hub yet.",comingSoon:!0}]},{id:"deploy",label:"Deployments",description:"Deploy the apps on this server from the Hub. Fetching code and running its commands happens here, with this server’s own settings.",children:[{id:"deploy.run",label:"Deploy",description:"Start a deployment of an existing app from its configured repository."},{id:"deploy.rollback",label:"Roll back",description:"Switch an app back to an earlier release that is still on this server."},{id:"deploy.logs",label:"View deployment logs",description:"Read the output of a deployment. Build output can contain whatever the build prints."},{id:"deploy.manage",label:"Create, edit and delete apps",description:"Add an app from a repository, change its settings, issue its deploy token, or remove it. This decides which code runs here."},{id:"deploy.env",label:"Read and edit environment variables",description:"See and change an app’s environment values. They pass through the Hub while being edited and are not stored there."},{id:"deploy.ci",label:"Deploy from CI through the Hub",description:"Let a GitHub Action trigger a deployment by calling the Hub with the app’s own deploy token, so this server needs no inbound port."}]},{id:"process",label:"Processes",description:"Control the PM2 processes on this server, including the Easy DevOps service itself.",children:[{id:"process.start",label:"Start",description:"Start a stopped PM2 process from the Hub.",comingSoon:!0},{id:"process.stop",label:"Stop",description:"Stop a running PM2 process from the Hub. Stopping the dashboard would cut the Hub off from this server.",comingSoon:!0},{id:"process.restart",label:"Restart",description:"Restart a PM2 process from the Hub.",comingSoon:!0}]},{id:"system",label:"System",description:"Server-level operations beyond nginx.",children:[{id:"system.nodeVersions",label:"Manage Node.js versions",description:"Install and switch Node.js versions through nvm.",comingSoon:!0},{id:"system.restartServer",label:"Reboot the server",description:"Reboot the whole machine.",comingSoon:!0}]}],z=h.flatMap(e=>e.children.filter(t=>t.comingSoon).map(t=>t.id));function B(){const e={};for(const t of h)for(const n of t.children)e[n.id]=!1;for(const t of["nginx.reload","nginx.test","nginx.config.view","nginx.logs.view","domains.create","domains.edit","domains.toggle","ssl.renew","ssl.renewAll"])e[t]=!0;return e}function F(e){return{linked:!0,hubUrl:"https://hub.example.com",serverId:"srv_demo_01",permissions:e,tree:h,comingSoon:z,connected:!0,status:"connected",lastError:null,attempts:0,dataDir:"/var/lib/easy-devops",devDataDir:!1}}const v=["dashboard","service-stopped","service-stopped-by-you","service-not-installed","service-elevation","login","setup","setupcode","setupcode-expired","none"],G="ez-mock-state-v4",w="ez-mock-scenario";function U(){try{const e=new URLSearchParams(window.location.search),t=window.location.hash.includes("?")?new URLSearchParams(window.location.hash.slice(window.location.hash.indexOf("?")+1)):null,n=e.get("mock")??t?.get("mock");if(n&&v.includes(n))return sessionStorage.setItem(w,n),n;const a=sessionStorage.getItem(w);if(a&&v.includes(a))return a}catch{}return"dashboard"}function X(e){const t=N(),n=t.backgroundService,a={command:"ezz service install",needsElevation:!1,shell:null};return e==="service-stopped"&&(t.backgroundService={...n,running:!1,connected:!1,pid:null,version:null,startedAt:null,heartbeatAgeMs:null,jobsRunningHere:!0,jobsOwnerPid:null,jobsOwnerRole:"dashboard",state:"inactive",detail:"The service is stopped."}),e==="service-stopped-by-you"&&(t.install=a,t.backgroundService={...n,running:!1,connected:!1,pid:null,version:null,startedAt:null,heartbeatAgeMs:null,jobsRunningHere:!0,jobsOwnerPid:null,jobsOwnerRole:"dashboard",mechanism:"startup-supervisor",mode:"personal",installed:!0,startsAt:"logon",stoppedByUser:!0,stoppedAt:new Date(Date.now()-36e5).toISOString(),state:null,enabledOnBoot:!0,detail:"The service is stopped.",runtime:{systemNode:{path:"C:\\Program Files\\nodejs\\node.exe",version:"v22.11.0",abi:"127"},pinned:{kind:"copy",path:"C:\\Users\\deploy\\AppData\\Local\\easy-devops\\runtime\\node.exe",version:"v20.18.1",exists:!0,broken:!1,differsFromSystem:!0},manager:{managed:!0,manager:"nvm-windows"},mixed:{mixed:!1,msiPath:null,managed:null},warnings:[]}}),e==="service-not-installed"&&(t.install=a,t.backgroundService={...n,running:!1,connected:!1,pid:null,version:null,startedAt:null,heartbeatAgeMs:null,jobsRunningHere:!0,jobsOwnerPid:null,jobsOwnerRole:"dashboard",mechanism:"startup-supervisor",mode:"personal",installed:!1,startsAt:"logon",stoppedByUser:!1,stoppedAt:null,state:null,enabledOnBoot:null,restarts:0,crashLooping:!1,runtime:null,warnings:[],detail:"The service is not installed."}),e==="service-elevation"&&(t.backgroundService={...n,mechanism:"systemd",mode:null,installed:!0,startsAt:"boot"}),t}function q(e){const t=P(),n=T(),a=B(),i=C(),u=e==="dashboard"||e==="none"||e.startsWith("service-"),p=e==="setup"||e==="setupcode"||e==="setupcode-expired";return{scenario:e,authenticated:u,authMode:e==="none"?"none":"password",setupConfigured:!p,hasPassword:!p,domains:t,certs:O(),channels:M(),nginx:E(),configs:H(),errorLog:L(),accessLog:$(),processes:{...j(),apps:n},service:X(e),settings:{...i,dashboardAuth:e==="none"?"none":"password",canUseNoPassword:!0},hub:F(a),pendingDns:{}}}let d=null;function k(e){return`${G}:${e}`}function K(){if(d)return d;const e=U();try{const t=sessionStorage.getItem(k(e));if(t){const n=JSON.parse(t);if(n&&n.scenario===e)return d=n,d}}catch{}return d=q(e),V(),d}function V(){if(d)try{sessionStorage.setItem(k(d.scenario),JSON.stringify(d))}catch{}}const J=e=>structuredClone(e),x=new Set;function W(){try{return J(K().service.backgroundService)}catch{return null}}function Y(e){return x.add(e),()=>{x.delete(e)}}const S={running:!0,version:"1.24.0",pid:1421},_=[{name:"app.example.com",up:!0,port:3e3,host:"127.0.0.1"},{name:"api.example.com",up:!0,port:8080,host:"127.0.0.1"},{name:"blog.example.com",up:!1,port:4e3,host:"10.0.0.12"},{name:"staging.example.com",up:!0,port:5e3,host:"127.0.0.1"}];function D(e,t,n,a={}){return{id:`${e}-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,type:e,severity:t,message:n,timestamp:Date.now(),...a}}async function Q(){const e=new Map;let t=!1,n=[],a=[],i=null,u=0,p=null;const r=(s,o)=>{for(const l of e.get(s)??[])l(o)},I=(s,o)=>{const l=e.get(s)??new Set;l.add(o),e.set(s,l)},R=(s,o)=>{e.get(s)?.delete(o)},f=()=>{n.forEach(clearTimeout),n=[],a.forEach(clearInterval),a=[],i&&clearInterval(i),i=null};return{get connected(){return t},on(s,o){I(s,o)},off(s,o){R(s,o)},emit(s,o){if(s==="logs:unsubscribe"){i&&clearInterval(i),i=null;return}const l=o?.logFile==="access"?"access":"error";i&&clearInterval(i);for(let c=50;c>0;c-=1){const b=new Date(Date.now()-c*3e4).toISOString().replace("T"," ").slice(0,19);r("logs:line",{logFile:l,line:l==="access"?`10.0.0.${5+c%4} - - [${b}] "GET /health HTTP/1.1" 200 ${300+c} "-" "Mozilla/5.0"`:`${b} [warn] 1421#1421: *${100+c} an upstream response is buffered to a temporary file`})}i=setInterval(()=>{u+=1;const c=l==="access"?{line:`10.0.0.${5+u%4} - - [${new Date().toISOString()}] "GET / HTTP/1.1" 200 ${1e3+u*37} "-" "Mozilla/5.0"`,logFile:l}:{line:`${new Date().toISOString().replace("T"," ").slice(0,19)} [warn] 1421#1421: *${400+u} an upstream response is buffered to a temporary file`,logFile:l};r("logs:line",c)},900)},connect(){t||(f(),n.push(setTimeout(()=>{t=!0,r("connect",void 0),r("nginx:status",S),r("domain:health",_);const s=W();s&&r("service:changed",s),p?.(),p=Y(o=>{t&&r("service:changed",o)})},120),setTimeout(()=>{r("notification:new",D("nginx_down","success","Nginx is running again",{subtype:"recovery"}))},2200),setTimeout(()=>{r("notification:new",D("cert_expiry","warning","🔒 SSL cert for api.example.com expires in 12 days",{domain:"api.example.com"}))},5200)),a.push(setInterval(()=>{t&&r("nginx:status",S)},5e3),setInterval(()=>{t&&r("domain:health",_)},6e4)))},disconnect(){t&&(t=!1,f(),p?.(),p=null,r("disconnect",void 0))}}}export{Q as createMockSocket};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en" data-theme="dark">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta name="color-scheme" content="dark light" />
|
|
7
|
+
<meta name="description" content="Easy DevOps dashboard — nginx, domains, certificates, processes and Hub in one place." />
|
|
8
|
+
<title>Easy DevOps</title>
|
|
9
|
+
<link rel="icon" href="./brand/favicon.ico" sizes="any" />
|
|
10
|
+
<link
|
|
11
|
+
rel="icon"
|
|
12
|
+
type="image/png"
|
|
13
|
+
sizes="16x16"
|
|
14
|
+
href="./brand/favicon-16.png"
|
|
15
|
+
data-ez-icon
|
|
16
|
+
data-dark="/brand/favicon-16.png"
|
|
17
|
+
data-light="/brand/favicon-light-16.png"
|
|
18
|
+
/>
|
|
19
|
+
<link
|
|
20
|
+
rel="icon"
|
|
21
|
+
type="image/png"
|
|
22
|
+
sizes="32x32"
|
|
23
|
+
href="./brand/favicon-32.png"
|
|
24
|
+
data-ez-icon
|
|
25
|
+
data-dark="/brand/favicon-32.png"
|
|
26
|
+
data-light="/brand/favicon-light-32.png"
|
|
27
|
+
/>
|
|
28
|
+
<link rel="icon" type="image/png" sizes="192x192" href="./brand/icon-192.png" />
|
|
29
|
+
<link rel="apple-touch-icon" sizes="180x180" href="./brand/apple-touch-icon.png" />
|
|
30
|
+
<script>
|
|
31
|
+
// Applies the saved theme before first paint so the page never flashes
|
|
32
|
+
// the wrong background. Dark is the default when nothing is stored.
|
|
33
|
+
(function () {
|
|
34
|
+
try {
|
|
35
|
+
var stored = localStorage.getItem('ez-theme');
|
|
36
|
+
if (stored === 'light' || stored === 'dark') {
|
|
37
|
+
document.documentElement.dataset.theme = stored;
|
|
38
|
+
}
|
|
39
|
+
} catch (_) {
|
|
40
|
+
/* storage blocked: keep the dark default */
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Keep the favicon variant in sync with the theme attribute.
|
|
44
|
+
function syncIcons() {
|
|
45
|
+
var light = document.documentElement.dataset.theme === 'light';
|
|
46
|
+
document.querySelectorAll('link[data-ez-icon]').forEach(function (link) {
|
|
47
|
+
var next = light ? link.getAttribute('data-light') : link.getAttribute('data-dark');
|
|
48
|
+
if (next) link.setAttribute('href', next);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function watchIcons() {
|
|
52
|
+
syncIcons();
|
|
53
|
+
new MutationObserver(syncIcons).observe(document.documentElement, {
|
|
54
|
+
attributes: true,
|
|
55
|
+
attributeFilter: ['data-theme'],
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (document.readyState === 'loading') {
|
|
59
|
+
document.addEventListener('DOMContentLoaded', watchIcons);
|
|
60
|
+
} else {
|
|
61
|
+
watchIcons();
|
|
62
|
+
}
|
|
63
|
+
})();
|
|
64
|
+
</script>
|
|
65
|
+
<script type="module" crossorigin src="./assets/index-DEouL3IK.js"></script>
|
|
66
|
+
<link rel="stylesheet" crossorigin href="./assets/index-CMRzkIKj.css">
|
|
67
|
+
</head>
|
|
68
|
+
<body>
|
|
69
|
+
<div id="root"></div>
|
|
70
|
+
</body>
|
|
71
|
+
</html>
|
package/install.ps1
CHANGED
|
@@ -17,6 +17,15 @@
|
|
|
17
17
|
Skip Node.js management entirely. Proceeds directly to dependency
|
|
18
18
|
installation using whatever Node.js is currently active.
|
|
19
19
|
|
|
20
|
+
.PARAMETER Service
|
|
21
|
+
Install the background service at the end without asking. On Windows Server
|
|
22
|
+
this installs a real Windows Service and relaunches elevated through UAC if
|
|
23
|
+
needed; otherwise it installs the logon launcher. No password is ever asked
|
|
24
|
+
for.
|
|
25
|
+
|
|
26
|
+
.PARAMETER NoService
|
|
27
|
+
Do not install the background service, and do not ask.
|
|
28
|
+
|
|
20
29
|
.EXAMPLE
|
|
21
30
|
.\install.ps1 # Interactive install
|
|
22
31
|
.\install.ps1 -Version 20 # Install Node.js 20.x (latest patch via nvm)
|
|
@@ -25,7 +34,9 @@
|
|
|
25
34
|
param(
|
|
26
35
|
[switch]$Help,
|
|
27
36
|
[string]$Version = "",
|
|
28
|
-
[switch]$KeepNode
|
|
37
|
+
[switch]$KeepNode,
|
|
38
|
+
[switch]$Service,
|
|
39
|
+
[switch]$NoService
|
|
29
40
|
)
|
|
30
41
|
|
|
31
42
|
Set-StrictMode -Version Latest
|
|
@@ -760,3 +771,179 @@ if ($allOK) {
|
|
|
760
771
|
Write-Host " node src/cli/index.js" -ForegroundColor Cyan
|
|
761
772
|
}
|
|
762
773
|
Write-Host ""
|
|
774
|
+
|
|
775
|
+
# ─── Offer to install the background service ─────────────────────────────────
|
|
776
|
+
#
|
|
777
|
+
# Asked LAST, after Node and the package are in place, because `ezz` has to be
|
|
778
|
+
# runnable for the answer to mean anything.
|
|
779
|
+
#
|
|
780
|
+
# Two modes on Windows, and they are genuinely different:
|
|
781
|
+
#
|
|
782
|
+
# Server — a real Windows Service. Starts before anyone logs in. Needs an
|
|
783
|
+
# Administrator terminal once, so this script relaunches itself
|
|
784
|
+
# elevated through UAC if it is not already. NO PASSWORD is ever
|
|
785
|
+
# requested: the service runs as the virtual account
|
|
786
|
+
# NT SERVICE\EasyDevOps, which Windows manages itself.
|
|
787
|
+
# Personal — a launcher in the Startup folder. Starts at logon, needs no
|
|
788
|
+
# administrator rights at all.
|
|
789
|
+
#
|
|
790
|
+
# The default follows the edition: Server on Windows Server, ask otherwise.
|
|
791
|
+
|
|
792
|
+
function Test-IsElevated {
|
|
793
|
+
try {
|
|
794
|
+
$id = [Security.Principal.WindowsIdentity]::GetCurrent()
|
|
795
|
+
$principal = New-Object Security.Principal.WindowsPrincipal($id)
|
|
796
|
+
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
797
|
+
} catch {
|
|
798
|
+
return $false
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
function Get-IsWindowsServer {
|
|
803
|
+
# InstallationType is 'Client', 'Server' or 'Server Core'. os.release() does
|
|
804
|
+
# not distinguish them, and the WMI route takes seconds to start its service
|
|
805
|
+
# on a cold machine; this is immediate.
|
|
806
|
+
try {
|
|
807
|
+
$key = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -ErrorAction Stop
|
|
808
|
+
return ($key.InstallationType -like 'Server*')
|
|
809
|
+
} catch {
|
|
810
|
+
return $false
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
function Get-EzCommand {
|
|
815
|
+
foreach ($name in @('ezz', 'easy-devops')) {
|
|
816
|
+
$found = Get-Command $name -ErrorAction SilentlyContinue
|
|
817
|
+
if ($found) { return $name }
|
|
818
|
+
}
|
|
819
|
+
$local = Join-Path $scriptDir 'src\cli\index.js'
|
|
820
|
+
if (Test-Path $local) { return "node `"$local`"" }
|
|
821
|
+
return $null
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
function Invoke-ServiceInstall {
|
|
825
|
+
param([string]$Mode)
|
|
826
|
+
|
|
827
|
+
$ez = Get-EzCommand
|
|
828
|
+
if (-not $ez) {
|
|
829
|
+
Write-Host " Could not find the ezz command, so the service was not installed." -ForegroundColor Yellow
|
|
830
|
+
Write-Host " Open a new terminal and run: ezz service install" -ForegroundColor Cyan
|
|
831
|
+
return $false
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
# Server mode writes under ProgramData, registers a service and sets ACLs,
|
|
835
|
+
# all of which need elevation. If this session is not elevated, relaunch
|
|
836
|
+
# ONLY the service install through UAC rather than re-running the whole
|
|
837
|
+
# installer -- Node is already in place and repeating it would be wasteful
|
|
838
|
+
# and could prompt again.
|
|
839
|
+
if ($Mode -eq 'server' -and -not (Test-IsElevated)) {
|
|
840
|
+
Write-Host ""
|
|
841
|
+
Write-Host " Server mode needs an Administrator terminal." -ForegroundColor Yellow
|
|
842
|
+
Write-Host " Windows will ask for consent. You will NOT be asked for a password." -ForegroundColor Gray
|
|
843
|
+
Write-Host ""
|
|
844
|
+
|
|
845
|
+
try {
|
|
846
|
+
# -Verb RunAs is what raises the UAC prompt. The child keeps its window
|
|
847
|
+
# open on failure so the user can read the error; a window that vanishes
|
|
848
|
+
# is the usual complaint about elevated helpers.
|
|
849
|
+
$inner = "$ez service install; if (`$LASTEXITCODE -ne 0) { Read-Host 'Press Enter to close' }"
|
|
850
|
+
$proc = Start-Process -FilePath 'powershell.exe' `
|
|
851
|
+
-ArgumentList '-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', $inner `
|
|
852
|
+
-Verb RunAs -Wait -PassThru -ErrorAction Stop
|
|
853
|
+
|
|
854
|
+
if ($proc.ExitCode -eq 0) { return $true }
|
|
855
|
+
|
|
856
|
+
Write-Host " The elevated install exited with code $($proc.ExitCode)." -ForegroundColor Yellow
|
|
857
|
+
return $false
|
|
858
|
+
} catch {
|
|
859
|
+
# The usual cause is the user declining the UAC prompt, which is a
|
|
860
|
+
# legitimate answer and not an error worth failing the installer over.
|
|
861
|
+
Write-Host " Elevation was declined or failed, so the service was not installed." -ForegroundColor Yellow
|
|
862
|
+
Write-Host ""
|
|
863
|
+
Write-Host " To do it yourself: open PowerShell as Administrator and run" -ForegroundColor Gray
|
|
864
|
+
Write-Host " ezz service install" -ForegroundColor Cyan
|
|
865
|
+
return $false
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
# Personal mode, or already elevated: run it here so the prompts appear in
|
|
870
|
+
# this window.
|
|
871
|
+
try {
|
|
872
|
+
Invoke-Expression "$ez service install"
|
|
873
|
+
return ($LASTEXITCODE -eq 0 -or $null -eq $LASTEXITCODE)
|
|
874
|
+
} catch {
|
|
875
|
+
Write-Host " The service install failed: $($_.Exception.Message)" -ForegroundColor Yellow
|
|
876
|
+
return $false
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
function Invoke-ServiceOffer {
|
|
881
|
+
if ($NoService) {
|
|
882
|
+
Write-Host ""
|
|
883
|
+
Write-Host " Skipping the background service (-NoService)." -ForegroundColor Gray
|
|
884
|
+
Write-Host " Install it later with: ezz service install" -ForegroundColor Cyan
|
|
885
|
+
Write-Host ""
|
|
886
|
+
return
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
$isServer = Get-IsWindowsServer
|
|
890
|
+
$mode = if ($isServer) { 'server' } else { 'personal' }
|
|
891
|
+
|
|
892
|
+
if (-not $Service) {
|
|
893
|
+
# Non-interactive host (a CI runner, or piped input): never guess on a
|
|
894
|
+
# question that may need elevation.
|
|
895
|
+
if ([Console]::IsInputRedirected) {
|
|
896
|
+
Write-Host ""
|
|
897
|
+
Write-Host " No terminal available, so the background service was not installed." -ForegroundColor Gray
|
|
898
|
+
Write-Host " Install it with: ezz service install" -ForegroundColor Cyan
|
|
899
|
+
Write-Host " Or non-interactively: .\install.ps1 -Service" -ForegroundColor Cyan
|
|
900
|
+
Write-Host ""
|
|
901
|
+
return
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
Write-Host ""
|
|
905
|
+
Write-Host " Easy DevOps can run a background service that keeps monitoring," -ForegroundColor White
|
|
906
|
+
Write-Host " notifications and the Hub agent alive even with no dashboard open." -ForegroundColor White
|
|
907
|
+
Write-Host ""
|
|
908
|
+
|
|
909
|
+
if ($isServer) {
|
|
910
|
+
Write-Host " This is Windows Server, so Server mode is recommended:" -ForegroundColor White
|
|
911
|
+
Write-Host " a real Windows Service that starts before anyone logs in." -ForegroundColor Gray
|
|
912
|
+
Write-Host " Needs Administrator consent once. No password, ever." -ForegroundColor Gray
|
|
913
|
+
} else {
|
|
914
|
+
Write-Host " On this machine it would start when you log in (Personal mode)," -ForegroundColor White
|
|
915
|
+
Write-Host " which needs no administrator rights." -ForegroundColor Gray
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
Write-Host ""
|
|
919
|
+
$answer = Read-Host " Install the background service now? (recommended for servers) [Y/n]"
|
|
920
|
+
|
|
921
|
+
if ($answer -match '^(n|no)$') {
|
|
922
|
+
Write-Host ""
|
|
923
|
+
Write-Host " Skipped. Install it later with: ezz service install" -ForegroundColor Gray
|
|
924
|
+
Write-Host ""
|
|
925
|
+
return
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
Write-Host ""
|
|
930
|
+
Write-Host " Installing the background service..." -ForegroundColor Cyan
|
|
931
|
+
Write-Host ""
|
|
932
|
+
|
|
933
|
+
$ok = Invoke-ServiceInstall -Mode $mode
|
|
934
|
+
|
|
935
|
+
Write-Host ""
|
|
936
|
+
if ($ok) {
|
|
937
|
+
Write-Host " Background service installed." -ForegroundColor Green
|
|
938
|
+
if ($mode -eq 'personal') {
|
|
939
|
+
Write-Host " It starts the next time you log in." -ForegroundColor Gray
|
|
940
|
+
Write-Host " To start it now without signing out: ezz daemon" -ForegroundColor Cyan
|
|
941
|
+
}
|
|
942
|
+
} else {
|
|
943
|
+
Write-Host " The service was not installed. Nothing else was changed." -ForegroundColor Yellow
|
|
944
|
+
Write-Host " You can retry with: ezz service install" -ForegroundColor Cyan
|
|
945
|
+
}
|
|
946
|
+
Write-Host ""
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
Invoke-ServiceOffer
|