@myrialabs/clopen 0.4.47 → 0.4.48

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 (325) hide show
  1. package/README.md +11 -11
  2. package/backend/artifacts/project/sources.ts +1 -1
  3. package/backend/auth/auth-service.ts +52 -358
  4. package/backend/auth/onboarding.test.ts +2 -3
  5. package/backend/auth/permissions.test.ts +10 -20
  6. package/backend/auth/permissions.ts +4 -290
  7. package/backend/auth/rate-limiter.test.ts +8 -9
  8. package/backend/auth/rate-limiter.ts +0 -2
  9. package/backend/auth/tokens.ts +1 -8
  10. package/backend/bootstrap.ts +7 -0
  11. package/backend/chat/attachments.test.ts +88 -0
  12. package/backend/chat/attachments.ts +159 -0
  13. package/backend/chat/engine-handoff.test.ts +0 -2
  14. package/backend/chat/stream-manager.ts +62 -62
  15. package/backend/chat/turn-answer.test.ts +64 -0
  16. package/backend/chat/turn-answer.ts +125 -0
  17. package/backend/chat-apps/awaiting.test.ts +39 -0
  18. package/backend/chat-apps/awaiting.ts +49 -0
  19. package/backend/chat-apps/conversation.ts +746 -0
  20. package/backend/chat-apps/inbound.ts +324 -0
  21. package/backend/chat-apps/index.ts +309 -0
  22. package/backend/chat-apps/link-events.ts +20 -0
  23. package/backend/chat-apps/media.test.ts +62 -0
  24. package/backend/chat-apps/media.ts +208 -0
  25. package/backend/chat-apps/messages.test.ts +229 -0
  26. package/backend/chat-apps/messages.ts +365 -0
  27. package/backend/chat-apps/outbound.ts +243 -0
  28. package/backend/chat-apps/pairing.test.ts +45 -0
  29. package/backend/chat-apps/pairing.ts +74 -0
  30. package/backend/chat-apps/platforms/index.ts +20 -0
  31. package/backend/chat-apps/platforms/telegram.test.ts +35 -0
  32. package/backend/chat-apps/platforms/telegram.ts +191 -0
  33. package/backend/chat-apps/platforms/types.ts +114 -0
  34. package/backend/chat-apps/questions.ts +133 -0
  35. package/backend/chat-apps/runtime.ts +572 -0
  36. package/backend/chat-apps/storage.test.ts +201 -0
  37. package/backend/chat-apps/turns.test.ts +45 -0
  38. package/backend/chat-apps/turns.ts +208 -0
  39. package/backend/containers/pty.ts +3 -11
  40. package/backend/control/actions/accounts.ts +89 -0
  41. package/backend/control/actions/files.ts +116 -0
  42. package/backend/control/actions/models.ts +188 -0
  43. package/backend/control/actions/projects.ts +272 -0
  44. package/backend/control/actions/sessions.ts +280 -0
  45. package/backend/control/actions/skills.ts +111 -0
  46. package/backend/control/control.test.ts +169 -0
  47. package/backend/control/define.ts +20 -0
  48. package/backend/control/folders.test.ts +67 -0
  49. package/backend/control/index.ts +213 -0
  50. package/backend/control/invoke.ts +44 -0
  51. package/backend/control/links.ts +35 -0
  52. package/backend/control/paging.ts +26 -0
  53. package/backend/control/types.ts +117 -0
  54. package/backend/control/workspace.ts +127 -0
  55. package/backend/database/migrations/084_create_channel_links.ts +71 -0
  56. package/backend/database/migrations/085_add_home_projects.ts +36 -0
  57. package/backend/database/migrations/086_single_owner.test.ts +170 -0
  58. package/backend/database/migrations/086_single_owner.ts +418 -0
  59. package/backend/database/migrations/index.ts +21 -0
  60. package/backend/database/queries/auth-queries.ts +7 -85
  61. package/backend/database/queries/channel-queries.ts +270 -0
  62. package/backend/database/queries/db-client-connection-queries.ts +18 -56
  63. package/backend/database/queries/file-share-queries.ts +5 -23
  64. package/backend/database/queries/git-identity-queries.ts +31 -42
  65. package/backend/database/queries/graph-queries.ts +1 -1
  66. package/backend/database/queries/index.ts +13 -1
  67. package/backend/database/queries/message-queries.test.ts +146 -0
  68. package/backend/database/queries/message-queries.ts +42 -1
  69. package/backend/database/queries/permission-set-queries.ts +1 -1
  70. package/backend/database/queries/profile-queries.ts +1 -1
  71. package/backend/database/queries/project-mcp-trust-queries.ts +1 -1
  72. package/backend/database/queries/project-queries.ts +50 -63
  73. package/backend/database/queries/session-queries.ts +28 -56
  74. package/backend/database/queries/ssh-connection-queries.ts +18 -41
  75. package/backend/db-client/integrations/projector.ts +0 -5
  76. package/backend/engine/adapters/claude/message-converter.test.ts +47 -0
  77. package/backend/engine/adapters/claude/message-converter.ts +25 -2
  78. package/backend/engine/adapters/cline/message-converter.ts +0 -1
  79. package/backend/engine/adapters/cline/stream.ts +11 -15
  80. package/backend/engine/adapters/codex/message-converter.ts +0 -2
  81. package/backend/engine/adapters/copilot/message-converter.ts +1 -2
  82. package/backend/engine/adapters/cursor/message-converter.ts +0 -1
  83. package/backend/engine/adapters/opencode/message-converter.ts +2 -4
  84. package/backend/engine/adapters/opencode/stream.ts +11 -0
  85. package/backend/engine/adapters/parent-scope.test.ts +38 -0
  86. package/backend/engine/adapters/parent-scope.ts +44 -0
  87. package/backend/engine/adapters/pi/message-converter.ts +0 -1
  88. package/backend/engine/adapters/pi/stream.ts +4 -5
  89. package/backend/engine/adapters/qwen/message-converter.ts +0 -2
  90. package/backend/engine/bootstrap-default-engine.ts +2 -2
  91. package/backend/engine/docs/adapter-contract.md +8 -1
  92. package/backend/engine/install-runner.ts +8 -17
  93. package/backend/files/file-shares.ts +20 -44
  94. package/backend/files/file-size-limit.ts +3 -3
  95. package/backend/files/image-processing.ts +1 -1
  96. package/backend/files/os-clipboard.ts +2 -2
  97. package/backend/git/git-executor.ts +25 -5
  98. package/backend/git/git-service.ts +420 -19
  99. package/backend/git/identity/credential-helper.test.ts +2 -7
  100. package/backend/git/identity/import-local.test.ts +11 -16
  101. package/backend/git/identity/import-local.ts +12 -12
  102. package/backend/git/identity/index.ts +10 -24
  103. package/backend/git/identity/resolve.ts +13 -14
  104. package/backend/git/identity/scope-config.ts +33 -28
  105. package/backend/git/identity/service.ts +44 -47
  106. package/backend/git/op-lock.test.ts +111 -0
  107. package/backend/git/op-lock.ts +180 -0
  108. package/backend/git/remote-sync.test.ts +249 -0
  109. package/backend/host/metrics.ts +1 -1
  110. package/backend/http/bearer-auth.ts +1 -2
  111. package/backend/http/files-download.test.ts +8 -9
  112. package/backend/http/files-download.ts +2 -2
  113. package/backend/http/files-shared.test.ts +62 -89
  114. package/backend/http/files-shared.ts +2 -2
  115. package/backend/http/files-upload.test.ts +3 -7
  116. package/backend/http/files-upload.ts +3 -3
  117. package/backend/http/notes-images.test.ts +15 -38
  118. package/backend/http/notes-images.ts +6 -8
  119. package/backend/http/ssh-sftp.ts +5 -10
  120. package/backend/index.ts +21 -7
  121. package/backend/integrations/accounts.ts +61 -3
  122. package/backend/integrations/index.ts +2 -2
  123. package/backend/integrations/registry/define.ts +15 -0
  124. package/backend/integrations/registry/index.ts +2 -0
  125. package/backend/integrations/registry/providers/telegram.ts +54 -0
  126. package/backend/integrations/registry/types.ts +21 -1
  127. package/backend/integrations/webhooks/gateway.ts +7 -6
  128. package/backend/integrations/webhooks/verify.test.ts +30 -0
  129. package/backend/integrations/webhooks/verify.ts +4 -0
  130. package/backend/mcp/external/project.ts +1 -1
  131. package/backend/mcp/internal/remote-server.test.ts +1 -3
  132. package/backend/mcp/internal/remote-server.ts +4 -4
  133. package/backend/mcp/internal/servers/browser-automation/actions/dialogs.ts +67 -0
  134. package/backend/mcp/internal/servers/browser-automation/actions/index.ts +3 -1
  135. package/backend/mcp/internal/servers/browser-automation/actions/input.ts +5 -5
  136. package/backend/mcp/internal/servers/browser-automation/actions/tabs.ts +157 -28
  137. package/backend/mcp/internal/servers/browser-automation/context.ts +1 -0
  138. package/backend/mcp/internal/servers/browser-automation/description.ts +5 -2
  139. package/backend/mcp/internal/servers/browser-automation/format.ts +24 -1
  140. package/backend/mcp/internal/servers/browser-automation/runner.ts +68 -3
  141. package/backend/memory/redact.ts +1 -1
  142. package/backend/notes/access.test.ts +28 -29
  143. package/backend/notes/access.ts +6 -11
  144. package/backend/permissions/service.ts +1 -1
  145. package/backend/preview/browser/browser-clipboard.test.ts +46 -0
  146. package/backend/preview/browser/browser-clipboard.ts +67 -0
  147. package/backend/preview/browser/browser-dialog-handler.ts +95 -6
  148. package/backend/preview/browser/browser-host-bridge.ts +9 -0
  149. package/backend/preview/browser/browser-interaction-handler.ts +316 -86
  150. package/backend/preview/browser/browser-mcp-control.ts +34 -0
  151. package/backend/preview/browser/browser-pool.ts +67 -6
  152. package/backend/preview/browser/browser-preview-service.ts +361 -25
  153. package/backend/preview/browser/browser-tab-manager.ts +66 -23
  154. package/backend/preview/browser/browser-video-capture.ts +92 -5
  155. package/backend/preview/browser/element-locator.ts +190 -17
  156. package/backend/preview/browser/keyboard-chords.test.ts +68 -0
  157. package/backend/preview/browser/keyboard-chords.ts +132 -0
  158. package/backend/preview/browser/paste.ts +81 -0
  159. package/backend/preview/browser/process-usage.ts +142 -0
  160. package/backend/preview/browser/profile-lock.ts +209 -0
  161. package/backend/preview/browser/scripts/host-bridge.ts +59 -0
  162. package/backend/preview/browser/scripts/video-stream.ts +58 -0
  163. package/backend/preview/browser/types.ts +40 -2
  164. package/backend/preview/browser/viewport.test.ts +45 -0
  165. package/backend/preview/browser/viewport.ts +96 -0
  166. package/backend/profiles/service.ts +2 -2
  167. package/backend/project/status-manager.ts +43 -172
  168. package/backend/projects/home.ts +61 -0
  169. package/backend/projects/project-cleanup.integration.test.ts +2 -2
  170. package/backend/projects/project-cleanup.ts +0 -8
  171. package/backend/skills/service.ts +2 -3
  172. package/backend/snapshot/helpers.ts +0 -1
  173. package/backend/snapshot/restore.ts +252 -0
  174. package/backend/ssh/ptykit.ts +1 -2
  175. package/backend/terminal/ptykit.ts +5 -8
  176. package/backend/tunnel/public-origin.ts +31 -20
  177. package/backend/utils/user-helpers.ts +0 -55
  178. package/backend/utils/ws.ts +61 -154
  179. package/backend/worktrees/branching/engine.ts +3 -16
  180. package/backend/worktrees/branching/index.ts +1 -1
  181. package/backend/worktrees/branching/projector.ts +1 -1
  182. package/backend/worktrees/branching/service.ts +13 -25
  183. package/backend/ws/access.ts +12 -21
  184. package/backend/ws/artifacts/generate.ts +2 -2
  185. package/backend/ws/auth/device.ts +16 -71
  186. package/backend/ws/auth/index.ts +4 -22
  187. package/backend/ws/auth/login.test.ts +14 -60
  188. package/backend/ws/auth/login.ts +24 -124
  189. package/backend/ws/auth/status.ts +0 -1
  190. package/backend/ws/chat/composer.ts +118 -118
  191. package/backend/ws/chat/stream.ts +64 -47
  192. package/backend/ws/chat-apps/index.ts +117 -0
  193. package/backend/ws/containers/actions.ts +11 -25
  194. package/backend/ws/containers/index.ts +3 -4
  195. package/backend/ws/containers/list.ts +10 -36
  196. package/backend/ws/containers/logs.ts +2 -2
  197. package/backend/ws/containers/tunnel.ts +1 -2
  198. package/backend/ws/db-client/access.ts +2 -16
  199. package/backend/ws/db-client/accounts.ts +5 -15
  200. package/backend/ws/db-client/connections.ts +17 -25
  201. package/backend/ws/db-client/context.ts +1 -1
  202. package/backend/ws/db-client/env.ts +7 -10
  203. package/backend/ws/db-client/index.ts +2 -2
  204. package/backend/ws/db-client/io.ts +5 -5
  205. package/backend/ws/db-client/query-history-retention.test.ts +8 -8
  206. package/backend/ws/db-client/query.ts +18 -17
  207. package/backend/ws/db-client/schema.ts +13 -13
  208. package/backend/ws/db-client/structure.ts +35 -35
  209. package/backend/ws/db-client/supabase.ts +4 -21
  210. package/backend/ws/deployments/context.ts +1 -1
  211. package/backend/ws/deployments/crud.ts +0 -5
  212. package/backend/ws/engine/access.ts +7 -20
  213. package/backend/ws/engine/claude/accounts.ts +4 -4
  214. package/backend/ws/engine/cline/accounts.ts +5 -5
  215. package/backend/ws/engine/codex/accounts.ts +3 -3
  216. package/backend/ws/engine/pi/accounts.ts +5 -5
  217. package/backend/ws/files/clipboard.ts +8 -27
  218. package/backend/ws/files/image-edit.ts +6 -6
  219. package/backend/ws/files/index.ts +1 -1
  220. package/backend/ws/files/path-access.test.ts +32 -131
  221. package/backend/ws/files/path-access.ts +8 -87
  222. package/backend/ws/files/read.ts +15 -19
  223. package/backend/ws/files/reveal.ts +3 -3
  224. package/backend/ws/files/search.ts +7 -7
  225. package/backend/ws/files/share.ts +9 -13
  226. package/backend/ws/files/state.ts +9 -12
  227. package/backend/ws/files/watch.ts +3 -3
  228. package/backend/ws/files/write.ts +30 -31
  229. package/backend/ws/git/branch.ts +80 -59
  230. package/backend/ws/git/commit.ts +63 -44
  231. package/backend/ws/git/conflict.ts +16 -18
  232. package/backend/ws/git/identity-context.ts +8 -17
  233. package/backend/ws/git/identity.ts +17 -27
  234. package/backend/ws/git/index.ts +3 -1
  235. package/backend/ws/git/op-state.ts +139 -0
  236. package/backend/ws/git/remote.ts +241 -141
  237. package/backend/ws/git/repo-context.ts +67 -0
  238. package/backend/ws/git/staging.ts +18 -28
  239. package/backend/ws/git/status.ts +5 -2
  240. package/backend/ws/index.ts +5 -1
  241. package/backend/ws/instructions/crud.ts +1 -1
  242. package/backend/ws/integrations/crud.ts +1 -3
  243. package/backend/ws/mcp/crud.ts +3 -5
  244. package/backend/ws/mcp/tools.ts +1 -1
  245. package/backend/ws/memory/crud.ts +14 -46
  246. package/backend/ws/memory/index.ts +2 -2
  247. package/backend/ws/messages/crud.ts +29 -8
  248. package/backend/ws/notes/index.ts +33 -39
  249. package/backend/ws/permissions/crud.ts +3 -4
  250. package/backend/ws/ports/index.ts +1 -2
  251. package/backend/ws/ports/kill.ts +5 -10
  252. package/backend/ws/ports/list.ts +4 -10
  253. package/backend/ws/preview/access.ts +1 -1
  254. package/backend/ws/preview/browser/interact.ts +52 -79
  255. package/backend/ws/preview/browser/native-ui.ts +24 -0
  256. package/backend/ws/preview/browser/stats.ts +98 -1
  257. package/backend/ws/preview/browser/tab-info.ts +15 -0
  258. package/backend/ws/preview/browser/tab.ts +19 -4
  259. package/backend/ws/preview/index.ts +27 -0
  260. package/backend/ws/profiles/crud.ts +6 -8
  261. package/backend/ws/project-artifacts/index.ts +30 -31
  262. package/backend/ws/projects/crud.ts +33 -35
  263. package/backend/ws/projects/index.ts +3 -8
  264. package/backend/ws/projects/info.ts +3 -3
  265. package/backend/ws/projects/overview.ts +19 -30
  266. package/backend/ws/projects/status.ts +17 -57
  267. package/backend/ws/sessions/crud.ts +34 -45
  268. package/backend/ws/sessions/index.ts +1 -1
  269. package/backend/ws/settings/crud.ts +1 -1
  270. package/backend/ws/skills/crud.ts +3 -4
  271. package/backend/ws/skills/index.ts +1 -1
  272. package/backend/ws/snapshot/changes.ts +7 -7
  273. package/backend/ws/snapshot/restore.ts +11 -295
  274. package/backend/ws/snapshot/timeline.ts +2 -4
  275. package/backend/ws/ssh/access.ts +6 -21
  276. package/backend/ws/ssh/connections.ts +21 -31
  277. package/backend/ws/ssh/forwards.ts +12 -12
  278. package/backend/ws/ssh/sftp.ts +34 -34
  279. package/backend/ws/ssh/tunnel.ts +1 -2
  280. package/backend/ws/stack/install.ts +7 -17
  281. package/backend/ws/subagents/crud.ts +1 -1
  282. package/backend/ws/tunnel/share.ts +0 -2
  283. package/backend/ws/user/crud.ts +1 -59
  284. package/backend/ws/user/index.ts +1 -1
  285. package/backend/ws/work/context.ts +1 -1
  286. package/backend/ws/work/crud.ts +0 -5
  287. package/backend/ws/workspace/state.ts +10 -13
  288. package/backend/ws/worktrees/branching.ts +7 -36
  289. package/backend/ws/worktrees/crud.ts +2 -2
  290. package/bin/clopen.ts +10 -11
  291. package/dist/assets/{index-CwuKQelV.js → index-CONlwAXZ.js} +1 -1
  292. package/dist/assets/{index-BTcR1byF.js → index-DJzwt-hq.js} +1 -1
  293. package/dist/assets/main-BUiUL3eZ.css +1 -0
  294. package/dist/assets/main-nBOb9YOA.js +1240 -0
  295. package/dist/index.html +2 -2
  296. package/package.json +2 -1
  297. package/shared/constants/attachments.ts +14 -0
  298. package/shared/constants/engine-tools.ts +1 -1
  299. package/shared/constants/preview.test.ts +259 -0
  300. package/shared/constants/preview.ts +1018 -57
  301. package/shared/constants/tool-icons.ts +5 -0
  302. package/shared/types/containers/container.ts +1 -1
  303. package/shared/types/database/schema.ts +9 -6
  304. package/shared/types/git-identity.ts +1 -1
  305. package/shared/types/git.ts +116 -0
  306. package/shared/types/integrations.ts +7 -0
  307. package/shared/types/stores/settings.ts +1 -1
  308. package/shared/types/unified/index.ts +1 -1
  309. package/shared/types/unified/message.ts +0 -7
  310. package/shared/types/unified/stream.ts +2 -4
  311. package/shared/types/unified/tool.ts +15 -1
  312. package/shared/utils/ask-user-question.test.ts +319 -0
  313. package/shared/utils/ask-user-question.ts +154 -0
  314. package/shared/utils/home-project.ts +25 -0
  315. package/shared/utils/logger.ts +2 -0
  316. package/shared/utils/ws-server.ts +32 -7
  317. package/backend/auth/session-invalidation.test.ts +0 -112
  318. package/backend/auth/session-invalidation.ts +0 -77
  319. package/backend/project/status-manager.test.ts +0 -32
  320. package/backend/ws/auth/invites.ts +0 -94
  321. package/backend/ws/auth/users.ts +0 -112
  322. package/backend/ws/projects/presence.ts +0 -46
  323. package/backend/ws/stack/access.ts +0 -31
  324. package/dist/assets/main-BiDNMWb3.css +0 -1
  325. package/dist/assets/main-BlhKWz2B.js +0 -1241
@@ -23,97 +23,46 @@ async function canCreateSymlinks(): Promise<boolean> {
23
23
  }
24
24
 
25
25
  // Mock dependencies before importing the module under test
26
- const mockGetAllForUser = mock(() => [] as Array<{ id: string; path: string }>);
27
26
  const mockGetAll = mock(() => [] as Array<{ id: string; path: string }>);
28
- const mockUserHasProject = mock(() => false);
29
27
  const mockGetByPath = mock(() => null as { id: string; path: string } | null);
30
28
  const mockGetById = mock(() => null as { id: string; path: string } | null);
31
29
 
32
30
  mock.module('../../database/queries/project-queries', () => ({
33
31
  projectQueries: {
34
- getAllForUser: mockGetAllForUser,
35
32
  getAll: mockGetAll,
36
- userHasProject: mockUserHasProject,
37
33
  getByPath: mockGetByPath,
38
34
  getById: mockGetById,
39
35
  }
40
36
  }));
41
37
 
42
- // A project's accessible area now includes its worktrees, so the lookup is part
43
- // of the data layer this test models.
44
- const mockWorktreesByProject = mock(() => [] as Array<{ id: string; path: string }>);
45
38
  const mockWorktreeByPath = mock(() => null as { id: string; project_id: string; path: string } | null);
46
39
 
47
40
  mock.module('../../database/queries/worktree-queries', () => ({
48
41
  worktreeQueries: {
49
- getByProjectId: mockWorktreesByProject,
42
+ getByProjectId: mock(() => []),
50
43
  getByPath: mockWorktreeByPath,
51
44
  }
52
45
  }));
53
46
 
54
- const mockGetRole = mock((): 'admin' | 'member' => 'member');
55
- const mockGetUserId = mock(() => 'user-1');
56
-
57
- mock.module('$backend/utils/ws', () => ({
58
- ws: {
59
- getRole: mockGetRole,
60
- getUserId: mockGetUserId,
61
- }
62
- }));
63
-
64
- mock.module('../access', () => ({
65
- requireProjectAccess: mock(() => ({ id: 'proj-1', path: '' })),
66
- }));
67
-
68
47
  // Import after mocking
69
- const { requireFilePathAccess, requireSharedFilePathAccess, findContainingProjectId, resolveProjectForRoot, requireWorkspaceRootAccess } = await import('./path-access');
48
+ const { resolveFilePath, findContainingProjectId, resolveProjectForRoot, requireWorkspaceRoot } = await import('./path-access');
70
49
 
71
50
  let testDir: string;
72
51
 
73
- describe('path-access symlink resolution', () => {
52
+ describe('workspace roots', () => {
74
53
  beforeEach(async () => {
75
54
  const rawTestDir = join(tmpdir(), `clopen-path-access-test-${randomUUID()}`);
76
55
  await mkdir(rawTestDir, { recursive: true });
77
56
  // Canonicalize so test expectations match what resolveRealPath returns.
78
57
  // macOS tmpdir lives under /var → /private/var, which realpath follows.
79
58
  testDir = await realpath(rawTestDir);
80
- mockGetRole.mockImplementation(() => 'member');
81
- mockGetUserId.mockImplementation(() => 'user-1');
82
59
  });
83
60
 
84
61
  afterEach(async () => {
85
62
  await rm(testDir, { recursive: true, force: true });
86
- mockWorktreesByProject.mockReturnValue([]);
87
63
  mockWorktreeByPath.mockReturnValue(null);
88
64
  });
89
65
 
90
- test('allows a path inside a worktree of an accessible project', async () => {
91
- const projectPath = join(testDir, 'project');
92
- const worktreePath = join(testDir, 'worktrees', 'feature');
93
- await mkdir(projectPath, { recursive: true });
94
- await mkdir(worktreePath, { recursive: true });
95
- await writeFile(join(worktreePath, 'index.ts'), 'export {};');
96
-
97
- mockGetAllForUser.mockReturnValue([{ id: 'proj-1', path: projectPath }]);
98
- mockWorktreesByProject.mockReturnValue([{ id: 'wt-1', path: worktreePath }]);
99
-
100
- const target = join(worktreePath, 'index.ts');
101
- await expect(requireFilePathAccess({} as any, target)).resolves.toBe(target);
102
- });
103
-
104
- test('still denies a worktree of a project the user cannot access', async () => {
105
- const worktreePath = join(testDir, 'worktrees', 'other');
106
- await mkdir(worktreePath, { recursive: true });
107
- await writeFile(join(worktreePath, 'secret.txt'), 'nope');
108
-
109
- mockGetAllForUser.mockReturnValue([]);
110
- mockWorktreesByProject.mockReturnValue([{ id: 'wt-1', path: worktreePath }]);
111
-
112
- await expect(
113
- requireFilePathAccess({} as any, join(worktreePath, 'secret.txt'))
114
- ).rejects.toThrow('Access denied');
115
- });
116
-
117
66
  test('resolves a worktree root back to its owning project', async () => {
118
67
  const worktreePath = join(testDir, 'worktrees', 'feature');
119
68
  mockGetByPath.mockReturnValue(null);
@@ -133,9 +82,8 @@ describe('path-access symlink resolution', () => {
133
82
  mockGetByPath.mockReturnValue(null);
134
83
  mockWorktreeByPath.mockReturnValue({ id: 'wt-1', project_id: 'proj-1', path: worktreePath });
135
84
  mockGetById.mockReturnValue({ id: 'proj-1', path: projectPath });
136
- mockGetRole.mockImplementation(() => 'admin');
137
85
 
138
- const resolved = requireWorkspaceRootAccess({} as any, worktreePath);
86
+ const resolved = requireWorkspaceRoot(worktreePath);
139
87
  expect(resolved.root).toBe(worktreePath);
140
88
  expect(resolved.worktreeId).toBe('wt-1');
141
89
  expect(resolved.project.id).toBe('proj-1');
@@ -146,9 +94,8 @@ describe('path-access symlink resolution', () => {
146
94
 
147
95
  mockWorktreeByPath.mockReturnValue(null);
148
96
  mockGetByPath.mockReturnValue({ id: 'proj-1', path: projectPath });
149
- mockGetRole.mockImplementation(() => 'admin');
150
97
 
151
- const resolved = requireWorkspaceRootAccess({} as any, projectPath);
98
+ const resolved = requireWorkspaceRoot(projectPath);
152
99
  expect(resolved.root).toBe(projectPath);
153
100
  expect(resolved.worktreeId).toBeNull();
154
101
  });
@@ -156,104 +103,58 @@ describe('path-access symlink resolution', () => {
156
103
  test('denies an unknown root', async () => {
157
104
  mockWorktreeByPath.mockReturnValue(null);
158
105
  mockGetByPath.mockReturnValue(null);
159
- mockGetRole.mockImplementation(() => 'admin');
160
106
 
161
- expect(() => requireWorkspaceRootAccess({} as any, join(testDir, 'nowhere'))).toThrow(
162
- 'Access denied'
163
- );
107
+ expect(() => requireWorkspaceRoot(join(testDir, 'nowhere'))).toThrow('Access denied');
164
108
  });
109
+ });
165
110
 
166
- test('blocks read through symlink to external directory', async () => {
111
+ describe('resolveFilePath', () => {
112
+ beforeEach(async () => {
113
+ const rawTestDir = join(tmpdir(), `clopen-resolve-path-test-${randomUUID()}`);
114
+ await mkdir(rawTestDir, { recursive: true });
115
+ testDir = await realpath(rawTestDir);
116
+ });
117
+
118
+ afterEach(async () => {
119
+ await rm(testDir, { recursive: true, force: true });
120
+ });
121
+
122
+ test('follows a symlink to its real location', async () => {
167
123
  if (!(await canCreateSymlinks())) {
168
124
  console.log('SKIP: symlink creation requires admin on this platform');
169
125
  return;
170
126
  }
171
- // Setup: project at testDir/project, symlink pointing to testDir/external
172
127
  const projectPath = join(testDir, 'project');
173
128
  const externalPath = join(testDir, 'external');
174
- const symlinkPath = join(projectPath, 'escape');
175
-
176
129
  await mkdir(projectPath, { recursive: true });
177
130
  await mkdir(externalPath, { recursive: true });
178
- await writeFile(join(externalPath, 'secret.txt'), 'confidential');
179
- await symlink(externalPath, symlinkPath, 'dir');
131
+ await writeFile(join(externalPath, 'notes.txt'), 'content');
132
+ await symlink(externalPath, join(projectPath, 'linked'), 'dir');
180
133
 
181
- mockGetAllForUser.mockReturnValue([{ id: 'proj-1', path: projectPath }]);
182
-
183
- // Attempt to access file through symlink
184
- const targetPath = join(symlinkPath, 'secret.txt');
185
- await expect(requireFilePathAccess({} as any, targetPath)).rejects.toThrow('Access denied');
134
+ const result = await resolveFilePath(join(projectPath, 'linked', 'notes.txt'));
135
+ expect(result).toBe(join(externalPath, 'notes.txt'));
186
136
  });
187
137
 
188
- test('blocks write through symlink to external directory for non-existing leaf', async () => {
138
+ test('follows a symlinked parent for a leaf that does not exist yet', async () => {
189
139
  if (!(await canCreateSymlinks())) {
190
140
  console.log('SKIP: symlink creation requires admin on this platform');
191
141
  return;
192
142
  }
193
- // Setup: project at testDir/project, symlink pointing to testDir/external
143
+ // realpath throws for a missing leaf; the symlinked parent must still be
144
+ // resolved so a write lands where it really will.
194
145
  const projectPath = join(testDir, 'project');
195
146
  const externalPath = join(testDir, 'external');
196
- const symlinkPath = join(projectPath, 'escape');
197
-
198
147
  await mkdir(projectPath, { recursive: true });
199
148
  await mkdir(externalPath, { recursive: true });
200
- await symlink(externalPath, symlinkPath, 'dir');
149
+ await symlink(externalPath, join(projectPath, 'linked'), 'dir');
201
150
 
202
- mockGetAllForUser.mockReturnValue([{ id: 'proj-1', path: projectPath }]);
203
-
204
- // Attempt to write to a non-existing file through symlink
205
- // This is the key regression: realpath throws for non-existing paths,
206
- // but resolveRealPath should still resolve the symlinked parent
207
- const targetPath = join(symlinkPath, 'new-file.txt');
208
- await expect(requireFilePathAccess({} as any, targetPath)).rejects.toThrow('Access denied');
151
+ const result = await resolveFilePath(join(projectPath, 'linked', 'new-file.txt'));
152
+ expect(result).toBe(join(externalPath, 'new-file.txt'));
209
153
  });
210
154
 
211
- test('blocks rename of ancestor path containing another user project', async () => {
212
- // Setup: user-1 tries to rename /parent, but user-2 has project at /parent/child
213
- const parentPath = join(testDir, 'parent');
214
- const childProjectPath = join(parentPath, 'child-project');
215
-
216
- await mkdir(childProjectPath, { recursive: true });
217
-
218
- mockGetAll.mockReturnValue([{ id: 'proj-2', path: childProjectPath }]);
219
- mockUserHasProject.mockReturnValue(false);
220
-
221
- // user-1 attempts to rename the parent directory
222
- await expect(requireSharedFilePathAccess({} as any, parentPath)).rejects.toThrow('Access denied');
223
- });
224
-
225
- test('allows access to files inside user own project', async () => {
226
- const projectPath = join(testDir, 'project');
227
- const filePath = join(projectPath, 'file.txt');
228
-
229
- await mkdir(projectPath, { recursive: true });
230
- await writeFile(filePath, 'content');
231
-
232
- mockGetAllForUser.mockReturnValue([{ id: 'proj-1', path: projectPath }]);
233
-
234
- const result = await requireFilePathAccess({} as any, filePath);
235
- expect(result).toBe(filePath);
236
- });
237
-
238
- test('allows creating new files inside user own project', async () => {
239
- const projectPath = join(testDir, 'project');
240
- const newFilePath = join(projectPath, 'new-file.txt');
241
-
242
- await mkdir(projectPath, { recursive: true });
243
-
244
- mockGetAllForUser.mockReturnValue([{ id: 'proj-1', path: projectPath }]);
245
-
246
- // new-file.txt doesn't exist yet, but should still be allowed
247
- const result = await requireFilePathAccess({} as any, newFilePath);
248
- expect(result).toBe(newFilePath);
249
- });
250
-
251
- test('admin bypasses all checks', async () => {
252
- mockGetRole.mockImplementation(() => 'admin');
253
-
254
- const anyPath = join(testDir, 'any', 'path', 'file.txt');
255
- const result = await requireFilePathAccess({} as any, anyPath);
256
- expect(result).toBe(anyPath);
155
+ test('returns a plain path unchanged', async () => {
156
+ const filePath = join(testDir, 'any', 'path', 'file.txt');
157
+ expect(await resolveFilePath(filePath)).toBe(filePath);
257
158
  });
258
159
  });
259
160
 
@@ -3,10 +3,7 @@ import { realpath } from 'node:fs/promises';
3
3
 
4
4
  import { projectQueries } from '../../database/queries/project-queries';
5
5
  import { worktreeQueries } from '../../database/queries/worktree-queries';
6
- import { ws } from '$backend/utils/ws';
7
- import type { WSConnection } from '$shared/utils/ws-server';
8
6
  import type { Project } from '$shared/types/database/schema';
9
- import { requireProjectAccess } from '../access';
10
7
 
11
8
  /**
12
9
  * Resolve a path to its real (canonical) location, following symlinks.
@@ -63,13 +60,13 @@ export interface WorkspaceRoot {
63
60
  }
64
61
 
65
62
  /**
66
- * Grant access to a workspace root and hand back the root that was requested.
63
+ * Resolve a workspace root and hand back the root that was requested.
67
64
  *
68
65
  * Returning the root rather than only the project is the point: callers used to
69
66
  * validate a path and then operate on `project.path`, which was identical until
70
67
  * worktrees existed and silently became "list the main tree" afterwards.
71
68
  */
72
- export function requireWorkspaceRootAccess(conn: WSConnection, rootPath: string): WorkspaceRoot {
69
+ export function requireWorkspaceRoot(rootPath: string): WorkspaceRoot {
73
70
  const worktree = worktreeQueries.getByPath(rootPath);
74
71
  const project = worktree
75
72
  ? projectQueries.getById(worktree.project_id)
@@ -78,9 +75,6 @@ export function requireWorkspaceRootAccess(conn: WSConnection, rootPath: string)
78
75
  if (!project) {
79
76
  throw new Error('Access denied');
80
77
  }
81
- if (ws.getRole(conn) !== 'admin') {
82
- requireProjectAccess(conn, project.id);
83
- }
84
78
 
85
79
  return {
86
80
  project,
@@ -89,46 +83,19 @@ export function requireWorkspaceRootAccess(conn: WSConnection, rootPath: string)
89
83
  };
90
84
  }
91
85
 
92
- export async function requireFilePathAccess(conn: WSConnection, filePath: string): Promise<string> {
93
- return await requireFilePathAccessFor(filePath, ws.getRole(conn), ws.getUserId(conn));
94
- }
95
-
96
86
  /**
97
- * Identity-based variant of {@link requireFilePathAccess} — usable from HTTP
98
- * routes (which have no `WSConnection`) once the caller has resolved the user
99
- * from a bearer token. Same access policy as the WS version.
87
+ * The canonical location of a path the owner named. Clopen controls the whole
88
+ * machine it runs on, so there is nothing to refuse — but every file operation
89
+ * still runs against the real path, never a symlink alias of it.
100
90
  */
101
- export async function requireFilePathAccessFor(filePath: string, role: string | null, userId: string | null): Promise<string> {
102
- const normalizedPath = await resolveRealPath(filePath);
103
- if (role === 'admin') {
104
- return normalizedPath;
105
- }
106
- if (!userId) {
107
- throw new Error('Access denied');
108
- }
109
-
110
- // A project's accessible area is its own tree plus every worktree cloned
111
- // from it — both are workspaces the user is already entitled to.
112
- const projects = projectQueries.getAllForUser(userId);
113
- for (const project of projects) {
114
- if (await isPathInside(project.path, normalizedPath)) {
115
- return normalizedPath;
116
- }
117
- for (const worktree of worktreeQueries.getByProjectId(project.id)) {
118
- if (await isPathInside(worktree.path, normalizedPath)) {
119
- return normalizedPath;
120
- }
121
- }
122
- }
123
-
124
- throw new Error('Access denied');
91
+ export async function resolveFilePath(filePath: string): Promise<string> {
92
+ return await resolveRealPath(filePath);
125
93
  }
126
94
 
127
95
  /**
128
96
  * Best-effort resolution of the project that contains a path, for audit
129
97
  * logging. Returns the most specific (longest-root) containing project's id,
130
- * or null when the path lives outside every registered project. Makes no
131
- * access decision — callers enforce access separately.
98
+ * or null when the path lives outside every registered project.
132
99
  */
133
100
  export async function findContainingProjectId(filePath: string): Promise<string | null> {
134
101
  const normalizedPath = await resolveRealPath(filePath);
@@ -145,52 +112,6 @@ export async function findContainingProjectId(filePath: string): Promise<string
145
112
  return containing?.id ?? null;
146
113
  }
147
114
 
148
- // Picker-style guard: allow paths inside the user's accessible projects OR
149
- // outside every registered project. Rejects only when the path lives inside
150
- // another project the user cannot access. Used by FolderBrowser flows that
151
- // operate around / before a project exists.
152
- export async function requireSharedFilePathAccess(conn: WSConnection, filePath: string): Promise<string> {
153
- const normalizedPath = await resolveRealPath(filePath);
154
- if (ws.getRole(conn) === 'admin') {
155
- return normalizedPath;
156
- }
157
- const userId = ws.getUserId(conn);
158
- const allProjects = projectQueries.getAll();
159
-
160
- // Ancestor guard: reject if the path is a parent of another user's project.
161
- // Without this, renaming/deleting `/foo` would break a project rooted at
162
- // `/foo/bar` even though `/foo` itself is not "inside" any project.
163
- for (const project of allProjects) {
164
- const projectRoot = await resolveRealPath(project.path);
165
- if (projectRoot === normalizedPath) continue; // equality is handled below
166
- if (!(await isPathInside(normalizedPath, project.path))) continue;
167
- if (!projectQueries.userHasProject(userId, project.id)) {
168
- throw new Error('Access denied');
169
- }
170
- }
171
-
172
- // Pick the most specific (longest matching root) project so nested project
173
- // roots resolve to the inner one, not whichever the DB returns first.
174
- let containing: { id: string; path: string } | null = null;
175
- for (const project of allProjects) {
176
- if (!(await isPathInside(project.path, normalizedPath))) continue;
177
- const projectRoot = await resolveRealPath(project.path);
178
- if (!containing || projectRoot.length > resolve(containing.path).length) {
179
- containing = project;
180
- }
181
- }
182
-
183
- if (!containing) {
184
- return normalizedPath;
185
- }
186
-
187
- const hasAccess = projectQueries.userHasProject(userId, containing.id);
188
- if (!hasAccess) {
189
- throw new Error('Access denied');
190
- }
191
- return normalizedPath;
192
- }
193
-
194
115
  export async function filterAccessibleExpandedPaths(rootPath: string, expandedPaths?: Set<string>): Promise<Set<string> | undefined> {
195
116
  if (!expandedPaths) return undefined;
196
117
  const filtered = new Set<string>();
@@ -25,9 +25,8 @@ import { isAbsolute, relative } from 'node:path';
25
25
  import { requireProjectAccess } from '../access';
26
26
  import {
27
27
  filterAccessibleExpandedPaths,
28
- requireFilePathAccess,
29
- requireWorkspaceRootAccess,
30
- requireSharedFilePathAccess
28
+ resolveFilePath,
29
+ requireWorkspaceRoot
31
30
  } from './path-access';
32
31
 
33
32
  // Bun-compatible existsSync implementation
@@ -71,10 +70,10 @@ export const readHandler = createRouter()
71
70
  })
72
71
  ])
73
72
  )
74
- }, async ({ data, conn }) => {
73
+ }, async ({ data }) => {
75
74
  // The requested root, not the project's: for a worktree these differ, and
76
75
  // listing the project would hand back the main tree's files and paths.
77
- const { root: projectPath } = requireWorkspaceRootAccess(conn, data.project_path);
76
+ const { root: projectPath } = requireWorkspaceRoot(data.project_path);
78
77
 
79
78
  if (!(await existsSync(projectPath))) {
80
79
  throw new Error('Project path does not exist');
@@ -123,18 +122,15 @@ export const readHandler = createRouter()
123
122
  ),
124
123
  error: t.Optional(t.String())
125
124
  })
126
- }, async ({ data, conn }) => {
125
+ }, async ({ data }) => {
127
126
  // FolderBrowser uses this before a project exists, so it must be able to
128
127
  // browse roots like "home", "drives", ".", and arbitrary candidate paths.
129
- // Security: enforce backend path ownership checks for real filesystem
130
- // paths so non-admin users can't enumerate directories inside projects
131
- // they are not assigned to.
132
128
  const requestedPath = data.path === 'home'
133
129
  ? (process.env.HOME || process.env.USERPROFILE || process.cwd())
134
130
  : (data.path === '.' || data.path === '' ? process.cwd() : data.path);
135
131
  const guardedPath = data.path === 'drives'
136
132
  ? 'drives'
137
- : await requireSharedFilePathAccess(conn, requestedPath);
133
+ : await resolveFilePath(requestedPath);
138
134
  const result = await handlePathBrowsing(guardedPath);
139
135
  return result;
140
136
  })
@@ -157,8 +153,8 @@ export const readHandler = createRouter()
157
153
  })
158
154
  )
159
155
  )
160
- }, async ({ data, conn }) => {
161
- const dirPath = await requireFilePathAccess(conn, data.dir_path);
156
+ }, async ({ data }) => {
157
+ const dirPath = await resolveFilePath(data.dir_path);
162
158
  const result = await listDirectoryContents(dirPath);
163
159
  return result;
164
160
  })
@@ -177,8 +173,8 @@ export const readHandler = createRouter()
177
173
  isBinary: t.Optional(t.Boolean()),
178
174
  error: t.Optional(t.String())
179
175
  })
180
- }, async ({ data, conn }) => {
181
- const filePath = await requireFilePathAccess(conn, data.file_path);
176
+ }, async ({ data }) => {
177
+ const filePath = await resolveFilePath(data.file_path);
182
178
  const result = await readFileContents(filePath);
183
179
  return result;
184
180
  })
@@ -196,12 +192,12 @@ export const readHandler = createRouter()
196
192
  content: t.Union([t.String(), t.Null()]),
197
193
  ref: t.String()
198
194
  })
199
- }, async ({ data, conn }) => {
195
+ }, async ({ data }) => {
200
196
  // A worktree is its own checkout, so the gutter diff has to resolve
201
197
  // against the tree the file is in rather than the project's.
202
198
  const { root } = data.rootPath
203
- ? requireWorkspaceRootAccess(conn, data.rootPath)
204
- : { root: requireProjectAccess(conn, data.projectId).path };
199
+ ? requireWorkspaceRoot(data.rootPath)
200
+ : { root: requireProjectAccess(data.projectId).path };
205
201
 
206
202
  const ref = data.ref || 'HEAD';
207
203
 
@@ -238,8 +234,8 @@ export const readHandler = createRouter()
238
234
  modified: t.Optional(t.String()),
239
235
  size: t.Optional(t.Number())
240
236
  })
241
- }, async ({ data, conn }) => {
242
- const path = await requireFilePathAccess(conn, data.path);
237
+ }, async ({ data }) => {
238
+ const path = await resolveFilePath(data.path);
243
239
 
244
240
  // Read file as binary
245
241
  const file = Bun.file(path);
@@ -10,7 +10,7 @@
10
10
  import { sep } from 'node:path';
11
11
  import { t } from 'elysia';
12
12
  import { createRouter } from '$shared/utils/ws-server';
13
- import { requireFilePathAccess } from './path-access';
13
+ import { resolveFilePath } from './path-access';
14
14
 
15
15
  export const revealHandler = createRouter()
16
16
 
@@ -21,8 +21,8 @@ export const revealHandler = createRouter()
21
21
  response: t.Object({
22
22
  ok: t.Boolean()
23
23
  })
24
- }, async ({ data, conn }) => {
25
- const targetPath = await requireFilePathAccess(conn, data.path);
24
+ }, async ({ data }) => {
25
+ const targetPath = await resolveFilePath(data.path);
26
26
 
27
27
  if (process.platform === 'darwin') {
28
28
  const proc = Bun.spawn(['open', '-R', targetPath], {
@@ -3,7 +3,7 @@ import { createRouter } from '$shared/utils/ws-server';
3
3
  import { debug } from '$shared/utils/logger';
4
4
  import { join, extname, basename, relative } from 'path';
5
5
  import { readdir } from 'fs/promises';
6
- import { requireWorkspaceRootAccess } from './path-access';
6
+ import { requireWorkspaceRoot } from './path-access';
7
7
  import { validateFileSize } from '../../files/file-size-limit';
8
8
 
9
9
  // Heuristic patterns that indicate potential ReDoS risk:
@@ -405,9 +405,9 @@ export const fileSearchHandler = createRouter()
405
405
  query: t.String()
406
406
  }),
407
407
  response: t.Array(FileSearchResultSchema)
408
- }, async ({ data, conn }) => {
408
+ }, async ({ data }) => {
409
409
  const { project_path, query } = data;
410
- const { root } = requireWorkspaceRootAccess(conn, project_path);
410
+ const { root } = requireWorkspaceRoot(project_path);
411
411
 
412
412
  if (!query || query.trim().length === 0) {
413
413
  return [];
@@ -436,7 +436,7 @@ export const fileSearchHandler = createRouter()
436
436
  })),
437
437
  totalMatches: t.Number()
438
438
  }))
439
- }, async ({ data, conn }) => {
439
+ }, async ({ data }) => {
440
440
  const {
441
441
  project_path,
442
442
  query,
@@ -446,7 +446,7 @@ export const fileSearchHandler = createRouter()
446
446
  include_pattern,
447
447
  exclude_pattern
448
448
  } = data;
449
- const { root } = requireWorkspaceRootAccess(conn, project_path);
449
+ const { root } = requireWorkspaceRoot(project_path);
450
450
 
451
451
  if (!query || query.trim().length === 0) {
452
452
  return [];
@@ -480,7 +480,7 @@ export const fileSearchHandler = createRouter()
480
480
  totalReplacements: t.Number(),
481
481
  totalFiles: t.Number()
482
482
  })
483
- }, async ({ data, conn }) => {
483
+ }, async ({ data }) => {
484
484
  const {
485
485
  project_path,
486
486
  search_query,
@@ -491,7 +491,7 @@ export const fileSearchHandler = createRouter()
491
491
  include_pattern,
492
492
  exclude_pattern
493
493
  } = data;
494
- const { root } = requireWorkspaceRootAccess(conn, project_path);
494
+ const { root } = requireWorkspaceRoot(project_path);
495
495
 
496
496
  if (!search_query || search_query.trim().length === 0) {
497
497
  return { results: [], totalReplacements: 0, totalFiles: 0 };
@@ -5,9 +5,9 @@
5
5
  * its one-time / deadline options. The raw token is embedded in the share
6
6
  * URL; only its hash is stored, and the row id comes back alongside it so
7
7
  * the link stays manageable afterwards.
8
- * - files:list-shares — live links: every user's for an admin, your own
9
- * otherwise. Carries no token material, so it can never rebuild a URL.
10
- * - files:revoke-share — creator (or admin) invalidates a link by row id.
8
+ * - files:list-shares — live links. Carries no token material, so it can
9
+ * never rebuild a URL.
10
+ * - files:revoke-share — invalidates a link by row id.
11
11
  * - files:shares-changed — broadcast whenever that list moves, so every open
12
12
  * management view reflects a mint, a revoke or an open without polling.
13
13
  *
@@ -33,8 +33,6 @@ const shareSummary = t.Object({
33
33
  projectName: t.Union([t.String(), t.Null()]),
34
34
  worktreeName: t.Union([t.String(), t.Null()]),
35
35
  relativePath: t.String(),
36
- createdBy: t.String(),
37
- createdByName: t.Union([t.String(), t.Null()]),
38
36
  createdAt: t.String(),
39
37
  oneTime: t.Boolean(),
40
38
  expiresAt: t.Union([t.String(), t.Null()]),
@@ -61,7 +59,7 @@ export const fileShareHandler = createRouter()
61
59
  expiresAt: t.Union([t.String(), t.Null()])
62
60
  })
63
61
  }, async ({ data, conn }) => {
64
- const result = await createFileShareLink(data.file_path, ws.getRole(conn), ws.getUserId(conn), {
62
+ const result = await createFileShareLink(data.file_path, ws.getUserId(conn), {
65
63
  oneTime: data.oneTime,
66
64
  expiresInMinutes: data.expiresInMinutes
67
65
  });
@@ -72,8 +70,8 @@ export const fileShareHandler = createRouter()
72
70
  .http('files:list-shares', {
73
71
  data: t.Object({}),
74
72
  response: t.Object({ shares: t.Array(shareSummary) })
75
- }, async ({ conn }) => {
76
- return { shares: listFileShares(ws.getRole(conn), ws.getUserId(conn)) };
73
+ }, async () => {
74
+ return { shares: listFileShares() };
77
75
  })
78
76
 
79
77
  .http('files:revoke-share', {
@@ -81,15 +79,13 @@ export const fileShareHandler = createRouter()
81
79
  shareId: t.String({ minLength: 1 })
82
80
  }),
83
81
  response: t.Object({ success: t.Boolean() })
84
- }, async ({ data, conn }) => {
85
- const success = revokeFileShareLink(data.shareId, ws.getRole(conn), ws.getUserId(conn));
82
+ }, async ({ data }) => {
83
+ const success = revokeFileShareLink(data.shareId);
86
84
  if (success) ws.emit.global('files:shares-changed', { kind: 'revoked' });
87
85
  return { success };
88
86
  })
89
87
 
90
- // Broadcast-only: the payload says nothing about whose link moved, because
91
- // every listener re-reads its own role-scoped list. A global ping cannot
92
- // leak what a user is not allowed to see.
88
+ // Broadcast-only: every listener re-reads the list.
93
89
  .emit('files:shares-changed', t.Object({
94
90
  kind: t.String()
95
91
  }));