@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,33 @@
1
+ import './assert_dev_env.js';
2
+ /**
3
+ * Schema-driven value generation helpers for testing.
4
+ *
5
+ * Walks Zod schemas to generate valid values for route params, request bodies,
6
+ * and URL paths. Used by adversarial input, adversarial 404, and round-trip
7
+ * validation test suites.
8
+ *
9
+ * @module
10
+ */
11
+ import { z } from 'zod';
12
+ import { type ZodFieldInfo } from '@fuzdev/fuz_util/zod.js';
13
+ /**
14
+ * Detect format constraints on a field by converting to JSON Schema.
15
+ * Returns format string (e.g. 'uuid', 'email') or null.
16
+ */
17
+ export declare const detect_format: (field_schema: z.ZodType) => string | null;
18
+ /** Generate a valid-ish value for a field based on its base type. */
19
+ export declare const generate_valid_value: (field: ZodFieldInfo, field_schema: z.ZodType) => unknown;
20
+ /**
21
+ * Resolve a route path with valid-ish param values so params validation passes.
22
+ * Used when testing input on routes that also have params.
23
+ */
24
+ export declare const resolve_valid_path: (path: string, params_schema?: z.ZodObject) => string;
25
+ /**
26
+ * Generate a valid request body for a route's input schema.
27
+ *
28
+ * Returns `undefined` for null schemas or schemas that can't be unwrapped to objects.
29
+ * Throws if the generated body fails validation — catches broken generation logic
30
+ * early with a descriptive error instead of a confusing 400 in downstream tests.
31
+ */
32
+ export declare const generate_valid_body: (input_schema: z.ZodType) => Record<string, unknown> | undefined;
33
+ //# sourceMappingURL=schema_generators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema_generators.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/schema_generators.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;GAQG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,yBAAyB,CAAC;AAIjC;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,cAAc,CAAC,CAAC,OAAO,KAAG,MAAM,GAAG,IAShE,CAAC;AAiBF,qEAAqE;AACrE,eAAO,MAAM,oBAAoB,GAAI,OAAO,YAAY,EAAE,cAAc,CAAC,CAAC,OAAO,KAAG,OAqCnF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,EAAE,gBAAgB,CAAC,CAAC,SAAS,KAAG,MAa9E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC/B,cAAc,CAAC,CAAC,OAAO,KACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAkB5B,CAAC"}
@@ -0,0 +1,137 @@
1
+ import './assert_dev_env.js';
2
+ /**
3
+ * Schema-driven value generation helpers for testing.
4
+ *
5
+ * Walks Zod schemas to generate valid values for route params, request bodies,
6
+ * and URL paths. Used by adversarial input, adversarial 404, and round-trip
7
+ * validation test suites.
8
+ *
9
+ * @module
10
+ */
11
+ import { z } from 'zod';
12
+ import { zod_unwrap_def, zod_get_base_type, zod_unwrap_to_object, zod_extract_fields, } from '@fuzdev/fuz_util/zod.js';
13
+ import { is_null_schema } from '../http/schema_helpers.js';
14
+ /**
15
+ * Detect format constraints on a field by converting to JSON Schema.
16
+ * Returns format string (e.g. 'uuid', 'email') or null.
17
+ */
18
+ export const detect_format = (field_schema) => {
19
+ try {
20
+ const json = z.toJSONSchema(field_schema);
21
+ if (typeof json.format === 'string')
22
+ return json.format;
23
+ if (typeof json.pattern === 'string')
24
+ return 'pattern';
25
+ }
26
+ catch {
27
+ // schema can't be converted, no format
28
+ }
29
+ return null;
30
+ };
31
+ /** Generate a string that satisfies minLength/maxLength constraints via JSON Schema. */
32
+ const generate_valid_string = (field_schema) => {
33
+ let min_length = 0;
34
+ let max_length = Infinity;
35
+ try {
36
+ const json = z.toJSONSchema(field_schema);
37
+ if (typeof json.minLength === 'number')
38
+ min_length = json.minLength;
39
+ if (typeof json.maxLength === 'number')
40
+ max_length = json.maxLength;
41
+ }
42
+ catch {
43
+ // no constraints
44
+ }
45
+ const target = Math.max(min_length, Math.min(10, max_length));
46
+ return 'x'.repeat(target) || 'test_value';
47
+ };
48
+ /** Generate a valid-ish value for a field based on its base type. */
49
+ export const generate_valid_value = (field, field_schema) => {
50
+ const format = detect_format(field_schema);
51
+ switch (field.base_type) {
52
+ case 'uuid':
53
+ return '00000000-0000-0000-0000-000000000000';
54
+ case 'email':
55
+ return 'test@example.com';
56
+ case 'string':
57
+ if (format === 'uuid')
58
+ return '00000000-0000-0000-0000-000000000000';
59
+ if (format === 'email')
60
+ return 'test@example.com';
61
+ return generate_valid_string(field_schema);
62
+ case 'number':
63
+ case 'int':
64
+ return 1;
65
+ case 'boolean':
66
+ return true;
67
+ case 'array':
68
+ return [];
69
+ case 'object':
70
+ return {};
71
+ case 'null':
72
+ return null;
73
+ case 'enum': {
74
+ const enum_def = zod_unwrap_def(field_schema);
75
+ if ('entries' in enum_def) {
76
+ const entries = enum_def.entries;
77
+ // Zod 4 enum entries is an object {key: value}, not an array
78
+ if (entries && typeof entries === 'object') {
79
+ const values = Object.values(entries);
80
+ if (values.length > 0)
81
+ return values[0];
82
+ }
83
+ }
84
+ return 'test';
85
+ }
86
+ default:
87
+ return 'test_value';
88
+ }
89
+ };
90
+ /**
91
+ * Resolve a route path with valid-ish param values so params validation passes.
92
+ * Used when testing input on routes that also have params.
93
+ */
94
+ export const resolve_valid_path = (path, params_schema) => {
95
+ if (!params_schema) {
96
+ return path.replace(/:(\w+)/g, 'test_$1');
97
+ }
98
+ return path.replace(/:(\w+)/g, (_match, name) => {
99
+ const field_schema = params_schema.shape[name];
100
+ if (!field_schema)
101
+ return `test_${name}`;
102
+ const base_type = zod_get_base_type(field_schema);
103
+ if (base_type === 'uuid')
104
+ return '00000000-0000-0000-0000-000000000000';
105
+ const format = detect_format(field_schema);
106
+ if (format === 'uuid')
107
+ return '00000000-0000-0000-0000-000000000000';
108
+ return `test_${name}`;
109
+ });
110
+ };
111
+ /**
112
+ * Generate a valid request body for a route's input schema.
113
+ *
114
+ * Returns `undefined` for null schemas or schemas that can't be unwrapped to objects.
115
+ * Throws if the generated body fails validation — catches broken generation logic
116
+ * early with a descriptive error instead of a confusing 400 in downstream tests.
117
+ */
118
+ export const generate_valid_body = (input_schema) => {
119
+ if (is_null_schema(input_schema))
120
+ return undefined;
121
+ const object_schema = zod_unwrap_to_object(input_schema);
122
+ if (!object_schema)
123
+ return undefined;
124
+ const fields = zod_extract_fields(object_schema);
125
+ const body = {};
126
+ for (const field of fields) {
127
+ if (!field.required && !field.has_default)
128
+ continue;
129
+ body[field.name] = generate_valid_value(field, object_schema.shape[field.name]);
130
+ }
131
+ const result = input_schema.safeParse(body);
132
+ if (!result.success) {
133
+ throw new Error(`generate_valid_body: generated body fails validation — ` +
134
+ `fix generate_valid_value for: ${result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join(', ')}`);
135
+ }
136
+ return body;
137
+ };
@@ -0,0 +1,49 @@
1
+ import './assert_dev_env.js';
2
+ /**
3
+ * Combined standard test suite helper.
4
+ *
5
+ * Convenience wrapper that runs both `describe_standard_integration_tests`
6
+ * and `describe_standard_admin_integration_tests` in a single call.
7
+ * Existing per-suite calls keep working — this is purely additive.
8
+ *
9
+ * @module
10
+ */
11
+ import type { SessionOptions } from '../auth/session_cookie.js';
12
+ import type { AppServerContext, AppServerOptions } from '../server/app_server.js';
13
+ import type { RouteSpec } from '../http/route_spec.js';
14
+ import type { RoleSchemaResult } from '../auth/role_schema.js';
15
+ import type { DbFactory } from './db.js';
16
+ /**
17
+ * Configuration for `describe_standard_tests`.
18
+ */
19
+ export interface StandardTestOptions {
20
+ /** Session config for cookie-based auth. */
21
+ session_options: SessionOptions<string>;
22
+ /** Route spec factory — same one used in production. */
23
+ create_route_specs: (ctx: AppServerContext) => Array<RouteSpec>;
24
+ /** Optional overrides for `AppServerOptions`. */
25
+ app_options?: Partial<Omit<AppServerOptions, 'backend' | 'session_options' | 'create_route_specs'>>;
26
+ /**
27
+ * Database factories to run tests against. Default: pglite only.
28
+ */
29
+ db_factories?: Array<DbFactory>;
30
+ /**
31
+ * Role schema result from `create_role_schema()`.
32
+ * When provided, admin integration tests are included.
33
+ */
34
+ roles?: RoleSchemaResult;
35
+ /**
36
+ * Path prefix where admin routes are mounted.
37
+ * Default `'/api/admin'`.
38
+ */
39
+ admin_prefix?: string;
40
+ }
41
+ /**
42
+ * Run both standard integration and admin integration test suites.
43
+ *
44
+ * Admin tests are only included when `roles` is provided.
45
+ *
46
+ * @param options - session config, route factory, and optional role schema
47
+ */
48
+ export declare const describe_standard_tests: (options: StandardTestOptions) => void;
49
+ //# sourceMappingURL=standard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/standard.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAC,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,SAAS,CAAC;AAIvC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,4CAA4C;IAC5C,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,wDAAwD;IACxD,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,iDAAiD;IACjD,WAAW,CAAC,EAAE,OAAO,CACpB,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,iBAAiB,GAAG,oBAAoB,CAAC,CAC5E,CAAC;IACF;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAChC;;;OAGG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS,mBAAmB,KAAG,IAKtE,CAAC"}
@@ -0,0 +1,16 @@
1
+ import './assert_dev_env.js';
2
+ import { describe_standard_integration_tests } from './integration.js';
3
+ import { describe_standard_admin_integration_tests } from './admin_integration.js';
4
+ /**
5
+ * Run both standard integration and admin integration test suites.
6
+ *
7
+ * Admin tests are only included when `roles` is provided.
8
+ *
9
+ * @param options - session config, route factory, and optional role schema
10
+ */
11
+ export const describe_standard_tests = (options) => {
12
+ describe_standard_integration_tests(options);
13
+ if (options.roles) {
14
+ describe_standard_admin_integration_tests({ ...options, roles: options.roles });
15
+ }
16
+ };
@@ -0,0 +1,96 @@
1
+ import './assert_dev_env.js';
2
+ import type { z } from 'zod';
3
+ import type { SessionOptions } from '../auth/session_cookie.js';
4
+ import type { MiddlewareSpec } from '../http/middleware_spec.js';
5
+ import type { AppDeps } from '../auth/deps.js';
6
+ import type { AppServerContext } from '../server/app_server.js';
7
+ import { Db } from '../db/db.js';
8
+ import { type RouteSpec } from '../http/route_spec.js';
9
+ import { type AppSurfaceSpec } from '../http/surface.js';
10
+ import type { SseEventSpec } from '../realtime/sse.js';
11
+ /**
12
+ * Create a Proxy that throws descriptive errors on any property access or method call.
13
+ *
14
+ * Use for deps that should never be reached during a test. If a test accidentally
15
+ * calls through to a throwing stub, the error message identifies exactly which stub
16
+ * was hit, catching test bugs that would silently pass with `{} as any`.
17
+ *
18
+ * @param label - descriptive name for error messages (e.g. `'keyring'`, `'db'`)
19
+ */
20
+ export declare const create_throwing_stub: <T = any>(label: string) => T;
21
+ /**
22
+ * Create a Proxy where every method access returns a no-op async function.
23
+ *
24
+ * Use for deps that may be reached during "correct auth passes guard" tests
25
+ * but whose return values don't matter. Unlike the explicit method listing,
26
+ * this auto-updates when interfaces change.
27
+ *
28
+ * @param label - descriptive name for debug purposes
29
+ * @param overrides - explicit properties to set (e.g. `{db: stub_db}`)
30
+ */
31
+ export declare const create_noop_stub: <T = any>(_label: string, overrides?: Record<string, unknown>) => T;
32
+ /** Throwing stub — use for deps that should never be reached. */
33
+ export declare const stub: any;
34
+ /**
35
+ * Create a stub `Db` for handler tests that use `apply_route_specs` with declarative transactions.
36
+ *
37
+ * Returns a real `Db` instance with:
38
+ * - `query` returns empty rows (safety net for unmocked query functions)
39
+ * - `query_one` returns undefined
40
+ * - `transaction(fn)` calls `fn(db)` synchronously (no real transaction)
41
+ */
42
+ export declare const create_stub_db: () => Db;
43
+ /** Stub handler that returns a 200 response. */
44
+ export declare const stub_handler: () => Response;
45
+ /** Stub middleware that passes through. */
46
+ export declare const stub_mw: (_c: any, next: any) => Promise<void>;
47
+ /** Stub `AppDeps` for auth surface tests — throws on any method access. */
48
+ export declare const stub_app_deps: AppDeps;
49
+ /**
50
+ * Create no-op app deps for auth surface testing.
51
+ *
52
+ * @returns an `AppDeps`-shaped object with no-op deps
53
+ */
54
+ export declare const create_stub_app_deps: () => AppDeps;
55
+ /** Create the API middleware stub array matching `create_auth_middleware_specs` output. */
56
+ export declare const create_stub_api_middleware: (options?: {
57
+ /** Include the daemon_token middleware layer. */
58
+ include_daemon_token?: boolean;
59
+ }) => Array<MiddlewareSpec>;
60
+ /**
61
+ * Create a stub `AppServerContext` for attack surface testing.
62
+ *
63
+ * Provides sensible defaults for all fields. Pass `session_options` since
64
+ * it varies per consumer; other fields use stubs/nulls.
65
+ *
66
+ * @param session_options - consumer's session config (required — varies per app)
67
+ */
68
+ export declare const create_stub_app_server_context: (session_options: SessionOptions<string>) => AppServerContext;
69
+ /** Options for `create_test_app_surface_spec`. */
70
+ export interface CreateTestAppSurfaceSpecOptions {
71
+ /** Consumer's session config (required — varies per app). */
72
+ session_options: SessionOptions<string>;
73
+ /** Consumer's route factory — receives the same `AppServerContext` as production. */
74
+ create_route_specs: (ctx: AppServerContext) => Array<RouteSpec>;
75
+ /** Env schema for surface generation (default: `BaseServerEnv`). */
76
+ env_schema?: z.ZodObject;
77
+ /** SSE event specs for surface generation. */
78
+ event_specs?: Array<SseEventSpec>;
79
+ /** Transform middleware array (e.g., tx's `extend_middleware_for_tx_binary`). */
80
+ transform_middleware?: (specs: Array<MiddlewareSpec>) => Array<MiddlewareSpec>;
81
+ /** Bootstrap route prefix (default: `'/api/account'`). */
82
+ bootstrap_route_prefix?: string;
83
+ }
84
+ /**
85
+ * Create an `AppSurfaceSpec` for attack surface testing.
86
+ *
87
+ * Mirrors `create_app_server`'s route assembly: consumer routes +
88
+ * factory-managed bootstrap routes + surface generation. If
89
+ * `create_app_server` changes how it wires routes, update this helper
90
+ * to stay in sync (single source of truth for all consumers).
91
+ *
92
+ * @param options - surface spec options
93
+ * @returns the surface spec for snapshot and adversarial testing
94
+ */
95
+ export declare const create_test_app_surface_spec: (options: CreateTestAppSurfaceSpecOptions) => AppSurfaceSpec;
96
+ //# sourceMappingURL=stubs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stubs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/stubs.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAa7B,OAAO,KAAK,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAE3B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAE/D,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAC,EAAE,EAAC,MAAM,aAAa,CAAC;AAC/B,OAAO,EAAqB,KAAK,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAEzE,OAAO,EAA0B,KAAK,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAChF,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAKrD;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,GAAG,GAAG,EAAE,OAAO,MAAM,KAAG,CAqBtD,CAAC;AAET;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,GAAG,GAAG,EAAE,QAAQ,MAAM,EAAE,YAAY,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,CAOxF,CAAC;AAET,iEAAiE;AACjE,eAAO,MAAM,IAAI,EAAE,GAAkC,CAAC;AAEtD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,QAAO,EAI/B,CAAC;AAEJ,gDAAgD;AAChD,eAAO,MAAM,YAAY,QAAO,QAAgC,CAAC;AAEjE,2CAA2C;AAC3C,eAAO,MAAM,OAAO,GAAU,IAAI,GAAG,EAAE,MAAM,GAAG,KAAG,OAAO,CAAC,IAAI,CAAW,CAAC;AAI3E,2EAA2E;AAC3E,eAAO,MAAM,aAAa,EAAE,OAS3B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAAO,OAStC,CAAC;AAEH,2FAA2F;AAC3F,eAAO,MAAM,0BAA0B,GAAI,UAAU;IACpD,iDAAiD;IACjD,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAC/B,KAAG,KAAK,CAAC,cAAc,CAqBvB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,GAC1C,iBAAiB,cAAc,CAAC,MAAM,CAAC,KACrC,gBAmBF,CAAC;AAEF,kDAAkD;AAClD,MAAM,WAAW,+BAA+B;IAC/C,6DAA6D;IAC7D,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,qFAAqF;IACrF,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,oEAAoE;IACpE,UAAU,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC;IACzB,8CAA8C;IAC9C,WAAW,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAClC,iFAAiF;IACjF,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,KAAK,CAAC,cAAc,CAAC,CAAC;IAC/E,0DAA0D;IAC1D,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,+BAA+B,KACtC,cAwBF,CAAC"}
@@ -0,0 +1,192 @@
1
+ import './assert_dev_env.js';
2
+ /**
3
+ * Stub factories for auth surface testing.
4
+ *
5
+ * Provides throwing stubs (catch unexpected access), no-op stubs (allow access
6
+ * without side effects), and pre-built bundles for `AppDeps`.
7
+ *
8
+ * @module
9
+ */
10
+ import { Logger } from '@fuzdev/fuz_util/log.js';
11
+ import { ApiError, RateLimitError } from '../http/error_schemas.js';
12
+ import { Db } from '../db/db.js';
13
+ import { prefix_route_specs } from '../http/route_spec.js';
14
+ import { create_bootstrap_route_specs } from '../auth/bootstrap_routes.js';
15
+ import { create_app_surface_spec } from '../http/surface.js';
16
+ import { BaseServerEnv } from '../server/env.js';
17
+ /* eslint-disable @typescript-eslint/require-await */
18
+ /**
19
+ * Create a Proxy that throws descriptive errors on any property access or method call.
20
+ *
21
+ * Use for deps that should never be reached during a test. If a test accidentally
22
+ * calls through to a throwing stub, the error message identifies exactly which stub
23
+ * was hit, catching test bugs that would silently pass with `{} as any`.
24
+ *
25
+ * @param label - descriptive name for error messages (e.g. `'keyring'`, `'db'`)
26
+ */
27
+ export const create_throwing_stub = (label) => new Proxy({}, {
28
+ get: (_target, prop) => {
29
+ // allow JS internals that runtime/test frameworks probe
30
+ if (typeof prop === 'symbol' ||
31
+ prop === 'then' ||
32
+ prop === 'constructor' ||
33
+ prop === '$$typeof')
34
+ return undefined;
35
+ // Return a sentinel for JSON serialization so accidental serialization
36
+ // is visible in output (e.g. "[throwing_stub:keyring]") rather than
37
+ // silently producing "{}". Does not throw — avoids crashing vitest
38
+ // assertion diffs and console.log output that contain stubs.
39
+ if (prop === 'toJSON')
40
+ return () => `[throwing_stub:${label}]`;
41
+ throw new Error(`Throwing stub '${label}' — unexpected access to '${prop}'. ` +
42
+ `This dep should not be reached in this test.`);
43
+ },
44
+ });
45
+ /**
46
+ * Create a Proxy where every method access returns a no-op async function.
47
+ *
48
+ * Use for deps that may be reached during "correct auth passes guard" tests
49
+ * but whose return values don't matter. Unlike the explicit method listing,
50
+ * this auto-updates when interfaces change.
51
+ *
52
+ * @param label - descriptive name for debug purposes
53
+ * @param overrides - explicit properties to set (e.g. `{db: stub_db}`)
54
+ */
55
+ export const create_noop_stub = (_label, overrides) => new Proxy({ ...(overrides ?? {}) }, {
56
+ get: (target, prop) => {
57
+ if (prop in target)
58
+ return target[prop];
59
+ if (typeof prop === 'symbol' || prop === 'then' || prop === 'toJSON')
60
+ return undefined;
61
+ return async () => undefined;
62
+ },
63
+ });
64
+ /** Throwing stub — use for deps that should never be reached. */
65
+ export const stub = create_throwing_stub('stub');
66
+ /**
67
+ * Create a stub `Db` for handler tests that use `apply_route_specs` with declarative transactions.
68
+ *
69
+ * Returns a real `Db` instance with:
70
+ * - `query` returns empty rows (safety net for unmocked query functions)
71
+ * - `query_one` returns undefined
72
+ * - `transaction(fn)` calls `fn(db)` synchronously (no real transaction)
73
+ */
74
+ export const create_stub_db = () => new Db({
75
+ client: { query: async () => ({ rows: [] }) },
76
+ transaction: async (fn) => fn(create_stub_db()),
77
+ });
78
+ /** Stub handler that returns a 200 response. */
79
+ export const stub_handler = () => new Response('stub');
80
+ /** Stub middleware that passes through. */
81
+ export const stub_mw = async (_c, next) => next();
82
+ const stub_db = create_noop_stub('stub_db');
83
+ /** Stub `AppDeps` for auth surface tests — throws on any method access. */
84
+ export const stub_app_deps = {
85
+ stat: create_throwing_stub('stat'),
86
+ read_file: create_throwing_stub('read_file'),
87
+ delete_file: create_throwing_stub('delete_file'),
88
+ keyring: create_throwing_stub('keyring'),
89
+ password: create_throwing_stub('password'),
90
+ db: create_throwing_stub('db'),
91
+ log: create_throwing_stub('log'),
92
+ on_audit_event: () => { }, // eslint-disable-line @typescript-eslint/no-empty-function
93
+ };
94
+ /**
95
+ * Create no-op app deps for auth surface testing.
96
+ *
97
+ * @returns an `AppDeps`-shaped object with no-op deps
98
+ */
99
+ export const create_stub_app_deps = () => ({
100
+ stat: async () => null,
101
+ read_file: async () => '',
102
+ delete_file: async (_path) => { }, // eslint-disable-line @typescript-eslint/no-empty-function
103
+ keyring: create_noop_stub('keyring'),
104
+ password: create_noop_stub('password'),
105
+ db: stub_db,
106
+ log: new Logger('test', { level: 'off' }),
107
+ on_audit_event: () => { }, // eslint-disable-line @typescript-eslint/no-empty-function
108
+ });
109
+ /** Create the API middleware stub array matching `create_auth_middleware_specs` output. */
110
+ export const create_stub_api_middleware = (options) => {
111
+ const specs = [
112
+ { name: 'origin', path: '/api/*', handler: stub_mw, errors: { 403: ApiError } },
113
+ { name: 'session', path: '/api/*', handler: stub_mw },
114
+ { name: 'request_context', path: '/api/*', handler: stub_mw },
115
+ {
116
+ name: 'bearer_auth',
117
+ path: '/api/*',
118
+ handler: stub_mw,
119
+ errors: { 401: ApiError, 403: ApiError, 429: RateLimitError },
120
+ },
121
+ ];
122
+ if (options?.include_daemon_token) {
123
+ specs.push({
124
+ name: 'daemon_token',
125
+ path: '/api/*',
126
+ handler: stub_mw,
127
+ errors: { 401: ApiError, 500: ApiError, 503: ApiError },
128
+ });
129
+ }
130
+ return specs;
131
+ };
132
+ /**
133
+ * Create a stub `AppServerContext` for attack surface testing.
134
+ *
135
+ * Provides sensible defaults for all fields. Pass `session_options` since
136
+ * it varies per consumer; other fields use stubs/nulls.
137
+ *
138
+ * @param session_options - consumer's session config (required — varies per app)
139
+ */
140
+ export const create_stub_app_server_context = (session_options) => {
141
+ const deps = create_stub_app_deps();
142
+ return {
143
+ deps,
144
+ backend: {
145
+ deps,
146
+ db_type: 'pglite-memory',
147
+ db_name: 'test',
148
+ migration_results: [],
149
+ close: async () => { }, // eslint-disable-line @typescript-eslint/no-empty-function
150
+ },
151
+ bootstrap_status: { available: false, token_path: null },
152
+ session_options,
153
+ ip_rate_limiter: null,
154
+ login_account_rate_limiter: null,
155
+ signup_account_rate_limiter: null,
156
+ app_settings: { open_signup: false, updated_at: null, updated_by: null },
157
+ audit_sse: null,
158
+ };
159
+ };
160
+ /**
161
+ * Create an `AppSurfaceSpec` for attack surface testing.
162
+ *
163
+ * Mirrors `create_app_server`'s route assembly: consumer routes +
164
+ * factory-managed bootstrap routes + surface generation. If
165
+ * `create_app_server` changes how it wires routes, update this helper
166
+ * to stay in sync (single source of truth for all consumers).
167
+ *
168
+ * @param options - surface spec options
169
+ * @returns the surface spec for snapshot and adversarial testing
170
+ */
171
+ export const create_test_app_surface_spec = (options) => {
172
+ const ctx = create_stub_app_server_context(options.session_options);
173
+ const consumer_routes = options.create_route_specs(ctx);
174
+ // Mirror create_app_server's factory-managed route assembly
175
+ const bootstrap_routes = create_bootstrap_route_specs(ctx.deps, {
176
+ session_options: options.session_options,
177
+ bootstrap_status: { available: false, token_path: null },
178
+ ip_rate_limiter: null,
179
+ });
180
+ const prefix = options.bootstrap_route_prefix ?? '/api/account';
181
+ const route_specs = [...consumer_routes, ...prefix_route_specs(prefix, bootstrap_routes)];
182
+ let middleware_specs = create_stub_api_middleware();
183
+ if (options.transform_middleware) {
184
+ middleware_specs = options.transform_middleware(middleware_specs);
185
+ }
186
+ return create_app_surface_spec({
187
+ middleware_specs,
188
+ route_specs,
189
+ env_schema: options.env_schema ?? BaseServerEnv,
190
+ event_specs: options.event_specs,
191
+ });
192
+ };