@clagentic/console 1.5.0-beta.2 → 1.5.0-beta.4

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.
Files changed (54) hide show
  1. package/README.md +18 -14
  2. package/bin/cli.js +1 -0
  3. package/lib/cli-sessions.js +71 -18
  4. package/lib/config.js +80 -6
  5. package/lib/daemon-projects.js +1 -1
  6. package/lib/daemon.js +142 -26
  7. package/lib/pages.js +1 -42
  8. package/lib/project-connection.js +4 -8
  9. package/lib/project-external-trigger.js +62 -7
  10. package/lib/project-http.js +17 -1
  11. package/lib/project-loop.js +3 -2
  12. package/lib/project-notifications.js +3 -18
  13. package/lib/project-sessions.js +68 -27
  14. package/lib/project-team.js +417 -0
  15. package/lib/project-user-message.js +5 -10
  16. package/lib/project.js +53 -53
  17. package/lib/public/app.js +7 -15
  18. package/lib/public/css/home-hub.css +36 -0
  19. package/lib/public/css/icon-strip.css +28 -126
  20. package/lib/public/css/menus.css +2 -2
  21. package/lib/public/css/team-panel.css +149 -0
  22. package/lib/public/index.html +72 -15
  23. package/lib/public/modules/admin.js +1 -52
  24. package/lib/public/modules/agent-picker.js +11 -3
  25. package/lib/public/modules/app-cursors.js +43 -47
  26. package/lib/public/modules/app-home-hub.js +12 -0
  27. package/lib/public/modules/app-messages.js +18 -12
  28. package/lib/public/modules/app-rendering.js +1 -2
  29. package/lib/public/modules/server-settings.js +74 -5
  30. package/lib/public/modules/sidebar-mobile.js +9 -88
  31. package/lib/public/modules/sidebar-projects.js +1 -1
  32. package/lib/public/modules/sidebar-sessions.js +6 -2
  33. package/lib/public/modules/sidebar-users.js +37 -307
  34. package/lib/public/modules/team-panel.js +331 -0
  35. package/lib/public/modules/tools.js +3 -0
  36. package/lib/public/modules/user-settings.js +0 -3
  37. package/lib/public/style.css +1 -0
  38. package/lib/sdk-bridge.js +121 -8
  39. package/lib/sdk-message-processor.js +39 -4
  40. package/lib/sdk-worker.js +2 -2
  41. package/lib/server-admin.js +1 -86
  42. package/lib/server-auth.js +13 -124
  43. package/lib/server-dm.js +2 -7
  44. package/lib/server-palette.js +9 -20
  45. package/lib/server-settings.js +41 -243
  46. package/lib/server-skills.js +11 -13
  47. package/lib/server.js +37 -60
  48. package/lib/sessions.js +16 -50
  49. package/lib/terminal-manager.js +13 -15
  50. package/lib/users-auth.js +0 -38
  51. package/lib/users.js +14 -11
  52. package/lib/ws-schema.js +12 -0
  53. package/lib/yoke/adapters/claude.js +5 -0
  54. package/package.json +1 -1
@@ -26,11 +26,6 @@ function attachAdmin(ctx) {
26
26
 
27
27
  // List all users (admin only)
28
28
  if (req.method === "GET" && fullUrl === "/api/admin/users") {
29
- if (!users.isMultiUser()) {
30
- res.writeHead(404, { "Content-Type": "application/json" });
31
- res.end('{"error":"Not found"}');
32
- return true;
33
- }
34
29
  var mu = getMultiUserFromReq(req);
35
30
  if (!mu) {
36
31
  res.writeHead(401, { "Content-Type": "application/json" });
@@ -54,11 +49,6 @@ function attachAdmin(ctx) {
54
49
 
55
50
  // Remove user (admin only)
56
51
  if (req.method === "DELETE" && fullUrl.indexOf("/api/admin/users/") === 0) {
57
- if (!users.isMultiUser()) {
58
- res.writeHead(404, { "Content-Type": "application/json" });
59
- res.end('{"error":"Not found"}');
60
- return true;
61
- }
62
52
  var mu = getMultiUserFromReq(req);
63
53
  if (!mu || mu.role !== "admin") {
64
54
  res.writeHead(403, { "Content-Type": "application/json" });
@@ -99,11 +89,6 @@ function attachAdmin(ctx) {
99
89
 
100
90
  // Create user (admin only) — generates a temporary PIN that must be changed on first login
101
91
  if (req.method === "POST" && fullUrl === "/api/admin/users") {
102
- if (!users.isMultiUser()) {
103
- res.writeHead(404, { "Content-Type": "application/json" });
104
- res.end('{"error":"Not found"}');
105
- return true;
106
- }
107
92
  var mu = getMultiUserFromReq(req);
108
93
  if (!mu || mu.role !== "admin") {
109
94
  res.writeHead(403, { "Content-Type": "application/json" });
@@ -166,11 +151,6 @@ function attachAdmin(ctx) {
166
151
 
167
152
  // Reset user PIN (admin only) — generates a new temp PIN
168
153
  if (req.method === "POST" && fullUrl.match(/^\/api\/admin\/users\/[^/]+\/reset-pin$/)) {
169
- if (!users.isMultiUser()) {
170
- res.writeHead(404, { "Content-Type": "application/json" });
171
- res.end('{"error":"Not found"}');
172
- return true;
173
- }
174
154
  var mu = getMultiUserFromReq(req);
175
155
  if (!mu || mu.role !== "admin") {
176
156
  res.writeHead(403, { "Content-Type": "application/json" });
@@ -214,11 +194,6 @@ function attachAdmin(ctx) {
214
194
 
215
195
  // Set Linux user mapping (admin only, OS-level multi-user)
216
196
  if (req.method === "PUT" && fullUrl.match(/^\/api\/admin\/users\/[^/]+\/linux-user$/)) {
217
- if (!users.isMultiUser()) {
218
- res.writeHead(404, { "Content-Type": "application/json" });
219
- res.end('{"error":"Not found"}');
220
- return true;
221
- }
222
197
  var mu = getMultiUserFromReq(req);
223
198
  if (!mu || mu.role !== "admin") {
224
199
  res.writeHead(403, { "Content-Type": "application/json" });
@@ -250,11 +225,6 @@ function attachAdmin(ctx) {
250
225
 
251
226
  // Update user permissions (admin only)
252
227
  if (req.method === "PUT" && fullUrl.match(/^\/api\/admin\/users\/[^/]+\/permissions$/)) {
253
- if (!users.isMultiUser()) {
254
- res.writeHead(404, { "Content-Type": "application/json" });
255
- res.end('{"error":"Not found"}');
256
- return true;
257
- }
258
228
  var mu = getMultiUserFromReq(req);
259
229
  if (!mu || mu.role !== "admin") {
260
230
  res.writeHead(403, { "Content-Type": "application/json" });
@@ -286,11 +256,6 @@ function attachAdmin(ctx) {
286
256
 
287
257
  // Create invite (admin only)
288
258
  if (req.method === "POST" && fullUrl === "/api/admin/invites") {
289
- if (!users.isMultiUser()) {
290
- res.writeHead(404, { "Content-Type": "application/json" });
291
- res.end('{"error":"Not found"}');
292
- return true;
293
- }
294
259
  var mu = getMultiUserFromReq(req);
295
260
  if (!mu || mu.role !== "admin") {
296
261
  res.writeHead(403, { "Content-Type": "application/json" });
@@ -308,11 +273,6 @@ function attachAdmin(ctx) {
308
273
 
309
274
  // List invites (admin only)
310
275
  if (req.method === "GET" && fullUrl === "/api/admin/invites") {
311
- if (!users.isMultiUser()) {
312
- res.writeHead(404, { "Content-Type": "application/json" });
313
- res.end('{"error":"Not found"}');
314
- return true;
315
- }
316
276
  var mu = getMultiUserFromReq(req);
317
277
  if (!mu || mu.role !== "admin") {
318
278
  res.writeHead(403, { "Content-Type": "application/json" });
@@ -326,11 +286,6 @@ function attachAdmin(ctx) {
326
286
 
327
287
  // Revoke invite (admin only)
328
288
  if (req.method === "DELETE" && fullUrl.indexOf("/api/admin/invites/") === 0) {
329
- if (!users.isMultiUser()) {
330
- res.writeHead(404, { "Content-Type": "application/json" });
331
- res.end('{"error":"Not found"}');
332
- return true;
333
- }
334
289
  var mu = getMultiUserFromReq(req);
335
290
  if (!mu || mu.role !== "admin") {
336
291
  res.writeHead(403, { "Content-Type": "application/json" });
@@ -356,7 +311,7 @@ function attachAdmin(ctx) {
356
311
 
357
312
  // Send invite via email (admin only)
358
313
  if (req.method === "POST" && fullUrl === "/api/admin/invites/email") {
359
- if (!users.isMultiUser() || !smtp.isSmtpConfigured()) {
314
+ if (!smtp.isSmtpConfigured()) {
360
315
  res.writeHead(400, { "Content-Type": "application/json" });
361
316
  res.end('{"error":"SMTP not configured"}');
362
317
  return true;
@@ -398,11 +353,6 @@ function attachAdmin(ctx) {
398
353
 
399
354
  // Get SMTP config (admin only)
400
355
  if (req.method === "GET" && fullUrl === "/api/admin/smtp") {
401
- if (!users.isMultiUser()) {
402
- res.writeHead(404, { "Content-Type": "application/json" });
403
- res.end('{"error":"Not found"}');
404
- return true;
405
- }
406
356
  var mu = getMultiUserFromReq(req);
407
357
  if (!mu || mu.role !== "admin") {
408
358
  res.writeHead(403, { "Content-Type": "application/json" });
@@ -422,11 +372,6 @@ function attachAdmin(ctx) {
422
372
 
423
373
  // Save SMTP config (admin only)
424
374
  if (req.method === "POST" && fullUrl === "/api/admin/smtp") {
425
- if (!users.isMultiUser()) {
426
- res.writeHead(404, { "Content-Type": "application/json" });
427
- res.end('{"error":"Not found"}');
428
- return true;
429
- }
430
375
  var mu = getMultiUserFromReq(req);
431
376
  if (!mu || mu.role !== "admin") {
432
377
  res.writeHead(403, { "Content-Type": "application/json" });
@@ -488,11 +433,6 @@ function attachAdmin(ctx) {
488
433
 
489
434
  // Test SMTP connection (admin only)
490
435
  if (req.method === "POST" && fullUrl === "/api/admin/smtp/test") {
491
- if (!users.isMultiUser()) {
492
- res.writeHead(404, { "Content-Type": "application/json" });
493
- res.end('{"error":"Not found"}');
494
- return true;
495
- }
496
436
  var mu = getMultiUserFromReq(req);
497
437
  if (!mu || mu.role !== "admin") {
498
438
  res.writeHead(403, { "Content-Type": "application/json" });
@@ -543,11 +483,6 @@ function attachAdmin(ctx) {
543
483
 
544
484
  // Set project visibility (admin only)
545
485
  if (req.method === "PUT" && /^\/api\/admin\/projects\/[a-z0-9_-]+\/visibility$/.test(fullUrl)) {
546
- if (!users.isMultiUser()) {
547
- res.writeHead(404, { "Content-Type": "application/json" });
548
- res.end('{"error":"Not found"}');
549
- return true;
550
- }
551
486
  var mu = getMultiUserFromReq(req);
552
487
  var _visSlug = fullUrl.split("/")[4];
553
488
  var _visAccess = onGetProjectAccess ? onGetProjectAccess(_visSlug) : null;
@@ -596,11 +531,6 @@ function attachAdmin(ctx) {
596
531
 
597
532
  // Set project owner (admin only)
598
533
  if (req.method === "PUT" && /^\/api\/admin\/projects\/[a-z0-9_-]+\/owner$/.test(fullUrl)) {
599
- if (!users.isMultiUser()) {
600
- res.writeHead(404, { "Content-Type": "application/json" });
601
- res.end('{"error":"Not found"}');
602
- return true;
603
- }
604
534
  var mu = getMultiUserFromReq(req);
605
535
  if (!mu || mu.role !== "admin") {
606
536
  res.writeHead(403, { "Content-Type": "application/json" });
@@ -648,11 +578,6 @@ function attachAdmin(ctx) {
648
578
 
649
579
  // Set project allowed users (admin only)
650
580
  if (req.method === "PUT" && /^\/api\/admin\/projects\/[a-z0-9_-]+\/users$/.test(fullUrl)) {
651
- if (!users.isMultiUser()) {
652
- res.writeHead(404, { "Content-Type": "application/json" });
653
- res.end('{"error":"Not found"}');
654
- return true;
655
- }
656
581
  var mu = getMultiUserFromReq(req);
657
582
  var _usrSlug = fullUrl.split("/")[4];
658
583
  var _usrAccess = onGetProjectAccess ? onGetProjectAccess(_usrSlug) : null;
@@ -701,11 +626,6 @@ function attachAdmin(ctx) {
701
626
 
702
627
  // Get project access info (admin or project owner)
703
628
  if (req.method === "GET" && /^\/api\/admin\/projects\/[a-z0-9_-]+\/access$/.test(fullUrl)) {
704
- if (!users.isMultiUser()) {
705
- res.writeHead(404, { "Content-Type": "application/json" });
706
- res.end('{"error":"Not found"}');
707
- return true;
708
- }
709
629
  var mu = getMultiUserFromReq(req);
710
630
  var _accSlug = fullUrl.split("/")[4];
711
631
  var _accAccess = onGetProjectAccess ? onGetProjectAccess(_accSlug) : null;
@@ -734,11 +654,6 @@ function attachAdmin(ctx) {
734
654
 
735
655
  // GET /api/admin/audit — tail the audit log (admin only, read-only)
736
656
  if (req.method === "GET" && fullUrl.indexOf("/api/admin/audit") === 0) {
737
- if (!users.isMultiUser()) {
738
- res.writeHead(404, { "Content-Type": "application/json" });
739
- res.end('{"error":"Not found"}');
740
- return true;
741
- }
742
657
  var mu = getMultiUserFromReq(req);
743
658
  if (!mu || mu.role !== "admin") {
744
659
  res.writeHead(403, { "Content-Type": "application/json" });
@@ -10,30 +10,6 @@ var audit = require("./audit");
10
10
  // treated as valid for one additional TTL cycle to avoid forced logouts on upgrade.
11
11
  var TOKEN_TTL_MS = 30 * 24 * 60 * 60 * 1000;
12
12
 
13
- // --- PIN hashing ---
14
-
15
- function generateAuthToken(pin) {
16
- var salt = crypto.randomBytes(16).toString("hex");
17
- var hash = crypto.scryptSync("clay:" + pin, salt, 64).toString("hex");
18
- return salt + ":" + hash;
19
- }
20
-
21
- function verifyPin(pin, storedHash) {
22
- if (!storedHash) return false;
23
- // New scrypt format: salt_hex:hash_hex (contains colon)
24
- if (storedHash.indexOf(":") !== -1) {
25
- var parts = storedHash.split(":");
26
- var salt = parts[0];
27
- var hash = parts[1];
28
- var derived = crypto.scryptSync("clay:" + pin, salt, 64).toString("hex");
29
- return crypto.timingSafeEqual(Buffer.from(derived, "hex"), Buffer.from(hash, "hex"));
30
- }
31
- // Legacy SHA256 format (no colon)
32
- var legacyHash = crypto.createHash("sha256").update("clay:" + pin).digest("hex");
33
- var match = crypto.timingSafeEqual(Buffer.from(legacyHash, "hex"), Buffer.from(storedHash, "hex"));
34
- return match;
35
- }
36
-
37
13
  // --- Cookie helpers ---
38
14
 
39
15
  function parseCookies(req) {
@@ -46,12 +22,6 @@ function parseCookies(req) {
46
22
  return cookies;
47
23
  }
48
24
 
49
- function isAuthed(req, authToken) {
50
- if (!authToken) return true;
51
- var cookies = parseCookies(req);
52
- return cookies["relay_auth"] === authToken;
53
- }
54
-
55
25
  // --- PIN rate limiting ---
56
26
 
57
27
  var PIN_MAX_ATTEMPTS = 5;
@@ -64,11 +34,8 @@ function attachAuth(ctx) {
64
34
  var tlsOptions = ctx.tlsOptions;
65
35
  var osUsers = ctx.osUsers;
66
36
  var provisionLinuxUser = ctx.provisionLinuxUser;
67
- var onUpgradePin = ctx.onUpgradePin;
68
37
  var onUserProvisioned = ctx.onUserProvisioned;
69
38
 
70
- var authToken = ctx.pinHash || null;
71
-
72
39
  // --- Multi-user auth tokens (persisted to disk) ---
73
40
  var TOKENS_NAME = _isDevMode ? "auth-tokens-dev.json" : "auth-tokens.json";
74
41
  var MULTI_USER_COOKIE = _isDevMode ? "relay_auth_user_dev" : "relay_auth_user";
@@ -335,25 +302,18 @@ function attachAuth(ctx) {
335
302
  }
336
303
 
337
304
  // --- Auth page selection ---
338
- var pinPage = pages.pinPageHtml();
339
305
  var adminSetupPage = pages.adminSetupPageHtml();
340
306
  var loginPage = pages.multiUserLoginPageHtml();
341
307
  var smtpLoginPage = pages.smtpLoginPageHtml();
342
308
 
343
309
  function getAuthPage() {
344
- if (!users.isMultiUser()) return pinPage;
345
310
  if (!users.hasAdmin()) return adminSetupPage;
346
311
  if (smtp.isEmailLoginEnabled()) return smtpLoginPage;
347
312
  return loginPage;
348
313
  }
349
314
 
350
315
  function isRequestAuthed(req) {
351
- if (users.isMultiUser()) return isMultiUserAuthed(req);
352
- return isAuthed(req, authToken);
353
- }
354
-
355
- function setAuthToken(hash) {
356
- authToken = hash;
316
+ return isMultiUserAuthed(req);
357
317
  }
358
318
 
359
319
  // --- Route handler ---
@@ -423,56 +383,8 @@ function attachAuth(ctx) {
423
383
  }
424
384
  }
425
385
 
426
- // Global auth endpoint (single-user PIN)
427
- if (req.method === "POST" && req.url === "/auth") {
428
- var ip = req.socket.remoteAddress || "";
429
- var remaining = checkPinRateLimit(ip);
430
- if (remaining !== null) {
431
- res.writeHead(429, { "Content-Type": "application/json" });
432
- res.end(JSON.stringify({ ok: false, locked: true, retryAfter: remaining }));
433
- return true;
434
- }
435
- var body = "";
436
- req.on("data", function (chunk) { body += chunk; });
437
- req.on("end", function () {
438
- try {
439
- var data = JSON.parse(body);
440
- if (authToken && verifyPin(data.pin, authToken)) {
441
- clearPinFailures(ip);
442
- // Auto-upgrade legacy SHA256 hash to scrypt
443
- if (authToken.indexOf(":") === -1) {
444
- var upgraded = generateAuthToken(data.pin);
445
- authToken = upgraded;
446
- if (typeof onUpgradePin === "function") {
447
- onUpgradePin(upgraded);
448
- }
449
- }
450
- res.writeHead(200, {
451
- "Set-Cookie": "relay_auth=" + authToken + "; Path=/; HttpOnly; SameSite=Strict; Max-Age=31536000" + (tlsOptions ? "; Secure" : ""),
452
- "Content-Type": "application/json",
453
- });
454
- res.end('{"ok":true}');
455
- } else {
456
- recordPinFailure(ip);
457
- var attemptsLeft = PIN_MAX_ATTEMPTS - (pinAttempts[ip] ? pinAttempts[ip].count : 0);
458
- res.writeHead(401, { "Content-Type": "application/json" });
459
- res.end(JSON.stringify({ ok: false, attemptsLeft: Math.max(attemptsLeft, 0) }));
460
- }
461
- } catch (e) {
462
- res.writeHead(400);
463
- res.end("Bad request");
464
- }
465
- });
466
- return true;
467
- }
468
-
469
386
  // Admin setup (first-time multi-user setup)
470
387
  if (req.method === "POST" && fullUrl === "/auth/setup") {
471
- if (!users.isMultiUser()) {
472
- res.writeHead(400, { "Content-Type": "application/json" });
473
- res.end('{"error":"Multi-user mode is not enabled"}');
474
- return true;
475
- }
476
388
  if (users.hasAdmin()) {
477
389
  res.writeHead(400, { "Content-Type": "application/json" });
478
390
  res.end('{"error":"Admin already exists"}');
@@ -546,11 +458,6 @@ function attachAuth(ctx) {
546
458
 
547
459
  // Multi-user login
548
460
  if (req.method === "POST" && fullUrl === "/auth/login") {
549
- if (!users.isMultiUser()) {
550
- res.writeHead(400, { "Content-Type": "application/json" });
551
- res.end('{"error":"Multi-user mode is not enabled"}');
552
- return true;
553
- }
554
461
  var ip = req.socket.remoteAddress || "";
555
462
  // IP-only pre-check (username not yet known — body not read)
556
463
  var remaining = checkPinRateLimit(ip);
@@ -602,7 +509,7 @@ function attachAuth(ctx) {
602
509
 
603
510
  // Request OTP code (SMTP login)
604
511
  if (req.method === "POST" && fullUrl === "/auth/request-otp") {
605
- if (!users.isMultiUser() || !smtp.isEmailLoginEnabled()) {
512
+ if (!smtp.isEmailLoginEnabled()) {
606
513
  res.writeHead(400, { "Content-Type": "application/json" });
607
514
  res.end('{"error":"OTP login not available"}');
608
515
  return true;
@@ -654,7 +561,7 @@ function attachAuth(ctx) {
654
561
 
655
562
  // Verify OTP code (SMTP login)
656
563
  if (req.method === "POST" && fullUrl === "/auth/verify-otp") {
657
- if (!users.isMultiUser() || !smtp.isEmailLoginEnabled()) {
564
+ if (!smtp.isEmailLoginEnabled()) {
658
565
  res.writeHead(400, { "Content-Type": "application/json" });
659
566
  res.end('{"error":"OTP login not available"}');
660
567
  return true;
@@ -706,11 +613,6 @@ function attachAuth(ctx) {
706
613
 
707
614
  // Invite registration
708
615
  if (req.method === "POST" && fullUrl === "/auth/register") {
709
- if (!users.isMultiUser()) {
710
- res.writeHead(400, { "Content-Type": "application/json" });
711
- res.end('{"error":"Multi-user mode is not enabled"}');
712
- return true;
713
- }
714
616
  var body = "";
715
617
  req.on("data", function (chunk) { body += chunk; });
716
618
  req.on("end", function () {
@@ -786,23 +688,16 @@ function attachAuth(ctx) {
786
688
 
787
689
  // Logout
788
690
  if (req.method === "POST" && fullUrl === "/auth/logout") {
789
- if (users.isMultiUser()) {
790
- var cookies = parseCookies(req);
791
- var token = cookies[MULTI_USER_COOKIE];
792
- if (token && multiUserTokens[token]) {
793
- delete multiUserTokens[token];
794
- saveTokens();
795
- }
796
- res.writeHead(200, {
797
- "Set-Cookie": MULTI_USER_COOKIE + "=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0" + (tlsOptions ? "; Secure" : ""),
798
- "Content-Type": "application/json",
799
- });
800
- } else {
801
- res.writeHead(200, {
802
- "Set-Cookie": "relay_auth=; Path=/; HttpOnly; SameSite=Strict; Max-Age=0" + (tlsOptions ? "; Secure" : ""),
803
- "Content-Type": "application/json",
804
- });
691
+ var cookies = parseCookies(req);
692
+ var token = cookies[MULTI_USER_COOKIE];
693
+ if (token && multiUserTokens[token]) {
694
+ delete multiUserTokens[token];
695
+ saveTokens();
805
696
  }
697
+ res.writeHead(200, {
698
+ "Set-Cookie": MULTI_USER_COOKIE + "=; Path=/; HttpOnly; SameSite=Lax; Max-Age=0" + (tlsOptions ? "; Secure" : ""),
699
+ "Content-Type": "application/json",
700
+ });
806
701
  res.end('{"ok":true}');
807
702
  return true;
808
703
  }
@@ -810,11 +705,6 @@ function attachAuth(ctx) {
810
705
  // Invite page (magic link)
811
706
  if (req.method === "GET" && fullUrl.indexOf("/invite/") === 0) {
812
707
  var inviteCode = fullUrl.substring("/invite/".length);
813
- if (!users.isMultiUser()) {
814
- res.writeHead(404, { "Content-Type": "text/plain" });
815
- res.end("Not found");
816
- return true;
817
- }
818
708
  var validation = users.validateInvite(inviteCode);
819
709
  if (!validation.valid) {
820
710
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
@@ -840,7 +730,6 @@ function attachAuth(ctx) {
840
730
  revokeUserTokens: revokeUserTokens,
841
731
  setRecovery: setRecovery,
842
732
  clearRecovery: clearRecovery,
843
- setAuthToken: setAuthToken,
844
733
  getAuthPage: getAuthPage,
845
734
  createMultiUserSession: createMultiUserSession,
846
735
  isUserLockedOut: isUserLockedOut,
@@ -848,4 +737,4 @@ function attachAuth(ctx) {
848
737
  };
849
738
  }
850
739
 
851
- module.exports = { attachAuth: attachAuth, generateAuthToken: generateAuthToken, verifyPin: verifyPin };
740
+ module.exports = { attachAuth: attachAuth };
package/lib/server-dm.js CHANGED
@@ -15,13 +15,8 @@ function attachDm(ctx) {
15
15
  var pushModule = ctx.pushModule;
16
16
 
17
17
  function handleMessage(ws, msg) {
18
- var userId;
19
- if (users.isMultiUser()) {
20
- if (!ws._clayUser) return false;
21
- userId = ws._clayUser.id;
22
- } else {
23
- userId = "default";
24
- }
18
+ if (!ws._clayUser) return false;
19
+ var userId = ws._clayUser.id;
25
20
 
26
21
  if (msg.type === "dm_list") {
27
22
  var dmList = dm.getDmList(userId);
@@ -9,14 +9,11 @@ function attachPalette(ctx) {
9
9
  function handleRequest(req, res, fullUrl) {
10
10
  if (req.method !== "GET" || fullUrl !== "/api/palette/search") return false;
11
11
 
12
- var paletteUser = null;
13
- if (users.isMultiUser()) {
14
- paletteUser = getMultiUserFromReq(req);
15
- if (!paletteUser) {
16
- res.writeHead(401, { "Content-Type": "application/json" });
17
- res.end('{"error":"unauthorized"}');
18
- return true;
19
- }
12
+ var paletteUser = getMultiUserFromReq(req);
13
+ if (!paletteUser) {
14
+ res.writeHead(401, { "Content-Type": "application/json" });
15
+ res.end('{"error":"unauthorized"}');
16
+ return true;
20
17
  }
21
18
  var pqs = req.url.indexOf("?") >= 0 ? req.url.substring(req.url.indexOf("?")) : "";
22
19
  var pQuery = new URLSearchParams(pqs).get("q") || "";
@@ -34,12 +31,8 @@ function attachPalette(ctx) {
34
31
  pCtx.sm.sessions.forEach(function (session) {
35
32
  if (session.hidden) return;
36
33
  if (paletteUser) {
37
- if (users.isMultiUser()) {
38
- var sAccess = onGetProjectAccess ? onGetProjectAccess(pSlug) : null;
39
- if (!users.canAccessSession(paletteUser.id, session, sAccess)) return;
40
- }
41
- } else {
42
- if (session.ownerId) return;
34
+ var sAccess = onGetProjectAccess ? onGetProjectAccess(pSlug) : null;
35
+ if (!users.canAccessSession(paletteUser.id, session, sAccess)) return;
43
36
  }
44
37
  var pItem = {
45
38
  projectSlug: pSlug,
@@ -70,12 +63,8 @@ function attachPalette(ctx) {
70
63
  pCtx.sm.sessions.forEach(function (session) {
71
64
  if (session.hidden) return;
72
65
  if (paletteUser) {
73
- if (users.isMultiUser()) {
74
- var sAccess = onGetProjectAccess ? onGetProjectAccess(pSlug) : null;
75
- if (!users.canAccessSession(paletteUser.id, session, sAccess)) return;
76
- }
77
- } else {
78
- if (session.ownerId) return;
66
+ var sAccess = onGetProjectAccess ? onGetProjectAccess(pSlug) : null;
67
+ if (!users.canAccessSession(paletteUser.id, session, sAccess)) return;
79
68
  }
80
69
  accessibleSessions.push(session);
81
70
  });