@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.
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/actions/action_bridge.d.ts +65 -0
- package/dist/actions/action_bridge.d.ts.map +1 -0
- package/dist/actions/action_bridge.js +76 -0
- package/dist/actions/action_codegen.d.ts +97 -0
- package/dist/actions/action_codegen.d.ts.map +1 -0
- package/dist/actions/action_codegen.js +280 -0
- package/dist/actions/action_registry.d.ts +35 -0
- package/dist/actions/action_registry.d.ts.map +1 -0
- package/dist/actions/action_registry.js +83 -0
- package/dist/actions/action_spec.d.ts +169 -0
- package/dist/actions/action_spec.d.ts.map +1 -0
- package/dist/actions/action_spec.js +76 -0
- package/dist/auth/account_queries.d.ts +96 -0
- package/dist/auth/account_queries.d.ts.map +1 -0
- package/dist/auth/account_queries.js +172 -0
- package/dist/auth/account_routes.d.ts +86 -0
- package/dist/auth/account_routes.d.ts.map +1 -0
- package/dist/auth/account_routes.js +406 -0
- package/dist/auth/account_schema.d.ts +192 -0
- package/dist/auth/account_schema.d.ts.map +1 -0
- package/dist/auth/account_schema.js +105 -0
- package/dist/auth/admin_routes.d.ts +29 -0
- package/dist/auth/admin_routes.d.ts.map +1 -0
- package/dist/auth/admin_routes.js +193 -0
- package/dist/auth/api_token.d.ts +33 -0
- package/dist/auth/api_token.d.ts.map +1 -0
- package/dist/auth/api_token.js +36 -0
- package/dist/auth/api_token_queries.d.ts +80 -0
- package/dist/auth/api_token_queries.d.ts.map +1 -0
- package/dist/auth/api_token_queries.js +116 -0
- package/dist/auth/app_settings_queries.d.ts +33 -0
- package/dist/auth/app_settings_queries.d.ts.map +1 -0
- package/dist/auth/app_settings_queries.js +51 -0
- package/dist/auth/app_settings_routes.d.ts +27 -0
- package/dist/auth/app_settings_routes.d.ts.map +1 -0
- package/dist/auth/app_settings_routes.js +66 -0
- package/dist/auth/app_settings_schema.d.ts +35 -0
- package/dist/auth/app_settings_schema.d.ts.map +1 -0
- package/dist/auth/app_settings_schema.js +22 -0
- package/dist/auth/audit_log_queries.d.ts +90 -0
- package/dist/auth/audit_log_queries.d.ts.map +1 -0
- package/dist/auth/audit_log_queries.js +205 -0
- package/dist/auth/audit_log_routes.d.ts +33 -0
- package/dist/auth/audit_log_routes.d.ts.map +1 -0
- package/dist/auth/audit_log_routes.js +106 -0
- package/dist/auth/audit_log_schema.d.ts +259 -0
- package/dist/auth/audit_log_schema.d.ts.map +1 -0
- package/dist/auth/audit_log_schema.js +123 -0
- package/dist/auth/bearer_auth.d.ts +32 -0
- package/dist/auth/bearer_auth.d.ts.map +1 -0
- package/dist/auth/bearer_auth.js +90 -0
- package/dist/auth/bootstrap_account.d.ts +82 -0
- package/dist/auth/bootstrap_account.d.ts.map +1 -0
- package/dist/auth/bootstrap_account.js +97 -0
- package/dist/auth/bootstrap_routes.d.ts +74 -0
- package/dist/auth/bootstrap_routes.d.ts.map +1 -0
- package/dist/auth/bootstrap_routes.js +154 -0
- package/dist/auth/daemon_token.d.ts +49 -0
- package/dist/auth/daemon_token.d.ts.map +1 -0
- package/dist/auth/daemon_token.js +49 -0
- package/dist/auth/daemon_token_middleware.d.ts +93 -0
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -0
- package/dist/auth/daemon_token_middleware.js +167 -0
- package/dist/auth/ddl.d.ts +27 -0
- package/dist/auth/ddl.d.ts.map +1 -0
- package/dist/auth/ddl.js +111 -0
- package/dist/auth/deps.d.ts +52 -0
- package/dist/auth/deps.d.ts.map +1 -0
- package/dist/auth/deps.js +10 -0
- package/dist/auth/invite_queries.d.ts +68 -0
- package/dist/auth/invite_queries.d.ts.map +1 -0
- package/dist/auth/invite_queries.js +105 -0
- package/dist/auth/invite_routes.d.ts +18 -0
- package/dist/auth/invite_routes.d.ts.map +1 -0
- package/dist/auth/invite_routes.js +129 -0
- package/dist/auth/invite_schema.d.ts +51 -0
- package/dist/auth/invite_schema.d.ts.map +1 -0
- package/dist/auth/invite_schema.js +25 -0
- package/dist/auth/keyring.d.ts +87 -0
- package/dist/auth/keyring.d.ts.map +1 -0
- package/dist/auth/keyring.js +142 -0
- package/dist/auth/middleware.d.ts +40 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +64 -0
- package/dist/auth/migrations.d.ts +42 -0
- package/dist/auth/migrations.d.ts.map +1 -0
- package/dist/auth/migrations.js +79 -0
- package/dist/auth/password.d.ts +39 -0
- package/dist/auth/password.d.ts.map +1 -0
- package/dist/auth/password.js +25 -0
- package/dist/auth/password_argon2.d.ts +43 -0
- package/dist/auth/password_argon2.d.ts.map +1 -0
- package/dist/auth/password_argon2.js +76 -0
- package/dist/auth/permit_queries.d.ts +72 -0
- package/dist/auth/permit_queries.d.ts.map +1 -0
- package/dist/auth/permit_queries.js +116 -0
- package/dist/auth/request_context.d.ts +114 -0
- package/dist/auth/request_context.d.ts.map +1 -0
- package/dist/auth/request_context.js +176 -0
- package/dist/auth/require_keeper.d.ts +20 -0
- package/dist/auth/require_keeper.d.ts.map +1 -0
- package/dist/auth/require_keeper.js +35 -0
- package/dist/auth/role_schema.d.ts +69 -0
- package/dist/auth/role_schema.d.ts.map +1 -0
- package/dist/auth/role_schema.js +70 -0
- package/dist/auth/route_guards.d.ts +21 -0
- package/dist/auth/route_guards.d.ts.map +1 -0
- package/dist/auth/route_guards.js +32 -0
- package/dist/auth/session_cookie.d.ts +158 -0
- package/dist/auth/session_cookie.d.ts.map +1 -0
- package/dist/auth/session_cookie.js +135 -0
- package/dist/auth/session_lifecycle.d.ts +35 -0
- package/dist/auth/session_lifecycle.d.ts.map +1 -0
- package/dist/auth/session_lifecycle.js +27 -0
- package/dist/auth/session_middleware.d.ts +33 -0
- package/dist/auth/session_middleware.d.ts.map +1 -0
- package/dist/auth/session_middleware.js +62 -0
- package/dist/auth/session_queries.d.ts +135 -0
- package/dist/auth/session_queries.d.ts.map +1 -0
- package/dist/auth/session_queries.js +186 -0
- package/dist/auth/signup_routes.d.ts +32 -0
- package/dist/auth/signup_routes.d.ts.map +1 -0
- package/dist/auth/signup_routes.js +150 -0
- package/dist/cli/args.d.ts +48 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +76 -0
- package/dist/cli/config.d.ts +48 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +77 -0
- package/dist/cli/daemon.d.ts +82 -0
- package/dist/cli/daemon.d.ts.map +1 -0
- package/dist/cli/daemon.js +149 -0
- package/dist/cli/help.d.ts +85 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/help.js +138 -0
- package/dist/cli/logger.d.ts +46 -0
- package/dist/cli/logger.d.ts.map +1 -0
- package/dist/cli/logger.js +48 -0
- package/dist/cli/util.d.ts +36 -0
- package/dist/cli/util.d.ts.map +1 -0
- package/dist/cli/util.js +50 -0
- package/dist/crypto.d.ts +13 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +19 -0
- package/dist/db/assert_row.d.ts +18 -0
- package/dist/db/assert_row.d.ts.map +1 -0
- package/dist/db/assert_row.js +24 -0
- package/dist/db/create_db.d.ts +38 -0
- package/dist/db/create_db.d.ts.map +1 -0
- package/dist/db/create_db.js +57 -0
- package/dist/db/db.d.ts +97 -0
- package/dist/db/db.d.ts.map +1 -0
- package/dist/db/db.js +76 -0
- package/dist/db/db_pg.d.ts +21 -0
- package/dist/db/db_pg.d.ts.map +1 -0
- package/dist/db/db_pg.js +45 -0
- package/dist/db/db_pglite.d.ts +21 -0
- package/dist/db/db_pglite.d.ts.map +1 -0
- package/dist/db/db_pglite.js +28 -0
- package/dist/db/migrate.d.ts +67 -0
- package/dist/db/migrate.d.ts.map +1 -0
- package/dist/db/migrate.js +118 -0
- package/dist/db/pg_error.d.ts +16 -0
- package/dist/db/pg_error.d.ts.map +1 -0
- package/dist/db/pg_error.js +15 -0
- package/dist/db/query_deps.d.ts +14 -0
- package/dist/db/query_deps.d.ts.map +1 -0
- package/dist/db/query_deps.js +9 -0
- package/dist/db/sql_identifier.d.ts +27 -0
- package/dist/db/sql_identifier.d.ts.map +1 -0
- package/dist/db/sql_identifier.js +31 -0
- package/dist/db/status.d.ts +62 -0
- package/dist/db/status.d.ts.map +1 -0
- package/dist/db/status.js +116 -0
- package/dist/dev/setup.d.ts +159 -0
- package/dist/dev/setup.d.ts.map +1 -0
- package/dist/dev/setup.js +265 -0
- package/dist/env/dotenv.d.ts +25 -0
- package/dist/env/dotenv.d.ts.map +1 -0
- package/dist/env/dotenv.js +52 -0
- package/dist/env/load.d.ts +52 -0
- package/dist/env/load.d.ts.map +1 -0
- package/dist/env/load.js +79 -0
- package/dist/env/mask.d.ts +19 -0
- package/dist/env/mask.d.ts.map +1 -0
- package/dist/env/mask.js +26 -0
- package/dist/env/resolve.d.ts +126 -0
- package/dist/env/resolve.d.ts.map +1 -0
- package/dist/env/resolve.js +200 -0
- package/dist/hono_context.d.ts +48 -0
- package/dist/hono_context.d.ts.map +1 -0
- package/dist/hono_context.js +22 -0
- package/dist/http/common_routes.d.ts +52 -0
- package/dist/http/common_routes.d.ts.map +1 -0
- package/dist/http/common_routes.js +65 -0
- package/dist/http/db_routes.d.ts +57 -0
- package/dist/http/db_routes.d.ts.map +1 -0
- package/dist/http/db_routes.js +176 -0
- package/dist/http/error_schemas.d.ts +169 -0
- package/dist/http/error_schemas.d.ts.map +1 -0
- package/dist/http/error_schemas.js +178 -0
- package/dist/http/middleware_spec.d.ts +19 -0
- package/dist/http/middleware_spec.d.ts.map +1 -0
- package/dist/http/middleware_spec.js +9 -0
- package/dist/http/origin.d.ts +57 -0
- package/dist/http/origin.d.ts.map +1 -0
- package/dist/http/origin.js +207 -0
- package/dist/http/proxy.d.ts +112 -0
- package/dist/http/proxy.d.ts.map +1 -0
- package/dist/http/proxy.js +240 -0
- package/dist/http/route_spec.d.ts +197 -0
- package/dist/http/route_spec.d.ts.map +1 -0
- package/dist/http/route_spec.js +243 -0
- package/dist/http/schema_helpers.d.ts +64 -0
- package/dist/http/schema_helpers.d.ts.map +1 -0
- package/dist/http/schema_helpers.js +90 -0
- package/dist/http/surface.d.ts +132 -0
- package/dist/http/surface.d.ts.map +1 -0
- package/dist/http/surface.js +156 -0
- package/dist/http/surface_query.d.ts +77 -0
- package/dist/http/surface_query.d.ts.map +1 -0
- package/dist/http/surface_query.js +86 -0
- package/dist/rate_limiter.d.ts +94 -0
- package/dist/rate_limiter.d.ts.map +1 -0
- package/dist/rate_limiter.js +156 -0
- package/dist/realtime/sse.d.ts +80 -0
- package/dist/realtime/sse.d.ts.map +1 -0
- package/dist/realtime/sse.js +109 -0
- package/dist/realtime/sse_auth_guard.d.ts +93 -0
- package/dist/realtime/sse_auth_guard.d.ts.map +1 -0
- package/dist/realtime/sse_auth_guard.js +111 -0
- package/dist/realtime/subscriber_registry.d.ts +85 -0
- package/dist/realtime/subscriber_registry.d.ts.map +1 -0
- package/dist/realtime/subscriber_registry.js +108 -0
- package/dist/runtime/deno.d.ts +21 -0
- package/dist/runtime/deno.d.ts.map +1 -0
- package/dist/runtime/deno.js +83 -0
- package/dist/runtime/deps.d.ts +113 -0
- package/dist/runtime/deps.d.ts.map +1 -0
- package/dist/runtime/deps.js +10 -0
- package/dist/runtime/fs.d.ts +15 -0
- package/dist/runtime/fs.d.ts.map +1 -0
- package/dist/runtime/fs.js +17 -0
- package/dist/runtime/mock.d.ts +81 -0
- package/dist/runtime/mock.d.ts.map +1 -0
- package/dist/runtime/mock.js +195 -0
- package/dist/runtime/node.d.ts +17 -0
- package/dist/runtime/node.d.ts.map +1 -0
- package/dist/runtime/node.js +117 -0
- package/dist/schema_meta.d.ts +16 -0
- package/dist/schema_meta.d.ts.map +1 -0
- package/dist/schema_meta.js +9 -0
- package/dist/sensitivity.d.ts +15 -0
- package/dist/sensitivity.d.ts.map +1 -0
- package/dist/sensitivity.js +9 -0
- package/dist/server/app_backend.d.ts +74 -0
- package/dist/server/app_backend.d.ts.map +1 -0
- package/dist/server/app_backend.js +39 -0
- package/dist/server/app_server.d.ts +201 -0
- package/dist/server/app_server.d.ts.map +1 -0
- package/dist/server/app_server.js +266 -0
- package/dist/server/env.d.ts +68 -0
- package/dist/server/env.d.ts.map +1 -0
- package/dist/server/env.js +95 -0
- package/dist/server/startup.d.ts +22 -0
- package/dist/server/startup.d.ts.map +1 -0
- package/dist/server/startup.js +48 -0
- package/dist/server/static.d.ts +39 -0
- package/dist/server/static.d.ts.map +1 -0
- package/dist/server/static.js +38 -0
- package/dist/server/validate_nginx.d.ts +34 -0
- package/dist/server/validate_nginx.d.ts.map +1 -0
- package/dist/server/validate_nginx.js +118 -0
- package/dist/testing/CLAUDE.md +3 -0
- package/dist/testing/admin_integration.d.ts +45 -0
- package/dist/testing/admin_integration.d.ts.map +1 -0
- package/dist/testing/admin_integration.js +840 -0
- package/dist/testing/adversarial_404.d.ts +15 -0
- package/dist/testing/adversarial_404.d.ts.map +1 -0
- package/dist/testing/adversarial_404.js +118 -0
- package/dist/testing/adversarial_headers.d.ts +36 -0
- package/dist/testing/adversarial_headers.d.ts.map +1 -0
- package/dist/testing/adversarial_headers.js +128 -0
- package/dist/testing/adversarial_input.d.ts +56 -0
- package/dist/testing/adversarial_input.d.ts.map +1 -0
- package/dist/testing/adversarial_input.js +494 -0
- package/dist/testing/app_server.d.ts +169 -0
- package/dist/testing/app_server.d.ts.map +1 -0
- package/dist/testing/app_server.js +240 -0
- package/dist/testing/assert_dev_env.d.ts +10 -0
- package/dist/testing/assert_dev_env.d.ts.map +1 -0
- package/dist/testing/assert_dev_env.js +13 -0
- package/dist/testing/assertions.d.ts +61 -0
- package/dist/testing/assertions.d.ts.map +1 -0
- package/dist/testing/assertions.js +96 -0
- package/dist/testing/attack_surface.d.ts +63 -0
- package/dist/testing/attack_surface.d.ts.map +1 -0
- package/dist/testing/attack_surface.js +224 -0
- package/dist/testing/audit_completeness.d.ts +29 -0
- package/dist/testing/audit_completeness.d.ts.map +1 -0
- package/dist/testing/audit_completeness.js +410 -0
- package/dist/testing/auth_apps.d.ts +55 -0
- package/dist/testing/auth_apps.d.ts.map +1 -0
- package/dist/testing/auth_apps.js +122 -0
- package/dist/testing/data_exposure.d.ts +62 -0
- package/dist/testing/data_exposure.d.ts.map +1 -0
- package/dist/testing/data_exposure.js +297 -0
- package/dist/testing/db.d.ts +111 -0
- package/dist/testing/db.d.ts.map +1 -0
- package/dist/testing/db.js +258 -0
- package/dist/testing/entities.d.ts +21 -0
- package/dist/testing/entities.d.ts.map +1 -0
- package/dist/testing/entities.js +42 -0
- package/dist/testing/error_coverage.d.ts +78 -0
- package/dist/testing/error_coverage.d.ts.map +1 -0
- package/dist/testing/error_coverage.js +135 -0
- package/dist/testing/integration.d.ts +37 -0
- package/dist/testing/integration.d.ts.map +1 -0
- package/dist/testing/integration.js +1139 -0
- package/dist/testing/integration_helpers.d.ts +107 -0
- package/dist/testing/integration_helpers.d.ts.map +1 -0
- package/dist/testing/integration_helpers.js +246 -0
- package/dist/testing/middleware.d.ts +125 -0
- package/dist/testing/middleware.d.ts.map +1 -0
- package/dist/testing/middleware.js +210 -0
- package/dist/testing/rate_limiting.d.ts +43 -0
- package/dist/testing/rate_limiting.d.ts.map +1 -0
- package/dist/testing/rate_limiting.js +216 -0
- package/dist/testing/round_trip.d.ts +37 -0
- package/dist/testing/round_trip.d.ts.map +1 -0
- package/dist/testing/round_trip.js +128 -0
- package/dist/testing/schema_generators.d.ts +33 -0
- package/dist/testing/schema_generators.d.ts.map +1 -0
- package/dist/testing/schema_generators.js +137 -0
- package/dist/testing/standard.d.ts +49 -0
- package/dist/testing/standard.d.ts.map +1 -0
- package/dist/testing/standard.js +16 -0
- package/dist/testing/stubs.d.ts +96 -0
- package/dist/testing/stubs.d.ts.map +1 -0
- package/dist/testing/stubs.js +192 -0
- package/dist/testing/surface_invariants.d.ts +189 -0
- package/dist/testing/surface_invariants.d.ts.map +1 -0
- package/dist/testing/surface_invariants.js +450 -0
- package/dist/ui/AccountSessions.svelte +75 -0
- package/dist/ui/AccountSessions.svelte.d.ts +19 -0
- package/dist/ui/AccountSessions.svelte.d.ts.map +1 -0
- package/dist/ui/AdminAccounts.svelte +107 -0
- package/dist/ui/AdminAccounts.svelte.d.ts +19 -0
- package/dist/ui/AdminAccounts.svelte.d.ts.map +1 -0
- package/dist/ui/AdminAuditLog.svelte +144 -0
- package/dist/ui/AdminAuditLog.svelte.d.ts +4 -0
- package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -0
- package/dist/ui/AdminInvites.svelte +142 -0
- package/dist/ui/AdminInvites.svelte.d.ts +4 -0
- package/dist/ui/AdminInvites.svelte.d.ts.map +1 -0
- package/dist/ui/AdminOverview.svelte +337 -0
- package/dist/ui/AdminOverview.svelte.d.ts +4 -0
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -0
- package/dist/ui/AdminPermitHistory.svelte +61 -0
- package/dist/ui/AdminPermitHistory.svelte.d.ts +19 -0
- package/dist/ui/AdminPermitHistory.svelte.d.ts.map +1 -0
- package/dist/ui/AdminSessions.svelte +85 -0
- package/dist/ui/AdminSessions.svelte.d.ts +19 -0
- package/dist/ui/AdminSessions.svelte.d.ts.map +1 -0
- package/dist/ui/AdminSettings.svelte +32 -0
- package/dist/ui/AdminSettings.svelte.d.ts +19 -0
- package/dist/ui/AdminSettings.svelte.d.ts.map +1 -0
- package/dist/ui/AdminSurface.svelte +42 -0
- package/dist/ui/AdminSurface.svelte.d.ts +4 -0
- package/dist/ui/AdminSurface.svelte.d.ts.map +1 -0
- package/dist/ui/AppShell.svelte +93 -0
- package/dist/ui/AppShell.svelte.d.ts +20 -0
- package/dist/ui/AppShell.svelte.d.ts.map +1 -0
- package/dist/ui/BootstrapForm.svelte +105 -0
- package/dist/ui/BootstrapForm.svelte.d.ts +4 -0
- package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -0
- package/dist/ui/ColumnLayout.svelte +46 -0
- package/dist/ui/ColumnLayout.svelte.d.ts +11 -0
- package/dist/ui/ColumnLayout.svelte.d.ts.map +1 -0
- package/dist/ui/ConfirmButton.svelte +125 -0
- package/dist/ui/ConfirmButton.svelte.d.ts +54 -0
- package/dist/ui/ConfirmButton.svelte.d.ts.map +1 -0
- package/dist/ui/Datatable.svelte +185 -0
- package/dist/ui/Datatable.svelte.d.ts +35 -0
- package/dist/ui/Datatable.svelte.d.ts.map +1 -0
- package/dist/ui/LoginForm.svelte +82 -0
- package/dist/ui/LoginForm.svelte.d.ts +8 -0
- package/dist/ui/LoginForm.svelte.d.ts.map +1 -0
- package/dist/ui/LogoutButton.svelte +36 -0
- package/dist/ui/LogoutButton.svelte.d.ts +10 -0
- package/dist/ui/LogoutButton.svelte.d.ts.map +1 -0
- package/dist/ui/MenuLink.svelte +35 -0
- package/dist/ui/MenuLink.svelte.d.ts +12 -0
- package/dist/ui/MenuLink.svelte.d.ts.map +1 -0
- package/dist/ui/OpenSignupToggle.svelte +36 -0
- package/dist/ui/OpenSignupToggle.svelte.d.ts +19 -0
- package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -0
- package/dist/ui/PopoverButton.svelte +136 -0
- package/dist/ui/PopoverButton.svelte.d.ts +63 -0
- package/dist/ui/PopoverButton.svelte.d.ts.map +1 -0
- package/dist/ui/SignupForm.svelte +117 -0
- package/dist/ui/SignupForm.svelte.d.ts +7 -0
- package/dist/ui/SignupForm.svelte.d.ts.map +1 -0
- package/dist/ui/SurfaceExplorer.svelte +287 -0
- package/dist/ui/SurfaceExplorer.svelte.d.ts +8 -0
- package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -0
- package/dist/ui/account_sessions_state.svelte.d.ts +15 -0
- package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -0
- package/dist/ui/account_sessions_state.svelte.js +45 -0
- package/dist/ui/admin_accounts_state.svelte.d.ts +19 -0
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -0
- package/dist/ui/admin_accounts_state.svelte.js +65 -0
- package/dist/ui/admin_invites_state.svelte.d.ts +19 -0
- package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -0
- package/dist/ui/admin_invites_state.svelte.js +71 -0
- package/dist/ui/admin_sessions_state.svelte.d.ts +18 -0
- package/dist/ui/admin_sessions_state.svelte.d.ts.map +1 -0
- package/dist/ui/admin_sessions_state.svelte.js +62 -0
- package/dist/ui/app_settings_state.svelte.d.ts +14 -0
- package/dist/ui/app_settings_state.svelte.d.ts.map +1 -0
- package/dist/ui/app_settings_state.svelte.js +44 -0
- package/dist/ui/audit_log_state.svelte.d.ts +40 -0
- package/dist/ui/audit_log_state.svelte.d.ts.map +1 -0
- package/dist/ui/audit_log_state.svelte.js +153 -0
- package/dist/ui/auth_state.svelte.d.ts +85 -0
- package/dist/ui/auth_state.svelte.d.ts.map +1 -0
- package/dist/ui/auth_state.svelte.js +238 -0
- package/dist/ui/datatable.d.ts +25 -0
- package/dist/ui/datatable.d.ts.map +1 -0
- package/dist/ui/datatable.js +9 -0
- package/dist/ui/enter_advance.d.ts +13 -0
- package/dist/ui/enter_advance.d.ts.map +1 -0
- package/dist/ui/enter_advance.js +30 -0
- package/dist/ui/loadable.svelte.d.ts +55 -0
- package/dist/ui/loadable.svelte.d.ts.map +1 -0
- package/dist/ui/loadable.svelte.js +75 -0
- package/dist/ui/popover.svelte.d.ts +137 -0
- package/dist/ui/popover.svelte.d.ts.map +1 -0
- package/dist/ui/popover.svelte.js +288 -0
- package/dist/ui/position_helpers.d.ts +27 -0
- package/dist/ui/position_helpers.d.ts.map +1 -0
- package/dist/ui/position_helpers.js +81 -0
- package/dist/ui/sidebar_state.svelte.d.ts +30 -0
- package/dist/ui/sidebar_state.svelte.d.ts.map +1 -0
- package/dist/ui/sidebar_state.svelte.js +39 -0
- package/dist/ui/table_state.svelte.d.ts +63 -0
- package/dist/ui/table_state.svelte.d.ts.map +1 -0
- package/dist/ui/table_state.svelte.js +117 -0
- package/dist/ui/ui_fetch.d.ts +29 -0
- package/dist/ui/ui_fetch.d.ts.map +1 -0
- package/dist/ui/ui_fetch.js +37 -0
- package/dist/ui/ui_format.d.ts +63 -0
- package/dist/ui/ui_format.d.ts.map +1 -0
- package/dist/ui/ui_format.js +196 -0
- package/package.json +121 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request context middleware and permit checking helpers.
|
|
3
|
+
*
|
|
4
|
+
* Builds `{ account, actor, permits }` from a session cookie
|
|
5
|
+
* for every authenticated request. Downstream handlers check
|
|
6
|
+
* permits, never flags.
|
|
7
|
+
*
|
|
8
|
+
* `build_request_context` is the shared helper used by session,
|
|
9
|
+
* bearer, and daemon token middleware to resolve account → actor → permits.
|
|
10
|
+
* `refresh_permits` reloads permits on an existing context.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import type { Context, MiddlewareHandler } from 'hono';
|
|
15
|
+
import type { Logger } from '@fuzdev/fuz_util/log.js';
|
|
16
|
+
import { type Account, type Actor, type Permit } from './account_schema.js';
|
|
17
|
+
import type { QueryDeps } from '../db/query_deps.js';
|
|
18
|
+
/** The resolved identity context for an authenticated request. */
|
|
19
|
+
export interface RequestContext {
|
|
20
|
+
account: Account;
|
|
21
|
+
actor: Actor;
|
|
22
|
+
permits: Array<Permit>;
|
|
23
|
+
}
|
|
24
|
+
/** Hono context variable name for the request context. */
|
|
25
|
+
export declare const REQUEST_CONTEXT_KEY = "request_context";
|
|
26
|
+
/**
|
|
27
|
+
* Get the request context from a Hono context, or `null` if unauthenticated.
|
|
28
|
+
*
|
|
29
|
+
* @param c - the Hono context
|
|
30
|
+
* @returns the request context, or `null`
|
|
31
|
+
*/
|
|
32
|
+
export declare const get_request_context: (c: Context) => RequestContext | null;
|
|
33
|
+
/**
|
|
34
|
+
* Get the request context, throwing if unauthenticated.
|
|
35
|
+
*
|
|
36
|
+
* Use in route handlers where auth middleware guarantees a context exists
|
|
37
|
+
* (i.e., routes with `auth: {type: 'authenticated'}` or stricter).
|
|
38
|
+
* Prefer this over `get_request_context(c)!` for explicit error handling.
|
|
39
|
+
*
|
|
40
|
+
* @param c - the Hono context
|
|
41
|
+
* @returns the request context (never null)
|
|
42
|
+
* @throws Error if no request context is set (middleware misconfiguration)
|
|
43
|
+
*/
|
|
44
|
+
export declare const require_request_context: (c: Context) => RequestContext;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a request context has an active permit for a given role.
|
|
47
|
+
*
|
|
48
|
+
* Checks the permits already loaded in the context (no DB query).
|
|
49
|
+
*
|
|
50
|
+
* @param ctx - the request context
|
|
51
|
+
* @param role - the role to check
|
|
52
|
+
* @param now - current time (defaults to `new Date()`, pass for testability and hot-path efficiency)
|
|
53
|
+
* @returns `true` if the actor has an active permit for the role
|
|
54
|
+
*/
|
|
55
|
+
export declare const has_role: (ctx: RequestContext, role: string, now?: Date) => boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Create middleware that builds the request context from a session cookie.
|
|
58
|
+
*
|
|
59
|
+
* Reads the session identity (set by session middleware), looks up
|
|
60
|
+
* the `auth_session`, loads account + actor + active permits, and
|
|
61
|
+
* sets the `RequestContext` on the Hono context.
|
|
62
|
+
*
|
|
63
|
+
* If the session is invalid or the account is not found, the context
|
|
64
|
+
* is set to `null` (unauthenticated). No 401 is returned — use
|
|
65
|
+
* `require_role` or `require_auth` for enforcement.
|
|
66
|
+
*
|
|
67
|
+
* @param deps - query dependencies (pool-level db for middleware)
|
|
68
|
+
* @param log - the logger instance
|
|
69
|
+
* @param session_context_key - the Hono context key where session middleware stored the session token
|
|
70
|
+
*/
|
|
71
|
+
export declare const create_request_context_middleware: (deps: QueryDeps, log: Logger, session_context_key?: string) => MiddlewareHandler;
|
|
72
|
+
/**
|
|
73
|
+
* Middleware that requires authentication.
|
|
74
|
+
*
|
|
75
|
+
* Returns 401 if no request context is set.
|
|
76
|
+
*/
|
|
77
|
+
export declare const require_auth: MiddlewareHandler;
|
|
78
|
+
/**
|
|
79
|
+
* Create middleware that requires a specific role.
|
|
80
|
+
*
|
|
81
|
+
* Returns 401 if unauthenticated, 403 if the role is missing.
|
|
82
|
+
*
|
|
83
|
+
* @param role - the required role
|
|
84
|
+
*/
|
|
85
|
+
export declare const require_role: (role: string) => MiddlewareHandler;
|
|
86
|
+
/**
|
|
87
|
+
* Reload active permits from the database, returning a new request context.
|
|
88
|
+
*
|
|
89
|
+
* Useful for long-lived WebSocket connections where permits may change
|
|
90
|
+
* (grant or revoke) during the connection lifetime. Call periodically
|
|
91
|
+
* or after receiving a revocation signal.
|
|
92
|
+
*
|
|
93
|
+
* Returns a new `RequestContext` with updated permits — the original
|
|
94
|
+
* context is not mutated, making concurrent calls safe.
|
|
95
|
+
*
|
|
96
|
+
* @param ctx - the request context to refresh
|
|
97
|
+
* @param deps - query dependencies
|
|
98
|
+
* @returns a new `RequestContext` with fresh permits
|
|
99
|
+
*/
|
|
100
|
+
export declare const refresh_permits: (ctx: RequestContext, deps: QueryDeps) => Promise<RequestContext>;
|
|
101
|
+
/**
|
|
102
|
+
* Build a full `RequestContext` from an account id.
|
|
103
|
+
*
|
|
104
|
+
* Shared helper used by session, bearer, and daemon token middleware,
|
|
105
|
+
* as well as WebSocket upgrade handlers. Does the account → actor → permits
|
|
106
|
+
* lookup pipeline and returns the composed context, or `null` if
|
|
107
|
+
* the account or actor is not found.
|
|
108
|
+
*
|
|
109
|
+
* @param deps - query dependencies
|
|
110
|
+
* @param account_id - the account to build context for
|
|
111
|
+
* @returns a request context, or `null` if account/actor not found
|
|
112
|
+
*/
|
|
113
|
+
export declare const build_request_context: (deps: QueryDeps, account_id: string) => Promise<RequestContext | null>;
|
|
114
|
+
//# sourceMappingURL=request_context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request_context.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/request_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAC,OAAO,EAAE,iBAAiB,EAAC,MAAM,MAAM,CAAC;AACrD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAC,KAAK,OAAO,EAAE,KAAK,KAAK,EAAoB,KAAK,MAAM,EAAC,MAAM,qBAAqB,CAAC;AAQ5F,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAOnD,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACvB;AAED,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,GAAG,OAAO,KAAG,cAAc,GAAG,IAEjE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,GAAI,GAAG,OAAO,KAAG,cAMpD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ,GAAI,KAAK,cAAc,EAAE,MAAM,MAAM,EAAE,MAAK,IAAiB,KAAG,OAChB,CAAC;AAEtE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iCAAiC,GAC7C,MAAM,SAAS,EACf,KAAK,MAAM,EACX,4BAAuC,KACrC,iBAqCF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,iBAM1B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,KAAG,iBAW3C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,GAC3B,KAAK,cAAc,EACnB,MAAM,SAAS,KACb,OAAO,CAAC,cAAc,CAGxB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,GACjC,MAAM,SAAS,EACf,YAAY,MAAM,KAChB,OAAO,CAAC,cAAc,GAAG,IAAI,CAS/B,CAAC"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request context middleware and permit checking helpers.
|
|
3
|
+
*
|
|
4
|
+
* Builds `{ account, actor, permits }` from a session cookie
|
|
5
|
+
* for every authenticated request. Downstream handlers check
|
|
6
|
+
* permits, never flags.
|
|
7
|
+
*
|
|
8
|
+
* `build_request_context` is the shared helper used by session,
|
|
9
|
+
* bearer, and daemon token middleware to resolve account → actor → permits.
|
|
10
|
+
* `refresh_permits` reloads permits on an existing context.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import { is_permit_active } from './account_schema.js';
|
|
15
|
+
import { hash_session_token, session_touch_fire_and_forget, query_session_get_valid, } from './session_queries.js';
|
|
16
|
+
import { query_actor_by_account, query_account_by_id } from './account_queries.js';
|
|
17
|
+
import { query_permit_find_active_for_actor } from './permit_queries.js';
|
|
18
|
+
import { CREDENTIAL_TYPE_KEY } from '../hono_context.js';
|
|
19
|
+
import { ERROR_AUTHENTICATION_REQUIRED, ERROR_INSUFFICIENT_PERMISSIONS, } from '../http/error_schemas.js';
|
|
20
|
+
/** Hono context variable name for the request context. */
|
|
21
|
+
export const REQUEST_CONTEXT_KEY = 'request_context';
|
|
22
|
+
/**
|
|
23
|
+
* Get the request context from a Hono context, or `null` if unauthenticated.
|
|
24
|
+
*
|
|
25
|
+
* @param c - the Hono context
|
|
26
|
+
* @returns the request context, or `null`
|
|
27
|
+
*/
|
|
28
|
+
export const get_request_context = (c) => {
|
|
29
|
+
return c.get(REQUEST_CONTEXT_KEY) ?? null;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Get the request context, throwing if unauthenticated.
|
|
33
|
+
*
|
|
34
|
+
* Use in route handlers where auth middleware guarantees a context exists
|
|
35
|
+
* (i.e., routes with `auth: {type: 'authenticated'}` or stricter).
|
|
36
|
+
* Prefer this over `get_request_context(c)!` for explicit error handling.
|
|
37
|
+
*
|
|
38
|
+
* @param c - the Hono context
|
|
39
|
+
* @returns the request context (never null)
|
|
40
|
+
* @throws Error if no request context is set (middleware misconfiguration)
|
|
41
|
+
*/
|
|
42
|
+
export const require_request_context = (c) => {
|
|
43
|
+
const ctx = get_request_context(c);
|
|
44
|
+
if (!ctx) {
|
|
45
|
+
throw new Error('require_request_context: no request context — is auth middleware applied?');
|
|
46
|
+
}
|
|
47
|
+
return ctx;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Check if a request context has an active permit for a given role.
|
|
51
|
+
*
|
|
52
|
+
* Checks the permits already loaded in the context (no DB query).
|
|
53
|
+
*
|
|
54
|
+
* @param ctx - the request context
|
|
55
|
+
* @param role - the role to check
|
|
56
|
+
* @param now - current time (defaults to `new Date()`, pass for testability and hot-path efficiency)
|
|
57
|
+
* @returns `true` if the actor has an active permit for the role
|
|
58
|
+
*/
|
|
59
|
+
export const has_role = (ctx, role, now = new Date()) => ctx.permits.some((p) => p.role === role && is_permit_active(p, now));
|
|
60
|
+
/**
|
|
61
|
+
* Create middleware that builds the request context from a session cookie.
|
|
62
|
+
*
|
|
63
|
+
* Reads the session identity (set by session middleware), looks up
|
|
64
|
+
* the `auth_session`, loads account + actor + active permits, and
|
|
65
|
+
* sets the `RequestContext` on the Hono context.
|
|
66
|
+
*
|
|
67
|
+
* If the session is invalid or the account is not found, the context
|
|
68
|
+
* is set to `null` (unauthenticated). No 401 is returned — use
|
|
69
|
+
* `require_role` or `require_auth` for enforcement.
|
|
70
|
+
*
|
|
71
|
+
* @param deps - query dependencies (pool-level db for middleware)
|
|
72
|
+
* @param log - the logger instance
|
|
73
|
+
* @param session_context_key - the Hono context key where session middleware stored the session token
|
|
74
|
+
*/
|
|
75
|
+
export const create_request_context_middleware = (deps, log, session_context_key = 'auth_session_id') => {
|
|
76
|
+
return async (c, next) => {
|
|
77
|
+
const session_token = c.get(session_context_key) ?? null;
|
|
78
|
+
if (!session_token) {
|
|
79
|
+
c.set(REQUEST_CONTEXT_KEY, null);
|
|
80
|
+
c.set(CREDENTIAL_TYPE_KEY, null);
|
|
81
|
+
await next();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const token_hash = hash_session_token(session_token);
|
|
85
|
+
const session = await query_session_get_valid(deps, token_hash);
|
|
86
|
+
if (!session) {
|
|
87
|
+
c.set(REQUEST_CONTEXT_KEY, null);
|
|
88
|
+
c.set(CREDENTIAL_TYPE_KEY, null);
|
|
89
|
+
await next();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const ctx = await build_request_context(deps, session.account_id);
|
|
93
|
+
if (!ctx) {
|
|
94
|
+
c.set(REQUEST_CONTEXT_KEY, null);
|
|
95
|
+
c.set(CREDENTIAL_TYPE_KEY, null);
|
|
96
|
+
await next();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
c.set(REQUEST_CONTEXT_KEY, ctx);
|
|
100
|
+
c.set(CREDENTIAL_TYPE_KEY, 'session');
|
|
101
|
+
// Touch session (fire-and-forget, don't block the request)
|
|
102
|
+
void session_touch_fire_and_forget(deps, token_hash, c.var.pending_effects, log);
|
|
103
|
+
await next();
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Middleware that requires authentication.
|
|
108
|
+
*
|
|
109
|
+
* Returns 401 if no request context is set.
|
|
110
|
+
*/
|
|
111
|
+
export const require_auth = async (c, next) => {
|
|
112
|
+
const ctx = get_request_context(c);
|
|
113
|
+
if (!ctx) {
|
|
114
|
+
return c.json({ error: ERROR_AUTHENTICATION_REQUIRED }, 401);
|
|
115
|
+
}
|
|
116
|
+
await next();
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Create middleware that requires a specific role.
|
|
120
|
+
*
|
|
121
|
+
* Returns 401 if unauthenticated, 403 if the role is missing.
|
|
122
|
+
*
|
|
123
|
+
* @param role - the required role
|
|
124
|
+
*/
|
|
125
|
+
export const require_role = (role) => {
|
|
126
|
+
return async (c, next) => {
|
|
127
|
+
const ctx = get_request_context(c);
|
|
128
|
+
if (!ctx) {
|
|
129
|
+
return c.json({ error: ERROR_AUTHENTICATION_REQUIRED }, 401);
|
|
130
|
+
}
|
|
131
|
+
if (!has_role(ctx, role)) {
|
|
132
|
+
return c.json({ error: ERROR_INSUFFICIENT_PERMISSIONS, required_role: role }, 403);
|
|
133
|
+
}
|
|
134
|
+
await next();
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Reload active permits from the database, returning a new request context.
|
|
139
|
+
*
|
|
140
|
+
* Useful for long-lived WebSocket connections where permits may change
|
|
141
|
+
* (grant or revoke) during the connection lifetime. Call periodically
|
|
142
|
+
* or after receiving a revocation signal.
|
|
143
|
+
*
|
|
144
|
+
* Returns a new `RequestContext` with updated permits — the original
|
|
145
|
+
* context is not mutated, making concurrent calls safe.
|
|
146
|
+
*
|
|
147
|
+
* @param ctx - the request context to refresh
|
|
148
|
+
* @param deps - query dependencies
|
|
149
|
+
* @returns a new `RequestContext` with fresh permits
|
|
150
|
+
*/
|
|
151
|
+
export const refresh_permits = async (ctx, deps) => {
|
|
152
|
+
const permits = await query_permit_find_active_for_actor(deps, ctx.actor.id);
|
|
153
|
+
return { ...ctx, permits };
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Build a full `RequestContext` from an account id.
|
|
157
|
+
*
|
|
158
|
+
* Shared helper used by session, bearer, and daemon token middleware,
|
|
159
|
+
* as well as WebSocket upgrade handlers. Does the account → actor → permits
|
|
160
|
+
* lookup pipeline and returns the composed context, or `null` if
|
|
161
|
+
* the account or actor is not found.
|
|
162
|
+
*
|
|
163
|
+
* @param deps - query dependencies
|
|
164
|
+
* @param account_id - the account to build context for
|
|
165
|
+
* @returns a request context, or `null` if account/actor not found
|
|
166
|
+
*/
|
|
167
|
+
export const build_request_context = async (deps, account_id) => {
|
|
168
|
+
const account = await query_account_by_id(deps, account_id);
|
|
169
|
+
if (!account)
|
|
170
|
+
return null;
|
|
171
|
+
const actor = await query_actor_by_account(deps, account.id);
|
|
172
|
+
if (!actor)
|
|
173
|
+
return null;
|
|
174
|
+
const permits = await query_permit_find_active_for_actor(deps, actor.id);
|
|
175
|
+
return { account, actor, permits };
|
|
176
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeper credential type guard.
|
|
3
|
+
*
|
|
4
|
+
* Two-part check:
|
|
5
|
+
* 1. Credential type must be `daemon_token` (not session cookie, not API token).
|
|
6
|
+
* 2. Account must hold active keeper permit.
|
|
7
|
+
*
|
|
8
|
+
* Both must pass. A session cookie from the bootstrap account still fails check #1.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import type { MiddlewareHandler } from 'hono';
|
|
13
|
+
/**
|
|
14
|
+
* Middleware that requires keeper credentials.
|
|
15
|
+
*
|
|
16
|
+
* Returns 401 if unauthenticated, 403 if credential type is not
|
|
17
|
+
* `daemon_token` or if the keeper role is missing.
|
|
18
|
+
*/
|
|
19
|
+
export declare const require_keeper: MiddlewareHandler;
|
|
20
|
+
//# sourceMappingURL=require_keeper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require_keeper.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/require_keeper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,MAAM,CAAC;AAW5C;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,iBAmB5B,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeper credential type guard.
|
|
3
|
+
*
|
|
4
|
+
* Two-part check:
|
|
5
|
+
* 1. Credential type must be `daemon_token` (not session cookie, not API token).
|
|
6
|
+
* 2. Account must hold active keeper permit.
|
|
7
|
+
*
|
|
8
|
+
* Both must pass. A session cookie from the bootstrap account still fails check #1.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { get_request_context, has_role } from './request_context.js';
|
|
13
|
+
import { CREDENTIAL_TYPE_KEY } from '../hono_context.js';
|
|
14
|
+
import { ROLE_KEEPER } from './role_schema.js';
|
|
15
|
+
import { ERROR_AUTHENTICATION_REQUIRED, ERROR_INSUFFICIENT_PERMISSIONS, ERROR_KEEPER_REQUIRES_DAEMON_TOKEN, } from '../http/error_schemas.js';
|
|
16
|
+
/**
|
|
17
|
+
* Middleware that requires keeper credentials.
|
|
18
|
+
*
|
|
19
|
+
* Returns 401 if unauthenticated, 403 if credential type is not
|
|
20
|
+
* `daemon_token` or if the keeper role is missing.
|
|
21
|
+
*/
|
|
22
|
+
export const require_keeper = async (c, next) => {
|
|
23
|
+
const ctx = get_request_context(c);
|
|
24
|
+
if (!ctx) {
|
|
25
|
+
return c.json({ error: ERROR_AUTHENTICATION_REQUIRED }, 401);
|
|
26
|
+
}
|
|
27
|
+
const credential_type = c.get(CREDENTIAL_TYPE_KEY);
|
|
28
|
+
if (credential_type !== 'daemon_token') {
|
|
29
|
+
return c.json({ error: ERROR_KEEPER_REQUIRES_DAEMON_TOKEN, credential_type: credential_type ?? 'none' }, 403);
|
|
30
|
+
}
|
|
31
|
+
if (!has_role(ctx, ROLE_KEEPER)) {
|
|
32
|
+
return c.json({ error: ERROR_INSUFFICIENT_PERMISSIONS, required_role: ROLE_KEEPER }, 403);
|
|
33
|
+
}
|
|
34
|
+
await next();
|
|
35
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Role system — builtin roles, role options, and extensible role schema factory.
|
|
3
|
+
*
|
|
4
|
+
* Defines the authorization policy vocabulary: which roles exist, what
|
|
5
|
+
* capabilities they require (daemon token, web grantability), and a factory
|
|
6
|
+
* for extending with app-defined roles.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
/** Valid role name: lowercase letters and underscores, no leading/trailing underscore. */
|
|
12
|
+
export declare const RoleName: z.ZodString;
|
|
13
|
+
export type RoleName = z.infer<typeof RoleName>;
|
|
14
|
+
/** System-level role. Requires daemon token (filesystem proof). Controls the keep. */
|
|
15
|
+
export declare const ROLE_KEEPER = "keeper";
|
|
16
|
+
/** App-level administrative role. Web-grantable, manages users and content. */
|
|
17
|
+
export declare const ROLE_ADMIN = "admin";
|
|
18
|
+
/** The builtin role names as a const tuple. */
|
|
19
|
+
export declare const BUILTIN_ROLES: readonly ["keeper", "admin"];
|
|
20
|
+
/** Zod schema for builtin roles only. */
|
|
21
|
+
export declare const BuiltinRole: z.ZodEnum<{
|
|
22
|
+
keeper: "keeper";
|
|
23
|
+
admin: "admin";
|
|
24
|
+
}>;
|
|
25
|
+
export type BuiltinRole = z.infer<typeof BuiltinRole>;
|
|
26
|
+
/**
|
|
27
|
+
* Configuration for a role.
|
|
28
|
+
*
|
|
29
|
+
* Builtin roles have fixed configs. App-defined roles get sensible defaults
|
|
30
|
+
* (`requires_daemon_token: false`, `web_grantable: true`).
|
|
31
|
+
*/
|
|
32
|
+
export interface RoleOptions {
|
|
33
|
+
/** If true, exercising this role requires daemon token authentication. Only `keeper` for now. */
|
|
34
|
+
requires_daemon_token?: boolean;
|
|
35
|
+
/** If true, admins can grant this role via the web UI. Default `true`. */
|
|
36
|
+
web_grantable?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** Builtin role configs. Not overridable by consumers. */
|
|
39
|
+
export declare const BUILTIN_ROLE_OPTIONS: ReadonlyMap<string, Required<RoleOptions>>;
|
|
40
|
+
/** The result of `create_role_schema` — a Zod schema and config map for all roles. */
|
|
41
|
+
export interface RoleSchemaResult {
|
|
42
|
+
/** Zod schema that validates role strings. Use at I/O boundaries (grant endpoint, permit queries). */
|
|
43
|
+
Role: z.ZodType<string>;
|
|
44
|
+
/** Options for every role (builtins + app-defined). Keyed by role name. */
|
|
45
|
+
role_options: ReadonlyMap<string, Required<RoleOptions>>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a role schema and config map that extends the builtins with app-defined roles.
|
|
49
|
+
*
|
|
50
|
+
* Call once at server init. The returned `Role` schema validates role strings
|
|
51
|
+
* at I/O boundaries (grant endpoint, permit queries). The `role_options` map
|
|
52
|
+
* is used by middleware to check `requires_daemon_token` and by admin UI to
|
|
53
|
+
* filter `web_grantable` roles.
|
|
54
|
+
*
|
|
55
|
+
* @param app_roles - app-defined roles with optional config overrides
|
|
56
|
+
* @returns `{Role, role_options}` — Zod schema and full config map
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* // visiones
|
|
61
|
+
* const {Role, role_options} = create_role_schema({
|
|
62
|
+
* teacher: {},
|
|
63
|
+
* });
|
|
64
|
+
* // Role validates 'keeper' | 'admin' | 'teacher'
|
|
65
|
+
* // role_options has all 3 entries with defaults applied
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare const create_role_schema: <T extends string>(app_roles: Record<T, RoleOptions>) => RoleSchemaResult;
|
|
69
|
+
//# sourceMappingURL=role_schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"role_schema.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,0FAA0F;AAC1F,eAAO,MAAM,QAAQ,aAKnB,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAIhD,sFAAsF;AACtF,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,+EAA+E;AAC/E,eAAO,MAAM,UAAU,UAAU,CAAC;AAElC,+CAA+C;AAC/C,eAAO,MAAM,aAAa,8BAAqC,CAAC;AAEhE,yCAAyC;AACzC,eAAO,MAAM,WAAW;;;EAAwB,CAAC;AACjD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAItD;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B,iGAAiG;IACjG,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,0EAA0E;IAC1E,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,0DAA0D;AAC1D,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,CAG1E,CAAC;AAEH,sFAAsF;AACtF,MAAM,WAAW,gBAAgB;IAChC,sGAAsG;IACtG,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,2EAA2E;IAC3E,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;CACzD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,EAClD,WAAW,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,KAC/B,gBAwBF,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Role system — builtin roles, role options, and extensible role schema factory.
|
|
3
|
+
*
|
|
4
|
+
* Defines the authorization policy vocabulary: which roles exist, what
|
|
5
|
+
* capabilities they require (daemon token, web grantability), and a factory
|
|
6
|
+
* for extending with app-defined roles.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
/** Valid role name: lowercase letters and underscores, no leading/trailing underscore. */
|
|
12
|
+
export const RoleName = z
|
|
13
|
+
.string()
|
|
14
|
+
.regex(/^[a-z][a-z_]*[a-z]$|^[a-z]$/, 'Role names must be lowercase letters and underscores (a-z_), no leading/trailing underscore');
|
|
15
|
+
// Builtin roles — provided by fuz_app, always available.
|
|
16
|
+
/** System-level role. Requires daemon token (filesystem proof). Controls the keep. */
|
|
17
|
+
export const ROLE_KEEPER = 'keeper';
|
|
18
|
+
/** App-level administrative role. Web-grantable, manages users and content. */
|
|
19
|
+
export const ROLE_ADMIN = 'admin';
|
|
20
|
+
/** The builtin role names as a const tuple. */
|
|
21
|
+
export const BUILTIN_ROLES = [ROLE_KEEPER, ROLE_ADMIN];
|
|
22
|
+
/** Zod schema for builtin roles only. */
|
|
23
|
+
export const BuiltinRole = z.enum(BUILTIN_ROLES);
|
|
24
|
+
/** Builtin role configs. Not overridable by consumers. */
|
|
25
|
+
export const BUILTIN_ROLE_OPTIONS = new Map([
|
|
26
|
+
[ROLE_KEEPER, { requires_daemon_token: true, web_grantable: false }],
|
|
27
|
+
[ROLE_ADMIN, { requires_daemon_token: false, web_grantable: true }],
|
|
28
|
+
]);
|
|
29
|
+
/**
|
|
30
|
+
* Create a role schema and config map that extends the builtins with app-defined roles.
|
|
31
|
+
*
|
|
32
|
+
* Call once at server init. The returned `Role` schema validates role strings
|
|
33
|
+
* at I/O boundaries (grant endpoint, permit queries). The `role_options` map
|
|
34
|
+
* is used by middleware to check `requires_daemon_token` and by admin UI to
|
|
35
|
+
* filter `web_grantable` roles.
|
|
36
|
+
*
|
|
37
|
+
* @param app_roles - app-defined roles with optional config overrides
|
|
38
|
+
* @returns `{Role, role_options}` — Zod schema and full config map
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* // visiones
|
|
43
|
+
* const {Role, role_options} = create_role_schema({
|
|
44
|
+
* teacher: {},
|
|
45
|
+
* });
|
|
46
|
+
* // Role validates 'keeper' | 'admin' | 'teacher'
|
|
47
|
+
* // role_options has all 3 entries with defaults applied
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export const create_role_schema = (app_roles) => {
|
|
51
|
+
const app_role_names = Object.keys(app_roles);
|
|
52
|
+
// Validate role names and no collisions with builtins
|
|
53
|
+
for (const name of app_role_names) {
|
|
54
|
+
RoleName.parse(name);
|
|
55
|
+
if (BUILTIN_ROLE_OPTIONS.has(name)) {
|
|
56
|
+
throw new Error(`App role "${name}" collides with builtin role`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const all_names = [...BUILTIN_ROLES, ...app_role_names];
|
|
60
|
+
const Role = z.enum(all_names);
|
|
61
|
+
const role_options = new Map(BUILTIN_ROLE_OPTIONS);
|
|
62
|
+
for (const name of app_role_names) {
|
|
63
|
+
const config = app_roles[name];
|
|
64
|
+
role_options.set(name, {
|
|
65
|
+
requires_daemon_token: config.requires_daemon_token ?? false,
|
|
66
|
+
web_grantable: config.web_grantable ?? true,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return { Role, role_options };
|
|
70
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth guard resolver for the route spec system.
|
|
3
|
+
*
|
|
4
|
+
* Maps `RouteAuth` discriminants to auth middleware handlers.
|
|
5
|
+
* Injected into `apply_route_specs` to decouple the generic HTTP
|
|
6
|
+
* framework (`route_spec.ts`) from auth-specific middleware.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { AuthGuardResolver } from '../http/route_spec.js';
|
|
11
|
+
/**
|
|
12
|
+
* Standard auth guard resolver for fuz_app.
|
|
13
|
+
*
|
|
14
|
+
* Maps `RouteAuth` to middleware:
|
|
15
|
+
* - `none` → no guards
|
|
16
|
+
* - `authenticated` → `require_auth`
|
|
17
|
+
* - `role` → `require_role(role)`
|
|
18
|
+
* - `keeper` → `require_keeper`
|
|
19
|
+
*/
|
|
20
|
+
export declare const fuz_auth_guard_resolver: AuthGuardResolver;
|
|
21
|
+
//# sourceMappingURL=route_guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route_guards.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/route_guards.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AAE7D;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,EAAE,iBAWrC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth guard resolver for the route spec system.
|
|
3
|
+
*
|
|
4
|
+
* Maps `RouteAuth` discriminants to auth middleware handlers.
|
|
5
|
+
* Injected into `apply_route_specs` to decouple the generic HTTP
|
|
6
|
+
* framework (`route_spec.ts`) from auth-specific middleware.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { require_auth, require_role } from './request_context.js';
|
|
11
|
+
import { require_keeper } from './require_keeper.js';
|
|
12
|
+
/**
|
|
13
|
+
* Standard auth guard resolver for fuz_app.
|
|
14
|
+
*
|
|
15
|
+
* Maps `RouteAuth` to middleware:
|
|
16
|
+
* - `none` → no guards
|
|
17
|
+
* - `authenticated` → `require_auth`
|
|
18
|
+
* - `role` → `require_role(role)`
|
|
19
|
+
* - `keeper` → `require_keeper`
|
|
20
|
+
*/
|
|
21
|
+
export const fuz_auth_guard_resolver = (auth) => {
|
|
22
|
+
switch (auth.type) {
|
|
23
|
+
case 'none':
|
|
24
|
+
return [];
|
|
25
|
+
case 'authenticated':
|
|
26
|
+
return [require_auth];
|
|
27
|
+
case 'role':
|
|
28
|
+
return [require_role(auth.role)];
|
|
29
|
+
case 'keeper':
|
|
30
|
+
return [require_keeper];
|
|
31
|
+
}
|
|
32
|
+
};
|