@fuzdev/fuz_app 0.179.0 → 0.181.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 (358) hide show
  1. package/dist/actions/CLAUDE.md +14 -14
  2. package/dist/actions/action_rpc.d.ts +14 -5
  3. package/dist/actions/action_rpc.d.ts.map +1 -1
  4. package/dist/actions/action_rpc.js +53 -46
  5. package/dist/actions/action_types.d.ts +15 -12
  6. package/dist/actions/action_types.d.ts.map +1 -1
  7. package/dist/actions/perform_action.d.ts +4 -4
  8. package/dist/actions/perform_action.d.ts.map +1 -1
  9. package/dist/actions/perform_action.js +6 -6
  10. package/dist/actions/register_action_ws.d.ts +6 -2
  11. package/dist/actions/register_action_ws.d.ts.map +1 -1
  12. package/dist/actions/register_action_ws.js +14 -3
  13. package/dist/actions/ws_socket_session.js +1 -1
  14. package/dist/auth/CLAUDE.md +36 -30
  15. package/dist/auth/account_actions.d.ts.map +1 -1
  16. package/dist/auth/account_actions.js +18 -1
  17. package/dist/auth/account_queries.d.ts +69 -0
  18. package/dist/auth/account_queries.d.ts.map +1 -1
  19. package/dist/auth/account_queries.js +82 -0
  20. package/dist/auth/account_route_schema.d.ts +26 -16
  21. package/dist/auth/account_route_schema.d.ts.map +1 -1
  22. package/dist/auth/account_route_schema.js +10 -24
  23. package/dist/auth/account_routes.d.ts +4 -6
  24. package/dist/auth/account_routes.d.ts.map +1 -1
  25. package/dist/auth/account_routes.js +86 -66
  26. package/dist/auth/admin_actions.d.ts.map +1 -1
  27. package/dist/auth/admin_actions.js +63 -14
  28. package/dist/auth/api_token_queries.d.ts +16 -7
  29. package/dist/auth/api_token_queries.d.ts.map +1 -1
  30. package/dist/auth/api_token_queries.js +18 -18
  31. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  32. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  33. package/dist/auth/audit_log_routes.d.ts +1 -1
  34. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  35. package/dist/auth/audit_log_routes.js +10 -12
  36. package/dist/auth/audit_log_schema.js +4 -4
  37. package/dist/auth/bearer_auth.d.ts +4 -3
  38. package/dist/auth/bearer_auth.d.ts.map +1 -1
  39. package/dist/auth/bearer_auth.js +35 -31
  40. package/dist/auth/bootstrap_account.d.ts +65 -37
  41. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  42. package/dist/auth/bootstrap_account.js +115 -66
  43. package/dist/auth/bootstrap_route_schema.d.ts +6 -2
  44. package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
  45. package/dist/auth/bootstrap_route_schema.js +7 -2
  46. package/dist/auth/bootstrap_routes.d.ts +50 -33
  47. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  48. package/dist/auth/bootstrap_routes.js +109 -87
  49. package/dist/auth/bootstrap_token_store.d.ts +60 -0
  50. package/dist/auth/bootstrap_token_store.d.ts.map +1 -0
  51. package/dist/auth/bootstrap_token_store.js +39 -0
  52. package/dist/auth/credential_headers.d.ts +71 -0
  53. package/dist/auth/credential_headers.d.ts.map +1 -0
  54. package/dist/auth/credential_headers.js +100 -0
  55. package/dist/auth/daemon_token.d.ts +13 -1
  56. package/dist/auth/daemon_token.d.ts.map +1 -1
  57. package/dist/auth/daemon_token.js +14 -2
  58. package/dist/auth/daemon_token_middleware.d.ts +10 -11
  59. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  60. package/dist/auth/daemon_token_middleware.js +27 -29
  61. package/dist/auth/deps.d.ts +0 -11
  62. package/dist/auth/deps.d.ts.map +1 -1
  63. package/dist/auth/invite_queries.d.ts +18 -0
  64. package/dist/auth/invite_queries.d.ts.map +1 -1
  65. package/dist/auth/invite_queries.js +24 -0
  66. package/dist/auth/request_context.d.ts +26 -5
  67. package/dist/auth/request_context.d.ts.map +1 -1
  68. package/dist/auth/request_context.js +17 -10
  69. package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
  70. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  71. package/dist/auth/role_grant_offer_action_specs.js +3 -2
  72. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  73. package/dist/auth/role_grant_offer_actions.js +37 -14
  74. package/dist/auth/role_grant_offer_ddl.d.ts +7 -1
  75. package/dist/auth/role_grant_offer_ddl.d.ts.map +1 -1
  76. package/dist/auth/role_grant_offer_ddl.js +9 -2
  77. package/dist/auth/role_grant_offer_queries.d.ts +56 -3
  78. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  79. package/dist/auth/role_grant_offer_queries.js +93 -8
  80. package/dist/auth/role_grant_queries.d.ts +7 -0
  81. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  82. package/dist/auth/role_grant_queries.js +8 -0
  83. package/dist/auth/session_cookie.d.ts +105 -25
  84. package/dist/auth/session_cookie.d.ts.map +1 -1
  85. package/dist/auth/session_cookie.js +124 -15
  86. package/dist/auth/session_middleware.d.ts +83 -54
  87. package/dist/auth/session_middleware.d.ts.map +1 -1
  88. package/dist/auth/session_middleware.js +92 -66
  89. package/dist/auth/session_queries.d.ts +64 -4
  90. package/dist/auth/session_queries.d.ts.map +1 -1
  91. package/dist/auth/session_queries.js +53 -4
  92. package/dist/auth/signup_route_schema.d.ts +5 -5
  93. package/dist/auth/signup_route_schema.d.ts.map +1 -1
  94. package/dist/auth/signup_route_schema.js +4 -4
  95. package/dist/auth/signup_routes.d.ts.map +1 -1
  96. package/dist/auth/signup_routes.js +17 -14
  97. package/dist/auth/token_scope.d.ts +5 -7
  98. package/dist/auth/token_scope.d.ts.map +1 -1
  99. package/dist/auth/token_scope.js +5 -8
  100. package/dist/dev/setup.d.ts +6 -1
  101. package/dist/dev/setup.d.ts.map +1 -1
  102. package/dist/dev/setup.js +42 -34
  103. package/dist/hono_context.d.ts +21 -0
  104. package/dist/hono_context.d.ts.map +1 -1
  105. package/dist/hono_context.js +17 -0
  106. package/dist/http/CLAUDE.md +150 -43
  107. package/dist/http/auth_shape.d.ts +3 -3
  108. package/dist/http/common_routes.js +1 -1
  109. package/dist/http/db_routes.d.ts +4 -3
  110. package/dist/http/db_routes.d.ts.map +1 -1
  111. package/dist/http/db_routes.js +14 -14
  112. package/dist/http/dev_route_error_check.d.ts +6 -3
  113. package/dist/http/dev_route_error_check.d.ts.map +1 -1
  114. package/dist/http/dev_route_error_check.js +6 -3
  115. package/dist/http/dev_set_cookie_check.d.ts +53 -0
  116. package/dist/http/dev_set_cookie_check.d.ts.map +1 -0
  117. package/dist/http/dev_set_cookie_check.js +80 -0
  118. package/dist/http/error_schemas.d.ts +36 -1
  119. package/dist/http/error_schemas.d.ts.map +1 -1
  120. package/dist/http/error_schemas.js +39 -2
  121. package/dist/http/header_lines.d.ts +42 -0
  122. package/dist/http/header_lines.d.ts.map +1 -0
  123. package/dist/http/header_lines.js +80 -0
  124. package/dist/http/host.d.ts +12 -9
  125. package/dist/http/host.d.ts.map +1 -1
  126. package/dist/http/host.js +25 -20
  127. package/dist/http/origin.d.ts +7 -22
  128. package/dist/http/origin.d.ts.map +1 -1
  129. package/dist/http/origin.js +11 -25
  130. package/dist/http/proxy.d.ts +1 -0
  131. package/dist/http/proxy.d.ts.map +1 -1
  132. package/dist/http/proxy.js +3 -0
  133. package/dist/http/request_headers.d.ts +95 -0
  134. package/dist/http/request_headers.d.ts.map +1 -0
  135. package/dist/http/request_headers.js +110 -0
  136. package/dist/http/request_target.d.ts +134 -0
  137. package/dist/http/request_target.d.ts.map +1 -0
  138. package/dist/http/request_target.js +193 -0
  139. package/dist/http/route_error_check.d.ts +4 -11
  140. package/dist/http/route_error_check.d.ts.map +1 -1
  141. package/dist/http/route_error_check.js +4 -21
  142. package/dist/http/route_result.d.ts +127 -23
  143. package/dist/http/route_result.d.ts.map +1 -1
  144. package/dist/http/route_result.js +97 -19
  145. package/dist/http/route_spec.d.ts +298 -82
  146. package/dist/http/route_spec.d.ts.map +1 -1
  147. package/dist/http/route_spec.js +548 -71
  148. package/dist/http/simple_request.d.ts +19 -14
  149. package/dist/http/simple_request.d.ts.map +1 -1
  150. package/dist/http/simple_request.js +17 -29
  151. package/dist/http/surface.d.ts +2 -0
  152. package/dist/http/surface.d.ts.map +1 -1
  153. package/dist/http/surface.js +4 -1
  154. package/dist/realtime/outbound_budget.d.ts +1 -2
  155. package/dist/realtime/outbound_budget.d.ts.map +1 -1
  156. package/dist/realtime/outbound_budget.js +1 -2
  157. package/dist/realtime/sse.d.ts +47 -17
  158. package/dist/realtime/sse.d.ts.map +1 -1
  159. package/dist/realtime/sse.js +115 -93
  160. package/dist/realtime/sse_constants.d.ts +7 -1
  161. package/dist/realtime/sse_constants.d.ts.map +1 -1
  162. package/dist/realtime/sse_constants.js +12 -1
  163. package/dist/realtime/sse_registry.d.ts +3 -3
  164. package/dist/realtime/sse_registry.js +3 -3
  165. package/dist/runtime/deps.d.ts +20 -4
  166. package/dist/runtime/deps.d.ts.map +1 -1
  167. package/dist/runtime/mock.d.ts +7 -1
  168. package/dist/runtime/mock.d.ts.map +1 -1
  169. package/dist/runtime/mock.js +33 -3
  170. package/dist/runtime/node.d.ts.map +1 -1
  171. package/dist/runtime/node.js +2 -1
  172. package/dist/runtime/secure_file.d.ts +71 -10
  173. package/dist/runtime/secure_file.d.ts.map +1 -1
  174. package/dist/runtime/secure_file.js +91 -11
  175. package/dist/server/app_backend.d.ts +0 -8
  176. package/dist/server/app_backend.d.ts.map +1 -1
  177. package/dist/server/app_backend.js +1 -3
  178. package/dist/server/app_server.d.ts +28 -17
  179. package/dist/server/app_server.d.ts.map +1 -1
  180. package/dist/server/app_server.js +52 -34
  181. package/dist/server/serve_fact_route.d.ts.map +1 -1
  182. package/dist/server/serve_fact_route.js +49 -45
  183. package/dist/server/static.d.ts +20 -0
  184. package/dist/server/static.d.ts.map +1 -1
  185. package/dist/server/static.js +56 -8
  186. package/dist/server/unmatched_route.d.ts +42 -0
  187. package/dist/server/unmatched_route.d.ts.map +1 -0
  188. package/dist/server/unmatched_route.js +64 -0
  189. package/dist/testing/CLAUDE.md +404 -1200
  190. package/dist/testing/app_server.d.ts +3 -1
  191. package/dist/testing/app_server.d.ts.map +1 -1
  192. package/dist/testing/app_server.js +4 -10
  193. package/dist/testing/auth_apps.d.ts.map +1 -1
  194. package/dist/testing/auth_apps.js +2 -1
  195. package/dist/testing/cross_backend/account_lifecycle.d.ts +11 -4
  196. package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
  197. package/dist/testing/cross_backend/account_lifecycle.js +277 -6
  198. package/dist/testing/cross_backend/build_test_backend_paths.d.ts +4 -1
  199. package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
  200. package/dist/testing/cross_backend/build_test_backend_paths.js +1 -1
  201. package/dist/testing/cross_backend/capabilities.d.ts +68 -5
  202. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  203. package/dist/testing/cross_backend/capabilities.js +20 -4
  204. package/dist/testing/cross_backend/cell_gated_create.js +1 -1
  205. package/dist/testing/cross_backend/conformance_case.d.ts +63 -21
  206. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  207. package/dist/testing/cross_backend/conformance_table.d.ts +54 -12
  208. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  209. package/dist/testing/cross_backend/conformance_table.js +179 -23
  210. package/dist/testing/cross_backend/cookie_attributes.js +1 -1
  211. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +7 -1
  212. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
  213. package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +3 -3
  214. package/dist/testing/cross_backend/credential_conformance.d.ts +196 -0
  215. package/dist/testing/cross_backend/credential_conformance.d.ts.map +1 -0
  216. package/dist/testing/cross_backend/credential_conformance.js +296 -0
  217. package/dist/testing/cross_backend/credential_conformance.json +1284 -0
  218. package/dist/testing/cross_backend/credential_conformance_wire.d.ts +40 -0
  219. package/dist/testing/cross_backend/credential_conformance_wire.d.ts.map +1 -0
  220. package/dist/testing/cross_backend/credential_conformance_wire.js +293 -0
  221. package/dist/testing/cross_backend/credential_header_robustness.d.ts +1 -3
  222. package/dist/testing/cross_backend/credential_header_robustness.d.ts.map +1 -1
  223. package/dist/testing/cross_backend/credential_header_robustness.js +24 -55
  224. package/dist/testing/cross_backend/credential_wire.d.ts +112 -0
  225. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -0
  226. package/dist/testing/cross_backend/credential_wire.js +188 -0
  227. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  228. package/dist/testing/cross_backend/default_backend_configs.js +22 -2
  229. package/dist/testing/cross_backend/default_spine_surface.js +1 -1
  230. package/dist/testing/cross_backend/differential.d.ts +1 -1
  231. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  232. package/dist/testing/cross_backend/differential.js +3 -2
  233. package/dist/testing/cross_backend/differential_normalize.d.ts +23 -6
  234. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  235. package/dist/testing/cross_backend/differential_normalize.js +11 -5
  236. package/dist/testing/cross_backend/full_spine_mount.d.ts +1 -0
  237. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  238. package/dist/testing/cross_backend/full_spine_mount.js +7 -0
  239. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  240. package/dist/testing/cross_backend/identity_parity.js +4 -0
  241. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  242. package/dist/testing/cross_backend/in_process_setup.js +78 -4
  243. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  244. package/dist/testing/cross_backend/login_security.js +13 -10
  245. package/dist/testing/cross_backend/peer_ping_ws.d.ts +1 -1
  246. package/dist/testing/cross_backend/peer_ping_ws.js +2 -2
  247. package/dist/testing/cross_backend/request_header_conformance.d.ts +174 -0
  248. package/dist/testing/cross_backend/request_header_conformance.d.ts.map +1 -0
  249. package/dist/testing/cross_backend/request_header_conformance.js +196 -0
  250. package/dist/testing/cross_backend/request_header_conformance.json +1158 -0
  251. package/dist/testing/cross_backend/request_header_conformance_wire.d.ts +39 -0
  252. package/dist/testing/cross_backend/request_header_conformance_wire.d.ts.map +1 -0
  253. package/dist/testing/cross_backend/request_header_conformance_wire.js +284 -0
  254. package/dist/testing/cross_backend/request_target_conformance.d.ts +298 -0
  255. package/dist/testing/cross_backend/request_target_conformance.d.ts.map +1 -0
  256. package/dist/testing/cross_backend/request_target_conformance.js +186 -0
  257. package/dist/testing/cross_backend/request_target_conformance.json +3765 -0
  258. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +32 -0
  259. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -0
  260. package/dist/testing/cross_backend/request_target_conformance_wire.js +278 -0
  261. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  262. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +173 -1
  263. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  264. package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +2 -1
  265. package/dist/testing/cross_backend/rpc_adversarial.d.ts +6 -4
  266. package/dist/testing/cross_backend/rpc_adversarial.d.ts.map +1 -1
  267. package/dist/testing/cross_backend/rpc_adversarial.js +5 -2
  268. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +6 -7
  269. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  270. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +4 -5
  271. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  272. package/dist/testing/cross_backend/session_cap.js +56 -29
  273. package/dist/testing/cross_backend/session_cookie_effect.d.ts +43 -0
  274. package/dist/testing/cross_backend/session_cookie_effect.d.ts.map +1 -0
  275. package/dist/testing/cross_backend/session_cookie_effect.js +103 -0
  276. package/dist/testing/cross_backend/session_login.d.ts +24 -0
  277. package/dist/testing/cross_backend/session_login.d.ts.map +1 -0
  278. package/dist/testing/cross_backend/session_login.js +31 -0
  279. package/dist/testing/cross_backend/setup.d.ts +117 -0
  280. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  281. package/dist/testing/cross_backend/setup.js +193 -9
  282. package/dist/testing/cross_backend/simple_request.d.ts.map +1 -1
  283. package/dist/testing/cross_backend/simple_request.js +5 -0
  284. package/dist/testing/cross_backend/spine_suites.d.ts +9 -1
  285. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  286. package/dist/testing/cross_backend/spine_suites.js +88 -5
  287. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  288. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  289. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  290. package/dist/testing/cross_backend/sse_round_trip.d.ts +8 -5
  291. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  292. package/dist/testing/cross_backend/sse_round_trip.js +205 -64
  293. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  294. package/dist/testing/cross_backend/testing_backdoor.js +5 -2
  295. package/dist/testing/cross_backend/testing_credential_read.d.ts +165 -0
  296. package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -0
  297. package/dist/testing/cross_backend/testing_credential_read.js +175 -0
  298. package/dist/testing/cross_backend/testing_reset_actions.d.ts +19 -0
  299. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  300. package/dist/testing/cross_backend/testing_reset_actions.js +22 -6
  301. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  302. package/dist/testing/cross_backend/token_lifetime.js +58 -2
  303. package/dist/testing/cross_backend/transport_composition.d.ts +2 -4
  304. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  305. package/dist/testing/cross_backend/transport_composition.js +13 -10
  306. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  307. package/dist/testing/cross_backend/ts_spine_backend_config.js +5 -3
  308. package/dist/testing/cross_backend/ws_endpoint.d.ts +11 -1
  309. package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
  310. package/dist/testing/cross_backend/ws_endpoint.js +19 -2
  311. package/dist/testing/cross_backend/ws_role_gated.d.ts.map +1 -1
  312. package/dist/testing/cross_backend/ws_role_gated.js +2 -3
  313. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  314. package/dist/testing/cross_backend/ws_round_trip.js +28 -12
  315. package/dist/testing/cross_backend/xfail.d.ts +44 -11
  316. package/dist/testing/cross_backend/xfail.d.ts.map +1 -1
  317. package/dist/testing/cross_backend/xfail.js +68 -23
  318. package/dist/testing/data_exposure.d.ts.map +1 -1
  319. package/dist/testing/data_exposure.js +4 -3
  320. package/dist/testing/integration.d.ts +1 -2
  321. package/dist/testing/integration.d.ts.map +1 -1
  322. package/dist/testing/integration.js +14 -8
  323. package/dist/testing/integration_helpers.d.ts +50 -3
  324. package/dist/testing/integration_helpers.d.ts.map +1 -1
  325. package/dist/testing/integration_helpers.js +87 -9
  326. package/dist/testing/middleware.d.ts +2 -0
  327. package/dist/testing/middleware.d.ts.map +1 -1
  328. package/dist/testing/middleware.js +9 -2
  329. package/dist/testing/round_trip.d.ts +6 -2
  330. package/dist/testing/round_trip.d.ts.map +1 -1
  331. package/dist/testing/round_trip.js +17 -6
  332. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  333. package/dist/testing/rpc_envelope_cases.js +7 -0
  334. package/dist/testing/rpc_helpers.d.ts +4 -2
  335. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  336. package/dist/testing/rpc_helpers.js +6 -1
  337. package/dist/testing/rpc_round_trip.d.ts +13 -2
  338. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  339. package/dist/testing/rpc_round_trip.js +25 -6
  340. package/dist/testing/schema_generators.d.ts +2 -2
  341. package/dist/testing/schema_generators.d.ts.map +1 -1
  342. package/dist/testing/schema_generators.js +4 -4
  343. package/dist/testing/stubs.d.ts +2 -2
  344. package/dist/testing/stubs.d.ts.map +1 -1
  345. package/dist/testing/stubs.js +8 -8
  346. package/dist/testing/transports/fetch_transport.d.ts +6 -3
  347. package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
  348. package/dist/testing/transports/fetch_transport.js +31 -19
  349. package/dist/testing/transports/raw_http.d.ts +61 -1
  350. package/dist/testing/transports/raw_http.d.ts.map +1 -1
  351. package/dist/testing/transports/raw_http.js +61 -1
  352. package/dist/testing/transports/ws_raw_client.d.ts +20 -0
  353. package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
  354. package/dist/testing/transports/ws_raw_client.js +10 -4
  355. package/dist/testing/transports/ws_transport.d.ts +21 -1
  356. package/dist/testing/transports/ws_transport.d.ts.map +1 -1
  357. package/dist/testing/transports/ws_transport.js +58 -20
  358. package/package.json +5 -5
@@ -2,16 +2,29 @@
2
2
  * Bootstrap flow for creating the first account.
3
3
  *
4
4
  * Uses an atomic `bootstrap_lock` table to prevent TOCTOU race conditions.
5
- * Token verification and account creation happen in a single transaction.
5
+ * The lock flip, the account, its keeper and admin grants, its session, and
6
+ * the burn of the one-shot token file all happen in one transaction, the burn
7
+ * last — so a live token never outlives a successful bootstrap, and a
8
+ * bootstrap whose token can't be burned never happened.
6
9
  *
7
10
  * @module
8
11
  */
9
12
  import { timingSafeEqual } from 'node:crypto';
10
13
  import { to_error_message } from '@fuzdev/fuz_util/error.ts';
11
- import { ERROR_INVALID_TOKEN, ERROR_ALREADY_BOOTSTRAPPED, ERROR_TOKEN_FILE_MISSING } from '../http/error_schemas.js';
14
+ import { ERROR_INVALID_TOKEN, ERROR_ALREADY_BOOTSTRAPPED, ERROR_TOKEN_FILE_MISSING, ERROR_TOKEN_FILE_UNDELETABLE } from '../http/error_schemas.js';
12
15
  import { ROLE_ADMIN, ROLE_KEEPER } from './role_schema.js';
13
16
  import { query_create_account_with_actor } from './account_queries.js';
14
17
  import { query_create_role_grant } from './role_grant_queries.js';
18
+ import { create_capped_session } from './session_queries.js';
19
+ import { DEFAULT_MAX_SESSIONS } from './account_route_schema.js';
20
+ /**
21
+ * Thrown out of the bootstrap transaction when the token can't be burned, so
22
+ * the transaction rolls back — `db.transaction` commits when its callback
23
+ * returns. Caught around the transaction and mapped to
24
+ * `ERROR_TOKEN_FILE_UNDELETABLE`; never escapes `bootstrap_account`.
25
+ */
26
+ class BootstrapTokenBurnError extends Error {
27
+ }
15
28
  /**
16
29
  * Strip exactly one trailing `\n` from the operator-written token bytes.
17
30
  *
@@ -34,21 +47,21 @@ const strip_one_trailing_newline = (bytes) => bytes.at(-1) === 0x0a ? bytes.suba
34
47
  export const BOOTSTRAP_TOKEN_MIN_BYTES = 32;
35
48
  /**
36
49
  * Read the bootstrap token the way both the availability check and the
37
- * request-time compare need it: the hardened secure read, less one trailing
50
+ * request-time compare need it: the store's hardened read, less one trailing
38
51
  * LF, refused when shorter than `BOOTSTRAP_TOKEN_MIN_BYTES`. A short token
39
52
  * logs an error naming the file before the throw — it is a misconfiguration
40
53
  * the operator must fix, never a quiet "unavailable". Twin of the Rust
41
54
  * `bootstrap_token_from_file`.
42
55
  *
43
- * @param deps - the secure read and a logger for the short-token error
44
- * @param token_path - the bootstrap token file
56
+ * @param deps - the token store and a logger for the short-token error
45
57
  * @returns the token bytes the provided token is compared against
46
- * @throws Error when the secure read refuses the file or the token is too short
58
+ * @throws Error when the store refuses the file or the token is too short
47
59
  */
48
- export const read_bootstrap_token = async (deps, token_path) => {
49
- const token = strip_one_trailing_newline(await deps.read_secure_file(token_path));
60
+ export const read_bootstrap_token = async (deps) => {
61
+ const { token_store } = deps;
62
+ const token = strip_one_trailing_newline(await token_store.read_token());
50
63
  if (token.length < BOOTSTRAP_TOKEN_MIN_BYTES) {
51
- const message = `bootstrap token at ${token_path} is ${token.length} bytes, under the ${BOOTSTRAP_TOKEN_MIN_BYTES}-byte minimum — regenerate it`;
64
+ const message = `bootstrap token at ${token_store.path} is ${token.length} bytes, under the ${BOOTSTRAP_TOKEN_MIN_BYTES}-byte minimum — regenerate it`;
52
65
  deps.log.error(message);
53
66
  throw new Error(message);
54
67
  }
@@ -57,36 +70,46 @@ export const read_bootstrap_token = async (deps, token_path) => {
57
70
  /**
58
71
  * Bootstrap the first account with keeper and admin privileges.
59
72
  *
60
- * Uses an atomic `bootstrap_lock` UPDATE to prevent concurrent bootstrap
61
- * attempts (TOCTOU). The full flow runs in a single transaction:
62
- *
63
- * 1. Read and verify the bootstrap token (before transaction) — the file's
64
- * raw bytes less one optional trailing LF, at least
73
+ * 1. Read and verify the bootstrap token (before the transaction) — the
74
+ * file's raw bytes less one optional trailing LF, at least
65
75
  * `BOOTSTRAP_TOKEN_MIN_BYTES` long, compared in constant time
66
- * 2. Hash the password (CPU-intensive, before transaction)
67
- * 3. Acquire the bootstrap lock atomically (inside transaction)
68
- * 4. Create account + actor
69
- * 5. Grant keeper and admin role_grants (no expiry, `granted_by = null`)
70
- * 6. Delete the token file (after commit, reported via `token_file_deleted`)
76
+ * 2. Hash the password (CPU-intensive, before the transaction)
77
+ * 3. In one transaction: flip the `bootstrap_lock` atomically (zero rows is
78
+ * the race loser, `already_bootstrapped`, nothing burned); create the
79
+ * account + actor; grant keeper and admin (no expiry, `granted_by =
80
+ * null`); mint the session through the capped minter login uses (the cap
81
+ * evicts nothing on a new account); then burn the token file, last, just
82
+ * before the commit
71
83
  *
72
- * @param deps - database, token path, filesystem callbacks, and password hashing
84
+ * The burn comes after the lock, so only the lock winner burns (its row lock
85
+ * is held across the unlink, so a concurrent attempt waits on its UPDATE);
86
+ * after the inserts, so a failed insert spends nothing; last, so the window
87
+ * between a burn and a failed commit is one round trip. A burn that fails
88
+ * rolls everything back and answers `token_file_undeletable`: nothing was
89
+ * created and the token is still valid, so the operator fixes the directory
90
+ * and retries. A commit that fails after the burn is logged as an error — the
91
+ * token is gone and a new one must be written. Twin of the Rust
92
+ * `bootstrap_handler`.
93
+ *
94
+ * @param deps - database, token store, password hashing, keyring, and logger
73
95
  * @param provided_token - the bootstrap token from the user
74
96
  * @param input - username and password
75
- * @returns the created account, actor, and role_grants — or a bootstrap failure
97
+ * @param options - the session cookie configuration
98
+ * @returns the created account, actor, role_grants, and session cookie value — or a bootstrap failure
76
99
  * @mutates `bootstrap_lock` row - flips `bootstrapped` to `true` atomically
77
- * @mutates `account` / `actor` / `role_grant` tables - inserts the bootstrap account, actor, and the keeper + admin role_grants
78
- * @mutates filesystem - deletes the bootstrap token file after commit (reported via `token_file_deleted`)
100
+ * @mutates `account` / `actor` / `role_grant` / `auth_session` tables - inserts the bootstrap account, actor, keeper + admin role_grants, and session
101
+ * @mutates filesystem - burns the bootstrap token file inside the transaction
79
102
  */
80
- export const bootstrap_account = async (deps, provided_token, input) => {
81
- const { db, token_path, read_secure_file, delete_file, password, log } = deps;
103
+ export const bootstrap_account = async (deps, provided_token, input, options) => {
104
+ const { db, token_store, password, keyring, log } = deps;
82
105
  // 1. Read and verify token (non-destructive, before transaction). The
83
106
  // secure read fails loud on a symlink / non-regular file / permissive mode /
84
- // oversized file, and the read refuses a token under the minimum length —
107
+ // second hard link / oversized file, and the read refuses a token under the minimum length —
85
108
  // every refusal masks as the same TOKEN_FILE_MISSING the wire always
86
109
  // carried, with the specific reason logged for the operator.
87
110
  let expected_token;
88
111
  try {
89
- expected_token = await read_bootstrap_token({ read_secure_file, log }, token_path);
112
+ expected_token = await read_bootstrap_token({ token_store, log });
90
113
  }
91
114
  catch (err) {
92
115
  log.warn(`bootstrap token file rejected: ${to_error_message(err)}`);
@@ -101,46 +124,72 @@ export const bootstrap_account = async (deps, provided_token, input) => {
101
124
  }
102
125
  // 2. Hash password (CPU-intensive, before transaction)
103
126
  const password_hash = await password.hash_password(input.password);
104
- // 3. Atomic transaction: lock + create
105
- const tx_result = await db.transaction(async (tx) => {
106
- const lock_rows = await tx.query('UPDATE bootstrap_lock SET bootstrapped = true WHERE id = 1 AND bootstrapped = false RETURNING id');
107
- if (lock_rows.length === 0) {
108
- return { ok: false, error: ERROR_ALREADY_BOOTSTRAPPED, status: 403 };
109
- }
110
- const tx_deps = { db: tx };
111
- const { account, actor } = await query_create_account_with_actor(tx_deps, {
112
- username: input.username,
113
- password_hash
114
- });
115
- const keeper_role_grant = await query_create_role_grant(tx_deps, {
116
- actor_id: actor.id,
117
- role: ROLE_KEEPER,
118
- granted_by: null,
119
- expires_at: null
120
- });
121
- const admin_role_grant = await query_create_role_grant(tx_deps, {
122
- actor_id: actor.id,
123
- role: ROLE_ADMIN,
124
- granted_by: null,
125
- expires_at: null
126
- });
127
- return {
128
- ok: true,
129
- account,
130
- actor,
131
- role_grants: { keeper: keeper_role_grant, admin: admin_role_grant }
132
- };
133
- });
134
- if (!tx_result.ok)
135
- return tx_result;
136
- // 4. Delete token file (after commit)
137
- let token_file_deleted = true;
127
+ // 3. Atomic transaction: lock, create, mint, burn
128
+ let burned = false;
129
+ let tx_result;
138
130
  try {
139
- await delete_file(token_path);
131
+ tx_result = await db.transaction(async (tx) => {
132
+ const lock_rows = await tx.query('UPDATE bootstrap_lock SET bootstrapped = true WHERE id = 1 AND bootstrapped = false RETURNING id');
133
+ if (lock_rows.length === 0) {
134
+ return { ok: false, error: ERROR_ALREADY_BOOTSTRAPPED, status: 403 };
135
+ }
136
+ const tx_deps = { db: tx };
137
+ const { account, actor } = await query_create_account_with_actor(tx_deps, {
138
+ username: input.username,
139
+ password_hash
140
+ });
141
+ const keeper_role_grant = await query_create_role_grant(tx_deps, {
142
+ actor_id: actor.id,
143
+ role: ROLE_KEEPER,
144
+ granted_by: null,
145
+ expires_at: null
146
+ });
147
+ const admin_role_grant = await query_create_role_grant(tx_deps, {
148
+ actor_id: actor.id,
149
+ role: ROLE_ADMIN,
150
+ granted_by: null,
151
+ expires_at: null
152
+ });
153
+ // The account was created above, so the cap evicts nothing. Routed
154
+ // through the shared minter anyway: the cap is a property of session
155
+ // creation, not of the login route.
156
+ const { cookie_value } = await create_capped_session({
157
+ keyring,
158
+ deps: tx_deps,
159
+ account_id: account.id,
160
+ session_options: options.session_options,
161
+ max_sessions: DEFAULT_MAX_SESSIONS
162
+ });
163
+ // the burn, last before the commit
164
+ let outcome;
165
+ try {
166
+ outcome = await token_store.burn_token();
167
+ }
168
+ catch (err) {
169
+ throw new BootstrapTokenBurnError(to_error_message(err), { cause: err });
170
+ }
171
+ burned = true;
172
+ if (outcome === 'already_gone') {
173
+ log.warn('bootstrap token file was already gone at the burn — counted as burned');
174
+ }
175
+ return {
176
+ ok: true,
177
+ account,
178
+ actor,
179
+ role_grants: { keeper: keeper_role_grant, admin: admin_role_grant },
180
+ session_cookie_value: cookie_value
181
+ };
182
+ });
140
183
  }
141
- catch {
142
- token_file_deleted = false;
143
- log.error(`CRITICAL: Failed to delete bootstrap token file at ${token_path}. Delete it manually.`);
184
+ catch (err) {
185
+ if (err instanceof BootstrapTokenBurnError) {
186
+ log.error(`bootstrap rolled back: could not delete the token file at ${token_store.path} (${err.message}) — the server user needs write access to its directory; nothing was created and the token is still valid, retry`);
187
+ return { ok: false, error: ERROR_TOKEN_FILE_UNDELETABLE, status: 500 };
188
+ }
189
+ if (burned) {
190
+ log.error(`bootstrap rolled back after its token file at ${token_store.path} was deleted (${to_error_message(err)}) — write a new token and restart the server to bootstrap`);
191
+ }
192
+ throw err;
144
193
  }
145
- return { ...tx_result, token_file_deleted };
194
+ return tx_result;
146
195
  };
@@ -57,7 +57,7 @@ export type BootstrapOutput = Infer<typeof BootstrapOutput>;
57
57
  * (`attach_route_handler`); surface generation attaches a stub (handlers are never run
58
58
  * during surface assembly, only the shape is read).
59
59
  */
60
- export declare const bootstrap_route_shape: import("../http/route_spec.js").RouteShape<readonly [import("../http/error_schemas.js").RestErrorDef<401, "invalid_token", Record<never, never>>, import("../http/error_schemas.js").RestErrorDef<403, "already_bootstrapped", Record<never, never>>, import("../http/error_schemas.js").RestErrorDef<404, "token_file_missing", Record<never, never>>], import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
60
+ export declare const bootstrap_route_shape: import("../http/route_spec.js").RouteShape<readonly [import("../http/error_schemas.js").RestErrorDef<401, "invalid_token", Record<never, never>>, import("../http/error_schemas.js").RestErrorDef<403, "already_bootstrapped", Record<never, never>>, import("../http/error_schemas.js").RestErrorDef<404, "token_file_missing", Record<never, never>>, import("../http/error_schemas.js").RestErrorDef<500, "token_file_undeletable", Record<never, never>>], import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
61
61
  ok: import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<true>;
62
62
  account: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
63
63
  id: import("@fuzdev/fuz_schema/schema.ts").BrandSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>, "Uuid">;
@@ -69,5 +69,9 @@ export declare const bootstrap_route_shape: import("../http/route_spec.js").Rout
69
69
  }>, {
70
70
  readonly account: "none";
71
71
  readonly actor: "none";
72
- }, "ip">;
72
+ }, "ip", import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
73
+ token: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
74
+ username: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>>;
75
+ password: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
76
+ }>, undefined, undefined>;
73
77
  //# sourceMappingURL=bootstrap_route_schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap_route_schema.d.ts","sourceRoot":"","sources":["../../src/lib/auth/bootstrap_route_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAON,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAYtC;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;EAMzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;;;;;EAI1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;QAWhC,CAAC"}
1
+ {"version":3,"file":"bootstrap_route_schema.d.ts","sourceRoot":"","sources":["../../src/lib/auth/bootstrap_route_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAON,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAatC;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;EAMzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;;;;;;;EAI1B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;yBAgBhC,CAAC"}
@@ -18,7 +18,7 @@ import { literal, max_length, min_length, object, pipe, string } from '@fuzdev/f
18
18
  import { Username, UsernameCanonical, Uuid } from '../primitive_schemas.js';
19
19
  import { Password } from './password.js';
20
20
  import { define_route_shape } from '../http/route_spec.js';
21
- import { REST_ALREADY_BOOTSTRAPPED, REST_INVALID_TOKEN, REST_TOKEN_FILE_MISSING } from '../http/error_schemas.js';
21
+ import { REST_ALREADY_BOOTSTRAPPED, REST_INVALID_TOKEN, REST_TOKEN_FILE_MISSING, REST_TOKEN_FILE_UNDELETABLE } from '../http/error_schemas.js';
22
22
  /**
23
23
  * The longest `token` `POST /bootstrap` takes, in UTF-16 code units: the token
24
24
  * file's cap, `MAX_SECURE_FILE_SIZE` bytes. A token that can match the file is
@@ -67,5 +67,10 @@ export const bootstrap_route_shape = define_route_shape({
67
67
  input: BootstrapInput,
68
68
  output: BootstrapOutput,
69
69
  rate_limit: 'ip',
70
- errors: [REST_INVALID_TOKEN, REST_ALREADY_BOOTSTRAPPED, REST_TOKEN_FILE_MISSING]
70
+ errors: [
71
+ REST_INVALID_TOKEN,
72
+ REST_ALREADY_BOOTSTRAPPED,
73
+ REST_TOKEN_FILE_MISSING,
74
+ REST_TOKEN_FILE_UNDELETABLE
75
+ ]
71
76
  });
@@ -6,46 +6,58 @@
6
6
  *
7
7
  * @module
8
8
  */
9
- import type { Context } from 'hono';
10
9
  import type { Logger } from '@fuzdev/fuz_util/log.ts';
11
- import type { SessionOptions } from './session_cookie.js';
12
- import { type BootstrapAccountSuccess } from './bootstrap_account.js';
10
+ import { type SessionOptions } from './session_cookie.js';
11
+ import { type BootstrapAccountCreated } from './bootstrap_account.js';
12
+ import type { BootstrapTokenStore } from './bootstrap_token_store.js';
13
13
  import type { Db } from '../db/db.js';
14
14
  import { type RouteSpec } from '../http/route_spec.js';
15
15
  import { type RateLimiter } from '../rate_limiter.js';
16
16
  import type { RouteFactoryDeps } from './deps.js';
17
17
  /**
18
- * Bootstrap status — runtime state computed once at startup.
18
+ * Bootstrap status — runtime state computed once at startup, flipped to
19
+ * unavailable when the window closes.
19
20
  */
20
21
  export interface BootstrapStatus {
21
22
  available: boolean;
22
- token_path: string | null;
23
23
  }
24
+ /**
25
+ * Called after a successful bootstrap has committed, with what it created.
26
+ * Use for app-specific post-bootstrap work like generating API tokens. It
27
+ * gets no request context: the response — its session cookie included — is
28
+ * the route's. A throw is logged and the bootstrap still succeeds, since it
29
+ * has already committed. Twin of the Rust `BootstrapKeeperResolved`.
30
+ */
31
+ export type OnBootstrap = (created: BootstrapAccountCreated) => Promise<void>;
24
32
  /**
25
33
  * Per-factory configuration for bootstrap route specs.
26
34
  *
27
35
  * `bootstrap_status` is runtime state (a mutable ref), not a dep or options value —
28
- * it is passed through so the route handler can flip it on success.
36
+ * it is passed through so the route handler can flip it.
29
37
  */
30
38
  export interface BootstrapRouteOptions {
31
39
  session_options: SessionOptions<string>;
32
- /** Shared mutable reference — flipped to false after successful bootstrap. */
40
+ /** Shared mutable reference — flipped to false when the window closes. */
33
41
  bootstrap_status: BootstrapStatus;
34
42
  /**
35
- * Called after successful bootstrap (account + session created).
36
- * Use for app-specific post-bootstrap work like generating API tokens.
43
+ * The one-shot token. `null` mounts the route permanently closed
44
+ * (`'surface_only'`), answering `already_bootstrapped` as a bootstrapped
45
+ * server does.
37
46
  */
38
- on_bootstrap?: (result: BootstrapAccountSuccess, c: Context) => Promise<void>;
47
+ token_store: BootstrapTokenStore | null;
48
+ /** Called after a successful bootstrap commits. */
49
+ on_bootstrap?: OnBootstrap;
39
50
  /**
40
51
  * Rate limiter for bootstrap attempts, keyed by client IP. Pass `null` to
41
52
  * disable. Its own instance, not login's: bootstrap is one-shot and its
42
53
  * bucket is never refunded on success (see `RateLimiter.reset`), so a
43
54
  * fumbled token would otherwise leave the operator's *login* budget nearly
44
55
  * spent on a deployment where their new account is the only one that
45
- * exists. The Rust spine rate-limits bootstrap not at all (the token is
46
- * 32 bytes of CSPRNG compared in constant time); this is the tighter side
47
- * of that divergence, kept because the token also sits in a file whose
48
- * read path an operator can misconfigure.
56
+ * exists. The token is 32 bytes of CSPRNG compared in constant time, so
57
+ * guessing is not what it bounds: the `invalid_token` and
58
+ * `token_file_undeletable` legs write an unauthenticated audit row each and
59
+ * leave the window open, and the limiter bounds them. Twin of the Rust
60
+ * `BootstrapOptions.bootstrap_ip_rate_limiter`.
49
61
  */
50
62
  bootstrap_ip_rate_limiter: RateLimiter | null;
51
63
  }
@@ -53,8 +65,6 @@ export interface BootstrapRouteOptions {
53
65
  * Dependencies for checking bootstrap status at startup.
54
66
  */
55
67
  export interface CheckBootstrapStatusDeps {
56
- /** Hardened secret-file read — the same capability the request-time read uses. */
57
- read_secure_file: (path: string) => Promise<Uint8Array>;
58
68
  /** Only the single-row `bootstrap_lock` read — narrower than the full `Db`. */
59
69
  db: Pick<Db, 'query_one'>;
60
70
  log: Logger;
@@ -62,31 +72,38 @@ export interface CheckBootstrapStatusDeps {
62
72
  /**
63
73
  * Check bootstrap availability at startup.
64
74
  *
65
- * Bootstrap is available when:
66
- * 1. A token path is configured
67
- * 2. The token file passes the secure read (exists, not a symlink, mode
68
- * `0600`/`0400`, within the size cap) and holds at least
69
- * `BOOTSTRAP_TOKEN_MIN_BYTES` (a shorter one logs an error)
70
- * 3. The `bootstrap_lock` table shows `bootstrapped = false`
75
+ * Bootstrap is available when a token store is configured, the
76
+ * `bootstrap_lock` row shows `bootstrapped = false`, and the token file
77
+ * passes the same `read_bootstrap_token` the request makes — so "bootstrap
78
+ * is available" and "the token file can actually be read" can't drift apart.
79
+ *
80
+ * The lock is read first, so the report fits the state:
81
+ *
82
+ * - a missing `bootstrap_lock` row is unavailable, logged as an `error` — the
83
+ * migration seeds it, and without it every bootstrap would be refused in
84
+ * its transaction while `/status` advertised an open window
85
+ * - bootstrapped, no readable token file: `info`, the steady state
86
+ * - bootstrapped with a readable token file: a `warn` naming it — it would
87
+ * reopen bootstrap on an empty database, so the operator should delete it
88
+ * - not bootstrapped and the file unreadable: a `warn` with the reason (and
89
+ * the `error` a short token logs)
71
90
  *
72
- * The probe **reads through the same `read_bootstrap_token` the request-time
73
- * read uses**, so "bootstrap is available" and "the token file can actually
74
- * be read" can't drift apart — an availability check laxer than the read it
75
- * gates is the misconfiguration that reports green at boot and fails at
76
- * request time. Twin of the Rust spine's `is_bootstrap_available`.
91
+ * Twin of the Rust spine's `is_bootstrap_available`, which logs the same
92
+ * states at the same levels. A failed lock read throws here (boot fails)
93
+ * where the Rust twin reads it as unavailable.
77
94
  *
78
- * @param deps - filesystem and database access for the check
79
- * @param options - static configuration including `token_path`
80
- * @returns an object with `available` (boolean) and `token_path` (string | null)
95
+ * @param deps - the lock read and a logger
96
+ * @param options - the token store, `null` when bootstrap is not configured
97
+ * @returns the initial `BootstrapStatus`
81
98
  */
82
99
  export declare const check_bootstrap_status: (deps: CheckBootstrapStatusDeps, options: {
83
- token_path: string | null;
100
+ token_store: BootstrapTokenStore | null;
84
101
  }) => Promise<BootstrapStatus>;
85
102
  /**
86
103
  * Create bootstrap route specs for first-time account creation.
87
104
  *
88
- * @param deps - stateless capabilities including filesystem access
89
- * @param options - per-factory configuration (session, token path, bootstrap status)
105
+ * @param deps - stateless capabilities (keyring, password, audit, log)
106
+ * @param options - per-factory configuration (session, token store, bootstrap status, limiter)
90
107
  * @returns route specs (not yet applied to Hono)
91
108
  */
92
109
  export declare const create_bootstrap_route_specs: (deps: RouteFactoryDeps, options: BootstrapRouteOptions) => Array<RouteSpec>;
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap_routes.d.ts","sourceRoot":"","sources":["../../src/lib/auth/bootstrap_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAGN,KAAK,uBAAuB,EAC5B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAyC,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAI9F,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAUlD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACrC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,8EAA8E;IAC9E,gBAAgB,EAAE,eAAe,CAAC;IAClC;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,EAAE,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E;;;;;;;;;;OAUG;IACH,yBAAyB,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,kFAAkF;IAClF,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACxD,+EAA+E;IAC/E,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,wBAAwB,EAC9B,SAAS;IAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,KACpC,OAAO,CAAC,eAAe,CAyBzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACxC,MAAM,gBAAgB,EACtB,SAAS,qBAAqB,KAC5B,KAAK,CAAC,SAAS,CA6HjB,CAAC"}
1
+ {"version":3,"file":"bootstrap_routes.d.ts","sourceRoot":"","sources":["../../src/lib/auth/bootstrap_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAGN,KAAK,uBAAuB,EAC5B,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAG7E,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAYlD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACrC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,0EAA0E;IAC1E,gBAAgB,EAAE,eAAe,CAAC;IAClC;;;;OAIG;IACH,WAAW,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACxC,mDAAmD;IACnD,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B;;;;;;;;;;;OAWG;IACH,yBAAyB,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,+EAA+E;IAC/E,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,wBAAwB,EAC9B,SAAS;IAAE,WAAW,EAAE,mBAAmB,GAAG,IAAI,CAAA;CAAE,KAClD,OAAO,CAAC,eAAe,CA0CzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACxC,MAAM,gBAAgB,EACtB,SAAS,qBAAqB,KAC5B,KAAK,CAAC,SAAS,CAmIjB,CAAC"}