@fuzdev/fuz_app 0.149.0 → 0.151.0

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 (650) hide show
  1. package/README.md +1 -1
  2. package/dist/actions/CLAUDE.md +327 -300
  3. package/dist/actions/action_bridge.d.ts +5 -79
  4. package/dist/actions/action_bridge.d.ts.map +1 -1
  5. package/dist/actions/action_bridge.js +4 -74
  6. package/dist/actions/action_codegen.d.ts +8 -166
  7. package/dist/actions/action_codegen.d.ts.map +1 -1
  8. package/dist/actions/action_codegen.js +19 -95
  9. package/dist/actions/action_dispatcher.d.ts +10 -0
  10. package/dist/actions/action_dispatcher.d.ts.map +1 -1
  11. package/dist/actions/action_dispatcher.js +9 -6
  12. package/dist/actions/action_event.d.ts +1 -2
  13. package/dist/actions/action_event.d.ts.map +1 -1
  14. package/dist/actions/action_event.js +7 -13
  15. package/dist/actions/action_event_helpers.d.ts +1 -40
  16. package/dist/actions/action_event_helpers.d.ts.map +1 -1
  17. package/dist/actions/action_event_helpers.js +1 -25
  18. package/dist/actions/action_event_types.d.ts +1 -1
  19. package/dist/actions/action_event_types.d.ts.map +1 -1
  20. package/dist/actions/action_rpc.d.ts +10 -215
  21. package/dist/actions/action_rpc.d.ts.map +1 -1
  22. package/dist/actions/action_rpc.js +56 -111
  23. package/dist/actions/action_spec.d.ts +2 -2
  24. package/dist/actions/action_spec.js +2 -2
  25. package/dist/actions/action_types.d.ts +229 -8
  26. package/dist/actions/action_types.d.ts.map +1 -1
  27. package/dist/actions/action_types.js +56 -5
  28. package/dist/actions/broadcast_api.d.ts +22 -17
  29. package/dist/actions/broadcast_api.d.ts.map +1 -1
  30. package/dist/actions/broadcast_api.js +16 -27
  31. package/dist/actions/cancel.d.ts +4 -13
  32. package/dist/actions/cancel.d.ts.map +1 -1
  33. package/dist/actions/cancel.js +5 -17
  34. package/dist/actions/compile_action_registry.d.ts +1 -2
  35. package/dist/actions/compile_action_registry.d.ts.map +1 -1
  36. package/dist/actions/connection_closer.d.ts +120 -50
  37. package/dist/actions/connection_closer.d.ts.map +1 -1
  38. package/dist/actions/connection_closer.js +139 -31
  39. package/dist/actions/{transports_ws_backend.d.ts → connection_registry.d.ts} +120 -132
  40. package/dist/actions/connection_registry.d.ts.map +1 -0
  41. package/dist/actions/{transports_ws_backend.js → connection_registry.js} +149 -152
  42. package/dist/actions/frontend_rpc_client.d.ts +52 -2
  43. package/dist/actions/frontend_rpc_client.d.ts.map +1 -1
  44. package/dist/actions/frontend_rpc_client.js +42 -4
  45. package/dist/actions/peer_ping.d.ts +7 -9
  46. package/dist/actions/peer_ping.d.ts.map +1 -1
  47. package/dist/actions/peer_ping.js +6 -8
  48. package/dist/actions/peer_request.d.ts +6 -5
  49. package/dist/actions/peer_request.d.ts.map +1 -1
  50. package/dist/actions/peer_request.js +6 -5
  51. package/dist/actions/perform_action.d.ts +36 -28
  52. package/dist/actions/perform_action.d.ts.map +1 -1
  53. package/dist/actions/perform_action.js +60 -31
  54. package/dist/actions/protocol.d.ts +14 -0
  55. package/dist/actions/protocol.d.ts.map +1 -1
  56. package/dist/actions/protocol.js +18 -0
  57. package/dist/actions/register_action_ws.d.ts +137 -292
  58. package/dist/actions/register_action_ws.d.ts.map +1 -1
  59. package/dist/actions/register_action_ws.js +155 -903
  60. package/dist/actions/socket.svelte.d.ts +9 -0
  61. package/dist/actions/socket.svelte.d.ts.map +1 -1
  62. package/dist/actions/socket.svelte.js +16 -5
  63. package/dist/actions/transports.d.ts +88 -34
  64. package/dist/actions/transports.d.ts.map +1 -1
  65. package/dist/actions/transports.js +76 -76
  66. package/dist/actions/transports_http.d.ts +48 -12
  67. package/dist/actions/transports_http.d.ts.map +1 -1
  68. package/dist/actions/transports_http.js +75 -44
  69. package/dist/actions/transports_ws.d.ts +29 -0
  70. package/dist/actions/transports_ws.d.ts.map +1 -1
  71. package/dist/actions/transports_ws.js +34 -8
  72. package/dist/actions/ws_endpoint_spec.d.ts +53 -76
  73. package/dist/actions/ws_endpoint_spec.d.ts.map +1 -1
  74. package/dist/actions/ws_endpoint_spec.js +27 -10
  75. package/dist/actions/ws_outbound_writer.d.ts +3 -3
  76. package/dist/actions/ws_outbound_writer.js +3 -3
  77. package/dist/actions/ws_socket_session.d.ts +321 -0
  78. package/dist/actions/ws_socket_session.d.ts.map +1 -0
  79. package/dist/actions/ws_socket_session.js +783 -0
  80. package/dist/auth/CLAUDE.md +132 -68
  81. package/dist/auth/account_action_specs.d.ts +2 -0
  82. package/dist/auth/account_action_specs.d.ts.map +1 -1
  83. package/dist/auth/account_actions.d.ts +1 -1
  84. package/dist/auth/account_actions.d.ts.map +1 -1
  85. package/dist/auth/account_actions.js +9 -3
  86. package/dist/auth/account_queries.d.ts +10 -0
  87. package/dist/auth/account_queries.d.ts.map +1 -1
  88. package/dist/auth/account_queries.js +27 -17
  89. package/dist/auth/account_routes.d.ts +2 -1
  90. package/dist/auth/account_routes.d.ts.map +1 -1
  91. package/dist/auth/account_routes.js +14 -17
  92. package/dist/auth/account_schema.d.ts +5 -5
  93. package/dist/auth/account_schema.d.ts.map +1 -1
  94. package/dist/auth/account_schema.js +5 -2
  95. package/dist/auth/actor_lookup_actions.d.ts +1 -1
  96. package/dist/auth/actor_lookup_actions.d.ts.map +1 -1
  97. package/dist/auth/actor_lookup_actions.js +1 -1
  98. package/dist/auth/actor_lookup_queries.d.ts +3 -2
  99. package/dist/auth/actor_lookup_queries.d.ts.map +1 -1
  100. package/dist/auth/actor_lookup_queries.js +6 -3
  101. package/dist/auth/actor_search_action_specs.d.ts.map +1 -1
  102. package/dist/auth/actor_search_action_specs.js +2 -1
  103. package/dist/auth/actor_search_actions.d.ts +1 -1
  104. package/dist/auth/actor_search_actions.d.ts.map +1 -1
  105. package/dist/auth/actor_search_actions.js +1 -1
  106. package/dist/auth/actor_search_queries.d.ts +10 -7
  107. package/dist/auth/actor_search_queries.d.ts.map +1 -1
  108. package/dist/auth/actor_search_queries.js +18 -11
  109. package/dist/auth/admin_action_specs.d.ts +4 -4
  110. package/dist/auth/admin_action_specs.d.ts.map +1 -1
  111. package/dist/auth/admin_action_specs.js +7 -5
  112. package/dist/auth/admin_actions.d.ts +1 -1
  113. package/dist/auth/admin_actions.d.ts.map +1 -1
  114. package/dist/auth/admin_actions.js +47 -48
  115. package/dist/auth/all_cell_actions.d.ts +14 -3
  116. package/dist/auth/all_cell_actions.d.ts.map +1 -1
  117. package/dist/auth/all_cell_actions.js +2 -1
  118. package/dist/auth/api_token_queries.d.ts +1 -0
  119. package/dist/auth/api_token_queries.d.ts.map +1 -1
  120. package/dist/auth/api_token_queries.js +1 -0
  121. package/dist/auth/audit_emitter.d.ts +12 -6
  122. package/dist/auth/audit_emitter.d.ts.map +1 -1
  123. package/dist/auth/audit_emitter.js +11 -5
  124. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  125. package/dist/auth/audit_log_route_schema.js +3 -2
  126. package/dist/auth/audit_log_routes.d.ts +20 -11
  127. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  128. package/dist/auth/audit_log_routes.js +49 -29
  129. package/dist/auth/audit_log_schema.d.ts +14 -21
  130. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  131. package/dist/auth/audit_log_schema.js +19 -23
  132. package/dist/auth/bearer_auth.d.ts +7 -4
  133. package/dist/auth/bearer_auth.d.ts.map +1 -1
  134. package/dist/auth/bearer_auth.js +21 -15
  135. package/dist/auth/bootstrap_account.d.ts +25 -1
  136. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  137. package/dist/auth/bootstrap_account.js +37 -4
  138. package/dist/auth/bootstrap_routes.d.ts +3 -2
  139. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  140. package/dist/auth/bootstrap_routes.js +5 -4
  141. package/dist/auth/cell_action_helpers.d.ts +89 -0
  142. package/dist/auth/cell_action_helpers.d.ts.map +1 -0
  143. package/dist/auth/cell_action_helpers.js +113 -0
  144. package/dist/auth/cell_action_specs.d.ts +215 -15
  145. package/dist/auth/cell_action_specs.d.ts.map +1 -1
  146. package/dist/auth/cell_action_specs.js +103 -16
  147. package/dist/auth/cell_actions.d.ts +58 -27
  148. package/dist/auth/cell_actions.d.ts.map +1 -1
  149. package/dist/auth/cell_actions.js +206 -161
  150. package/dist/auth/cell_audit_actions.d.ts +1 -1
  151. package/dist/auth/cell_audit_actions.d.ts.map +1 -1
  152. package/dist/auth/cell_audit_actions.js +3 -12
  153. package/dist/auth/cell_audit_events.d.ts +1 -1
  154. package/dist/auth/cell_audit_events.d.ts.map +1 -1
  155. package/dist/auth/cell_audit_events.js +3 -2
  156. package/dist/auth/cell_audit_metadata.d.ts +12 -1
  157. package/dist/auth/cell_audit_metadata.d.ts.map +1 -1
  158. package/dist/auth/cell_audit_metadata.js +11 -1
  159. package/dist/auth/cell_field_actions.d.ts +1 -1
  160. package/dist/auth/cell_field_actions.d.ts.map +1 -1
  161. package/dist/auth/cell_field_actions.js +16 -66
  162. package/dist/auth/cell_grant_action_specs.d.ts +9 -2
  163. package/dist/auth/cell_grant_action_specs.d.ts.map +1 -1
  164. package/dist/auth/cell_grant_action_specs.js +10 -3
  165. package/dist/auth/cell_grant_actions.d.ts +105 -11
  166. package/dist/auth/cell_grant_actions.d.ts.map +1 -1
  167. package/dist/auth/cell_grant_actions.js +81 -56
  168. package/dist/auth/cell_grant_audit_metadata.d.ts +6 -3
  169. package/dist/auth/cell_grant_audit_metadata.d.ts.map +1 -1
  170. package/dist/auth/cell_grant_audit_metadata.js +7 -4
  171. package/dist/auth/cell_item_actions.d.ts +1 -1
  172. package/dist/auth/cell_item_actions.d.ts.map +1 -1
  173. package/dist/auth/cell_item_actions.js +21 -82
  174. package/dist/auth/cleanup.d.ts +1 -1
  175. package/dist/auth/cleanup.d.ts.map +1 -1
  176. package/dist/auth/cleanup.js +6 -3
  177. package/dist/auth/credential_deadline.d.ts +3 -3
  178. package/dist/auth/credential_deadline.js +3 -3
  179. package/dist/auth/credential_type_schema.d.ts +8 -7
  180. package/dist/auth/credential_type_schema.d.ts.map +1 -1
  181. package/dist/auth/credential_type_schema.js +8 -7
  182. package/dist/auth/daemon_token_middleware.d.ts +12 -6
  183. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  184. package/dist/auth/daemon_token_middleware.js +28 -17
  185. package/dist/auth/deps.d.ts +4 -4
  186. package/dist/auth/fail_floor.d.ts +55 -0
  187. package/dist/auth/fail_floor.d.ts.map +1 -0
  188. package/dist/auth/fail_floor.js +63 -0
  189. package/dist/auth/invite_queries.d.ts +3 -15
  190. package/dist/auth/invite_queries.d.ts.map +1 -1
  191. package/dist/auth/invite_queries.js +3 -21
  192. package/dist/auth/middleware.d.ts +12 -7
  193. package/dist/auth/middleware.d.ts.map +1 -1
  194. package/dist/auth/middleware.js +42 -29
  195. package/dist/auth/migrations.d.ts +5 -33
  196. package/dist/auth/migrations.d.ts.map +1 -1
  197. package/dist/auth/migrations.js +9 -16
  198. package/dist/auth/request_context.d.ts +101 -71
  199. package/dist/auth/request_context.d.ts.map +1 -1
  200. package/dist/auth/request_context.js +137 -140
  201. package/dist/auth/resolved_auth.d.ts +122 -36
  202. package/dist/auth/resolved_auth.d.ts.map +1 -1
  203. package/dist/auth/resolved_auth.js +89 -38
  204. package/dist/auth/role_grant_offer_action_specs.d.ts +117 -16
  205. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  206. package/dist/auth/role_grant_offer_action_specs.js +51 -16
  207. package/dist/auth/role_grant_offer_actions.d.ts +22 -11
  208. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  209. package/dist/auth/role_grant_offer_actions.js +72 -19
  210. package/dist/auth/role_grant_offer_notifications.d.ts +6 -5
  211. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  212. package/dist/auth/role_grant_offer_notifications.js +4 -3
  213. package/dist/auth/role_grant_offer_queries.d.ts +20 -5
  214. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  215. package/dist/auth/role_grant_offer_queries.js +40 -37
  216. package/dist/auth/role_grant_queries.d.ts +44 -76
  217. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  218. package/dist/auth/role_grant_queries.js +73 -118
  219. package/dist/auth/role_grant_sql.d.ts +42 -0
  220. package/dist/auth/role_grant_sql.d.ts.map +1 -0
  221. package/dist/auth/role_grant_sql.js +54 -0
  222. package/dist/auth/role_schema.d.ts +14 -8
  223. package/dist/auth/role_schema.d.ts.map +1 -1
  224. package/dist/auth/role_schema.js +6 -3
  225. package/dist/auth/scope_kind_schema.d.ts +1 -1
  226. package/dist/auth/scope_kind_schema.js +1 -1
  227. package/dist/auth/self_service_role_actions.d.ts +1 -1
  228. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  229. package/dist/auth/self_service_role_actions.js +21 -1
  230. package/dist/auth/session_queries.d.ts +2 -1
  231. package/dist/auth/session_queries.d.ts.map +1 -1
  232. package/dist/auth/session_queries.js +2 -1
  233. package/dist/auth/signup_routes.d.ts +2 -1
  234. package/dist/auth/signup_routes.d.ts.map +1 -1
  235. package/dist/auth/signup_routes.js +14 -13
  236. package/dist/auth/standard_rpc_actions.d.ts +1 -1
  237. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  238. package/dist/auth/token_scope.d.ts +19 -46
  239. package/dist/auth/token_scope.d.ts.map +1 -1
  240. package/dist/auth/token_scope.js +23 -41
  241. package/dist/db/CLAUDE.md +18 -6
  242. package/dist/db/cell_ddl.d.ts +5 -134
  243. package/dist/db/cell_ddl.d.ts.map +1 -1
  244. package/dist/db/cell_ddl.js +28 -17
  245. package/dist/db/cell_field_queries.d.ts +0 -13
  246. package/dist/db/cell_field_queries.d.ts.map +1 -1
  247. package/dist/db/cell_field_queries.js +0 -16
  248. package/dist/db/cell_grant_queries.d.ts +10 -5
  249. package/dist/db/cell_grant_queries.d.ts.map +1 -1
  250. package/dist/db/cell_grant_queries.js +13 -7
  251. package/dist/db/cell_item_queries.d.ts +0 -7
  252. package/dist/db/cell_item_queries.d.ts.map +1 -1
  253. package/dist/db/cell_item_queries.js +0 -10
  254. package/dist/db/cell_queries.d.ts +65 -55
  255. package/dist/db/cell_queries.d.ts.map +1 -1
  256. package/dist/db/cell_queries.js +85 -62
  257. package/dist/db/cell_view_sql.d.ts +1 -6
  258. package/dist/db/cell_view_sql.d.ts.map +1 -1
  259. package/dist/db/cell_view_sql.js +1 -2
  260. package/dist/db/fact_ddl.d.ts +5 -30
  261. package/dist/db/fact_ddl.d.ts.map +1 -1
  262. package/dist/db/fact_ddl.js +14 -13
  263. package/dist/db/fact_store.d.ts +11 -0
  264. package/dist/db/fact_store.d.ts.map +1 -1
  265. package/dist/db/fact_store.js +4 -1
  266. package/dist/db/migrate.d.ts +44 -6
  267. package/dist/db/migrate.d.ts.map +1 -1
  268. package/dist/db/migrate.js +63 -4
  269. package/dist/dev/setup.d.ts +18 -14
  270. package/dist/dev/setup.d.ts.map +1 -1
  271. package/dist/dev/setup.js +42 -39
  272. package/dist/env/dotenv.d.ts +2 -2
  273. package/dist/env/dotenv.js +2 -2
  274. package/dist/env/update_env_variable.d.ts +33 -21
  275. package/dist/env/update_env_variable.d.ts.map +1 -1
  276. package/dist/env/update_env_variable.js +54 -35
  277. package/dist/hono_context.d.ts +15 -90
  278. package/dist/hono_context.d.ts.map +1 -1
  279. package/dist/hono_context.js +9 -56
  280. package/dist/http/CLAUDE.md +35 -20
  281. package/dist/http/auth_shape.d.ts +1 -8
  282. package/dist/http/auth_shape.d.ts.map +1 -1
  283. package/dist/http/auth_shape.js +6 -12
  284. package/dist/http/body_limit.d.ts +3 -1
  285. package/dist/http/body_limit.d.ts.map +1 -1
  286. package/dist/http/body_limit.js +6 -1
  287. package/dist/http/common_routes.d.ts.map +1 -1
  288. package/dist/http/common_routes.js +3 -2
  289. package/dist/http/db_routes.d.ts +3 -3
  290. package/dist/http/db_routes.js +3 -3
  291. package/dist/http/error_schemas.d.ts +1 -2
  292. package/dist/http/error_schemas.d.ts.map +1 -1
  293. package/dist/http/error_schemas.js +1 -2
  294. package/dist/http/health_schema.d.ts +16 -0
  295. package/dist/http/health_schema.d.ts.map +1 -0
  296. package/dist/http/health_schema.js +12 -0
  297. package/dist/http/jsonrpc.d.ts +9 -0
  298. package/dist/http/jsonrpc.d.ts.map +1 -1
  299. package/dist/http/jsonrpc.js +17 -0
  300. package/dist/http/jsonrpc_errors.d.ts +22 -2
  301. package/dist/http/jsonrpc_errors.d.ts.map +1 -1
  302. package/dist/http/jsonrpc_errors.js +70 -23
  303. package/dist/http/jsonrpc_helpers.d.ts +60 -17
  304. package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
  305. package/dist/http/jsonrpc_helpers.js +67 -25
  306. package/dist/http/origin.d.ts +30 -1
  307. package/dist/http/origin.d.ts.map +1 -1
  308. package/dist/http/origin.js +46 -9
  309. package/dist/http/origin_wildcard.d.ts +97 -0
  310. package/dist/http/origin_wildcard.d.ts.map +1 -0
  311. package/dist/http/origin_wildcard.js +142 -0
  312. package/dist/http/pending_effects.d.ts +28 -0
  313. package/dist/http/pending_effects.d.ts.map +1 -1
  314. package/dist/http/pending_effects.js +32 -1
  315. package/dist/http/proxy.d.ts +4 -2
  316. package/dist/http/proxy.d.ts.map +1 -1
  317. package/dist/http/proxy.js +7 -2
  318. package/dist/http/route_spec.d.ts +4 -3
  319. package/dist/http/route_spec.d.ts.map +1 -1
  320. package/dist/http/route_spec.js +54 -45
  321. package/dist/http/surface.d.ts +4 -2
  322. package/dist/http/surface.d.ts.map +1 -1
  323. package/dist/http/surface.js +7 -4
  324. package/dist/http/surface_query.d.ts +9 -50
  325. package/dist/http/surface_query.d.ts.map +1 -1
  326. package/dist/http/surface_query.js +48 -94
  327. package/dist/realtime/audit_log_sse.d.ts +180 -0
  328. package/dist/realtime/audit_log_sse.d.ts.map +1 -0
  329. package/dist/realtime/audit_log_sse.js +154 -0
  330. package/dist/realtime/sse.d.ts +21 -6
  331. package/dist/realtime/sse.d.ts.map +1 -1
  332. package/dist/realtime/sse.js +33 -10
  333. package/dist/realtime/sse_constants.d.ts +29 -2
  334. package/dist/realtime/sse_constants.d.ts.map +1 -1
  335. package/dist/realtime/sse_constants.js +35 -2
  336. package/dist/realtime/{subscriber_registry.d.ts → sse_registry.d.ts} +12 -12
  337. package/dist/realtime/sse_registry.d.ts.map +1 -0
  338. package/dist/realtime/{subscriber_registry.js → sse_registry.js} +4 -4
  339. package/dist/schema_meta.d.ts +52 -1
  340. package/dist/schema_meta.d.ts.map +1 -1
  341. package/dist/schema_meta.js +123 -6
  342. package/dist/sensitivity.d.ts +9 -3
  343. package/dist/sensitivity.d.ts.map +1 -1
  344. package/dist/sensitivity.js +3 -2
  345. package/dist/server/app_backend.d.ts +8 -5
  346. package/dist/server/app_backend.d.ts.map +1 -1
  347. package/dist/server/app_backend.js +6 -12
  348. package/dist/server/app_server.d.ts +73 -54
  349. package/dist/server/app_server.d.ts.map +1 -1
  350. package/dist/server/app_server.js +115 -78
  351. package/dist/server/app_server_context.d.ts +1 -1
  352. package/dist/server/app_server_context.d.ts.map +1 -1
  353. package/dist/server/env.d.ts +24 -20
  354. package/dist/server/env.d.ts.map +1 -1
  355. package/dist/server/env.js +24 -34
  356. package/dist/server/serve_fact_route.d.ts +12 -16
  357. package/dist/server/serve_fact_route.d.ts.map +1 -1
  358. package/dist/server/serve_fact_route.js +59 -34
  359. package/dist/server/static.d.ts.map +1 -1
  360. package/dist/server/static.js +2 -2
  361. package/dist/testing/CLAUDE.md +213 -179
  362. package/dist/testing/admin_integration.d.ts.map +1 -1
  363. package/dist/testing/admin_integration.js +10 -19
  364. package/dist/testing/adversarial_headers.d.ts.map +1 -1
  365. package/dist/testing/adversarial_headers.js +8 -0
  366. package/dist/testing/app_server.d.ts +9 -75
  367. package/dist/testing/app_server.d.ts.map +1 -1
  368. package/dist/testing/app_server.js +31 -112
  369. package/dist/testing/attack_surface.d.ts.map +1 -1
  370. package/dist/testing/attack_surface.js +3 -4
  371. package/dist/testing/audit_completeness.d.ts.map +1 -1
  372. package/dist/testing/audit_completeness.js +4 -5
  373. package/dist/testing/auth_apps.d.ts +3 -3
  374. package/dist/testing/auth_apps.d.ts.map +1 -1
  375. package/dist/testing/auth_apps.js +9 -6
  376. package/dist/testing/connection_closer_helpers.d.ts +8 -16
  377. package/dist/testing/connection_closer_helpers.d.ts.map +1 -1
  378. package/dist/testing/connection_closer_helpers.js +7 -20
  379. package/dist/testing/cross_backend/action_manifest.d.ts +15 -4
  380. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  381. package/dist/testing/cross_backend/action_manifest.js +13 -3
  382. package/dist/testing/cross_backend/action_manifest_parity.d.ts +15 -7
  383. package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
  384. package/dist/testing/cross_backend/action_manifest_parity.js +8 -1
  385. package/dist/testing/cross_backend/actor_lookup.d.ts.map +1 -1
  386. package/dist/testing/cross_backend/actor_lookup.js +27 -0
  387. package/dist/testing/cross_backend/body_size.d.ts.map +1 -1
  388. package/dist/testing/cross_backend/body_size.js +25 -22
  389. package/dist/testing/cross_backend/build_test_backend_paths.d.ts +22 -3
  390. package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
  391. package/dist/testing/cross_backend/build_test_backend_paths.js +34 -11
  392. package/dist/testing/cross_backend/capabilities.d.ts +15 -8
  393. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  394. package/dist/testing/cross_backend/cell_gated_create.d.ts.map +1 -1
  395. package/dist/testing/cross_backend/cell_gated_create.js +109 -13
  396. package/dist/testing/cross_backend/cell_grant_role.js +2 -2
  397. package/dist/testing/cross_backend/cell_grant_steward.d.ts +4 -0
  398. package/dist/testing/cross_backend/cell_grant_steward.d.ts.map +1 -0
  399. package/dist/testing/cross_backend/cell_grant_steward.js +120 -0
  400. package/dist/testing/cross_backend/cell_moderate.d.ts +7 -1
  401. package/dist/testing/cross_backend/cell_moderate.d.ts.map +1 -1
  402. package/dist/testing/cross_backend/cell_moderate.js +68 -4
  403. package/dist/testing/cross_backend/cell_ref_admission.d.ts.map +1 -1
  404. package/dist/testing/cross_backend/cell_ref_admission.js +18 -9
  405. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  406. package/dist/testing/cross_backend/cell_relations.js +21 -0
  407. package/dist/testing/cross_backend/conformance_table.d.ts +6 -1
  408. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  409. package/dist/testing/cross_backend/conformance_table.js +12 -10
  410. package/dist/testing/cross_backend/default_backend_configs.d.ts +18 -4
  411. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  412. package/dist/testing/cross_backend/default_backend_configs.js +29 -9
  413. package/dist/testing/cross_backend/default_spine_surface.d.ts +7 -7
  414. package/dist/testing/cross_backend/default_spine_surface.js +2 -2
  415. package/dist/testing/cross_backend/differential.d.ts +7 -0
  416. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  417. package/dist/testing/cross_backend/differential.js +17 -0
  418. package/dist/testing/cross_backend/expected_schema.json +1 -0
  419. package/dist/testing/cross_backend/fact_serving.d.ts.map +1 -1
  420. package/dist/testing/cross_backend/fact_serving.js +48 -0
  421. package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -4
  422. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  423. package/dist/testing/cross_backend/full_spine_mount.js +13 -5
  424. package/dist/testing/cross_backend/origin_scope.d.ts.map +1 -1
  425. package/dist/testing/cross_backend/origin_scope.js +5 -13
  426. package/dist/testing/cross_backend/peer_ping_ws.d.ts.map +1 -1
  427. package/dist/testing/cross_backend/peer_ping_ws.js +29 -4
  428. package/dist/testing/cross_backend/postgres_database.d.ts +32 -0
  429. package/dist/testing/cross_backend/postgres_database.d.ts.map +1 -1
  430. package/dist/testing/cross_backend/postgres_database.js +56 -1
  431. package/dist/testing/cross_backend/query_shape.d.ts.map +1 -1
  432. package/dist/testing/cross_backend/query_shape.js +18 -1
  433. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  434. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +96 -2
  435. package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -2
  436. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +1 -1
  437. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  438. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +17 -5
  439. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  440. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +5 -4
  441. package/dist/testing/cross_backend/session_cap.d.ts +8 -0
  442. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  443. package/dist/testing/cross_backend/session_cap.js +66 -2
  444. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  445. package/dist/testing/cross_backend/setup.js +5 -4
  446. package/dist/testing/cross_backend/spine_suites.d.ts +4 -1
  447. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  448. package/dist/testing/cross_backend/spine_suites.js +21 -0
  449. package/dist/testing/cross_backend/spine_surface_constants.d.ts +22 -7
  450. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  451. package/dist/testing/cross_backend/spine_surface_constants.js +22 -7
  452. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  453. package/dist/testing/cross_backend/sse_round_trip.js +4 -3
  454. package/dist/testing/cross_backend/standard.d.ts +6 -12
  455. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  456. package/dist/testing/cross_backend/test_cell_gated_create_authorize.d.ts +18 -19
  457. package/dist/testing/cross_backend/test_cell_gated_create_authorize.d.ts.map +1 -1
  458. package/dist/testing/cross_backend/test_cell_gated_create_authorize.js +66 -42
  459. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts +8 -0
  460. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts.map +1 -0
  461. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.js +22 -0
  462. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  463. package/dist/testing/cross_backend/testing_backdoor.js +4 -6
  464. package/dist/testing/cross_backend/testing_origin_check.d.ts +1 -1
  465. package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
  466. package/dist/testing/cross_backend/testing_origin_check.js +1 -1
  467. package/dist/testing/cross_backend/testing_reset_actions.d.ts +10 -5
  468. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  469. package/dist/testing/cross_backend/testing_reset_actions.js +7 -6
  470. package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
  471. package/dist/testing/cross_backend/testing_server_bun.js +5 -4
  472. package/dist/testing/cross_backend/testing_server_core.d.ts +6 -7
  473. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  474. package/dist/testing/cross_backend/testing_server_core.js +1 -1
  475. package/dist/testing/cross_backend/testing_server_node.d.ts.map +1 -1
  476. package/dist/testing/cross_backend/testing_server_node.js +13 -2
  477. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  478. package/dist/testing/cross_backend/token_lifetime.js +68 -0
  479. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  480. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  481. package/dist/testing/cross_backend/transport_composition.js +48 -6
  482. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +16 -2
  483. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  484. package/dist/testing/cross_backend/ts_spine_backend_config.js +11 -8
  485. package/dist/testing/cross_backend/ws_action_rate_limit.d.ts.map +1 -1
  486. package/dist/testing/cross_backend/ws_action_rate_limit.js +30 -12
  487. package/dist/testing/cross_backend/ws_connection_cap.d.ts.map +1 -1
  488. package/dist/testing/cross_backend/ws_connection_cap.js +5 -7
  489. package/dist/testing/cross_backend/ws_endpoint.d.ts +2 -3
  490. package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
  491. package/dist/testing/cross_backend/ws_envelope.d.ts +17 -0
  492. package/dist/testing/cross_backend/ws_envelope.d.ts.map +1 -0
  493. package/dist/testing/cross_backend/ws_envelope.js +172 -0
  494. package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts +16 -0
  495. package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts.map +1 -1
  496. package/dist/testing/cross_backend/ws_inbound_dispatch.js +8 -4
  497. package/dist/testing/cross_backend/ws_outbound_overflow.d.ts.map +1 -1
  498. package/dist/testing/cross_backend/ws_outbound_overflow.js +5 -8
  499. package/dist/testing/cross_backend/ws_role_gated.js +2 -2
  500. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  501. package/dist/testing/cross_backend/ws_round_trip.js +6 -4
  502. package/dist/{cli/daemon.d.ts → testing/daemon_info.d.ts} +15 -47
  503. package/dist/testing/daemon_info.d.ts.map +1 -0
  504. package/dist/testing/daemon_info.js +108 -0
  505. package/dist/testing/daemon_token_rotation.js +1 -1
  506. package/dist/testing/data_exposure.d.ts.map +1 -1
  507. package/dist/testing/data_exposure.js +3 -4
  508. package/dist/testing/db.js +2 -2
  509. package/dist/testing/integration.d.ts.map +1 -1
  510. package/dist/testing/integration.js +35 -65
  511. package/dist/testing/integration_helpers.d.ts +0 -15
  512. package/dist/testing/integration_helpers.d.ts.map +1 -1
  513. package/dist/testing/integration_helpers.js +2 -42
  514. package/dist/testing/middleware.d.ts +20 -12
  515. package/dist/testing/middleware.d.ts.map +1 -1
  516. package/dist/testing/middleware.js +49 -40
  517. package/dist/testing/rate_limiting.d.ts.map +1 -1
  518. package/dist/testing/rate_limiting.js +13 -22
  519. package/dist/testing/resolved_auth.d.ts +30 -0
  520. package/dist/testing/resolved_auth.d.ts.map +1 -0
  521. package/dist/testing/resolved_auth.js +41 -0
  522. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  523. package/dist/testing/rpc_envelope_cases.js +3 -0
  524. package/dist/testing/rpc_helpers.d.ts +1 -1
  525. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  526. package/dist/testing/rpc_helpers.js +2 -1
  527. package/dist/testing/sse_round_trip.d.ts +5 -4
  528. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  529. package/dist/testing/sse_round_trip.js +2 -2
  530. package/dist/testing/stubs.d.ts +2 -2
  531. package/dist/testing/stubs.d.ts.map +1 -1
  532. package/dist/testing/stubs.js +24 -21
  533. package/dist/testing/test_origin.d.ts +25 -0
  534. package/dist/testing/test_origin.d.ts.map +1 -0
  535. package/dist/testing/test_origin.js +28 -0
  536. package/dist/testing/transports/raw_http.d.ts +54 -0
  537. package/dist/testing/transports/raw_http.d.ts.map +1 -1
  538. package/dist/testing/transports/raw_http.js +58 -0
  539. package/dist/testing/transports/ws_raw_client.d.ts +8 -0
  540. package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
  541. package/dist/testing/transports/ws_raw_client.js +13 -0
  542. package/dist/testing/transports/ws_transport.d.ts +15 -2
  543. package/dist/testing/transports/ws_transport.d.ts.map +1 -1
  544. package/dist/testing/transports/ws_transport.js +4 -2
  545. package/dist/testing/ws_round_trip.d.ts +27 -25
  546. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  547. package/dist/testing/ws_round_trip.js +34 -26
  548. package/dist/ui/AccountSessions.svelte +48 -19
  549. package/dist/ui/AccountSessions.svelte.d.ts +2 -17
  550. package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
  551. package/dist/ui/AdminAccounts.svelte +6 -1
  552. package/dist/ui/AdminAuditLog.svelte +61 -22
  553. package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
  554. package/dist/ui/AdminInvites.svelte +1 -1
  555. package/dist/ui/AdminOverview.svelte +76 -37
  556. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
  557. package/dist/ui/AdminRoleGrantHistory.svelte +6 -1
  558. package/dist/ui/AdminSessions.svelte +1 -1
  559. package/dist/ui/AppShell.svelte +3 -2
  560. package/dist/ui/AppShell.svelte.d.ts +3 -2
  561. package/dist/ui/AppShell.svelte.d.ts.map +1 -1
  562. package/dist/ui/CLAUDE.md +121 -35
  563. package/dist/ui/Datatable.svelte +33 -18
  564. package/dist/ui/Datatable.svelte.d.ts +2 -14
  565. package/dist/ui/Datatable.svelte.d.ts.map +1 -1
  566. package/dist/ui/OpenSignupToggle.svelte +10 -1
  567. package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
  568. package/dist/ui/PopoverButton.svelte +13 -8
  569. package/dist/ui/PopoverButton.svelte.d.ts.map +1 -1
  570. package/dist/ui/RoleGrantOfferForm.svelte +3 -2
  571. package/dist/ui/RoleGrantOfferForm.svelte.d.ts +3 -2
  572. package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -1
  573. package/dist/ui/RoleGrantOfferHistory.svelte +3 -3
  574. package/dist/ui/RoleGrantOfferInbox.svelte +19 -15
  575. package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -1
  576. package/dist/ui/SurfaceExplorer.svelte +66 -27
  577. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
  578. package/dist/ui/account_sessions_state.svelte.d.ts +7 -14
  579. package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
  580. package/dist/ui/admin_accounts_state.svelte.d.ts +14 -9
  581. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
  582. package/dist/ui/admin_accounts_state.svelte.js +6 -4
  583. package/dist/ui/admin_invites_state.svelte.d.ts +2 -2
  584. package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
  585. package/dist/ui/admin_rpc_adapters.d.ts +9 -9
  586. package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
  587. package/dist/ui/admin_rpc_adapters.js +9 -9
  588. package/dist/ui/app_settings_state.svelte.d.ts +2 -2
  589. package/dist/ui/app_settings_state.svelte.d.ts.map +1 -1
  590. package/dist/ui/audit_log_state.svelte.d.ts +70 -13
  591. package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
  592. package/dist/ui/audit_log_state.svelte.js +239 -47
  593. package/dist/ui/backend_probe.svelte.d.ts +93 -0
  594. package/dist/ui/backend_probe.svelte.d.ts.map +1 -0
  595. package/dist/ui/backend_probe.svelte.js +140 -0
  596. package/dist/ui/format_scope.d.ts +7 -7
  597. package/dist/ui/format_scope.d.ts.map +1 -1
  598. package/dist/ui/format_scope.js +4 -4
  599. package/dist/ui/keyed_async_slot.svelte.d.ts +2 -2
  600. package/dist/ui/keyed_async_slot.svelte.js +2 -2
  601. package/dist/ui/popover.svelte.d.ts +18 -19
  602. package/dist/ui/popover.svelte.d.ts.map +1 -1
  603. package/dist/ui/popover.svelte.js +103 -16
  604. package/dist/ui/role_grant_offers_state.svelte.d.ts +41 -46
  605. package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -1
  606. package/dist/ui/role_grant_offers_state.svelte.js +37 -19
  607. package/dist/ui/ui_format.d.ts +17 -0
  608. package/dist/ui/ui_format.d.ts.map +1 -1
  609. package/dist/ui/ui_format.js +20 -0
  610. package/package.json +2 -1
  611. package/dist/actions/register_ws_endpoint.d.ts +0 -79
  612. package/dist/actions/register_ws_endpoint.d.ts.map +0 -1
  613. package/dist/actions/register_ws_endpoint.js +0 -109
  614. package/dist/actions/transports_ws_auth_guard.d.ts +0 -94
  615. package/dist/actions/transports_ws_auth_guard.d.ts.map +0 -1
  616. package/dist/actions/transports_ws_auth_guard.js +0 -138
  617. package/dist/actions/transports_ws_backend.d.ts.map +0 -1
  618. package/dist/cli/args.d.ts +0 -55
  619. package/dist/cli/args.d.ts.map +0 -1
  620. package/dist/cli/args.js +0 -100
  621. package/dist/cli/config.d.ts +0 -47
  622. package/dist/cli/config.d.ts.map +0 -1
  623. package/dist/cli/config.js +0 -77
  624. package/dist/cli/daemon.d.ts.map +0 -1
  625. package/dist/cli/daemon.js +0 -181
  626. package/dist/cli/help.d.ts +0 -124
  627. package/dist/cli/help.d.ts.map +0 -1
  628. package/dist/cli/help.js +0 -215
  629. package/dist/cli/logger.d.ts +0 -46
  630. package/dist/cli/logger.d.ts.map +0 -1
  631. package/dist/cli/logger.js +0 -48
  632. package/dist/cli/util.d.ts +0 -36
  633. package/dist/cli/util.d.ts.map +0 -1
  634. package/dist/cli/util.js +0 -50
  635. package/dist/realtime/sse_auth_guard.d.ts +0 -197
  636. package/dist/realtime/sse_auth_guard.d.ts.map +0 -1
  637. package/dist/realtime/sse_auth_guard.js +0 -238
  638. package/dist/realtime/subscriber_registry.d.ts.map +0 -1
  639. package/dist/testing/bootstrap_success.d.ts +0 -29
  640. package/dist/testing/bootstrap_success.d.ts.map +0 -1
  641. package/dist/testing/bootstrap_success.js +0 -144
  642. package/dist/testing/mock_fs.d.ts +0 -20
  643. package/dist/testing/mock_fs.d.ts.map +0 -1
  644. package/dist/testing/mock_fs.js +0 -28
  645. package/dist/testing/standard.d.ts +0 -122
  646. package/dist/testing/standard.d.ts.map +0 -1
  647. package/dist/testing/standard.js +0 -73
  648. package/dist/testing/testing_rate_limiter.d.ts +0 -65
  649. package/dist/testing/testing_rate_limiter.d.ts.map +0 -1
  650. package/dist/testing/testing_rate_limiter.js +0 -80
@@ -15,26 +15,32 @@
15
15
  * principals against the role schema; rejects owner-as-principal.
16
16
  * Actor-shaped principals carry a pre-resolved `actor_id` (callers pick
17
17
  * via `actor_search`). Idempotent — re-granting the same principal
18
- * updates `level` via UPSERT.
18
+ * updates `level` via UPSERT. A mounted `authorize_grant_create` is asked
19
+ * after the spine's own gates, before the owner check and the write (403
20
+ * `cell_grant_not_authorized` on refusal).
19
21
  * - `cell_grant_revoke` — admin / owner, plus self for actor-shaped grants
20
- * ("leave shared cell"). Returns `still_admitted` computed by re-running
21
- * `can_view_cell` against the remaining grants.
22
+ * ("leave shared cell"), plus — when `authorize_grant_revoke` is mounted —
23
+ * the steward of a scoped role-shaped grant's scope. Returns
24
+ * `still_admitted` computed by re-running `can_view_cell` against the
25
+ * remaining grants.
22
26
  * - `cell_grant_list` — admin / owner only. Viewers and editors alike get
23
27
  * the IDOR-mask 404 (the share list is the manager's to curate).
24
28
  *
25
- * All three 404 with `cell_not_found` on cell-miss / cell-unviewable, and
26
- * with `cell_grant_not_found` on grant-miss, mirroring the existence-leak
27
- * guards in `auth/cell_actions.ts`.
29
+ * Every miss and every authority denial is a 404 mask, as in
30
+ * `auth/cell_actions.ts`: `cell_grant_create` and `cell_grant_list` answer
31
+ * `cell_not_found` for a missing cell and a non-manager alike;
32
+ * `cell_grant_revoke` answers `cell_grant_not_found` for a missing grant, a
33
+ * grant whose cell is gone, and a caller with no authority to revoke it.
28
34
  *
29
35
  * Audit events `cell_grant_create` / `cell_grant_revoke` carry IDs only
30
36
  * (no display-name snapshots); see `auth/cell_grant_audit_metadata.ts`.
31
37
  *
32
38
  * @module
33
39
  */
34
- import { rpc_action } from '../actions/action_rpc.js';
40
+ import { rpc_action } from '../actions/action_types.js';
35
41
  import { jsonrpc_errors } from '../http/jsonrpc_errors.js';
36
- import { cell_grant_create_action_spec, cell_grant_revoke_action_spec, cell_grant_list_action_spec, ERROR_CELL_GRANT_NOT_FOUND, ERROR_CELL_GRANT_PRINCIPAL_IS_OWNER, ERROR_CELL_GRANT_UNAPPROVED, ERROR_CELL_GRANT_UNKNOWN_ROLE } from './cell_grant_action_specs.js';
37
- import { ERROR_CELL_NOT_FOUND } from './cell_action_specs.js';
42
+ import { cell_grant_create_action_spec, cell_grant_revoke_action_spec, cell_grant_list_action_spec, ERROR_CELL_GRANT_NOT_AUTHORIZED, ERROR_CELL_GRANT_NOT_FOUND, ERROR_CELL_GRANT_PRINCIPAL_IS_OWNER, ERROR_CELL_GRANT_UNAPPROVED, ERROR_CELL_GRANT_UNKNOWN_ROLE } from './cell_grant_action_specs.js';
43
+ import { emit_cell_audit, require_manageable_cell } from './cell_action_helpers.js';
38
44
  import { can_view_cell, can_manage_cell } from './cell_authorize.js';
39
45
  import { query_cell_get } from '../db/cell_queries.js';
40
46
  import { cell_moderation_admits_audience } from '../db/cell_moderation.js';
@@ -88,26 +94,38 @@ const assert_principal_is_not_owner = (cell, principal) => {
88
94
  });
89
95
  }
90
96
  };
97
+ /**
98
+ * Whether the mounted `CellGrantRevokeAuthorize` admits `auth` as the steward
99
+ * of `grant`'s scope — `false` with no callback, for an actor-shaped grant,
100
+ * and for a scopeless role grant, none of which reach it.
101
+ */
102
+ const steward_admits_revoke = async (auth, grant, cell, authorize, ctx) => {
103
+ if (!authorize)
104
+ return false;
105
+ if (grant.actor_id !== null || grant.role === null || grant.scope_id === null)
106
+ return false;
107
+ return authorize(auth, {
108
+ grant_id: grant.id,
109
+ cell_id: grant.cell_id,
110
+ cell_created_by: cell.created_by,
111
+ role: grant.role,
112
+ scope_id: grant.scope_id,
113
+ level: grant.level
114
+ }, ctx);
115
+ };
91
116
  /** Create the three `cell_grant_*` RPC actions. */
92
117
  export const create_cell_grant_actions = (deps) => {
93
- const { roles } = deps;
118
+ const { roles, authorize_grant_create, authorize_grant_revoke } = deps;
94
119
  const create_handler = async (input, ctx) => {
95
120
  const auth = ctx.auth;
96
- const cell = await query_cell_get(ctx, input.cell_id);
97
- if (!cell) {
98
- // IDOR mask: same code as cell_get's miss/unviewable so probing
99
- // for cells via the share endpoint is no easier than via cell_get.
100
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
101
- }
102
121
  // Grant management is manage-tier only (admin / owner). Editor-grant
103
122
  // holders may edit the cell's content + relations but cannot mint
104
123
  // grants of any level — delegating the share list would let editors
105
124
  // widen access (or mint peer editors) and escape the manager's
106
- // authority. Non-managers get the IDOR-mask 404, same as a non-viewer
107
- // on the read path.
108
- if (!can_manage_cell(auth, cell)) {
109
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
110
- }
125
+ // authority. A miss and a non-manager both get the IDOR-mask 404, so
126
+ // probing for cells via the share endpoint is no easier than via
127
+ // cell_get.
128
+ const cell = await require_manageable_cell(ctx, auth, input.cell_id);
111
129
  // A grant extends a cell's audience, and a contribution whose moderation
112
130
  // doesn't admit one (pending, rejected, or an unknown marker) has none past
113
131
  // its author and admins — `can_view_cell`'s grant arm wouldn't admit on it —
@@ -127,6 +145,21 @@ export const create_cell_grant_actions = (deps) => {
127
145
  reason: ERROR_CELL_GRANT_UNKNOWN_ROLE
128
146
  });
129
147
  }
148
+ // The consumer's gate, asked only of a manager past the spine's gates;
149
+ // a refusal writes nothing.
150
+ if (authorize_grant_create) {
151
+ const allowed = await authorize_grant_create(auth, {
152
+ cell_id: cell.id,
153
+ cell_created_by: cell.created_by,
154
+ level: input.level,
155
+ principal
156
+ }, ctx);
157
+ if (!allowed) {
158
+ throw jsonrpc_errors.forbidden('cell grant is not permitted here', {
159
+ reason: ERROR_CELL_GRANT_NOT_AUTHORIZED
160
+ });
161
+ }
162
+ }
130
163
  assert_principal_is_not_owner(cell, principal);
131
164
  const row = await query_cell_grant_create(ctx, {
132
165
  cell_id: cell.id,
@@ -134,17 +167,11 @@ export const create_cell_grant_actions = (deps) => {
134
167
  principal,
135
168
  granted_by: auth.actor.id
136
169
  });
137
- deps.audit.emit(ctx, {
138
- event_type: 'cell_grant_create',
139
- actor_id: auth.actor.id,
140
- account_id: auth.account.id,
141
- ip: ctx.client_ip,
142
- metadata: {
143
- cell_id: row.cell_id,
144
- grant_id: row.id,
145
- level: row.level,
146
- principal: principal_from_row(row)
147
- }
170
+ emit_cell_audit(ctx, deps.audit, auth, 'cell_grant_create', {
171
+ cell_id: row.cell_id,
172
+ grant_id: row.id,
173
+ level: row.level,
174
+ principal: principal_from_row(row)
148
175
  });
149
176
  return { grant: to_grant_json(row) };
150
177
  };
@@ -166,21 +193,30 @@ export const create_cell_grant_actions = (deps) => {
166
193
  // authority path. Owner-with-self-grant can't happen
167
194
  // (`assert_principal_is_not_owner` blocks it at create time).
168
195
  const is_self_actor_grant = grant.actor_id !== null && grant.actor_id === auth.actor.id;
196
+ // The steward of a scoped role grant's scope, asked only of a caller with
197
+ // neither of the above — so a manager or self-revoker never consults it.
198
+ const is_steward = !is_manager &&
199
+ !is_self_actor_grant &&
200
+ (await steward_admits_revoke(auth, grant, cell, authorize_grant_revoke, ctx));
169
201
  // Grant management is manage-tier only (admin / owner); editor-grant
170
- // holders cannot revoke grants (mirrors the create gate). The sole
171
- // exception is self-revoke. Non-qualifying callers get the IDOR mask.
172
- if (!is_manager && !is_self_actor_grant) {
202
+ // holders cannot revoke grants (mirrors the create gate). The
203
+ // exceptions are self-revoke and a scope's steward. Non-qualifying
204
+ // callers get the IDOR mask.
205
+ if (!is_manager && !is_self_actor_grant && !is_steward) {
173
206
  throw jsonrpc_errors.not_found('cell grant', { reason: ERROR_CELL_GRANT_NOT_FOUND });
174
207
  }
175
- const deleted = await query_cell_grant_delete(ctx, grant.id);
208
+ // A steward's admission was decided on the grant's level, so its delete
209
+ // matches that level: a level change landing in between deletes nothing.
210
+ const deleted = await query_cell_grant_delete(ctx, grant.id, is_steward ? grant.level : undefined);
176
211
  if (!deleted) {
177
- // Raced with another revoker. Same shape as cell_actions.ts —
178
- // 404 covers the gap.
212
+ // Raced with another revoker, or (a steward's) with a level change.
213
+ // Same shape as cell_actions.ts — 404 covers the gap.
179
214
  throw jsonrpc_errors.not_found('cell grant', { reason: ERROR_CELL_GRANT_NOT_FOUND });
180
215
  }
181
- // Recompute admit state against the remaining grants. Always true
182
- // for non-self revokes (caller didn't admit via this row), but the
183
- // recompute is uniform shape — let `can_view_cell` decide.
216
+ // Recompute admit state against the remaining grants. Always true for
217
+ // a manager's revoke; a self-revoker or a steward may have admitted
218
+ // through nothing else, so the recompute is uniform shape — let
219
+ // `can_view_cell` decide.
184
220
  const remaining = await query_cell_grant_list_for_cell(ctx, cell.id);
185
221
  const still_admitted = can_view_cell(auth, cell, remaining);
186
222
  const audit_metadata = {
@@ -188,29 +224,18 @@ export const create_cell_grant_actions = (deps) => {
188
224
  grant_id: deleted.id,
189
225
  level: deleted.level,
190
226
  principal: principal_from_row(deleted),
191
- ...(is_self_actor_grant ? { self: true } : {})
227
+ ...(is_self_actor_grant ? { self: true } : {}),
228
+ ...(is_steward ? { steward: true } : {})
192
229
  };
193
- deps.audit.emit(ctx, {
194
- event_type: 'cell_grant_revoke',
195
- actor_id: auth.actor.id,
196
- account_id: auth.account.id,
197
- ip: ctx.client_ip,
198
- metadata: audit_metadata
199
- });
230
+ emit_cell_audit(ctx, deps.audit, auth, 'cell_grant_revoke', audit_metadata);
200
231
  return { ok: true, still_admitted };
201
232
  };
202
233
  const list_handler = async (input, ctx) => {
203
234
  const auth = ctx.auth;
204
- const cell = await query_cell_get(ctx, input.cell_id);
205
- if (!cell) {
206
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
207
- }
208
235
  // Same authz gate as create — manage tier only (admin / owner). The
209
236
  // share list is the manager's to curate; viewers and editors alike
210
237
  // fall through to the IDOR-mask 404.
211
- if (!can_manage_cell(auth, cell)) {
212
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
213
- }
238
+ const cell = await require_manageable_cell(ctx, auth, input.cell_id);
214
239
  const grants = await query_cell_grant_list_for_cell(ctx, cell.id);
215
240
  return { grants: grants.map(to_grant_json) };
216
241
  };
@@ -52,9 +52,11 @@ export type CellGrantCreateAuditMetadata = z.infer<typeof CellGrantCreateAuditMe
52
52
  *
53
53
  * `self: true` distinguishes the recipient-side "leave shared cell"
54
54
  * path (actor-shaped grant where the principal actor === caller
55
- * actor) from a delegator-side revoke. Single event type for both
56
- * — the boolean is enough for forensic review and avoids surface-
57
- * doubling with a parallel `cell_grant_leave` event.
55
+ * actor) from a delegator-side revoke, and `steward: true` a scope
56
+ * steward's revoke of a scoped role-shaped grant, admitted by the
57
+ * consumer's `CellGrantRevokeAuthorize`. Single event type for all
58
+ * three — the boolean is enough for forensic review and avoids
59
+ * surface-doubling with parallel events.
58
60
  */
59
61
  export declare const CellGrantRevokeAuditMetadata: z.ZodObject<{
60
62
  cell_id: z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">;
@@ -70,6 +72,7 @@ export declare const CellGrantRevokeAuditMetadata: z.ZodObject<{
70
72
  scope_id: z.ZodNullable<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
71
73
  }, z.core.$loose>]>;
72
74
  self: z.ZodOptional<z.ZodLiteral<true>>;
75
+ steward: z.ZodOptional<z.ZodLiteral<true>>;
73
76
  }, z.core.$loose>;
74
77
  export type CellGrantRevokeAuditMetadata = z.infer<typeof CellGrantRevokeAuditMetadata>;
75
78
  //# sourceMappingURL=cell_grant_audit_metadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cell_grant_audit_metadata.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cell_grant_audit_metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B;;;;;mBAG1C,CAAC;AACH,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAE9F;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;iBAKvC,CAAC;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAExF;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;iBAMvC,CAAC;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC"}
1
+ {"version":3,"file":"cell_grant_audit_metadata.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cell_grant_audit_metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B;;;;;mBAG1C,CAAC;AACH,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAE9F;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;iBAKvC,CAAC;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAExF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;iBAOvC,CAAC;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC"}
@@ -41,14 +41,17 @@ export const CellGrantCreateAuditMetadata = z.looseObject({
41
41
  *
42
42
  * `self: true` distinguishes the recipient-side "leave shared cell"
43
43
  * path (actor-shaped grant where the principal actor === caller
44
- * actor) from a delegator-side revoke. Single event type for both
45
- * — the boolean is enough for forensic review and avoids surface-
46
- * doubling with a parallel `cell_grant_leave` event.
44
+ * actor) from a delegator-side revoke, and `steward: true` a scope
45
+ * steward's revoke of a scoped role-shaped grant, admitted by the
46
+ * consumer's `CellGrantRevokeAuthorize`. Single event type for all
47
+ * three — the boolean is enough for forensic review and avoids
48
+ * surface-doubling with parallel events.
47
49
  */
48
50
  export const CellGrantRevokeAuditMetadata = z.looseObject({
49
51
  cell_id: Uuid,
50
52
  grant_id: Uuid,
51
53
  level: z.enum(['viewer', 'editor']),
52
54
  principal: CellGrantPrincipalAuditMetadata,
53
- self: z.literal(true).optional()
55
+ self: z.literal(true).optional(),
56
+ steward: z.literal(true).optional()
54
57
  });
@@ -27,7 +27,7 @@
27
27
  *
28
28
  * @module
29
29
  */
30
- import { type RpcAction } from '../actions/action_rpc.js';
30
+ import { type RpcAction } from '../actions/action_types.js';
31
31
  import type { ActionFactoryDeps } from './deps.js';
32
32
  import { type ItemJson } from './cell_item_action_specs.js';
33
33
  import { type CellItemRow } from '../db/cell_item_queries.js';
@@ -1 +1 @@
1
- {"version":3,"file":"cell_item_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cell_item_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAIN,KAAK,SAAS,EACd,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAgBN,KAAK,QAAQ,EACb,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAMN,KAAK,WAAW,EAChB,MAAM,4BAA4B,CAAC;AAOpC,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAEnD,eAAO,MAAM,YAAY,GAAI,KAAK,WAAW,KAAG,QAS9C,CAAC;AAOH,iDAAiD;AACjD,eAAO,MAAM,wBAAwB,GAAI,MAAM,kBAAkB,KAAG,KAAK,CAAC,SAAS,CA+KlF,CAAC"}
1
+ {"version":3,"file":"cell_item_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cell_item_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAIN,KAAK,SAAS,EACd,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAgBN,KAAK,QAAQ,EACb,MAAM,6BAA6B,CAAC;AASrC,OAAO,EAMN,KAAK,WAAW,EAChB,MAAM,4BAA4B,CAAC;AAOpC,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAEnD,eAAO,MAAM,YAAY,GAAI,KAAK,WAAW,KAAG,QAS9C,CAAC;AAOH,iDAAiD;AACjD,eAAO,MAAM,wBAAwB,GAAI,MAAM,kBAAkB,KAAG,KAAK,CAAC,SAAS,CAmHlF,CAAC"}
@@ -27,15 +27,14 @@
27
27
  *
28
28
  * @module
29
29
  */
30
- import { rpc_action } from '../actions/action_rpc.js';
30
+ import { rpc_action } from '../actions/action_types.js';
31
31
  import { jsonrpc_errors } from '../http/jsonrpc_errors.js';
32
32
  import { is_pg_unique_violation } from '../db/pg_error.js';
33
33
  import { cell_item_insert_action_spec, cell_item_move_action_spec, cell_item_delete_action_spec, cell_item_list_action_spec, ERROR_CELL_ITEM_POSITION_TAKEN, ERROR_CELL_ITEM_LIST_REQUIRES_PARENT_OR_CHILD } from './cell_item_action_specs.js';
34
34
  import { ERROR_CELL_NOT_FOUND } from './cell_action_specs.js';
35
- import { can_view_cell, can_edit_cell, cell_viewer_from_auth } from './cell_authorize.js';
35
+ import { cell_viewer_from_auth } from './cell_authorize.js';
36
+ import { emit_cell_audit, require_editable_cell, require_viewable_cell } from './cell_action_helpers.js';
36
37
  import { CELL_RELATION_LIST_LIMIT_DEFAULT } from './cell_relation_list_limit.js';
37
- import { query_cell_get } from '../db/cell_queries.js';
38
- import { query_cell_grant_list_for_cell } from '../db/cell_grant_queries.js';
39
38
  import { query_cell_item_insert, query_cell_item_move, query_cell_item_delete, query_cell_item_list_for_parent, query_cell_item_list_for_child } from '../db/cell_item_queries.js';
40
39
  export const to_item_json = (row) => ({
41
40
  parent_id: row.parent_id,
@@ -54,23 +53,9 @@ const position_taken_error = () => jsonrpc_errors.invalid_params('cell_item posi
54
53
  export const create_cell_item_actions = (deps) => {
55
54
  const insert_handler = async (input, ctx) => {
56
55
  const auth = ctx.auth;
57
- const parent = await query_cell_get(ctx, input.parent_id);
58
- if (!parent) {
59
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
60
- }
61
- const parent_grants = await query_cell_grant_list_for_cell(ctx, parent.id);
62
- if (!can_edit_cell(auth, parent, parent_grants)) {
63
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
64
- }
65
- const child = await query_cell_get(ctx, input.child_id);
66
- if (!child) {
67
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
68
- }
56
+ await require_editable_cell(ctx, auth, input.parent_id);
69
57
  // Child must be view-admitted — otherwise insert leaks existence.
70
- const child_grants = await query_cell_grant_list_for_cell(ctx, child.id);
71
- if (!can_view_cell(auth, child, child_grants)) {
72
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
73
- }
58
+ await require_viewable_cell(ctx, auth, input.child_id);
74
59
  let row;
75
60
  try {
76
61
  row = await query_cell_item_insert(ctx, {
@@ -84,29 +69,16 @@ export const create_cell_item_actions = (deps) => {
84
69
  throw position_taken_error();
85
70
  throw err;
86
71
  }
87
- deps.audit.emit(ctx, {
88
- event_type: 'cell_item_insert',
89
- actor_id: auth.actor.id,
90
- account_id: auth.account.id,
91
- ip: ctx.client_ip,
92
- metadata: {
93
- parent_id: row.parent_id,
94
- position: row.position,
95
- child_id: row.child_id
96
- }
72
+ emit_cell_audit(ctx, deps.audit, auth, 'cell_item_insert', {
73
+ parent_id: row.parent_id,
74
+ position: row.position,
75
+ child_id: row.child_id
97
76
  });
98
77
  return { item: to_item_json(row) };
99
78
  };
100
79
  const move_handler = async (input, ctx) => {
101
80
  const auth = ctx.auth;
102
- const parent = await query_cell_get(ctx, input.parent_id);
103
- if (!parent) {
104
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
105
- }
106
- const parent_grants = await query_cell_grant_list_for_cell(ctx, parent.id);
107
- if (!can_edit_cell(auth, parent, parent_grants)) {
108
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
109
- }
81
+ await require_editable_cell(ctx, auth, input.parent_id);
110
82
  let row;
111
83
  try {
112
84
  row = await query_cell_item_move(ctx, input.parent_id, input.position, input.new_position);
@@ -120,41 +92,22 @@ export const create_cell_item_actions = (deps) => {
120
92
  // Source row missing — raced with deleter. 404 covers the gap.
121
93
  throw jsonrpc_errors.not_found('cell_item', { reason: ERROR_CELL_NOT_FOUND });
122
94
  }
123
- deps.audit.emit(ctx, {
124
- event_type: 'cell_item_move',
125
- actor_id: auth.actor.id,
126
- account_id: auth.account.id,
127
- ip: ctx.client_ip,
128
- metadata: {
129
- parent_id: row.parent_id,
130
- position_old: input.position,
131
- position_new: row.position
132
- }
95
+ emit_cell_audit(ctx, deps.audit, auth, 'cell_item_move', {
96
+ parent_id: row.parent_id,
97
+ position_old: input.position,
98
+ position_new: row.position
133
99
  });
134
100
  return { item: to_item_json(row) };
135
101
  };
136
102
  const delete_handler = async (input, ctx) => {
137
103
  const auth = ctx.auth;
138
- const parent = await query_cell_get(ctx, input.parent_id);
139
- if (!parent) {
140
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
141
- }
142
- const parent_grants = await query_cell_grant_list_for_cell(ctx, parent.id);
143
- if (!can_edit_cell(auth, parent, parent_grants)) {
144
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
145
- }
104
+ await require_editable_cell(ctx, auth, input.parent_id);
146
105
  const deleted = await query_cell_item_delete(ctx, input.parent_id, input.position);
147
106
  if (deleted) {
148
- deps.audit.emit(ctx, {
149
- event_type: 'cell_item_delete',
150
- actor_id: auth.actor.id,
151
- account_id: auth.account.id,
152
- ip: ctx.client_ip,
153
- metadata: {
154
- parent_id: deleted.parent_id,
155
- position: deleted.position,
156
- child_id: deleted.child_id
157
- }
107
+ emit_cell_audit(ctx, deps.audit, auth, 'cell_item_delete', {
108
+ parent_id: deleted.parent_id,
109
+ position: deleted.position,
110
+ child_id: deleted.child_id
158
111
  });
159
112
  }
160
113
  return { ok: true, deleted: deleted !== null };
@@ -174,26 +127,12 @@ export const create_cell_item_actions = (deps) => {
174
127
  // whose child the caller may view (strict target-visibility, in SQL
175
128
  // before the limit).
176
129
  if (input.parent_id !== undefined) {
177
- const parent = await query_cell_get(ctx, input.parent_id);
178
- if (!parent) {
179
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
180
- }
181
- const parent_grants = auth ? await query_cell_grant_list_for_cell(ctx, parent.id) : null;
182
- if (!can_view_cell(auth, parent, parent_grants)) {
183
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
184
- }
130
+ const parent = await require_viewable_cell(ctx, auth, input.parent_id);
185
131
  const rows = await query_cell_item_list_for_parent(ctx, cell_viewer_from_auth(auth), parent.id, { limit, position_after: input.position_after });
186
132
  return { items: rows.map(to_item_json) };
187
133
  }
188
134
  // Reverse listing: 2-layer authz. First, can_view_cell(child).
189
- const child = await query_cell_get(ctx, input.child_id);
190
- if (!child) {
191
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
192
- }
193
- const child_grants = auth ? await query_cell_grant_list_for_cell(ctx, child.id) : null;
194
- if (!can_view_cell(auth, child, child_grants)) {
195
- throw jsonrpc_errors.not_found('cell', { reason: ERROR_CELL_NOT_FOUND });
196
- }
135
+ const child = await require_viewable_cell(ctx, auth, input.child_id);
197
136
  // Then page the items whose parent the caller may view — filtered in
198
137
  // SQL before the limit, so hidden parents never crowd out visible ones,
199
138
  // and bounded so a heavily inbound-linked child can't force an
@@ -141,7 +141,7 @@ export interface AuthCleanupDeps extends QueryDeps {
141
141
  /**
142
142
  * Closes the connections of each session the sweep deletes. Pass the
143
143
  * closer the app's revocation handlers hold — `AppDeps.connection_closer`,
144
- * the `RealtimeCloser` over every transport it serves. Required: a sweep
144
+ * the `RealtimeCloser` over every registry it serves. Required: a sweep
145
145
  * with nothing to close through would strand the swept sessions'
146
146
  * connections. `noop_connection_closer` is for a database no other
147
147
  * process holds connections on — a sweep run beside a live server from
@@ -1 +1 @@
1
- {"version":3,"file":"cleanup.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cleanup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4GG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD;;;;;;;;;GASG;AACH,eAAO,MAAM,gCAAgC,QAAiB,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,SAAS;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;OAOG;IACH,KAAK,EAAE,YAAY,CAAC;IACpB;;;;;;;;;OASG;IACH,iBAAiB,EAAE,gBAAgB,CAAC;CACpC;AAED,+FAA+F;AAC/F,MAAM,WAAW,iBAAiB;IACjC,8EAA8E;IAC9E,gBAAgB,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,cAAc,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,wBAAwB,GAAU,MAAM,eAAe,KAAG,OAAO,CAAC,MAAM,CAqCpF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iCAAiC,GAAU,MAAM,eAAe,KAAG,OAAO,CAAC,MAAM,CAgC7F,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gBAAgB,GAAU,MAAM,eAAe,KAAG,OAAO,CAAC,iBAAiB,CAIvF,CAAC;AAEF,wCAAwC;AACxC,MAAM,WAAW,0BAA0B;IAC1C;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,kBAAkB,GAC9B,MAAM,eAAe,EACrB,UAAS,0BAA+B,KACtC,YAWD,CAAC"}
1
+ {"version":3,"file":"cleanup.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/cleanup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4GG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD;;;;;;;;;GASG;AACH,eAAO,MAAM,gCAAgC,QAAiB,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,SAAS;IACjD,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;OAOG;IACH,KAAK,EAAE,YAAY,CAAC;IACpB;;;;;;;;;OASG;IACH,iBAAiB,EAAE,gBAAgB,CAAC;CACpC;AAED,+FAA+F;AAC/F,MAAM,WAAW,iBAAiB;IACjC,8EAA8E;IAC9E,gBAAgB,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,cAAc,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,wBAAwB,GAAU,MAAM,eAAe,KAAG,OAAO,CAAC,MAAM,CAwCpF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,iCAAiC,GAAU,MAAM,eAAe,KAAG,OAAO,CAAC,MAAM,CAgC7F,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gBAAgB,GAAU,MAAM,eAAe,KAAG,OAAO,CAAC,iBAAiB,CAIvF,CAAC;AAEF,wCAAwC;AACxC,MAAM,WAAW,0BAA0B;IAC1C;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,kBAAkB,GAC9B,MAAM,eAAe,EACrB,UAAS,0BAA+B,KACtC,YAWD,CAAC"}
@@ -164,12 +164,15 @@ export const cleanup_expired_sessions = async (deps) => {
164
164
  // the transaction has settled. The closes are synchronous, so nothing can
165
165
  // interleave between the first and the last
166
166
  let closed_connections = 0;
167
- for (const session_token_hash of swept) {
167
+ for (const session_hash of swept) {
168
168
  try {
169
- closed_connections += deps.connection_closer.close_sockets_for_session(session_token_hash);
169
+ closed_connections += deps.connection_closer.close_connections({
170
+ kind: 'session',
171
+ session_hash
172
+ });
170
173
  }
171
174
  catch (error) {
172
- // keep going — one transport's failure must not leave another
175
+ // keep going — one registry's failure must not leave another
173
176
  // expired session's connections open
174
177
  deps.log.error("auth cleanup failed to close an expired session's connections:", error);
175
178
  }
@@ -5,9 +5,9 @@
5
5
  * A WebSocket or an SSE stream is authorized once, at open, and closed on
6
6
  * revocation by identity. Expiry has no revocation event: nothing is written
7
7
  * when a session or token passes its `expires_at`. So the auth middleware
8
- * computes the deadline once (`CREDENTIAL_DEADLINE_KEY`, gathered onto
9
- * `ResolvedAuth.credential_deadline`) and the transport closes the connection
10
- * when it arrives (`schedule_credential_deadline`).
8
+ * computes the deadline once (`ResolvedAuth.credential_deadline`) and the
9
+ * transport closes the connection when it arrives
10
+ * (`schedule_credential_deadline`).
11
11
  *
12
12
  * The deadline is the earliest of what the credential carries:
13
13
  *
@@ -5,9 +5,9 @@
5
5
  * A WebSocket or an SSE stream is authorized once, at open, and closed on
6
6
  * revocation by identity. Expiry has no revocation event: nothing is written
7
7
  * when a session or token passes its `expires_at`. So the auth middleware
8
- * computes the deadline once (`CREDENTIAL_DEADLINE_KEY`, gathered onto
9
- * `ResolvedAuth.credential_deadline`) and the transport closes the connection
10
- * when it arrives (`schedule_credential_deadline`).
8
+ * computes the deadline once (`ResolvedAuth.credential_deadline`) and the
9
+ * transport closes the connection when it arrives
10
+ * (`schedule_credential_deadline`).
11
11
  *
12
12
  * The deadline is the earliest of what the credential carries:
13
13
  *
@@ -6,16 +6,17 @@
6
6
  * Open-string registry on top so consumers can declare additional
7
7
  * credential types (e.g. `'sso_assertion'`, `'agent_token'`) without an
8
8
  * upstream release. `RoleSpec.required_credential_types` references
9
- * entries from this registry; v1 keeps the field informative-only
10
- * (consumed by `auth/middleware.ts` and the dispatcher). Mirrors the
9
+ * entries from this registry; v1 keeps the field informative-only —
10
+ * validated at construction, enforced nowhere; routes and actions gate
11
+ * with `auth.credential_types`. Mirrors the
11
12
  * open-registry pattern used for `RoleName`, `ScopeKindName`,
12
13
  * `GrantPathName`, and `AuditEventTypeName`.
13
14
  *
14
- * The Hono-side wire-validated `CredentialType` Zod enum (in
15
- * `hono_context.ts`) is the closed-set narrow type middleware sets on
16
- * the context; the constants below are the source of truth for those
17
- * three string values. Future builtin credential types added here
18
- * propagate to the wire enum by editing the import list.
15
+ * `BuiltinCredentialType` is the closed set middleware sets on the Hono
16
+ * context (`hono_context.ts`) and the audit log records — middleware only
17
+ * ever authenticates through a builtin. Consumer-declared types live in
18
+ * the registry `create_credential_type_schema` builds, consulted when
19
+ * validating `RoleSpec.required_credential_types`.
19
20
  *
20
21
  * @module
21
22
  */
@@ -1 +1 @@
1
- {"version":3,"file":"credential_type_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/credential_type_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,QAAgC,CAAC;AAExE,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,aAK7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAIpE,uCAAuC;AACvC,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,cAAc,CAAC;AAErD,yEAAyE;AACzE,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAE3D,0DAA0D;AAC1D,eAAO,MAAM,wBAAwB,mDAI3B,CAAC;AAEX,kDAAkD;AAClD,eAAO,MAAM,qBAAqB;;;;EAAmC,CAAC;AACtE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAa/E,CAAC;AAEH,qFAAqF;AACrF,MAAM,WAAW,0BAA0B;IAC1C;;;;;;OAMG;IACH,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC;;;OAGG;IACH,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,6BAA6B,GACzC,iBAAgB,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAM,KACrD,0BA2BF,CAAC"}
1
+ {"version":3,"file":"credential_type_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/credential_type_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,QAAgC,CAAC;AAExE,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,aAK7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAIpE,uCAAuC;AACvC,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,cAAc,CAAC;AAErD,yEAAyE;AACzE,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAE3D,0DAA0D;AAC1D,eAAO,MAAM,wBAAwB,mDAI3B,CAAC;AAEX,kDAAkD;AAClD,eAAO,MAAM,qBAAqB;;;;EAAmC,CAAC;AACtE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAa/E,CAAC;AAEH,qFAAqF;AACrF,MAAM,WAAW,0BAA0B;IAC1C;;;;;;OAMG;IACH,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAClC;;;OAGG;IACH,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,6BAA6B,GACzC,iBAAgB,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAM,KACrD,0BA2BF,CAAC"}
@@ -6,16 +6,17 @@
6
6
  * Open-string registry on top so consumers can declare additional
7
7
  * credential types (e.g. `'sso_assertion'`, `'agent_token'`) without an
8
8
  * upstream release. `RoleSpec.required_credential_types` references
9
- * entries from this registry; v1 keeps the field informative-only
10
- * (consumed by `auth/middleware.ts` and the dispatcher). Mirrors the
9
+ * entries from this registry; v1 keeps the field informative-only —
10
+ * validated at construction, enforced nowhere; routes and actions gate
11
+ * with `auth.credential_types`. Mirrors the
11
12
  * open-registry pattern used for `RoleName`, `ScopeKindName`,
12
13
  * `GrantPathName`, and `AuditEventTypeName`.
13
14
  *
14
- * The Hono-side wire-validated `CredentialType` Zod enum (in
15
- * `hono_context.ts`) is the closed-set narrow type middleware sets on
16
- * the context; the constants below are the source of truth for those
17
- * three string values. Future builtin credential types added here
18
- * propagate to the wire enum by editing the import list.
15
+ * `BuiltinCredentialType` is the closed set middleware sets on the Hono
16
+ * context (`hono_context.ts`) and the audit log records — middleware only
17
+ * ever authenticates through a builtin. Consumer-declared types live in
18
+ * the registry `create_credential_type_schema` builds, consulted when
19
+ * validating `RoleSpec.required_credential_types`.
19
20
  *
20
21
  * @module
21
22
  */
@@ -34,10 +34,15 @@ import { type DaemonTokenState } from './daemon_token.js';
34
34
  */
35
35
  export declare const resolve_keeper_account_id: (deps: QueryDeps) => Promise<string | null>;
36
36
  /**
37
- * Create middleware that authenticates via daemon token.
37
+ * Create middleware that authenticates via daemon token — the first leg of the
38
+ * auth middleware chain, as in the Rust spine's `resolve_auth_from_headers`.
39
+ *
40
+ * Being first, it starts the chain from a clean slate: it clears
41
+ * `RESOLVED_AUTH_KEY` on entry, so a layer mounted before the credential legs
42
+ * cannot pre-set an identity that every leg would then skip past.
38
43
  *
39
44
  * Checks the `X-Daemon-Token` header. Behavior:
40
- * - No header: pass through (don't touch existing context).
45
+ * - No header: pass through.
41
46
  * - Header present + `Origin` / `Referer` present: discard the credential
42
47
  * (browser context) and pass through — daemon tokens are loopback-only and
43
48
  * never carry an `Origin` in production, so a header-bearing request is not
@@ -56,9 +61,10 @@ export declare const resolve_keeper_account_id: (deps: QueryDeps) => Promise<str
56
61
  * mirrors the Rust spine's `resolve.rs` (`None`), so the request falls
57
62
  * through to anonymous and a daemon-gated action returns
58
63
  * `credential_type_required` downstream.
59
- * - Header present + valid + ok: set `c.var.auth_account_id =
60
- * state.keeper_account_id`, `CREDENTIAL_TYPE_KEY = 'daemon_token'`
61
- * (overrides any existing session / bearer identity).
64
+ * - Header present + valid + ok: set the `daemon_token` arm of `ResolvedAuth`
65
+ * (`RESOLVED_AUTH_KEY`) for the keeper account. The session and bearer legs
66
+ * after it see the request resolved and skip, so a cookie or bearer sent
67
+ * beside the daemon token is never looked up.
62
68
  *
63
69
  * Acting-actor resolution + `RequestContext` construction are deferred
64
70
  * to the dispatcher's authorization phase. Multi-actor keeper accounts
@@ -68,7 +74,7 @@ export declare const resolve_keeper_account_id: (deps: QueryDeps) => Promise<str
68
74
  * @param state - the daemon token runtime state
69
75
  * @param deps - query dependencies (pool-level db for keeper-account resolution)
70
76
  * @param log - the logger instance
71
- * @mutates Hono context - sets `ACCOUNT_ID_KEY`, `CREDENTIAL_TYPE_KEY`, and `AUTH_API_TOKEN_ID_KEY` on a valid token
77
+ * @mutates Hono context - clears `RESOLVED_AUTH_KEY` on entry, then sets it on a valid token
72
78
  */
73
79
  export declare const create_daemon_token_middleware: (state: DaemonTokenState, deps: QueryDeps, log: Logger) => MiddlewareHandler;
74
80
  //# sourceMappingURL=daemon_token_middleware.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"daemon_token_middleware.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/daemon_token_middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAYtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,GAAU,MAAM,SAAS,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAEtF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,8BAA8B,GAC1C,OAAO,gBAAgB,EACvB,MAAM,SAAS,EACf,KAAK,MAAM,KACT,iBA6EF,CAAC"}
1
+ {"version":3,"file":"daemon_token_middleware.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/daemon_token_middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAMtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,GAAU,MAAM,SAAS,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAEtF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,8BAA8B,GAC1C,OAAO,gBAAgB,EACvB,MAAM,SAAS,EACf,KAAK,MAAM,KACT,iBAkFF,CAAC"}