@fuzdev/fuz_app 0.55.0 → 0.57.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 (333) hide show
  1. package/dist/actions/CLAUDE.md +211 -155
  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 +19 -0
  6. package/dist/actions/action_codegen.d.ts.map +1 -1
  7. package/dist/actions/action_codegen.js +20 -14
  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 +110 -44
  11. package/dist/actions/action_rpc.d.ts.map +1 -1
  12. package/dist/actions/action_rpc.js +92 -287
  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 +44 -38
  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 +2 -10
  34. package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
  35. package/dist/actions/register_ws_endpoint.js +32 -10
  36. package/dist/actions/transports_ws_auth_guard.d.ts +1 -1
  37. package/dist/actions/transports_ws_auth_guard.js +1 -1
  38. package/dist/actions/transports_ws_backend.d.ts +1 -1
  39. package/dist/actions/transports_ws_backend.js +1 -1
  40. package/dist/auth/CLAUDE.md +673 -442
  41. package/dist/auth/account_action_specs.d.ts +28 -7
  42. package/dist/auth/account_action_specs.d.ts.map +1 -1
  43. package/dist/auth/account_action_specs.js +7 -7
  44. package/dist/auth/account_actions.d.ts +8 -14
  45. package/dist/auth/account_actions.d.ts.map +1 -1
  46. package/dist/auth/account_actions.js +26 -32
  47. package/dist/auth/account_queries.d.ts +46 -13
  48. package/dist/auth/account_queries.d.ts.map +1 -1
  49. package/dist/auth/account_queries.js +73 -33
  50. package/dist/auth/account_routes.d.ts +4 -3
  51. package/dist/auth/account_routes.d.ts.map +1 -1
  52. package/dist/auth/account_routes.js +58 -33
  53. package/dist/auth/account_schema.d.ts +46 -54
  54. package/dist/auth/account_schema.d.ts.map +1 -1
  55. package/dist/auth/account_schema.js +21 -48
  56. package/dist/auth/admin_action_specs.d.ts +55 -21
  57. package/dist/auth/admin_action_specs.d.ts.map +1 -1
  58. package/dist/auth/admin_action_specs.js +42 -26
  59. package/dist/auth/admin_actions.d.ts +14 -21
  60. package/dist/auth/admin_actions.d.ts.map +1 -1
  61. package/dist/auth/admin_actions.js +47 -44
  62. package/dist/auth/audit_emitter.d.ts +160 -0
  63. package/dist/auth/audit_emitter.d.ts.map +1 -0
  64. package/dist/auth/audit_emitter.js +83 -0
  65. package/dist/auth/audit_log_queries.d.ts +17 -87
  66. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  67. package/dist/auth/audit_log_queries.js +17 -96
  68. package/dist/auth/audit_log_routes.d.ts +1 -1
  69. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  70. package/dist/auth/audit_log_routes.js +7 -3
  71. package/dist/auth/audit_log_schema.d.ts +48 -42
  72. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  73. package/dist/auth/audit_log_schema.js +56 -43
  74. package/dist/auth/auth_guard_resolver.d.ts +44 -0
  75. package/dist/auth/auth_guard_resolver.d.ts.map +1 -0
  76. package/dist/auth/auth_guard_resolver.js +56 -0
  77. package/dist/auth/bootstrap_account.d.ts +7 -7
  78. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  79. package/dist/auth/bootstrap_account.js +7 -7
  80. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  81. package/dist/auth/bootstrap_routes.js +11 -10
  82. package/dist/auth/cleanup.d.ts +20 -26
  83. package/dist/auth/cleanup.d.ts.map +1 -1
  84. package/dist/auth/cleanup.js +33 -47
  85. package/dist/auth/credential_type_schema.d.ts +115 -0
  86. package/dist/auth/credential_type_schema.d.ts.map +1 -0
  87. package/dist/auth/credential_type_schema.js +127 -0
  88. package/dist/auth/daemon_token_middleware.d.ts +1 -1
  89. package/dist/auth/daemon_token_middleware.js +3 -3
  90. package/dist/auth/ddl.d.ts +2 -2
  91. package/dist/auth/ddl.d.ts.map +1 -1
  92. package/dist/auth/ddl.js +6 -6
  93. package/dist/auth/deps.d.ts +7 -32
  94. package/dist/auth/deps.d.ts.map +1 -1
  95. package/dist/auth/grant_path_schema.d.ts +117 -0
  96. package/dist/auth/grant_path_schema.d.ts.map +1 -0
  97. package/dist/auth/grant_path_schema.js +137 -0
  98. package/dist/auth/invite_queries.d.ts +12 -1
  99. package/dist/auth/invite_queries.d.ts.map +1 -1
  100. package/dist/auth/invite_queries.js +12 -1
  101. package/dist/auth/invite_schema.d.ts +1 -1
  102. package/dist/auth/invite_schema.d.ts.map +1 -1
  103. package/dist/auth/invite_schema.js +1 -1
  104. package/dist/auth/middleware.d.ts.map +1 -1
  105. package/dist/auth/middleware.js +5 -2
  106. package/dist/auth/migrations.d.ts +22 -7
  107. package/dist/auth/migrations.d.ts.map +1 -1
  108. package/dist/auth/migrations.js +64 -25
  109. package/dist/auth/request_context.d.ts +157 -170
  110. package/dist/auth/request_context.d.ts.map +1 -1
  111. package/dist/auth/request_context.js +224 -268
  112. package/dist/auth/{permit_offer_action_specs.d.ts → role_grant_offer_action_specs.d.ts} +130 -100
  113. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -0
  114. package/dist/auth/role_grant_offer_action_specs.js +262 -0
  115. package/dist/auth/role_grant_offer_actions.d.ts +104 -0
  116. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -0
  117. package/dist/auth/{permit_offer_actions.js → role_grant_offer_actions.js} +153 -140
  118. package/dist/auth/{permit_offer_notifications.d.ts → role_grant_offer_notifications.d.ts} +80 -70
  119. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -0
  120. package/dist/auth/role_grant_offer_notifications.js +182 -0
  121. package/dist/auth/{permit_offer_queries.d.ts → role_grant_offer_queries.d.ts} +64 -64
  122. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -0
  123. package/dist/auth/{permit_offer_queries.js → role_grant_offer_queries.js} +136 -123
  124. package/dist/auth/role_grant_offer_schema.d.ts +150 -0
  125. package/dist/auth/role_grant_offer_schema.d.ts.map +1 -0
  126. package/dist/auth/{permit_offer_schema.js → role_grant_offer_schema.js} +55 -36
  127. package/dist/auth/role_grant_queries.d.ts +231 -0
  128. package/dist/auth/role_grant_queries.d.ts.map +1 -0
  129. package/dist/auth/role_grant_queries.js +320 -0
  130. package/dist/auth/role_schema.d.ts +150 -40
  131. package/dist/auth/role_schema.d.ts.map +1 -1
  132. package/dist/auth/role_schema.js +144 -45
  133. package/dist/auth/scope_kind_schema.d.ts +96 -0
  134. package/dist/auth/scope_kind_schema.d.ts.map +1 -0
  135. package/dist/auth/scope_kind_schema.js +94 -0
  136. package/dist/auth/self_service_role_action_specs.d.ts +4 -1
  137. package/dist/auth/self_service_role_action_specs.d.ts.map +1 -1
  138. package/dist/auth/self_service_role_action_specs.js +2 -2
  139. package/dist/auth/self_service_role_actions.d.ts +35 -29
  140. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  141. package/dist/auth/self_service_role_actions.js +58 -48
  142. package/dist/auth/session_cookie.d.ts +43 -6
  143. package/dist/auth/session_cookie.d.ts.map +1 -1
  144. package/dist/auth/session_cookie.js +31 -5
  145. package/dist/auth/session_middleware.d.ts +37 -3
  146. package/dist/auth/session_middleware.d.ts.map +1 -1
  147. package/dist/auth/session_middleware.js +33 -7
  148. package/dist/auth/signup_routes.d.ts.map +1 -1
  149. package/dist/auth/signup_routes.js +48 -19
  150. package/dist/auth/standard_action_specs.d.ts +2 -2
  151. package/dist/auth/standard_action_specs.js +4 -4
  152. package/dist/auth/standard_rpc_actions.d.ts +23 -19
  153. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  154. package/dist/auth/standard_rpc_actions.js +12 -12
  155. package/dist/db/migrate.d.ts +1 -1
  156. package/dist/db/migrate.js +1 -1
  157. package/dist/dev/setup.d.ts +2 -2
  158. package/dist/dev/setup.d.ts.map +1 -1
  159. package/dist/dev/setup.js +4 -4
  160. package/dist/env/load.d.ts +1 -1
  161. package/dist/env/load.js +1 -1
  162. package/dist/hono_context.d.ts +27 -45
  163. package/dist/hono_context.d.ts.map +1 -1
  164. package/dist/hono_context.js +14 -28
  165. package/dist/http/CLAUDE.md +235 -121
  166. package/dist/http/auth_shape.d.ts +191 -0
  167. package/dist/http/auth_shape.d.ts.map +1 -0
  168. package/dist/http/auth_shape.js +237 -0
  169. package/dist/http/common_routes.js +3 -3
  170. package/dist/http/db_routes.d.ts +4 -0
  171. package/dist/http/db_routes.d.ts.map +1 -1
  172. package/dist/http/db_routes.js +44 -7
  173. package/dist/http/error_schemas.d.ts +72 -39
  174. package/dist/http/error_schemas.d.ts.map +1 -1
  175. package/dist/http/error_schemas.js +81 -33
  176. package/dist/http/pending_effects.d.ts +71 -18
  177. package/dist/http/pending_effects.d.ts.map +1 -1
  178. package/dist/http/pending_effects.js +87 -18
  179. package/dist/http/proxy.d.ts +52 -5
  180. package/dist/http/proxy.d.ts.map +1 -1
  181. package/dist/http/proxy.js +92 -14
  182. package/dist/http/route_spec.d.ts +89 -75
  183. package/dist/http/route_spec.d.ts.map +1 -1
  184. package/dist/http/route_spec.js +54 -72
  185. package/dist/http/schema_helpers.d.ts +3 -14
  186. package/dist/http/schema_helpers.d.ts.map +1 -1
  187. package/dist/http/schema_helpers.js +2 -14
  188. package/dist/http/surface.d.ts +2 -10
  189. package/dist/http/surface.d.ts.map +1 -1
  190. package/dist/http/surface.js +3 -4
  191. package/dist/http/surface_query.d.ts +39 -35
  192. package/dist/http/surface_query.d.ts.map +1 -1
  193. package/dist/http/surface_query.js +79 -36
  194. package/dist/primitive_schemas.d.ts +39 -0
  195. package/dist/primitive_schemas.d.ts.map +1 -0
  196. package/dist/primitive_schemas.js +40 -0
  197. package/dist/realtime/sse_auth_guard.d.ts +5 -5
  198. package/dist/realtime/sse_auth_guard.js +9 -9
  199. package/dist/runtime/mock.d.ts +1 -1
  200. package/dist/runtime/mock.js +1 -1
  201. package/dist/server/app_backend.d.ts +14 -11
  202. package/dist/server/app_backend.d.ts.map +1 -1
  203. package/dist/server/app_backend.js +12 -8
  204. package/dist/server/app_server.d.ts +7 -7
  205. package/dist/server/app_server.d.ts.map +1 -1
  206. package/dist/server/app_server.js +35 -40
  207. package/dist/server/validate_nginx.d.ts +1 -1
  208. package/dist/server/validate_nginx.js +1 -1
  209. package/dist/testing/CLAUDE.md +50 -38
  210. package/dist/testing/admin_integration.d.ts +5 -6
  211. package/dist/testing/admin_integration.d.ts.map +1 -1
  212. package/dist/testing/admin_integration.js +87 -85
  213. package/dist/testing/app_server.d.ts +11 -14
  214. package/dist/testing/app_server.d.ts.map +1 -1
  215. package/dist/testing/app_server.js +16 -15
  216. package/dist/testing/assertions.d.ts.map +1 -1
  217. package/dist/testing/assertions.js +2 -1
  218. package/dist/testing/attack_surface.d.ts.map +1 -1
  219. package/dist/testing/attack_surface.js +15 -9
  220. package/dist/testing/audit_completeness.d.ts +2 -2
  221. package/dist/testing/audit_completeness.d.ts.map +1 -1
  222. package/dist/testing/audit_completeness.js +36 -36
  223. package/dist/testing/auth_apps.d.ts +5 -4
  224. package/dist/testing/auth_apps.d.ts.map +1 -1
  225. package/dist/testing/auth_apps.js +22 -19
  226. package/dist/testing/data_exposure.d.ts.map +1 -1
  227. package/dist/testing/data_exposure.js +5 -5
  228. package/dist/testing/db.d.ts +1 -1
  229. package/dist/testing/db.d.ts.map +1 -1
  230. package/dist/testing/db.js +4 -4
  231. package/dist/testing/db_entities.d.ts +22 -0
  232. package/dist/testing/db_entities.d.ts.map +1 -0
  233. package/dist/testing/db_entities.js +28 -0
  234. package/dist/testing/entities.d.ts +8 -7
  235. package/dist/testing/entities.d.ts.map +1 -1
  236. package/dist/testing/entities.js +21 -18
  237. package/dist/testing/integration.d.ts.map +1 -1
  238. package/dist/testing/integration.js +13 -14
  239. package/dist/testing/integration_helpers.d.ts +4 -4
  240. package/dist/testing/integration_helpers.d.ts.map +1 -1
  241. package/dist/testing/integration_helpers.js +20 -18
  242. package/dist/testing/middleware.d.ts +4 -4
  243. package/dist/testing/middleware.d.ts.map +1 -1
  244. package/dist/testing/middleware.js +12 -11
  245. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  246. package/dist/testing/rpc_attack_surface.js +40 -24
  247. package/dist/testing/rpc_round_trip.d.ts +1 -1
  248. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  249. package/dist/testing/rpc_round_trip.js +14 -13
  250. package/dist/testing/sse_round_trip.d.ts +3 -4
  251. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  252. package/dist/testing/sse_round_trip.js +7 -11
  253. package/dist/testing/standard.d.ts +1 -1
  254. package/dist/testing/stubs.d.ts +25 -0
  255. package/dist/testing/stubs.d.ts.map +1 -1
  256. package/dist/testing/stubs.js +43 -2
  257. package/dist/testing/surface_invariants.d.ts +14 -6
  258. package/dist/testing/surface_invariants.d.ts.map +1 -1
  259. package/dist/testing/surface_invariants.js +119 -43
  260. package/dist/testing/ws_round_trip.d.ts +12 -13
  261. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  262. package/dist/testing/ws_round_trip.js +19 -11
  263. package/dist/ui/AdminAccounts.svelte +23 -20
  264. package/dist/ui/AdminOverview.svelte +15 -13
  265. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
  266. package/dist/ui/{AdminPermitHistory.svelte → AdminRoleGrantHistory.svelte} +12 -12
  267. package/dist/ui/AdminRoleGrantHistory.svelte.d.ts +4 -0
  268. package/dist/ui/AdminRoleGrantHistory.svelte.d.ts.map +1 -0
  269. package/dist/ui/BootstrapForm.svelte +1 -1
  270. package/dist/ui/CLAUDE.md +60 -60
  271. package/dist/ui/{PermitOfferForm.svelte → RoleGrantOfferForm.svelte} +27 -26
  272. package/dist/ui/{PermitOfferForm.svelte.d.ts → RoleGrantOfferForm.svelte.d.ts} +7 -7
  273. package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -0
  274. package/dist/ui/{PermitOfferHistory.svelte → RoleGrantOfferHistory.svelte} +12 -12
  275. package/dist/ui/{PermitOfferHistory.svelte.d.ts → RoleGrantOfferHistory.svelte.d.ts} +4 -4
  276. package/dist/ui/RoleGrantOfferHistory.svelte.d.ts.map +1 -0
  277. package/dist/ui/{PermitOfferInbox.svelte → RoleGrantOfferInbox.svelte} +14 -14
  278. package/dist/ui/{PermitOfferInbox.svelte.d.ts → RoleGrantOfferInbox.svelte.d.ts} +4 -4
  279. package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -0
  280. package/dist/ui/SignupForm.svelte +1 -1
  281. package/dist/ui/SurfaceExplorer.svelte +35 -15
  282. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
  283. package/dist/ui/account_sessions_state.svelte.d.ts +2 -3
  284. package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
  285. package/dist/ui/account_sessions_state.svelte.js +2 -3
  286. package/dist/ui/admin_accounts_state.svelte.d.ts +18 -18
  287. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
  288. package/dist/ui/admin_accounts_state.svelte.js +16 -16
  289. package/dist/ui/admin_rpc_adapters.d.ts +20 -20
  290. package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
  291. package/dist/ui/admin_rpc_adapters.js +17 -17
  292. package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
  293. package/dist/ui/admin_sessions_state.svelte.js +2 -2
  294. package/dist/ui/audit_log_state.svelte.d.ts +7 -7
  295. package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
  296. package/dist/ui/audit_log_state.svelte.js +6 -6
  297. package/dist/ui/auth_state.svelte.d.ts +3 -3
  298. package/dist/ui/auth_state.svelte.d.ts.map +1 -1
  299. package/dist/ui/auth_state.svelte.js +6 -6
  300. package/dist/ui/format_scope.d.ts +2 -2
  301. package/dist/ui/format_scope.js +2 -2
  302. package/dist/ui/{permit_offers_state.svelte.d.ts → role_grant_offers_state.svelte.d.ts} +30 -30
  303. package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -0
  304. package/dist/ui/{permit_offers_state.svelte.js → role_grant_offers_state.svelte.js} +18 -18
  305. package/dist/ui/ui_format.js +2 -2
  306. package/package.json +3 -3
  307. package/dist/auth/permit_offer_action_specs.d.ts.map +0 -1
  308. package/dist/auth/permit_offer_action_specs.js +0 -258
  309. package/dist/auth/permit_offer_actions.d.ts +0 -110
  310. package/dist/auth/permit_offer_actions.d.ts.map +0 -1
  311. package/dist/auth/permit_offer_notifications.d.ts.map +0 -1
  312. package/dist/auth/permit_offer_notifications.js +0 -182
  313. package/dist/auth/permit_offer_queries.d.ts.map +0 -1
  314. package/dist/auth/permit_offer_schema.d.ts +0 -125
  315. package/dist/auth/permit_offer_schema.d.ts.map +0 -1
  316. package/dist/auth/permit_queries.d.ts +0 -222
  317. package/dist/auth/permit_queries.d.ts.map +0 -1
  318. package/dist/auth/permit_queries.js +0 -305
  319. package/dist/auth/require_keeper.d.ts +0 -20
  320. package/dist/auth/require_keeper.d.ts.map +0 -1
  321. package/dist/auth/require_keeper.js +0 -35
  322. package/dist/auth/route_guards.d.ts +0 -27
  323. package/dist/auth/route_guards.d.ts.map +0 -1
  324. package/dist/auth/route_guards.js +0 -38
  325. package/dist/auth/session_lifecycle.d.ts +0 -37
  326. package/dist/auth/session_lifecycle.d.ts.map +0 -1
  327. package/dist/auth/session_lifecycle.js +0 -29
  328. package/dist/ui/AdminPermitHistory.svelte.d.ts +0 -4
  329. package/dist/ui/AdminPermitHistory.svelte.d.ts.map +0 -1
  330. package/dist/ui/PermitOfferForm.svelte.d.ts.map +0 -1
  331. package/dist/ui/PermitOfferHistory.svelte.d.ts.map +0 -1
  332. package/dist/ui/PermitOfferInbox.svelte.d.ts.map +0 -1
  333. package/dist/ui/permit_offers_state.svelte.d.ts.map +0 -1
@@ -3,14 +3,14 @@ import './assert_dev_env.js';
3
3
  * Standard admin integration test suite for fuz_app admin routes.
4
4
  *
5
5
  * `describe_standard_admin_integration_tests` creates a composable test suite
6
- * that exercises admin account listing, permit grant/revoke (via the RPC
7
- * surface — see `permit_offer_create` / `permit_revoke`), session/token
6
+ * that exercises admin account listing, role_grant grant/revoke (via the RPC
7
+ * surface — see `role_grant_offer_create` / `role_grant_revoke`), session/token
8
8
  * management, and audit log routes against a real PGlite database.
9
9
  *
10
10
  * Consumers call it with their route factory, session config, role schema,
11
11
  * and RPC endpoint specs — all admin route tests come for free.
12
12
  *
13
- * Scope: admin *semantics* — cross-admin isolation, permit grant/revoke
13
+ * Scope: admin *semantics* — cross-admin isolation, role_grant grant/revoke
14
14
  * flow, session/token revoke-all, audit writes. Output-schema conformance
15
15
  * for admin methods is **not** the concern of this suite; it lives in:
16
16
  *
@@ -27,6 +27,7 @@ import './assert_dev_env.js';
27
27
  */
28
28
  import { describe, test, assert, afterAll } from 'vitest';
29
29
  import { ROLE_KEEPER, ROLE_ADMIN } from '../auth/role_schema.js';
30
+ import { GRANT_PATH_ADMIN } from '../auth/grant_path_schema.js';
30
31
  import { AUTH_MIGRATION_NS } from '../auth/migrations.js';
31
32
  import { create_test_app } from './app_server.js';
32
33
  import { create_pglite_factory, create_describe_db, AUTH_INTEGRATION_TRUNCATE_TABLES, } from './db.js';
@@ -34,17 +35,20 @@ import { find_auth_route } from './integration_helpers.js';
34
35
  import { run_migrations } from '../db/migrate.js';
35
36
  import { ErrorCoverageCollector, assert_error_coverage, DEFAULT_INTEGRATION_ERROR_COVERAGE, } from './error_coverage.js';
36
37
  import { rpc_call_for_spec, require_rpc_endpoint_path, resolve_rpc_endpoints_for_setup, } from './rpc_helpers.js';
37
- import { permit_offer_create_action_spec, permit_revoke_action_spec, } from '../auth/permit_offer_action_specs.js';
38
- import { admin_account_list_action_spec, admin_session_list_action_spec, admin_session_revoke_all_action_spec, admin_token_revoke_all_action_spec, audit_log_list_action_spec, audit_log_permit_history_action_spec, } from '../auth/admin_action_specs.js';
38
+ import { role_grant_offer_create_action_spec, role_grant_revoke_action_spec, } from '../auth/role_grant_offer_action_specs.js';
39
+ import { admin_account_list_action_spec, admin_session_list_action_spec, admin_session_revoke_all_action_spec, admin_token_revoke_all_action_spec, audit_log_list_action_spec, audit_log_role_grant_history_action_spec, } from '../auth/admin_action_specs.js';
39
40
  import { account_token_create_action_spec, account_verify_action_spec, } from '../auth/account_action_specs.js';
40
- import { query_grant_permit } from '../auth/permit_queries.js';
41
- import { query_accept_offer } from '../auth/permit_offer_queries.js';
41
+ import { query_create_role_grant } from '../auth/role_grant_queries.js';
42
+ import { query_accept_offer } from '../auth/role_grant_offer_queries.js';
42
43
  /**
43
- * Pick a web-grantable role for testing, preferring a non-admin app-defined role.
44
+ * Pick a role for admin-grant testing, preferring a non-admin app-defined
45
+ * role whose `RoleSpec.grant_paths` includes `'admin'` (the
46
+ * `GRANT_PATH_ADMIN` constant). Falls back to `ROLE_ADMIN` when no
47
+ * app-defined admin-grant-path role is registered.
44
48
  */
45
- const pick_grantable_role = (role_options) => {
46
- for (const [name, opts] of role_options) {
47
- if (opts.web_grantable && name !== ROLE_ADMIN)
49
+ const pick_grantable_role = (role_specs) => {
50
+ for (const [name, spec] of role_specs) {
51
+ if (spec.grant_paths?.includes(GRANT_PATH_ADMIN) && name !== ROLE_ADMIN)
48
52
  return name;
49
53
  }
50
54
  return ROLE_ADMIN; // fallback
@@ -65,17 +69,16 @@ const build_admin_test_app_options = (options, db, roles) => ({
65
69
  /**
66
70
  * Standard admin integration test suite for fuz_app admin routes.
67
71
  *
68
- * Exercises account listing, permit grant/revoke (via RPC), session
72
+ * Exercises account listing, role_grant grant/revoke (via RPC), session
69
73
  * management, token management, audit log reads, admin-to-admin
70
74
  * isolation, and 401/403 error-coverage on the admin REST surface.
71
75
  * Output-schema conformance is not in scope — see the module docstring
72
76
  * for the suites that cover it.
73
77
  *
74
78
  * @throws Error at setup time when `options.rpc_endpoints` is empty — admin
75
- * permit grant/revoke, session/token revoke-all, and audit-log reads are
76
- * all RPC-only since the 2026-04-22 migration. Hard-fails via
77
- * `require_rpc_endpoint_path` so consumers see a clear setup error rather
78
- * than `method not found` mid-suite.
79
+ * role_grant grant/revoke, session/token revoke-all, and audit-log reads
80
+ * are RPC-only. Hard-fails via `require_rpc_endpoint_path` so consumers
81
+ * see a clear setup error rather than `method not found` mid-suite.
79
82
  */
80
83
  export const describe_standard_admin_integration_tests = (options) => {
81
84
  // Hard-fail early so consumers see a clear setup error instead of a
@@ -91,30 +94,30 @@ export const describe_standard_admin_integration_tests = (options) => {
91
94
  const describe_db = create_describe_db(factories, AUTH_INTEGRATION_TRUNCATE_TABLES);
92
95
  describe_db('standard_admin_integration', (get_db) => {
93
96
  const { cookie_name } = options.session_options;
94
- const { role_options } = options.roles;
95
- const grantable_role = pick_grantable_role(role_options);
97
+ const { role_specs } = options.roles;
98
+ const grantable_role = pick_grantable_role(role_specs);
96
99
  // Error coverage tracking across test groups
97
100
  const error_collector = new ErrorCoverageCollector();
98
101
  let captured_route_specs = null;
99
102
  afterAll(() => {
100
103
  if (captured_route_specs) {
101
- // Scope coverage to admin auth-related routes. Post-2026-04-23
102
- // RPC migration: account listing, session/token revoke-all,
103
- // audit-log reads, and invite CRUD are RPC-only. The only
104
- // admin REST route remaining is the optional
105
- // `GET /audit/stream` SSE, plus the shared RPC endpoint
106
- // path itself (admin methods live behind spec-level role auth).
104
+ // Scope coverage to admin auth-related routes. Account listing,
105
+ // session/token revoke-all, audit-log reads, and invite CRUD all
106
+ // live on the RPC surface; the only admin REST route remaining
107
+ // is the optional `GET /audit/stream` SSE (admin RPC methods
108
+ // live behind spec-level role auth on the shared endpoint path).
107
109
  // The `/audit/stream` suffix tracks the hardcoded path in
108
110
  // `auth/audit_log_routes.ts` — if consumers ever need to mount
109
111
  // the audit SSE at a different suffix, promote this to an
110
112
  // `audit_log_path_suffix` option on
111
113
  // `StandardAdminIntegrationTestOptions`.
112
- const admin_routes = captured_route_specs.filter((s) => s.path.endsWith('/audit/stream') && s.auth.type === 'role' && s.auth.role === 'admin');
114
+ const admin_routes = captured_route_specs.filter((s) => s.path.endsWith('/audit/stream') && (s.auth.roles?.includes('admin') ?? false));
113
115
  // Adaptive threshold: when the scoped admin REST surface is
114
- // effectively empty (0–1 routes, typical post-RPC-migration),
115
- // the 20% baseline is meaningless — a single SSE route that
116
- // can't be exercised against an error schema drops the ratio
117
- // to 0.0%. Log an informational skip instead of asserting.
116
+ // effectively empty (0–1 routes typical for the RPC-first
117
+ // admin surface), the 20% baseline is meaningless — a single
118
+ // SSE route that can't be exercised against an error schema
119
+ // drops the ratio to 0.0%. Log an informational skip instead
120
+ // of asserting.
118
121
  // The admin RPC surface is covered by
119
122
  // `describe_rpc_round_trip_tests`, not this collector.
120
123
  if (admin_routes.length <= 1) {
@@ -137,7 +140,7 @@ export const describe_standard_admin_integration_tests = (options) => {
137
140
  });
138
141
  /**
139
142
  * Drive the full consent flow (admin offer → recipient accept) and
140
- * return the materialized permit id. Accept is a direct transactional
143
+ * return the materialized role_grant id. Accept is a direct transactional
141
144
  * `query_accept_offer` call because the suite focuses on the admin
142
145
  * side; exercising the recipient's UI-wired accept path is covered by
143
146
  * `describe_rpc_round_trip_tests` + fuz_app's own action suite.
@@ -146,11 +149,11 @@ export const describe_standard_admin_integration_tests = (options) => {
146
149
  const res = await rpc_call_for_spec({
147
150
  app: args.app,
148
151
  path: rpc_path,
149
- spec: permit_offer_create_action_spec,
152
+ spec: role_grant_offer_create_action_spec,
150
153
  params: { to_account_id: args.to_account_id, role: args.role },
151
154
  headers: args.admin_headers,
152
155
  });
153
- assert.ok(res.ok, `permit_offer_create failed: ${res.ok ? '' : JSON.stringify(res.error)}`);
156
+ assert.ok(res.ok, `role_grant_offer_create failed: ${res.ok ? '' : JSON.stringify(res.error)}`);
154
157
  const { offer } = res.result;
155
158
  const accept_result = await get_db().transaction(async (tx) => query_accept_offer({ db: tx }, {
156
159
  offer_id: offer.id,
@@ -158,7 +161,7 @@ export const describe_standard_admin_integration_tests = (options) => {
158
161
  actor_id: args.to_actor_id,
159
162
  ip: null,
160
163
  }));
161
- return { offer_id: offer.id, permit_id: accept_result.permit.id };
164
+ return { offer_id: offer.id, role_grant_id: accept_result.role_grant.id };
162
165
  };
163
166
  // --- 1. Admin account listing (RPC) ---
164
167
  describe('admin account listing', () => {
@@ -194,12 +197,12 @@ export const describe_standard_admin_integration_tests = (options) => {
194
197
  assert.strictEqual(res.status, 403);
195
198
  });
196
199
  });
197
- // --- 2. Permit grant/revoke lifecycle ---
198
- // Permit grant/revoke are RPC-only (see `permit_offer_create` /
199
- // `permit_revoke`). End-to-end coverage lives in
200
+ // --- 2. Role grant create/revoke lifecycle ---
201
+ // Role grant create/revoke are RPC-only (see `role_grant_offer_create` /
202
+ // `role_grant_revoke`). End-to-end coverage lives in
200
203
  // `describe_rpc_round_trip_tests` + fuz_app's own
201
- // `permit_offer_actions.db.test.ts` /
202
- // `permit_offer_actions.notifications.revoke.db.test.ts`. The
204
+ // `role_grant_offer_actions.db.test.ts` /
205
+ // `role_grant_offer_actions.notifications.revoke.db.test.ts`. The
203
206
  // audit/isolation groups below exercise them as preconditions for
204
207
  // cross-cutting checks (event emission, admin-to-admin isolation).
205
208
  // --- 3. Admin session management ---
@@ -329,34 +332,34 @@ export const describe_standard_admin_integration_tests = (options) => {
329
332
  });
330
333
  test('audit log supports event_type filter', async () => {
331
334
  const test_app = await create_test_app(build_admin_test_app_options(options, get_db()));
332
- // Admin offer emits `permit_offer_create`. The downstream
333
- // `permit_grant` only fires on accept — out of scope for this test.
335
+ // Admin offer emits `role_grant_offer_create`. The downstream
336
+ // `role_grant_create` only fires on accept — out of scope for this test.
334
337
  const user_two = await test_app.create_account({ username: 'user_two' });
335
338
  const offer_res = await rpc_call_for_spec({
336
339
  app: test_app.app,
337
340
  path: rpc_path,
338
- spec: permit_offer_create_action_spec,
341
+ spec: role_grant_offer_create_action_spec,
339
342
  params: { to_account_id: user_two.account.id, role: grantable_role },
340
343
  headers: test_app.create_session_headers(),
341
344
  });
342
- assert.ok(offer_res.ok, 'permit_offer_create should succeed');
345
+ assert.ok(offer_res.ok, 'role_grant_offer_create should succeed');
343
346
  const res = await rpc_call_for_spec({
344
347
  app: test_app.app,
345
348
  path: rpc_path,
346
349
  spec: audit_log_list_action_spec,
347
- params: { event_type: 'permit_offer_create' },
350
+ params: { event_type: 'role_grant_offer_create' },
348
351
  headers: test_app.create_session_headers(),
349
352
  });
350
353
  assert.ok(res.ok, `audit_log_list failed: ${res.ok ? '' : JSON.stringify(res.error)}`);
351
- assert.ok(res.result.events.length >= 1, 'Expected at least 1 permit_offer_create event');
354
+ assert.ok(res.result.events.length >= 1, 'Expected at least 1 role_grant_offer_create event');
352
355
  for (const event of res.result.events) {
353
- assert.strictEqual(event.event_type, 'permit_offer_create');
356
+ assert.strictEqual(event.event_type, 'role_grant_offer_create');
354
357
  }
355
358
  });
356
- test('admin can view permit history', async () => {
359
+ test('admin can view role_grant history', async () => {
357
360
  const test_app = await create_test_app(build_admin_test_app_options(options, get_db()));
358
- // Drive the full consent flow so `permit_grant` lands in the audit log
359
- // — `query_audit_log_list_permit_history` filters to (permit_grant, permit_revoke).
361
+ // Drive the full consent flow so `role_grant_create` lands in the audit log
362
+ // — `query_audit_log_list_role_grant_history` filters to (role_grant_create, role_grant_revoke).
360
363
  const user_two = await test_app.create_account({ username: 'user_two' });
361
364
  await offer_and_accept({
362
365
  app: test_app.app,
@@ -368,20 +371,20 @@ export const describe_standard_admin_integration_tests = (options) => {
368
371
  const res = await rpc_call_for_spec({
369
372
  app: test_app.app,
370
373
  path: rpc_path,
371
- spec: audit_log_permit_history_action_spec,
374
+ spec: audit_log_role_grant_history_action_spec,
372
375
  params: {},
373
376
  headers: test_app.create_session_headers(),
374
377
  });
375
- assert.ok(res.ok, `audit_log_permit_history failed: ${res.ok ? '' : JSON.stringify(res.error)}`);
376
- assert.ok(res.result.events.length >= 1, 'Expected at least 1 permit history event');
378
+ assert.ok(res.ok, `audit_log_role_grant_history failed: ${res.ok ? '' : JSON.stringify(res.error)}`);
379
+ assert.ok(res.result.events.length >= 1, 'Expected at least 1 role_grant history event');
377
380
  });
378
381
  });
379
382
  // --- 6. Admin audit trail ---
380
383
  describe('admin audit trail', () => {
381
- test('permit revoke creates audit event', async () => {
384
+ test('role_grant revoke creates audit event', async () => {
382
385
  const test_app = await create_test_app(build_admin_test_app_options(options, get_db()));
383
386
  const user_two = await test_app.create_account({ username: 'user_two' });
384
- const permit = await query_grant_permit({ db: get_db() }, {
387
+ const role_grant = await query_create_role_grant({ db: get_db() }, {
385
388
  actor_id: user_two.actor.id,
386
389
  role: grantable_role,
387
390
  granted_by: test_app.backend.actor.id,
@@ -390,22 +393,22 @@ export const describe_standard_admin_integration_tests = (options) => {
390
393
  const revoke_res = await rpc_call_for_spec({
391
394
  app: test_app.app,
392
395
  path: rpc_path,
393
- spec: permit_revoke_action_spec,
394
- params: { actor_id: user_two.actor.id, permit_id: permit.id },
396
+ spec: role_grant_revoke_action_spec,
397
+ params: { actor_id: user_two.actor.id, role_grant_id: role_grant.id },
395
398
  headers: test_app.create_session_headers(),
396
399
  });
397
- assert.ok(revoke_res.ok, `permit_revoke failed: ${revoke_res.ok ? '' : JSON.stringify(revoke_res.error)}`);
398
- // Check audit log for permit_revoke event
400
+ assert.ok(revoke_res.ok, `role_grant_revoke failed: ${revoke_res.ok ? '' : JSON.stringify(revoke_res.error)}`);
401
+ // Check audit log for role_grant_revoke event
399
402
  const audit_res = await rpc_call_for_spec({
400
403
  app: test_app.app,
401
404
  path: rpc_path,
402
405
  spec: audit_log_list_action_spec,
403
- params: { event_type: 'permit_revoke' },
406
+ params: { event_type: 'role_grant_revoke' },
404
407
  headers: test_app.create_session_headers(),
405
408
  });
406
409
  assert.ok(audit_res.ok, `audit_log_list failed: ${audit_res.ok ? '' : JSON.stringify(audit_res.error)}`);
407
- assert.ok(audit_res.result.events.length >= 1, 'Expected permit_revoke audit event');
408
- assert.strictEqual(audit_res.result.events[0].event_type, 'permit_revoke');
410
+ assert.ok(audit_res.result.events.length >= 1, 'Expected role_grant_revoke audit event');
411
+ assert.strictEqual(audit_res.result.events[0].event_type, 'role_grant_revoke');
409
412
  });
410
413
  test('admin session revoke-all creates audit event', async () => {
411
414
  const test_app = await create_test_app(build_admin_test_app_options(options, get_db()));
@@ -556,25 +559,25 @@ export const describe_standard_admin_integration_tests = (options) => {
556
559
  },
557
560
  });
558
561
  }
559
- // 3. offer permit (admin offers grantable_role to user_two) — full
560
- // consentful flow: offer + accept so both `permit_offer_create` and
561
- // `permit_grant` audit events land.
562
- const { permit_id } = await offer_and_accept({
562
+ // 3. offer role_grant (admin offers grantable_role to user_two) — full
563
+ // consentful flow: offer + accept so both `role_grant_offer_create` and
564
+ // `role_grant_create` audit events land.
565
+ const { role_grant_id } = await offer_and_accept({
563
566
  app: test_app.app,
564
567
  admin_headers: test_app.create_session_headers(),
565
568
  to_account_id: user_two.account.id,
566
569
  to_actor_id: user_two.actor.id,
567
570
  role: grantable_role,
568
571
  });
569
- // 4. revoke permit (RPC)
572
+ // 4. revoke role_grant (RPC)
570
573
  const revoke_res = await rpc_call_for_spec({
571
574
  app: test_app.app,
572
575
  path: rpc_path,
573
- spec: permit_revoke_action_spec,
574
- params: { actor_id: user_two.actor.id, permit_id },
576
+ spec: role_grant_revoke_action_spec,
577
+ params: { actor_id: user_two.actor.id, role_grant_id },
575
578
  headers: test_app.create_session_headers(),
576
579
  });
577
- assert.ok(revoke_res.ok, `permit_revoke failed: ${revoke_res.ok ? '' : JSON.stringify(revoke_res.error)}`);
580
+ assert.ok(revoke_res.ok, `role_grant_revoke failed: ${revoke_res.ok ? '' : JSON.stringify(revoke_res.error)}`);
578
581
  // 5. create token (RPC)
579
582
  const token_res = await rpc_call_for_spec({
580
583
  app: test_app.app,
@@ -628,28 +631,28 @@ export const describe_standard_admin_integration_tests = (options) => {
628
631
  assert.ok(audit_res.ok, `audit_log_list failed: ${audit_res.ok ? '' : JSON.stringify(audit_res.error)}`);
629
632
  const events = audit_res.result.events;
630
633
  // check that each operation produced at least one event.
631
- // `permit_offer_create` fires on the admin RPC; `permit_grant`
634
+ // `role_grant_offer_create` fires on the admin RPC; `role_grant_create`
632
635
  // fires when the recipient accepts (driven by offer_and_accept).
633
636
  const expected_types = [
634
637
  'login',
635
638
  'logout',
636
- 'permit_offer_create',
637
- 'permit_offer_accept',
638
- 'permit_grant',
639
- 'permit_revoke',
639
+ 'role_grant_offer_create',
640
+ 'role_grant_offer_accept',
641
+ 'role_grant_create',
642
+ 'role_grant_revoke',
640
643
  'token_create',
641
644
  'password_change',
642
645
  ];
643
646
  for (const event_type of expected_types) {
644
647
  const found = events.filter((e) => e.event_type === event_type);
645
648
  assert.ok(found.length >= 1, `Expected at least 1 '${event_type}' audit event, found ${found.length}. ` +
646
- `This may indicate audit_log_fire_and_forget was removed from a handler.`);
649
+ `This may indicate a deps.audit.emit call was removed from a handler.`);
647
650
  }
648
651
  });
649
652
  });
650
653
  // --- 8. Admin-to-admin isolation ---
651
654
  describe('admin-to-admin isolation', () => {
652
- test('admin B revoking own permit via RPC succeeds', async () => {
655
+ test('admin B revoking own role_grant via RPC succeeds', async () => {
653
656
  const test_app = await create_test_app(build_admin_test_app_options(options, get_db()));
654
657
  captured_route_specs ??= test_app.route_specs;
655
658
  // Bootstrap user is admin A. Create admin B.
@@ -657,22 +660,22 @@ export const describe_standard_admin_integration_tests = (options) => {
657
660
  username: 'admin_b_iso',
658
661
  roles: ['admin'],
659
662
  });
660
- // Seed an active permit directly — the revoke IDOR check is the
663
+ // Seed an active role_grant directly — the revoke IDOR check is the
661
664
  // subject of this test, not the grant→accept cycle.
662
- const permit = await query_grant_permit({ db: get_db() }, {
665
+ const role_grant = await query_create_role_grant({ db: get_db() }, {
663
666
  actor_id: admin_b.actor.id,
664
667
  role: grantable_role,
665
668
  granted_by: test_app.backend.actor.id,
666
669
  });
667
- // Admin B revokes their own permit via RPC — should succeed
670
+ // Admin B revokes their own role_grant via RPC — should succeed
668
671
  const revoke_res = await rpc_call_for_spec({
669
672
  app: test_app.app,
670
673
  path: rpc_path,
671
- spec: permit_revoke_action_spec,
672
- params: { actor_id: admin_b.actor.id, permit_id: permit.id },
674
+ spec: role_grant_revoke_action_spec,
675
+ params: { actor_id: admin_b.actor.id, role_grant_id: role_grant.id },
673
676
  headers: create_headers(admin_b.session_cookie),
674
677
  });
675
- assert.ok(revoke_res.ok, `permit_revoke failed: ${revoke_res.ok ? '' : JSON.stringify(revoke_res.error)}`);
678
+ assert.ok(revoke_res.ok, `role_grant_revoke failed: ${revoke_res.ok ? '' : JSON.stringify(revoke_res.error)}`);
676
679
  assert.strictEqual(revoke_res.result.revoked, true);
677
680
  });
678
681
  test('admin revoke-all sessions for another admin works', async () => {
@@ -741,14 +744,13 @@ export const describe_standard_admin_integration_tests = (options) => {
741
744
  test('exercises 401/403 on admin routes for error coverage', async () => {
742
745
  const test_app = await create_test_app(build_admin_test_app_options(options, get_db()));
743
746
  captured_route_specs ??= test_app.route_specs;
744
- // Post-RPC migration, `/api/admin` is nearly empty — admin reads
745
- // and mutations live on the RPC endpoint behind spec-level role
746
- // auth. The path-prefix carve is still the right scope here
747
+ // `/api/admin` is nearly empty — admin reads and mutations live
748
+ // on the RPC endpoint behind spec-level role auth. The path-prefix carve is still the right scope here
747
749
  // because error coverage is tracked against REST `RouteSpec`s,
748
750
  // not RPC method specs (`describe_rpc_round_trip_tests` covers
749
751
  // the admin RPC surface separately).
750
752
  const prefix = options.admin_prefix ?? '/api/admin';
751
- const admin_routes = test_app.route_specs.filter((s) => s.path.startsWith(prefix) && s.auth.type === 'role' && s.auth.role === 'admin');
753
+ const admin_routes = test_app.route_specs.filter((s) => s.path.startsWith(prefix) && (s.auth.roles?.includes('admin') ?? false));
752
754
  // Hit admin routes without auth to exercise 401 error schemas.
753
755
  for (const route of admin_routes) {
754
756
  const res = await test_app.app.request(route.path, {
@@ -53,7 +53,7 @@ export interface BootstrapTestAccountOptions {
53
53
  * `create_test_app_server` and `TestApp.create_account`.
54
54
  *
55
55
  * @mutates the underlying `options.db` — inserts rows into `account`, `actor`,
56
- * `permit` (one per role), `api_token`, and `auth_session`.
56
+ * `role_grant` (one per role), `api_token`, and `auth_session`.
57
57
  */
58
58
  export declare const bootstrap_test_account: (options: BootstrapTestAccountOptions) => Promise<{
59
59
  account: {
@@ -107,17 +107,16 @@ export interface TestAppServerOptions {
107
107
  /** Roles to grant. Default: `[ROLE_KEEPER]`. */
108
108
  roles?: Array<string>;
109
109
  /**
110
- * Backend audit event callback — wired into `backend.deps.on_audit_event`.
111
- * When `audit_log_sse: true` is passed to `create_app_server`, this runs
112
- * after the audit SSE broadcast (composed downstream by app_server).
113
- * Use to wire consumer SSE auth guards in tests.
114
- * Default: no-op.
110
+ * Backend audit event callback — threaded into `create_audit_emitter` so
111
+ * it becomes the first listener on `backend.deps.audit.on_event_chain`.
112
+ * When `audit_log_sse: true` is passed to `create_app_server`, the SSE
113
+ * listener is appended after this one. Use to wire consumer SSE auth
114
+ * guards in tests. Default: no-op.
115
115
  */
116
116
  on_audit_event?: (event: AuditLogEvent) => void;
117
117
  /**
118
- * Optional audit log config — written onto `backend.deps.audit_log_config`
119
- * before return so it lands in time for `create_app_server`'s shallow
120
- * spread of `backend.deps` (SSE branch) and the no-SSE alias branch alike.
118
+ * Optional audit log config — threaded into `create_audit_emitter` and
119
+ * captured inside `backend.deps.audit`'s closure.
121
120
  *
122
121
  * Use when the consumer registers extra event types via
123
122
  * `create_audit_log_config({extra_events})` — without this, emits for
@@ -132,7 +131,7 @@ export interface TestAppServerOptions {
132
131
  * Sets up:
133
132
  * - Auth tables (via cached PGlite factory, or reuses existing `db`)
134
133
  * - A keeper account with hashed password
135
- * - Role permits for each role in `options.roles`
134
+ * - Role role_grants for each role in `options.roles`
136
135
  * - An API token for Bearer auth
137
136
  * - A session with a signed cookie value
138
137
  *
@@ -143,10 +142,8 @@ export interface TestAppServerOptions {
143
142
  * @returns a `TestAppServer` ready for HTTP testing
144
143
  * @mutates the underlying database — when `db` is supplied, resets singleton
145
144
  * state (`bootstrap_lock.bootstrapped`, `app_settings.open_signup`) before
146
- * bootstrapping; in either branch inserts an account, actor, role permits,
147
- * API token, and session row. When `audit_log_config` is provided, also
148
- * sets `backend.deps.audit_log_config` so `create_app_server`'s shallow
149
- * spread picks it up.
145
+ * bootstrapping; in either branch inserts an account, actor, role role_grants,
146
+ * API token, and session row.
150
147
  */
151
148
  export declare const create_test_app_server: (options: TestAppServerOptions) => Promise<TestAppServer>;
152
149
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"app_server.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/app_server.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAG/B,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAGjD,OAAO,EAA2B,KAAK,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAE1E,OAAO,KAAK,EAAC,EAAE,EAAE,MAAM,EAAC,MAAM,aAAa,CAA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M,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnF,gEAAgE;IAChE,qBAAqB,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClF,iEAAiE;IACjE,2BAA2B,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxF,qDAAqD;IACrD,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE;QAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;KACtB,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IAC3B,8DAA8D;IAC9D,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,GAAU,SAAS,oBAAoB,KAAG,OAAO,CAAC,OAAO,CAyGpF,CAAC"}
@@ -5,12 +5,13 @@ import { ROLE_KEEPER } from '../auth/role_schema.js';
5
5
  import { create_validated_keyring } from '../auth/keyring.js';
6
6
  import { generate_api_token } from '../auth/api_token.js';
7
7
  import { query_create_account_with_actor } from '../auth/account_queries.js';
8
- import { query_grant_permit } from '../auth/permit_queries.js';
8
+ import { query_create_role_grant } from '../auth/role_grant_queries.js';
9
9
  import { generate_session_token, hash_session_token, AUTH_SESSION_LIFETIME_MS, query_create_session, } from '../auth/session_queries.js';
10
10
  import { query_create_api_token } from '../auth/api_token_queries.js';
11
11
  import { create_session_cookie_value } from '../auth/session_cookie.js';
12
12
  import { run_migrations } from '../db/migrate.js';
13
13
  import { AUTH_MIGRATION_NS } from '../auth/migrations.js';
14
+ import { create_audit_emitter } from '../auth/audit_emitter.js';
14
15
  import { create_app_server, } from '../server/app_server.js';
15
16
  import { generate_daemon_token, DAEMON_TOKEN_HEADER, } from '../auth/daemon_token.js';
16
17
  import { create_pglite_factory } from './db.js';
@@ -42,7 +43,7 @@ const fallback_pglite_factory = create_pglite_factory(async (db) => {
42
43
  * `create_test_app_server` and `TestApp.create_account`.
43
44
  *
44
45
  * @mutates the underlying `options.db` — inserts rows into `account`, `actor`,
45
- * `permit` (one per role), `api_token`, and `auth_session`.
46
+ * `role_grant` (one per role), `api_token`, and `auth_session`.
46
47
  */
47
48
  export const bootstrap_test_account = async (options) => {
48
49
  const { db, keyring, session_options, password, username = 'keeper', password_value = 'test-password-123', roles = [], } = options;
@@ -54,7 +55,7 @@ export const bootstrap_test_account = async (options) => {
54
55
  });
55
56
  // Grant roles
56
57
  for (const role of roles) {
57
- await query_grant_permit(deps, { actor_id: actor.id, role, granted_by: null });
58
+ await query_create_role_grant(deps, { actor_id: actor.id, role, granted_by: null });
58
59
  }
59
60
  // Create API token (account-scoped — acting actor is per-request)
60
61
  const { token: api_token, id: token_id, token_hash } = generate_api_token();
@@ -80,7 +81,7 @@ const test_log = new Logger('test', { level: 'off' });
80
81
  * Sets up:
81
82
  * - Auth tables (via cached PGlite factory, or reuses existing `db`)
82
83
  * - A keeper account with hashed password
83
- * - Role permits for each role in `options.roles`
84
+ * - Role role_grants for each role in `options.roles`
84
85
  * - An API token for Bearer auth
85
86
  * - A session with a signed cookie value
86
87
  *
@@ -91,10 +92,8 @@ const test_log = new Logger('test', { level: 'off' });
91
92
  * @returns a `TestAppServer` ready for HTTP testing
92
93
  * @mutates the underlying database — when `db` is supplied, resets singleton
93
94
  * state (`bootstrap_lock.bootstrapped`, `app_settings.open_signup`) before
94
- * bootstrapping; in either branch inserts an account, actor, role permits,
95
- * API token, and session row. When `audit_log_config` is provided, also
96
- * sets `backend.deps.audit_log_config` so `create_app_server`'s shallow
97
- * spread picks it up.
95
+ * bootstrapping; in either branch inserts an account, actor, role role_grants,
96
+ * API token, and session row.
98
97
  */
99
98
  export const create_test_app_server = async (options) => {
100
99
  const { session_options, db: existing_db, db_type = 'pglite-memory', password = stub_password_deps, username = 'keeper', password_value = 'test-password-123', roles = [ROLE_KEEPER], on_audit_event = () => { }, // eslint-disable-line @typescript-eslint/no-empty-function
@@ -117,6 +116,12 @@ export const create_test_app_server = async (options) => {
117
116
  await existing_db.query('UPDATE app_settings SET open_signup = false, updated_at = NULL, updated_by = NULL WHERE open_signup = true OR updated_at IS NOT NULL');
118
117
  // Use the caller's database — tables already created by the factory's init_schema.
119
118
  // Caller owns the DB lifecycle — close is a no-op.
119
+ const audit = create_audit_emitter({
120
+ db: existing_db,
121
+ log: test_log,
122
+ on_audit_event,
123
+ audit_log_config,
124
+ });
120
125
  backend = {
121
126
  db_type,
122
127
  db_name: 'test',
@@ -127,7 +132,7 @@ export const create_test_app_server = async (options) => {
127
132
  password,
128
133
  db: existing_db,
129
134
  log: test_log,
130
- on_audit_event,
135
+ audit,
131
136
  ...fs_stubs,
132
137
  },
133
138
  };
@@ -137,6 +142,7 @@ export const create_test_app_server = async (options) => {
137
142
  // instead of creating a new PGlite each time. Schema is reset and migrations re-run
138
143
  // on each call, but the expensive WASM cold start only happens once per worker thread.
139
144
  const db = await fallback_pglite_factory.create();
145
+ const audit = create_audit_emitter({ db, log: test_log, on_audit_event, audit_log_config });
140
146
  backend = {
141
147
  db_type: 'pglite-memory',
142
148
  db_name: '(memory)',
@@ -147,7 +153,7 @@ export const create_test_app_server = async (options) => {
147
153
  password,
148
154
  db,
149
155
  log: test_log,
150
- on_audit_event,
156
+ audit,
151
157
  ...fs_stubs,
152
158
  },
153
159
  };
@@ -161,11 +167,6 @@ export const create_test_app_server = async (options) => {
161
167
  password_value,
162
168
  roles,
163
169
  });
164
- // Land before `create_app_server`'s shallow-spread of `backend.deps` so
165
- // the SSE branch's snapshot picks it up alongside the no-SSE alias branch.
166
- if (audit_log_config !== undefined) {
167
- backend.deps.audit_log_config = audit_log_config;
168
- }
169
170
  return {
170
171
  ...backend,
171
172
  ...bootstrapped,
@@ -1 +1 @@
1
- {"version":3,"file":"assertions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/assertions.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAe7B,OAAO,KAAK,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAE3B,OAAO,KAAK,EAAC,UAAU,EAAE,eAAe,EAAC,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,UAAU,MAAM,EAAE,iBAAiB,MAAM,KAAG,MACtB,CAAC;AAE5D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,+BAA+B,GAC3C,SAAS,UAAU,EACnB,eAAe,MAAM,KACnB,IAOF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,GAAI,eAAe,MAAM,UAAU,KAAG,IAE9E,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kCAAkC,GAC9C,SAAS,UAAU,EACnB,iBAAiB,KAAK,CAAC,MAAM,CAAC,KAC5B,IAWF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GAClC,QAAQ,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,EACtC,OAAO,eAAe,EACtB,QAAQ,MAAM,KACZ,CAAC,CAAC,OAAO,GAAG,SAGd,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,GACrC,QAAQ,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,EACtC,OAAO,eAAe,EACtB,QAAQ,MAAM,EACd,MAAM,OAAO,KACX,IAIF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,UAAU,EACnB,aAAa,MAAM,EACn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KAChC,IAUF,CAAC"}
@@ -11,6 +11,7 @@ import { readFileSync } from 'node:fs';
11
11
  import { resolve, dirname } from 'node:path';
12
12
  import { fileURLToPath } from 'node:url';
13
13
  import { assert } from 'vitest';
14
+ import { is_public_auth } from '../http/auth_shape.js';
14
15
  /**
15
16
  * Resolve an absolute path relative to the caller's module.
16
17
  *
@@ -52,7 +53,7 @@ export const assert_surface_deterministic = (build_surface) => {
52
53
  export const assert_only_expected_public_routes = (surface, expected_public) => {
53
54
  const expected = new Set(expected_public);
54
55
  const actual_public = surface.routes
55
- .filter((r) => r.auth.type === 'none')
56
+ .filter((r) => is_public_auth(r.auth))
56
57
  .map((r) => `${r.method} ${r.path}`);
57
58
  const unexpected = actual_public.filter((r) => !expected.has(r));
58
59
  const missing = expected_public.filter((r) => !actual_public.includes(r));
@@ -1 +1 @@
1
- {"version":3,"file":"attack_surface.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/attack_surface.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAoB7B,OAAO,EAON,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,MAAM,yBAAyB,CAAC;AAoBjC,OAAO,EAA4B,KAAK,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAsClF,oFAAoF;AACpF,MAAM,WAAW,sBAAsB;IACtC,+EAA+E;IAC/E,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5B,yDAAyD;IACzD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,sBAAsB,KAAG,IAkH3E,CAAC;AAIF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uCAAuC,GACnD,UAAU,2BAA2B,GAAG,IAAI,GAAG,SAAS,KACtD,2BAA2B,GAAG,IAWhC,CAAC;AAEF,0DAA0D;AAC1D,MAAM,WAAW,4BAA4B;IAC5C,+EAA+E;IAC/E,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5B,yDAAyD;IACzD,aAAa,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,sBAAsB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtC,gHAAgH;IAChH,uBAAuB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvC,yDAAyD;IACzD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iEAAiE;IACjE,eAAe,CAAC,EAAE,4BAA4B,CAAC;IAC/C;;;;;;;;;;;OAWG;IACH,sBAAsB,CAAC,EAAE,2BAA2B,GAAG,IAAI,CAAC;CAC5D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,sCAAsC,GAClD,SAAS,4BAA4B,KACnC,IAuEF,CAAC"}
1
+ {"version":3,"file":"attack_surface.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/attack_surface.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAoB7B,OAAO,EAON,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,MAAM,yBAAyB,CAAC;AAoBjC,OAAO,EAA4B,KAAK,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAsClF,oFAAoF;AACpF,MAAM,WAAW,sBAAsB;IACtC,+EAA+E;IAC/E,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5B,yDAAyD;IACzD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,sBAAsB,KAAG,IA4H3E,CAAC;AAIF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uCAAuC,GACnD,UAAU,2BAA2B,GAAG,IAAI,GAAG,SAAS,KACtD,2BAA2B,GAAG,IAWhC,CAAC;AAEF,0DAA0D;AAC1D,MAAM,WAAW,4BAA4B;IAC5C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