rechrome 1.8.1 → 1.8.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rechrome",
3
- "version": "1.8.1",
3
+ "version": "1.8.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/snomiao/rechrome.git"
package/rech.js CHANGED
@@ -535,15 +535,19 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
535
535
  const url = await getOrCreateUrl();
536
536
  const { host, port, protocol } = parseUrl(url);
537
537
 
538
- let ping = await fetch(`${protocol}://${host}:${port}/`, { signal: AbortSignal.timeout(2000) }).catch(() => null);
539
- if (ping) {
540
- console.log(` Already running at ${protocol}://${host}:${port}`);
541
- await daemonInstall(url);
542
- console.log(` Updated daemon: ${OXMGR_PROCESS_NAME}`);
538
+ const { key: serveKey } = parseUrl(url);
539
+ const authPing = await fetch(`${protocol}://${host}:${port}/ping`, {
540
+ headers: { Authorization: `Bearer ${serveKey}` },
541
+ signal: AbortSignal.timeout(2000),
542
+ }).catch(() => null);
543
+ if (authPing?.ok) {
544
+ console.log(` Already running at ${protocol}://${host}:${port} — skipping reinstall`);
545
+ await runOxmgr(["service", "install"]);
543
546
  } else {
544
547
  await daemonInstall(url);
545
548
  console.log(` Registered daemon: ${OXMGR_PROCESS_NAME}`);
546
549
  process.stdout.write(" Starting");
550
+ let ping = null;
547
551
  for (let i = 0; i < 15; i++) {
548
552
  await Bun.sleep(1000);
549
553
  ping = await fetch(`${protocol}://${host}:${port}/`, { signal: AbortSignal.timeout(2000) }).catch(() => null);
package/rech.ts CHANGED
@@ -535,15 +535,19 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
535
535
  const url = await getOrCreateUrl();
536
536
  const { host, port, protocol } = parseUrl(url);
537
537
 
538
- let ping = await fetch(`${protocol}://${host}:${port}/`, { signal: AbortSignal.timeout(2000) }).catch(() => null);
539
- if (ping) {
540
- console.log(` Already running at ${protocol}://${host}:${port}`);
541
- await daemonInstall(url);
542
- console.log(` Updated daemon: ${OXMGR_PROCESS_NAME}`);
538
+ const { key: serveKey } = parseUrl(url);
539
+ const authPing = await fetch(`${protocol}://${host}:${port}/ping`, {
540
+ headers: { Authorization: `Bearer ${serveKey}` },
541
+ signal: AbortSignal.timeout(2000),
542
+ }).catch(() => null);
543
+ if (authPing?.ok) {
544
+ console.log(` Already running at ${protocol}://${host}:${port} — skipping reinstall`);
545
+ await runOxmgr(["service", "install"]);
543
546
  } else {
544
547
  await daemonInstall(url);
545
548
  console.log(` Registered daemon: ${OXMGR_PROCESS_NAME}`);
546
549
  process.stdout.write(" Starting");
550
+ let ping = null;
547
551
  for (let i = 0; i < 15; i++) {
548
552
  await Bun.sleep(1000);
549
553
  ping = await fetch(`${protocol}://${host}:${port}/`, { signal: AbortSignal.timeout(2000) }).catch(() => null);
package/serve.js CHANGED
@@ -107,6 +107,11 @@ export async function serve() {
107
107
  return new Response(f);
108
108
  }
109
109
 
110
+ if (reqUrl.pathname === "/ping") {
111
+ const denied = authCheck(req, key);
112
+ if (denied) return denied;
113
+ return new Response("ok");
114
+ }
110
115
  if (reqUrl.pathname !== "/run") return new Response("rech server\n");
111
116
  const denied = authCheck(req, key);
112
117
  if (denied) return denied;
package/serve.ts CHANGED
@@ -107,6 +107,11 @@ export async function serve() {
107
107
  return new Response(f);
108
108
  }
109
109
 
110
+ if (reqUrl.pathname === "/ping") {
111
+ const denied = authCheck(req, key);
112
+ if (denied) return denied;
113
+ return new Response("ok");
114
+ }
110
115
  if (reqUrl.pathname !== "/run") return new Response("rech server\n");
111
116
  const denied = authCheck(req, key);
112
117
  if (denied) return denied;