@fuzdev/fuz_app 0.182.0 → 0.184.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 (295) hide show
  1. package/README.md +2 -0
  2. package/dist/actions/CLAUDE.md +535 -1223
  3. package/dist/actions/action_codegen.d.ts +1 -1
  4. package/dist/actions/action_codegen.d.ts.map +1 -1
  5. package/dist/actions/action_codegen.js +3 -2
  6. package/dist/actions/connection_closer.d.ts +11 -9
  7. package/dist/actions/connection_closer.d.ts.map +1 -1
  8. package/dist/actions/connection_closer.js +11 -9
  9. package/dist/actions/frontend_rpc_client.d.ts +1 -1
  10. package/dist/actions/register_action_ws.d.ts +14 -1
  11. package/dist/actions/register_action_ws.d.ts.map +1 -1
  12. package/dist/actions/register_action_ws.js +2 -1
  13. package/dist/actions/ws_socket_session.d.ts +9 -1
  14. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  15. package/dist/actions/ws_socket_session.js +43 -19
  16. package/dist/auth/CLAUDE.md +430 -1024
  17. package/dist/auth/account_queries.d.ts +1 -1
  18. package/dist/auth/account_queries.js +1 -1
  19. package/dist/auth/account_routes.d.ts +9 -8
  20. package/dist/auth/account_routes.d.ts.map +1 -1
  21. package/dist/auth/account_routes.js +78 -75
  22. package/dist/auth/admin_actions.d.ts.map +1 -1
  23. package/dist/auth/admin_actions.js +32 -28
  24. package/dist/auth/api_token.d.ts +20 -3
  25. package/dist/auth/api_token.d.ts.map +1 -1
  26. package/dist/auth/api_token.js +28 -9
  27. package/dist/auth/api_token_queries.d.ts +2 -2
  28. package/dist/auth/api_token_queries.js +2 -2
  29. package/dist/auth/audit_emitter.d.ts +75 -84
  30. package/dist/auth/audit_emitter.d.ts.map +1 -1
  31. package/dist/auth/audit_emitter.js +83 -71
  32. package/dist/auth/audit_log_schema.d.ts +25 -14
  33. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  34. package/dist/auth/audit_log_schema.js +23 -8
  35. package/dist/auth/auth_guard_resolver.d.ts +1 -1
  36. package/dist/auth/auth_guard_resolver.js +1 -1
  37. package/dist/auth/bearer_auth.d.ts +2 -5
  38. package/dist/auth/bearer_auth.d.ts.map +1 -1
  39. package/dist/auth/bearer_auth.js +4 -13
  40. package/dist/auth/bootstrap_account.d.ts +42 -26
  41. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  42. package/dist/auth/bootstrap_account.js +36 -19
  43. package/dist/auth/bootstrap_routes.d.ts +20 -21
  44. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  45. package/dist/auth/bootstrap_routes.js +26 -31
  46. package/dist/auth/bootstrap_token_store.d.ts +3 -4
  47. package/dist/auth/bootstrap_token_store.d.ts.map +1 -1
  48. package/dist/auth/bootstrap_token_store.js +1 -1
  49. package/dist/auth/daemon_token.d.ts +5 -1
  50. package/dist/auth/daemon_token.d.ts.map +1 -1
  51. package/dist/auth/daemon_token_middleware.d.ts +12 -8
  52. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  53. package/dist/auth/daemon_token_middleware.js +15 -21
  54. package/dist/auth/deps.d.ts +19 -5
  55. package/dist/auth/deps.d.ts.map +1 -1
  56. package/dist/auth/deps.js +3 -2
  57. package/dist/auth/invite_queries.d.ts +51 -3
  58. package/dist/auth/invite_queries.d.ts.map +1 -1
  59. package/dist/auth/invite_queries.js +81 -6
  60. package/dist/auth/invite_schema.d.ts +2 -1
  61. package/dist/auth/invite_schema.d.ts.map +1 -1
  62. package/dist/auth/middleware.d.ts +2 -3
  63. package/dist/auth/middleware.d.ts.map +1 -1
  64. package/dist/auth/middleware.js +3 -3
  65. package/dist/auth/request_context.d.ts +3 -3
  66. package/dist/auth/request_context.js +3 -3
  67. package/dist/auth/resolved_auth.d.ts +7 -7
  68. package/dist/auth/resolved_auth.d.ts.map +1 -1
  69. package/dist/auth/resolved_auth.js +4 -4
  70. package/dist/auth/role_grant_offer_actions.d.ts +27 -3
  71. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  72. package/dist/auth/role_grant_offer_actions.js +42 -35
  73. package/dist/auth/role_grant_offer_queries.d.ts +60 -4
  74. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  75. package/dist/auth/role_grant_offer_queries.js +79 -5
  76. package/dist/auth/role_grant_queries.d.ts +3 -52
  77. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  78. package/dist/auth/role_grant_queries.js +5 -80
  79. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  80. package/dist/auth/self_service_role_actions.js +11 -22
  81. package/dist/auth/session_cookie.d.ts +82 -174
  82. package/dist/auth/session_cookie.d.ts.map +1 -1
  83. package/dist/auth/session_cookie.js +80 -130
  84. package/dist/auth/session_middleware.d.ts +8 -17
  85. package/dist/auth/session_middleware.d.ts.map +1 -1
  86. package/dist/auth/session_middleware.js +14 -23
  87. package/dist/auth/session_queries.d.ts +15 -17
  88. package/dist/auth/session_queries.d.ts.map +1 -1
  89. package/dist/auth/session_queries.js +28 -20
  90. package/dist/auth/signup_routes.d.ts.map +1 -1
  91. package/dist/auth/signup_routes.js +93 -43
  92. package/dist/db/CLAUDE.md +5 -3
  93. package/dist/db/sql_columns.d.ts +1 -1
  94. package/dist/db/sql_columns.js +1 -1
  95. package/dist/dev/setup.d.ts +3 -1
  96. package/dist/dev/setup.d.ts.map +1 -1
  97. package/dist/dev/setup.js +3 -1
  98. package/dist/http/CLAUDE.md +315 -763
  99. package/dist/http/db_routes.d.ts +8 -23
  100. package/dist/http/db_routes.d.ts.map +1 -1
  101. package/dist/http/db_routes.js +73 -73
  102. package/dist/http/origin.d.ts +7 -8
  103. package/dist/http/origin.d.ts.map +1 -1
  104. package/dist/http/origin.js +7 -8
  105. package/dist/http/pending_effects.d.ts +118 -6
  106. package/dist/http/pending_effects.d.ts.map +1 -1
  107. package/dist/http/pending_effects.js +114 -6
  108. package/dist/http/route_result.d.ts +1 -1
  109. package/dist/http/route_spec.d.ts +14 -11
  110. package/dist/http/route_spec.d.ts.map +1 -1
  111. package/dist/realtime/sse.d.ts +4 -23
  112. package/dist/realtime/sse.d.ts.map +1 -1
  113. package/dist/realtime/sse.js +4 -25
  114. package/dist/server/app_backend.d.ts +4 -5
  115. package/dist/server/app_backend.d.ts.map +1 -1
  116. package/dist/server/app_backend.js +3 -1
  117. package/dist/server/app_server.d.ts +80 -16
  118. package/dist/server/app_server.d.ts.map +1 -1
  119. package/dist/server/app_server.js +113 -31
  120. package/dist/server/app_server_context.d.ts +1 -2
  121. package/dist/server/app_server_context.d.ts.map +1 -1
  122. package/dist/server/env.js +2 -2
  123. package/dist/testing/CLAUDE.md +265 -796
  124. package/dist/testing/admin_integration.d.ts +2 -3
  125. package/dist/testing/admin_integration.d.ts.map +1 -1
  126. package/dist/testing/admin_integration.js +3 -3
  127. package/dist/testing/adversarial_404.d.ts +6 -1
  128. package/dist/testing/adversarial_404.d.ts.map +1 -1
  129. package/dist/testing/adversarial_404.js +38 -17
  130. package/dist/testing/app_server.d.ts +23 -148
  131. package/dist/testing/app_server.d.ts.map +1 -1
  132. package/dist/testing/app_server.js +53 -131
  133. package/dist/testing/attack_surface.d.ts +1 -1
  134. package/dist/testing/attack_surface.d.ts.map +1 -1
  135. package/dist/testing/audit_completeness.d.ts +2 -3
  136. package/dist/testing/audit_completeness.d.ts.map +1 -1
  137. package/dist/testing/audit_completeness.js +1 -1
  138. package/dist/testing/audit_drift_guard.d.ts +11 -6
  139. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  140. package/dist/testing/audit_drift_guard.js +15 -8
  141. package/dist/testing/cross_backend/audit_cross_helpers.d.ts +12 -9
  142. package/dist/testing/cross_backend/audit_cross_helpers.d.ts.map +1 -1
  143. package/dist/testing/cross_backend/audit_cross_helpers.js +13 -14
  144. package/dist/testing/cross_backend/capabilities.d.ts +9 -6
  145. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  146. package/dist/testing/cross_backend/capabilities.js +11 -7
  147. package/dist/testing/cross_backend/capability_mounts.d.ts +103 -0
  148. package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -0
  149. package/dist/testing/cross_backend/capability_mounts.js +428 -0
  150. package/dist/testing/cross_backend/cell_moderate.js +2 -2
  151. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  152. package/dist/testing/cross_backend/cell_relations.js +12 -11
  153. package/dist/testing/cross_backend/conformance_principal.d.ts +54 -0
  154. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -0
  155. package/dist/testing/cross_backend/conformance_principal.js +283 -0
  156. package/dist/testing/cross_backend/conformance_table.d.ts +7 -56
  157. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  158. package/dist/testing/cross_backend/conformance_table.js +6 -274
  159. package/dist/testing/cross_backend/cookie_attributes.js +1 -1
  160. package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -1
  161. package/dist/testing/cross_backend/credential_deadline.js +2 -0
  162. package/dist/testing/cross_backend/credential_wire.d.ts +1 -1
  163. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -1
  164. package/dist/testing/cross_backend/db_state_diff.d.ts +72 -0
  165. package/dist/testing/cross_backend/db_state_diff.d.ts.map +1 -0
  166. package/dist/testing/cross_backend/db_state_diff.js +444 -0
  167. package/dist/testing/cross_backend/declared_skips.d.ts +68 -0
  168. package/dist/testing/cross_backend/declared_skips.d.ts.map +1 -0
  169. package/dist/testing/cross_backend/declared_skips.js +132 -0
  170. package/dist/testing/cross_backend/default_backend_configs.d.ts +3 -3
  171. package/dist/testing/cross_backend/default_spine_surface.d.ts +0 -6
  172. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  173. package/dist/testing/cross_backend/default_spine_surface.js +4 -9
  174. package/dist/testing/cross_backend/differential.d.ts +13 -5
  175. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  176. package/dist/testing/cross_backend/differential.js +35 -11
  177. package/dist/testing/cross_backend/differential_normalize.d.ts +12 -0
  178. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  179. package/dist/testing/cross_backend/differential_normalize.js +16 -0
  180. package/dist/testing/cross_backend/full_spine_mount.d.ts +1 -42
  181. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  182. package/dist/testing/cross_backend/full_spine_mount.js +45 -4
  183. package/dist/testing/cross_backend/in_process_setup.d.ts +28 -19
  184. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  185. package/dist/testing/cross_backend/in_process_setup.js +156 -142
  186. package/dist/testing/cross_backend/login_security.d.ts +12 -0
  187. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  188. package/dist/testing/cross_backend/login_security.js +21 -4
  189. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +0 -2
  190. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -1
  191. package/dist/testing/cross_backend/request_target_conformance_wire.js +3 -1
  192. package/dist/testing/cross_backend/revocation_drivers.d.ts +18 -5
  193. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  194. package/dist/testing/cross_backend/revocation_drivers.js +18 -10
  195. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +1 -1
  196. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -1
  197. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  198. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +33 -1
  199. package/dist/testing/cross_backend/role_grant_participation.js +4 -4
  200. package/dist/testing/cross_backend/rpc_adversarial.js +1 -1
  201. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -4
  202. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  203. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +2 -2
  204. package/dist/testing/cross_backend/session_cap.d.ts +2 -2
  205. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  206. package/dist/testing/cross_backend/session_cap.js +22 -11
  207. package/dist/testing/cross_backend/setup.d.ts +32 -2
  208. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  209. package/dist/testing/cross_backend/setup.js +32 -1
  210. package/dist/testing/cross_backend/spine_suites.d.ts +125 -15
  211. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  212. package/dist/testing/cross_backend/spine_suites.js +459 -62
  213. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  214. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  215. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  216. package/dist/testing/cross_backend/sse_round_trip.d.ts +9 -1
  217. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  218. package/dist/testing/cross_backend/sse_round_trip.js +123 -27
  219. package/dist/testing/cross_backend/standard.d.ts +2 -3
  220. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  221. package/dist/testing/cross_backend/standard.js +3 -3
  222. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  223. package/dist/testing/cross_backend/testing_backdoor.js +4 -2
  224. package/dist/testing/cross_backend/testing_credential_read.d.ts +10 -11
  225. package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -1
  226. package/dist/testing/cross_backend/testing_credential_read.js +12 -12
  227. package/dist/testing/cross_backend/testing_reset_actions.d.ts +84 -47
  228. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  229. package/dist/testing/cross_backend/testing_reset_actions.js +95 -63
  230. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  231. package/dist/testing/cross_backend/testing_server_core.js +2 -3
  232. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  233. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  234. package/dist/testing/cross_backend/transport_composition.js +7 -3
  235. package/dist/testing/cross_backend/ws_round_trip.d.ts +5 -0
  236. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  237. package/dist/testing/cross_backend/ws_round_trip.js +54 -8
  238. package/dist/testing/daemon_token_rotation.d.ts.map +1 -1
  239. package/dist/testing/daemon_token_rotation.js +2 -3
  240. package/dist/testing/data_exposure.d.ts.map +1 -1
  241. package/dist/testing/data_exposure.js +3 -0
  242. package/dist/testing/db.d.ts +0 -32
  243. package/dist/testing/db.d.ts.map +1 -1
  244. package/dist/testing/db.js +0 -86
  245. package/dist/testing/db_entities.d.ts +14 -0
  246. package/dist/testing/db_entities.d.ts.map +1 -1
  247. package/dist/testing/db_entities.js +17 -0
  248. package/dist/testing/db_invariant_queries.d.ts +259 -0
  249. package/dist/testing/db_invariant_queries.d.ts.map +1 -0
  250. package/dist/testing/db_invariant_queries.js +400 -0
  251. package/dist/testing/db_invariants.d.ts +106 -0
  252. package/dist/testing/db_invariants.d.ts.map +1 -0
  253. package/dist/testing/db_invariants.gen.sql.d.ts +11 -0
  254. package/dist/testing/db_invariants.gen.sql.d.ts.map +1 -0
  255. package/dist/testing/db_invariants.gen.sql.js +13 -0
  256. package/dist/testing/db_invariants.js +141 -0
  257. package/dist/testing/db_invariants.sql +152 -0
  258. package/dist/testing/describe_db.d.ts +36 -0
  259. package/dist/testing/describe_db.d.ts.map +1 -0
  260. package/dist/testing/describe_db.js +71 -0
  261. package/dist/testing/integration.d.ts +8 -12
  262. package/dist/testing/integration.d.ts.map +1 -1
  263. package/dist/testing/integration.js +13 -17
  264. package/dist/testing/integration_helpers.d.ts +1 -1
  265. package/dist/testing/integration_helpers.d.ts.map +1 -1
  266. package/dist/testing/rate_limiting.d.ts +3 -4
  267. package/dist/testing/rate_limiting.d.ts.map +1 -1
  268. package/dist/testing/rate_limiting.js +6 -5
  269. package/dist/testing/role_grant_helpers.d.ts +1 -1
  270. package/dist/testing/role_grant_helpers.d.ts.map +1 -1
  271. package/dist/testing/round_trip.d.ts.map +1 -1
  272. package/dist/testing/round_trip.js +3 -0
  273. package/dist/testing/rpc_attack_surface.d.ts +8 -6
  274. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  275. package/dist/testing/rpc_attack_surface.js +69 -6
  276. package/dist/testing/rpc_helpers.d.ts +1 -2
  277. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  278. package/dist/testing/rpc_helpers.js +3 -3
  279. package/dist/testing/rpc_round_trip.d.ts +3 -4
  280. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  281. package/dist/testing/rpc_round_trip.js +4 -1
  282. package/dist/testing/sse_round_trip.d.ts +3 -4
  283. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  284. package/dist/testing/sse_round_trip.js +15 -6
  285. package/dist/testing/stubs.d.ts +9 -8
  286. package/dist/testing/stubs.d.ts.map +1 -1
  287. package/dist/testing/stubs.js +20 -13
  288. package/dist/testing/test_app.d.ts +168 -0
  289. package/dist/testing/test_app.d.ts.map +1 -0
  290. package/dist/testing/test_app.js +123 -0
  291. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  292. package/dist/testing/ws_round_trip.js +3 -0
  293. package/dist/ui/ui_format.d.ts.map +1 -1
  294. package/dist/ui/ui_format.js +1 -2
  295. package/package.json +1 -1
@@ -1,12 +1,13 @@
1
1
  import '../assert_dev_env.js';
2
- import { ROLE_KEEPER } from '../../auth/role_schema.js';
3
2
  import { AUTH_SESSION_LIFETIME_MS, query_session_revoke_for_account } from '../../auth/session_queries.js';
4
3
  import { generate_api_token } from '../../auth/api_token.js';
5
4
  import { query_create_api_token, query_revoke_api_token_for_account } from '../../auth/api_token_queries.js';
6
5
  import { token_scope_full } from '../../auth/token_scope.js';
7
6
  import { create_test_extra_actor } from '../db_entities.js';
8
- import { create_test_app, create_test_account_with_credentials, mint_test_session } from '../app_server.js';
7
+ import { create_test_account_with_credentials, DEFAULT_TEST_KEEPER_ROLES, mint_test_session } from '../app_server.js';
8
+ import { create_test_app } from '../test_app.js';
9
9
  import { create_test_app_surface_spec } from '../stubs.js';
10
+ import { validate_db_invariant_exclusions } from '../db_invariant_queries.js';
10
11
  import { find_rpc_action, http_transport, resolve_rpc_endpoints_for_setup } from '../rpc_helpers.js';
11
12
  import { query_shorten_credential_expiry } from './testing_reset_actions.js';
12
13
  import { in_process_capabilities } from './capabilities.js';
@@ -37,143 +38,155 @@ const in_process_fetch_transport = (app) => {
37
38
  * `_testing_reset` cradle so suite bodies read
38
39
  * `fixture.extra_accounts[username]` uniformly regardless of transport.
39
40
  *
41
+ * The keeper holds `options.roles`, or `create_test_app`'s default when
42
+ * omitted (`DEFAULT_TEST_KEEPER_ROLES` — keeper and admin, as a production
43
+ * bootstrap and the cross-process reset seed it). The database invariant
44
+ * check is the test app's: registered when the fixture is built inside a
45
+ * test, less `options.exclude_db_invariants`, and run on demand by
46
+ * `fixture.assert_db_invariants`. The exclusions are validated here, before
47
+ * any test runs.
48
+ *
40
49
  * The describe-level `auth_integration_truncate_tables` / WASM database
41
- * cache lifecycle stays in `create_default_db_factory` / `create_describe_db`
42
- * (`testing/db.ts`) — `default_in_process_setup` doesn't manage db state
50
+ * cache lifecycle stays in `create_default_db_factory` (`testing/db.ts`) /
51
+ * `create_describe_db` (`testing/describe_db.ts`) — `default_in_process_setup` doesn't manage db state
43
52
  * beyond what `create_test_app` already does.
44
53
  */
45
- export const default_in_process_setup = (options) => async () => {
46
- // Per-test fresh db. When `options.migration_namespaces` is set,
47
- // `create_test_app` provisions an auth+extras database (e.g. the cell
48
- // layer); otherwise the auth-only default. Either way the factory
49
- // resets + re-migrates on each `create`, so the per-test keeper
50
- // bootstrap below lands on a clean DB.
51
- const test_app = await create_test_app(options);
52
- // Seed bootstrap-time secondaries against the same DB the keeper
53
- // just landed on. Direct-insert is the only path for roles whose
54
- // `grant_paths` excludes `'admin'` (e.g. `ROLE_KEEPER`) — see
55
- // `ExtraAccountSpec` for why this bypass is bootstrap-cradle-only.
56
- const extra_accounts = {};
57
- const { cookie_name } = options.session_options;
58
- // where `account_verify` is mounted, for the liveness checks of the
59
- // dead-credential mints; read only when one runs
60
- const account_verify_rpc_path = (accessor) => {
61
- const found = find_rpc_action(resolve_rpc_endpoints_for_setup(options.rpc_endpoints ?? [], options.session_options), 'account_verify');
62
- if (!found) {
63
- throw new Error(`${accessor}: the in-process app mounts no account_verify to prove the credential live`);
64
- }
65
- return found.path;
66
- };
67
- for (const spec of options.extra_accounts ?? []) {
68
- const seeded = await create_test_account_with_credentials({
69
- db: test_app.backend.deps.db,
70
- keyring: test_app.backend.keyring,
71
- session_options: options.session_options,
72
- password: test_app.backend.deps.password,
73
- username: spec.username,
74
- password_value: spec.password_value,
75
- roles: [...spec.roles]
76
- });
77
- extra_accounts[spec.username] = to_test_account(seeded, cookie_name);
78
- }
79
- // Seed additional keeper actors directly against the same DB. Mirrors
80
- // the cross-process `_testing_reset` `extra_actors` path; no production
81
- // wire mints a second actor, so this bootstrap-cradle insert is the
82
- // only way into a multi-actor keeper state. Seeded at the wall clock,
83
- // like the reset, so they sort after the bootstrap actor.
84
- const extra_actors = [];
85
- for (const name of options.extra_actors ?? []) {
86
- const seeded_actor = await create_test_extra_actor(test_app.backend.deps.db, test_app.backend.account.id, name);
87
- extra_actors.push({ id: seeded_actor.id, name: seeded_actor.name });
88
- }
89
- return {
90
- transport: in_process_fetch_transport(test_app.app),
91
- // In-process the wrapper is stateless and never auto-adds Origin —
92
- // `options` is accepted for API symmetry with cross-process but
93
- // has no observable effect.
94
- fresh_transport: () => in_process_fetch_transport(test_app.app),
95
- account: test_app.backend.account,
96
- actor: test_app.backend.actor,
97
- create_session_headers: test_app.create_session_headers,
98
- create_bearer_headers: test_app.create_bearer_headers,
99
- create_daemon_token_headers: test_app.create_daemon_token_headers,
100
- create_account: test_app.create_account,
101
- extra_accounts,
102
- extra_actors,
103
- reject_unknown_audit_metadata_keys: options.reject_unknown_audit_metadata_keys ?? false,
104
- // Forge directly against the live backend's DB + keyring — no wire
105
- // hop needed in-process.
106
- mint_expired_session: async () => {
107
- const { session_cookie } = await mint_test_session({
54
+ export const default_in_process_setup = (options) => {
55
+ validate_db_invariant_exclusions(options.exclude_db_invariants, 'default_in_process_setup');
56
+ return async () => {
57
+ // Per-test fresh db. When `options.migration_namespaces` is set,
58
+ // `create_test_app` provisions an auth+extras database (e.g. the cell
59
+ // layer); otherwise the auth-only default. Either way the factory
60
+ // resets + re-migrates on each `create`, so the per-test keeper
61
+ // bootstrap below lands on a clean DB.
62
+ const test_app = await create_test_app(options);
63
+ // Seed bootstrap-time secondaries against the same DB the keeper
64
+ // just landed on. Direct-insert is the only path for roles whose
65
+ // `grant_paths` excludes `'admin'` (e.g. `ROLE_KEEPER`) — see
66
+ // `ExtraAccountSpec` for why this bypass is bootstrap-cradle-only.
67
+ const extra_accounts = {};
68
+ const cookie_name = options.session_cookie_name;
69
+ // where `account_verify` is mounted, for the liveness checks of the
70
+ // dead-credential mints; read only when one runs
71
+ const account_verify_rpc_path = (accessor) => {
72
+ const found = find_rpc_action(resolve_rpc_endpoints_for_setup(options.rpc_endpoints ?? [], options.session_cookie_name), 'account_verify');
73
+ if (!found) {
74
+ throw new Error(`${accessor}: the in-process app mounts no account_verify to prove the credential live`);
75
+ }
76
+ return found.path;
77
+ };
78
+ for (const spec of options.extra_accounts ?? []) {
79
+ const seeded = await create_test_account_with_credentials({
108
80
  db: test_app.backend.deps.db,
109
81
  keyring: test_app.backend.keyring,
110
- session_options: options.session_options,
111
- account_id: test_app.backend.account.id,
112
- expires_in_seconds: EXPIRED_SESSION_OFFSET_SECONDS
113
- });
114
- return `${cookie_name}=${session_cookie}`;
115
- },
116
- // The mints, revocations and the expiry go through the queries the
117
- // production paths (and the expiry backdoor) write with, so the rows
118
- // match what the cross-process accessors leave; each credential is
119
- // proven live first, so its refusal can only be the revocation or the
120
- // expiry.
121
- mint_revoked_session: async () => {
122
- const db = test_app.backend.deps.db;
123
- const account_id = test_app.backend.account.id;
124
- const { session_cookie, session_hash } = await mint_test_session({
125
- db,
126
- keyring: test_app.backend.keyring,
127
- session_options: options.session_options,
128
- account_id,
129
- expires_in_seconds: AUTH_SESSION_LIFETIME_MS / 1000
130
- });
131
- const cookie = `${cookie_name}=${session_cookie}`;
132
- await assert_credential_authenticates({
133
- transport: in_process_fetch_transport(test_app.app),
134
- rpc_path: account_verify_rpc_path('mint_revoked_session'),
135
- headers: { cookie },
136
- account_id,
137
- accessor: 'mint_revoked_session'
82
+ password: test_app.backend.deps.password,
83
+ username: spec.username,
84
+ password_value: spec.password_value,
85
+ roles: [...spec.roles]
138
86
  });
139
- if (!(await query_session_revoke_for_account({ db }, session_hash, account_id))) {
140
- throw new Error('mint_revoked_session: the revoke removed no session row');
141
- }
142
- return cookie;
143
- },
144
- mint_revoked_token: async () => {
145
- const deps = { db: test_app.backend.deps.db };
146
- const account_id = test_app.backend.account.id;
147
- const { token, id, token_hash } = generate_api_token();
148
- await query_create_api_token(deps, id, account_id, 'conformance revoked token', token_hash, token_scope_full());
149
- await assert_credential_authenticates({
150
- transport: in_process_fetch_transport(test_app.app),
151
- rpc_path: account_verify_rpc_path('mint_revoked_token'),
152
- headers: { authorization: `Bearer ${token}` },
153
- account_id,
154
- accessor: 'mint_revoked_token'
155
- });
156
- if (!(await query_revoke_api_token_for_account(deps, id, account_id))) {
157
- throw new Error('mint_revoked_token: the revoke removed no token row');
158
- }
159
- return token;
160
- },
161
- mint_expired_token: async () => {
162
- const other = await test_app.create_account();
163
- await assert_credential_authenticates({
164
- transport: in_process_fetch_transport(test_app.app),
165
- rpc_path: account_verify_rpc_path('mint_expired_token'),
166
- headers: { authorization: `Bearer ${other.api_token}` },
167
- account_id: other.account.id,
168
- accessor: 'mint_expired_token'
169
- });
170
- const shortened = await query_shorten_credential_expiry(test_app.backend.deps.db, other.account.id, EXPIRED_TOKEN_SHORTEN_SECONDS);
171
- if (shortened.api_tokens < 1) {
172
- throw new Error('mint_expired_token: the expiry rewrote no token row');
173
- }
174
- await new Promise((resolve) => setTimeout(resolve, EXPIRED_TOKEN_WAIT_MS));
175
- return other.api_token;
87
+ extra_accounts[spec.username] = to_test_account(seeded, cookie_name);
88
+ }
89
+ // Seed additional keeper actors directly against the same DB. Mirrors
90
+ // the cross-process `_testing_reset` `extra_actors` path; no production
91
+ // wire mints a second actor, so this bootstrap-cradle insert is the
92
+ // only way into a multi-actor keeper state. Seeded at the wall clock,
93
+ // like the reset, so they sort after the bootstrap actor.
94
+ const extra_actors = [];
95
+ for (const name of options.extra_actors ?? []) {
96
+ const seeded_actor = await create_test_extra_actor(test_app.backend.deps.db, test_app.backend.account.id, name);
97
+ extra_actors.push({ id: seeded_actor.id, name: seeded_actor.name });
176
98
  }
99
+ const fixture = {
100
+ transport: in_process_fetch_transport(test_app.app),
101
+ // In-process the wrapper is stateless and never auto-adds Origin —
102
+ // `options` is accepted for API symmetry with cross-process but
103
+ // has no observable effect.
104
+ fresh_transport: () => in_process_fetch_transport(test_app.app),
105
+ account: test_app.backend.account,
106
+ actor: test_app.backend.actor,
107
+ create_session_headers: test_app.create_session_headers,
108
+ create_bearer_headers: test_app.create_bearer_headers,
109
+ create_daemon_token_headers: test_app.create_daemon_token_headers,
110
+ create_account: test_app.create_account,
111
+ extra_accounts,
112
+ extra_actors,
113
+ reject_unknown_audit_metadata_keys: options.reject_unknown_audit_metadata_keys ?? false,
114
+ assert_db_invariants: test_app.assert_db_invariants,
115
+ // Forge directly against the live backend's DB + keyring — no wire
116
+ // hop needed in-process.
117
+ mint_expired_session: async () => {
118
+ const { session_cookie } = await mint_test_session({
119
+ db: test_app.backend.deps.db,
120
+ keyring: test_app.backend.keyring,
121
+ account_id: test_app.backend.account.id,
122
+ expires_in_seconds: EXPIRED_SESSION_OFFSET_SECONDS
123
+ });
124
+ return `${cookie_name}=${session_cookie}`;
125
+ },
126
+ // The session mint writes what the Rust `_testing_mint_session` writes
127
+ // (`mint_test_session`: a full lifetime past the database's `NOW()`);
128
+ // the token mints, the revocations and the expiry go through the
129
+ // queries the production paths (and the expiry backdoor) write with,
130
+ // so the rows match what the cross-process accessors leave. Each
131
+ // credential is proven live first, so its refusal can only be the
132
+ // revocation or the expiry.
133
+ mint_revoked_session: async () => {
134
+ const db = test_app.backend.deps.db;
135
+ const account_id = test_app.backend.account.id;
136
+ const { session_cookie, session_hash } = await mint_test_session({
137
+ db,
138
+ keyring: test_app.backend.keyring,
139
+ account_id,
140
+ expires_in_seconds: AUTH_SESSION_LIFETIME_MS / 1000
141
+ });
142
+ const cookie = `${cookie_name}=${session_cookie}`;
143
+ await assert_credential_authenticates({
144
+ transport: in_process_fetch_transport(test_app.app),
145
+ rpc_path: account_verify_rpc_path('mint_revoked_session'),
146
+ headers: { cookie },
147
+ account_id,
148
+ accessor: 'mint_revoked_session'
149
+ });
150
+ if (!(await query_session_revoke_for_account({ db }, session_hash, account_id))) {
151
+ throw new Error('mint_revoked_session: the revoke removed no session row');
152
+ }
153
+ return cookie;
154
+ },
155
+ mint_revoked_token: async () => {
156
+ const deps = { db: test_app.backend.deps.db };
157
+ const account_id = test_app.backend.account.id;
158
+ const { token, id, token_hash } = generate_api_token();
159
+ await query_create_api_token(deps, id, account_id, 'conformance revoked token', token_hash, token_scope_full());
160
+ await assert_credential_authenticates({
161
+ transport: in_process_fetch_transport(test_app.app),
162
+ rpc_path: account_verify_rpc_path('mint_revoked_token'),
163
+ headers: { authorization: `Bearer ${token}` },
164
+ account_id,
165
+ accessor: 'mint_revoked_token'
166
+ });
167
+ if (!(await query_revoke_api_token_for_account(deps, id, account_id))) {
168
+ throw new Error('mint_revoked_token: the revoke removed no token row');
169
+ }
170
+ return token;
171
+ },
172
+ mint_expired_token: async () => {
173
+ const other = await test_app.create_account();
174
+ await assert_credential_authenticates({
175
+ transport: in_process_fetch_transport(test_app.app),
176
+ rpc_path: account_verify_rpc_path('mint_expired_token'),
177
+ headers: { authorization: `Bearer ${other.api_token}` },
178
+ account_id: other.account.id,
179
+ accessor: 'mint_expired_token'
180
+ });
181
+ const shortened = await query_shorten_credential_expiry(test_app.backend.deps.db, other.account.id, EXPIRED_TOKEN_SHORTEN_SECONDS);
182
+ if (shortened.api_tokens < 1) {
183
+ throw new Error('mint_expired_token: the expiry rewrote no token row');
184
+ }
185
+ await new Promise((resolve) => setTimeout(resolve, EXPIRED_TOKEN_WAIT_MS));
186
+ return other.api_token;
187
+ }
188
+ };
189
+ return fixture;
177
190
  };
178
191
  };
179
192
  // NOTE: bootstrap config is read from `options.bootstrap` — top-level slot,
@@ -187,7 +200,7 @@ export const default_in_process_setup = (options) => async () => {
187
200
  * Build the full in-process suite bundle in a single helper invocation.
188
201
  * Output covers `{setup_test, surface_source, capabilities}` plus every
189
202
  * factory input the Tier 1 suites read at their top level
190
- * (`session_options`, `create_route_specs`, `rpc_endpoints`), and the
203
+ * (`session_cookie_name`, `create_route_specs`, `rpc_endpoints`), and the
191
204
  * integration suite's `base_url` (`null`, no socket) and `max_body_bytes`
192
205
  * (`app_options.max_body_size`, `app_options.host_gate`) — so the call site spreads once and adds
193
206
  * only suite-specific extras (`roles`, `skip_routes`, `input_overrides`,
@@ -196,7 +209,7 @@ export const default_in_process_setup = (options) => async () => {
196
209
  * ```ts
197
210
  * // Suite-extras-free call: helper output is the entire options bag.
198
211
  * describe_round_trip_validation(default_in_process_suite_options({
199
- * session_options,
212
+ * session_cookie_name,
200
213
  * create_route_specs,
201
214
  * rpc_endpoints: [rpc_endpoint_spec],
202
215
  * }));
@@ -204,33 +217,34 @@ export const default_in_process_setup = (options) => async () => {
204
217
  * // With suite-specific extras: spread and add.
205
218
  * describe_standard_admin_integration_tests({
206
219
  * ...default_in_process_suite_options({
207
- * session_options, create_route_specs, rpc_endpoints,
208
- * extra_keeper_roles: [ROLE_ADMIN],
220
+ * session_cookie_name, create_route_specs, rpc_endpoints,
221
+ * extra_keeper_roles: [MY_APP_ROLE],
209
222
  * }),
210
223
  * roles,
211
224
  * });
212
225
  * ```
213
226
  *
214
- * Suites that don't read `session_options` / `rpc_endpoints` at their
227
+ * Suites that don't read `session_cookie_name` / `rpc_endpoints` at their
215
228
  * top level (`round_trip`, `data_exposure`) accept the spread anyway —
216
229
  * excess properties on spread sources aren't checked by TS, and the
217
230
  * uniform shape keeps consumer call sites mechanical.
218
231
  */
219
232
  export const default_in_process_suite_options = (options) => ({
220
233
  setup_test: default_in_process_setup({
221
- session_options: options.session_options,
234
+ session_cookie_name: options.session_cookie_name,
222
235
  create_route_specs: options.create_route_specs,
223
236
  rpc_endpoints: options.rpc_endpoints,
224
237
  bootstrap: options.bootstrap,
225
238
  app_options: options.app_options,
226
- roles: [ROLE_KEEPER, ...(options.extra_keeper_roles ?? [])],
239
+ roles: [...new Set([...DEFAULT_TEST_KEEPER_ROLES, ...(options.extra_keeper_roles ?? [])])],
227
240
  extra_accounts: options.extra_accounts,
228
241
  extra_actors: options.extra_actors,
229
- reject_unknown_audit_metadata_keys: options.reject_unknown_audit_metadata_keys
242
+ reject_unknown_audit_metadata_keys: options.reject_unknown_audit_metadata_keys,
243
+ exclude_db_invariants: options.exclude_db_invariants
230
244
  }),
231
245
  surface_source: options.surface_source ??
232
246
  create_test_app_surface_spec({
233
- session_options: options.session_options,
247
+ session_cookie_name: options.session_cookie_name,
234
248
  create_route_specs: options.create_route_specs,
235
249
  rpc_endpoints: options.rpc_endpoints,
236
250
  // Mirror what `create_test_app` → `create_app_server` will mount.
@@ -245,7 +259,7 @@ export const default_in_process_suite_options = (options) => ({
245
259
  daemon_token: true
246
260
  }),
247
261
  capabilities: in_process_capabilities,
248
- session_options: options.session_options,
262
+ session_cookie_name: options.session_cookie_name,
249
263
  create_route_specs: options.create_route_specs,
250
264
  rpc_endpoints: options.rpc_endpoints,
251
265
  // in-process: no socket, and the limit `create_app_server` mounts
@@ -8,6 +8,18 @@ export interface LoginSecurityCrossTestOptions {
8
8
  readonly login_path?: string;
9
9
  /** REST password-change route path. Default `/api/account/password`. */
10
10
  readonly password_path?: string;
11
+ /**
12
+ * JSON-RPC endpoint path, for the burst-of-correct-logins case's session
13
+ * count. Default `SPINE_RPC_PATH`.
14
+ */
15
+ readonly rpc_path?: string;
16
+ /**
17
+ * The per-account session cap the backend enforces, which the
18
+ * burst-of-correct-logins case holds the account to. Defaults to
19
+ * `DEFAULT_MAX_SESSIONS` — the TS route default and the Rust `const`. A
20
+ * backend that overrides `max_sessions` on the TS side passes its value here.
21
+ */
22
+ readonly max_sessions?: number;
11
23
  /**
12
24
  * Whether the backend serves concurrent logins — each its own database
13
25
  * transaction — at once, for the burst-of-correct-logins case. Default
@@ -1 +1 @@
1
- {"version":3,"file":"login_security.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/login_security.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA2F9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAO5C,mDAAmD;AACnD,MAAM,WAAW,6BAA6B;IAC7C,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAmDD,eAAO,MAAM,mCAAmC,GAC/C,SAAS,6BAA6B,KACpC,IA8VF,CAAC"}
1
+ {"version":3,"file":"login_security.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/login_security.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAgG9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAU5C,mDAAmD;AACnD,MAAM,WAAW,6BAA6B;IAC7C,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,kFAAkF;IAClF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;;;OAMG;IACH,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAmDD,eAAO,MAAM,mCAAmC,GAC/C,SAAS,6BAA6B,KACpC,IA0XF,CAAC"}
@@ -38,7 +38,10 @@ import '../assert_dev_env.js';
38
38
  * - **a burst of correct logins past the cap waits, then succeeds** — attempts
39
39
  * count while in flight whatever their outcome, so `2 × ip_limit` correct
40
40
  * logins at once from one address meet the cap; the ones past it wait for a
41
- * slot (at most the cap of them) and all answer `200`. Runs on a backend
41
+ * slot (at most the cap of them) and all answer `200`. Afterward the account
42
+ * holds exactly the session cap (`max_sessions`): concurrent mints of one
43
+ * account take turns on its row lock, each evicting against the sessions
44
+ * committed before it, so none commits above the cap. Runs on a backend
42
45
  * that serves concurrent transactions (`concurrent_transactions`).
43
46
  * - **every `X-Forwarded-For` line is read** — a client that sends its own
44
47
  * line ahead of the one the trusted proxy appended can't choose its bucket:
@@ -76,11 +79,15 @@ import '../assert_dev_env.js';
76
79
  * @module
77
80
  */
78
81
  import { describe, test, assert } from 'vitest';
82
+ import { SessionListOutput } from '../../auth/account_action_specs.js';
83
+ import { DEFAULT_MAX_SESSIONS } from '../../auth/account_route_schema.js';
79
84
  import { ERROR_RATE_LIMIT_EXCEEDED } from '../../http/error_schemas.js';
80
85
  import { raw_http_exchange, raw_http_parse_response, raw_http_request } from '../transports/raw_http.js';
81
86
  import { default_login_account_rate_limit, default_login_ip_rate_limit } from '../../rate_limiter.js';
82
87
  import { list_audit_events } from './audit_cross_helpers.js';
83
- import { SPINE_ACCOUNT_LOGIN_PATH, SPINE_ACCOUNT_PASSWORD_PATH } from './spine_surface_constants.js';
88
+ import { test_if } from './capabilities.js';
89
+ import { cross_rpc_call, expect_output } from './cross_rpc.js';
90
+ import { SPINE_ACCOUNT_LOGIN_PATH, SPINE_ACCOUNT_PASSWORD_PATH, SPINE_RPC_PATH } from './spine_surface_constants.js';
84
91
  /**
85
92
  * RFC 5737 TEST-NET-3 (`203.0.113.0/24`) documentation addresses — guaranteed
86
93
  * non-routable, so they never collide with a real client IP. One per bucket the
@@ -123,6 +130,8 @@ export const describe_login_security_cross_tests = (options) => {
123
130
  const { setup_test } = options;
124
131
  const login_path = options.login_path ?? SPINE_ACCOUNT_LOGIN_PATH;
125
132
  const password_path = options.password_path ?? SPINE_ACCOUNT_PASSWORD_PATH;
133
+ const rpc_path = options.rpc_path ?? SPINE_RPC_PATH;
134
+ const max_sessions = options.max_sessions ?? DEFAULT_MAX_SESSIONS;
126
135
  const concurrent_transactions = options.concurrent_transactions ?? false;
127
136
  const base_url = options.base_url ?? null;
128
137
  /** Per-IP cap shared by both impls (TS `default_login_ip_rate_limit`, Rust `DEFAULT_LOGIN_IP_RATE_LIMIT`). */
@@ -134,6 +143,8 @@ export const describe_login_security_cross_tests = (options) => {
134
143
  // Assert the ordering so a future cap change fails loud here instead of as a
135
144
  // confusing 429-instead-of-401 mid-case.
136
145
  assert(default_login_account_rate_limit.max_attempts > ip_limit, 'login-security XFF segregation needs the per-account cap above the per-IP cap');
146
+ // The concurrent correct-login burst counts on filling the session cap.
147
+ assert(ip_limit * 2 >= max_sessions, `the login burst (${ip_limit * 2}) must reach the session cap (${max_sessions})`);
137
148
  /**
138
149
  * POST a login with the given `X-Forwarded-For` on a fresh (cookie-jar-free)
139
150
  * transport — wrong password against a non-existent username, so the handler
@@ -284,7 +295,7 @@ export const describe_login_security_cross_tests = (options) => {
284
295
  const after = await attempt(fixture, XFF_BURST, 'probe_burst');
285
296
  assert.strictEqual(after.status, 429, 'the burst must leave the per-IP bucket full');
286
297
  });
287
- test.skipIf(!concurrent_transactions)(`a concurrent burst of ${ip_limit * 2} correct logins all succeed past the per-IP cap`, async () => {
298
+ test_if(concurrent_transactions, `a concurrent burst of ${ip_limit * 2} correct logins all succeed past the per-IP cap`, async () => {
288
299
  const fixture = await setup_test();
289
300
  const account = await fixture.create_account({
290
301
  username: 'burst_correct',
@@ -292,8 +303,14 @@ export const describe_login_security_cross_tests = (options) => {
292
303
  });
293
304
  const statuses = await Promise.all(Array.from({ length: ip_limit * 2 }, () => succeed(fixture, XFF_CORRECT_BURST, account.account.username, 'burst_correct_password')));
294
305
  assert.deepStrictEqual(statuses, Array(ip_limit * 2).fill(200), 'the logins past the cap wait for a slot rather than being refused');
306
+ // The burst alone fills the session cap (asserted at collection), so
307
+ // whatever the account held before it, exactly the cap remains. Listed
308
+ // with the account's API token, which no session eviction touches.
309
+ const { sessions } = expect_output(await cross_rpc_call(fixture.fresh_transport({ origin: null }), rpc_path, 'account_session_list', undefined, account.create_bearer_headers()), SessionListOutput);
310
+ assert.strictEqual(sessions.length, max_sessions, `the account must hold exactly ${max_sessions} sessions after a concurrent burst ` +
311
+ 'of logins — each mint evicting against the sessions committed before it');
295
312
  });
296
- test.skipIf(base_url === null)('every X-Forwarded-For line is read (a spoofed first line picks no bucket)', async () => {
313
+ test_if(base_url !== null, 'every X-Forwarded-For line is read (a spoofed first line picks no bucket)', async () => {
297
314
  assert.ok(base_url !== null);
298
315
  const fixture = await setup_test();
299
316
  for (let i = 0; i < ip_limit; i++) {
@@ -19,8 +19,6 @@ export interface RequestTargetConformanceWireCrossTestOptions {
19
19
  readonly rpc_path?: string;
20
20
  /** WebSocket endpoint path. Default `SPINE_WS_PATH`. */
21
21
  readonly ws_path?: string;
22
- /** Account status route path. Default `SPINE_ACCOUNT_STATUS_PATH`. */
23
- readonly account_status_path?: string;
24
22
  /** Login route path, the `POST`-only route. Default `SPINE_ACCOUNT_LOGIN_PATH`. */
25
23
  readonly account_login_path?: string;
26
24
  /** Audit stream path, the SSE route. Default `SPINE_SSE_PATH`. */
@@ -1 +1 @@
1
- {"version":3,"file":"request_target_conformance_wire.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/request_target_conformance_wire.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA8D9B,OAAO,EAAW,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAQtE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AASzD,0EAA0E;AAC1E,MAAM,WAAW,4CAA4C;IAC5D,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,sEAAsE;IACtE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC,mFAAmF;IACnF,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,8EAA8E;IAC9E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC9B;AA6HD,eAAO,MAAM,oDAAoD,GAChE,SAAS,4CAA4C,KACnD,IAgKF,CAAC"}
1
+ {"version":3,"file":"request_target_conformance_wire.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/request_target_conformance_wire.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA8D9B,OAAO,EAAW,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAQtE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AASzD,0EAA0E;AAC1E,MAAM,WAAW,4CAA4C;IAC5D,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,mFAAmF;IACnF,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,8EAA8E;IAC9E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC9B;AA6HD,eAAO,MAAM,oDAAoD,GAChE,SAAS,4CAA4C,KACnD,IAkKF,CAAC"}
@@ -151,7 +151,9 @@ export const describe_request_target_conformance_wire_cross_tests = (options) =>
151
151
  const placeholders = {
152
152
  rpc_path: options.rpc_path ?? SPINE_RPC_PATH,
153
153
  ws_path: options.ws_path ?? SPINE_WS_PATH,
154
- account_status_path: options.account_status_path ?? SPINE_ACCOUNT_STATUS_PATH,
154
+ // the spine's, as `query_shape` and `token_scope_surface` send to and the
155
+ // mount suite probes: the one path `capabilities.account_status` names
156
+ account_status_path: SPINE_ACCOUNT_STATUS_PATH,
155
157
  account_login_path: options.account_login_path ?? SPINE_ACCOUNT_LOGIN_PATH,
156
158
  sse_path: options.sse_path ?? SPINE_SSE_PATH,
157
159
  health_path: options.health_path ?? '/health'
@@ -1,6 +1,6 @@
1
1
  import '../assert_dev_env.js';
2
2
  import type { BackendCapabilities } from './capabilities.js';
3
- import type { TestAccount } from '../app_server.js';
3
+ import type { TestAccount } from '../test_app.js';
4
4
  import type { TestFixture } from './setup.js';
5
5
  /**
6
6
  * POST a JSON body to a REST route on `account`'s session, asserting `200`.
@@ -30,7 +30,17 @@ export declare const cross_admin_token_revoke_all: (fixture: TestFixture, rpc_pa
30
30
  * @param account_id - the account to purge
31
31
  */
32
32
  export declare const cross_account_purge: (fixture: TestFixture, rpc_path: string, account_id: string) => Promise<void>;
33
- /** One account-wide revocation, as a row both transport suites iterate. */
33
+ /**
34
+ * What a revocation row closes:
35
+ *
36
+ * - `account` — every connection of the target account, whatever credential
37
+ * opened it
38
+ * - `session` — only the connections of the session the revocation was sent on
39
+ * (`TestAccount.create_session_headers`'s); the account's other sessions, its
40
+ * API tokens, and the daemon token stay valid, and their connections open
41
+ */
42
+ export type AccountRevocationCloses = 'account' | 'session';
43
+ /** One revocation of a target account's credentials, as a row both transport suites iterate. */
34
44
  export interface AccountRevocation {
35
45
  /** Names the revocation in a case name and a failure message. */
36
46
  readonly label: string;
@@ -41,6 +51,8 @@ export interface AccountRevocation {
41
51
  readonly slug: string;
42
52
  /** Whether the backend serves the revocation (beyond `rpc_path`, which every row needs). */
43
53
  readonly gate: boolean;
54
+ /** Which of the target's connections the revocation closes. */
55
+ readonly closes: AccountRevocationCloses;
44
56
  /**
45
57
  * Revoke `target`'s credentials and assert the revocation succeeded.
46
58
  * `target` must have been created with `DEFAULT_TEST_PASSWORD`, which the
@@ -60,9 +72,10 @@ export interface AccountRevocationsOptions {
60
72
  readonly password_path: string;
61
73
  }
62
74
  /**
63
- * The account-wide revocations that close every connection of the target
64
- * account: `admin_token_revoke_all`, `POST /logout`, `POST /password`, and
65
- * `account_purge` (gated on `capabilities.account_lifecycle`).
75
+ * The revocations of a target account's credentials both transport suites
76
+ * drive: `admin_token_revoke_all`, `POST /password`, and `account_purge`
77
+ * (gated on `capabilities.account_lifecycle`) close every connection of the
78
+ * account; `POST /logout` closes only the connections of the session it ends.
66
79
  *
67
80
  * @param options - the backend's capabilities and route paths
68
81
  * @returns the revocation rows, in a stable order
@@ -1 +1 @@
1
- {"version":3,"file":"revocation_drivers.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/revocation_drivers.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA4B9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GACzB,SAAS,WAAW,EACpB,SAAS,WAAW,EACpB,MAAM,MAAM,EACZ,MAAM,OAAO,KACX,OAAO,CAAC,IAAI,CAOd,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,WAAW,EACpB,UAAU,MAAM,EAChB,YAAY,MAAM,KAChB,OAAO,CAAC,IAAI,CASd,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAC/B,SAAS,WAAW,EACpB,UAAU,MAAM,EAChB,YAAY,MAAM,KAChB,OAAO,CAAC,IAAI,CASd,CAAC;AAEF,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IACjC,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4FAA4F;IAC5F,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9E;AAED,sDAAsD;AACtD,MAAM,WAAW,yBAAyB;IACzC,8EAA8E;IAC9E,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8BAA8B;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,uCAAuC;IACvC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,GACtC,SAAS,yBAAyB,KAChC,aAAa,CAAC,iBAAiB,CAiCjC,CAAC"}
1
+ {"version":3,"file":"revocation_drivers.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/revocation_drivers.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA+B9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GACzB,SAAS,WAAW,EACpB,SAAS,WAAW,EACpB,MAAM,MAAM,EACZ,MAAM,OAAO,KACX,OAAO,CAAC,IAAI,CAOd,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,WAAW,EACpB,UAAU,MAAM,EAChB,YAAY,MAAM,KAChB,OAAO,CAAC,IAAI,CASd,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAC/B,SAAS,WAAW,EACpB,UAAU,MAAM,EAChB,YAAY,MAAM,KAChB,OAAO,CAAC,IAAI,CASd,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,SAAS,CAAC;AAE5D,gGAAgG;AAChG,MAAM,WAAW,iBAAiB;IACjC,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4FAA4F;IAC5F,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9E;AAED,sDAAsD;AACtD,MAAM,WAAW,yBAAyB;IACzC,8EAA8E;IAC9E,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8BAA8B;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,uCAAuC;IACvC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,GACtC,SAAS,yBAAyB,KAChC,aAAa,CAAC,iBAAiB,CAqCjC,CAAC"}
@@ -1,16 +1,19 @@
1
1
  import '../assert_dev_env.js';
2
2
  /**
3
- * The account-wide revocations the cross-process WS and SSE round-trip suites
4
- * both close a live connection on — one table, so a revocation added here is
5
- * covered on both transports.
3
+ * The revocations sent on a target account's own session or by an admin that
4
+ * the cross-process WS and SSE round-trip suites both close a live connection
5
+ * on — one table, so a revocation added here is covered on both transports.
6
6
  *
7
7
  * Each row drives one revocation of a target account's credentials and asserts
8
8
  * it succeeded; the suite opens the target's connections first and asserts
9
- * their close after. `describe_cross_process_ws_tests` and
9
+ * their close after. Each row says what it closes (`AccountRevocation.closes`):
10
+ * the whole account, or only the session the revocation was sent on
11
+ * (`POST /logout`), which leaves the account's other credentials' connections
12
+ * open. `describe_cross_process_ws_tests` and
10
13
  * `describe_cross_process_sse_tests` iterate `create_account_revocations`. The
11
- * revocations whose close is narrower than the account (one session, one
12
- * token, a cap eviction) or that a suite drives differently (session
13
- * revoke-all, account delete) stay in their suites.
14
+ * revocations that name a credential in their input (one session, one token),
15
+ * a cap eviction, and those a suite drives differently (session revoke-all,
16
+ * account delete) stay in their suites.
14
17
  *
15
18
  * The drivers are exported on their own for a consumer suite that closes a
16
19
  * transport of its own on the same revocations.
@@ -63,9 +66,10 @@ export const cross_account_purge = async (fixture, rpc_path, account_id) => {
63
66
  assert.ok(res.ok, `account_purge failed: ${JSON.stringify(res.error)}`);
64
67
  };
65
68
  /**
66
- * The account-wide revocations that close every connection of the target
67
- * account: `admin_token_revoke_all`, `POST /logout`, `POST /password`, and
68
- * `account_purge` (gated on `capabilities.account_lifecycle`).
69
+ * The revocations of a target account's credentials both transport suites
70
+ * drive: `admin_token_revoke_all`, `POST /password`, and `account_purge`
71
+ * (gated on `capabilities.account_lifecycle`) close every connection of the
72
+ * account; `POST /logout` closes only the connections of the session it ends.
69
73
  *
70
74
  * @param options - the backend's capabilities and route paths
71
75
  * @returns the revocation rows, in a stable order
@@ -77,18 +81,21 @@ export const create_account_revocations = (options) => {
77
81
  label: 'admin_token_revoke_all',
78
82
  slug: 'token_revoke_all',
79
83
  gate: true,
84
+ closes: 'account',
80
85
  revoke: (fixture, target) => cross_admin_token_revoke_all(fixture, rpc_path, target.account.id)
81
86
  },
82
87
  {
83
88
  label: 'POST /logout',
84
89
  slug: 'logout',
85
90
  gate: true,
91
+ closes: 'session',
86
92
  revoke: (fixture, target) => cross_post_as(fixture, target, logout_path, {})
87
93
  },
88
94
  {
89
95
  label: 'POST /password',
90
96
  slug: 'password',
91
97
  gate: true,
98
+ closes: 'account',
92
99
  revoke: (fixture, target) => cross_post_as(fixture, target, password_path, {
93
100
  current_password: DEFAULT_TEST_PASSWORD,
94
101
  new_password: 'revoked-new-password-456'
@@ -98,6 +105,7 @@ export const create_account_revocations = (options) => {
98
105
  label: 'account_purge',
99
106
  slug: 'purge',
100
107
  gate: capabilities.account_lifecycle,
108
+ closes: 'account',
101
109
  revoke: (fixture, target) => cross_account_purge(fixture, rpc_path, target.account.id)
102
110
  }
103
111
  ];