@fuzdev/fuz_app 0.54.0 → 0.56.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 (348) hide show
  1. package/dist/actions/CLAUDE.md +214 -103
  2. package/dist/actions/action_bridge.d.ts +8 -5
  3. package/dist/actions/action_bridge.d.ts.map +1 -1
  4. package/dist/actions/action_bridge.js +1 -11
  5. package/dist/actions/action_codegen.d.ts +32 -0
  6. package/dist/actions/action_codegen.d.ts.map +1 -1
  7. package/dist/actions/action_codegen.js +35 -15
  8. package/dist/actions/action_registry.d.ts.map +1 -1
  9. package/dist/actions/action_registry.js +5 -2
  10. package/dist/actions/action_rpc.d.ts +141 -22
  11. package/dist/actions/action_rpc.d.ts.map +1 -1
  12. package/dist/actions/action_rpc.js +106 -187
  13. package/dist/actions/action_spec.d.ts +55 -16
  14. package/dist/actions/action_spec.d.ts.map +1 -1
  15. package/dist/actions/action_spec.js +16 -11
  16. package/dist/actions/action_types.d.ts +28 -60
  17. package/dist/actions/action_types.d.ts.map +1 -1
  18. package/dist/actions/action_types.js +13 -5
  19. package/dist/actions/broadcast_api.d.ts +2 -2
  20. package/dist/actions/broadcast_api.js +2 -2
  21. package/dist/actions/compile_action_registry.d.ts +50 -0
  22. package/dist/actions/compile_action_registry.d.ts.map +1 -0
  23. package/dist/actions/compile_action_registry.js +69 -0
  24. package/dist/actions/heartbeat.d.ts +8 -4
  25. package/dist/actions/heartbeat.d.ts.map +1 -1
  26. package/dist/actions/heartbeat.js +5 -4
  27. package/dist/actions/perform_action.d.ts +145 -0
  28. package/dist/actions/perform_action.d.ts.map +1 -0
  29. package/dist/actions/perform_action.js +258 -0
  30. package/dist/actions/register_action_ws.d.ts +46 -40
  31. package/dist/actions/register_action_ws.d.ts.map +1 -1
  32. package/dist/actions/register_action_ws.js +101 -159
  33. package/dist/actions/register_ws_endpoint.d.ts +15 -10
  34. package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
  35. package/dist/actions/register_ws_endpoint.js +54 -7
  36. package/dist/actions/transports.d.ts.map +1 -1
  37. package/dist/actions/transports.js +0 -4
  38. package/dist/actions/transports_ws_auth_guard.d.ts +1 -1
  39. package/dist/actions/transports_ws_auth_guard.js +1 -1
  40. package/dist/actions/transports_ws_backend.d.ts +1 -1
  41. package/dist/actions/transports_ws_backend.js +1 -1
  42. package/dist/auth/CLAUDE.md +794 -410
  43. package/dist/auth/account_action_specs.d.ts +28 -7
  44. package/dist/auth/account_action_specs.d.ts.map +1 -1
  45. package/dist/auth/account_action_specs.js +7 -7
  46. package/dist/auth/account_actions.d.ts +7 -13
  47. package/dist/auth/account_actions.d.ts.map +1 -1
  48. package/dist/auth/account_actions.js +26 -35
  49. package/dist/auth/account_queries.d.ts +52 -16
  50. package/dist/auth/account_queries.d.ts.map +1 -1
  51. package/dist/auth/account_queries.js +87 -38
  52. package/dist/auth/account_routes.d.ts +9 -11
  53. package/dist/auth/account_routes.d.ts.map +1 -1
  54. package/dist/auth/account_routes.js +118 -46
  55. package/dist/auth/account_schema.d.ts +46 -35
  56. package/dist/auth/account_schema.d.ts.map +1 -1
  57. package/dist/auth/account_schema.js +21 -28
  58. package/dist/auth/admin_action_specs.d.ts +100 -32
  59. package/dist/auth/admin_action_specs.d.ts.map +1 -1
  60. package/dist/auth/admin_action_specs.js +64 -33
  61. package/dist/auth/admin_actions.d.ts +13 -19
  62. package/dist/auth/admin_actions.d.ts.map +1 -1
  63. package/dist/auth/admin_actions.js +37 -41
  64. package/dist/auth/audit_emitter.d.ts +160 -0
  65. package/dist/auth/audit_emitter.d.ts.map +1 -0
  66. package/dist/auth/audit_emitter.js +83 -0
  67. package/dist/auth/audit_log_queries.d.ts +17 -48
  68. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  69. package/dist/auth/audit_log_queries.js +20 -56
  70. package/dist/auth/audit_log_routes.d.ts +1 -1
  71. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  72. package/dist/auth/audit_log_routes.js +7 -3
  73. package/dist/auth/audit_log_schema.d.ts +92 -32
  74. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  75. package/dist/auth/audit_log_schema.js +75 -46
  76. package/dist/auth/auth_guard_resolver.d.ts +44 -0
  77. package/dist/auth/auth_guard_resolver.d.ts.map +1 -0
  78. package/dist/auth/auth_guard_resolver.js +56 -0
  79. package/dist/auth/bearer_auth.d.ts +9 -7
  80. package/dist/auth/bearer_auth.d.ts.map +1 -1
  81. package/dist/auth/bearer_auth.js +13 -21
  82. package/dist/auth/bootstrap_account.d.ts +7 -7
  83. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  84. package/dist/auth/bootstrap_account.js +7 -7
  85. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  86. package/dist/auth/bootstrap_routes.js +11 -10
  87. package/dist/auth/cleanup.d.ts +20 -26
  88. package/dist/auth/cleanup.d.ts.map +1 -1
  89. package/dist/auth/cleanup.js +33 -42
  90. package/dist/auth/credential_type_schema.d.ts +115 -0
  91. package/dist/auth/credential_type_schema.d.ts.map +1 -0
  92. package/dist/auth/credential_type_schema.js +127 -0
  93. package/dist/auth/daemon_token_middleware.d.ts +23 -11
  94. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  95. package/dist/auth/daemon_token_middleware.js +28 -22
  96. package/dist/auth/ddl.d.ts +2 -2
  97. package/dist/auth/ddl.d.ts.map +1 -1
  98. package/dist/auth/ddl.js +6 -6
  99. package/dist/auth/deps.d.ts +7 -18
  100. package/dist/auth/deps.d.ts.map +1 -1
  101. package/dist/auth/grant_path_schema.d.ts +117 -0
  102. package/dist/auth/grant_path_schema.d.ts.map +1 -0
  103. package/dist/auth/grant_path_schema.js +137 -0
  104. package/dist/auth/invite_queries.d.ts +12 -1
  105. package/dist/auth/invite_queries.d.ts.map +1 -1
  106. package/dist/auth/invite_queries.js +12 -1
  107. package/dist/auth/invite_schema.d.ts +1 -1
  108. package/dist/auth/invite_schema.d.ts.map +1 -1
  109. package/dist/auth/invite_schema.js +1 -1
  110. package/dist/auth/middleware.d.ts.map +1 -1
  111. package/dist/auth/middleware.js +9 -4
  112. package/dist/auth/migrations.d.ts +37 -14
  113. package/dist/auth/migrations.d.ts.map +1 -1
  114. package/dist/auth/migrations.js +79 -32
  115. package/dist/auth/request_context.d.ts +331 -61
  116. package/dist/auth/request_context.d.ts.map +1 -1
  117. package/dist/auth/request_context.js +378 -95
  118. package/dist/auth/{permit_offer_action_specs.d.ts → role_grant_offer_action_specs.d.ts} +163 -94
  119. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -0
  120. package/dist/auth/role_grant_offer_action_specs.js +262 -0
  121. package/dist/auth/role_grant_offer_actions.d.ts +104 -0
  122. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -0
  123. package/dist/auth/role_grant_offer_actions.js +473 -0
  124. package/dist/auth/{permit_offer_notifications.d.ts → role_grant_offer_notifications.d.ts} +90 -70
  125. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -0
  126. package/dist/auth/role_grant_offer_notifications.js +182 -0
  127. package/dist/auth/role_grant_offer_queries.d.ts +242 -0
  128. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -0
  129. package/dist/auth/role_grant_offer_queries.js +533 -0
  130. package/dist/auth/role_grant_offer_schema.d.ts +150 -0
  131. package/dist/auth/role_grant_offer_schema.d.ts.map +1 -0
  132. package/dist/auth/{permit_offer_schema.js → role_grant_offer_schema.js} +60 -36
  133. package/dist/auth/role_grant_queries.d.ts +231 -0
  134. package/dist/auth/role_grant_queries.d.ts.map +1 -0
  135. package/dist/auth/role_grant_queries.js +320 -0
  136. package/dist/auth/role_schema.d.ts +150 -40
  137. package/dist/auth/role_schema.d.ts.map +1 -1
  138. package/dist/auth/role_schema.js +144 -45
  139. package/dist/auth/scope_kind_schema.d.ts +96 -0
  140. package/dist/auth/scope_kind_schema.d.ts.map +1 -0
  141. package/dist/auth/scope_kind_schema.js +94 -0
  142. package/dist/auth/self_service_role_action_specs.d.ts +6 -1
  143. package/dist/auth/self_service_role_action_specs.d.ts.map +1 -1
  144. package/dist/auth/self_service_role_action_specs.js +3 -1
  145. package/dist/auth/self_service_role_actions.d.ts +34 -27
  146. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  147. package/dist/auth/self_service_role_actions.js +68 -48
  148. package/dist/auth/session_cookie.d.ts +43 -6
  149. package/dist/auth/session_cookie.d.ts.map +1 -1
  150. package/dist/auth/session_cookie.js +31 -5
  151. package/dist/auth/session_middleware.d.ts +37 -3
  152. package/dist/auth/session_middleware.d.ts.map +1 -1
  153. package/dist/auth/session_middleware.js +33 -7
  154. package/dist/auth/signup_routes.d.ts.map +1 -1
  155. package/dist/auth/signup_routes.js +48 -19
  156. package/dist/auth/standard_action_specs.d.ts +2 -2
  157. package/dist/auth/standard_action_specs.js +4 -4
  158. package/dist/auth/standard_rpc_actions.d.ts +23 -19
  159. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  160. package/dist/auth/standard_rpc_actions.js +12 -12
  161. package/dist/db/migrate.d.ts +12 -8
  162. package/dist/db/migrate.d.ts.map +1 -1
  163. package/dist/db/migrate.js +10 -7
  164. package/dist/dev/setup.d.ts +2 -2
  165. package/dist/dev/setup.d.ts.map +1 -1
  166. package/dist/dev/setup.js +9 -7
  167. package/dist/env/load.d.ts +1 -1
  168. package/dist/env/load.js +1 -1
  169. package/dist/hono_context.d.ts +64 -5
  170. package/dist/hono_context.d.ts.map +1 -1
  171. package/dist/hono_context.js +38 -2
  172. package/dist/http/CLAUDE.md +264 -87
  173. package/dist/http/auth_shape.d.ts +191 -0
  174. package/dist/http/auth_shape.d.ts.map +1 -0
  175. package/dist/http/auth_shape.js +237 -0
  176. package/dist/http/common_routes.js +3 -3
  177. package/dist/http/db_routes.d.ts +4 -0
  178. package/dist/http/db_routes.d.ts.map +1 -1
  179. package/dist/http/db_routes.js +44 -7
  180. package/dist/http/error_schemas.d.ts +132 -19
  181. package/dist/http/error_schemas.d.ts.map +1 -1
  182. package/dist/http/error_schemas.js +132 -40
  183. package/dist/http/jsonrpc_errors.d.ts +27 -2
  184. package/dist/http/jsonrpc_errors.d.ts.map +1 -1
  185. package/dist/http/jsonrpc_errors.js +26 -2
  186. package/dist/http/pending_effects.d.ts +71 -18
  187. package/dist/http/pending_effects.d.ts.map +1 -1
  188. package/dist/http/pending_effects.js +87 -18
  189. package/dist/http/proxy.d.ts +52 -5
  190. package/dist/http/proxy.d.ts.map +1 -1
  191. package/dist/http/proxy.js +92 -14
  192. package/dist/http/route_spec.d.ts +113 -41
  193. package/dist/http/route_spec.d.ts.map +1 -1
  194. package/dist/http/route_spec.js +130 -52
  195. package/dist/http/schema_helpers.d.ts +3 -2
  196. package/dist/http/schema_helpers.d.ts.map +1 -1
  197. package/dist/http/schema_helpers.js +9 -2
  198. package/dist/http/surface.d.ts +2 -1
  199. package/dist/http/surface.d.ts.map +1 -1
  200. package/dist/http/surface.js +1 -2
  201. package/dist/http/surface_query.d.ts +39 -35
  202. package/dist/http/surface_query.d.ts.map +1 -1
  203. package/dist/http/surface_query.js +79 -36
  204. package/dist/primitive_schemas.d.ts +39 -0
  205. package/dist/primitive_schemas.d.ts.map +1 -0
  206. package/dist/primitive_schemas.js +40 -0
  207. package/dist/realtime/sse_auth_guard.d.ts +5 -5
  208. package/dist/realtime/sse_auth_guard.js +9 -9
  209. package/dist/runtime/mock.d.ts +1 -1
  210. package/dist/runtime/mock.js +1 -1
  211. package/dist/server/app_backend.d.ts +14 -11
  212. package/dist/server/app_backend.d.ts.map +1 -1
  213. package/dist/server/app_backend.js +12 -8
  214. package/dist/server/app_server.d.ts +7 -7
  215. package/dist/server/app_server.d.ts.map +1 -1
  216. package/dist/server/app_server.js +36 -31
  217. package/dist/server/validate_nginx.d.ts +1 -1
  218. package/dist/server/validate_nginx.js +1 -1
  219. package/dist/testing/CLAUDE.md +73 -55
  220. package/dist/testing/admin_integration.d.ts +5 -6
  221. package/dist/testing/admin_integration.d.ts.map +1 -1
  222. package/dist/testing/admin_integration.js +100 -96
  223. package/dist/testing/adversarial_headers.js +1 -1
  224. package/dist/testing/app_server.d.ts +11 -14
  225. package/dist/testing/app_server.d.ts.map +1 -1
  226. package/dist/testing/app_server.js +18 -17
  227. package/dist/testing/assertions.d.ts.map +1 -1
  228. package/dist/testing/assertions.js +2 -1
  229. package/dist/testing/attack_surface.d.ts.map +1 -1
  230. package/dist/testing/attack_surface.js +15 -9
  231. package/dist/testing/audit_completeness.d.ts +2 -2
  232. package/dist/testing/audit_completeness.d.ts.map +1 -1
  233. package/dist/testing/audit_completeness.js +53 -39
  234. package/dist/testing/auth_apps.d.ts +5 -4
  235. package/dist/testing/auth_apps.d.ts.map +1 -1
  236. package/dist/testing/auth_apps.js +28 -22
  237. package/dist/testing/data_exposure.d.ts.map +1 -1
  238. package/dist/testing/data_exposure.js +5 -5
  239. package/dist/testing/db.d.ts +1 -1
  240. package/dist/testing/db.d.ts.map +1 -1
  241. package/dist/testing/db.js +4 -4
  242. package/dist/testing/db_entities.d.ts +22 -0
  243. package/dist/testing/db_entities.d.ts.map +1 -0
  244. package/dist/testing/db_entities.js +28 -0
  245. package/dist/testing/entities.d.ts +10 -8
  246. package/dist/testing/entities.d.ts.map +1 -1
  247. package/dist/testing/entities.js +22 -18
  248. package/dist/testing/integration.d.ts.map +1 -1
  249. package/dist/testing/integration.js +13 -14
  250. package/dist/testing/integration_helpers.d.ts +8 -6
  251. package/dist/testing/integration_helpers.d.ts.map +1 -1
  252. package/dist/testing/integration_helpers.js +29 -23
  253. package/dist/testing/middleware.d.ts +15 -11
  254. package/dist/testing/middleware.d.ts.map +1 -1
  255. package/dist/testing/middleware.js +75 -32
  256. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  257. package/dist/testing/rpc_attack_surface.js +40 -24
  258. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  259. package/dist/testing/rpc_helpers.js +3 -1
  260. package/dist/testing/rpc_round_trip.d.ts +1 -1
  261. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  262. package/dist/testing/rpc_round_trip.js +14 -13
  263. package/dist/testing/sse_round_trip.d.ts +3 -4
  264. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  265. package/dist/testing/sse_round_trip.js +7 -11
  266. package/dist/testing/standard.d.ts +1 -1
  267. package/dist/testing/stubs.d.ts +25 -0
  268. package/dist/testing/stubs.d.ts.map +1 -1
  269. package/dist/testing/stubs.js +43 -2
  270. package/dist/testing/surface_invariants.d.ts +2 -2
  271. package/dist/testing/ws_round_trip.d.ts +12 -13
  272. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  273. package/dist/testing/ws_round_trip.js +24 -12
  274. package/dist/ui/AdminAccounts.svelte +23 -20
  275. package/dist/ui/AdminOverview.svelte +15 -13
  276. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
  277. package/dist/ui/{AdminPermitHistory.svelte → AdminRoleGrantHistory.svelte} +12 -12
  278. package/dist/ui/AdminRoleGrantHistory.svelte.d.ts +4 -0
  279. package/dist/ui/AdminRoleGrantHistory.svelte.d.ts.map +1 -0
  280. package/dist/ui/BootstrapForm.svelte +1 -1
  281. package/dist/ui/CLAUDE.md +65 -59
  282. package/dist/ui/{PermitOfferForm.svelte → RoleGrantOfferForm.svelte} +37 -22
  283. package/dist/ui/RoleGrantOfferForm.svelte.d.ts +20 -0
  284. package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -0
  285. package/dist/ui/{PermitOfferHistory.svelte → RoleGrantOfferHistory.svelte} +12 -12
  286. package/dist/ui/{PermitOfferHistory.svelte.d.ts → RoleGrantOfferHistory.svelte.d.ts} +4 -4
  287. package/dist/ui/RoleGrantOfferHistory.svelte.d.ts.map +1 -0
  288. package/dist/ui/{PermitOfferInbox.svelte → RoleGrantOfferInbox.svelte} +14 -14
  289. package/dist/ui/{PermitOfferInbox.svelte.d.ts → RoleGrantOfferInbox.svelte.d.ts} +4 -4
  290. package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -0
  291. package/dist/ui/SignupForm.svelte +1 -1
  292. package/dist/ui/SurfaceExplorer.svelte +35 -15
  293. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
  294. package/dist/ui/account_sessions_state.svelte.d.ts +2 -3
  295. package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
  296. package/dist/ui/account_sessions_state.svelte.js +2 -3
  297. package/dist/ui/admin_accounts_state.svelte.d.ts +25 -18
  298. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
  299. package/dist/ui/admin_accounts_state.svelte.js +28 -17
  300. package/dist/ui/admin_rpc_adapters.d.ts +20 -20
  301. package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
  302. package/dist/ui/admin_rpc_adapters.js +17 -17
  303. package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
  304. package/dist/ui/admin_sessions_state.svelte.js +2 -2
  305. package/dist/ui/audit_log_state.svelte.d.ts +7 -7
  306. package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
  307. package/dist/ui/audit_log_state.svelte.js +6 -6
  308. package/dist/ui/auth_state.svelte.d.ts +3 -3
  309. package/dist/ui/auth_state.svelte.d.ts.map +1 -1
  310. package/dist/ui/auth_state.svelte.js +6 -6
  311. package/dist/ui/format_scope.d.ts +2 -2
  312. package/dist/ui/format_scope.js +2 -2
  313. package/dist/ui/{permit_offers_state.svelte.d.ts → role_grant_offers_state.svelte.d.ts} +39 -31
  314. package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -0
  315. package/dist/ui/{permit_offers_state.svelte.js → role_grant_offers_state.svelte.js} +25 -19
  316. package/dist/ui/ui_format.js +2 -2
  317. package/package.json +3 -3
  318. package/dist/auth/permit_offer_action_specs.d.ts.map +0 -1
  319. package/dist/auth/permit_offer_action_specs.js +0 -227
  320. package/dist/auth/permit_offer_actions.d.ts +0 -110
  321. package/dist/auth/permit_offer_actions.d.ts.map +0 -1
  322. package/dist/auth/permit_offer_actions.js +0 -452
  323. package/dist/auth/permit_offer_notifications.d.ts.map +0 -1
  324. package/dist/auth/permit_offer_notifications.js +0 -182
  325. package/dist/auth/permit_offer_queries.d.ts +0 -183
  326. package/dist/auth/permit_offer_queries.d.ts.map +0 -1
  327. package/dist/auth/permit_offer_queries.js +0 -408
  328. package/dist/auth/permit_offer_schema.d.ts +0 -103
  329. package/dist/auth/permit_offer_schema.d.ts.map +0 -1
  330. package/dist/auth/permit_queries.d.ts +0 -210
  331. package/dist/auth/permit_queries.d.ts.map +0 -1
  332. package/dist/auth/permit_queries.js +0 -294
  333. package/dist/auth/require_keeper.d.ts +0 -20
  334. package/dist/auth/require_keeper.d.ts.map +0 -1
  335. package/dist/auth/require_keeper.js +0 -35
  336. package/dist/auth/route_guards.d.ts +0 -21
  337. package/dist/auth/route_guards.d.ts.map +0 -1
  338. package/dist/auth/route_guards.js +0 -32
  339. package/dist/auth/session_lifecycle.d.ts +0 -37
  340. package/dist/auth/session_lifecycle.d.ts.map +0 -1
  341. package/dist/auth/session_lifecycle.js +0 -29
  342. package/dist/ui/AdminPermitHistory.svelte.d.ts +0 -4
  343. package/dist/ui/AdminPermitHistory.svelte.d.ts.map +0 -1
  344. package/dist/ui/PermitOfferForm.svelte.d.ts +0 -14
  345. package/dist/ui/PermitOfferForm.svelte.d.ts.map +0 -1
  346. package/dist/ui/PermitOfferHistory.svelte.d.ts.map +0 -1
  347. package/dist/ui/PermitOfferInbox.svelte.d.ts.map +0 -1
  348. package/dist/ui/permit_offers_state.svelte.d.ts.map +0 -1
@@ -90,7 +90,10 @@ export declare const account_verify_action_spec: {
90
90
  method: string;
91
91
  kind: "request_response";
92
92
  initiator: "frontend";
93
- auth: "authenticated";
93
+ auth: {
94
+ account: "required";
95
+ actor: "none";
96
+ };
94
97
  side_effects: false;
95
98
  input: z.ZodVoid;
96
99
  output: z.ZodObject<{
@@ -107,7 +110,10 @@ export declare const account_session_list_action_spec: {
107
110
  method: string;
108
111
  kind: "request_response";
109
112
  initiator: "frontend";
110
- auth: "authenticated";
113
+ auth: {
114
+ account: "required";
115
+ actor: "none";
116
+ };
111
117
  side_effects: false;
112
118
  input: z.ZodVoid;
113
119
  output: z.ZodObject<{
@@ -126,7 +132,10 @@ export declare const account_session_revoke_action_spec: {
126
132
  method: string;
127
133
  kind: "request_response";
128
134
  initiator: "frontend";
129
- auth: "authenticated";
135
+ auth: {
136
+ account: "required";
137
+ actor: "none";
138
+ };
130
139
  side_effects: true;
131
140
  input: z.ZodObject<{
132
141
  session_id: z.ZodString;
@@ -142,7 +151,10 @@ export declare const account_session_revoke_all_action_spec: {
142
151
  method: string;
143
152
  kind: "request_response";
144
153
  initiator: "frontend";
145
- auth: "authenticated";
154
+ auth: {
155
+ account: "required";
156
+ actor: "none";
157
+ };
146
158
  side_effects: true;
147
159
  input: z.ZodVoid;
148
160
  output: z.ZodObject<{
@@ -156,7 +168,10 @@ export declare const account_token_create_action_spec: {
156
168
  method: string;
157
169
  kind: "request_response";
158
170
  initiator: "frontend";
159
- auth: "authenticated";
171
+ auth: {
172
+ account: "required";
173
+ actor: "none";
174
+ };
160
175
  side_effects: true;
161
176
  input: z.ZodObject<{
162
177
  name: z.ZodDefault<z.ZodString>;
@@ -174,7 +189,10 @@ export declare const account_token_list_action_spec: {
174
189
  method: string;
175
190
  kind: "request_response";
176
191
  initiator: "frontend";
177
- auth: "authenticated";
192
+ auth: {
193
+ account: "required";
194
+ actor: "none";
195
+ };
178
196
  side_effects: false;
179
197
  input: z.ZodVoid;
180
198
  output: z.ZodObject<{
@@ -195,7 +213,10 @@ export declare const account_token_revoke_action_spec: {
195
213
  method: string;
196
214
  kind: "request_response";
197
215
  initiator: "frontend";
198
- auth: "authenticated";
216
+ auth: {
217
+ account: "required";
218
+ actor: "none";
219
+ };
199
220
  side_effects: true;
200
221
  input: z.ZodObject<{
201
222
  token_id: z.ZodString;
@@ -1 +1 @@
1
- {"version":3,"file":"account_action_specs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/account_action_specs.ts"],"names":[],"mappings":"AAAA;;;;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AAwB,EAAE,KAAK,CAAC,yBAAyB,CAQrE,CAAC"}
@@ -70,7 +70,7 @@ export const account_verify_action_spec = {
70
70
  method: 'account_verify',
71
71
  kind: 'request_response',
72
72
  initiator: 'frontend',
73
- auth: 'authenticated',
73
+ auth: { account: 'required', actor: 'none' },
74
74
  side_effects: false,
75
75
  input: VerifyInput,
76
76
  output: SessionAccountJson,
@@ -81,7 +81,7 @@ export const account_session_list_action_spec = {
81
81
  method: 'account_session_list',
82
82
  kind: 'request_response',
83
83
  initiator: 'frontend',
84
- auth: 'authenticated',
84
+ auth: { account: 'required', actor: 'none' },
85
85
  side_effects: false,
86
86
  input: SessionListInput,
87
87
  output: SessionListOutput,
@@ -92,7 +92,7 @@ export const account_session_revoke_action_spec = {
92
92
  method: 'account_session_revoke',
93
93
  kind: 'request_response',
94
94
  initiator: 'frontend',
95
- auth: 'authenticated',
95
+ auth: { account: 'required', actor: 'none' },
96
96
  side_effects: true,
97
97
  input: SessionRevokeInput,
98
98
  output: SessionRevokeOutput,
@@ -103,7 +103,7 @@ export const account_session_revoke_all_action_spec = {
103
103
  method: 'account_session_revoke_all',
104
104
  kind: 'request_response',
105
105
  initiator: 'frontend',
106
- auth: 'authenticated',
106
+ auth: { account: 'required', actor: 'none' },
107
107
  side_effects: true,
108
108
  input: SessionRevokeAllInput,
109
109
  output: SessionRevokeAllOutput,
@@ -114,7 +114,7 @@ export const account_token_create_action_spec = {
114
114
  method: 'account_token_create',
115
115
  kind: 'request_response',
116
116
  initiator: 'frontend',
117
- auth: 'authenticated',
117
+ auth: { account: 'required', actor: 'none' },
118
118
  side_effects: true,
119
119
  input: TokenCreateInput,
120
120
  output: TokenCreateOutput,
@@ -125,7 +125,7 @@ export const account_token_list_action_spec = {
125
125
  method: 'account_token_list',
126
126
  kind: 'request_response',
127
127
  initiator: 'frontend',
128
- auth: 'authenticated',
128
+ auth: { account: 'required', actor: 'none' },
129
129
  side_effects: false,
130
130
  input: TokenListInput,
131
131
  output: TokenListOutput,
@@ -136,7 +136,7 @@ export const account_token_revoke_action_spec = {
136
136
  method: 'account_token_revoke',
137
137
  kind: 'request_response',
138
138
  initiator: 'frontend',
139
- auth: 'authenticated',
139
+ auth: { account: 'required', actor: 'none' },
140
140
  side_effects: true,
141
141
  input: TokenRevokeInput,
142
142
  output: TokenRevokeOutput,
@@ -10,8 +10,9 @@
10
10
  * `account_token_revoke`.
11
11
  *
12
12
  * The action specs themselves live in `auth/account_action_specs.ts`. Every spec
13
- * declares `auth: 'authenticated'` so the dispatcher enforces auth before the
14
- * handler runs. Revoke operations are account-scoped (via
13
+ * declares `auth: {account: 'required', actor: 'none'}` so the dispatcher
14
+ * enforces account-grain auth before the handler runs. Revoke operations are
15
+ * account-scoped (via
15
16
  * `query_session_revoke_for_account` / `query_revoke_api_token_for_account`)
16
17
  * so passing another account's session or token id returns `revoked: false`
17
18
  * rather than revealing whether the id exists.
@@ -33,21 +34,14 @@ export interface AccountActionOptions {
33
34
  */
34
35
  max_tokens?: number | null;
35
36
  }
36
- /**
37
- * Dependencies for `create_account_actions`.
38
- *
39
- * Shares shape with `AdminActionDeps` / `PermitOfferActionDeps` so consumers
40
- * can pass the same deps to every action factory. `audit_log_config` is
41
- * carried through `AppDeps` and consumed by `audit_log_fire_and_forget`;
42
- * absent → defaults to `BUILTIN_AUDIT_LOG_CONFIG`.
43
- */
44
- export type AccountActionDeps = Pick<RouteFactoryDeps, 'log' | 'on_audit_event' | 'audit_log_config'>;
45
37
  /**
46
38
  * Create the self-service account RPC actions.
47
39
  *
48
- * @param deps - `AccountActionDeps` slice of `AppDeps` (`log`, `on_audit_event`, optional `audit_log_config`)
40
+ * @param deps - `RouteFactoryDeps` (`log`, `audit`, …). `audit.emit` writes
41
+ * audit rows via the captured pool; the bound emitter encapsulates
42
+ * `on_audit_event` fan-out and the optional `AuditLogConfig`.
49
43
  * @param options - per-factory configuration
50
44
  * @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
51
45
  */
52
- export declare const create_account_actions: (deps: AccountActionDeps, options?: AccountActionOptions) => Array<RpcAction>;
46
+ export declare const create_account_actions: (deps: Pick<RouteFactoryDeps, "log" | "audit">, options?: AccountActionOptions) => Array<RpcAction>;
53
47
  //# sourceMappingURL=account_actions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"account_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/account_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAiC,KAAK,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAgBxF,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAwBhD,4CAA4C;AAC5C,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CACnC,gBAAgB,EAChB,KAAK,GAAG,gBAAgB,GAAG,kBAAkB,CAC7C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,iBAAiB,EACvB,UAAS,oBAAyB,KAChC,KAAK,CAAC,SAAS,CAyHjB,CAAC"}
1
+ {"version":3,"file":"account_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/account_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAqC,KAAK,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAe5F,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAwBhD,4CAA4C;AAC5C,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,OAAO,CAAC,EAC7C,UAAS,oBAAyB,KAChC,KAAK,CAAC,SAAS,CAsGjB,CAAC"}
@@ -10,8 +10,9 @@
10
10
  * `account_token_revoke`.
11
11
  *
12
12
  * The action specs themselves live in `auth/account_action_specs.ts`. Every spec
13
- * declares `auth: 'authenticated'` so the dispatcher enforces auth before the
14
- * handler runs. Revoke operations are account-scoped (via
13
+ * declares `auth: {account: 'required', actor: 'none'}` so the dispatcher
14
+ * enforces account-grain auth before the handler runs. Revoke operations are
15
+ * account-scoped (via
15
16
  * `query_session_revoke_for_account` / `query_revoke_api_token_for_account`)
16
17
  * so passing another account's session or token id returns `revoked: false`
17
18
  * rather than revealing whether the id exists.
@@ -26,84 +27,74 @@ import { to_session_account } from './account_schema.js';
26
27
  import { query_session_list_for_account, query_session_revoke_for_account, query_session_revoke_all_for_account, } from './session_queries.js';
27
28
  import { query_api_token_enforce_limit, query_api_token_list_for_account, query_create_api_token, query_revoke_api_token_for_account, } from './api_token_queries.js';
28
29
  import { generate_api_token } from './api_token.js';
29
- import { audit_log_fire_and_forget } from './audit_log_queries.js';
30
30
  import { DEFAULT_MAX_TOKENS } from './account_routes.js';
31
31
  import { account_verify_action_spec, account_session_list_action_spec, account_session_revoke_action_spec, account_session_revoke_all_action_spec, account_token_create_action_spec, account_token_list_action_spec, account_token_revoke_action_spec, } from './account_action_specs.js';
32
32
  /**
33
33
  * Create the self-service account RPC actions.
34
34
  *
35
- * @param deps - `AccountActionDeps` slice of `AppDeps` (`log`, `on_audit_event`, optional `audit_log_config`)
35
+ * @param deps - `RouteFactoryDeps` (`log`, `audit`, …). `audit.emit` writes
36
+ * audit rows via the captured pool; the bound emitter encapsulates
37
+ * `on_audit_event` fan-out and the optional `AuditLogConfig`.
36
38
  * @param options - per-factory configuration
37
39
  * @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
38
40
  */
39
41
  export const create_account_actions = (deps, options = {}) => {
40
42
  const { max_tokens = DEFAULT_MAX_TOKENS } = options;
41
43
  const verify_handler = (_input, ctx) => {
42
- const auth = ctx.auth;
43
- return to_session_account(auth.account);
44
+ return to_session_account(ctx.auth.account);
44
45
  };
45
46
  const session_list_handler = async (_input, ctx) => {
46
- const auth = ctx.auth;
47
- const sessions = await query_session_list_for_account(ctx, auth.account.id);
47
+ const sessions = await query_session_list_for_account(ctx, ctx.auth.account.id);
48
48
  return { sessions };
49
49
  };
50
50
  const session_revoke_handler = async (input, ctx) => {
51
- const auth = ctx.auth;
52
- const revoked = await query_session_revoke_for_account(ctx, input.session_id, auth.account.id);
53
- void audit_log_fire_and_forget(ctx, {
51
+ const revoked = await query_session_revoke_for_account(ctx, input.session_id, ctx.auth.account.id);
52
+ deps.audit.emit(ctx, {
54
53
  event_type: 'session_revoke',
55
54
  outcome: revoked ? 'success' : 'failure',
56
- actor_id: auth.actor.id,
57
- account_id: auth.account.id,
55
+ account_id: ctx.auth.account.id,
58
56
  ip: ctx.client_ip,
59
57
  metadata: { session_id: input.session_id },
60
- }, deps);
58
+ });
61
59
  return { ok: true, revoked };
62
60
  };
63
61
  const session_revoke_all_handler = async (_input, ctx) => {
64
- const auth = ctx.auth;
65
- const count = await query_session_revoke_all_for_account(ctx, auth.account.id);
66
- void audit_log_fire_and_forget(ctx, {
62
+ const count = await query_session_revoke_all_for_account(ctx, ctx.auth.account.id);
63
+ deps.audit.emit(ctx, {
67
64
  event_type: 'session_revoke_all',
68
- actor_id: auth.actor.id,
69
- account_id: auth.account.id,
65
+ account_id: ctx.auth.account.id,
70
66
  ip: ctx.client_ip,
71
67
  metadata: { count },
72
- }, deps);
68
+ });
73
69
  return { ok: true, count };
74
70
  };
75
71
  const token_create_handler = async (input, ctx) => {
76
- const auth = ctx.auth;
77
72
  const { token, id, token_hash } = generate_api_token();
78
- await query_create_api_token(ctx, id, auth.account.id, input.name, token_hash);
73
+ await query_create_api_token(ctx, id, ctx.auth.account.id, input.name, token_hash);
79
74
  if (max_tokens != null) {
80
- await query_api_token_enforce_limit(ctx, auth.account.id, max_tokens);
75
+ await query_api_token_enforce_limit(ctx, ctx.auth.account.id, max_tokens);
81
76
  }
82
- void audit_log_fire_and_forget(ctx, {
77
+ deps.audit.emit(ctx, {
83
78
  event_type: 'token_create',
84
- actor_id: auth.actor.id,
85
- account_id: auth.account.id,
79
+ account_id: ctx.auth.account.id,
86
80
  ip: ctx.client_ip,
87
81
  metadata: { token_id: id, name: input.name },
88
- }, deps);
82
+ });
89
83
  return { ok: true, token, id, name: input.name };
90
84
  };
91
85
  const token_list_handler = async (_input, ctx) => {
92
- const auth = ctx.auth;
93
- const tokens = await query_api_token_list_for_account(ctx, auth.account.id);
86
+ const tokens = await query_api_token_list_for_account(ctx, ctx.auth.account.id);
94
87
  return { tokens };
95
88
  };
96
89
  const token_revoke_handler = async (input, ctx) => {
97
- const auth = ctx.auth;
98
- const revoked = await query_revoke_api_token_for_account(ctx, input.token_id, auth.account.id);
99
- void audit_log_fire_and_forget(ctx, {
90
+ const revoked = await query_revoke_api_token_for_account(ctx, input.token_id, ctx.auth.account.id);
91
+ deps.audit.emit(ctx, {
100
92
  event_type: 'token_revoke',
101
93
  outcome: revoked ? 'success' : 'failure',
102
- actor_id: auth.actor.id,
103
- account_id: auth.account.id,
94
+ account_id: ctx.auth.account.id,
104
95
  ip: ctx.client_ip,
105
96
  metadata: { token_id: input.token_id },
106
- }, deps);
97
+ });
107
98
  return { ok: true, revoked };
108
99
  };
109
100
  return [
@@ -42,15 +42,30 @@ export declare const query_account_by_email: (deps: QueryDeps, email: string) =>
42
42
  */
43
43
  export declare const query_account_by_username_or_email: (deps: QueryDeps, input: string) => Promise<Account | undefined>;
44
44
  /**
45
- * Update the password hash for an account.
45
+ * Update the password hash for an account, conditional on the current
46
+ * stored hash matching `expected_hash` — the verify-write atomic guard.
46
47
  *
47
- * @mutates `account` row - updates `password_hash`, `updated_at`, and `updated_by`
48
+ * The condition closes the race where two concurrent password changes both
49
+ * verify against the pre-update hash (loaded by the authorization phase
50
+ * outside the route's transaction) and would otherwise both UPDATE,
51
+ * silently clobbering whichever lands first. With the conditional WHERE,
52
+ * the second UPDATE matches zero rows; the route reads the boolean
53
+ * return and surfaces 401 instead of pretending success.
54
+ *
55
+ * Pass the same hash the verify ran against — typically
56
+ * `ctx.account.password_hash` from the request context.
57
+ *
58
+ * @returns `true` if the row was updated, `false` if `expected_hash` no
59
+ * longer matched (concurrent change won — caller should treat as a
60
+ * stale-credential failure).
61
+ * @mutates `account` row - updates `password_hash`, `updated_at`, and
62
+ * `updated_by` only when the stored hash equals `expected_hash`
48
63
  */
49
- export declare const query_update_account_password: (deps: QueryDeps, id: string, password_hash: string, updated_by: string | null) => Promise<void>;
64
+ export declare const query_update_account_password: (deps: QueryDeps, id: string, password_hash: string, updated_by: string | null, expected_hash: string) => Promise<boolean>;
50
65
  /**
51
- * Delete an account. Cascades to actors, permits, sessions, and tokens.
66
+ * Delete an account. Cascades to actors, role_grants, sessions, and tokens.
52
67
  *
53
- * @mutates `account` table and downstream FK rows - DELETE cascades through actors/permits/sessions/tokens
68
+ * @mutates `account` table and downstream FK rows - DELETE cascades through actors/role_grants/sessions/tokens
54
69
  */
55
70
  export declare const query_delete_account: (deps: QueryDeps, id: string) => Promise<boolean>;
56
71
  /**
@@ -68,11 +83,14 @@ export declare const query_account_has_any: (deps: QueryDeps) => Promise<boolean
68
83
  */
69
84
  export declare const query_create_actor: (deps: QueryDeps, account_id: string, name: string) => Promise<Actor>;
70
85
  /**
71
- * Find the actor for an account.
86
+ * List every actor on an account, ordered by `created_at`.
72
87
  *
73
- * For v1, each account has exactly one actor.
88
+ * Used by `resolve_acting_actor` to resolve the acting actor for a
89
+ * request: 1 actor picks transparently, multiple require an explicit
90
+ * `acting` field on the request payload. For lookups by id, use
91
+ * `query_actor_by_id` instead.
74
92
  */
75
- export declare const query_actor_by_account: (deps: QueryDeps, account_id: string) => Promise<Actor | undefined>;
93
+ export declare const query_actors_by_account: (deps: QueryDeps, account_id: string) => Promise<Array<Actor>>;
76
94
  /**
77
95
  * Find an actor by id.
78
96
  */
@@ -91,17 +109,35 @@ export declare const query_create_account_with_actor: (deps: QueryDeps, input: C
91
109
  account: Account;
92
110
  actor: Actor;
93
111
  }>;
112
+ /** Options for `query_admin_account_list`. */
113
+ export interface AdminAccountListOptions {
114
+ /**
115
+ * Max accounts to return. Defaults to `ADMIN_ACCOUNT_LIST_DEFAULT_LIMIT`
116
+ * when omitted; pass `null` explicitly to disable the limit (unbounded
117
+ * fetch — for trusted internal callers / scripts; the RPC schema bounds
118
+ * wire callers to `[1, ADMIN_ACCOUNT_LIST_LIMIT_MAX]`).
119
+ */
120
+ limit?: number | null;
121
+ /** Pagination offset. Defaults to 0. */
122
+ offset?: number | null;
123
+ }
94
124
  /**
95
- * List all accounts with their actors, active permits, and pending inbound
96
- * permit offers for admin display.
125
+ * List accounts with their actors, active role_grants, and pending inbound
126
+ * role_grant offers for admin display.
97
127
  *
98
- * Uses 4 flat queries instead of N+1 per-account loops. Pending offers surface
99
- * the "offer pending awaiting acceptance" UX without a second round-trip;
100
- * `message` is intentionally excluded (cross-admin visibility of grantor notes
101
- * would expand beyond what the audit log discloses).
128
+ * Pages the accounts query (one round-trip), then fans out three parallel
129
+ * lookups scoped to the page's `account_ids` (one round-trip). The role_grants
130
+ * and offers queries use a subquery on `actor.account_id` so the page bound
131
+ * pushes through to the DB without round-tripping `actor.id`s back to the
132
+ * application. Pending offers surface the "offer pending — awaiting
133
+ * acceptance" UX; `message` is intentionally excluded (cross-admin
134
+ * visibility of grantor notes would expand beyond what the audit log
135
+ * discloses).
102
136
  *
103
137
  * @param deps - query dependencies
104
- * @returns admin account entries sorted by creation date
138
+ * @param options - optional `{limit, offset}`. Default limit is
139
+ * `ADMIN_ACCOUNT_LIST_DEFAULT_LIMIT`; pass `limit: null` to disable.
140
+ * @returns admin account entries sorted by creation date (oldest first)
105
141
  */
106
- export declare const query_admin_account_list: (deps: QueryDeps) => Promise<Array<AdminAccountEntryJson>>;
142
+ export declare const query_admin_account_list: (deps: QueryDeps, options?: AdminAccountListOptions) => Promise<Array<AdminAccountEntryJson>>;
107
143
  //# sourceMappingURL=account_queries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"account_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/account_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAEN,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,SAAS,EACf,OAAO,kBAAkB,KACvB,OAAO,CAAC,OAAO,CAQjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC/B,MAAM,SAAS,EACf,IAAI,MAAM,KACR,OAAO,CAAC,OAAO,GAAG,SAAS,CAE7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,GACrC,MAAM,SAAS,EACf,UAAU,MAAM,KACd,OAAO,CAAC,OAAO,GAAG,SAAS,CAI7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,SAAS,EACf,OAAO,MAAM,KACX,OAAO,CAAC,OAAO,GAAG,SAAS,CAI7B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kCAAkC,GAC9C,MAAM,SAAS,EACf,OAAO,MAAM,KACX,OAAO,CAAC,OAAO,GAAG,SAAS,CAS7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,GACzC,MAAM,SAAS,EACf,IAAI,MAAM,EACV,eAAe,MAAM,EACrB,YAAY,MAAM,GAAG,IAAI,KACvB,OAAO,CAAC,IAAI,CAKd,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAU,MAAM,SAAS,EAAE,IAAI,MAAM,KAAG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AM,KACR,OAAO,CAAC,KAAK,GAAG,SAAS,CAE3B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,+BAA+B,GAC3C,MAAM,SAAS,EACf,OAAO,kBAAkB,KACvB,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAC,CAI1C,CAAC;AA2BF,8CAA8C;AAC9C,MAAM,WAAW,uBAAuB;IACvC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,wBAAwB,GACpC,MAAM,SAAS,EACf,UAAU,uBAAuB,KAC/B,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAyGtC,CAAC"}
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import { assert_row } from '../db/assert_row.js';
10
10
  import { to_admin_account, } from './account_schema.js';
11
+ import { ADMIN_ACCOUNT_LIST_DEFAULT_LIMIT } from './admin_action_specs.js';
11
12
  /**
12
13
  * Create a new account.
13
14
  *
@@ -62,17 +63,35 @@ export const query_account_by_username_or_email = async (deps, input) => {
62
63
  return ((await query_account_by_username(deps, input)) ?? (await query_account_by_email(deps, input)));
63
64
  };
64
65
  /**
65
- * Update the password hash for an account.
66
+ * Update the password hash for an account, conditional on the current
67
+ * stored hash matching `expected_hash` — the verify-write atomic guard.
66
68
  *
67
- * @mutates `account` row - updates `password_hash`, `updated_at`, and `updated_by`
69
+ * The condition closes the race where two concurrent password changes both
70
+ * verify against the pre-update hash (loaded by the authorization phase
71
+ * outside the route's transaction) and would otherwise both UPDATE,
72
+ * silently clobbering whichever lands first. With the conditional WHERE,
73
+ * the second UPDATE matches zero rows; the route reads the boolean
74
+ * return and surfaces 401 instead of pretending success.
75
+ *
76
+ * Pass the same hash the verify ran against — typically
77
+ * `ctx.account.password_hash` from the request context.
78
+ *
79
+ * @returns `true` if the row was updated, `false` if `expected_hash` no
80
+ * longer matched (concurrent change won — caller should treat as a
81
+ * stale-credential failure).
82
+ * @mutates `account` row - updates `password_hash`, `updated_at`, and
83
+ * `updated_by` only when the stored hash equals `expected_hash`
68
84
  */
69
- export const query_update_account_password = async (deps, id, password_hash, updated_by) => {
70
- await deps.db.query(`UPDATE account SET password_hash = $1, updated_at = NOW(), updated_by = $2 WHERE id = $3`, [password_hash, updated_by ?? null, id]);
85
+ export const query_update_account_password = async (deps, id, password_hash, updated_by, expected_hash) => {
86
+ const rows = await deps.db.query(`UPDATE account SET password_hash = $1, updated_at = NOW(), updated_by = $2
87
+ WHERE id = $3 AND password_hash = $4
88
+ RETURNING id`, [password_hash, updated_by ?? null, id, expected_hash]);
89
+ return rows.length > 0;
71
90
  };
72
91
  /**
73
- * Delete an account. Cascades to actors, permits, sessions, and tokens.
92
+ * Delete an account. Cascades to actors, role_grants, sessions, and tokens.
74
93
  *
75
- * @mutates `account` table and downstream FK rows - DELETE cascades through actors/permits/sessions/tokens
94
+ * @mutates `account` table and downstream FK rows - DELETE cascades through actors/role_grants/sessions/tokens
76
95
  */
77
96
  export const query_delete_account = async (deps, id) => {
78
97
  const rows = await deps.db.query(`DELETE FROM account WHERE id = $1 RETURNING id`, [
@@ -101,12 +120,15 @@ export const query_create_actor = async (deps, account_id, name) => {
101
120
  return assert_row(row, 'INSERT INTO actor');
102
121
  };
103
122
  /**
104
- * Find the actor for an account.
123
+ * List every actor on an account, ordered by `created_at`.
105
124
  *
106
- * For v1, each account has exactly one actor.
125
+ * Used by `resolve_acting_actor` to resolve the acting actor for a
126
+ * request: 1 actor picks transparently, multiple require an explicit
127
+ * `acting` field on the request payload. For lookups by id, use
128
+ * `query_actor_by_id` instead.
107
129
  */
108
- export const query_actor_by_account = async (deps, account_id) => {
109
- return deps.db.query_one(`SELECT * FROM actor WHERE account_id = $1`, [account_id]);
130
+ export const query_actors_by_account = async (deps, account_id) => {
131
+ return deps.db.query(`SELECT * FROM actor WHERE account_id = $1 ORDER BY created_at ASC, id ASC`, [account_id]);
110
132
  };
111
133
  /**
112
134
  * Find an actor by id.
@@ -130,51 +152,76 @@ export const query_create_account_with_actor = async (deps, input) => {
130
152
  return { account, actor };
131
153
  };
132
154
  /**
133
- * List all accounts with their actors, active permits, and pending inbound
134
- * permit offers for admin display.
155
+ * List accounts with their actors, active role_grants, and pending inbound
156
+ * role_grant offers for admin display.
135
157
  *
136
- * Uses 4 flat queries instead of N+1 per-account loops. Pending offers surface
137
- * the "offer pending awaiting acceptance" UX without a second round-trip;
138
- * `message` is intentionally excluded (cross-admin visibility of grantor notes
139
- * would expand beyond what the audit log discloses).
158
+ * Pages the accounts query (one round-trip), then fans out three parallel
159
+ * lookups scoped to the page's `account_ids` (one round-trip). The role_grants
160
+ * and offers queries use a subquery on `actor.account_id` so the page bound
161
+ * pushes through to the DB without round-tripping `actor.id`s back to the
162
+ * application. Pending offers surface the "offer pending — awaiting
163
+ * acceptance" UX; `message` is intentionally excluded (cross-admin
164
+ * visibility of grantor notes would expand beyond what the audit log
165
+ * discloses).
140
166
  *
141
167
  * @param deps - query dependencies
142
- * @returns admin account entries sorted by creation date
168
+ * @param options - optional `{limit, offset}`. Default limit is
169
+ * `ADMIN_ACCOUNT_LIST_DEFAULT_LIMIT`; pass `limit: null` to disable.
170
+ * @returns admin account entries sorted by creation date (oldest first)
143
171
  */
144
- export const query_admin_account_list = async (deps) => {
145
- const [accounts, actors, permits, pending_offers] = await Promise.all([
146
- deps.db.query(`SELECT * FROM account ORDER BY created_at`),
147
- deps.db.query(`SELECT * FROM actor`),
148
- deps.db.query(`SELECT id, actor_id, role, scope_id, created_at, expires_at, granted_by
149
- FROM permit
150
- WHERE revoked_at IS NULL
151
- AND (expires_at IS NULL OR expires_at > NOW())`),
152
- deps.db.query(`SELECT po.id, po.to_account_id, po.from_actor_id, po.role, po.scope_id,
172
+ export const query_admin_account_list = async (deps, options) => {
173
+ const limit = options?.limit === null ? null : (options?.limit ?? ADMIN_ACCOUNT_LIST_DEFAULT_LIMIT);
174
+ const offset = options?.offset ?? 0;
175
+ const account_query = limit == null
176
+ ? deps.db.query(`SELECT * FROM account ORDER BY created_at OFFSET $1`, [offset])
177
+ : deps.db.query(`SELECT * FROM account ORDER BY created_at LIMIT $1 OFFSET $2`, [
178
+ limit,
179
+ offset,
180
+ ]);
181
+ const accounts = await account_query;
182
+ if (accounts.length === 0)
183
+ return [];
184
+ const account_ids = accounts.map((a) => a.id);
185
+ const [actors, role_grants, pending_offers] = await Promise.all([
186
+ deps.db.query(`SELECT * FROM actor WHERE account_id = ANY($1::uuid[])`, [account_ids]),
187
+ deps.db.query(`SELECT id, actor_id, role, scope_kind, scope_id, created_at, expires_at, granted_by
188
+ FROM role_grant
189
+ WHERE actor_id IN (SELECT id FROM actor WHERE account_id = ANY($1::uuid[]))
190
+ AND revoked_at IS NULL
191
+ AND (expires_at IS NULL OR expires_at > NOW())`, [account_ids]),
192
+ deps.db.query(`SELECT po.id, po.to_account_id, po.from_actor_id, po.role, po.scope_kind, po.scope_id,
153
193
  po.created_at, po.expires_at, a.username AS from_username
154
- FROM permit_offer po
194
+ FROM role_grant_offer po
155
195
  JOIN actor act ON act.id = po.from_actor_id
156
196
  JOIN account a ON a.id = act.account_id
157
- WHERE po.accepted_at IS NULL
197
+ WHERE po.to_account_id = ANY($1::uuid[])
198
+ AND po.accepted_at IS NULL
158
199
  AND po.declined_at IS NULL
159
200
  AND po.retracted_at IS NULL
160
201
  AND po.superseded_at IS NULL
161
202
  AND po.expires_at > NOW()
162
- ORDER BY po.expires_at ASC`),
203
+ ORDER BY po.expires_at ASC`, [account_ids]),
163
204
  ]);
164
- // Index actors by account_id (1:1 in v1)
205
+ // Index actors by account_id. Multi-actor TODO: this Map keyed by
206
+ // account_id silently overwrites earlier actors when an account
207
+ // hosts more than one — when multi-actor lands, the admin row shape
208
+ // must change from "account → one actor" to "account → Array<Actor>"
209
+ // (or split into a separate per-actor row). The JSON shape change
210
+ // will ripple into the admin UI; bundle that with the multi-actor
211
+ // session-actor-selector work.
165
212
  const actor_by_account = new Map();
166
213
  for (const actor of actors) {
167
214
  actor_by_account.set(actor.account_id, actor);
168
215
  }
169
- // Group permits by actor_id
170
- const permits_by_actor = new Map();
171
- for (const permit of permits) {
172
- let list = permits_by_actor.get(permit.actor_id);
216
+ // Group role_grants by actor_id
217
+ const role_grants_by_actor = new Map();
218
+ for (const role_grant of role_grants) {
219
+ let list = role_grants_by_actor.get(role_grant.actor_id);
173
220
  if (!list) {
174
221
  list = [];
175
- permits_by_actor.set(permit.actor_id, list);
222
+ role_grants_by_actor.set(role_grant.actor_id, list);
176
223
  }
177
- list.push(permit);
224
+ list.push(role_grant);
178
225
  }
179
226
  // Group pending offers by recipient account_id
180
227
  const offers_by_account = new Map();
@@ -188,14 +235,15 @@ export const query_admin_account_list = async (deps) => {
188
235
  }
189
236
  return accounts.map((account) => {
190
237
  const actor = actor_by_account.get(account.id);
191
- const actor_permits = actor ? (permits_by_actor.get(actor.id) ?? []) : [];
238
+ const actor_role_grants = actor ? (role_grants_by_actor.get(actor.id) ?? []) : [];
192
239
  const account_offers = offers_by_account.get(account.id) ?? [];
193
240
  return {
194
241
  account: to_admin_account(account),
195
242
  actor: actor ? { id: actor.id, name: actor.name } : null,
196
- permits: actor_permits.map((p) => ({
243
+ role_grants: actor_role_grants.map((p) => ({
197
244
  id: p.id,
198
245
  role: p.role,
246
+ scope_kind: p.scope_kind,
199
247
  scope_id: p.scope_id,
200
248
  created_at: p.created_at,
201
249
  expires_at: p.expires_at,
@@ -204,6 +252,7 @@ export const query_admin_account_list = async (deps) => {
204
252
  pending_offers: account_offers.map((o) => ({
205
253
  id: o.id,
206
254
  role: o.role,
255
+ scope_kind: o.scope_kind,
207
256
  scope_id: o.scope_id,
208
257
  from_actor_id: o.from_actor_id,
209
258
  from_username: o.from_username,