clay-server 2.35.0-beta.1 → 2.35.0-beta.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.
@@ -362,8 +362,9 @@ function attachSettings(ctx) {
362
362
 
363
363
  // PUT /api/user/auto-continue
364
364
  if (req.method === "PUT" && fullUrl === "/api/user/auto-continue") {
365
+ var isMultiUser = users.isMultiUser();
365
366
  var mu = getMultiUserFromReq(req);
366
- if (!mu) {
367
+ if (!isMultiUser) {
367
368
  // Single-user: use daemon config fallback
368
369
  var body = "";
369
370
  req.on("data", function (chunk) { body += chunk; });
@@ -382,6 +383,11 @@ function attachSettings(ctx) {
382
383
  });
383
384
  return true;
384
385
  }
386
+ if (!mu) {
387
+ res.writeHead(401, { "Content-Type": "application/json" });
388
+ res.end('{"error":"unauthorized"}');
389
+ return true;
390
+ }
385
391
  var body = "";
386
392
  req.on("data", function (chunk) { body += chunk; });
387
393
  req.on("end", function () {
@@ -405,8 +411,9 @@ function attachSettings(ctx) {
405
411
 
406
412
  // PUT /api/user/mates-enabled
407
413
  if (req.method === "PUT" && fullUrl === "/api/user/mates-enabled") {
414
+ var isMultiUser = users.isMultiUser();
408
415
  var mu = getMultiUserFromReq(req);
409
- if (!mu) {
416
+ if (!isMultiUser) {
410
417
  // Single-user: store on daemon config
411
418
  var body = "";
412
419
  req.on("data", function (chunk) { body += chunk; });
@@ -426,6 +433,11 @@ function attachSettings(ctx) {
426
433
  });
427
434
  return true;
428
435
  }
436
+ if (!mu) {
437
+ res.writeHead(401, { "Content-Type": "application/json" });
438
+ res.end('{"error":"unauthorized"}');
439
+ return true;
440
+ }
429
441
  var body = "";
430
442
  req.on("data", function (chunk) { body += chunk; });
431
443
  req.on("end", function () {
@@ -449,8 +461,9 @@ function attachSettings(ctx) {
449
461
 
450
462
  // PUT /api/user/chat-layout
451
463
  if (req.method === "PUT" && fullUrl === "/api/user/chat-layout") {
464
+ var isMultiUser = users.isMultiUser();
452
465
  var mu = getMultiUserFromReq(req);
453
- if (!mu) {
466
+ if (!isMultiUser) {
454
467
  // Single-user: save to daemon config
455
468
  var body = "";
456
469
  req.on("data", function (chunk) { body += chunk; });
@@ -470,6 +483,11 @@ function attachSettings(ctx) {
470
483
  });
471
484
  return true;
472
485
  }
486
+ if (!mu) {
487
+ res.writeHead(401, { "Content-Type": "application/json" });
488
+ res.end('{"error":"unauthorized"}');
489
+ return true;
490
+ }
473
491
  var body = "";
474
492
  req.on("data", function (chunk) { body += chunk; });
475
493
  req.on("end", function () {
@@ -493,8 +511,9 @@ function attachSettings(ctx) {
493
511
 
494
512
  // POST /api/user/mate-onboarded
495
513
  if (req.method === "POST" && fullUrl === "/api/user/mate-onboarded") {
514
+ var isMultiUser = users.isMultiUser();
496
515
  var mu = getMultiUserFromReq(req);
497
- if (!mu) {
516
+ if (!isMultiUser) {
498
517
  // Single-user: save to daemon config
499
518
  if (typeof opts.onSetMateOnboarded === "function") {
500
519
  opts.onSetMateOnboarded();
@@ -502,6 +521,11 @@ function attachSettings(ctx) {
502
521
  res.writeHead(200, { "Content-Type": "application/json" });
503
522
  res.end('{"ok":true}');
504
523
  } else {
524
+ if (!mu) {
525
+ res.writeHead(401, { "Content-Type": "application/json" });
526
+ res.end('{"error":"unauthorized"}');
527
+ return true;
528
+ }
505
529
  users.setMateOnboarded(mu.id);
506
530
  res.writeHead(200, { "Content-Type": "application/json" });
507
531
  res.end('{"ok":true}');
@@ -511,13 +535,19 @@ function attachSettings(ctx) {
511
535
 
512
536
  // GET /api/user/tool-palettes
513
537
  if (req.method === "GET" && fullUrl === "/api/user/tool-palettes") {
538
+ var isMultiUser = users.isMultiUser();
514
539
  var muGet = getMultiUserFromReq(req);
515
540
  var palettes = {};
516
- if (!muGet) {
541
+ if (!isMultiUser) {
517
542
  if (typeof opts.onGetToolPalettes === "function") {
518
543
  palettes = opts.onGetToolPalettes() || {};
519
544
  }
520
545
  } else {
546
+ if (!muGet) {
547
+ res.writeHead(401, { "Content-Type": "application/json" });
548
+ res.end('{"error":"unauthorized"}');
549
+ return true;
550
+ }
521
551
  palettes = users.getToolPalettes(muGet.id) || {};
522
552
  }
523
553
  res.writeHead(200, { "Content-Type": "application/json" });
@@ -527,6 +557,7 @@ function attachSettings(ctx) {
527
557
 
528
558
  // PUT /api/user/tool-palettes
529
559
  if (req.method === "PUT" && fullUrl === "/api/user/tool-palettes") {
560
+ var isMultiUser = users.isMultiUser();
530
561
  var muPut = getMultiUserFromReq(req);
531
562
  var bodyTp = "";
532
563
  req.on("data", function (chunk) { bodyTp += chunk; });
@@ -537,7 +568,7 @@ function attachSettings(ctx) {
537
568
  var order = dataTp.order;
538
569
  var hidden = dataTp.hidden;
539
570
  var result;
540
- if (!muPut) {
571
+ if (!isMultiUser) {
541
572
  if (typeof opts.onSetToolPalette !== "function") {
542
573
  res.writeHead(500, { "Content-Type": "application/json" });
543
574
  res.end('{"error":"Not supported"}');
@@ -545,6 +576,11 @@ function attachSettings(ctx) {
545
576
  }
546
577
  result = opts.onSetToolPalette(paletteName, order, hidden);
547
578
  } else {
579
+ if (!muPut) {
580
+ res.writeHead(401, { "Content-Type": "application/json" });
581
+ res.end('{"error":"unauthorized"}');
582
+ return;
583
+ }
548
584
  result = users.setToolPalette(muPut.id, paletteName, order, hidden);
549
585
  }
550
586
  if (result && result.error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clay-server",
3
- "version": "2.35.0-beta.1",
3
+ "version": "2.35.0-beta.2",
4
4
  "description": "Self-hosted Claude Code in your browser. Multi-session, multi-user, push notifications.",
5
5
  "bin": {
6
6
  "clay-server": "./bin/cli.js",