@fuzdev/fuz_app 0.1.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 (457) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -0
  3. package/dist/actions/action_bridge.d.ts +65 -0
  4. package/dist/actions/action_bridge.d.ts.map +1 -0
  5. package/dist/actions/action_bridge.js +76 -0
  6. package/dist/actions/action_codegen.d.ts +97 -0
  7. package/dist/actions/action_codegen.d.ts.map +1 -0
  8. package/dist/actions/action_codegen.js +280 -0
  9. package/dist/actions/action_registry.d.ts +35 -0
  10. package/dist/actions/action_registry.d.ts.map +1 -0
  11. package/dist/actions/action_registry.js +83 -0
  12. package/dist/actions/action_spec.d.ts +169 -0
  13. package/dist/actions/action_spec.d.ts.map +1 -0
  14. package/dist/actions/action_spec.js +76 -0
  15. package/dist/auth/account_queries.d.ts +96 -0
  16. package/dist/auth/account_queries.d.ts.map +1 -0
  17. package/dist/auth/account_queries.js +172 -0
  18. package/dist/auth/account_routes.d.ts +86 -0
  19. package/dist/auth/account_routes.d.ts.map +1 -0
  20. package/dist/auth/account_routes.js +406 -0
  21. package/dist/auth/account_schema.d.ts +192 -0
  22. package/dist/auth/account_schema.d.ts.map +1 -0
  23. package/dist/auth/account_schema.js +105 -0
  24. package/dist/auth/admin_routes.d.ts +29 -0
  25. package/dist/auth/admin_routes.d.ts.map +1 -0
  26. package/dist/auth/admin_routes.js +193 -0
  27. package/dist/auth/api_token.d.ts +33 -0
  28. package/dist/auth/api_token.d.ts.map +1 -0
  29. package/dist/auth/api_token.js +36 -0
  30. package/dist/auth/api_token_queries.d.ts +80 -0
  31. package/dist/auth/api_token_queries.d.ts.map +1 -0
  32. package/dist/auth/api_token_queries.js +116 -0
  33. package/dist/auth/app_settings_queries.d.ts +33 -0
  34. package/dist/auth/app_settings_queries.d.ts.map +1 -0
  35. package/dist/auth/app_settings_queries.js +51 -0
  36. package/dist/auth/app_settings_routes.d.ts +27 -0
  37. package/dist/auth/app_settings_routes.d.ts.map +1 -0
  38. package/dist/auth/app_settings_routes.js +66 -0
  39. package/dist/auth/app_settings_schema.d.ts +35 -0
  40. package/dist/auth/app_settings_schema.d.ts.map +1 -0
  41. package/dist/auth/app_settings_schema.js +22 -0
  42. package/dist/auth/audit_log_queries.d.ts +90 -0
  43. package/dist/auth/audit_log_queries.d.ts.map +1 -0
  44. package/dist/auth/audit_log_queries.js +205 -0
  45. package/dist/auth/audit_log_routes.d.ts +33 -0
  46. package/dist/auth/audit_log_routes.d.ts.map +1 -0
  47. package/dist/auth/audit_log_routes.js +106 -0
  48. package/dist/auth/audit_log_schema.d.ts +259 -0
  49. package/dist/auth/audit_log_schema.d.ts.map +1 -0
  50. package/dist/auth/audit_log_schema.js +123 -0
  51. package/dist/auth/bearer_auth.d.ts +32 -0
  52. package/dist/auth/bearer_auth.d.ts.map +1 -0
  53. package/dist/auth/bearer_auth.js +90 -0
  54. package/dist/auth/bootstrap_account.d.ts +82 -0
  55. package/dist/auth/bootstrap_account.d.ts.map +1 -0
  56. package/dist/auth/bootstrap_account.js +97 -0
  57. package/dist/auth/bootstrap_routes.d.ts +74 -0
  58. package/dist/auth/bootstrap_routes.d.ts.map +1 -0
  59. package/dist/auth/bootstrap_routes.js +154 -0
  60. package/dist/auth/daemon_token.d.ts +49 -0
  61. package/dist/auth/daemon_token.d.ts.map +1 -0
  62. package/dist/auth/daemon_token.js +49 -0
  63. package/dist/auth/daemon_token_middleware.d.ts +93 -0
  64. package/dist/auth/daemon_token_middleware.d.ts.map +1 -0
  65. package/dist/auth/daemon_token_middleware.js +167 -0
  66. package/dist/auth/ddl.d.ts +27 -0
  67. package/dist/auth/ddl.d.ts.map +1 -0
  68. package/dist/auth/ddl.js +111 -0
  69. package/dist/auth/deps.d.ts +52 -0
  70. package/dist/auth/deps.d.ts.map +1 -0
  71. package/dist/auth/deps.js +10 -0
  72. package/dist/auth/invite_queries.d.ts +68 -0
  73. package/dist/auth/invite_queries.d.ts.map +1 -0
  74. package/dist/auth/invite_queries.js +105 -0
  75. package/dist/auth/invite_routes.d.ts +18 -0
  76. package/dist/auth/invite_routes.d.ts.map +1 -0
  77. package/dist/auth/invite_routes.js +129 -0
  78. package/dist/auth/invite_schema.d.ts +51 -0
  79. package/dist/auth/invite_schema.d.ts.map +1 -0
  80. package/dist/auth/invite_schema.js +25 -0
  81. package/dist/auth/keyring.d.ts +87 -0
  82. package/dist/auth/keyring.d.ts.map +1 -0
  83. package/dist/auth/keyring.js +142 -0
  84. package/dist/auth/middleware.d.ts +40 -0
  85. package/dist/auth/middleware.d.ts.map +1 -0
  86. package/dist/auth/middleware.js +64 -0
  87. package/dist/auth/migrations.d.ts +42 -0
  88. package/dist/auth/migrations.d.ts.map +1 -0
  89. package/dist/auth/migrations.js +79 -0
  90. package/dist/auth/password.d.ts +39 -0
  91. package/dist/auth/password.d.ts.map +1 -0
  92. package/dist/auth/password.js +25 -0
  93. package/dist/auth/password_argon2.d.ts +43 -0
  94. package/dist/auth/password_argon2.d.ts.map +1 -0
  95. package/dist/auth/password_argon2.js +76 -0
  96. package/dist/auth/permit_queries.d.ts +72 -0
  97. package/dist/auth/permit_queries.d.ts.map +1 -0
  98. package/dist/auth/permit_queries.js +116 -0
  99. package/dist/auth/request_context.d.ts +114 -0
  100. package/dist/auth/request_context.d.ts.map +1 -0
  101. package/dist/auth/request_context.js +176 -0
  102. package/dist/auth/require_keeper.d.ts +20 -0
  103. package/dist/auth/require_keeper.d.ts.map +1 -0
  104. package/dist/auth/require_keeper.js +35 -0
  105. package/dist/auth/role_schema.d.ts +69 -0
  106. package/dist/auth/role_schema.d.ts.map +1 -0
  107. package/dist/auth/role_schema.js +70 -0
  108. package/dist/auth/route_guards.d.ts +21 -0
  109. package/dist/auth/route_guards.d.ts.map +1 -0
  110. package/dist/auth/route_guards.js +32 -0
  111. package/dist/auth/session_cookie.d.ts +158 -0
  112. package/dist/auth/session_cookie.d.ts.map +1 -0
  113. package/dist/auth/session_cookie.js +135 -0
  114. package/dist/auth/session_lifecycle.d.ts +35 -0
  115. package/dist/auth/session_lifecycle.d.ts.map +1 -0
  116. package/dist/auth/session_lifecycle.js +27 -0
  117. package/dist/auth/session_middleware.d.ts +33 -0
  118. package/dist/auth/session_middleware.d.ts.map +1 -0
  119. package/dist/auth/session_middleware.js +62 -0
  120. package/dist/auth/session_queries.d.ts +135 -0
  121. package/dist/auth/session_queries.d.ts.map +1 -0
  122. package/dist/auth/session_queries.js +186 -0
  123. package/dist/auth/signup_routes.d.ts +32 -0
  124. package/dist/auth/signup_routes.d.ts.map +1 -0
  125. package/dist/auth/signup_routes.js +150 -0
  126. package/dist/cli/args.d.ts +48 -0
  127. package/dist/cli/args.d.ts.map +1 -0
  128. package/dist/cli/args.js +76 -0
  129. package/dist/cli/config.d.ts +48 -0
  130. package/dist/cli/config.d.ts.map +1 -0
  131. package/dist/cli/config.js +77 -0
  132. package/dist/cli/daemon.d.ts +82 -0
  133. package/dist/cli/daemon.d.ts.map +1 -0
  134. package/dist/cli/daemon.js +149 -0
  135. package/dist/cli/help.d.ts +85 -0
  136. package/dist/cli/help.d.ts.map +1 -0
  137. package/dist/cli/help.js +138 -0
  138. package/dist/cli/logger.d.ts +46 -0
  139. package/dist/cli/logger.d.ts.map +1 -0
  140. package/dist/cli/logger.js +48 -0
  141. package/dist/cli/util.d.ts +36 -0
  142. package/dist/cli/util.d.ts.map +1 -0
  143. package/dist/cli/util.js +50 -0
  144. package/dist/crypto.d.ts +13 -0
  145. package/dist/crypto.d.ts.map +1 -0
  146. package/dist/crypto.js +19 -0
  147. package/dist/db/assert_row.d.ts +18 -0
  148. package/dist/db/assert_row.d.ts.map +1 -0
  149. package/dist/db/assert_row.js +24 -0
  150. package/dist/db/create_db.d.ts +38 -0
  151. package/dist/db/create_db.d.ts.map +1 -0
  152. package/dist/db/create_db.js +57 -0
  153. package/dist/db/db.d.ts +97 -0
  154. package/dist/db/db.d.ts.map +1 -0
  155. package/dist/db/db.js +76 -0
  156. package/dist/db/db_pg.d.ts +21 -0
  157. package/dist/db/db_pg.d.ts.map +1 -0
  158. package/dist/db/db_pg.js +45 -0
  159. package/dist/db/db_pglite.d.ts +21 -0
  160. package/dist/db/db_pglite.d.ts.map +1 -0
  161. package/dist/db/db_pglite.js +28 -0
  162. package/dist/db/migrate.d.ts +67 -0
  163. package/dist/db/migrate.d.ts.map +1 -0
  164. package/dist/db/migrate.js +118 -0
  165. package/dist/db/pg_error.d.ts +16 -0
  166. package/dist/db/pg_error.d.ts.map +1 -0
  167. package/dist/db/pg_error.js +15 -0
  168. package/dist/db/query_deps.d.ts +14 -0
  169. package/dist/db/query_deps.d.ts.map +1 -0
  170. package/dist/db/query_deps.js +9 -0
  171. package/dist/db/sql_identifier.d.ts +27 -0
  172. package/dist/db/sql_identifier.d.ts.map +1 -0
  173. package/dist/db/sql_identifier.js +31 -0
  174. package/dist/db/status.d.ts +62 -0
  175. package/dist/db/status.d.ts.map +1 -0
  176. package/dist/db/status.js +116 -0
  177. package/dist/dev/setup.d.ts +159 -0
  178. package/dist/dev/setup.d.ts.map +1 -0
  179. package/dist/dev/setup.js +265 -0
  180. package/dist/env/dotenv.d.ts +25 -0
  181. package/dist/env/dotenv.d.ts.map +1 -0
  182. package/dist/env/dotenv.js +52 -0
  183. package/dist/env/load.d.ts +52 -0
  184. package/dist/env/load.d.ts.map +1 -0
  185. package/dist/env/load.js +79 -0
  186. package/dist/env/mask.d.ts +19 -0
  187. package/dist/env/mask.d.ts.map +1 -0
  188. package/dist/env/mask.js +26 -0
  189. package/dist/env/resolve.d.ts +126 -0
  190. package/dist/env/resolve.d.ts.map +1 -0
  191. package/dist/env/resolve.js +200 -0
  192. package/dist/hono_context.d.ts +48 -0
  193. package/dist/hono_context.d.ts.map +1 -0
  194. package/dist/hono_context.js +22 -0
  195. package/dist/http/common_routes.d.ts +52 -0
  196. package/dist/http/common_routes.d.ts.map +1 -0
  197. package/dist/http/common_routes.js +65 -0
  198. package/dist/http/db_routes.d.ts +57 -0
  199. package/dist/http/db_routes.d.ts.map +1 -0
  200. package/dist/http/db_routes.js +176 -0
  201. package/dist/http/error_schemas.d.ts +169 -0
  202. package/dist/http/error_schemas.d.ts.map +1 -0
  203. package/dist/http/error_schemas.js +178 -0
  204. package/dist/http/middleware_spec.d.ts +19 -0
  205. package/dist/http/middleware_spec.d.ts.map +1 -0
  206. package/dist/http/middleware_spec.js +9 -0
  207. package/dist/http/origin.d.ts +57 -0
  208. package/dist/http/origin.d.ts.map +1 -0
  209. package/dist/http/origin.js +207 -0
  210. package/dist/http/proxy.d.ts +112 -0
  211. package/dist/http/proxy.d.ts.map +1 -0
  212. package/dist/http/proxy.js +240 -0
  213. package/dist/http/route_spec.d.ts +197 -0
  214. package/dist/http/route_spec.d.ts.map +1 -0
  215. package/dist/http/route_spec.js +243 -0
  216. package/dist/http/schema_helpers.d.ts +64 -0
  217. package/dist/http/schema_helpers.d.ts.map +1 -0
  218. package/dist/http/schema_helpers.js +90 -0
  219. package/dist/http/surface.d.ts +132 -0
  220. package/dist/http/surface.d.ts.map +1 -0
  221. package/dist/http/surface.js +156 -0
  222. package/dist/http/surface_query.d.ts +77 -0
  223. package/dist/http/surface_query.d.ts.map +1 -0
  224. package/dist/http/surface_query.js +86 -0
  225. package/dist/rate_limiter.d.ts +94 -0
  226. package/dist/rate_limiter.d.ts.map +1 -0
  227. package/dist/rate_limiter.js +156 -0
  228. package/dist/realtime/sse.d.ts +80 -0
  229. package/dist/realtime/sse.d.ts.map +1 -0
  230. package/dist/realtime/sse.js +109 -0
  231. package/dist/realtime/sse_auth_guard.d.ts +93 -0
  232. package/dist/realtime/sse_auth_guard.d.ts.map +1 -0
  233. package/dist/realtime/sse_auth_guard.js +111 -0
  234. package/dist/realtime/subscriber_registry.d.ts +85 -0
  235. package/dist/realtime/subscriber_registry.d.ts.map +1 -0
  236. package/dist/realtime/subscriber_registry.js +108 -0
  237. package/dist/runtime/deno.d.ts +21 -0
  238. package/dist/runtime/deno.d.ts.map +1 -0
  239. package/dist/runtime/deno.js +83 -0
  240. package/dist/runtime/deps.d.ts +113 -0
  241. package/dist/runtime/deps.d.ts.map +1 -0
  242. package/dist/runtime/deps.js +10 -0
  243. package/dist/runtime/fs.d.ts +15 -0
  244. package/dist/runtime/fs.d.ts.map +1 -0
  245. package/dist/runtime/fs.js +17 -0
  246. package/dist/runtime/mock.d.ts +81 -0
  247. package/dist/runtime/mock.d.ts.map +1 -0
  248. package/dist/runtime/mock.js +195 -0
  249. package/dist/runtime/node.d.ts +17 -0
  250. package/dist/runtime/node.d.ts.map +1 -0
  251. package/dist/runtime/node.js +117 -0
  252. package/dist/schema_meta.d.ts +16 -0
  253. package/dist/schema_meta.d.ts.map +1 -0
  254. package/dist/schema_meta.js +9 -0
  255. package/dist/sensitivity.d.ts +15 -0
  256. package/dist/sensitivity.d.ts.map +1 -0
  257. package/dist/sensitivity.js +9 -0
  258. package/dist/server/app_backend.d.ts +74 -0
  259. package/dist/server/app_backend.d.ts.map +1 -0
  260. package/dist/server/app_backend.js +39 -0
  261. package/dist/server/app_server.d.ts +201 -0
  262. package/dist/server/app_server.d.ts.map +1 -0
  263. package/dist/server/app_server.js +266 -0
  264. package/dist/server/env.d.ts +68 -0
  265. package/dist/server/env.d.ts.map +1 -0
  266. package/dist/server/env.js +95 -0
  267. package/dist/server/startup.d.ts +22 -0
  268. package/dist/server/startup.d.ts.map +1 -0
  269. package/dist/server/startup.js +48 -0
  270. package/dist/server/static.d.ts +39 -0
  271. package/dist/server/static.d.ts.map +1 -0
  272. package/dist/server/static.js +38 -0
  273. package/dist/server/validate_nginx.d.ts +34 -0
  274. package/dist/server/validate_nginx.d.ts.map +1 -0
  275. package/dist/server/validate_nginx.js +118 -0
  276. package/dist/testing/CLAUDE.md +3 -0
  277. package/dist/testing/admin_integration.d.ts +45 -0
  278. package/dist/testing/admin_integration.d.ts.map +1 -0
  279. package/dist/testing/admin_integration.js +840 -0
  280. package/dist/testing/adversarial_404.d.ts +15 -0
  281. package/dist/testing/adversarial_404.d.ts.map +1 -0
  282. package/dist/testing/adversarial_404.js +118 -0
  283. package/dist/testing/adversarial_headers.d.ts +36 -0
  284. package/dist/testing/adversarial_headers.d.ts.map +1 -0
  285. package/dist/testing/adversarial_headers.js +128 -0
  286. package/dist/testing/adversarial_input.d.ts +56 -0
  287. package/dist/testing/adversarial_input.d.ts.map +1 -0
  288. package/dist/testing/adversarial_input.js +494 -0
  289. package/dist/testing/app_server.d.ts +169 -0
  290. package/dist/testing/app_server.d.ts.map +1 -0
  291. package/dist/testing/app_server.js +240 -0
  292. package/dist/testing/assert_dev_env.d.ts +10 -0
  293. package/dist/testing/assert_dev_env.d.ts.map +1 -0
  294. package/dist/testing/assert_dev_env.js +13 -0
  295. package/dist/testing/assertions.d.ts +61 -0
  296. package/dist/testing/assertions.d.ts.map +1 -0
  297. package/dist/testing/assertions.js +96 -0
  298. package/dist/testing/attack_surface.d.ts +63 -0
  299. package/dist/testing/attack_surface.d.ts.map +1 -0
  300. package/dist/testing/attack_surface.js +224 -0
  301. package/dist/testing/audit_completeness.d.ts +29 -0
  302. package/dist/testing/audit_completeness.d.ts.map +1 -0
  303. package/dist/testing/audit_completeness.js +410 -0
  304. package/dist/testing/auth_apps.d.ts +55 -0
  305. package/dist/testing/auth_apps.d.ts.map +1 -0
  306. package/dist/testing/auth_apps.js +122 -0
  307. package/dist/testing/data_exposure.d.ts +62 -0
  308. package/dist/testing/data_exposure.d.ts.map +1 -0
  309. package/dist/testing/data_exposure.js +297 -0
  310. package/dist/testing/db.d.ts +111 -0
  311. package/dist/testing/db.d.ts.map +1 -0
  312. package/dist/testing/db.js +258 -0
  313. package/dist/testing/entities.d.ts +21 -0
  314. package/dist/testing/entities.d.ts.map +1 -0
  315. package/dist/testing/entities.js +42 -0
  316. package/dist/testing/error_coverage.d.ts +78 -0
  317. package/dist/testing/error_coverage.d.ts.map +1 -0
  318. package/dist/testing/error_coverage.js +135 -0
  319. package/dist/testing/integration.d.ts +37 -0
  320. package/dist/testing/integration.d.ts.map +1 -0
  321. package/dist/testing/integration.js +1139 -0
  322. package/dist/testing/integration_helpers.d.ts +107 -0
  323. package/dist/testing/integration_helpers.d.ts.map +1 -0
  324. package/dist/testing/integration_helpers.js +246 -0
  325. package/dist/testing/middleware.d.ts +125 -0
  326. package/dist/testing/middleware.d.ts.map +1 -0
  327. package/dist/testing/middleware.js +210 -0
  328. package/dist/testing/rate_limiting.d.ts +43 -0
  329. package/dist/testing/rate_limiting.d.ts.map +1 -0
  330. package/dist/testing/rate_limiting.js +216 -0
  331. package/dist/testing/round_trip.d.ts +37 -0
  332. package/dist/testing/round_trip.d.ts.map +1 -0
  333. package/dist/testing/round_trip.js +128 -0
  334. package/dist/testing/schema_generators.d.ts +33 -0
  335. package/dist/testing/schema_generators.d.ts.map +1 -0
  336. package/dist/testing/schema_generators.js +137 -0
  337. package/dist/testing/standard.d.ts +49 -0
  338. package/dist/testing/standard.d.ts.map +1 -0
  339. package/dist/testing/standard.js +16 -0
  340. package/dist/testing/stubs.d.ts +96 -0
  341. package/dist/testing/stubs.d.ts.map +1 -0
  342. package/dist/testing/stubs.js +192 -0
  343. package/dist/testing/surface_invariants.d.ts +189 -0
  344. package/dist/testing/surface_invariants.d.ts.map +1 -0
  345. package/dist/testing/surface_invariants.js +450 -0
  346. package/dist/ui/AccountSessions.svelte +75 -0
  347. package/dist/ui/AccountSessions.svelte.d.ts +19 -0
  348. package/dist/ui/AccountSessions.svelte.d.ts.map +1 -0
  349. package/dist/ui/AdminAccounts.svelte +107 -0
  350. package/dist/ui/AdminAccounts.svelte.d.ts +19 -0
  351. package/dist/ui/AdminAccounts.svelte.d.ts.map +1 -0
  352. package/dist/ui/AdminAuditLog.svelte +144 -0
  353. package/dist/ui/AdminAuditLog.svelte.d.ts +4 -0
  354. package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -0
  355. package/dist/ui/AdminInvites.svelte +142 -0
  356. package/dist/ui/AdminInvites.svelte.d.ts +4 -0
  357. package/dist/ui/AdminInvites.svelte.d.ts.map +1 -0
  358. package/dist/ui/AdminOverview.svelte +337 -0
  359. package/dist/ui/AdminOverview.svelte.d.ts +4 -0
  360. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -0
  361. package/dist/ui/AdminPermitHistory.svelte +61 -0
  362. package/dist/ui/AdminPermitHistory.svelte.d.ts +19 -0
  363. package/dist/ui/AdminPermitHistory.svelte.d.ts.map +1 -0
  364. package/dist/ui/AdminSessions.svelte +85 -0
  365. package/dist/ui/AdminSessions.svelte.d.ts +19 -0
  366. package/dist/ui/AdminSessions.svelte.d.ts.map +1 -0
  367. package/dist/ui/AdminSettings.svelte +32 -0
  368. package/dist/ui/AdminSettings.svelte.d.ts +19 -0
  369. package/dist/ui/AdminSettings.svelte.d.ts.map +1 -0
  370. package/dist/ui/AdminSurface.svelte +42 -0
  371. package/dist/ui/AdminSurface.svelte.d.ts +4 -0
  372. package/dist/ui/AdminSurface.svelte.d.ts.map +1 -0
  373. package/dist/ui/AppShell.svelte +93 -0
  374. package/dist/ui/AppShell.svelte.d.ts +20 -0
  375. package/dist/ui/AppShell.svelte.d.ts.map +1 -0
  376. package/dist/ui/BootstrapForm.svelte +105 -0
  377. package/dist/ui/BootstrapForm.svelte.d.ts +4 -0
  378. package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -0
  379. package/dist/ui/ColumnLayout.svelte +46 -0
  380. package/dist/ui/ColumnLayout.svelte.d.ts +11 -0
  381. package/dist/ui/ColumnLayout.svelte.d.ts.map +1 -0
  382. package/dist/ui/ConfirmButton.svelte +125 -0
  383. package/dist/ui/ConfirmButton.svelte.d.ts +54 -0
  384. package/dist/ui/ConfirmButton.svelte.d.ts.map +1 -0
  385. package/dist/ui/Datatable.svelte +185 -0
  386. package/dist/ui/Datatable.svelte.d.ts +35 -0
  387. package/dist/ui/Datatable.svelte.d.ts.map +1 -0
  388. package/dist/ui/LoginForm.svelte +82 -0
  389. package/dist/ui/LoginForm.svelte.d.ts +8 -0
  390. package/dist/ui/LoginForm.svelte.d.ts.map +1 -0
  391. package/dist/ui/LogoutButton.svelte +36 -0
  392. package/dist/ui/LogoutButton.svelte.d.ts +10 -0
  393. package/dist/ui/LogoutButton.svelte.d.ts.map +1 -0
  394. package/dist/ui/MenuLink.svelte +35 -0
  395. package/dist/ui/MenuLink.svelte.d.ts +12 -0
  396. package/dist/ui/MenuLink.svelte.d.ts.map +1 -0
  397. package/dist/ui/OpenSignupToggle.svelte +36 -0
  398. package/dist/ui/OpenSignupToggle.svelte.d.ts +19 -0
  399. package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -0
  400. package/dist/ui/PopoverButton.svelte +136 -0
  401. package/dist/ui/PopoverButton.svelte.d.ts +63 -0
  402. package/dist/ui/PopoverButton.svelte.d.ts.map +1 -0
  403. package/dist/ui/SignupForm.svelte +117 -0
  404. package/dist/ui/SignupForm.svelte.d.ts +7 -0
  405. package/dist/ui/SignupForm.svelte.d.ts.map +1 -0
  406. package/dist/ui/SurfaceExplorer.svelte +287 -0
  407. package/dist/ui/SurfaceExplorer.svelte.d.ts +8 -0
  408. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -0
  409. package/dist/ui/account_sessions_state.svelte.d.ts +15 -0
  410. package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -0
  411. package/dist/ui/account_sessions_state.svelte.js +45 -0
  412. package/dist/ui/admin_accounts_state.svelte.d.ts +19 -0
  413. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -0
  414. package/dist/ui/admin_accounts_state.svelte.js +65 -0
  415. package/dist/ui/admin_invites_state.svelte.d.ts +19 -0
  416. package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -0
  417. package/dist/ui/admin_invites_state.svelte.js +71 -0
  418. package/dist/ui/admin_sessions_state.svelte.d.ts +18 -0
  419. package/dist/ui/admin_sessions_state.svelte.d.ts.map +1 -0
  420. package/dist/ui/admin_sessions_state.svelte.js +62 -0
  421. package/dist/ui/app_settings_state.svelte.d.ts +14 -0
  422. package/dist/ui/app_settings_state.svelte.d.ts.map +1 -0
  423. package/dist/ui/app_settings_state.svelte.js +44 -0
  424. package/dist/ui/audit_log_state.svelte.d.ts +40 -0
  425. package/dist/ui/audit_log_state.svelte.d.ts.map +1 -0
  426. package/dist/ui/audit_log_state.svelte.js +153 -0
  427. package/dist/ui/auth_state.svelte.d.ts +85 -0
  428. package/dist/ui/auth_state.svelte.d.ts.map +1 -0
  429. package/dist/ui/auth_state.svelte.js +238 -0
  430. package/dist/ui/datatable.d.ts +25 -0
  431. package/dist/ui/datatable.d.ts.map +1 -0
  432. package/dist/ui/datatable.js +9 -0
  433. package/dist/ui/enter_advance.d.ts +13 -0
  434. package/dist/ui/enter_advance.d.ts.map +1 -0
  435. package/dist/ui/enter_advance.js +30 -0
  436. package/dist/ui/loadable.svelte.d.ts +55 -0
  437. package/dist/ui/loadable.svelte.d.ts.map +1 -0
  438. package/dist/ui/loadable.svelte.js +75 -0
  439. package/dist/ui/popover.svelte.d.ts +137 -0
  440. package/dist/ui/popover.svelte.d.ts.map +1 -0
  441. package/dist/ui/popover.svelte.js +288 -0
  442. package/dist/ui/position_helpers.d.ts +27 -0
  443. package/dist/ui/position_helpers.d.ts.map +1 -0
  444. package/dist/ui/position_helpers.js +81 -0
  445. package/dist/ui/sidebar_state.svelte.d.ts +30 -0
  446. package/dist/ui/sidebar_state.svelte.d.ts.map +1 -0
  447. package/dist/ui/sidebar_state.svelte.js +39 -0
  448. package/dist/ui/table_state.svelte.d.ts +63 -0
  449. package/dist/ui/table_state.svelte.d.ts.map +1 -0
  450. package/dist/ui/table_state.svelte.js +117 -0
  451. package/dist/ui/ui_fetch.d.ts +29 -0
  452. package/dist/ui/ui_fetch.d.ts.map +1 -0
  453. package/dist/ui/ui_fetch.js +37 -0
  454. package/dist/ui/ui_format.d.ts +63 -0
  455. package/dist/ui/ui_format.d.ts.map +1 -0
  456. package/dist/ui/ui_format.js +196 -0
  457. package/package.json +121 -0
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Trusted proxy configuration and middleware.
3
+ *
4
+ * Resolves the client IP from `X-Forwarded-For` only when the TCP connection
5
+ * originates from a configured trusted proxy. Without this middleware,
6
+ * `get_client_ip` returns `'unknown'`.
7
+ *
8
+ * @module
9
+ */
10
+ import type { Context, MiddlewareHandler } from 'hono';
11
+ import type { Logger } from '@fuzdev/fuz_util/log.js';
12
+ import type { MiddlewareSpec } from './middleware_spec.js';
13
+ /**
14
+ * Normalize an IP address for consistent matching and storage.
15
+ *
16
+ * - Strips `::ffff:` prefix from IPv4-mapped IPv6 addresses
17
+ * (e.g. `::ffff:127.0.0.1` → `127.0.0.1`)
18
+ * - Lowercases for case-insensitive IPv6 comparison
19
+ * - Idempotent: calling twice produces the same result
20
+ * - Safe on non-IP strings: `normalize_ip('unknown')` returns `'unknown'`
21
+ *
22
+ * @param ip - IP address string to normalize
23
+ */
24
+ export declare const normalize_ip: (ip: string) => string;
25
+ /**
26
+ * Configuration for trusted proxy resolution.
27
+ */
28
+ export interface ProxyOptions {
29
+ /** Trusted proxy IPs or CIDR ranges (e.g. `'127.0.0.1'`, `'10.0.0.0/8'`, `'::1'`). */
30
+ trusted_proxies: Array<string>;
31
+ /** Extract the raw TCP connection IP from the Hono context. */
32
+ get_connection_ip: (c: Context) => string | undefined;
33
+ /** Optional logger for proxy resolution diagnostics. */
34
+ log?: Logger;
35
+ }
36
+ /**
37
+ * A parsed proxy entry — either an exact IP or a CIDR range.
38
+ */
39
+ export type ParsedProxy = {
40
+ type: 'ip';
41
+ address: string;
42
+ } | {
43
+ type: 'cidr';
44
+ network: bigint;
45
+ prefix: number;
46
+ address_type: 'IPv4' | 'IPv6';
47
+ };
48
+ /**
49
+ * Parse a trusted proxy entry string into a structured form.
50
+ *
51
+ * Accepts plain IPs (`'127.0.0.1'`, `'::1'`) and CIDR notation (`'10.0.0.0/8'`, `'fe80::/10'`).
52
+ * Plain IPs are normalized (lowercase, IPv4-mapped IPv6 stripped) and validated.
53
+ * CIDR prefixes are validated against address family bounds.
54
+ *
55
+ * @param entry - IP address or CIDR notation
56
+ * @throws on invalid IP, invalid CIDR network, or NaN/negative/over-range prefix
57
+ */
58
+ export declare const parse_proxy_entry: (entry: string) => ParsedProxy;
59
+ /**
60
+ * Check whether `ip` matches any entry in the trusted proxy list.
61
+ *
62
+ * Normalizes `ip` before matching (lowercase, IPv4-mapped IPv6 stripped).
63
+ *
64
+ * @param ip - the IP address to check
65
+ * @param proxies - parsed proxy entries
66
+ */
67
+ export declare const is_trusted_ip: (ip: string, proxies: Array<ParsedProxy>) => boolean;
68
+ /**
69
+ * Resolve the real client IP from an `X-Forwarded-For` header value.
70
+ *
71
+ * Walks right-to-left, skipping trusted proxy entries. The first
72
+ * non-trusted entry is the client IP. If all entries are trusted,
73
+ * returns the leftmost entry. All entries are normalized before
74
+ * matching and in the returned value.
75
+ *
76
+ * @param forwarded_for - the `X-Forwarded-For` header value
77
+ * @param proxies - parsed trusted proxy entries
78
+ * @returns the normalized client IP, or `undefined` if the header is empty
79
+ */
80
+ export declare const resolve_client_ip: (forwarded_for: string, proxies: Array<ParsedProxy>) => string | undefined;
81
+ /**
82
+ * Create a Hono middleware that resolves the client IP from trusted proxies.
83
+ *
84
+ * Sets `client_ip` on the Hono context for downstream use by `get_client_ip`.
85
+ * All client IPs are normalized (lowercase, IPv4-mapped IPv6 stripped).
86
+ *
87
+ * Resolution logic:
88
+ * 1. No `X-Forwarded-For` → use connection IP directly.
89
+ * 2. `X-Forwarded-For` present but connection is untrusted → ignore header
90
+ * (spoofed by a direct attacker), use connection IP.
91
+ * 3. `X-Forwarded-For` present and connection is trusted → walk header
92
+ * right-to-left, strip trusted entries, use first untrusted entry.
93
+ *
94
+ * @param options - trusted proxy configuration
95
+ */
96
+ export declare const create_proxy_middleware: (options: ProxyOptions) => MiddlewareHandler;
97
+ /**
98
+ * Create a middleware spec for trusted proxy resolution.
99
+ *
100
+ * Apply before auth middleware so `client_ip` is available for rate limiting.
101
+ *
102
+ * @param options - trusted proxy configuration
103
+ */
104
+ export declare const create_proxy_middleware_spec: (options: ProxyOptions) => MiddlewareSpec;
105
+ /**
106
+ * Read the resolved client IP from the Hono context.
107
+ *
108
+ * Returns `'unknown'` if the proxy middleware has not run or no IP is available.
109
+ * Set by `create_proxy_middleware`.
110
+ */
111
+ export declare const get_client_ip: (c: Context) => string;
112
+ //# sourceMappingURL=proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/proxy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAE,iBAAiB,EAAC,MAAM,MAAM,CAAC;AAErD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,sBAAsB,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,KAAG,MAQzC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,sFAAsF;IACtF,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,+DAA+D;IAC/D,iBAAiB,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;IACtD,wDAAwD;IACxD,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GACpB;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,GAC7B;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,CAAC;AAElF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,WA6CjD,CAAC;AAiBF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,IAAI,MAAM,EAAE,SAAS,KAAK,CAAC,WAAW,CAAC,KAAG,OAqBvE,CAAC;AAQF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,GAC7B,eAAe,MAAM,EACrB,SAAS,KAAK,CAAC,WAAW,CAAC,KACzB,MAAM,GAAG,SAiBX,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,YAAY,KAAG,iBAyC/D,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,YAAY,KAAG,cAInE,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,GAAG,OAAO,KAAG,MAAyC,CAAC"}
@@ -0,0 +1,240 @@
1
+ /**
2
+ * Trusted proxy configuration and middleware.
3
+ *
4
+ * Resolves the client IP from `X-Forwarded-For` only when the TCP connection
5
+ * originates from a configured trusted proxy. Without this middleware,
6
+ * `get_client_ip` returns `'unknown'`.
7
+ *
8
+ * @module
9
+ */
10
+ import { convertIPv4ToBinary, convertIPv6ToBinary, distinctRemoteAddr } from 'hono/utils/ipaddr';
11
+ /**
12
+ * Normalize an IP address for consistent matching and storage.
13
+ *
14
+ * - Strips `::ffff:` prefix from IPv4-mapped IPv6 addresses
15
+ * (e.g. `::ffff:127.0.0.1` → `127.0.0.1`)
16
+ * - Lowercases for case-insensitive IPv6 comparison
17
+ * - Idempotent: calling twice produces the same result
18
+ * - Safe on non-IP strings: `normalize_ip('unknown')` returns `'unknown'`
19
+ *
20
+ * @param ip - IP address string to normalize
21
+ */
22
+ export const normalize_ip = (ip) => {
23
+ const lowered = ip.toLowerCase();
24
+ // Strip ::ffff: prefix only when remainder contains a dot (IPv4-mapped IPv6).
25
+ // This distinguishes ::ffff:127.0.0.1 (IPv4-mapped) from ::ffff:1 (pure IPv6).
26
+ if (lowered.startsWith('::ffff:') && lowered.substring(7).includes('.')) {
27
+ return lowered.substring(7);
28
+ }
29
+ return lowered;
30
+ };
31
+ /**
32
+ * Parse a trusted proxy entry string into a structured form.
33
+ *
34
+ * Accepts plain IPs (`'127.0.0.1'`, `'::1'`) and CIDR notation (`'10.0.0.0/8'`, `'fe80::/10'`).
35
+ * Plain IPs are normalized (lowercase, IPv4-mapped IPv6 stripped) and validated.
36
+ * CIDR prefixes are validated against address family bounds.
37
+ *
38
+ * @param entry - IP address or CIDR notation
39
+ * @throws on invalid IP, invalid CIDR network, or NaN/negative/over-range prefix
40
+ */
41
+ export const parse_proxy_entry = (entry) => {
42
+ const slash_index = entry.indexOf('/');
43
+ if (slash_index === -1) {
44
+ const normalized = normalize_ip(entry);
45
+ if (!distinctRemoteAddr(normalized)) {
46
+ throw new Error(`Invalid proxy IP: ${entry}`);
47
+ }
48
+ return { type: 'ip', address: normalized };
49
+ }
50
+ const network_str = entry.substring(0, slash_index);
51
+ const prefix_str = entry.substring(slash_index + 1);
52
+ const prefix = parseInt(prefix_str, 10);
53
+ if (Number.isNaN(prefix)) {
54
+ throw new Error(`Invalid CIDR prefix (not a number): ${entry}`);
55
+ }
56
+ if (prefix < 0) {
57
+ throw new Error(`Invalid CIDR prefix (negative): ${entry}`);
58
+ }
59
+ if (String(prefix) !== prefix_str) {
60
+ throw new Error(`Invalid CIDR prefix (not an integer): ${entry}`);
61
+ }
62
+ const address_type = distinctRemoteAddr(network_str);
63
+ if (address_type === 'IPv4') {
64
+ if (prefix > 32) {
65
+ throw new Error(`Invalid CIDR prefix for IPv4 (max 32): ${entry}`);
66
+ }
67
+ const network = convertIPv4ToBinary(network_str);
68
+ const host_mask = prefix === 32 ? 0n : (1n << BigInt(32 - prefix)) - 1n;
69
+ if ((network & host_mask) !== 0n) {
70
+ throw new Error(`Non-network-aligned CIDR (host bits set): ${entry}`);
71
+ }
72
+ return { type: 'cidr', network, prefix, address_type };
73
+ }
74
+ if (address_type === 'IPv6') {
75
+ if (prefix > 128) {
76
+ throw new Error(`Invalid CIDR prefix for IPv6 (max 128): ${entry}`);
77
+ }
78
+ const network = convertIPv6ToBinary(network_str);
79
+ const host_mask = prefix === 128 ? 0n : (1n << BigInt(128 - prefix)) - 1n;
80
+ if ((network & host_mask) !== 0n) {
81
+ throw new Error(`Non-network-aligned CIDR (host bits set): ${entry}`);
82
+ }
83
+ return { type: 'cidr', network, prefix, address_type };
84
+ }
85
+ throw new Error(`Invalid proxy CIDR: ${entry}`);
86
+ };
87
+ /**
88
+ * Check whether an IP falls within a CIDR range.
89
+ *
90
+ * Compares the top `prefix` bits by right-shifting both values.
91
+ */
92
+ const cidr_contains = (ip_binary, network, prefix, total_bits) => {
93
+ const shift = BigInt(total_bits - prefix);
94
+ return ip_binary >> shift === network >> shift;
95
+ };
96
+ /**
97
+ * Check whether `ip` matches any entry in the trusted proxy list.
98
+ *
99
+ * Normalizes `ip` before matching (lowercase, IPv4-mapped IPv6 stripped).
100
+ *
101
+ * @param ip - the IP address to check
102
+ * @param proxies - parsed proxy entries
103
+ */
104
+ export const is_trusted_ip = (ip, proxies) => {
105
+ const normalized = normalize_ip(ip);
106
+ const address_type = distinctRemoteAddr(normalized);
107
+ if (!address_type)
108
+ return false;
109
+ for (const proxy of proxies) {
110
+ if (proxy.type === 'ip') {
111
+ if (proxy.address === normalized)
112
+ return true;
113
+ continue;
114
+ }
115
+ // CIDR match — skip mismatched address families
116
+ if (proxy.address_type !== address_type)
117
+ continue;
118
+ if (address_type === 'IPv4') {
119
+ if (cidr_contains(convertIPv4ToBinary(normalized), proxy.network, proxy.prefix, 32))
120
+ return true;
121
+ }
122
+ else {
123
+ if (cidr_contains(convertIPv6ToBinary(normalized), proxy.network, proxy.prefix, 128))
124
+ return true;
125
+ }
126
+ }
127
+ return false;
128
+ };
129
+ // NOTE: some non-standard proxies include ports in XFF entries (e.g.
130
+ // 203.0.113.1:8080). The entry fails distinctRemoteAddr and is treated as
131
+ // untrusted (safe default), but rate limiting keys on the port-suffixed
132
+ // string instead of the bare IP. Low risk — nginx and cloud LBs don't
133
+ // include ports.
134
+ /**
135
+ * Resolve the real client IP from an `X-Forwarded-For` header value.
136
+ *
137
+ * Walks right-to-left, skipping trusted proxy entries. The first
138
+ * non-trusted entry is the client IP. If all entries are trusted,
139
+ * returns the leftmost entry. All entries are normalized before
140
+ * matching and in the returned value.
141
+ *
142
+ * @param forwarded_for - the `X-Forwarded-For` header value
143
+ * @param proxies - parsed trusted proxy entries
144
+ * @returns the normalized client IP, or `undefined` if the header is empty
145
+ */
146
+ export const resolve_client_ip = (forwarded_for, proxies) => {
147
+ const entries = [];
148
+ for (const raw of forwarded_for.split(',')) {
149
+ const trimmed = raw.trim();
150
+ if (trimmed)
151
+ entries.push(normalize_ip(trimmed));
152
+ }
153
+ if (entries.length === 0)
154
+ return undefined;
155
+ // Walk from right to left, skip trusted proxies
156
+ for (let i = entries.length - 1; i >= 0; i--) {
157
+ const entry = entries[i];
158
+ if (!is_trusted_ip(entry, proxies)) {
159
+ return entry;
160
+ }
161
+ }
162
+ // All entries are trusted — return leftmost (edge case, likely misconfigured)
163
+ return entries[0];
164
+ };
165
+ /**
166
+ * Create a Hono middleware that resolves the client IP from trusted proxies.
167
+ *
168
+ * Sets `client_ip` on the Hono context for downstream use by `get_client_ip`.
169
+ * All client IPs are normalized (lowercase, IPv4-mapped IPv6 stripped).
170
+ *
171
+ * Resolution logic:
172
+ * 1. No `X-Forwarded-For` → use connection IP directly.
173
+ * 2. `X-Forwarded-For` present but connection is untrusted → ignore header
174
+ * (spoofed by a direct attacker), use connection IP.
175
+ * 3. `X-Forwarded-For` present and connection is trusted → walk header
176
+ * right-to-left, strip trusted entries, use first untrusted entry.
177
+ *
178
+ * @param options - trusted proxy configuration
179
+ */
180
+ export const create_proxy_middleware = (options) => {
181
+ const parsed_proxies = options.trusted_proxies.map(parse_proxy_entry);
182
+ const { log } = options;
183
+ return async (c, next) => {
184
+ const connection_ip = options.get_connection_ip(c);
185
+ const forwarded_for = c.req.header('x-forwarded-for');
186
+ let client_ip;
187
+ if (!forwarded_for) {
188
+ // No proxy header — use connection IP directly
189
+ client_ip = connection_ip ? normalize_ip(connection_ip) : 'unknown';
190
+ if (!connection_ip) {
191
+ log?.warn('Connection IP is undefined — client_ip set to unknown');
192
+ }
193
+ }
194
+ else if (!connection_ip || !is_trusted_ip(connection_ip, parsed_proxies)) {
195
+ // Header present but connection is untrusted — ignore spoofed header
196
+ client_ip = connection_ip ? normalize_ip(connection_ip) : 'unknown';
197
+ if (connection_ip) {
198
+ log?.debug('XFF ignored — connection from untrusted IP:', connection_ip);
199
+ }
200
+ else {
201
+ log?.warn('Connection IP is undefined with XFF present — client_ip set to unknown');
202
+ }
203
+ }
204
+ else {
205
+ // Connection from a trusted proxy — resolve from header
206
+ const resolved = resolve_client_ip(forwarded_for, parsed_proxies);
207
+ if (!resolved) {
208
+ client_ip = normalize_ip(connection_ip);
209
+ }
210
+ else {
211
+ client_ip = resolved;
212
+ // all XFF entries were trusted — likely misconfiguration
213
+ if (is_trusted_ip(resolved, parsed_proxies)) {
214
+ log?.warn('All XFF entries are trusted — possible misconfiguration:', forwarded_for);
215
+ }
216
+ }
217
+ }
218
+ c.set('client_ip', client_ip);
219
+ await next();
220
+ };
221
+ };
222
+ /**
223
+ * Create a middleware spec for trusted proxy resolution.
224
+ *
225
+ * Apply before auth middleware so `client_ip` is available for rate limiting.
226
+ *
227
+ * @param options - trusted proxy configuration
228
+ */
229
+ export const create_proxy_middleware_spec = (options) => ({
230
+ name: 'trusted_proxy',
231
+ path: '*',
232
+ handler: create_proxy_middleware(options),
233
+ });
234
+ /**
235
+ * Read the resolved client IP from the Hono context.
236
+ *
237
+ * Returns `'unknown'` if the proxy middleware has not run or no IP is available.
238
+ * Set by `create_proxy_middleware`.
239
+ */
240
+ export const get_client_ip = (c) => c.get('client_ip') || 'unknown';
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Introspectable route spec system for Hono apps.
3
+ *
4
+ * Routes are defined as data (method, path, auth, input/output schemas, handler),
5
+ * then applied to Hono. The attack surface is generated from the specs —
6
+ * always accurate, always complete.
7
+ *
8
+ * Input/output schemas align with SAES `ActionSpec` conventions:
9
+ * - `input`: Zod schema for the request body (`z.null()` for no body)
10
+ * - `output`: Zod schema for the success response body
11
+ * - `z.strictObject()` for inputs (reject unknown keys)
12
+ *
13
+ * @module
14
+ */
15
+ import type { Context, Hono, MiddlewareHandler } from 'hono';
16
+ import type { z } from 'zod';
17
+ import type { Logger } from '@fuzdev/fuz_util/log.js';
18
+ import type { Db } from '../db/db.js';
19
+ import { type RouteErrorSchemas, type RateLimitKey } from './error_schemas.js';
20
+ import type { MiddlewareSpec } from './middleware_spec.js';
21
+ /**
22
+ * Auth requirement for a route — `none`, `authenticated`, a specific role, or `keeper`.
23
+ *
24
+ * `{type: 'none'}` means the route is open to all clients — including non-browser
25
+ * callers (CLI, API tokens, scripts). No session or auth middleware guards are applied.
26
+ */
27
+ export type RouteAuth = {
28
+ type: 'none';
29
+ } | {
30
+ type: 'authenticated';
31
+ } | {
32
+ type: 'role';
33
+ role: string;
34
+ } | {
35
+ type: 'keeper';
36
+ };
37
+ /**
38
+ * Resolves a `RouteAuth` to middleware guard handlers.
39
+ *
40
+ * Injected into `apply_route_specs` to decouple route registration
41
+ * from auth-specific middleware. See `fuz_auth_guard_resolver` in
42
+ * `auth/route_guards.ts` for the standard implementation.
43
+ */
44
+ export type AuthGuardResolver = (auth: RouteAuth) => Array<MiddlewareHandler>;
45
+ /** HTTP methods supported by route specs. */
46
+ export type RouteMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
47
+ /**
48
+ * Per-request deps provided by the framework to route handlers.
49
+ *
50
+ * `db` is transaction-scoped for mutation routes and pool-level for reads.
51
+ * `background_db` is always pool-level — use it for fire-and-forget effects
52
+ * that must outlive the transaction.
53
+ */
54
+ export interface RouteContext {
55
+ /** Transaction-scoped for mutations, pool-level for reads. */
56
+ db: Db;
57
+ /** Always pool-level — for fire-and-forget effects that outlive the transaction. */
58
+ background_db: Db;
59
+ /** Fire-and-forget side effects — push here for post-response flushing. */
60
+ pending_effects: Array<Promise<void>>;
61
+ }
62
+ /**
63
+ * Route handler function — receives the Hono context and a `RouteContext`
64
+ * with per-request deps (db, background_db, pending_effects).
65
+ *
66
+ * TypeScript allows fewer params, so handlers that don't need `route`
67
+ * can use `(c) => ...` without changes.
68
+ */
69
+ export type RouteHandler = (c: Context, route: RouteContext) => Response | Promise<Response>;
70
+ /**
71
+ * A single route definition — the unit of the surface map.
72
+ *
73
+ * `input` and `output` schemas align with SAES `ActionSpec` naming.
74
+ * Use `z.null()` for routes with no request body (GET, DELETE without body).
75
+ */
76
+ export interface RouteSpec {
77
+ method: RouteMethod;
78
+ path: string;
79
+ /**
80
+ * Auth requirement for this route.
81
+ *
82
+ * `{type: 'none'}` means the route is open to all clients including non-browser
83
+ * callers (CLI, scripts) — no auth guards are applied.
84
+ */
85
+ auth: RouteAuth;
86
+ handler: RouteHandler;
87
+ description: string;
88
+ /**
89
+ * URL path parameter schema. Use `z.strictObject()` with string fields matching `:param` segments.
90
+ *
91
+ * TODO @action-system-review `params` is HTTP-specific — SAES encodes everything in
92
+ * `input`. When saes-rpc lands, this may move to `ActionRouteOptions` only.
93
+ */
94
+ params?: z.ZodObject;
95
+ /** URL query parameter schema. Use `z.strictObject()` with string fields. */
96
+ query?: z.ZodObject;
97
+ /** Request body schema. Use `z.null()` for routes with no body. */
98
+ input: z.ZodType;
99
+ /** Success response body schema. */
100
+ output: z.ZodType;
101
+ /**
102
+ * Rate limit key type — declares what this route's rate limiter is keyed on.
103
+ *
104
+ * When set, 429 (`RateLimitError`) is auto-derived in `derive_error_schemas`.
105
+ * The actual `RateLimiter` instance is still wired imperatively in the handler —
106
+ * this field is metadata for surface introspection and policy invariants.
107
+ */
108
+ rate_limit?: RateLimitKey;
109
+ /**
110
+ * Handler-specific error response schemas keyed by HTTP status code.
111
+ *
112
+ * Middleware errors (auth 401/403, validation 400, rate limit 429) are
113
+ * auto-derived from `auth`, `input`, and `rate_limit`. Declare handler-specific
114
+ * errors here (e.g., 404 for not-found, 409 for conflicts).
115
+ *
116
+ * Explicit entries override auto-derived ones for the same status code.
117
+ */
118
+ errors?: RouteErrorSchemas;
119
+ /**
120
+ * Whether to wrap the handler in a database transaction.
121
+ *
122
+ * When omitted, defaults are derived from the HTTP method:
123
+ * - `GET` → `false` (read-only, no transaction)
124
+ * - All others (`POST`, `PUT`, `DELETE`, `PATCH`) → `true`
125
+ *
126
+ * Set explicitly to override the default (e.g., `false` for a POST
127
+ * that manages its own transaction like signup).
128
+ */
129
+ transaction?: boolean;
130
+ }
131
+ /**
132
+ * Get validated input from the Hono context.
133
+ *
134
+ * Call this in route handlers after the input validation middleware has run.
135
+ * The type parameter should match the route's `input` schema.
136
+ *
137
+ * @returns the validated request body
138
+ */
139
+ export declare const get_route_input: <T>(c: Context) => T;
140
+ /**
141
+ * Get validated URL path params from the Hono context.
142
+ *
143
+ * Call this in route handlers after the params validation middleware has run.
144
+ * The type parameter should match the route's `params` schema.
145
+ *
146
+ * TODO @action-system-review Make typesafe — derive `T` from the `params` schema on the
147
+ * route spec so the type parameter isn't manually specified.
148
+ *
149
+ * @returns the validated path parameters
150
+ */
151
+ export declare const get_route_params: <T>(c: Context) => T;
152
+ /**
153
+ * Get validated URL query params from the Hono context.
154
+ *
155
+ * Call this in route handlers after the query validation middleware has run.
156
+ * The type parameter should match the route's `query` schema.
157
+ *
158
+ * @returns the validated query parameters
159
+ */
160
+ export declare const get_route_query: <T>(c: Context) => T;
161
+ /**
162
+ * Apply named middleware specs to a Hono app.
163
+ *
164
+ * @param app - the Hono app
165
+ * @param specs - middleware specs to apply
166
+ * @mutates `app`
167
+ */
168
+ export declare const apply_middleware_specs: (app: Hono, specs: Array<MiddlewareSpec>) => void;
169
+ /**
170
+ * Apply route specs to a Hono app.
171
+ *
172
+ * For each spec: resolves auth to guards via the provided resolver,
173
+ * adds input validation middleware (for routes with non-null input schemas),
174
+ * wraps handler with DEV-only output and error validation, and registers the route.
175
+ *
176
+ * Each handler receives a `RouteContext` with:
177
+ * - `db`: transaction-scoped (for non-GET) or pool-level (for GET)
178
+ * - `background_db`: always pool-level
179
+ * - `pending_effects`: fire-and-forget effect queue
180
+ *
181
+ * @param app - the Hono app
182
+ * @param specs - route specs to apply
183
+ * @param resolve_auth_guards - maps `RouteAuth` to middleware — use `fuz_auth_guard_resolver` from `auth/route_guards.ts`
184
+ * @param log - the logger instance
185
+ * @param db - database instance for transaction wrapping and `RouteContext`
186
+ * @mutates `app`
187
+ */
188
+ export declare const apply_route_specs: (app: Hono, specs: Array<RouteSpec>, resolve_auth_guards: AuthGuardResolver, log: Logger, db: Db) => void;
189
+ /**
190
+ * Prepend a prefix to all route spec paths.
191
+ *
192
+ * @param prefix - the path prefix (e.g. `/api/account`)
193
+ * @param specs - route specs to prefix
194
+ * @returns new array of specs with prefixed paths
195
+ */
196
+ export declare const prefix_route_specs: (prefix: string, specs: Array<RouteSpec>) => Array<RouteSpec>;
197
+ //# sourceMappingURL=route_spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route_spec.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/route_spec.ts"],"names":[],"mappings":"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"}