@lifeaitools/clauth 1.30.9 → 1.30.10

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.
@@ -583,6 +583,10 @@ function validateWriteToken(req, writeSession) {
583
583
  return a.length === b.length && crypto.timingSafeEqual(a, b);
584
584
  }
585
585
 
586
+ export function isLoopbackAddress(remote) {
587
+ return remote === "127.0.0.1" || remote === "::1" || remote === "::ffff:127.0.0.1";
588
+ }
589
+
586
590
  export function supervisorRequiresWriteToken(port = getSupervisorPort(), env = process.env) {
587
591
  if (port !== getSupervisorPort()) return true;
588
592
  return env.CLAUTH_SUPERVISOR_REQUIRE_WRITE_TOKEN === "1";
@@ -3183,6 +3187,7 @@ function createServer(initPassword, whitelist, port, tunnelHostnameInit = null,
3183
3187
  function hasSupervisorWrite(req) {
3184
3188
  if (validateWriteToken(req, writeSession)) return true;
3185
3189
  if (!isSupervisorPort) return false;
3190
+ if (!isLoopbackAddress(req.socket?.remoteAddress)) return false;
3186
3191
  return supervisorTestNoToken || !supervisorRequiresWriteToken(port);
3187
3192
  }
3188
3193
 
@@ -3611,9 +3616,9 @@ function createServer(initPassword, whitelist, port, tunnelHostnameInit = null,
3611
3616
  }
3612
3617
  }
3613
3618
 
3614
- const server = http.createServer(async (req, res) => {
3615
- const remote = req.socket.remoteAddress;
3616
- const isLocal = remote === "127.0.0.1" || remote === "::1" || remote === "::ffff:127.0.0.1";
3619
+ const server = http.createServer(async (req, res) => {
3620
+ const remote = req.socket.remoteAddress;
3621
+ const isLocal = isLoopbackAddress(remote);
3617
3622
 
3618
3623
  const url = new URL(req.url, `http://127.0.0.1:${port}`);
3619
3624
  const reqPath = url.pathname;
@@ -17,7 +17,7 @@ import {
17
17
  supervisorHealth,
18
18
  validatePluginManifest,
19
19
  } from "./supervisor-registry.js";
20
- import { supervisorRequiresWriteToken } from "./commands/serve.js";
20
+ import { isLoopbackAddress, supervisorRequiresWriteToken } from "./commands/serve.js";
21
21
 
22
22
  function withTempSupervisor(fn) {
23
23
  const root = fs.mkdtempSync(path.join(os.tmpdir(), "clauth-supervisor-"));
@@ -181,6 +181,10 @@ test("supervisor write-token policy is temporarily relaxed only for the localhos
181
181
  assert.equal(supervisorRequiresWriteToken(52439, {}), false);
182
182
  assert.equal(supervisorRequiresWriteToken(52439, { CLAUTH_SUPERVISOR_REQUIRE_WRITE_TOKEN: "1" }), true);
183
183
  assert.equal(supervisorRequiresWriteToken(52437, {}), true);
184
+ assert.equal(isLoopbackAddress("127.0.0.1"), true);
185
+ assert.equal(isLoopbackAddress("::1"), true);
186
+ assert.equal(isLoopbackAddress("::ffff:127.0.0.1"), true);
187
+ assert.equal(isLoopbackAddress("192.168.1.25"), false);
184
188
  });
185
189
 
186
190
  test("tunnel route add and remove produce reversible operation receipts", () => withTempSupervisor((root) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifeaitools/clauth",
3
- "version": "1.30.9",
3
+ "version": "1.30.10",
4
4
  "description": "Hardware-bound credential vault for the LIFEAI infrastructure stack",
5
5
  "type": "module",
6
6
  "bin": {
Binary file
Binary file
Binary file