herdr-remote 0.2.38 → 0.3.31
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/dist/chunks/353DMT35.js +3 -0
- package/dist/chunks/42KARAL4.js +31 -0
- package/dist/chunks/7AUQHB3O.js +10 -0
- package/dist/chunks/7SMZ43LI.js +9 -0
- package/dist/chunks/AM3OEMFK.js +16 -0
- package/dist/chunks/ANNJESOL.js +10 -0
- package/dist/chunks/AWB4A65P.js +63 -0
- package/dist/chunks/C2UUZY6J.js +2 -0
- package/dist/chunks/DGUZCGQN.js +3 -0
- package/dist/chunks/H24ZP5D5.js +16 -0
- package/dist/chunks/I6NRCYLI.js +3 -0
- package/dist/chunks/JJGEV4EZ.js +3 -0
- package/dist/chunks/KRSURB5L.js +5 -0
- package/dist/chunks/KRVF37OW.js +3 -0
- package/dist/chunks/KUDCC7ZO.js +6 -0
- package/dist/chunks/M3NRPJK2.js +77 -0
- package/dist/chunks/M4AFZHKH.js +3 -0
- package/dist/chunks/M52LJEES.js +6 -0
- package/dist/chunks/O2LNVFUT.js +3 -0
- package/dist/chunks/OJPBI7KB.js +3 -0
- package/dist/chunks/OMN6C7J6.js +3 -0
- package/dist/chunks/PBMBFWLQ.js +3 -0
- package/dist/chunks/PBRQ3HEG.js +3 -0
- package/dist/chunks/PFFVGFPL.js +45 -0
- package/dist/chunks/QRGNEKME.js +5 -0
- package/dist/chunks/TNLCNVA2.js +3 -0
- package/dist/chunks/U27JJKJ6.js +3 -0
- package/dist/chunks/U6QAYG3E.js +3 -0
- package/dist/chunks/UEOQE77N.js +4 -0
- package/dist/chunks/WSACSE45.js +4 -0
- package/dist/chunks/WY7WHEJ4.js +3 -0
- package/dist/chunks/XJKWLK43.js +4 -0
- package/dist/chunks/XN6D5S55.js +3 -0
- package/dist/chunks/YD3MIP7B.js +5 -0
- package/dist/chunks/YXDQ62BB.js +4 -0
- package/dist/cli.js +21 -294
- package/dist/connector/admin-broker.js +3 -302
- package/dist/connector/main.js +20 -18
- package/dist/harfbuzz-subset.wasm +0 -0
- package/dist/postinstall.js +17 -0
- package/herdr-plugin.toml +1 -1
- package/node_modules/herdr-remote-relay/bin/herdr-remote-relay.js +33 -92
- package/node_modules/herdr-remote-relay/package.json +3 -46
- package/package.json +8 -27
- package/dist/agent-status.js +0 -130
- package/dist/binary-plist.js +0 -157
- package/dist/config.js +0 -278
- package/dist/connector/admin-broker-setup.js +0 -40
- package/dist/connector/admin-shell.js +0 -67
- package/dist/connector/admin-tab.js +0 -90
- package/dist/connector/adminBrokerEndpoint.js +0 -68
- package/dist/connector/agent-watch.js +0 -123
- package/dist/connector/elevatedPty.js +0 -141
- package/dist/connector/font-server.js +0 -165
- package/dist/connector/herdr-prefix-keys.js +0 -28
- package/dist/connector/host-connector.js +0 -433
- package/dist/connector/host-hello.js +0 -32
- package/dist/connector/lock.js +0 -73
- package/dist/connector/sessions.js +0 -381
- package/dist/connector/update-report.js +0 -70
- package/dist/connector/wire.js +0 -42
- package/dist/exit-codes.js +0 -13
- package/dist/font-subset.js +0 -110
- package/dist/herdr-api.js +0 -254
- package/dist/herdr-command.js +0 -245
- package/dist/herdr-plugin.js +0 -120
- package/dist/herdr-server.js +0 -190
- package/dist/i18n/en.js +0 -257
- package/dist/i18n/index.js +0 -48
- package/dist/i18n/zh.js +0 -256
- package/dist/keepalive/detached.js +0 -97
- package/dist/keepalive/environment.js +0 -44
- package/dist/keepalive/index.js +0 -129
- package/dist/keepalive/launchd.js +0 -117
- package/dist/keepalive/systemd.js +0 -112
- package/dist/keepalive/types.js +0 -1
- package/dist/keepalive/windows-service-setup.js +0 -138
- package/dist/keepalive/windows-service.js +0 -272
- package/dist/keepalive/windows-task.js +0 -191
- package/dist/lib/process.js +0 -132
- package/dist/lifecycle.js +0 -79
- package/dist/net-interfaces.js +0 -82
- package/dist/node-pty-loader.js +0 -80
- package/dist/pasted-files.js +0 -115
- package/dist/paths.js +0 -74
- package/dist/pty-session.js +0 -133
- package/dist/relay-client.js +0 -106
- package/dist/relay-urls.js +0 -99
- package/dist/runtime.js +0 -107
- package/dist/service.js +0 -267
- package/dist/settings-model.js +0 -298
- package/dist/socket-discovery.js +0 -70
- package/dist/supervisor.js +0 -323
- package/dist/terminal-font/deps.js +0 -83
- package/dist/terminal-font/files.js +0 -357
- package/dist/terminal-font/formats.js +0 -355
- package/dist/terminal-font/index.js +0 -187
- package/dist/terminal-font/readers.js +0 -373
- package/dist/terminal-font/terminals.js +0 -147
- package/dist/terminal-palette.js +0 -399
- package/dist/tui/App.js +0 -199
- package/dist/tui/api.js +0 -91
- package/dist/tui/components/TextField.js +0 -50
- package/dist/tui/components/common.js +0 -80
- package/dist/tui/index.js +0 -36
- package/dist/tui/mouse/index.js +0 -164
- package/dist/tui/mouse/protocol.js +0 -96
- package/dist/tui/mouse/source.js +0 -79
- package/dist/tui/screens/About.js +0 -172
- package/dist/tui/screens/Herdr.js +0 -75
- package/dist/tui/screens/Keepalive.js +0 -141
- package/dist/tui/screens/Overview.js +0 -36
- package/dist/tui/screens/Pair.js +0 -74
- package/dist/tui/screens/Relay.js +0 -243
- package/dist/tui/screens/Services.js +0 -63
- package/dist/tui/screens/Wizard.js +0 -241
- package/dist/tui/terminal.js +0 -39
- package/dist/tui/theme.js +0 -33
- package/dist/update-command.js +0 -118
- package/dist/updater/in-place.js +0 -83
- package/dist/updater/npm.js +0 -62
- package/dist/updater.js +0 -401
- package/node_modules/herdr-remote-relay/README.md +0 -76
- package/node_modules/herdr-remote-relay/README.zh-CN.md +0 -76
- package/node_modules/herdr-remote-relay/config.example.json +0 -18
- package/node_modules/herdr-remote-relay/deploy/cloudflared/config.yml.example +0 -9
- package/node_modules/herdr-remote-relay/deploy/docker/compose.yaml +0 -23
- package/node_modules/herdr-remote-relay/deploy/nginx/herdr-remote-relay.conf.example +0 -49
- package/node_modules/herdr-remote-relay/deploy/systemd/herdr-remote-relay.service +0 -41
- package/node_modules/herdr-remote-relay/deploy/systemd/relay.env.example +0 -25
- package/node_modules/herdr-remote-relay/dist/auth-store.d.ts +0 -114
- package/node_modules/herdr-remote-relay/dist/auth-store.js +0 -289
- package/node_modules/herdr-remote-relay/dist/metrics.d.ts +0 -76
- package/node_modules/herdr-remote-relay/dist/metrics.js +0 -249
- package/node_modules/herdr-remote-relay/dist/protocol/frames.d.ts +0 -27
- package/node_modules/herdr-remote-relay/dist/protocol/frames.js +0 -110
- package/node_modules/herdr-remote-relay/dist/protocol/herdr-keys.d.ts +0 -8
- package/node_modules/herdr-remote-relay/dist/protocol/herdr-keys.js +0 -34
- package/node_modules/herdr-remote-relay/dist/protocol/http.d.ts +0 -165
- package/node_modules/herdr-remote-relay/dist/protocol/http.js +0 -3
- package/node_modules/herdr-remote-relay/dist/protocol/index.d.ts +0 -7
- package/node_modules/herdr-remote-relay/dist/protocol/index.js +0 -9
- package/node_modules/herdr-remote-relay/dist/protocol/messages.d.ts +0 -362
- package/node_modules/herdr-remote-relay/dist/protocol/messages.js +0 -20
- package/node_modules/herdr-remote-relay/dist/protocol/paste.d.ts +0 -14
- package/node_modules/herdr-remote-relay/dist/protocol/paste.js +0 -50
- package/node_modules/herdr-remote-relay/dist/protocol/release.d.ts +0 -8
- package/node_modules/herdr-remote-relay/dist/protocol/release.js +0 -17
- package/node_modules/herdr-remote-relay/dist/protocol/terminal.d.ts +0 -79
- package/node_modules/herdr-remote-relay/dist/protocol/terminal.js +0 -150
- package/node_modules/herdr-remote-relay/dist/relay-config.d.ts +0 -74
- package/node_modules/herdr-remote-relay/dist/relay-config.js +0 -316
- package/node_modules/herdr-remote-relay/dist/relay-server.d.ts +0 -67
- package/node_modules/herdr-remote-relay/dist/relay-server.js +0 -196
- package/node_modules/herdr-remote-relay/dist/scroll-input.d.ts +0 -17
- package/node_modules/herdr-remote-relay/dist/scroll-input.js +0 -124
- package/node_modules/herdr-remote-relay/dist/server/client-channel.d.ts +0 -3
- package/node_modules/herdr-remote-relay/dist/server/client-channel.js +0 -396
- package/node_modules/herdr-remote-relay/dist/server/font-proxy.d.ts +0 -19
- package/node_modules/herdr-remote-relay/dist/server/font-proxy.js +0 -155
- package/node_modules/herdr-remote-relay/dist/server/host-broadcasts.d.ts +0 -27
- package/node_modules/herdr-remote-relay/dist/server/host-broadcasts.js +0 -83
- package/node_modules/herdr-remote-relay/dist/server/host-channel.d.ts +0 -3
- package/node_modules/herdr-remote-relay/dist/server/host-channel.js +0 -271
- package/node_modules/herdr-remote-relay/dist/server/http-api.d.ts +0 -4
- package/node_modules/herdr-remote-relay/dist/server/http-api.js +0 -219
- package/node_modules/herdr-remote-relay/dist/server/maintenance.d.ts +0 -5
- package/node_modules/herdr-remote-relay/dist/server/maintenance.js +0 -64
- package/node_modules/herdr-remote-relay/dist/server/requests.d.ts +0 -34
- package/node_modules/herdr-remote-relay/dist/server/requests.js +0 -142
- package/node_modules/herdr-remote-relay/dist/server/sessions.d.ts +0 -36
- package/node_modules/herdr-remote-relay/dist/server/sessions.js +0 -230
- package/node_modules/herdr-remote-relay/dist/server/sockets.d.ts +0 -12
- package/node_modules/herdr-remote-relay/dist/server/sockets.js +0 -64
- package/node_modules/herdr-remote-relay/dist/server/status.d.ts +0 -11
- package/node_modules/herdr-remote-relay/dist/server/status.js +0 -99
- package/node_modules/herdr-remote-relay/dist/server/transport.d.ts +0 -16
- package/node_modules/herdr-remote-relay/dist/server/transport.js +0 -110
- package/node_modules/herdr-remote-relay/dist/server/types.d.ts +0 -133
- package/node_modules/herdr-remote-relay/dist/server/types.js +0 -3
- package/node_modules/herdr-remote-relay/dist/server/version.d.ts +0 -2
- package/node_modules/herdr-remote-relay/dist/server/version.js +0 -5
- package/node_modules/herdr-remote-relay/dist/state.d.ts +0 -6
- package/node_modules/herdr-remote-relay/dist/state.js +0 -47
- package/node_modules/ws/LICENSE +0 -20
- package/node_modules/ws/README.md +0 -548
- package/node_modules/ws/browser.js +0 -8
- package/node_modules/ws/index.js +0 -22
- package/node_modules/ws/lib/buffer-util.js +0 -131
- package/node_modules/ws/lib/constants.js +0 -19
- package/node_modules/ws/lib/event-target.js +0 -292
- package/node_modules/ws/lib/extension.js +0 -203
- package/node_modules/ws/lib/limiter.js +0 -55
- package/node_modules/ws/lib/permessage-deflate.js +0 -530
- package/node_modules/ws/lib/receiver.js +0 -743
- package/node_modules/ws/lib/sender.js +0 -607
- package/node_modules/ws/lib/stream.js +0 -161
- package/node_modules/ws/lib/subprotocol.js +0 -62
- package/node_modules/ws/lib/validation.js +0 -152
- package/node_modules/ws/lib/websocket-server.js +0 -562
- package/node_modules/ws/lib/websocket.js +0 -1407
- package/node_modules/ws/package.json +0 -74
- package/node_modules/ws/wrapper.mjs +0 -21
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a,b,c,d,e,f,g}from"./U27JJKJ6.js";import"./KRSURB5L.js";import"./DGUZCGQN.js";import"./JJGEV4EZ.js";import"./H24ZP5D5.js";import"./PBRQ3HEG.js";import"./U6QAYG3E.js";import"./PFFVGFPL.js";import"./AWB4A65P.js";import"./M4AFZHKH.js";import"./UEOQE77N.js";import"./M52LJEES.js";import"./KRVF37OW.js";import"./QRGNEKME.js";import"./PBMBFWLQ.js";import"./TNLCNVA2.js";import"./I6NRCYLI.js";export{g as fullStatus,a as managerInUse,d as restartAll,e as servicesRunning,b as startAll,c as stopAll,f as whileServicesStopped};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a as R,c as p}from"./TNLCNVA2.js";import{execFileSync as re}from"node:child_process";import te from"node:fs";import ne from"node:net";import A from"node:path";import X from"node:os";import{createHash as W}from"node:crypto";import u from"node:fs";import{createRequire as F}from"node:module";import d from"node:path";var y=F(import.meta.url),K=[".node",".dll",".exe"];function H(e,r,t){let n=["package.json"],i=(s,a)=>{let c=d.join(e,s);if(u.existsSync(c))for(let m of u.readdirSync(c,{recursive:!0,withFileTypes:!0}))m.isFile()&&a(m.name)&&n.push(d.relative(e,d.join(m.parentPath,m.name)))};i("lib",s=>s.endsWith(".js")&&!s.endsWith(".test.js"));let o=s=>K.includes(d.extname(s));return i(d.join("build","Release"),o),i(d.join("prebuilds",`${r}-${t}`),o),n}function G(e,r,t,n){let i=H(e,t,n),o=W("sha256");for(let c of i)o.update(`${c}\0`).update(u.readFileSync(d.join(e,c)));let s=d.join(r,o.digest("hex").slice(0,16));if(u.existsSync(s))return s;let a=`${s}.${process.pid}.tmp`;for(let c of i)u.mkdirSync(d.dirname(d.join(a,c)),{recursive:!0}),u.copyFileSync(d.join(e,c),d.join(a,c));try{u.renameSync(a,s)}catch(c){if(u.rmSync(a,{recursive:!0,force:!0}),!u.existsSync(s))throw c}return s}function J({platform:e=process.platform,arch:r=process.arch,source:t=d.dirname(y.resolve("node-pty/package.json")),directory:n=d.join(p(),"node-pty"),warn:i=o=>process.stderr.write(`${o}
|
|
4
|
+
`)}={}){if(e!=="win32")return y(t);try{return y(G(t,n,e,r))}catch(o){return i(`herdr-remote: could not copy node-pty out of the package: ${o.message}`),y(t)}}var O=null;function I(){return O??=J(),O}var q=["TERM_PROGRAM","TERM_PROGRAM_VERSION","ITERM_SESSION_ID","LC_TERMINAL","LC_TERMINAL_VERSION","WEZTERM_PANE","KITTY_WINDOW_ID","WT_SESSION","TMUX","TMUX_PANE","STY","ZELLIJ","ZELLIJ_SESSION_NAME","ZELLIJ_PANE_ID"],h=class e{static DEFAULT_COLS=100;static DEFAULT_ROWS=30;static MIN_DIMENSION=2;static MAX_DIMENSION=500;command;args;cwd;socketPath;platform;fastWindowsPty;spawnPty;terminal;startedAt;constructor({command:r,args:t=[],cwd:n=X.homedir(),socketPath:i,platform:o=process.platform,spawn:s=I().spawn,fastWindowsPty:a=!1}={}){if(typeof r!="string"||r.length===0)throw new TypeError("command must be a non-empty string");if(!Array.isArray(t)||!t.every(c=>typeof c=="string"))throw new TypeError("args must be strings");this.command=r,this.args=t,this.cwd=n,this.socketPath=i,this.platform=o,this.fastWindowsPty=a,this.spawnPty=s,this.terminal=null,this.startedAt=null}static childEnv(r,t=process.env){let n={...t};for(let i of Object.keys(n))i.startsWith("HERDR_")&&delete n[i];for(let i of q)delete n[i];return r&&(n.HERDR_SOCKET_PATH=r),n.TERM="xterm-256color",n.COLORTERM="truecolor",n}static clampDimension(r,t){let n=Number(r);return Number.isInteger(n)?Math.min(e.MAX_DIMENSION,Math.max(e.MIN_DIMENSION,n)):t}start({cols:r,rows:t,onData:n,onExit:i}){if(this.terminal)throw new Error("PTY session already started");this.terminal=this.spawnPty(this.command,this.args,{name:"xterm-256color",cols:e.clampDimension(r,e.DEFAULT_COLS),rows:e.clampDimension(t,e.DEFAULT_ROWS),cwd:this.cwd,env:e.childEnv(this.socketPath),...this.platform==="win32"?this.fastWindowsPty?{useConpty:!1}:{useConptyDll:!0}:{}}),this.startedAt=new Date().toISOString();let o=this.terminal;return n&&o.onData(n),i&&o.onExit(s=>{this.terminal=null,i(s)}),this}write(r){this.terminal&&this.terminal.write(Buffer.isBuffer(r)?r.toString("utf8"):String(r))}resize(r,t){this.terminal&&this.terminal.resize(e.clampDimension(r,e.DEFAULT_COLS),e.clampDimension(t,e.DEFAULT_ROWS))}info(){return{pid:this.terminal?.pid||null,command:this.command,cols:this.terminal?.cols||null,rows:this.terminal?.rows||null,cwd:this.cwd,createdAt:this.startedAt}}kill(){try{this.terminal?.kill()}catch{}this.terminal=null}};import{createHash as Y,randomBytes as z,timingSafeEqual as Z}from"node:crypto";import E from"node:fs";import V from"node:net";import $ from"node:path";var Q="HerdrRemoteAdminBroker",M="127.0.0.1",g=2*1024*1024;function ee(){let e=`${process.env.USERDOMAIN||""}\\${process.env.USERNAME||process.env.USERPROFILE||"default"}`;return Y("sha256").update(e.toLowerCase()).digest("hex").slice(0,24)}function T(){return`${Q}-${ee()}`}function P(){return $.join(p(),"admin-broker.json")}function b(e){let r=z(32).toString("hex"),t=P();E.mkdirSync($.dirname(t),{recursive:!0});let n=`${t}.${process.pid}.tmp`;return E.writeFileSync(n,JSON.stringify({port:e,token:r}),{mode:384}),E.renameSync(n,t),r}function D(e,r){if(!e||typeof r!="string")return!1;let t=Buffer.from(e),n=Buffer.from(r);return t.length===n.length&&Z(t,n)}function B(){return Object.assign(new Error("The administrator terminal broker is not running."),{code:"ENOENT"})}function x(){let e;try{e=JSON.parse(E.readFileSync(P(),"utf8"))}catch{throw B()}let{port:r,token:t}=e;if(!Number.isInteger(r)||typeof t!="string")throw B();return{socket:V.createConnection({host:M,port:r}),token:t}}function v(e,r){e.listen(0,M,()=>{r(e.address().port)})}function w(e,r){e.write(`${JSON.stringify(r)}
|
|
5
|
+
`)}var oe=1e3,ie=5e3,L=250,se=1e4,ae=1e3;function f(e){return`'${e.replaceAll("'","''")}'`}function _(e,r){try{re("powershell.exe",["-NoProfile","-NonInteractive","-EncodedCommand",Buffer.from(e,"utf16le").toString("base64")],{stdio:"pipe",windowsHide:!0,timeout:15e3})}catch{throw new Error(r("adminBroker.needsElevation"))}}function ce(){let e=A.join(R,"dist","connector","admin-broker.js"),r=`$env:HERDR_REMOTE_STATE_DIR = ${f(p())}; & ${f(process.execPath)} ${f(e)}`,t=Buffer.from(r,"utf16le").toString("base64"),n=A.join(process.env.SystemRoot||"C:\\Windows","System32","WindowsPowerShell","v1.0","powershell.exe");return`
|
|
6
|
+
$ErrorActionPreference = 'Stop'
|
|
7
|
+
$taskName = ${f(T())}
|
|
8
|
+
$user = [Security.Principal.WindowsIdentity]::GetCurrent().Name
|
|
9
|
+
$action = New-ScheduledTaskAction -Execute ${f(n)} -Argument ${f(`-NoProfile -NonInteractive -WindowStyle Hidden -EncodedCommand ${t}`)} -WorkingDirectory ${f(p())}
|
|
10
|
+
$trigger = New-ScheduledTaskTrigger -AtLogOn -User $user
|
|
11
|
+
$principal = New-ScheduledTaskPrincipal -UserId $user -LogonType Interactive -RunLevel Highest
|
|
12
|
+
$settings = New-ScheduledTaskSettingsSet -MultipleInstances IgnoreNew -StartWhenAvailable -ExecutionTimeLimit (New-TimeSpan -Seconds 0)
|
|
13
|
+
Stop-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
|
|
14
|
+
Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Force | Out-Null
|
|
15
|
+
Start-ScheduledTask -TaskName $taskName
|
|
16
|
+
`}function xe(e){if(process.platform!=="win32")throw new Error(e("adminBroker.windowsOnly"));te.mkdirSync(p(),{recursive:!0}),_(ce(),e)}function ve(e){if(process.platform!=="win32")throw new Error(e("adminBroker.windowsOnly"));_(`
|
|
17
|
+
$ErrorActionPreference = 'Stop'
|
|
18
|
+
$taskName = ${f(T())}
|
|
19
|
+
Stop-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
|
|
20
|
+
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue
|
|
21
|
+
`,e)}function C(e){let r;try{r=x()}catch{return Promise.resolve(null)}let{socket:t,token:n}=r;return new Promise(i=>{let o=!1,s="",a=c=>{o||(o=!0,t.destroy(),i(c))};t.setTimeout(oe,()=>a(null)),t.setEncoding("utf8"),t.on("connect",()=>w(t,{type:e,token:n})),t.on("data",c=>{s+=c;let m=s.indexOf(`
|
|
22
|
+
`);if(!(m<0))try{a(String(JSON.parse(s.slice(0,m)).type))}catch{a(null)}}),t.on("error",()=>a(null))})}async function le(){return await C("ping")==="pong"}async function Le(){let e=await C("shutdown");return e==="bye"?"stopped":e==="busy"?"busy":"unavailable"}function Ce(e){if(process.platform!=="win32")throw new Error(e("adminBroker.windowsOnly"));_(`
|
|
23
|
+
$ErrorActionPreference = 'Stop'
|
|
24
|
+
$taskName = ${f(T())}
|
|
25
|
+
# A broker that was just stopped may still be ending, and IgnoreNew drops a start until it has.
|
|
26
|
+
$deadline = [DateTime]::UtcNow.AddMilliseconds(${se})
|
|
27
|
+
while ((Get-ScheduledTask -TaskName $taskName).State -eq 'Running' -and [DateTime]::UtcNow -lt $deadline) { Start-Sleep -Milliseconds ${L} }
|
|
28
|
+
Start-ScheduledTask -TaskName $taskName
|
|
29
|
+
`,e)}async function je(){let e=Date.now()+ie;for(;!await le();){if(Date.now()>=e)return!1;await new Promise(r=>setTimeout(r,L))}return!0}function k(e,r){let t=r instanceof Error?r.message:String(r);w(e,{type:"error",message:t}),e.end()}function de(e,r,t){if(typeof r.command!="string"||!r.command||r.command.length>4096)throw new Error("Invalid administrator terminal command.");if(A.basename(r.command).toLowerCase()!=="powershell.exe")throw new Error("The administrator broker only starts PowerShell.");if(!Array.isArray(r.args)||r.args.length>128||!r.args.every(i=>typeof i=="string"))throw new Error("Invalid administrator terminal arguments.");if(r.args.length!==2||r.args[0]!=="-NoLogo"||r.args[1]!=="-NoProfile")throw new Error("The administrator broker only starts an interactive PowerShell prompt.");if(typeof r.cwd!="string"||r.cwd.length>4096)throw new Error("Invalid administrator terminal working directory.");if(r.socketPath!==null&&r.socketPath!==void 0)throw new Error("An administrator PowerShell session does not use a Herdr socket.");let n=new h({command:r.command,args:r.args,cwd:r.cwd,socketPath:r.socketPath,platform:"win32",fastWindowsPty:!0,spawn:t});return n.start({cols:h.clampDimension(r.cols,h.DEFAULT_COLS),rows:h.clampDimension(r.rows,h.DEFAULT_ROWS),onData:i=>{e.writable&&w(e,{type:"data",dataBase64:Buffer.from(i).toString("base64")})},onExit:({exitCode:i,signal:o})=>{e.writable&&w(e,{type:"exit",exitCode:i,signal:o}),e.end()}}),w(e,{type:"started",pid:n.terminal?.pid??0}),n}function me({spawn:e,onShutdown:r=()=>{}}={}){let t="",n=new Set,i=ne.createServer(o=>{o.setEncoding("utf8");let s="",a=null,c=!0;o.on("data",j=>{if(s+=j,Buffer.byteLength(s,"utf8")>g){o.destroy(new Error("Administrator terminal message exceeded the limit."));return}for(;;){let N=s.indexOf(`
|
|
30
|
+
`);if(N<0)return;let U=s.slice(0,N);s=s.slice(N+1);let l;try{l=JSON.parse(U)}catch{k(o,new Error("Invalid administrator terminal message."));return}if(c){if(c=!1,!D(t,l.token)){k(o,new Error("Administrator terminal request was not authorized."));return}if(l.type==="ping"){w(o,{type:"pong"}),o.end();return}if(l.type==="shutdown"){let S=n.size>0;w(o,{type:S?"busy":"bye"}),o.end(),S||(i.close(),r());return}if(l.type!=="start"){k(o,new Error("Expected an administrator terminal start request."));return}try{a=de(o,l,e),n.add(a)}catch(S){k(o,S);return}continue}if(!a)return;if(l.type==="input"&&typeof l.dataBase64=="string")l.dataBase64.length<=g&&a.write(Buffer.from(l.dataBase64,"base64"));else if(l.type==="resize")a.resize(l.cols,l.rows);else if(l.type==="kill"){a.kill(),o.end();return}}});let m=()=>{a&&(a.kill(),n.delete(a))};o.on("close",m),o.on("error",m)});return v(i,o=>{t=b(o)}),i}function ue(){if(process.platform!=="win32")throw new Error("Administrator PTYs are only supported on Windows.");me({onShutdown:()=>setTimeout(()=>process.exit(0),ae).unref()}).on("error",e=>{process.stderr.write(`herdr-remote administrator broker: ${e.message}
|
|
31
|
+
`)})}A.basename(process.argv[1]||"")==="admin-broker.js"&&ue();export{h as a,g as b,x as c,w as d,ce as e,xe as f,ve as g,le as h,Le as i,Ce as j,je as k,me as l};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a as M,b as O}from"./XN6D5S55.js";import{h as I}from"./42KARAL4.js";import{b as g}from"./JJGEV4EZ.js";import{a as x}from"./M4AFZHKH.js";import R from"node:net";var H=1e4,B=8*1024*1024,v=1e3,N=1e4,T=0;function L(r,t,n={},a={}){let{timeout:c=H,connect:o=R.connect}=a;T+=1;let m=`herdr-remote:${T}`;return new Promise((y,p)=>{let i,s="",h=!1,l=(e,u)=>{h||(h=!0,clearTimeout(w),i&&(i.removeAllListeners(),i.destroy()),e?p(e):y(u))},w=setTimeout(()=>l(new Error(`Herdr API did not answer ${t} in time`)),c);typeof w.unref=="function"&&w.unref();try{i=o(g(r))}catch(e){l(e);return}let f=i;f.setEncoding("utf8"),f.on("connect",()=>{f.write(`${JSON.stringify({id:m,method:t,params:n})}
|
|
4
|
+
`)}),f.on("data",e=>{if(s+=e,s.length>B){l(new Error("Herdr API sent an oversized response"));return}let u=s.indexOf(`
|
|
5
|
+
`);if(u===-1)return;let d;try{d=JSON.parse(s.slice(0,u))}catch{l(new Error("Herdr API sent a line that is not JSON"));return}if(d.error){let b=Object.assign(new Error(d.error.message||"Herdr API request failed"),{code:d.error.code||"herdr_api_error"});l(b);return}l(null,d.result)}),f.on("error",e=>l(e)),f.on("close",()=>l(new Error(`Herdr API closed before answering ${t}`)))})}function z(r,t,n,a={}){let{connect:c=R.connect,retryBaseMs:o=v,retryMaxMs:m=N,onStarted:y}=a,p=null,i=null,s=null,h=0,l=!1,w=()=>{if(l||i)return;let e=Math.min(o*2**h,m);h+=1,i=setTimeout(()=>{i=null,f()},e),typeof i.unref=="function"&&i.unref()},f=()=>{if(l)return;let e;try{e=c(g(r))}catch{w();return}p=e;let u="",d=null,b=!1,A=()=>{s&&clearTimeout(s),s=null};e.setEncoding("utf8"),e.on("connect",()=>{T+=1,d=`herdr-remote:subscription:${T}`,e.write(`${JSON.stringify({id:d,method:"events.subscribe",params:{subscriptions:t}})}
|
|
6
|
+
`),s=setTimeout(()=>e.destroy(),H),typeof s.unref=="function"&&s.unref()}),e.on("data",k=>{if(u+=k,Buffer.byteLength(u,"utf8")>B){e.destroy();return}let E=u.indexOf(`
|
|
7
|
+
`);for(;E!==-1;E=u.indexOf(`
|
|
8
|
+
`)){let $=u.slice(0,E);if(u=u.slice(E+1),!$)continue;let _;try{_=JSON.parse($)}catch{e.destroy();return}if(_?.id===d){if(A(),_.error){e.destroy();return}b=!0,h=0,y?.()}else if(b&&typeof _?.event=="string"&&_.data&&typeof _.data=="object")try{n(_)}catch(S){process.stderr.write(`herdr-remote: Herdr event handler failed: ${S instanceof Error?S.message:S}
|
|
9
|
+
`)}}}),e.on("error",()=>{}),e.on("close",()=>{A(),p===e&&(p=null),w()})};return f(),{close(){if(l)return;l=!0,i&&clearTimeout(i),s&&clearTimeout(s),i=null,s=null;let e=p;p=null,e&&e.destroy()}}}import C from"node:path";var D=5e3,J=100,U="HERDR_REMOTE_ADMIN_TAB";function P(r){return`'${r.replaceAll("'","''")}'`}function j(r){return`'${r.replaceAll("'","'\\''")}'`}function Q(r,t,n){let a=C.win32.basename(r).toLowerCase().replace(/\.exe$/,"");if(a==="powershell"||a==="pwsh")return`& ${P(t)} ${P(n)} admin-shell`;if(a==="cmd")return`"${t}" "${n}" admin-shell`;let c=o=>j(o.replaceAll("\\","/"));return`${c(t)} ${c(n)} admin-shell`}async function Y(r,t,n){let a=Date.now()+D;for(;;){let o=(await r(t,"pane.process_info",{pane_id:n})).process_info?.foreground_processes?.[0]?.name;if(o)return o;if(Date.now()>=a)throw new Error("The new tab did not start a shell in time.");await new Promise(m=>setTimeout(m,J))}}async function q({socketPath:r,label:t,request:n=L,brokerReady:a=I}){if(!await a())throw Object.assign(new Error("The administrator terminal broker is not running."),{code:"admin_broker_unavailable"});let c=await n(r,"tab.create",{label:t,focus:!1,env:{[U]:"1"}}),o=c.root_pane.pane_id;await n(r,"tab.focus",{tab_id:c.tab.tab_id});let m=await Y(n,r,o);await n(r,"pane.send_input",{pane_id:o,text:Q(m,process.execPath,x()),keys:["enter"]})}async function re(r,t){let n=O(M({preference:t.language}));try{await q({socketPath:t.socketPath,label:n("adminShell.tabLabel")})}catch(a){let{code:c,message:o}=a;process.stderr.write(`herdr-remote host connector: could not open an admin tab: ${o}
|
|
10
|
+
`),t.send({type:"error",clientId:r,code:c==="admin_broker_unavailable"?c:"admin_tab_failed",message:o})}}export{L as a,z as b,U as c,re as d};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a as p,b as S,d as N}from"./I6NRCYLI.js";var T=S((Er,Ve)=>{"use strict";var $e=["nodebuffer","arraybuffer","fragments"],je=typeof Blob<"u";je&&$e.push("blob");Ve.exports={BINARY_TYPES:$e,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:je,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var X=S((vr,re)=>{"use strict";var{EMPTY_BUFFER:Yt}=T(),xe=Buffer[Symbol.species];function Kt(t,e){if(t.length===0)return Yt;if(t.length===1)return t[0];let s=Buffer.allocUnsafe(e),r=0;for(let i=0;i<t.length;i++){let n=t[i];s.set(n,r),r+=n.length}return r<e?new xe(s.buffer,s.byteOffset,r):s}function ze(t,e,s,r,i){for(let n=0;n<i;n++)s[r+n]=t[n]^e[n&3]}function He(t,e){for(let s=0;s<t.length;s++)t[s]^=e[s&3]}function Xt(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Se(t){if(Se.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new xe(t):ArrayBuffer.isView(t)?e=new xe(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Se.readOnly=!1),e}re.exports={concat:Kt,mask:ze,toArrayBuffer:Xt,toBuffer:Se,unmask:He};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=p("bufferutil");re.exports.mask=function(e,s,r,i,n){n<48?ze(e,s,r,i,n):t.mask(e,s,r,i,n)},re.exports.unmask=function(e,s){e.length<32?He(e,s):t.unmask(e,s)}}catch{}});var Xe=S((br,Ke)=>{"use strict";var Ye=Symbol("kDone"),Ee=Symbol("kRun"),ve=class{constructor(e){this[Ye]=()=>{this.pending--,this[Ee]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ee]()}[Ee](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Ye])}}};Ke.exports=ve});var G=S((wr,et)=>{"use strict";var Z=p("zlib"),Ze=X(),Zt=Xe(),{kStatusCode:Qe}=T(),Qt=Buffer[Symbol.species],Jt=Buffer.from([0,0,255,255]),ne=Symbol("permessage-deflate"),k=Symbol("total-length"),W=Symbol("callback"),P=Symbol("buffers"),q=Symbol("error"),ie,be=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ie){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ie=new Zt(s)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[W];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,r=e.find(i=>!(s.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>i.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&(typeof i.client_max_window_bits=="number"?s.clientMaxWindowBits>i.client_max_window_bits:!i.client_max_window_bits)));if(!r)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(r.server_no_context_takeover=!0),s.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(r.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?r.client_max_window_bits=s.clientMaxWindowBits:(r.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(r=>{let i=s[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="client_max_window_bits"){if(i!==!0){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=n}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);s[r]=i})}),e}decompress(e,s,r){ie.add(i=>{this._decompress(e,s,(n,o)=>{i(),r(n,o)})})}compress(e,s,r){ie.add(i=>{this._compress(e,s,(n,o)=>{i(),r(n,o)})})}_decompress(e,s,r){let i=this._isServer?"client":"server";if(!this._inflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Z.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Z.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[ne]=this,this._inflate[k]=0,this._inflate[P]=[],this._inflate.on("error",ts),this._inflate.on("data",Je)}this._inflate[W]=r,this._inflate.write(e),s&&this._inflate.write(Jt),this._inflate.flush(()=>{let n=this._inflate[q];if(n){this._inflate.close(),this._inflate=null,r(n);return}let o=Ze.concat(this._inflate[P],this._inflate[k]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[k]=0,this._inflate[P]=[],s&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,s,r){let i=this._isServer?"server":"client";if(!this._deflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Z.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Z.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[k]=0,this._deflate[P]=[],this._deflate.on("data",es)}this._deflate[W]=r,this._deflate.write(e),this._deflate.flush(Z.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Ze.concat(this._deflate[P],this._deflate[k]);s&&(n=new Qt(n.buffer,n.byteOffset,n.length-4)),this._deflate[W]=null,this._deflate[k]=0,this._deflate[P]=[],s&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,n)})}};et.exports=be;function es(t){this[P].push(t),this[k]+=t.length}function Je(t){if(this[k]+=t.length,this[ne]._maxPayload<1||this[k]<=this[ne]._maxPayload){this[P].push(t);return}this[q]=new RangeError("Max payload size exceeded"),this[q].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[q][Qe]=1009,this.removeListener("data",Je),this.reset()}function ts(t){if(this[ne]._inflate=null,this[q]){this[W](this[q]);return}t[Qe]=1007,this[W](t)}});var $=S((Or,oe)=>{"use strict";var{isUtf8:tt}=p("buffer"),{hasBlob:ss}=T(),rs=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function is(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function we(t){let e=t.length,s=0;for(;s<e;)if((t[s]&128)===0)s++;else if((t[s]&224)===192){if(s+1===e||(t[s+1]&192)!==128||(t[s]&254)===192)return!1;s+=2}else if((t[s]&240)===224){if(s+2>=e||(t[s+1]&192)!==128||(t[s+2]&192)!==128||t[s]===224&&(t[s+1]&224)===128||t[s]===237&&(t[s+1]&224)===160)return!1;s+=3}else if((t[s]&248)===240){if(s+3>=e||(t[s+1]&192)!==128||(t[s+2]&192)!==128||(t[s+3]&192)!==128||t[s]===240&&(t[s+1]&240)===128||t[s]===244&&t[s+1]>143||t[s]>244)return!1;s+=4}else return!1;return!0}function ns(t){return ss&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}oe.exports={isBlob:ns,isValidStatusCode:is,isValidUTF8:we,tokenChars:rs};if(tt)oe.exports.isValidUTF8=function(t){return t.length<24?we(t):tt(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=p("utf-8-validate");oe.exports.isValidUTF8=function(e){return e.length<32?we(e):t(e)}}catch{}});var Le=S((Tr,ft)=>{"use strict";var{Writable:os}=p("stream"),st=G(),{BINARY_TYPES:as,EMPTY_BUFFER:rt,kStatusCode:fs,kWebSocket:ls}=T(),{concat:Oe,toArrayBuffer:hs,unmask:cs}=X(),{isValidStatusCode:us,isValidUTF8:it}=$(),ae=Buffer[Symbol.species],v=0,nt=1,ot=2,at=3,Te=4,ke=5,fe=6,Ce=class extends os{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||as[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[ls]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=v}_write(e,s,r){if(this._opcode===8&&this._state==v)return r();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){r(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new ae(r.buffer,r.byteOffset+e,r.length-e),new ae(r.buffer,r.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let r=this._buffers[0],i=s.length-e;e>=r.length?s.set(this._buffers.shift(),i):(s.set(new Uint8Array(r.buffer,r.byteOffset,e),i),this._buffers[0]=new ae(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case v:this.getInfo(e);break;case nt:this.getPayloadLength16(e);break;case ot:this.getPayloadLength64(e);break;case at:this.getMask();break;case Te:this.getData(e);break;case ke:case fe:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(i);return}let r=(s[0]&64)===64;if(r&&!this._extensions[st.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(i);return}if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(i);return}this._payloadLength===126?this._state=nt:this._payloadLength===127?this._state=ot:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let s=this.consume(8),r=s.readUInt32BE(0);if(r>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(i);return}this._payloadLength=r*Math.pow(2,32)+s.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=at:this._state=Te}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Te}getData(e){let s=rt;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&cs(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let r=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(r);return}if(this._compressed){this._state=ke,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[st.extensionName].decompress(e,this._fin,(i,n)=>{if(i)return s(i);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(o);return}this._fragments.push(n)}this.dataMessage(s),this._state===v&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=v;return}let s=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Oe(r,s):this._binaryType==="arraybuffer"?i=hs(Oe(r,s)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=v):(this._state=fe,setImmediate(()=>{this.emit("message",i,!0),this._state=v,this.startLoop(e)}))}else{let i=Oe(r,s);if(!this._skipUTF8Validation&&!it(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(n);return}this._state===ke||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=v):(this._state=fe,setImmediate(()=>{this.emit("message",i,!1),this._state=v,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,rt),this.end();else{let r=e.readUInt16BE(0);if(!us(r)){let n=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(n);return}let i=new ae(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!it(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(n);return}this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=v;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=v):(this._state=fe,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=v,this.startLoop(s)}))}createError(e,s,r,i,n){this._loop=!1,this._errored=!0;let o=new e(r?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(o,this.createError),o.code=n,o[fs]=i,o}};ft.exports=Ce});var Be=S((Cr,ct)=>{"use strict";var{Duplex:kr}=p("stream"),{randomFillSync:ds}=p("crypto"),{types:{isUint8Array:_s}}=p("util"),lt=G(),{EMPTY_BUFFER:ms,kWebSocket:ps,NOOP:gs}=T(),{isBlob:j,isValidStatusCode:ys}=$(),{mask:ht,toBuffer:R}=X(),b=Symbol("kByteLength"),xs=Buffer.alloc(4),le=8*1024,U,V=le,w=0,Ss=1,Es=2,Ne=class t{constructor(e,s,r){this._extensions=s||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=w,this.onerror=gs,this[ps]=void 0}static frame(e,s){let r,i=!1,n=2,o=!1;s.mask&&(r=s.maskBuffer||xs,s.generateMask?s.generateMask(r):(V===le&&(U===void 0&&(U=Buffer.alloc(le)),ds(U,0,le),V=0),r[0]=U[V++],r[1]=U[V++],r[2]=U[V++],r[3]=U[V++]),o=(r[0]|r[1]|r[2]|r[3])===0,n=6);let f;typeof e=="string"?(!s.mask||o)&&s[b]!==void 0?f=s[b]:(e=Buffer.from(e),f=e.length):(f=e.length,i=s.mask&&s.readOnly&&!o);let l=f;f>=65536?(n+=8,l=127):f>125&&(n+=2,l=126);let a=Buffer.allocUnsafe(i?f+n:n);return a[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(a[0]|=64),a[1]=l,l===126?a.writeUInt16BE(f,2):l===127&&(a[2]=a[3]=0,a.writeUIntBE(f,4,6)),s.mask?(a[1]|=128,a[n-4]=r[0],a[n-3]=r[1],a[n-2]=r[2],a[n-1]=r[3],o?[a,e]:i?(ht(e,r,a,n,f),[a]):(ht(e,r,e,0,f),[a,e])):[a,e]}close(e,s,r,i){let n;if(e===void 0)n=ms;else{if(typeof e!="number"||!ys(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let f=Buffer.byteLength(s);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");if(n=Buffer.allocUnsafe(2+f),n.writeUInt16BE(e,0),typeof s=="string")n.write(s,2);else if(_s(s))n.set(s,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[b]:n.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==w?this.enqueue([this.dispatch,n,!1,o,i]):this.sendFrame(t.frame(n,o),i)}ping(e,s,r){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):j(e)?(i=e.size,n=!1):(e=R(e),i=e.length,n=R.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==w?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}pong(e,s,r){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):j(e)?(i=e.size,n=!1):(e=R(e),i=e.length,n=R.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==w?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}send(e,s,r){let i=this._extensions[lt.extensionName],n=s.binary?2:1,o=s.compress,f,l;typeof e=="string"?(f=Buffer.byteLength(e),l=!1):j(e)?(f=e.size,l=!1):(e=R(e),f=e.length,l=R.readOnly),this._firstFragment?(this._firstFragment=!1,o&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=f>=i._threshold),this._compress=o):(o=!1,n=0),s.fin&&(this._firstFragment=!0);let a={[b]:f,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:l,rsv1:o};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,this._compress,a,r]):this.getBlobData(e,this._compress,a,r):this._state!==w?this.enqueue([this.dispatch,e,this._compress,a,r]):this.dispatch(e,this._compress,a,r)}getBlobData(e,s,r,i){this._bufferedBytes+=r[b],this._state=Es,e.arrayBuffer().then(n=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(Pe,this,f,i);return}this._bufferedBytes-=r[b];let o=R(n);s?this.dispatch(o,s,r,i):(this._state=w,this.sendFrame(t.frame(o,r),i),this.dequeue())}).catch(n=>{process.nextTick(vs,this,n,i)})}dispatch(e,s,r,i){if(!s){this.sendFrame(t.frame(e,r),i);return}let n=this._extensions[lt.extensionName];this._bufferedBytes+=r[b],this._state=Ss,n.compress(e,r.fin,(o,f)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");Pe(this,l,i);return}this._bufferedBytes-=r[b],this._state=w,r.readOnly=!1,this.sendFrame(t.frame(f,r),i),this.dequeue()})}dequeue(){for(;this._state===w&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][b],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][b],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};ct.exports=Ne;function Pe(t,e,s){typeof s=="function"&&s(e);for(let r=0;r<t._queue.length;r++){let i=t._queue[r],n=i[i.length-1];typeof n=="function"&&n(e)}}function vs(t,e,s){Pe(t,e,s),t.onerror(e)}});var St=S((Lr,xt)=>{"use strict";var{kForOnEventAttribute:Q,kListener:Re}=T(),ut=Symbol("kCode"),dt=Symbol("kData"),_t=Symbol("kError"),mt=Symbol("kMessage"),pt=Symbol("kReason"),z=Symbol("kTarget"),gt=Symbol("kType"),yt=Symbol("kWasClean"),C=class{constructor(e){this[z]=null,this[gt]=e}get target(){return this[z]}get type(){return this[gt]}};Object.defineProperty(C.prototype,"target",{enumerable:!0});Object.defineProperty(C.prototype,"type",{enumerable:!0});var I=class extends C{constructor(e,s={}){super(e),this[ut]=s.code===void 0?0:s.code,this[pt]=s.reason===void 0?"":s.reason,this[yt]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[ut]}get reason(){return this[pt]}get wasClean(){return this[yt]}};Object.defineProperty(I.prototype,"code",{enumerable:!0});Object.defineProperty(I.prototype,"reason",{enumerable:!0});Object.defineProperty(I.prototype,"wasClean",{enumerable:!0});var H=class extends C{constructor(e,s={}){super(e),this[_t]=s.error===void 0?null:s.error,this[mt]=s.message===void 0?"":s.message}get error(){return this[_t]}get message(){return this[mt]}};Object.defineProperty(H.prototype,"error",{enumerable:!0});Object.defineProperty(H.prototype,"message",{enumerable:!0});var J=class extends C{constructor(e,s={}){super(e),this[dt]=s.data===void 0?null:s.data}get data(){return this[dt]}};Object.defineProperty(J.prototype,"data",{enumerable:!0});var bs={addEventListener(t,e,s={}){for(let i of this.listeners(t))if(!s[Q]&&i[Re]===e&&!i[Q])return;let r;if(t==="message")r=function(n,o){let f=new J("message",{data:o?n:n.toString()});f[z]=this,he(e,this,f)};else if(t==="close")r=function(n,o){let f=new I("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[z]=this,he(e,this,f)};else if(t==="error")r=function(n){let o=new H("error",{error:n,message:n.message});o[z]=this,he(e,this,o)};else if(t==="open")r=function(){let n=new C("open");n[z]=this,he(e,this,n)};else return;r[Q]=!!s[Q],r[Re]=e,s.once?this.once(t,r):this.on(t,r)},removeEventListener(t,e){for(let s of this.listeners(t))if(s[Re]===e&&!s[Q]){this.removeListener(t,s);break}}};xt.exports={CloseEvent:I,ErrorEvent:H,Event:C,EventTarget:bs,MessageEvent:J};function he(t,e,s){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,s):t.call(e,s)}});var ce=S((Nr,Et)=>{"use strict";var{tokenChars:ee}=$();function O(t,e,s){t[e]===void 0?t[e]=[s]:t[e].push(s)}function ws(t){let e=Object.create(null),s=Object.create(null),r=!1,i=!1,n=!1,o,f,l=-1,a=-1,h=-1,c=0;for(;c<t.length;c++)if(a=t.charCodeAt(c),o===void 0)if(h===-1&&ee[a]===1)l===-1&&(l=c);else if(c!==0&&(a===32||a===9))h===-1&&l!==-1&&(h=c);else if(a===59||a===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(l,h);a===44?(O(e,g,s),s=Object.create(null)):o=g,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(f===void 0)if(h===-1&&ee[a]===1)l===-1&&(l=c);else if(a===32||a===9)h===-1&&l!==-1&&(h=c);else if(a===59||a===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c),O(s,t.slice(l,h),!0),a===44&&(O(e,o,s),s=Object.create(null),o=void 0),l=h=-1}else if(a===61&&l!==-1&&h===-1)f=t.slice(l,c),l=h=-1;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(i){if(ee[a]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);l===-1?l=c:r||(r=!0),i=!1}else if(n)if(ee[a]===1)l===-1&&(l=c);else if(a===34&&l!==-1)n=!1,h=c;else if(a===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(a===34&&t.charCodeAt(c-1)===61)n=!0;else if(h===-1&&ee[a]===1)l===-1&&(l=c);else if(l!==-1&&(a===32||a===9))h===-1&&(h=c);else if(a===59||a===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(l,h);r&&(g=g.replace(/\\/g,""),r=!1),O(s,f,g),a===44&&(O(e,o,s),s=Object.create(null),o=void 0),f=void 0,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);if(l===-1||n||a===32||a===9)throw new SyntaxError("Unexpected end of input");h===-1&&(h=c);let _=t.slice(l,h);return o===void 0?O(e,_,s):(f===void 0?O(s,_,!0):r?O(s,f,_.replace(/\\/g,"")):O(s,f,_),O(e,o,s)),e}function Os(t){return Object.keys(t).map(e=>{let s=t[e];return Array.isArray(s)||(s=[s]),s.map(r=>[e].concat(Object.keys(r).map(i=>{let n=r[i];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Et.exports={format:Os,parse:ws}});var me=S((Rr,Rt)=>{"use strict";var Ts=p("events"),ks=p("https"),Cs=p("http"),wt=p("net"),Ls=p("tls"),{randomBytes:Ns,createHash:Ps}=p("crypto"),{Duplex:Pr,Readable:Br}=p("stream"),{URL:Ue}=p("url"),B=G(),Bs=Le(),Rs=Be(),{isBlob:Us}=$(),{BINARY_TYPES:vt,CLOSE_TIMEOUT:Is,EMPTY_BUFFER:ue,GUID:Ds,kForOnEventAttribute:Ie,kListener:Ms,kStatusCode:Fs,kWebSocket:y,NOOP:Ot}=T(),{EventTarget:{addEventListener:As,removeEventListener:Ws}}=St(),{format:qs,parse:Gs}=ce(),{toBuffer:$s}=X(),Tt=Symbol("kAborted"),De=[8,13],L=["CONNECTING","OPEN","CLOSING","CLOSED"],js=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,d=class t extends Ts{constructor(e,s,r){super(),this._binaryType=vt[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ue,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?s=[]:Array.isArray(s)||(typeof s=="object"&&s!==null?(r=s,s=[]):s=[s]),kt(this,e,s,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){vt.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,s,r){let i=new Bs({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),n=new Rs(e,this._extensions,r.generateMask);this._receiver=i,this._sender=n,this._socket=e,i[y]=this,n[y]=this,e[y]=this,i.on("conclude",Hs),i.on("drain",Ys),i.on("error",Ks),i.on("message",Xs),i.on("ping",Zs),i.on("pong",Qs),n.onerror=Js,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",Nt),e.on("data",_e),e.on("end",Pt),e.on("error",Bt),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[B.extensionName]&&this._extensions[B.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,s,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Lt(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=s=void 0):typeof s=="function"&&(r=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Me(this,e,r);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||ue,s,r)}pong(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=s=void 0):typeof s=="function"&&(r=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Me(this,e,r);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||ue,s,r)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(r=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Me(this,e,r);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[B.extensionName]||(i.compress=!1),this._sender.send(e||ue,i,r)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(d,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d.prototype,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d.prototype,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d.prototype,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});Object.defineProperty(d.prototype,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(d.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(d.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Ie])return e[Ms];return null},set(e){for(let s of this.listeners(t))if(s[Ie]){this.removeListener(t,s);break}typeof e=="function"&&this.addEventListener(t,e,{[Ie]:!0})}})});d.prototype.addEventListener=As;d.prototype.removeEventListener=Ws;Rt.exports=d;function kt(t,e,s,r){let i={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Is,protocolVersion:De[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=i.autoPong,t._closeTimeout=i.closeTimeout,!De.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${De.join(", ")})`);let n;if(e instanceof Ue)n=e;else try{n=new Ue(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}n.protocol==="http:"?n.protocol="ws:":n.protocol==="https:"&&(n.protocol="wss:"),t._url=n.href;let o=n.protocol==="wss:",f=n.protocol==="ws+unix:",l;if(n.protocol!=="ws:"&&!o&&!f?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!n.pathname?l="The URL's pathname is empty":n.hash&&(l="The URL contains a fragment identifier"),l){let u=new SyntaxError(l);if(t._redirects===0)throw u;de(t,u);return}let a=o?443:80,h=Ns(16).toString("base64"),c=o?ks.request:Cs.request,_=new Set,g;if(i.createConnection=i.createConnection||(o?zs:Vs),i.defaultPort=i.defaultPort||a,i.port=n.port||a,i.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"},i.path=n.pathname+n.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(g=new B({...i.perMessageDeflate,isServer:!1,maxPayload:i.maxPayload}),i.headers["Sec-WebSocket-Extensions"]=qs({[B.extensionName]:g.offer()})),s.length){for(let u of s){if(typeof u!="string"||!js.test(u)||_.has(u))throw new SyntaxError("An invalid or duplicated subprotocol was specified");_.add(u)}i.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(n.username||n.password)&&(i.auth=`${n.username}:${n.password}`),f){let u=i.path.split(":");i.socketPath=u[0],i.path=u[1]}let m;if(i.followRedirects){if(t._redirects===0){t._originalIpc=f,t._originalSecure=o,t._originalHostOrSocketPath=f?i.socketPath:n.host;let u=r&&r.headers;if(r={...r,headers:{}},u)for(let[x,F]of Object.entries(u))r.headers[x.toLowerCase()]=F}else if(t.listenerCount("redirect")===0){let u=f?t._originalIpc?i.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:n.host===t._originalHostOrSocketPath;(!u||t._originalSecure&&!o)&&(delete i.headers.authorization,delete i.headers.cookie,u||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),m=t._req=c(i),t._redirects&&t.emit("redirect",t.url,m)}else m=t._req=c(i);i.timeout&&m.on("timeout",()=>{E(t,m,"Opening handshake has timed out")}),m.on("error",u=>{m===null||m[Tt]||(m=t._req=null,de(t,u))}),m.on("response",u=>{let x=u.headers.location,F=u.statusCode;if(x&&i.followRedirects&&F>=300&&F<400){if(++t._redirects>i.maxRedirects){E(t,m,"Maximum redirects exceeded");return}m.abort();let Y;try{Y=new Ue(x,e)}catch{let A=new SyntaxError(`Invalid URL: ${x}`);de(t,A);return}kt(t,Y,s,r)}else t.emit("unexpected-response",m,u)||E(t,m,`Unexpected server response: ${u.statusCode}`)}),m.on("upgrade",(u,x,F)=>{if(t.emit("upgrade",u),t.readyState!==d.CONNECTING)return;m=t._req=null;let Y=u.headers.upgrade;if(Y===void 0||Y.toLowerCase()!=="websocket"){E(t,x,"Invalid Upgrade header");return}let We=Ps("sha1").update(h+Ds).digest("base64");if(u.headers["sec-websocket-accept"]!==We){E(t,x,"Invalid Sec-WebSocket-Accept header");return}let A=u.headers["sec-websocket-protocol"],K;if(A!==void 0?_.size?_.has(A)||(K="Server sent an invalid subprotocol"):K="Server sent a subprotocol but none was requested":_.size&&(K="Server sent no subprotocol"),K){E(t,x,K);return}A&&(t._protocol=A);let qe=u.headers["sec-websocket-extensions"];if(qe!==void 0){if(!g){E(t,x,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ge;try{ge=Gs(qe)}catch{E(t,x,"Invalid Sec-WebSocket-Extensions header");return}let Ge=Object.keys(ge);if(Ge.length!==1||Ge[0]!==B.extensionName){E(t,x,"Server indicated an extension that was not requested");return}try{g.accept(ge[B.extensionName])}catch{E(t,x,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[B.extensionName]=g}t.setSocket(x,F,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(m,t):m.end()}function de(t,e){t._readyState=d.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Vs(t){return t.path=t.socketPath,wt.connect(t)}function zs(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=wt.isIP(t.host)?"":t.host),Ls.connect(t)}function E(t,e,s){t._readyState=d.CLOSING;let r=new Error(s);Error.captureStackTrace(r,E),e.setHeader?(e[Tt]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(de,t,r)):(e.destroy(r),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Me(t,e,s){if(e){let r=Us(e)?e.size:$s(e).length;t._socket?t._sender._bufferedBytes+=r:t._bufferedAmount+=r}if(s){let r=new Error(`WebSocket is not open: readyState ${t.readyState} (${L[t.readyState]})`);process.nextTick(s,r)}}function Hs(t,e){let s=this[y];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=t,s._socket[y]!==void 0&&(s._socket.removeListener("data",_e),process.nextTick(Ct,s._socket),t===1005?s.close():s.close(t,e))}function Ys(){let t=this[y];t.isPaused||t._socket.resume()}function Ks(t){let e=this[y];e._socket[y]!==void 0&&(e._socket.removeListener("data",_e),process.nextTick(Ct,e._socket),e.close(t[Fs])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function bt(){this[y].emitClose()}function Xs(t,e){this[y].emit("message",t,e)}function Zs(t){let e=this[y];e._autoPong&&e.pong(t,!this._isServer,Ot),e.emit("ping",t)}function Qs(t){this[y].emit("pong",t)}function Ct(t){t.resume()}function Js(t){let e=this[y];e.readyState!==d.CLOSED&&(e.readyState===d.OPEN&&(e._readyState=d.CLOSING,Lt(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Lt(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Nt(){let t=this[y];if(this.removeListener("close",Nt),this.removeListener("data",_e),this.removeListener("end",Pt),t._readyState=d.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[y]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",bt),t._receiver.on("finish",bt))}function _e(t){this[y]._receiver.write(t)||this.pause()}function Pt(){let t=this[y];t._readyState=d.CLOSING,t._receiver.end(),this.end()}function Bt(){let t=this[y];this.removeListener("error",Bt),this.on("error",Ot),t&&(t._readyState=d.CLOSING,this.destroy())}});var Mt=S((Ir,Dt)=>{"use strict";var Ur=me(),{Duplex:er}=p("stream");function Ut(t){t.emit("close")}function tr(){!this.destroyed&&this._writableState.finished&&this.destroy()}function It(t){this.removeListener("error",It),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function sr(t,e){let s=!0,r=new er({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(n,o){let f=!o&&r._readableState.objectMode?n.toString():n;r.push(f)||t.pause()}),t.once("error",function(n){r.destroyed||(s=!1,r.destroy(n))}),t.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(i,n){if(t.readyState===t.CLOSED){n(i),process.nextTick(Ut,r);return}let o=!1;t.once("error",function(l){o=!0,n(l)}),t.once("close",function(){o||n(i),process.nextTick(Ut,r)}),s&&t.terminate()},r._final=function(i){if(t.readyState===t.CONNECTING){t.once("open",function(){r._final(i)});return}t._socket!==null&&(t._socket._writableState.finished?(i(),r._readableState.endEmitted&&r.destroy()):(t._socket.once("finish",function(){i()}),t.close()))},r._read=function(){t.isPaused&&t.resume()},r._write=function(i,n,o){if(t.readyState===t.CONNECTING){t.once("open",function(){r._write(i,n,o)});return}t.send(i,o)},r.on("end",tr),r.on("error",It),r}Dt.exports=sr});var Fe=S((Dr,Ft)=>{"use strict";var{tokenChars:rr}=$();function ir(t){let e=new Set,s=-1,r=-1,i=0;for(i;i<t.length;i++){let o=t.charCodeAt(i);if(r===-1&&rr[o]===1)s===-1&&(s=i);else if(i!==0&&(o===32||o===9))r===-1&&s!==-1&&(r=i);else if(o===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${i}`);r===-1&&(r=i);let f=t.slice(s,r);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),s=r=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(s===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let n=t.slice(s,i);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}Ft.exports={parse:ir}});var Vt=S((Fr,jt)=>{"use strict";var nr=p("events"),pe=p("http"),{Duplex:Mr}=p("stream"),{createHash:or}=p("crypto"),At=ce(),D=G(),ar=Fe(),fr=me(),{CLOSE_TIMEOUT:lr,GUID:hr,kWebSocket:cr}=T(),ur=/^[+/0-9A-Za-z]{22}==$/,Wt=0,qt=1,$t=2,Ae=class extends nr{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:lr,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:fr,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=pe.createServer((r,i)=>{let n=pe.STATUS_CODES[426];i.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),i.end(n)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=dr(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,n,o)=>{this.handleUpgrade(i,n,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Wt}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===$t){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(te,this);return}if(e&&this.once("close",e),this._state!==qt)if(this._state=qt,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(te,this):process.nextTick(te,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{te(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,r,i){s.on("error",Gt);let n=e.headers["sec-websocket-key"],o=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){M(this,e,s,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){M(this,e,s,400,"Invalid Upgrade header");return}if(n===void 0||!ur.test(n)){M(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){M(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){se(s,400);return}let l=e.headers["sec-websocket-protocol"],a=new Set;if(l!==void 0)try{a=ar.parse(l)}catch{M(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let h=e.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&h!==void 0){let _=new D({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let g=At.parse(h);g[D.extensionName]&&(_.accept(g[D.extensionName]),c[D.extensionName]=_)}catch{M(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let _={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(_,(g,m,u,x)=>{if(!g)return se(s,m||401,u,x);this.completeUpgrade(c,n,a,e,s,r,i)});return}if(!this.options.verifyClient(_))return se(s,401)}this.completeUpgrade(c,n,a,e,s,r,i)}completeUpgrade(e,s,r,i,n,o,f){if(!n.readable||!n.writable)return n.destroy();if(n[cr])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Wt)return se(n,503);let a=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${or("sha1").update(s+hr).digest("base64")}`],h=new this.options.WebSocket(null,void 0,this.options);if(r.size){let c=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;c&&(a.push(`Sec-WebSocket-Protocol: ${c}`),h._protocol=c)}if(e[D.extensionName]){let c=e[D.extensionName].params,_=At.format({[D.extensionName]:[c]});a.push(`Sec-WebSocket-Extensions: ${_}`),h._extensions=e}this.emit("headers",a,i),n.write(a.concat(`\r
|
|
4
|
+
`).join(`\r
|
|
5
|
+
`)),n.removeListener("error",Gt),h.setSocket(n,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(h),h.on("close",()=>{this.clients.delete(h),this._shouldEmitClose&&!this.clients.size&&process.nextTick(te,this)})),f(h,i)}};jt.exports=Ae;function dr(t,e){for(let s of Object.keys(e))t.on(s,e[s]);return function(){for(let r of Object.keys(e))t.removeListener(r,e[r])}}function te(t){t._state=$t,t.emit("close")}function Gt(){this.destroy()}function se(t,e,s,r){s=s||pe.STATUS_CODES[e],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${pe.STATUS_CODES[e]}\r
|
|
6
|
+
`+Object.keys(r).map(i=>`${i}: ${r[i]}`).join(`\r
|
|
7
|
+
`)+`\r
|
|
8
|
+
\r
|
|
9
|
+
`+s)}function M(t,e,s,r,i,n){if(t.listenerCount("wsClientError")){let o=new Error(i);Error.captureStackTrace(o,M),t.emit("wsClientError",o,s,e)}else se(s,r,i,n)}});var _r=N(Mt(),1),mr=N(ce(),1),pr=N(G(),1),gr=N(Le(),1),yr=N(Be(),1),xr=N(Fe(),1),zt=N(me(),1),Sr=N(Vt(),1);var Ar=zt.default;export{zt as a,Ar as b};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{e as m,f as S,g as l,h as v,i as h,j as $,k as g,l as x,m as A}from"./AWB4A65P.js";import"./M4AFZHKH.js";import"./UEOQE77N.js";import"./QRGNEKME.js";import"./PBMBFWLQ.js";import"./TNLCNVA2.js";import"./I6NRCYLI.js";import{spawnSync as f}from"node:child_process";import P from"node:fs";var y=3;function I({id:n,account:t}){let r=l(n),e=l(t);return`$ErrorActionPreference = 'Stop'
|
|
4
|
+
$password = [Console]::In.ReadLine()
|
|
5
|
+
$service = Get-CimInstance -ClassName Win32_Service -Filter "Name='${r}'"
|
|
6
|
+
$result = Invoke-CimMethod -InputObject $service -MethodName Change -Arguments @{ StartName = '${e}'; StartPassword = $password }
|
|
7
|
+
exit [int]$result.ReturnValue`}function b(n,t,r){let e=I({id:n,account:t});return f("powershell.exe",["-NoProfile","-NonInteractive","-EncodedCommand",v(e)],{input:`${r}
|
|
8
|
+
`,encoding:"utf8",windowsHide:!0})}function k(n){let t=process.stdin;return process.stdout.write(n),t.setRawMode(!0),t.resume(),new Promise(r=>{let e="",i=o=>{t.removeListener("data",c),t.setRawMode(!1),t.pause(),process.stdout.write(`
|
|
9
|
+
`),r(o)},c=o=>{let u=String(o).replace(/\x1b(?:\[[0-9;?]*[ -/]*[@-~]|\][^\x07\x1b]*(?:\x07|\x1b\\)|O.|.)/g,"");for(let s of u){if(s==="\r"||s===`
|
|
10
|
+
`)return i(e);if(s==="")return i(null);if(s==="\x7F"||s==="\b"){e.length>0&&(e=Array.from(e).slice(0,-1).join(""),process.stdout.write("\b \b"));continue}let a=s.codePointAt(0)||0;a<32||a>=127&&a<=159||(e+=s,process.stdout.write("*"))}};t.on("data",c)})}function w(n,t){let r=String(t.stdout||t.stderr||"").trim();return new Error(`${n} failed (${String(t.status)}): ${r}`)}async function C(n,t,r,e={}){let i=e.setAccount||b,c=e.start||$,o=e.prompt||(s=>k(r("keepalive.passwordPrompt",{account:s}))),u=e.write||(s=>process.stdout.write(s));for(let s=0;s<=y;s+=1){let a=s===0?"":await o(t);if(a===null)return!1;let d=i(n,t,a);if(d.error||d.status!==0)throw w("Setting the Windows service account",d);let p=h(c());if(p==="ok")return!0;if(p!=="logon-failed")return u(`${p.message}
|
|
11
|
+
`),!1;u(`${r("keepalive.passwordRejected")}
|
|
12
|
+
`)}return!1}async function E(n){try{let t=S();if(!P.existsSync(t.unitPath))return process.stdout.write(`${n("keepalive.wrongAccount")}
|
|
13
|
+
`),1;if(g()!=="NonExistent"){A.stop(),x("Stopped");let o=f(t.exePath,["uninstall"],{encoding:"utf8",windowsHide:!0});if(o.error||o.status!==0)throw w("WinSW uninstall",o)}let r=f(t.exePath,["install"],{stdio:"inherit",windowsHide:!0});if(r.error||r.status!==0)throw w("WinSW install",r);let{domain:e,user:i}=m(),c=`${e}\\${i}`;return await C(t.id,c,n)?(process.stdout.write(`${n("keepalive.serviceInstalled",{id:t.id})}
|
|
14
|
+
`),0):1}catch(t){return process.stdout.write(`${t.message}
|
|
15
|
+
`),1}finally{process.stdout.write(`${n("keepalive.pressEnter")}
|
|
16
|
+
`),process.stdin.resume(),await new Promise(t=>{let r=e=>{/[\r\n]/.test(String(e))&&(process.stdin.removeListener("data",r),process.stdin.pause(),t())};process.stdin.on("data",r)})}}export{E as completeServiceInstall,C as configureAndStartServiceAccount,I as renderSetServiceAccountScript};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{g as c,h as s}from"./AWB4A65P.js";import{a as i}from"./M4AFZHKH.js";import"./UEOQE77N.js";import"./QRGNEKME.js";import"./PBMBFWLQ.js";import"./TNLCNVA2.js";import"./I6NRCYLI.js";import{spawn as a}from"node:child_process";function d(r){return new Promise((e,n)=>{r.once("error",n),r.once("close",o=>e(o??1))})}function l({action:r,nodePath:e,entryPoint:n}){let o=c,t=`"${n}" admin-broker ${r} --elevated`;return`$ErrorActionPreference = 'Stop'
|
|
4
|
+
try {
|
|
5
|
+
$process = Start-Process -FilePath '${o(e)}' -ArgumentList '${o(t)}' -Verb RunAs -Wait -PassThru -WindowStyle Hidden
|
|
6
|
+
} catch {
|
|
7
|
+
if (($_.Exception.HResult -band 65535) -eq 1223) { exit 1223 }
|
|
8
|
+
exit 1
|
|
9
|
+
}
|
|
10
|
+
exit $process.ExitCode`}function m(r,e){return Object.assign(new Error(r),{code:e})}async function f(r,e){if(process.platform!=="win32")throw new Error(e("adminBroker.windowsOnly"));let n=l({action:r,nodePath:process.execPath,entryPoint:i()}),o=a("powershell.exe",["-NoProfile","-NonInteractive","-EncodedCommand",s(n)],{windowsHide:!0,stdio:"ignore"}),t=await d(o);if(t===1223)throw m(e("adminBroker.elevationCancelled"),"ELEVATION_CANCELLED");if(t!==0)throw new Error(e("adminBroker.setupFailed"))}export{f as configureAdminBroker,l as renderAdminBrokerElevationScript};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a as m,c as S}from"./M4AFZHKH.js";import{a as x}from"./QRGNEKME.js";import{a as R,b as D,c,f as g}from"./TNLCNVA2.js";import{spawnSync as T}from"node:child_process";import $ from"node:fs";import M from"node:os";import W from"node:path";var k="dev.herdr.remote";function C(){return W.join(M.homedir(),"Library","LaunchAgents",`${k}.plist`)}function n(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function V({nodePath:t=process.execPath,entryPoint:e=m(),label:r=k,outLog:o=g("supervisor"),errLog:i=g("supervisor"),environment:p={}}={}){let u=Object.entries(p).map(([y,v])=>` <key>${n(y)}</key>
|
|
4
|
+
<string>${n(v)}</string>`).join(`
|
|
5
|
+
`),s=u?` <key>EnvironmentVariables</key>
|
|
6
|
+
<dict>
|
|
7
|
+
${u}
|
|
8
|
+
</dict>
|
|
9
|
+
`:"";return`<?xml version="1.0" encoding="UTF-8"?>
|
|
10
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
11
|
+
<plist version="1.0">
|
|
12
|
+
<dict>
|
|
13
|
+
<key>Label</key>
|
|
14
|
+
<string>${n(r)}</string>
|
|
15
|
+
<key>ProgramArguments</key>
|
|
16
|
+
<array>
|
|
17
|
+
<string>${n(t)}</string>
|
|
18
|
+
<string>${n(e)}</string>
|
|
19
|
+
<string>run</string>
|
|
20
|
+
</array>
|
|
21
|
+
<key>RunAtLoad</key>
|
|
22
|
+
<true/>
|
|
23
|
+
<key>KeepAlive</key>
|
|
24
|
+
<true/>
|
|
25
|
+
<key>ProcessType</key>
|
|
26
|
+
<string>Background</string>
|
|
27
|
+
${s} <key>StandardOutPath</key>
|
|
28
|
+
<string>${n(o)}</string>
|
|
29
|
+
<key>StandardErrorPath</key>
|
|
30
|
+
<string>${n(i)}</string>
|
|
31
|
+
</dict>
|
|
32
|
+
</plist>
|
|
33
|
+
`}function O(){return`gui/${process.getuid?process.getuid():""}`}function d(){return`${O()}/${k}`}function L(t){return T("launchctl",t,{encoding:"utf8",windowsHide:!0})}function f(t){T("launchctl",t,{stdio:"ignore",windowsHide:!0})}var yt={name:"launchd",status(){let t=C();if(!$.existsSync(t))return{manager:"launchd",installed:!1,active:!1,enabled:!1};let e=L(["print",d()]),r=String(e.stdout||"");return{manager:"launchd",installed:!0,active:e.status===0&&/state = running/.test(r),enabled:e.status===0,unitPath:t,state:e.status===0?"loaded":"not loaded"}},async install(){let t=C();x(W.dirname(t)),x(c()),$.writeFileSync(t,V({environment:S()}),{mode:420}),f(["bootout",d()]);let e=L(["bootstrap",O(),t]);if(e.status!==0)throw new Error(`launchctl bootstrap failed: ${String(e.stderr||"").trim()}`);return f(["enable",d()]),{ok:!0,unitPath:t}},async uninstall(){let t=C();return f(["bootout",d()]),$.rmSync(t,{force:!0}),{ok:!0,unitPath:t}},restart(){return f(["kickstart","-k",d()]),{ok:!0}},stop(){f(["bootout",d()])},logsHint(){return`tail -f ${g("supervisor")}`}};import{spawn as G,spawnSync as E}from"node:child_process";import{createHash as Y}from"node:crypto";import a from"node:fs";import K from"node:os";import h from"node:path";var Q=2e4,X=250;function q(t){return`herdr-remote-${t.replace(/[^A-Za-z0-9._-]/g,"_")}`}function N(){return{domain:process.env.USERDOMAIN||"",user:process.env.USERNAME||K.userInfo().username}}function w(){let t=q(N().user),e=h.join(c(),"service");return{id:t,directory:e,exePath:h.join(e,`${t}.exe`),unitPath:h.join(e,`${t}.xml`)}}function H(t){return t.trim().split(/\r?\n/).pop()?.trim()}function z(t){let e=H(t)?.match(/"([^"]+)"\s*$/)?.[1];return e&&/^S-\d(?:-\d+)+$/.test(e)?e:null}function Z(t){let e=H(t);return e==="Started"||e==="Stopped"||e==="NonExistent"?e:"NonExistent"}function J(t){return"D:"+["(A;;CCLCSWRPWPDTLOCRRC;;;SY)","(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)","(A;;CCLCSWLOCRRC;;;IU)","(A;;CCLCSWLOCRRC;;;SU)",`(A;;CCLCSWRPWPDTLOCRRC;;;${t})`].join("")}function tt(t){let{id:e,user:r,domain:o,userSid:i,nodePath:p,entryPoint:u,workingDirectory:s,environment:y}=t,v=Object.entries(y).map(([U,B])=>` <env name="${n(U)}" value="${n(B)}"/>`);return`<service>
|
|
34
|
+
<id>${n(e)}</id>
|
|
35
|
+
<name>${n(`Herdr Remote (${r})`)}</name>
|
|
36
|
+
<description>${n(`Browser access to Herdr workspaces, running as ${o}\\${r}.`)}</description>
|
|
37
|
+
<executable>${n(p)}</executable>
|
|
38
|
+
<arguments>${n(`"${u}" run --daemon`)}</arguments>
|
|
39
|
+
<workingdirectory>${n(s)}</workingdirectory>
|
|
40
|
+
<startmode>Automatic</startmode>
|
|
41
|
+
<delayedAutoStart/>
|
|
42
|
+
<onfailure action="restart" delay="3 sec"/>
|
|
43
|
+
<resetfailure>1 hour</resetfailure>
|
|
44
|
+
<stoptimeout>15 sec</stoptimeout>
|
|
45
|
+
<logpath>${n(s)}</logpath>
|
|
46
|
+
<logname>supervisor</logname>
|
|
47
|
+
<log mode="append"/>
|
|
48
|
+
${v.join(`
|
|
49
|
+
`)}
|
|
50
|
+
<serviceaccount>
|
|
51
|
+
<domain>${n(o)}</domain>
|
|
52
|
+
<user>${n(r)}</user>
|
|
53
|
+
<allowservicelogon>true</allowservicelogon>
|
|
54
|
+
</serviceaccount>
|
|
55
|
+
<securityDescriptor>${n(J(i))}</securityDescriptor>
|
|
56
|
+
</service>
|
|
57
|
+
`}function _(t){return t.replace(/'/g,"''")}function et({nodePath:t,entryPoint:e}){let r=_(t),o=_(e);return`$ErrorActionPreference = 'Stop'
|
|
58
|
+
try {
|
|
59
|
+
$process = Start-Process -FilePath '${r}' -ArgumentList '"${o}" keepalive install --elevated' -Verb RunAs -Wait -PassThru
|
|
60
|
+
} catch {
|
|
61
|
+
exit 1223
|
|
62
|
+
}
|
|
63
|
+
exit $process.ExitCode`}function rt(t){return Buffer.from(t,"utf16le").toString("base64")}function l(t){return t?String(t).trim():""}function I(t){let e=E("sc.exe",[t,w().id],{encoding:"utf8",windowsHide:!0});return{code:e.status,stdout:l(e.stdout),stderr:l(e.stderr)}}function j(t,e){let r=e.stdout||e.stderr;return new Error(`sc.exe ${t} failed (${e.code}): ${r}`)}function nt(t){return t.code===0||t.code===1056?"ok":t.code===1069?"logon-failed":j("start",t)}function ot(){return I("start")}function it(){return I("stop")}function P(){let{exePath:t}=w();if(!a.existsSync(t))return"NonExistent";let e=E(t,["status"],{encoding:"utf8",windowsHide:!0});return e.error||e.status!==0?"NonExistent":Z(l(e.stdout))}function F(t,e=Q){let r=Date.now()+e;for(;P()!==t;){if(Date.now()>=r)throw new Error(`Windows service did not reach ${t} within ${e} ms`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,X)}}function A(){let t=it();if(t.code!==0&&t.code!==1062&&t.code!==1060)throw j("stop",t)}function st(){let t=ot(),e=nt(t);if(e==="logon-failed"){let r=t.stdout||t.stderr;throw new Error(`Windows service logon failed (1069): ${r}`)}if(e instanceof Error)throw e;return{ok:!0}}function b(t){return Y("sha256").update(a.readFileSync(t)).digest("hex")}async function ct(){let t=w();await a.promises.mkdir(t.directory,{recursive:!0});let e=h.join(R,"vendor","winsw","WinSW.NET461.exe");if(!a.existsSync(t.exePath)||b(t.exePath)!==b(e))try{await a.promises.copyFile(e,t.exePath)}catch(s){throw["EBUSY","EPERM","EACCES"].includes(s.code||"")?new Error(`Could not replace ${t.exePath}; stop the Windows service first.`,{cause:s}):s}let r={...S(),HERDR_REMOTE_CONFIG_DIR:D(),HERDR_REMOTE_STATE_DIR:c(),HERDR_REMOTE_SERVICE:"1"},o=E("whoami",["/user","/fo","csv","/nh"],{encoding:"utf8",windowsHide:!0}),i=!o.error&&o.status===0?z(l(o.stdout)):null;if(!i)throw new Error(`Could not read the current Windows user SID: ${l(o.stderr)}`);let{user:p,domain:u}=N();return await a.promises.writeFile(t.unitPath,tt({id:t.id,user:p,domain:u,userSid:i,nodePath:process.execPath,entryPoint:m(),workingDirectory:c(),environment:r}),"utf8"),t}function at(t){return new Promise((e,r)=>{t.once("error",r),t.once("close",o=>e(o??1))})}async function ut(){let t=await ct(),e=et({nodePath:process.execPath,entryPoint:m()}),r=G("powershell.exe",["-NoProfile","-NonInteractive","-EncodedCommand",rt(e)],{windowsHide:!0,stdio:"ignore"}),o=await at(r);if(o===1223){let i=new Error("Administrator rights were not granted; nothing was installed.");throw i.code="ELEVATION_CANCELLED",i}if(o!==0)throw new Error(`Windows service installation did not complete (exit code ${o}).`);return{ok:!0,unitPath:t.unitPath,state:P()}}function dt(){let t=w(),e=P(),r=e!=="NonExistent";return{manager:"windows-service",installed:r,active:e==="Started",enabled:r,unitPath:t.unitPath,state:e}}async function lt(){let t=w();A(),F("Stopped");let e=E(t.exePath,["uninstall"],{windowsHide:!0});if(e.error||e.status!==0)throw new Error(`WinSW uninstall failed with exit code ${String(e.status)}: ${l(e.stdout)}`);if(P()!=="NonExistent")throw new Error(`Windows service still exists: ${t.id}`);return a.rmSync(t.directory,{recursive:!0,force:!0}),{ok:!0,unitPath:t.unitPath}}function pt(){return A(),F("Stopped"),st()}function mt(){return`Get-Content -Wait -Tail 40 "${h.join(c(),"supervisor.out.log")}"`}var Tt={name:"windows-service",status:dt,install:ut,uninstall:lt,restart:pt,stop:A,logsHint:mt};export{n as a,V as b,yt as c,q as d,N as e,w as f,_ as g,rt as h,nt as i,ot as j,P as k,F as l,Tt as m};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{d as h}from"./U6QAYG3E.js";import{g as m}from"./M52LJEES.js";import b from"node:http";import g from"node:https";function p(e,t={}){return new Promise((n,o)=>{let s;try{s=new URL(e)}catch(i){o(i);return}let r=(s.protocol==="https:"?g:b).request(s,{method:t.method||"GET",headers:t.headers||{},timeout:t.timeout||1500},i=>{let d=[];i.on("data",a=>d.push(a)),i.on("end",()=>{let a=Buffer.concat(d).toString("utf8"),u;try{u=JSON.parse(a)}catch{u={raw:a}}let l=i.statusCode||0;if(l>=400){let f=new Error(typeof u.message=="string"?u.message:`HTTP ${l}`);f.statusCode=l,f.body=u,o(f)}else n(u)})});r.on("timeout",()=>r.destroy(new Error("request timed out"))),r.on("error",o),t.body&&r.write(t.body),r.end()})}function k(e){return`${m(e)}/healthz`}function E(){let e=h();return{"X-Herdr-Host-Id":e.hostId,"X-Herdr-Host-Token":e.hostToken}}async function C(e,{attempts:t=20,delayMs:n=100}={}){let o;for(let s=0;s<t;s+=1){try{return await p(k(e),{timeout:800})}catch(c){o=c}await new Promise(c=>setTimeout(c,n))}throw o||new Error("relay did not become ready")}async function S(e,{attempts:t=30,delayMs:n=100}={}){let o=E(),s=o["X-Herdr-Host-Id"],c=`${m(e)}/api/status`,r=null;for(let d=0;d<t;d+=1){try{if(r=await p(c,{timeout:800,headers:o}),r.hosts?.some(a=>a.id===s))return r}catch(a){r={ok:!1,message:a.message}}await new Promise(a=>setTimeout(a,n))}let i=new Error(r?.message||"the Herdr host connector did not register with the relay");throw i.health=r,i}function _(e){let t=e,n=t?.code||t?.pairCode;if(typeof n!="string"||n.length===0)throw new Error("the relay response did not contain a valid pairing code");return n}import y from"node:os";var I=/^(docker|br-|virbr|veth|vmnet|vboxnet|lxcbr|cni|flannel|kube|vmware network adapter|virtualbox host-only)/i,T=/^(tailscale|ts)\d*$/i;function v(e){let t=String(e).split(".");if(t.length!==4)return!1;let n=Number(t[0]),o=Number(t[1]);return!Number.isInteger(n)||!Number.isInteger(o)?!1:n===100&&o>=64&&o<=127}function x(e){let t=String(e).split(".");return t.length!==4?!1:Number(t[0])===169&&Number(t[1])===254}function A(e,t){return t.internal?"loopback":T.test(e)||v(t.address)?"tailscale":x(t.address)||I.test(e)?"virtual":"lan"}var w={tailscale:0,lan:1,virtual:2,loopback:3};function N({includeLoopback:e=!0,includeIpv6:t=!1,interfaces:n=y.networkInterfaces()}={}){let o=[];for(let[s,c]of Object.entries(n))for(let r of c||[]){let i=r.family,d=typeof i=="string"?i:`IPv${i}`;if(d!=="IPv4"&&!(t&&d==="IPv6"))continue;let a=A(s,r);a==="loopback"&&!e||o.push({name:s,address:r.address,family:d,kind:a,internal:!!r.internal})}return o.sort((s,c)=>{let r=w[s.kind]-w[c.kind];return r!==0?r:s.address.localeCompare(c.address)}),o}function O(e=y.networkInterfaces()){let t=N({includeLoopback:!1,interfaces:e});return t.length>0?t[0].address:null}export{p as a,k as b,E as c,C as d,S as e,_ as f,N as g,O as h};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a as J,b as it}from"./U6QAYG3E.js";import{e as G,g as q}from"./PBMBFWLQ.js";import U from"node:fs";import{spawnSync as Bt}from"node:child_process";import st from"node:fs";import jt from"node:os";import O from"node:path";var Dt=96/72,Wt=3e3,$=new Set(["monospace","mono","sans","sans-serif","serif","system-ui","ui-monospace"]);function Y(t,e){try{let n=Bt(t,e,{encoding:"utf8",timeout:Wt,windowsHide:!0});return{status:n.status,stdout:n.stdout||""}}catch{return{status:null,stdout:""}}}function vt(t){try{return st.readFileSync(t,"utf8")}catch{return null}}function Ut(t){try{return st.readFileSync(t)}catch{return null}}function R(t={}){let e=t.env||process.env;return{env:e,platform:t.platform||process.platform,home:t.home||e.HOME||jt.homedir(),run:t.run||Y,readFile:t.readFile||vt,readBuffer:t.readBuffer||Ut,terminalArgs:t.terminalArgs||[]}}function F(t){return t.env.XDG_CONFIG_HOME||O.join(t.home,".config")}function lt(t){return t.env.XDG_DATA_HOME||O.join(t.home,".local","share")}function L(t){return t.env.LOCALAPPDATA||O.join(t.home,"AppData","Local")}function X(t){return t.env.APPDATA||O.join(t.home,"AppData","Roaming")}function k(t,e){return t.startsWith("~/")?O.join(e.home,t.slice(2)):t}function S(t){let e=Number(t);return Number.isFinite(e)&&e>0?Math.round(e*Dt*10)/10:void 0}function N(t){let e=Number(t);return Number.isFinite(e)&&e>0?e:void 0}import ct from"node:crypto";import w from"node:fs";import C from"node:path";var V={regular:":weight=regular:slant=roman",bold:":weight=bold:slant=roman",italic:":weight=regular:slant=italic",boldItalic:":weight=bold:slant=italic"};function B(t){return t.replace(/([\\\-:,])/g,"\\$1")}function K(t){if(!t||t.length<4)return null;let e=t.subarray(0,4).toString("latin1");return e==="\0\0\0"||e==="true"?"truetype":e==="OTTO"?"opentype":null}function ut(t,e){let n;try{n=w.openSync(t,"r");let r=Buffer.alloc(e),o=w.readSync(n,r,0,e,0);return r.subarray(0,o)}catch{return null}finally{if(n!==void 0)try{w.closeSync(n)}catch{}}}function ft(t){let e;try{e=w.openSync(t,"r");let n=Buffer.alloc(12);if(w.readSync(e,n,0,12,0),!K(n))return null;let r=n.readUInt16BE(4),o=Buffer.alloc(r*16);w.readSync(e,o,0,o.length,12);let i=-1,s=0;for(let c=0;c<r;c+=1)o.toString("latin1",c*16,c*16+4)==="name"&&(i=o.readUInt32BE(c*16+8),s=o.readUInt32BE(c*16+12));if(i<0||s>1024*1024)return null;let l=Buffer.alloc(s);w.readSync(e,l,0,s,i);let a=l.readUInt16BE(2),m=l.readUInt16BE(4),f={};for(let c=0;c<a;c+=1){let u=6+c*12,y=l.readUInt16BE(u),p=l.readUInt16BE(u+4),x=l.readUInt16BE(u+6),g=l.readUInt16BE(u+8),h=m+l.readUInt16BE(u+10);if(![1,2,6,16,17].includes(x)||h+g>l.length)continue;let b;if((y===3||y===0)&&g%2===0){if(y===3&&p!==1033&&f[x])continue;b=Buffer.from(l.subarray(h,h+g)).swap16().toString("utf16le")}else y===1&&!f[x]&&(b=l.toString("latin1",h,h+g));b&&(f[x]=b)}return{family:f[16]||f[1]||null,subfamily:f[17]||f[2]||"",postscript:f[6]||null}}catch{return null}finally{if(e!==void 0)try{w.closeSync(e)}catch{}}}function mt(t){let e=t.platform==="darwin"?[C.join(t.home,"Library","Fonts"),"/Library/Fonts","/System/Library/Fonts"]:t.platform==="win32"?[C.join(t.env.WINDIR||t.env.SystemRoot||"C:\\Windows","Fonts"),C.join(L(t),"Microsoft","Windows","Fonts")]:[],n=[],r=(o,i)=>{let s;try{s=w.readdirSync(o,{withFileTypes:!0})}catch{return}for(let l of s){let a=C.join(o,l.name);l.isDirectory()&&i<2?r(a,i+1):/\.(ttf|otf)$/i.test(l.name)&&n.push(a)}};for(let o of e)r(o,0);return n}var Gt=[[/^\.?SF(NS)?Mono/,"SF Mono"],[/^Menlo-/,"Menlo"],[/^Monaco$/,"Monaco"],[/^Courier(New)?/,"Courier New"],[/^AndaleMono$/,"Andale Mono"]];function Q(t,e){let n=Gt.find(([o])=>o.test(t));if(n&&e.platform==="darwin")return n[1];let r=e.run("fc-list",[`:postscriptname=${B(t)}`,"family"]);if(r.status===0&&r.stdout.trim())return r.stdout.trim().split(`
|
|
4
|
+
`)[0].split(",")[0].trim();if(e.platform!=="darwin")return null;for(let o of mt(e)){let i=ft(o);if(i?.postscript===t)return i.family}return null}function qt(t){let e=String(t||"").toLowerCase(),n=/\bbold\b/.test(e)&&!/(semi|demi|extra|ultra)\s*bold/.test(e),r=/italic|oblique/.test(e);return n&&r?"boldItalic":n?"bold":r?"italic":/^(regular|normal|book|roman)$/.test(e.trim())?"regular":null}function Jt(t,e){let n={},r=!1;for(let o of G){let i=e.run("fc-match",["-f",`%{file}
|
|
5
|
+
%{family}
|
|
6
|
+
%{index}
|
|
7
|
+
`,`${B(t)}${V[o]}`]);if(i.status!==0)continue;r=!0;let[s,l="",a="0"]=i.stdout.split(`
|
|
8
|
+
`),m=l.split(",").map(f=>f.trim().toLowerCase());!s||!m.includes(t.toLowerCase())||Number(a)!==0||(n[o]=s)}if(r||e.platform!=="darwin"&&e.platform!=="win32")return n;for(let o of mt(e)){let i=ft(o);if(!i||i.family?.toLowerCase()!==t.toLowerCase())continue;let s=qt(i.subfamily);s&&!n[s]&&(n[s]=o)}return n}function Yt(t){return ct.createHash("sha256").update(w.readFileSync(t)).digest("hex")}function pt(t,e={}){let n=R(e);if(!t||$.has(t.toLowerCase()))return[];let r=Jt(t,n),o=[],i=new Set;for(let s of G){let l=r[s];if(!l||i.has(l)||/^\/System\//.test(l)||/\.app\/Contents\//.test(l)||s!=="regular"&&!o.length)continue;let a;try{a=w.statSync(l)}catch{continue}if(!a.isFile()||a.size<=0||a.size>16777216)continue;let m=K(ut(l,4));m&&(i.add(l),o.push({style:s,format:m,bytes:a.size,sha256:Yt(l),path:l,mtimeMs:a.mtimeMs}))}return o}var Xt=64*1024*1024;function at(t,e){let n=e.run("fc-match",["-f",`%{file}
|
|
9
|
+
%{family}
|
|
10
|
+
%{index}
|
|
11
|
+
`,t]);if(n.status!==0)return null;let[r,o="",i="0"]=n.stdout.split(`
|
|
12
|
+
`);return r?{file:r,families:o.split(",").map(s=>s.trim()).filter(Boolean),index:Number(i)||0}:null}function dt(t,e,n={}){let r=R(n);if(!t||$.has(t.toLowerCase()))return[];let o=t.toLowerCase(),i=[],s=(c,u,y)=>{if(!c||/^\/System\//.test(c.file)||/\.app\/Contents\//.test(c.file))return;let p;try{p=w.statSync(c.file)}catch{return}if(!p.isFile()||p.size>Xt)return;let x=ut(c.file,4);if(!K(x)&&x?.toString("latin1")!=="ttcf")return;let g=ct.createHash("sha256").update(`${c.file}\0${c.index}\0${p.size}\0${p.mtimeMs}`).digest("hex");i.push({family:y,style:"regular",scope:u,sha256:g,path:c.file,index:c.index,bytes:p.size,mtimeMs:p.mtimeMs})},l=at(`${B(t)}${V.regular}`,r);l?.families.some(c=>c.toLowerCase()===o)&&!e.some(c=>c.style==="regular")&&s(l,"all",t);let m=at(`${B(t)}:charset=4e00${V.regular}`,r),f=m?.families.some(c=>c.toLowerCase()===o);return m&&!f&&m.families[0]&&s(m,"cjk",m.families[0]),i}function yt(t,e){if(!$.has(String(t).toLowerCase()))return t;let n=e.run("fc-match",["-f","%{family[0]}",t]);return(n.status===0?n.stdout.trim():"")||null}import d from"node:path";var P=class{value;constructor(e){this.value=e}};function T(t,e,n){let r=0;for(let o=0;o<n;o+=1)r=r*256+t[e+o];return r}function Z(t){if(!Buffer.isBuffer(t)||t.length<40||t.toString("latin1",0,8)!=="bplist00")throw new Error("not a binary plist");let e=t.length-32,n=t[e+6],r=t[e+7],o=T(t,e+8,8),i=T(t,e+16,8),s=T(t,e+24,8);if(!n||!r||o>1e6||s+o*n>e)throw new Error("corrupt binary plist trailer");let l=[];for(let u=0;u<o;u+=1)l.push(T(t,s+u*n,n));let a=new Set,m=u=>{if(u>=o||a.has(u))throw new Error("corrupt binary plist reference");a.add(u);try{return c(l[u])}finally{a.delete(u)}},f=u=>{let y=t[u]&15;if(y!==15)return{length:y,start:u+1};let p=t[u+1];if((p&240)!==16)throw new Error("corrupt binary plist length");let x=1<<(p&15);return{length:T(t,u+2,x),start:u+2+x}},c=u=>{let y=t[u],p=y>>4,x=y&15;switch(p){case 0:return y===8?!1:y===9?!0:null;case 1:{let g=1<<x;return g===8?Number(t.readBigInt64BE(u+1)):T(t,u+1,g)}case 2:return x===2?t.readFloatBE(u+1):t.readDoubleBE(u+1);case 3:return new Date(Date.UTC(2001,0,1)+t.readDoubleBE(u+1)*1e3);case 4:{let{length:g,start:h}=f(u);return t.subarray(h,h+g)}case 5:{let{length:g,start:h}=f(u);return t.toString("latin1",h,h+g)}case 6:{let{length:g,start:h}=f(u);return Buffer.from(t.subarray(h,h+g*2)).swap16().toString("utf16le")}case 8:return new P(T(t,u+1,x+1));case 10:case 12:{let{length:g,start:h}=f(u),b=[];for(let E=0;E<g;E+=1)b.push(m(T(t,h+E*r,r)));return b}case 13:{let{length:g,start:h}=f(u),b={};for(let E=0;E<g;E+=1){let Ct=m(T(t,h+E*r,r));b[String(Ct)]=m(T(t,h+(g+E)*r,r))}return b}default:throw new Error(`unsupported binary plist object 0x${y.toString(16)}`)}};return m(i)}function gt(t,e=6){let n=s=>s&&typeof s=="object"&&!Array.isArray(s)?s:void 0,r=n(t)?.$objects,o=n(n(t)?.$top)?.root;if(!Array.isArray(r)||!(o instanceof P))throw new Error("not a keyed archive");let i=(s,l)=>{if(s instanceof P)return l>e?null:i(r[s.value],l+1);if(Array.isArray(s))return s.map(a=>i(a,l));if(s&&typeof s=="object"&&!Buffer.isBuffer(s)&&!(s instanceof Date)){let a={};for(let[m,f]of Object.entries(s))a[m]=i(f,l);return a}return s==="$null"?null:s};return i(o,0)}function _(t){let e={"":{}},n=e[""];for(let r of String(t||"").split(/\r?\n/)){let o=r.trim();if(!o||o.startsWith("#")||o.startsWith(";"))continue;let i=/^\[(.+)\]$/.exec(o);if(i){n=e[i[1].trim()]||={};continue}let s=o.indexOf("=");s!==-1&&(n[o.slice(0,s).trim()]=o.slice(s+1).trim())}return e}function z(t){let e=String(t||"").trim(),n=/^'((?:[^'\\]|\\.)*)'$/.exec(e)||/^"((?:[^"\\]|\\.)*)"$/.exec(e);return n?n[1].replace(/\\(.)/g,"$1"):null}var Vt=new Set(["normal","roman","oblique","italic","small-caps","all-small-caps","petite-caps","all-petite-caps","unicase","title-caps","ultra-condensed","extra-condensed","condensed","semi-condensed","semi-expanded","expanded","extra-expanded","ultra-expanded","thin","ultra-light","extra-light","light","semi-light","demi-light","book","regular","medium","semi-bold","demi-bold","bold","ultra-bold","extra-bold","heavy","black","ultra-black","extra-black","ultra-heavy","extra-heavy","not-rotated","south","upside-down","north","rotated-left","east","rotated-right","west"]);function A(t){if(typeof t!="string")return null;let e=t.trim().split(/\s+/).filter(Boolean);for(;e.length&&e[e.length-1].startsWith("@");)e.pop();let n,r=/^(\d+(?:\.\d+)?)(px)?$/i.exec(e[e.length-1]||"");for(r&&e.length>1&&(e.pop(),n=r[2]?N(r[1]):S(r[1]));e.length>1;){let i=e[e.length-1].toLowerCase();if(!Vt.has(i)&&!/^weight=\d+$/.test(i))break;e.pop()}let o=e.join(" ").split(",")[0].trim();return o?{family:o,sizePx:n}:null}function tt(t){if(typeof t!="string")return null;let e=t.split(","),n=(e[0]||"").trim();if(!n)return null;let r=Number(e[1]),o=Number(e[2]),i=r>0?S(r):o>0?o:void 0;return{family:n,sizePx:i}}function j(t){if(typeof t!="string")return null;let e=t.split(/(?<!\\),/)[0],[n,...r]=e.split(/(?<!\\):/),o=n.replace(/\\(.)/g,"$1").trim();if(!o)return null;let i;for(let s of r){let[l,a]=s.split("=");l==="size"?i=S(a):l==="pixelsize"&&(i=N(a))}return{family:o,sizePx:i}}function M(t){return typeof t!="string"?null:t.split(",")[0].trim().replace(/^(['"])(.*)\1$/,"$2").trim()||null}function et(t){if(typeof t!="string")return null;let e="",n=!1;for(let r=0;r<t.length;r+=1){let o=t[r];if(n){e+=o,o==="\\"?(e+=t[r+1]||"",r+=1):o==='"'&&(n=!1);continue}if(o==='"'){n=!0,e+=o;continue}if(o==="/"&&t[r+1]==="/"){for(;r<t.length&&t[r]!==`
|
|
13
|
+
`;)r+=1;e+=`
|
|
14
|
+
`;continue}if(o==="/"&&t[r+1]==="*"){for(r+=2;r<t.length&&!(t[r]==="*"&&t[r+1]==="/");)r+=1;r+=1;continue}e+=o}try{return JSON.parse(e.replace(/,(\s*[}\]])/g,"$1"))}catch{return null}}function ht(t){let e="";for(let n=0;n<t.length;n+=1){let r=t[n];if(e)r==="\\"&&e==='"'?n+=1:r===e&&(e="");else if(r==='"'||r==="'")e=r;else if(r==="#")return t.slice(0,n)}return t}function xt(t){let e={},n=String(t||"").split(/\r?\n/),r="",o=l=>{let a=l.trim(),m=/^"((?:[^"\\]|\\.)*)"/.exec(a);if(m)return m[1].replace(/\\(.)/g,"$1");let f=/^'([^']*)'/.exec(a);if(f)return f[1];let c=Number(a.replace(/#.*$/,"").trim());return Number.isFinite(c)?c:void 0},i=l=>l.split(".").map(a=>a.trim().replace(/^(['"])(.*)\1$/,"$2")),s=(l,a,m)=>{let f=[...l?[l]:[],...i(a)].join("."),c=m.trim();if(c.startsWith("{")){let y=c.slice(1,c.lastIndexOf("}"));for(let p of y.split(/,(?=(?:[^"']|"[^"]*"|'[^']*')*$)/)){let x=p.indexOf("=");x!==-1&&s(f,p.slice(0,x),p.slice(x+1))}return}if(c.startsWith("[")){e[f]=[...c.matchAll(/"((?:[^"\\]|\\.)*)"|'([^']*)'/g)].map(y=>y[1]??y[2]);return}let u=o(c);u!==void 0&&(e[f]=u)};for(let l=0;l<n.length;l+=1){let a=n[l].trim();if(!a||a.startsWith("#"))continue;let m=/^\[([^[\]]+)\]/.exec(a);if(m){r=i(m[1]).join(".");continue}if(a.startsWith("[[")){r="\0";continue}if(r==="\0")continue;let f=a.indexOf("=");if(f===-1)continue;let c=a.slice(f+1);if(c.trim().startsWith("["))for(c=ht(c);l+1<n.length&&!c.includes("]");)l+=1,c+=` ${ht(n[l]).trim()}`;s(r,a.slice(0,f),c)}return e}function D(t,e){let n=null;for(let r=0;r<t.length-1;r+=1)e.includes(t[r])&&(n=t[r+1]);return n}function nt(t){let e=[];for(let n=0;n<t.length-1;n+=1){if(t[n]!=="-xrm")continue;let r=t[n+1].indexOf(":");r!==-1&&e.push([t[n+1].slice(0,r).trim(),t[n+1].slice(r+1).trim()])}return e}function W(t,e,n){let r=null,o=null;for(let[i,s]of t){let l=i.split(/[.*]/).filter(Boolean);l[l.length-1]!==n||!s||(l.length===1?o=s:e.includes(l[0])&&(r=s))}return r??o}function rt(t,{bareIsPattern:e=!1}={}){let n=String(t||"").split(/,(?=\s*(?:xft:|-))/)[0].trim();if(/^xft:/i.test(n))return j(n.slice(4));if(n.startsWith("-")){let r=n.split("-"),o=(r[2]||"").trim();if(!o||o==="*"||/^(fixed|misc)$/i.test(o))return null;let i=Number(r[7]),s=Number(r[8]);return{family:o,sizePx:i>0?i:s>0?S(s/10):void 0}}return n&&(e||n.includes(":"))?j(n):null}function I(t,e,n){let r=t.run("gsettings",["get",e,n]);return r.status!==0?null:r.stdout.trim()}function St(t,{schema:e,path:n,fontKey:r="font"}){let o=I(t,`${e}:${n}`,"use-system-font");if(o===null)return null;if(o==="false"){let i=A(z(I(t,`${e}:${n}`,r)));if(i)return i}return Tt(t)}function Tt(t){return A(z(I(t,"org.gnome.desktop.interface","monospace-font-name")))}function v(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:null}function wt(t){let e=v(t),n=v(e?.font);return{family:M(n?.face)||M(e?.fontFace),size:N(n?.size)||N(e?.fontSize)}}function Kt(t){let e=L(t),n=null;for(let p of[d.join(e,"Packages","Microsoft.WindowsTerminal_8wekyb3d8bbwe","LocalState","settings.json"),d.join(e,"Packages","Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe","LocalState","settings.json"),d.join(e,"Microsoft","Windows Terminal","settings.json")])if(n=et(t.readFile(p)),n)break;if(!n)return null;let r=n.profiles,o=v(r),i=Array.isArray(r)?r:Array.isArray(o?.list)?o.list:[],s=p=>String(v(p)?.guid||"").toLowerCase(),l=String(t.env.WT_PROFILE_ID||"").toLowerCase(),a=String(n.defaultProfile||"").toLowerCase(),m=(l?i.find(p=>s(p)===l):void 0)||(a?i.find(p=>s(p)===a):void 0),f=wt(m),c=wt(o?.defaults),u=f.family||c.family||"Cascadia Mono",y=f.size||c.size||12;return{family:u,sizePx:S(y)}}var Et={"windows-terminal":Kt,"gnome-terminal":t=>{let e=z(I(t,"org.gnome.Terminal.ProfilesList","default"));return e?St(t,{schema:"org.gnome.Terminal.Legacy.Profile",path:`/org/gnome/terminal/legacy/profiles:/:${e}/`}):null},tilix:t=>{let e=z(I(t,"com.gexperts.Tilix.ProfilesList","default"));return e?St(t,{schema:"com.gexperts.Tilix.Profile",path:`/com/gexperts/Tilix/profiles/${e}/`}):null},ptyxis:t=>{let e=I(t,"org.gnome.Ptyxis","use-system-font");if(e==="false"){let n=A(z(I(t,"org.gnome.Ptyxis","font-name")));if(n)return n}return e===null?null:Tt(t)},konsole:t=>{let n=_(t.readFile(d.join(F(t),"konsolerc")))["Desktop Entry"]?.DefaultProfile;if(n){let o=_(t.readFile(d.join(lt(t),"konsole",n))),i=tt(o.Appearance?.Font);if(i)return i}let r=_(t.readFile(d.join(F(t),"kdeglobals")));return tt(r.General?.fixed)||{family:"Hack",sizePx:S(10)}},"xfce4-terminal":t=>{let e=i=>{let s=t.run("xfconf-query",["-c","xfce4-terminal","-p",i]);return s.status===0?s.stdout.trim():null},n=_(t.readFile(d.join(F(t),"xfce4","terminal","terminalrc"))).Configuration||{};if(!((e("/font-use-system")??n.FontUseSystem??"false").toLowerCase()==="true")){let i=A(e("/font-name")??n.FontName??"Monospace 12");if(i)return i}let o=t.run("xfconf-query",["-c","xsettings","-p","/Gtk/MonospaceFontName"]);return A(o.status===0?o.stdout.trim():"Monospace 10")},kitty:t=>{let e=t.env.KITTY_CONFIG_DIRECTORY||d.join(F(t),"kitty"),n={},r=(l,a)=>{let m=t.readFile(l);if(!(m===null||a>4))for(let f of m.split(/\r?\n/)){let c=f.trim();if(!c||c.startsWith("#"))continue;let[u,...y]=c.split(/\s+/),p=y.join(" ");u==="include"?r(d.resolve(e,k(p,t)),a+1):(u==="font_family"||u==="font_size")&&(n[u]=p)}};r(d.join(e,"kitty.conf"),0);let o=n.font_family||"monospace",i=/family\s*=\s*(?:"([^"]+)"|'([^']+)'|(\S+))/.exec(o);return{family:i?i[1]||i[2]||i[3]:o,sizePx:S(n.font_size||11)}},alacritty:t=>{let e=[...t.platform==="win32"?[d.join(X(t),"alacritty","alacritty.toml")]:[],d.join(F(t),"alacritty","alacritty.toml"),d.join(F(t),"alacritty.toml"),d.join(t.home,".alacritty.toml")],n={},r=(i,s)=>{let l=t.readFile(i);if(l===null||s>4)return!1;let a=xt(l);for(let m of[...a.import||[],...a["general.import"]||[]])r(d.resolve(d.dirname(i),k(String(m),t)),s+1);return Object.assign(n,a),!0};e.some(i=>r(i,0));let o=t.platform==="darwin"?"Menlo":"monospace";return{family:String(n["font.normal.family"]||o),sizePx:S(n["font.size"]||11.25)}},ghostty:t=>{let e={families:[],size:void 0},n=(r,o)=>{let i=t.readFile(r);if(!(i===null||o>4))for(let s of i.split(/\r?\n/)){let l=s.trim();if(!l||l.startsWith("#"))continue;let a=l.indexOf("=");if(a===-1)continue;let m=l.slice(0,a).trim(),f=l.slice(a+1).trim().replace(/^"(.*)"$/,"$1");if(m==="font-family")f?e.families.push(f):e.families=[];else if(m==="font-size")e.size=f;else if(m==="config-file"){let c=k(f.replace(/^\?/,""),t);n(d.resolve(d.dirname(r),c),o+1)}}};return n(d.join(F(t),"ghostty","config"),0),t.platform==="darwin"&&n(d.join(t.home,"Library","Application Support","com.mitchellh.ghostty","config"),0),{family:e.families[0]||"JetBrains Mono",sizePx:S(e.size||(t.platform==="darwin"?13:12))}},wezterm:t=>{let e=t.run("wezterm",["ls-fonts"]),n=e.status===0?e.stdout:"",r=/family\s*=\s*"([^"]+)"/.exec(n)||/font_with_fallback\(\{[\s\S]*?"([^"]+)"/.exec(n),o=12;for(let i of[d.join(t.home,".wezterm.lua"),d.join(F(t),"wezterm","wezterm.lua")]){let s=/font_size\s*=\s*(\d+(?:\.\d+)?)/.exec(t.readFile(i)||"");if(s){o=Number(s[1]);break}}return{family:r?r[1]:"JetBrains Mono",sizePx:S(o)}},foot:t=>{let e=_(t.readFile(d.join(F(t),"foot","foot.ini"))),n=e.main?.font||e[""]?.font||"monospace:size=8";return j(n)},vscode:t=>{let e=t.platform==="darwin"?d.join(t.home,"Library","Application Support"):t.platform==="win32"?X(t):F(t);for(let r of["Code","Cursor","Code - Insiders","VSCodium","Windsurf"]){let o=et(t.readFile(d.join(e,r,"User","settings.json")));if(!o)continue;let i=M(o["terminal.integrated.fontFamily"])||M(o["editor.fontFamily"]),s=N(o["terminal.integrated.fontSize"])||N(o["editor.fontSize"])||14;if(i)return{family:i,sizePx:s}}return{family:t.platform==="darwin"?"Menlo":t.platform==="win32"?"Consolas":"Droid Sans Mono",sizePx:14}},iterm2:t=>{let e=Ft("com.googlecode.iterm2",t),n=e?.["New Bookmarks"],r=Array.isArray(n)?n:[],o=r.find(l=>l?.Guid===e?.["Default Bookmark Guid"])||r[0],i=/^(.+?)\s+(\d+(?:\.\d+)?)$/.exec(String(o?.["Normal Font"]||"").trim());if(!i)return null;let s=Q(i[1],t);return s?{family:s,sizePx:S(i[2])}:null},"apple-terminal":t=>{let e=Ft("com.apple.Terminal",t);if(!e)return null;let n=e["Default Window Settings"]||e["Startup Window Settings"]||"Basic",r=e["Window Settings"]?.[String(n)],o="SFMono-Regular",i=11,s=r?.Font;if(Buffer.isBuffer(s)){let a=gt(Z(s));typeof a?.NSName=="string"&&a.NSName&&(o=a.NSName),Number(a?.NSSize)>0&&(i=Number(a?.NSSize))}let l=Q(o,t);return l?{family:l,sizePx:S(i)}:null},xterm:t=>{let e=["XTerm","xterm","UXTerm","uxterm"],n=t.terminalArgs||[],r=[...bt(t),...nt(n)],o=D(n,["-fa","-faceName"])||W(r,e,"faceName");if(!o)return null;let i=rt(o,{bareIsPattern:!0});if(!i)return null;let s=Number(D(n,["-fs","-faceSize"])||W(r,e,"faceSize"));return s>0?{...i,sizePx:S(s)}:i},urxvt:t=>{let e=t.terminalArgs||[],n=[...bt(t),...nt(e)],r=D(e,["-fn"])||W(n,["URxvt","urxvt","Rxvt","rxvt"],"font");return r?rt(r):null}};function Ft(t,e){let n=e.readBuffer(d.join(e.home,"Library","Preferences",`${t}.plist`));if(!n)return null;try{return Z(n)}catch{return null}}function bt(t){let e=t.run("xrdb",["-query"]);return e.status!==0?[]:e.stdout.split(`
|
|
15
|
+
`).map(n=>{let r=n.indexOf(":");return r===-1?null:[n.slice(0,r).trim(),n.slice(r+1).trim()]}).filter(n=>n!==null)}import It from"node:fs";import _t from"node:path";var zt=[[/^gnome-terminal/,"gnome-terminal"],[/^ptyxis/,"ptyxis"],[/^tilix$/,"tilix"],[/^konsole$/,"konsole"],[/^xfce4-terminal$/,"xfce4-terminal"],[/^kitty$/,"kitty"],[/^alacritty$/i,"alacritty"],[/^ghostty$/i,"ghostty"],[/^wezterm-gui$/,"wezterm"],[/^foot(client)?$/,"foot"],[/^iTerm2$/,"iterm2"],[/^Terminal$/,"apple-terminal"],[/^xterm$/,"xterm"],[/^(urxvt|urxvtd|rxvt)$/,"urxvt"]],Nt={"com.apple.Terminal":"apple-terminal","com.googlecode.iterm2":"iterm2","com.microsoft.VSCode":"vscode","com.mitchellh.ghostty":"ghostty","com.github.wez.wezterm":"wezterm","net.kovidgoyal.kitty":"kitty"};function At({env:t=process.env,ancestry:e=[]}={}){for(let o of e){let i=_t.basename(String(o||""));for(let[s,l]of zt)if(s.test(i))return l}let n=t.TERM_PROGRAM||"",r=t.__CFBundleIdentifier||"";return n==="vscode"?"vscode":n==="iTerm.app"||t.ITERM_SESSION_ID||t.ITERM_PROFILE?"iterm2":n==="Apple_Terminal"?"apple-terminal":n==="WezTerm"||t.WEZTERM_EXECUTABLE?"wezterm":n==="ghostty"||t.GHOSTTY_RESOURCES_DIR?"ghostty":t.KITTY_WINDOW_ID||t.KITTY_PID||t.TERM==="xterm-kitty"?"kitty":t.ALACRITTY_SOCKET||t.ALACRITTY_WINDOW_ID||t.ALACRITTY_LOG?"alacritty":/^foot/.test(t.TERM||"")?"foot":t.KONSOLE_VERSION||t.KONSOLE_DBUS_SESSION?"konsole":t.PTYXIS_VERSION?"ptyxis":t.TILIX_ID?"tilix":t.GNOME_TERMINAL_SCREEN||t.GNOME_TERMINAL_SERVICE?"gnome-terminal":/^rxvt-unicode/.test(t.TERM||"")?"urxvt":Object.hasOwn(Nt,r)?Nt[r]:t.WT_SESSION||t.WT_PROFILE_ID?"windows-terminal":t.XTERM_VERSION?"xterm":null}function Ot({platform:t=process.platform,pid:e=process.ppid,run:n=Y}={}){let r=[];if(t==="linux"){let o=e;for(let i=0;i<32&&o>1;i+=1){let s;try{s=It.readFileSync(`/proc/${o}/stat`,"utf8")}catch{break}let l=s.indexOf("("),a=s.lastIndexOf(")");if(l===-1||a===-1)break;r.push({pid:o,name:s.slice(l+1,a)}),o=Number(s.slice(a+2).split(" ")[1])}return r}if(t==="darwin"){let o=n("ps",["-axo","pid=,ppid=,comm="]);if(o.status!==0)return r;let i=new Map;for(let l of o.stdout.split(`
|
|
16
|
+
`)){let a=/^\s*(\d+)\s+(\d+)\s+(.+)$/.exec(l);a&&i.set(Number(a[1]),{ppid:Number(a[2]),comm:a[3].trim()})}let s=e;for(let l=0;l<32&&i.has(s)&&s>1;l+=1){let a=i.get(s);r.push({pid:s,name:a.comm}),s=a.ppid}}return r}function Rt(t,{platform:e=process.platform}={}){if(e!=="linux")return[];try{return It.readFileSync(`/proc/${t}/cmdline`,"utf8").split("\0").filter(Boolean)}catch{return[]}}function Pt(t,e){return e.find(n=>zt.some(([r,o])=>o===t&&r.test(_t.basename(String(n.name||"")))))||null}function Mt(t,e={}){let n=R(e),r=Et[t];if(!r)return null;let o;try{o=r(n)}catch{return null}if(!o?.family)return null;let i=yt(o.family,n);return i?H({source:t,family:i,sizePx:o.sizePx}):null}function $t({env:t=process.env,ancestry:e,lineage:n,deps:r={}}={}){let o=n||(e?e.map(a=>({pid:0,name:a})):Ot({run:r.run})),i=At({env:t,ancestry:o.map(a=>a.name)});if(!i)return null;let s=Pt(i,o),l=r.terminalArgs||(s?.pid?Rt(s.pid):[]);return Mt(i,{...r,env:t,terminalArgs:l})}function H(t){let e=q(t);if(!e)return null;let n={source:e.source||null,family:e.family};return e.sizePx&&(n.sizePx=e.sizePx),n}function Qt(t,e={}){if(!t?.family)return null;let n=pt(t.family,e);return{...t,faces:n,subsets:dt(t.family,n,e)}}function Pe(t){return t?q(t):null}function Me(t,e,n){let r=t?.faces?.find(s=>s.sha256===e);if(!r)return null;let o=Math.ceil(r.bytes/262144);if(!Number.isInteger(n)||n<0||n>=o)return null;let i;try{let s=U.statSync(r.path);if(s.size!==r.bytes||s.mtimeMs!==r.mtimeMs)return null;i=U.openSync(r.path,"r");let l=n*262144,a=Math.min(262144,r.bytes-l),m=Buffer.alloc(a);return U.readSync(i,m,0,a,l)!==a?null:{data:m,total:o}}catch{return null}finally{if(i!==void 0)try{U.closeSync(i)}catch{}}}function Lt(t=process.env){let e=t.HERDR_TERM_FONT_JSON;if(!e)return null;try{return H(JSON.parse(e))}catch{return null}}function kt(t){let e=H(t);if(!e)return null;try{let n=J(),r=n.terminalFont;(!r||JSON.stringify(r)!==JSON.stringify(e))&&it({...n,terminalFont:e})}catch{}return e}function Zt(){try{return H(J().terminalFont)}catch{return null}}function $e({env:t=process.env,detect:e=$t}={}){if(t.HERDR_TERM_FONT_JSON)return Lt(t);let n=e({env:t});return n?(t.HERDR_TERM_FONT_JSON=JSON.stringify(n),kt(n),n):null}function te({env:t=process.env}={}){return Lt(t)||Zt()}function Le({env:t=process.env,refresh:e=!1,deps:n={}}={}){let r=te({env:t}),o=r?.source?Mt(r.source,{...n,env:t}):null;return!o&&e&&!r&&(o=$t({env:t,deps:n})),o&&JSON.stringify(o)!==JSON.stringify(r)&&kt(o),Qt(o||r,n)}export{xt as a,Mt as b,$t as c,Pe as d,Me as e,Lt as f,$e as g,te as h,Le as i};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
var g=Object.create;var e=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var n=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports),o=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0})},l=(a,b,c,f)=>{if(b&&typeof b=="object"||typeof b=="function")for(let d of i(b))!k.call(a,d)&&d!==c&&e(a,d,{get:()=>b[d],enumerable:!(f=h(b,d))||f.enumerable});return a};var p=(a,b,c)=>(c=a!=null?g(j(a)):{},l(b||!a||!a.__esModule?e(c,"default",{value:a,enumerable:!0}):c,a));export{m as a,n as b,o as c,p as d};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import f from"node:fs";import i from"node:os";import n from"node:path";function s(o=process.env,r=process.platform){if(r==="win32"){let t=o.XDG_CONFIG_HOME||o.APPDATA||o.USERPROFILE&&n.join(o.USERPROFILE,"AppData","Roaming")||n.join(i.homedir(),"AppData","Roaming");return n.join(t,"herdr")}let e=o.XDG_CONFIG_HOME||n.join(i.homedir(),".config");return n.join(e,"herdr")}function c(o=process.env,r=process.platform){return o.HERDR_SOCKET_PATH||n.join(s(o,r),"herdr.sock")}function d(o=process.env,r=process.platform){return o.HERDR_CONFIG_PATH||n.join(s(o,r),"config.toml")}function l(o,r=process.platform){return r==="win32"?`\\\\.\\pipe\\${o}`:o}function E(o=null,r=process.env){return o||r.HERDR_SOCKET_PATH||c(r)}function g(o,r={}){if(typeof o!="string"||o.length===0)return{ok:!1,reason:"socket path is empty",path:o};try{let e=f.statSync(o);return process.platform!=="win32"&&!e.isSocket()?{ok:!1,reason:"path is not a Unix socket",path:o}:r.requireOwner!==!1&&typeof process.getuid=="function"&&e.uid!==process.getuid()?{ok:!1,reason:"socket is not owned by the current user",path:o,uid:e.uid}:{ok:!0,path:o,uid:e.uid,mode:e.mode}}catch(e){let{code:t,message:p}=e;return{ok:!1,missing:t==="ENOENT",reason:t==="ENOENT"?"socket does not exist":p,path:o}}}export{d as a,l as b,E as c,g as d};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{a as f,b as I,c as N,d as w,e as k,h as R}from"./DGUZCGQN.js";import{c as E}from"./JJGEV4EZ.js";import{h as U}from"./H24ZP5D5.js";import{o as F}from"./PBRQ3HEG.js";import{a as v,b as H,c as D,d as A,g,h as u}from"./U6QAYG3E.js";import{k as x,l as C,m as Y,o as M}from"./UEOQE77N.js";import{d as l,e as p,f as h,g as L,h as O,o as c}from"./M52LJEES.js";import{a as P}from"./QRGNEKME.js";import{a as T,c as m,f as S}from"./TNLCNVA2.js";import{spawn as b}from"node:child_process";import _ from"node:fs";import{createRequire as j}from"node:module";import y from"node:path";function G(){let e=j(import.meta.url).resolve("herdr-remote-relay/package.json");return y.join(y.dirname(e),"bin","herdr-remote-relay.js")}function J(){return y.join(m(),"relay-auth.json")}function V(e=c(),t=A()){let r=[],s=h(e,R());l(e)&&r.push({name:"relay",command:process.execPath,args:[G()],cwd:m(),env:{RELAY_DEPLOYMENT_MODE:"local",RELAY_BIND:p(e),RELAY_PORT:String(e.relay.port),RELAY_PUBLIC_URL:s,RELAY_PASSWORD:t.hostToken,RELAY_AUTH_STATE_FILE:J(),RELAY_ALLOWED_ORIGINS:(e.relay.allowedOrigins||[]).join(","),RELAY_MAX_CLIENTS_PER_HOST:String(e.relay.maxClientsPerHost),RELAY_MAX_HOSTS:String(e.relay.maxHosts),RELAY_MAX_PENDING_HANDSHAKES:String(e.relay.maxPendingHandshakes),RELAY_MAX_BUFFERED_BYTES_PER_CLIENT:String(e.relay.maxBufferedBytesPerClient),RELAY_HOST_RECONNECT_GRACE_MS:String(e.relay.hostReconnectGraceMs)}});let n=F(),a=U();return r.push({name:"host",command:process.execPath,args:[y.join(T,"dist","connector","main.js")],cwd:m(),env:{...n?{HERDR_TERM_PALETTE_JSON:JSON.stringify(n)}:{},...a?{HERDR_TERM_FONT_JSON:JSON.stringify(a)}:{},RELAY_URL:O(e),RELAY_HOST_ID:t.hostId,RELAY_HOST_TOKEN:t.hostToken,RELAY_PASSWORD:l(e)?t.hostToken:t.relayPassword||"",HERDR_SOCKET_PATH:E(e.herdr.socketPath),HERDR_ARGS_JSON:JSON.stringify(e.herdr.args),HERDR_CWD:e.herdr.cwd,HERDR_BIN_PATH:Y()}}),r}function K(){return{...process.env,HERDR_REMOTE_SERVICE:"1"}}function W(e){P(m());let t=_.openSync(S(e.name),"a");try{let r=b(e.command,e.args,{cwd:e.cwd,env:{...K(),...e.env},detached:!0,windowsHide:!0,stdio:["ignore",t,t]});return r.unref(),r.pid}finally{_.closeSync(t)}}var X={relay:"relayPid",host:"hostPid"};function B(){let e=c(),t=A(),r={...t},s=V(e,t),n=u(r),a=o=>n.some(i=>i.pid===o);for(let o of s){let i=X[o.name];a(r[i])||(r[i]=W(o)??null,g(r,o.name,r[i]))}if(!s.some(o=>o.name==="relay")&&a(r.relayPid)){try{process.kill(r.relayPid,"SIGTERM")}catch{}r.relayPid=null}r.startedAt=r.startedAt||new Date().toISOString(),r.mode=e.relay.mode,H(r);let d=u(r);return{ok:!0,mode:e.relay.mode,relay:{local:l(e),pid:r.relayPid||null,alive:d.some(({pid:o})=>o===r.relayPid),bind:l(e)?p(e):null,port:e.relay.port,remoteUrl:e.relay.remoteUrl||null},host:{pid:r.hostPid||null,alive:d.some(({pid:o})=>o===r.hostPid),socketPath:E(e.herdr.socketPath)},publicUrl:h(e,R())}}function $(){let e=[];return P(m()),D(t=>{let r=u(t).sort((s,n)=>(s.name==="supervisor"?0:1)-(n.name==="supervisor"?0:1));for(let{pid:s,name:n}of r)try{process.kill(s,"SIGTERM"),e.push({name:n,pid:s})}catch(a){process.stderr.write(`herdr-remote: could not stop ${n} (pid ${s}): ${a.message}
|
|
4
|
+
`)}t.hostPid=null,t.relayPid=null,t.supervisorPid=null,t.managedPids=[],t.startedAt=null}),{ok:!0,stopped:e}}function ce(){return $(),B()}async function ue(){let e=c(),t=v(),r=u(t),s=R(),n;try{n=await f(I(e),{timeout:1200})}catch(i){n={ok:!1,message:i.message}}let a=E(e.herdr.socketPath),d=C(),o=d.found?M({command:d.command}):{version:null,supported:!0};return{ok:!0,mode:e.relay.mode,relay:{local:l(e),pid:t.relayPid||null,alive:l(e)?r.some(({pid:i})=>i===t.relayPid):null,bind:l(e)?p(e):null,port:e.relay.port,remoteUrl:e.relay.remoteUrl||null,health:n},host:{pid:t.hostPid||null,alive:r.some(({pid:i})=>i===t.hostPid),hostId:t.hostId||null,socketPath:a,socketExists:!!a&&_.existsSync(a),herdrCommand:d.command,herdrCommandFound:d.found,herdrCommandSource:d.source,herdrVersion:o.version,herdrVersionSupported:o.supported,herdrVersionMinimum:x},publicUrl:h(e,s),startedAt:t.startedAt||null}}async function pe(){let e=c();return l(e)&&B(),await w(e),await k(e),f(`${L(e)}/api/pair/start`,{method:"POST",headers:N(),timeout:5e3})}function he(e,t=40){try{return _.readFileSync(S(e),"utf8").split(`
|
|
5
|
+
`).filter(Boolean).slice(-t)}catch{return[]}}export{G as a,V as b,K as c,B as d,$ as e,ce as f,ue as g,pe as h,he as i};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{spawnSync as d}from"node:child_process";import a from"node:fs";var $=1e4,S=/herdr-remote-relay\.js|connector[\\/]main\.js|herdr-remote\.js"?\s+run\b/;function g(t){if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function u(t,e){let n=d(t,e,{encoding:"utf8",env:{...process.env,LC_ALL:"C",TZ:"UTC"},stdio:["ignore","pipe","ignore"],timeout:$,windowsHide:!0});return typeof n.stdout=="string"?n.stdout:""}function l(t){let e=new Map;for(let n of t.split(/\r?\n/)){let r=/^\s*(\d+)\s+(\S.*?)\s*$/.exec(n);r&&e.set(Number(r[1]),r[2])}return e}function _(t,e,n){let r="";if(e==="start")try{r=a.readFileSync("/proc/sys/kernel/random/boot_id","utf8").trim()}catch{return p(t,e,n)}let o=new Map;for(let s of t){let i;try{i=a.readFileSync(`/proc/${s}/${e==="start"?"stat":"cmdline"}`,"utf8")}catch{continue}if(e==="command"){o.set(s,i.replaceAll("\0"," ").trim());continue}let c=i.slice(i.lastIndexOf(")")+2).split(" ");c[19]&&o.set(s,`${r}:${c[19]}`)}return o}function p(t,e,n){return l(n("ps",["-o",`pid=,${e==="start"?"lstart":"command"}=`,"-p",t.join(",")]))}function h(t,e,n){let r=e==="start"?`Get-Process -Id ${t.join(",")} -ErrorAction SilentlyContinue | Where-Object StartTime | ForEach-Object { "$($_.Id) $($_.StartTime.ToFileTimeUtc())" }`:`Get-CimInstance Win32_Process -Filter "${t.map(o=>`ProcessId=${o}`).join(" OR ")}" | ForEach-Object { "$($_.ProcessId) $($_.CommandLine)" }`;return l(n("powershell.exe",["-NoProfile","-NonInteractive","-Command",r]))}function f(t,e,n,r){let o=[...new Set(t)].filter(g);return o.length===0?new Map:n==="linux"?_(o,e,r):n==="win32"?h(o,e,r):p(o,e,r)}function m(t,e=process.platform,n=u){return f(t,"start",e,n)}function w(t,e=process.platform,n=u){return f(t,"command",e,n)}function x(t,e=process.platform){return m([t],e).get(t)??null}function C(t){let e=s=>s.map(i=>i.pid).filter(i=>Number.isInteger(i)),n=t.filter(s=>typeof s.processStart!="string"),r=m(e(t.filter(s=>!n.includes(s)))),o=n.length>0?w(e(n)):new Map;return t.filter(s=>n.includes(s)?s.pid!==process.pid&&S.test(o.get(s.pid)??""):r.get(s.pid)===s.processStart)}export{g as a,x as b,C as c};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire as __herdrCreateRequire } from 'node:module';
|
|
2
|
+
const require = __herdrCreateRequire(import.meta.url);
|
|
3
|
+
import{b as t}from"./7SMZ43LI.js";import"./I6NRCYLI.js";var n=globalThis;n.WebSocket||=t;n.window||=globalThis;n.self||=globalThis;n.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__=[{type:1,value:7,isEnabled:!0},{type:2,value:"InternalApp",isEnabled:!0,isValid:!0},{type:2,value:"InternalAppContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalStdoutContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalStderrContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalStdinContext",isEnabled:!0,isValid:!0},{type:2,value:"InternalFocusContext",isEnabled:!0,isValid:!0}];import a from"react-devtools-core";var l=async()=>new Promise(o=>{let e=new t("ws://localhost:8097"),i=setTimeout(()=>{e.terminate(),o(!1)},2e3);i.unref(),e.on("open",()=>{clearTimeout(i),e.terminate(),o(!0)}),e.on("error",()=>{clearTimeout(i),e.terminate(),o(!1)})});await l()?(a.initialize(),a.connectToDevTools()):console.warn(`DEV is set to true, but the React DevTools server is not running. Start it with:
|
|
4
|
+
|
|
5
|
+
$ npx react-devtools
|
|
6
|
+
`);
|