@fuzdev/fuz_app 0.181.0 → 0.183.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 (267) hide show
  1. package/README.md +2 -0
  2. package/dist/actions/CLAUDE.md +28 -10
  3. package/dist/actions/action_rpc.d.ts +11 -1
  4. package/dist/actions/action_rpc.d.ts.map +1 -1
  5. package/dist/actions/action_rpc.js +3 -2
  6. package/dist/actions/action_types.d.ts +16 -1
  7. package/dist/actions/action_types.d.ts.map +1 -1
  8. package/dist/actions/action_types.js +1 -1
  9. package/dist/actions/notification_sender.d.ts +83 -0
  10. package/dist/actions/notification_sender.d.ts.map +1 -0
  11. package/dist/actions/notification_sender.js +85 -0
  12. package/dist/actions/perform_action.d.ts +9 -0
  13. package/dist/actions/perform_action.d.ts.map +1 -1
  14. package/dist/actions/perform_action.js +22 -13
  15. package/dist/actions/register_action_ws.d.ts +14 -0
  16. package/dist/actions/register_action_ws.d.ts.map +1 -1
  17. package/dist/actions/register_action_ws.js +3 -2
  18. package/dist/actions/ws_socket_session.d.ts +3 -0
  19. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  20. package/dist/actions/ws_socket_session.js +2 -1
  21. package/dist/auth/CLAUDE.md +113 -70
  22. package/dist/auth/account_actions.d.ts.map +1 -1
  23. package/dist/auth/account_actions.js +13 -3
  24. package/dist/auth/account_queries.d.ts +158 -16
  25. package/dist/auth/account_queries.d.ts.map +1 -1
  26. package/dist/auth/account_queries.js +189 -18
  27. package/dist/auth/account_routes.d.ts +6 -4
  28. package/dist/auth/account_routes.d.ts.map +1 -1
  29. package/dist/auth/account_routes.js +98 -92
  30. package/dist/auth/admin_actions.d.ts.map +1 -1
  31. package/dist/auth/admin_actions.js +93 -45
  32. package/dist/auth/api_token_queries.d.ts +13 -5
  33. package/dist/auth/api_token_queries.d.ts.map +1 -1
  34. package/dist/auth/api_token_queries.js +24 -9
  35. package/dist/auth/audit_emitter.d.ts +75 -84
  36. package/dist/auth/audit_emitter.d.ts.map +1 -1
  37. package/dist/auth/audit_emitter.js +83 -71
  38. package/dist/auth/audit_log_schema.d.ts +10 -5
  39. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  40. package/dist/auth/audit_log_schema.js +22 -6
  41. package/dist/auth/bearer_auth.d.ts.map +1 -1
  42. package/dist/auth/bearer_auth.js +3 -2
  43. package/dist/auth/bootstrap_account.d.ts +31 -13
  44. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  45. package/dist/auth/bootstrap_account.js +34 -15
  46. package/dist/auth/bootstrap_routes.d.ts +1 -1
  47. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  48. package/dist/auth/bootstrap_routes.js +7 -14
  49. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  50. package/dist/auth/daemon_token_middleware.js +12 -1
  51. package/dist/auth/deps.d.ts +18 -5
  52. package/dist/auth/deps.d.ts.map +1 -1
  53. package/dist/auth/deps.js +3 -2
  54. package/dist/auth/request_context.d.ts +73 -73
  55. package/dist/auth/request_context.d.ts.map +1 -1
  56. package/dist/auth/request_context.js +78 -96
  57. package/dist/auth/resolved_auth.d.ts +16 -11
  58. package/dist/auth/resolved_auth.d.ts.map +1 -1
  59. package/dist/auth/resolved_auth.js +6 -6
  60. package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
  61. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  62. package/dist/auth/role_grant_offer_action_specs.js +2 -1
  63. package/dist/auth/role_grant_offer_actions.d.ts +32 -12
  64. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  65. package/dist/auth/role_grant_offer_actions.js +91 -116
  66. package/dist/auth/role_grant_offer_notifications.d.ts +87 -38
  67. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  68. package/dist/auth/role_grant_offer_notifications.js +75 -22
  69. package/dist/auth/role_grant_offer_queries.d.ts +155 -18
  70. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  71. package/dist/auth/role_grant_offer_queries.js +262 -73
  72. package/dist/auth/role_grant_offer_schema.js +1 -1
  73. package/dist/auth/role_grant_queries.d.ts +43 -52
  74. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  75. package/dist/auth/role_grant_queries.js +50 -74
  76. package/dist/auth/role_grant_sql.d.ts +21 -0
  77. package/dist/auth/role_grant_sql.d.ts.map +1 -1
  78. package/dist/auth/role_grant_sql.js +21 -0
  79. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  80. package/dist/auth/self_service_role_actions.js +17 -21
  81. package/dist/auth/session_queries.d.ts +40 -16
  82. package/dist/auth/session_queries.d.ts.map +1 -1
  83. package/dist/auth/session_queries.js +68 -29
  84. package/dist/auth/signup_routes.d.ts.map +1 -1
  85. package/dist/auth/signup_routes.js +90 -38
  86. package/dist/auth/standard_rpc_actions.d.ts +6 -19
  87. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  88. package/dist/auth/standard_rpc_actions.js +5 -6
  89. package/dist/auth/token_scope.d.ts +1 -1
  90. package/dist/auth/token_scope.js +1 -1
  91. package/dist/db/sql_columns.d.ts +1 -1
  92. package/dist/db/sql_columns.js +1 -1
  93. package/dist/http/CLAUDE.md +22 -16
  94. package/dist/http/auth_shape.d.ts +1 -1
  95. package/dist/http/db_routes.d.ts +7 -22
  96. package/dist/http/db_routes.d.ts.map +1 -1
  97. package/dist/http/db_routes.js +72 -72
  98. package/dist/http/error_schemas.d.ts +9 -21
  99. package/dist/http/error_schemas.d.ts.map +1 -1
  100. package/dist/http/error_schemas.js +14 -24
  101. package/dist/http/pending_effects.d.ts +42 -4
  102. package/dist/http/pending_effects.d.ts.map +1 -1
  103. package/dist/http/pending_effects.js +34 -4
  104. package/dist/http/route_spec.d.ts +2 -2
  105. package/dist/server/app_backend.d.ts.map +1 -1
  106. package/dist/server/app_backend.js +3 -1
  107. package/dist/server/app_server.d.ts +69 -18
  108. package/dist/server/app_server.d.ts.map +1 -1
  109. package/dist/server/app_server.js +74 -10
  110. package/dist/server/serve_fact_route.d.ts +3 -3
  111. package/dist/server/serve_fact_route.js +12 -12
  112. package/dist/testing/CLAUDE.md +259 -790
  113. package/dist/testing/adversarial_404.d.ts +6 -1
  114. package/dist/testing/adversarial_404.d.ts.map +1 -1
  115. package/dist/testing/adversarial_404.js +38 -17
  116. package/dist/testing/app_server.d.ts +20 -140
  117. package/dist/testing/app_server.d.ts.map +1 -1
  118. package/dist/testing/app_server.js +48 -125
  119. package/dist/testing/audit_drift_guard.d.ts +11 -6
  120. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  121. package/dist/testing/audit_drift_guard.js +15 -8
  122. package/dist/testing/auth_apps.js +1 -1
  123. package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
  124. package/dist/testing/cross_backend/account_lifecycle.js +43 -0
  125. package/dist/testing/cross_backend/audit_cross_helpers.d.ts +12 -9
  126. package/dist/testing/cross_backend/audit_cross_helpers.d.ts.map +1 -1
  127. package/dist/testing/cross_backend/audit_cross_helpers.js +13 -14
  128. package/dist/testing/cross_backend/capabilities.d.ts +9 -6
  129. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  130. package/dist/testing/cross_backend/capabilities.js +11 -7
  131. package/dist/testing/cross_backend/capability_mounts.d.ts +103 -0
  132. package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -0
  133. package/dist/testing/cross_backend/capability_mounts.js +423 -0
  134. package/dist/testing/cross_backend/cell_moderate.js +2 -2
  135. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  136. package/dist/testing/cross_backend/cell_relations.js +12 -11
  137. package/dist/testing/cross_backend/conformance_principal.d.ts +54 -0
  138. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -0
  139. package/dist/testing/cross_backend/conformance_principal.js +283 -0
  140. package/dist/testing/cross_backend/conformance_table.d.ts +2 -50
  141. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  142. package/dist/testing/cross_backend/conformance_table.js +2 -270
  143. package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -1
  144. package/dist/testing/cross_backend/credential_deadline.js +2 -0
  145. package/dist/testing/cross_backend/credential_wire.d.ts +1 -1
  146. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -1
  147. package/dist/testing/cross_backend/db_state_diff.d.ts +72 -0
  148. package/dist/testing/cross_backend/db_state_diff.d.ts.map +1 -0
  149. package/dist/testing/cross_backend/db_state_diff.js +444 -0
  150. package/dist/testing/cross_backend/declared_skips.d.ts +68 -0
  151. package/dist/testing/cross_backend/declared_skips.d.ts.map +1 -0
  152. package/dist/testing/cross_backend/declared_skips.js +132 -0
  153. package/dist/testing/cross_backend/default_spine_surface.d.ts +1 -26
  154. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  155. package/dist/testing/cross_backend/default_spine_surface.js +2 -6
  156. package/dist/testing/cross_backend/differential.d.ts +11 -2
  157. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  158. package/dist/testing/cross_backend/differential.js +35 -11
  159. package/dist/testing/cross_backend/differential_normalize.d.ts +12 -0
  160. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  161. package/dist/testing/cross_backend/differential_normalize.js +16 -0
  162. package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -10
  163. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  164. package/dist/testing/cross_backend/full_spine_mount.js +4 -4
  165. package/dist/testing/cross_backend/in_process_setup.d.ts +22 -12
  166. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  167. package/dist/testing/cross_backend/in_process_setup.js +151 -134
  168. package/dist/testing/cross_backend/login_security.d.ts +12 -0
  169. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  170. package/dist/testing/cross_backend/login_security.js +21 -4
  171. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +0 -2
  172. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -1
  173. package/dist/testing/cross_backend/request_target_conformance_wire.js +3 -1
  174. package/dist/testing/cross_backend/revocation_drivers.d.ts +18 -5
  175. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  176. package/dist/testing/cross_backend/revocation_drivers.js +18 -10
  177. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +1 -1
  178. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -1
  179. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  180. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +33 -1
  181. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +5 -4
  182. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  183. package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +183 -30
  184. package/dist/testing/cross_backend/role_grant_participation.js +4 -4
  185. package/dist/testing/cross_backend/rpc_adversarial.js +1 -1
  186. package/dist/testing/cross_backend/session_cap.d.ts +2 -2
  187. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  188. package/dist/testing/cross_backend/session_cap.js +48 -16
  189. package/dist/testing/cross_backend/setup.d.ts +31 -1
  190. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  191. package/dist/testing/cross_backend/setup.js +32 -1
  192. package/dist/testing/cross_backend/spine_suites.d.ts +123 -12
  193. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  194. package/dist/testing/cross_backend/spine_suites.js +454 -57
  195. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  196. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  197. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  198. package/dist/testing/cross_backend/sse_round_trip.d.ts +9 -1
  199. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  200. package/dist/testing/cross_backend/sse_round_trip.js +123 -27
  201. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  202. package/dist/testing/cross_backend/testing_backdoor.js +4 -2
  203. package/dist/testing/cross_backend/testing_reset_actions.d.ts +59 -27
  204. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  205. package/dist/testing/cross_backend/testing_reset_actions.js +66 -42
  206. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  207. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  208. package/dist/testing/cross_backend/transport_composition.js +7 -3
  209. package/dist/testing/cross_backend/ws_round_trip.d.ts +5 -0
  210. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  211. package/dist/testing/cross_backend/ws_round_trip.js +54 -8
  212. package/dist/testing/data_exposure.d.ts.map +1 -1
  213. package/dist/testing/data_exposure.js +3 -0
  214. package/dist/testing/db.d.ts +0 -32
  215. package/dist/testing/db.d.ts.map +1 -1
  216. package/dist/testing/db.js +0 -86
  217. package/dist/testing/db_entities.d.ts +14 -0
  218. package/dist/testing/db_entities.d.ts.map +1 -1
  219. package/dist/testing/db_entities.js +17 -0
  220. package/dist/testing/db_invariant_queries.d.ts +259 -0
  221. package/dist/testing/db_invariant_queries.d.ts.map +1 -0
  222. package/dist/testing/db_invariant_queries.js +400 -0
  223. package/dist/testing/db_invariants.d.ts +106 -0
  224. package/dist/testing/db_invariants.d.ts.map +1 -0
  225. package/dist/testing/db_invariants.gen.sql.d.ts +11 -0
  226. package/dist/testing/db_invariants.gen.sql.d.ts.map +1 -0
  227. package/dist/testing/db_invariants.gen.sql.js +13 -0
  228. package/dist/testing/db_invariants.js +141 -0
  229. package/dist/testing/db_invariants.sql +152 -0
  230. package/dist/testing/describe_db.d.ts +36 -0
  231. package/dist/testing/describe_db.d.ts.map +1 -0
  232. package/dist/testing/describe_db.js +71 -0
  233. package/dist/testing/integration.d.ts +6 -9
  234. package/dist/testing/integration.d.ts.map +1 -1
  235. package/dist/testing/integration.js +9 -13
  236. package/dist/testing/integration_helpers.d.ts +1 -1
  237. package/dist/testing/integration_helpers.d.ts.map +1 -1
  238. package/dist/testing/middleware.d.ts +1 -1
  239. package/dist/testing/middleware.js +5 -5
  240. package/dist/testing/rate_limiting.d.ts +1 -1
  241. package/dist/testing/rate_limiting.d.ts.map +1 -1
  242. package/dist/testing/rate_limiting.js +3 -2
  243. package/dist/testing/resolved_auth.d.ts +3 -1
  244. package/dist/testing/resolved_auth.d.ts.map +1 -1
  245. package/dist/testing/resolved_auth.js +4 -4
  246. package/dist/testing/role_grant_helpers.d.ts +1 -1
  247. package/dist/testing/role_grant_helpers.d.ts.map +1 -1
  248. package/dist/testing/round_trip.d.ts.map +1 -1
  249. package/dist/testing/round_trip.js +3 -0
  250. package/dist/testing/rpc_attack_surface.d.ts +8 -6
  251. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  252. package/dist/testing/rpc_attack_surface.js +69 -6
  253. package/dist/testing/rpc_round_trip.d.ts +1 -1
  254. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  255. package/dist/testing/rpc_round_trip.js +3 -0
  256. package/dist/testing/sse_round_trip.d.ts +1 -1
  257. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  258. package/dist/testing/sse_round_trip.js +13 -4
  259. package/dist/testing/stubs.d.ts +4 -2
  260. package/dist/testing/stubs.d.ts.map +1 -1
  261. package/dist/testing/stubs.js +15 -7
  262. package/dist/testing/test_app.d.ts +166 -0
  263. package/dist/testing/test_app.d.ts.map +1 -0
  264. package/dist/testing/test_app.js +124 -0
  265. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  266. package/dist/testing/ws_round_trip.js +8 -4
  267. package/package.json +1 -1
@@ -48,7 +48,7 @@ export interface BearerAuthTestCase extends BearerAuthTestOptions {
48
48
  * `ResolvedAuth` — its fields and no others.
49
49
  */
50
50
  assert_account_set?: boolean;
51
- /** Expected `ResolvedAuth.account_id` when `assert_account_set` is true. */
51
+ /** Expected `ResolvedAuth.account.id` when `assert_account_set` is true. */
52
52
  expected_account_id?: string;
53
53
  /** If set, assert the resolved `api_token_id` after a successful bearer auth. */
54
54
  expected_api_token_id?: string;
@@ -119,7 +119,7 @@ export const create_bearer_auth_test_app = (tc) => {
119
119
  app.use('*', async (c, next) => {
120
120
  c.set(RESOLVED_AUTH_KEY, create_test_resolved_auth({
121
121
  credential_type: 'session',
122
- account_id: pre_context.account.id
122
+ account: pre_context.account
123
123
  }));
124
124
  c.set(REQUEST_CONTEXT_KEY, pre_context);
125
125
  c.set(TEST_CONTEXT_PRESET_KEY, TEST_CONTEXT_PRESET);
@@ -194,10 +194,10 @@ export const describe_bearer_auth_cases = (suite_name, cases) => {
194
194
  const resolved = body.resolved_auth;
195
195
  if (tc.assert_account_set) {
196
196
  assert.ok(resolved, 'the request should resolve to a credential');
197
- assert.deepStrictEqual(Object.keys(resolved).sort(), ['account_id', 'api_token_id', 'credential_deadline', 'credential_type', 'scope'], 'the resolved credential should be the api_token arm, with no other fields');
197
+ assert.deepStrictEqual(Object.keys(resolved).sort(), ['account', 'api_token_id', 'credential_deadline', 'credential_type', 'scope'], 'the resolved credential should be the api_token arm, with no other fields');
198
198
  assert.strictEqual(resolved.credential_type, 'api_token');
199
199
  if (tc.expected_account_id !== undefined) {
200
- assert.strictEqual(resolved.account_id, tc.expected_account_id, 'account_id should match the validated api_token.account_id');
200
+ assert.strictEqual(resolved.account?.id, tc.expected_account_id, 'account_id should match the validated api_token.account_id');
201
201
  }
202
202
  }
203
203
  if (tc.expected_api_token_id !== undefined) {
@@ -276,13 +276,13 @@ export const create_test_middleware_stack_app = (options) => {
276
276
  app.use(ORIGIN_MIDDLEWARE_PATH, origin_mw);
277
277
  app.use(AUTH_MIDDLEWARE_PATH, bearer_mw);
278
278
  // echo route for assertions — exposes the account-grain identity bearer
279
- // auth writes (`ResolvedAuth.account_id`); the full request context is the
279
+ // auth writes (`ResolvedAuth.account`); the full request context is the
280
280
  // dispatcher's authorization phase concern, not middleware.
281
281
  app.get(TEST_MIDDLEWARE_PATH, (c) => {
282
282
  return c.json({
283
283
  ok: true,
284
284
  client_ip: get_client_ip(c),
285
- account_id: get_resolved_auth(c)?.account_id ?? null
285
+ account_id: get_resolved_auth(c)?.account.id ?? null
286
286
  });
287
287
  });
288
288
  return {
@@ -2,7 +2,7 @@ import './assert_dev_env.js';
2
2
  import type { SessionOptions } from '../auth/session_cookie.js';
3
3
  import type { AppServerContext } from '../server/app_server_context.js';
4
4
  import type { RouteSpec } from '../http/route_spec.js';
5
- import { type SuiteAppOptions } from './app_server.js';
5
+ import { type SuiteAppOptions } from './test_app.js';
6
6
  import { type DbFactory } from './db.js';
7
7
  import type { RpcEndpointsSuiteOption } from './rpc_helpers.js';
8
8
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"rate_limiting.d.ts","sourceRoot":"","sources":["../../src/lib/testing/rate_limiting.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA2B7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,EAIN,KAAK,SAAS,EACd,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAIhE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,4CAA4C;IAC5C,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,wDAAwD;IACxD,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,iDAAiD;IACjD,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAChC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACxC;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,uBAAuB,KAAG,IA2J/E,CAAC"}
1
+ {"version":3,"file":"rate_limiting.d.ts","sourceRoot":"","sources":["../../src/lib/testing/rate_limiting.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA2B7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,EAGN,KAAK,SAAS,EACd,MAAM,SAAS,CAAC;AAGjB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAIhE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,4CAA4C;IAC5C,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,wDAAwD;IACxD,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,iDAAiD;IACjD,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAChC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACxC;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,uBAAuB,KAAG,IA2J/E,CAAC"}
@@ -25,9 +25,10 @@ import { parse_or_throw } from '@fuzdev/fuz_schema/schema.ts';
25
25
  import { RateLimiter } from '../rate_limiter.js';
26
26
  import { REST_RATE_LIMIT_EXCEEDED } from '../http/error_schemas.js';
27
27
  import { AUTH_MIGRATION_NS } from '../auth/migrations.js';
28
- import { create_test_app } from './app_server.js';
28
+ import { create_test_app } from './test_app.js';
29
29
  import { create_test_request_headers } from './test_origin.js';
30
- import { create_default_db_factory, create_describe_db, auth_integration_truncate_tables } from './db.js';
30
+ import { create_default_db_factory, auth_integration_truncate_tables } from './db.js';
31
+ import { create_describe_db } from './describe_db.js';
31
32
  import { find_auth_route, assert_rate_limit_retry_after_header } from './integration_helpers.js';
32
33
  import { run_migrations } from '../db/migrate.js';
33
34
  /**
@@ -1,11 +1,13 @@
1
1
  import './assert_dev_env.js';
2
+ import type { Account } from '../auth/account_schema.js';
2
3
  import type { BuiltinCredentialType } from '../auth/credential_type_schema.js';
3
4
  import type { ResolvedAuth } from '../auth/resolved_auth.js';
4
5
  import { type TokenScope } from '../auth/token_scope.js';
5
6
  /** Options for `create_test_resolved_auth`. */
6
7
  export interface TestResolvedAuthOptions {
7
8
  credential_type: BuiltinCredentialType;
8
- account_id: string;
9
+ /** The account the credential resolved — the row the authorization phase builds on. */
10
+ account: Account;
9
11
  /**
10
12
  * The raw session token a `session` credential carries, hashed into its
11
13
  * `session_hash` the way the session leg hashes the cookie's. Default a
@@ -1 +1 @@
1
- {"version":3,"file":"resolved_auth.d.ts","sourceRoot":"","sources":["../../src/lib/testing/resolved_auth.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAW7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAE3E,+CAA+C;AAC/C,MAAM,WAAW,uBAAuB;IACvC,eAAe,EAAE,qBAAqB,CAAC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uGAAuG;IACvG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8FAA8F;IAC9F,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,uBAAuB,KAAG,YAsB5E,CAAC"}
1
+ {"version":3,"file":"resolved_auth.d.ts","sourceRoot":"","sources":["../../src/lib/testing/resolved_auth.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAW7B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAE3E,+CAA+C;AAC/C,MAAM,WAAW,uBAAuB;IACvC,eAAe,EAAE,qBAAqB,CAAC;IACvC,uFAAuF;IACvF,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uGAAuG;IACvG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8FAA8F;IAC9F,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,iFAAiF;IACjF,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,uBAAuB,KAAG,YAsB5E,CAAC"}
@@ -17,25 +17,25 @@ import { token_scope_full } from '../auth/token_scope.js';
17
17
  * @returns the resolved credential
18
18
  */
19
19
  export const create_test_resolved_auth = (options) => {
20
- const { credential_type, account_id } = options;
20
+ const { credential_type, account } = options;
21
21
  const credential_deadline = options.credential_deadline ?? null;
22
22
  switch (credential_type) {
23
23
  case 'session':
24
24
  return {
25
25
  credential_type,
26
- account_id,
26
+ account,
27
27
  session_hash: hash_session_token(options.session_id ?? create_uuid()),
28
28
  credential_deadline
29
29
  };
30
30
  case 'api_token':
31
31
  return {
32
32
  credential_type,
33
- account_id,
33
+ account,
34
34
  api_token_id: options.api_token_id ?? create_uuid(),
35
35
  scope: options.scope ?? token_scope_full(),
36
36
  credential_deadline
37
37
  };
38
38
  case 'daemon_token':
39
- return { credential_type, account_id, credential_deadline: null };
39
+ return { credential_type, account, credential_deadline: null };
40
40
  }
41
41
  };
@@ -1,6 +1,6 @@
1
1
  import './assert_dev_env.js';
2
2
  import type { Uuid } from '../primitive_schemas.js';
3
- import type { TestAccount, TestApp } from './app_server.js';
3
+ import type { TestAccount, TestApp } from './test_app.js';
4
4
  import type { TestFixture } from './cross_backend/setup.js';
5
5
  import { type RpcCallArgs } from './rpc_helpers.js';
6
6
  export interface RoleGrantOfferAndAcceptArgs {
@@ -1 +1 @@
1
- {"version":3,"file":"role_grant_helpers.d.ts","sourceRoot":"","sources":["../../src/lib/testing/role_grant_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiB7B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAMpD,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEvE,MAAM,WAAW,2BAA2B;IAC3C,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC;IAC7C,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GACvC,MAAM,2BAA2B,KAC/B,OAAO,CAAC;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,aAAa,EAAE,IAAI,CAAA;CAAE,CAyBjD,CAAC"}
1
+ {"version":3,"file":"role_grant_helpers.d.ts","sourceRoot":"","sources":["../../src/lib/testing/role_grant_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiB7B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAMpD,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEvE,MAAM,WAAW,2BAA2B;IAC3C,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC;IAC7C,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GACvC,MAAM,2BAA2B,KAC/B,OAAO,CAAC;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,aAAa,EAAE,IAAI,CAAA;CAAE,CAyBjD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"round_trip.d.ts","sourceRoot":"","sources":["../../src/lib/testing/round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA+B7B,OAAO,EASN,KAAK,aAAa,EAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE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CAAC;AAEzD,oDAAoD;AACpD,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,kDAAkD;IAClD,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,+EAA+E;IAC/E,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD;;;;OAIG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAAC,EAAE,GAAG,CACrB,MAAM,EACN,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CACnF,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,0BAA0B,GACtC,WAAW,MAAM,EACjB,QAAQ,MAAM,EACd,MAAM,OAAO,EACb,WAAW,aAAa,KACtB,IAiBF,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,8BAA8B,GAAI,SAAS,oBAAoB,KAAG,IAqK9E,CAAC"}
@@ -21,6 +21,7 @@ import './assert_dev_env.js';
21
21
  * @module
22
22
  */
23
23
  import { describe, test, beforeAll, assert } from 'vitest';
24
+ import { check_db_invariants_after_all } from './db_invariants.js';
24
25
  import { ROLE_ADMIN } from '../auth/role_schema.js';
25
26
  import { format_route_key } from '../http/surface_query.js';
26
27
  import { ERROR_CREDENTIAL_TYPE_REQUIRED } from '../http/error_schemas.js';
@@ -79,6 +80,8 @@ export const describe_round_trip_validation = (options) => {
79
80
  const skip_set = new Set(options.skip_routes);
80
81
  describe('round-trip validation', () => {
81
82
  let fixture;
83
+ // `fixture` is unassigned until `beforeAll` runs, which the check allows for
84
+ check_db_invariants_after_all(() => fixture);
82
85
  let authed_account;
83
86
  let admin_account;
84
87
  beforeAll(async () => {
@@ -7,12 +7,14 @@ export interface RpcAttackSurfaceOptions {
7
7
  /** All roles in the app (e.g. `['admin', 'keeper']`). */
8
8
  roles: Array<string>;
9
9
  /**
10
- * Valid params per method (method name → params) to build its adversarial
11
- * params cases from, in place of the generated base — for an input whose
12
- * valid shape the generator can't reach. Each must pass the method's input
13
- * schema; one that doesn't throws at collection, naming the method. The
14
- * cases are sent as a single-actor principal, so an override omits
15
- * `acting`. The cross-process twin is
10
+ * Valid params per method (method name → params), in place of the
11
+ * generated base — for an input whose valid shape the generator can't
12
+ * reach. They seed the adversarial params cases and the "correct auth
13
+ * passes" request. Each must pass the method's input schema: in the params
14
+ * group one that doesn't throws at collection, naming the method; in
15
+ * "correct auth passes" its 400 fails the method's test, the handler
16
+ * unreached. The params cases are sent as a single-actor principal, so an
17
+ * override omits `acting`. The cross-process twin is
16
18
  * `RpcAdversarialCrossTestOptions.input_overrides`.
17
19
  */
18
20
  input_overrides?: ReadonlyMap<string, Record<string, unknown>>;
@@ -1 +1 @@
1
- {"version":3,"file":"rpc_attack_surface.d.ts","sourceRoot":"","sources":["../../src/lib/testing/rpc_attack_surface.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAkB7B,OAAO,KAAK,EAGX,cAAc,EACd,MAAM,oBAAoB,CAAC;AA+B5B,uDAAuD;AACvD,MAAM,WAAW,uBAAuB;IACvC,+FAA+F;IAC/F,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5B,yDAAyD;IACzD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC/D;AA2VD;;;;;;;;;GASG;AACH,eAAO,MAAM,iCAAiC,GAAI,SAAS,uBAAuB,KAAG,IAOpF,CAAC"}
1
+ {"version":3,"file":"rpc_attack_surface.d.ts","sourceRoot":"","sources":["../../src/lib/testing/rpc_attack_surface.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAmB7B,OAAO,KAAK,EAGX,cAAc,EACd,MAAM,oBAAoB,CAAC;AAmC5B,uDAAuD;AACvD,MAAM,WAAW,uBAAuB;IACvC,+FAA+F;IAC/F,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5B,yDAAyD;IACzD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC/D;AAuaD;;;;;;;;;GASG;AACH,eAAO,MAAM,iCAAiC,GAAI,SAAS,uBAAuB,KAAG,IAOpF,CAAC"}
@@ -13,10 +13,14 @@ import './assert_dev_env.js';
13
13
  * @module
14
14
  */
15
15
  import { test, assert, describe } from 'vitest';
16
+ import { Logger } from '@fuzdev/fuz_util/log.ts';
16
17
  import { is_keeper_auth, is_public_auth, is_role_auth } from '../http/auth_shape.js';
17
18
  import { JSONRPC_ERROR_CODES } from '../http/jsonrpc_errors.js';
18
19
  import { create_auth_test_apps, create_test_app_from_specs, create_test_request_context, select_auth_app } from './auth_apps.js';
19
20
  import { generate_valid_body } from './schema_generators.js';
21
+ import { create_rpc_endpoint } from '../actions/action_rpc.js';
22
+ import { format_route_key } from '../http/surface_query.js';
23
+ import { noop_notification_sender } from '../actions/notification_sender.js';
20
24
  import { create_rpc_post_init, create_rpc_get_url, assert_jsonrpc_error_response } from './rpc_helpers.js';
21
25
  import { assert_rpc_envelope_refusal, create_rpc_envelope_cases, generate_rpc_params_test_cases, to_rpc_envelope_request } from './rpc_envelope_cases.js';
22
26
  import { expected_invalid_reason } from './adversarial_input_cases.js';
@@ -35,6 +39,57 @@ const find_rpc_action = (rpc_endpoint_specs, endpoint_path, method_name) => {
35
39
  const ep = rpc_endpoint_specs.find((e) => e.path === endpoint_path);
36
40
  return ep?.actions.find((a) => a.spec.method === method_name);
37
41
  };
42
+ /** The key a recording stub notes its call under: the endpoint path and method. */
43
+ const to_reached_key = (endpoint_path, method_name) => `${endpoint_path} ${method_name}`;
44
+ /**
45
+ * The route specs with every RPC endpoint's routes rebuilt over its actions,
46
+ * each handler swapped for a stub that records its call in `reached` and
47
+ * answers `null`, so a test that the handler is reached never depends on
48
+ * what the handler would do over stub deps (a live re-read's 401). Each
49
+ * endpoint's routes take the place of its first route in the list, matched
50
+ * on method and path, so another route at the endpoint's path stays; the
51
+ * rest of the list is kept in order. The endpoints mount with no rate limiters,
52
+ * a silent logger (a stub's `null` fails a non-null output schema, which DEV
53
+ * validation only logs), and the no-op notification sender.
54
+ *
55
+ * @param route_specs - the app's route specs, the endpoints' routes among them
56
+ * @param rpc_endpoint_specs - the endpoints whose handlers are stubbed
57
+ * @param reached - where each stub records its call (`to_reached_key`)
58
+ * @returns the route specs with the endpoints rebuilt
59
+ */
60
+ const stub_rpc_endpoint_handlers = (route_specs, rpc_endpoint_specs, reached) => {
61
+ const log = new Logger('test:rpc_attack_surface', { level: 'off' });
62
+ // each endpoint's rebuilt routes, keyed by every `METHOD path` they serve
63
+ const rebuilt_by_key = new Map();
64
+ for (const endpoint of rpc_endpoint_specs) {
65
+ const rebuilt = create_rpc_endpoint({
66
+ path: endpoint.path,
67
+ actions: endpoint.actions.map((action) => ({
68
+ spec: action.spec,
69
+ handler: () => {
70
+ reached.add(to_reached_key(endpoint.path, action.spec.method));
71
+ return null;
72
+ }
73
+ })),
74
+ log,
75
+ action_ip_rate_limiter: null,
76
+ action_account_rate_limiter: null,
77
+ notification_sender: noop_notification_sender
78
+ });
79
+ for (const spec of rebuilt)
80
+ rebuilt_by_key.set(format_route_key(spec), rebuilt);
81
+ }
82
+ const mounted = new Set();
83
+ return route_specs.flatMap((spec) => {
84
+ const rebuilt = rebuilt_by_key.get(format_route_key(spec));
85
+ if (!rebuilt)
86
+ return [spec];
87
+ if (mounted.has(rebuilt))
88
+ return [];
89
+ mounted.add(rebuilt);
90
+ return rebuilt;
91
+ });
92
+ };
38
93
  // --- Auth enforcement ---
39
94
  /**
40
95
  * Generate adversarial auth enforcement tests for RPC endpoints.
@@ -48,7 +103,9 @@ const find_rpc_action = (rpc_endpoint_specs, endpoint_path, method_name) => {
48
103
  * - wrong role → error code -32002 — every role method with non-matching roles
49
104
  * - authenticated without role → -32002 — every role method, no-role context
50
105
  * - keeper rejects non-daemon credentials → -32002 — session and api_token rejected
51
- * - correct auth passes — every protected method, assert not 401/403
106
+ * - correct auth passes — every protected method, sent valid params by the
107
+ * app its auth admits, reaches its handler, a recording stub
108
+ * (`stub_rpc_endpoint_handlers`), at 200
52
109
  */
53
110
  const describe_rpc_auth = (options) => {
54
111
  const { build, roles } = options;
@@ -56,6 +113,8 @@ const describe_rpc_auth = (options) => {
56
113
  if (surface.rpc_endpoints.length === 0)
57
114
  return;
58
115
  const apps = create_auth_test_apps(route_specs, roles);
116
+ const reached = new Set();
117
+ const stubbed_apps = create_auth_test_apps(stub_rpc_endpoint_handlers(route_specs, rpc_endpoint_specs, reached), roles);
59
118
  describe('RPC auth enforcement', () => {
60
119
  for (const endpoint of surface.rpc_endpoints) {
61
120
  const protected_methods = filter_protected_rpc_methods(endpoint);
@@ -138,11 +197,15 @@ const describe_rpc_auth = (options) => {
138
197
  describe('correct auth passes', () => {
139
198
  for (const method of protected_methods) {
140
199
  test(method.name, async () => {
141
- const app = select_auth_app(apps, method.auth);
142
- const res = await app.request(endpoint.path, create_rpc_post_init(method.name));
143
- // handler may error (500, 404 from stub deps) — that's fine
144
- assert.notStrictEqual(res.status, 401, 'should not be 401');
145
- assert.notStrictEqual(res.status, 403, 'should not be 403');
200
+ const action = find_rpc_action(rpc_endpoint_specs, endpoint.path, method.name);
201
+ assert.ok(action, `surface has method '${method.name}' but no matching RpcAction in rpc_endpoints`);
202
+ const params = options.input_overrides?.get(method.name) ?? generate_valid_body(action.spec.input);
203
+ const key = to_reached_key(endpoint.path, method.name);
204
+ reached.delete(key);
205
+ const app = select_auth_app(stubbed_apps, method.auth);
206
+ const res = await app.request(endpoint.path, create_rpc_post_init(method.name, params));
207
+ assert.ok(reached.has(key), `${method.name} should reach its handler, got ${res.status}: ${await res.text()}`);
208
+ assert.strictEqual(res.status, 200, `${method.name} should answer 200`);
146
209
  });
147
210
  }
148
211
  });
@@ -1,5 +1,5 @@
1
1
  import './assert_dev_env.js';
2
- import type { TestAccount } from './app_server.js';
2
+ import type { TestAccount } from './test_app.js';
3
3
  import type { AppSurfaceSpec, AppSurfaceRpcMethod } from '../http/surface.js';
4
4
  import { type RpcEndpointsSuiteOption } from './rpc_helpers.js';
5
5
  import { type AuthPrincipal, type KeeperHeaderProvider } from './integration_helpers.js';
@@ -1 +1 @@
1
- {"version":3,"file":"rpc_round_trip.d.ts","sourceRoot":"","sources":["../../src/lib/testing/rpc_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAwC7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAQN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAON,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,mDAAmD;AACnD,MAAM,WAAW,uBAAuB;IACvC,kEAAkE;IAClE,UAAU,EAAE,SAAS,CAAC;IACtB;;;;OAIG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B;;;;;OAKG;IACH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;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,0GAA0G;AAC1G,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAEzF,0GAA0G;AAC1G,MAAM,MAAM,kBAAkB,GAAG,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAEhE,oEAAoE;AACpE,MAAM,WAAW,gBAAgB;IAChC,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACzB,QAAQ,mBAAmB,EAC3B,QAAQ,oBAAoB,EAC5B,gBAAgB,WAAW,EAC3B,eAAe,WAAW,KACxB,gBAMF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,wBAAwB,GACpC,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,MAAM,OAAO,EACb,WAAW,aAAa,KACtB,IAwBF,CAAC;AA8GF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,6BAA6B,GAAI,SAAS,uBAAuB,KAAG,IAuKhF,CAAC"}
@@ -26,6 +26,7 @@ import './assert_dev_env.js';
26
26
  * @module
27
27
  */
28
28
  import { describe, test, beforeAll, assert } from 'vitest';
29
+ import { check_db_invariants_after_all } from './db_invariants.js';
29
30
  import { is, parse } from '@fuzdev/fuz_schema/schema.ts';
30
31
  import { ROLE_ADMIN } from '../auth/role_schema.js';
31
32
  import { JSONRPC_INTERNAL_ERROR, JSONRPC_METHOD_NOT_FOUND, JsonrpcErrorResponse } from '../http/jsonrpc.js';
@@ -213,6 +214,8 @@ export const describe_rpc_round_trip_tests = (options) => {
213
214
  const surface_rpc_endpoints = options.surface_source.surface.rpc_endpoints;
214
215
  describe('RPC round-trip validation', () => {
215
216
  let fixture;
217
+ // `fixture` is unassigned until `beforeAll` runs, which the check allows for
218
+ check_db_invariants_after_all(() => fixture);
216
219
  let authed_account;
217
220
  let admin_account;
218
221
  beforeAll(async () => {
@@ -4,7 +4,7 @@ import type { AppServerContext } from '../server/app_server_context.js';
4
4
  import type { SessionOptions } from '../auth/session_cookie.js';
5
5
  import type { EventSpec } from '../realtime/sse.js';
6
6
  import type { AuditLogEvent } from '../auth/audit_log_schema.js';
7
- import { type SuiteAppOptions, type TestApp, type TestAccount } from './app_server.js';
7
+ import { type SuiteAppOptions, type TestApp, type TestAccount } from './test_app.js';
8
8
  import { type DbFactory } from './db.js';
9
9
  import { type RpcEndpointsSuiteOption } from './rpc_helpers.js';
10
10
  /** Config for a single SSE route under test. */
@@ -1 +1 @@
1
- {"version":3,"file":"sse_round_trip.d.ts","sourceRoot":"","sources":["../../src/lib/testing/sse_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAoB7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAmB,MAAM,oBAAoB,CAAC;AAGrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAGjE,OAAO,EAEN,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpE,OAAO,EAIN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AAO1B,gDAAgD;AAChD,MAAM,WAAW,gBAAgB;IAChC,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,OAAO,EAAE,CAAC,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AG,IAyIvE,CAAC"}
@@ -18,7 +18,8 @@ import { parse } from '@fuzdev/fuz_schema/schema.ts';
18
18
  import { SSE_CONNECTED_COMMENT } from '../realtime/sse_constants.js';
19
19
  import { ROLE_ADMIN } from '../auth/role_schema.js';
20
20
  import { create_audit_emitter } from '../auth/audit_emitter.js';
21
- import { create_test_app } from './app_server.js';
21
+ import { create_test_app } from './test_app.js';
22
+ import { check_db_invariants_after_suite } from './db_invariants.js';
22
23
  import { create_default_db_factory } from './db.js';
23
24
  import { find_route_spec, pick_auth_headers } from './integration_helpers.js';
24
25
  import { rpc_call, require_rpc_endpoint_path, resolve_rpc_endpoints_for_setup } from './rpc_helpers.js';
@@ -112,9 +113,17 @@ export const describe_sse_route_tests = (options) => {
112
113
  roles: [ROLE_ADMIN]
113
114
  });
114
115
  });
115
- afterAll(async () => {
116
- await test_app.cleanup();
117
- await factory.close(db);
116
+ // the app is built in `beforeAll`, outside any test, so it is checked
117
+ // once the describe's tests are done, ahead of the cleanup
118
+ // eslint-disable-next-line no-empty-pattern
119
+ afterAll(async ({}, suite) => {
120
+ try {
121
+ await check_db_invariants_after_suite(suite, test_app);
122
+ }
123
+ finally {
124
+ await test_app.cleanup();
125
+ await factory.close(db);
126
+ }
118
127
  });
119
128
  test('opens, emits payload, closes on revoke', async () => {
120
129
  const spec = find_route_spec(test_app.route_specs, 'GET', route_config.path);
@@ -50,7 +50,9 @@ export declare const stub: any;
50
50
  * Returns a real `Db` instance with:
51
51
  * - `query` returns empty rows (safety net for unmocked query functions)
52
52
  * - `query_one` returns undefined
53
- * - `transaction(fn)` calls `fn(db)` synchronously (no real transaction)
53
+ * - `transaction(fn)` calls `fn(tx)` with a stub transaction `Db` (no real
54
+ * transaction): it reads as one (`in_transaction`) and refuses a nested
55
+ * transaction, as a production transaction `Db` does
54
56
  */
55
57
  export declare const create_stub_db: () => Db;
56
58
  /** Stub handler that answers a 200 `stub` text response, as a raw result. */
@@ -75,7 +77,7 @@ export declare const stub_mw: (_c: any, next: any) => Promise<void>;
75
77
  * wires a listener fails loudly instead of silently never firing
76
78
  * (`create_recording_audit_emitter` accepts listeners); `listener_count`
77
79
  * returns 0; `drain_inflight` resolves immediately, since nothing is ever
78
- * written, and `is_tracking_inflight` answers `false`. Tests asserting on
80
+ * written, and `inflight_count` returns 0. Tests asserting on
79
81
  * real audit-row persistence (or on listener fan-out) build a real emitter
80
82
  * via `create_audit_emitter` against a stub or real DB — `create_test_app`
81
83
  * already does this on the test backend.
@@ -1 +1 @@
1
- {"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../../src/lib/testing/stubs.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAa7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAIrF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAGN,KAAK,UAAU,EACf,KAAK,SAAS,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAInE,OAAO,EAEN,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAC3F,OAAO,KAAK,EAA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,CAAC,CAAC;IAC9C;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,+BAA+B,KACtC,cAmHF,CAAC"}
@@ -12,7 +12,8 @@ import { REST_FORBIDDEN_ORIGIN } from '../http/error_schemas.js';
12
12
  import { body_limit_middleware_shape } from '../http/body_limit_schema.js';
13
13
  import { host_gate_middleware_shape } from '../http/host.js';
14
14
  import { create_realtime_closer } from '../actions/connection_closer.js';
15
- import { Db } from '../db/db.js';
15
+ import { create_realtime_notification_sender } from '../actions/notification_sender.js';
16
+ import { Db, no_nested_transaction } from '../db/db.js';
16
17
  import { attach_route_handler, prefix_route_specs } from '../http/route_spec.js';
17
18
  import { route_raw } from '../http/route_result.js';
18
19
  import { bootstrap_route_shape } from '../auth/bootstrap_route_schema.js';
@@ -86,11 +87,16 @@ export const stub = create_throwing_stub('stub');
86
87
  * Returns a real `Db` instance with:
87
88
  * - `query` returns empty rows (safety net for unmocked query functions)
88
89
  * - `query_one` returns undefined
89
- * - `transaction(fn)` calls `fn(db)` synchronously (no real transaction)
90
+ * - `transaction(fn)` calls `fn(tx)` with a stub transaction `Db` (no real
91
+ * transaction): it reads as one (`in_transaction`) and refuses a nested
92
+ * transaction, as a production transaction `Db` does
90
93
  */
91
94
  export const create_stub_db = () => new Db({
92
95
  client: { query: async () => ({ rows: [] }) },
93
- transaction: async (fn) => fn(create_stub_db())
96
+ transaction: async (fn) => fn(new Db({
97
+ client: { query: async () => ({ rows: [] }) },
98
+ transaction: no_nested_transaction
99
+ }))
94
100
  });
95
101
  /** Stub handler that answers a 200 `stub` text response, as a raw result. */
96
102
  export const stub_handler = () => route_raw({ status: 200, headers: { 'Content-Type': 'text/plain;charset=UTF-8' }, body: 'stub' });
@@ -119,7 +125,7 @@ const stub_db = create_noop_stub('stub_db');
119
125
  * wires a listener fails loudly instead of silently never firing
120
126
  * (`create_recording_audit_emitter` accepts listeners); `listener_count`
121
127
  * returns 0; `drain_inflight` resolves immediately, since nothing is ever
122
- * written, and `is_tracking_inflight` answers `false`. Tests asserting on
128
+ * written, and `inflight_count` returns 0. Tests asserting on
123
129
  * real audit-row persistence (or on listener fan-out) build a real emitter
124
130
  * via `create_audit_emitter` against a stub or real DB — `create_test_app`
125
131
  * already does this on the test backend.
@@ -134,7 +140,7 @@ export const create_test_audit_emitter = () => ({
134
140
  },
135
141
  listener_count: () => 0,
136
142
  drain_inflight: async () => { },
137
- is_tracking_inflight: () => false
143
+ inflight_count: () => 0
138
144
  });
139
145
  /**
140
146
  * Build a no-op `AuditLogSse` for tests that wire `audit_sse` into the
@@ -170,7 +176,8 @@ export const create_stub_app_deps = () => ({
170
176
  db: stub_db,
171
177
  log: new Logger('test', { level: 'off' }),
172
178
  audit: create_test_audit_emitter(),
173
- connection_closer: create_realtime_closer()
179
+ connection_closer: create_realtime_closer(),
180
+ notification_sender: create_realtime_notification_sender()
174
181
  });
175
182
  /**
176
183
  * Create a stub `AppBackend` with no database behind it — no migration
@@ -319,7 +326,8 @@ export const create_test_app_surface_spec = (options) => {
319
326
  actions: endpoint.actions,
320
327
  log: ctx.deps.log,
321
328
  action_ip_rate_limiter: ctx.action_ip_rate_limiter,
322
- action_account_rate_limiter: ctx.action_account_rate_limiter
329
+ action_account_rate_limiter: ctx.action_account_rate_limiter,
330
+ notification_sender: ctx.deps.notification_sender
323
331
  });
324
332
  }) ?? [];
325
333
  // Resolve ws endpoints (mirrors create_app_server). Surface-only —