@fuzdev/fuz_app 0.180.0 → 0.182.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/dist/actions/CLAUDE.md +38 -20
- package/dist/actions/action_rpc.d.ts +25 -6
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +56 -48
- package/dist/actions/action_types.d.ts +31 -13
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +1 -1
- package/dist/actions/notification_sender.d.ts +83 -0
- package/dist/actions/notification_sender.d.ts.map +1 -0
- package/dist/actions/notification_sender.js +85 -0
- package/dist/actions/perform_action.d.ts +13 -4
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +27 -18
- package/dist/actions/register_action_ws.d.ts +20 -2
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +17 -5
- package/dist/actions/ws_socket_session.d.ts +3 -0
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +3 -2
- package/dist/auth/CLAUDE.md +84 -59
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +30 -3
- package/dist/auth/account_queries.d.ts +213 -2
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +255 -2
- package/dist/auth/account_route_schema.d.ts +26 -16
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +10 -24
- package/dist/auth/account_routes.d.ts +5 -7
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +110 -89
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +117 -25
- package/dist/auth/api_token_queries.d.ts +29 -12
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +42 -27
- package/dist/auth/audit_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.d.ts +1 -1
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +10 -12
- package/dist/auth/audit_log_schema.js +4 -4
- package/dist/auth/bearer_auth.d.ts +4 -3
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +37 -32
- package/dist/auth/bootstrap_account.d.ts +65 -37
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +115 -66
- package/dist/auth/bootstrap_route_schema.d.ts +6 -2
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_route_schema.js +7 -2
- package/dist/auth/bootstrap_routes.d.ts +50 -33
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +109 -87
- package/dist/auth/bootstrap_token_store.d.ts +60 -0
- package/dist/auth/bootstrap_token_store.d.ts.map +1 -0
- package/dist/auth/bootstrap_token_store.js +39 -0
- package/dist/auth/credential_headers.d.ts +71 -0
- package/dist/auth/credential_headers.d.ts.map +1 -0
- package/dist/auth/credential_headers.js +100 -0
- package/dist/auth/daemon_token.d.ts +13 -1
- package/dist/auth/daemon_token.d.ts.map +1 -1
- package/dist/auth/daemon_token.js +14 -2
- package/dist/auth/daemon_token_middleware.d.ts +10 -11
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +39 -30
- package/dist/auth/deps.d.ts +10 -11
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/invite_queries.d.ts +18 -0
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +24 -0
- package/dist/auth/request_context.d.ts +97 -76
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +93 -104
- package/dist/auth/resolved_auth.d.ts +10 -5
- package/dist/auth/resolved_auth.d.ts.map +1 -1
- package/dist/auth/resolved_auth.js +2 -2
- package/dist/auth/role_grant_offer_action_specs.d.ts +2 -2
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +5 -3
- package/dist/auth/role_grant_offer_actions.d.ts +7 -11
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +97 -106
- package/dist/auth/role_grant_offer_ddl.d.ts +7 -1
- package/dist/auth/role_grant_offer_ddl.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_ddl.js +9 -2
- package/dist/auth/role_grant_offer_notifications.d.ts +87 -38
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_notifications.js +75 -22
- package/dist/auth/role_grant_offer_queries.d.ts +143 -9
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +266 -66
- package/dist/auth/role_grant_offer_schema.js +1 -1
- package/dist/auth/role_grant_queries.d.ts +57 -10
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +81 -22
- package/dist/auth/role_grant_sql.d.ts +21 -0
- package/dist/auth/role_grant_sql.d.ts.map +1 -1
- package/dist/auth/role_grant_sql.js +21 -0
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +9 -2
- package/dist/auth/session_cookie.d.ts +105 -25
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +124 -15
- package/dist/auth/session_middleware.d.ts +83 -54
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +92 -66
- package/dist/auth/session_queries.d.ts +95 -14
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +98 -19
- package/dist/auth/signup_route_schema.d.ts +5 -5
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +4 -4
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +17 -14
- package/dist/auth/standard_rpc_actions.d.ts +6 -19
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/standard_rpc_actions.js +5 -6
- package/dist/auth/token_scope.d.ts +6 -8
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +6 -9
- package/dist/dev/setup.d.ts +6 -1
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +42 -34
- package/dist/hono_context.d.ts +21 -0
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +17 -0
- package/dist/http/CLAUDE.md +156 -48
- package/dist/http/auth_shape.d.ts +4 -4
- package/dist/http/common_routes.js +1 -1
- package/dist/http/db_routes.d.ts +4 -3
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +14 -14
- package/dist/http/dev_route_error_check.d.ts +6 -3
- package/dist/http/dev_route_error_check.d.ts.map +1 -1
- package/dist/http/dev_route_error_check.js +6 -3
- package/dist/http/dev_set_cookie_check.d.ts +53 -0
- package/dist/http/dev_set_cookie_check.d.ts.map +1 -0
- package/dist/http/dev_set_cookie_check.js +80 -0
- package/dist/http/error_schemas.d.ts +45 -22
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +53 -26
- package/dist/http/header_lines.d.ts +42 -0
- package/dist/http/header_lines.d.ts.map +1 -0
- package/dist/http/header_lines.js +80 -0
- package/dist/http/host.d.ts +12 -9
- package/dist/http/host.d.ts.map +1 -1
- package/dist/http/host.js +25 -20
- package/dist/http/origin.d.ts +7 -22
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +11 -25
- package/dist/http/proxy.d.ts +1 -0
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +3 -0
- package/dist/http/request_headers.d.ts +95 -0
- package/dist/http/request_headers.d.ts.map +1 -0
- package/dist/http/request_headers.js +110 -0
- package/dist/http/request_target.d.ts +134 -0
- package/dist/http/request_target.d.ts.map +1 -0
- package/dist/http/request_target.js +193 -0
- package/dist/http/route_error_check.d.ts +4 -11
- package/dist/http/route_error_check.d.ts.map +1 -1
- package/dist/http/route_error_check.js +4 -21
- package/dist/http/route_result.d.ts +127 -23
- package/dist/http/route_result.d.ts.map +1 -1
- package/dist/http/route_result.js +97 -19
- package/dist/http/route_spec.d.ts +299 -83
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +548 -71
- package/dist/http/simple_request.d.ts +19 -14
- package/dist/http/simple_request.d.ts.map +1 -1
- package/dist/http/simple_request.js +17 -29
- package/dist/http/surface.d.ts +2 -0
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +4 -1
- package/dist/realtime/outbound_budget.d.ts +1 -2
- package/dist/realtime/outbound_budget.d.ts.map +1 -1
- package/dist/realtime/outbound_budget.js +1 -2
- package/dist/realtime/sse.d.ts +47 -17
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +115 -93
- package/dist/realtime/sse_constants.d.ts +7 -1
- package/dist/realtime/sse_constants.d.ts.map +1 -1
- package/dist/realtime/sse_constants.js +12 -1
- package/dist/realtime/sse_registry.d.ts +3 -3
- package/dist/realtime/sse_registry.js +3 -3
- package/dist/runtime/deps.d.ts +20 -4
- package/dist/runtime/deps.d.ts.map +1 -1
- package/dist/runtime/mock.d.ts +7 -1
- package/dist/runtime/mock.d.ts.map +1 -1
- package/dist/runtime/mock.js +33 -3
- package/dist/runtime/node.d.ts.map +1 -1
- package/dist/runtime/node.js +2 -1
- package/dist/runtime/secure_file.d.ts +71 -10
- package/dist/runtime/secure_file.d.ts.map +1 -1
- package/dist/runtime/secure_file.js +91 -11
- package/dist/server/app_backend.d.ts +0 -8
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +4 -4
- package/dist/server/app_server.d.ts +54 -33
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +69 -41
- package/dist/server/serve_fact_route.d.ts +3 -3
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +59 -55
- package/dist/server/static.d.ts +20 -0
- package/dist/server/static.d.ts.map +1 -1
- package/dist/server/static.js +56 -8
- package/dist/server/unmatched_route.d.ts +42 -0
- package/dist/server/unmatched_route.d.ts.map +1 -0
- package/dist/server/unmatched_route.js +64 -0
- package/dist/testing/CLAUDE.md +406 -1202
- package/dist/testing/app_server.d.ts +3 -1
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +5 -9
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +3 -2
- package/dist/testing/cross_backend/account_lifecycle.d.ts +11 -4
- package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/account_lifecycle.js +320 -6
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts +4 -1
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
- package/dist/testing/cross_backend/build_test_backend_paths.js +1 -1
- package/dist/testing/cross_backend/capabilities.d.ts +68 -5
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/capabilities.js +20 -4
- package/dist/testing/cross_backend/cell_gated_create.js +1 -1
- package/dist/testing/cross_backend/conformance_case.d.ts +63 -21
- package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.d.ts +54 -12
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +179 -23
- package/dist/testing/cross_backend/cookie_attributes.js +1 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +7 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +3 -3
- package/dist/testing/cross_backend/credential_conformance.d.ts +196 -0
- package/dist/testing/cross_backend/credential_conformance.d.ts.map +1 -0
- package/dist/testing/cross_backend/credential_conformance.js +296 -0
- package/dist/testing/cross_backend/credential_conformance.json +1284 -0
- package/dist/testing/cross_backend/credential_conformance_wire.d.ts +40 -0
- package/dist/testing/cross_backend/credential_conformance_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/credential_conformance_wire.js +293 -0
- package/dist/testing/cross_backend/credential_header_robustness.d.ts +1 -3
- package/dist/testing/cross_backend/credential_header_robustness.d.ts.map +1 -1
- package/dist/testing/cross_backend/credential_header_robustness.js +24 -55
- package/dist/testing/cross_backend/credential_wire.d.ts +112 -0
- package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/credential_wire.js +188 -0
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +22 -2
- package/dist/testing/cross_backend/default_spine_surface.d.ts +1 -26
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +3 -7
- package/dist/testing/cross_backend/differential.d.ts +1 -1
- package/dist/testing/cross_backend/differential.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential.js +3 -2
- package/dist/testing/cross_backend/differential_normalize.d.ts +23 -6
- package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential_normalize.js +11 -5
- package/dist/testing/cross_backend/full_spine_mount.d.ts +4 -10
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +11 -4
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +4 -0
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +78 -4
- package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
- package/dist/testing/cross_backend/login_security.js +13 -10
- package/dist/testing/cross_backend/peer_ping_ws.d.ts +1 -1
- package/dist/testing/cross_backend/peer_ping_ws.js +2 -2
- package/dist/testing/cross_backend/request_header_conformance.d.ts +174 -0
- package/dist/testing/cross_backend/request_header_conformance.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_header_conformance.js +196 -0
- package/dist/testing/cross_backend/request_header_conformance.json +1158 -0
- package/dist/testing/cross_backend/request_header_conformance_wire.d.ts +39 -0
- package/dist/testing/cross_backend/request_header_conformance_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_header_conformance_wire.js +284 -0
- package/dist/testing/cross_backend/request_target_conformance.d.ts +298 -0
- package/dist/testing/cross_backend/request_target_conformance.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_target_conformance.js +186 -0
- package/dist/testing/cross_backend/request_target_conformance.json +3765 -0
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +32 -0
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -0
- package/dist/testing/cross_backend/request_target_conformance_wire.js +278 -0
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +173 -1
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +5 -4
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +185 -31
- package/dist/testing/cross_backend/rpc_adversarial.d.ts +6 -4
- package/dist/testing/cross_backend/rpc_adversarial.d.ts.map +1 -1
- package/dist/testing/cross_backend/rpc_adversarial.js +5 -2
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +6 -7
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +4 -5
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +82 -34
- package/dist/testing/cross_backend/session_cookie_effect.d.ts +43 -0
- package/dist/testing/cross_backend/session_cookie_effect.d.ts.map +1 -0
- package/dist/testing/cross_backend/session_cookie_effect.js +103 -0
- package/dist/testing/cross_backend/session_login.d.ts +24 -0
- package/dist/testing/cross_backend/session_login.d.ts.map +1 -0
- package/dist/testing/cross_backend/session_login.js +31 -0
- package/dist/testing/cross_backend/setup.d.ts +117 -0
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +193 -9
- package/dist/testing/cross_backend/simple_request.d.ts.map +1 -1
- package/dist/testing/cross_backend/simple_request.js +5 -0
- package/dist/testing/cross_backend/spine_suites.d.ts +9 -1
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +88 -5
- package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
- package/dist/testing/cross_backend/sse_round_trip.d.ts +8 -5
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +205 -64
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +5 -2
- package/dist/testing/cross_backend/testing_credential_read.d.ts +165 -0
- package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -0
- package/dist/testing/cross_backend/testing_credential_read.js +175 -0
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +19 -0
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +22 -6
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +58 -2
- package/dist/testing/cross_backend/transport_composition.d.ts +2 -4
- package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
- package/dist/testing/cross_backend/transport_composition.js +13 -10
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +5 -3
- package/dist/testing/cross_backend/ws_endpoint.d.ts +11 -1
- package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_endpoint.js +19 -2
- package/dist/testing/cross_backend/ws_role_gated.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_role_gated.js +2 -3
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +28 -12
- package/dist/testing/cross_backend/xfail.d.ts +44 -11
- package/dist/testing/cross_backend/xfail.d.ts.map +1 -1
- package/dist/testing/cross_backend/xfail.js +68 -23
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +4 -3
- package/dist/testing/integration.d.ts +1 -2
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +14 -8
- package/dist/testing/integration_helpers.d.ts +50 -3
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +87 -9
- package/dist/testing/middleware.d.ts +3 -1
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +14 -7
- package/dist/testing/resolved_auth.d.ts +3 -1
- package/dist/testing/resolved_auth.d.ts.map +1 -1
- package/dist/testing/resolved_auth.js +4 -4
- package/dist/testing/round_trip.d.ts +6 -2
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +17 -6
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +7 -0
- package/dist/testing/rpc_helpers.d.ts +4 -2
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +6 -1
- package/dist/testing/rpc_round_trip.d.ts +13 -2
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +25 -6
- package/dist/testing/schema_generators.d.ts +2 -2
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +4 -4
- package/dist/testing/stubs.d.ts +2 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +13 -10
- package/dist/testing/transports/fetch_transport.d.ts +6 -3
- package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
- package/dist/testing/transports/fetch_transport.js +31 -19
- package/dist/testing/transports/raw_http.d.ts +61 -1
- package/dist/testing/transports/raw_http.d.ts.map +1 -1
- package/dist/testing/transports/raw_http.js +61 -1
- package/dist/testing/transports/ws_raw_client.d.ts +20 -0
- package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
- package/dist/testing/transports/ws_raw_client.js +10 -4
- package/dist/testing/transports/ws_transport.d.ts +21 -1
- package/dist/testing/transports/ws_transport.d.ts.map +1 -1
- package/dist/testing/transports/ws_transport.js +58 -20
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +8 -4
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hono-free wire schemas + route shapes for the account REST routes.
|
|
3
3
|
*
|
|
4
|
-
* Split from `account_routes.ts` (whose handlers
|
|
5
|
-
* `session_middleware`) so cross-process test suites can build the account
|
|
4
|
+
* Split from `account_routes.ts` (whose handlers mint and end sessions through
|
|
5
|
+
* `session_middleware` and the query layer) so cross-process test suites can build the account
|
|
6
6
|
* route shapes — and assert on the `POST /login` / `GET /api/account/status`
|
|
7
|
-
* response shapes — without dragging the in-process
|
|
8
|
-
*
|
|
7
|
+
* response shapes — without dragging the in-process session handlers and
|
|
8
|
+
* their queries onto a backend-spawning consumer. `account_routes.ts`
|
|
9
9
|
* imports these back and attaches the live handlers; single source of truth
|
|
10
10
|
* for the wire shape.
|
|
11
11
|
*
|
|
@@ -16,7 +16,7 @@ import { ActorSummaryJson, RoleGrantSummaryJson, SessionAccountJson } from './ac
|
|
|
16
16
|
import { UsernameCanonical, UsernameProvided } from '../primitive_schemas.js';
|
|
17
17
|
import { Password, PasswordProvided } from './password.js';
|
|
18
18
|
import { define_route_shape } from '../http/route_spec.js';
|
|
19
|
-
import { REST_AUTHENTICATION_REQUIRED_BOOTSTRAP, REST_INVALID_CREDENTIALS } from '../http/error_schemas.js';
|
|
19
|
+
import { REST_AUTHENTICATION_REQUIRED_BOOTSTRAP, REST_INVALID_CREDENTIALS, REST_INVALID_QUERY_PARAMS } from '../http/error_schemas.js';
|
|
20
20
|
/** Input for `GET /api/account/status`, `literal(null)`. No parameters — caller is the subject. */
|
|
21
21
|
export const AccountStatusInput = literal(null);
|
|
22
22
|
/** Output for `GET /api/account/status`, a `@fuzdev/fuz_schema` schema. */
|
|
@@ -88,7 +88,7 @@ export const DEFAULT_MAX_TOKENS = 10;
|
|
|
88
88
|
* context; surface generation attaches a stub.
|
|
89
89
|
*
|
|
90
90
|
* The path is **relative** like the sibling account shapes (`/login`,
|
|
91
|
-
* `/
|
|
91
|
+
* `/logout`), so it composes under `prefix_route_specs('/api/account', …)` into
|
|
92
92
|
* `/api/account/status`. `create_account_route_specs` bundles it (so every
|
|
93
93
|
* account surface serves `/status`, matching the Rust `account_router`);
|
|
94
94
|
* mirror Rust by mounting it as part of the account family, not separately.
|
|
@@ -103,35 +103,21 @@ export const account_status_route_shape = define_route_shape({
|
|
|
103
103
|
description: 'Current account info (unauthenticated: 401 with bootstrap status)',
|
|
104
104
|
input: AccountStatusInput,
|
|
105
105
|
output: AccountStatusOutput,
|
|
106
|
-
|
|
106
|
+
// the query is read after the anonymous 401, decoded strictly
|
|
107
|
+
errors: [REST_AUTHENTICATION_REQUIRED_BOOTSTRAP, REST_INVALID_QUERY_PARAMS]
|
|
107
108
|
});
|
|
108
109
|
/**
|
|
109
|
-
* The
|
|
110
|
+
* The account route shapes (`/login`, `/logout`, `/password`)
|
|
110
111
|
* minus their handlers — pure hono-free data. `create_account_route_specs`
|
|
111
112
|
* attaches the live handler to each (`attach_route_handler`); cross-process
|
|
112
113
|
* surface builders attach stubs (`stub_route_spec`). Single source of truth —
|
|
113
114
|
* the shapes can't drift between the live routes and the surface.
|
|
114
115
|
*
|
|
115
|
-
* Returns a fixed
|
|
116
|
+
* Returns a fixed tuple `[login, logout, password]` so destructuring
|
|
116
117
|
* yields non-optional shapes under `noUncheckedIndexedAccess`, each with the
|
|
117
118
|
* types `attach_route_handler` checks its handler against.
|
|
118
119
|
*/
|
|
119
120
|
export const create_account_route_shapes = (options) => [
|
|
120
|
-
define_route_shape({
|
|
121
|
-
method: 'GET',
|
|
122
|
-
path: '/verify',
|
|
123
|
-
// a non-RPC surface: the probe answers 200 for the account behind a
|
|
124
|
-
// credential, so a narrowed token is refused it (it would otherwise pass
|
|
125
|
-
// an nginx `auth_request` gate as its account)
|
|
126
|
-
auth: {
|
|
127
|
-
account: 'required',
|
|
128
|
-
actor: 'none',
|
|
129
|
-
required_scope: 'surface:account_verify'
|
|
130
|
-
},
|
|
131
|
-
description: 'Session-validity probe for nginx auth_request (empty body; 200, 401, or 403 for a narrowed token)',
|
|
132
|
-
input: literal(null),
|
|
133
|
-
output: literal(null)
|
|
134
|
-
}),
|
|
135
121
|
define_route_shape({
|
|
136
122
|
method: 'POST',
|
|
137
123
|
path: '/login',
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Returns `RouteSpec[]` — caller applies them to Hono via `apply_route_specs`.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* These REST flows remain here, each with a concrete reason to stay REST
|
|
7
7
|
* rather than moving to `auth/account_actions.ts`:
|
|
8
8
|
*
|
|
9
9
|
* - `POST /login` — issues a signed `Set-Cookie` and pre-handler rate-limits
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
* - `POST /logout` — clears the session cookie.
|
|
12
12
|
* - `POST /password` — cookie clear + revoke-all cascade; rate-limit-shaped
|
|
13
13
|
* error envelope on 429.
|
|
14
|
-
* - `GET /verify` — empty-body nginx `auth_request` probe. Programmatic
|
|
15
|
-
* callers should use the `account_verify` RPC action for the typed payload.
|
|
16
14
|
*
|
|
17
15
|
* Session listing/revocation and API token CRUD are on the RPC endpoint —
|
|
18
16
|
* see `auth/account_actions.ts`. Signup is in `auth/signup_routes.ts`. Defaults are
|
|
@@ -21,7 +19,7 @@
|
|
|
21
19
|
*
|
|
22
20
|
* @module
|
|
23
21
|
*/
|
|
24
|
-
import type
|
|
22
|
+
import { type SessionOptions } from './session_cookie.js';
|
|
25
23
|
import { type RouteSpec } from '../http/route_spec.js';
|
|
26
24
|
import { type RateLimiter } from '../rate_limiter.js';
|
|
27
25
|
import type { RouteFactoryDeps } from './deps.js';
|
|
@@ -38,7 +36,7 @@ import type { RouteFactoryDeps } from './deps.js';
|
|
|
38
36
|
* its verification state, and the acting actor's role grants; the route
|
|
39
37
|
* already answers anonymous callers, so that answer is the refusal — a 403
|
|
40
38
|
* would tell the holder nothing that dropping the header doesn't. The handler
|
|
41
|
-
* reads the credential through `
|
|
39
|
+
* reads the credential through `get_public_account`, which applies it.
|
|
42
40
|
*
|
|
43
41
|
* This eliminates the need for a separate `/health` fetch on page load —
|
|
44
42
|
* the frontend gets both session state and bootstrap availability in one request.
|
|
@@ -136,8 +134,8 @@ export interface AccountRouteOptions extends AuthSessionRouteOptions {
|
|
|
136
134
|
* Create account route specs for session-based auth.
|
|
137
135
|
*
|
|
138
136
|
* The returned specs cover the REST flows that stay after the RPC migration:
|
|
139
|
-
* `/status` (account info + bootstrap availability), `/
|
|
140
|
-
*
|
|
137
|
+
* `/status` (account info + bootstrap availability), `/login`, `/logout`,
|
|
138
|
+
* `/password`. `/status` is bundled
|
|
141
139
|
* here (relative path, prefixed to `/api/account/status` by the caller) so
|
|
142
140
|
* every account surface serves it, matching the Rust `account_router`.
|
|
143
141
|
* Self-service session/token management is on `auth/account_actions.ts`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_routes.d.ts","sourceRoot":"","sources":["../../src/lib/auth/account_routes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"account_routes.d.ts","sourceRoot":"","sources":["../../src/lib/auth/account_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,qBAAqB,CAAC;AAyB7B,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAI7E,OAAO,EAAoB,KAAK,WAAW,EAA6B,MAAM,oBAAoB,CAAC;AACnG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAclD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,gCAAgC,GAAI,UAAU,oBAAoB,KAAG,SAiFjF,CAAC;AAEF,iDAAiD;AACjD,MAAM,WAAW,oBAAoB;IACpC,yDAAyD;IACzD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8FAA8F;IAC9F,gBAAgB,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1C;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAE/C;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,uBAAuB;IACvC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IACnE;;;;;;;OAOG;IACH,qBAAqB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1C,4FAA4F;IAC5F,0BAA0B,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/C,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;CAC1C;AAID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,0BAA0B,GACtC,MAAM,gBAAgB,EACtB,SAAS,mBAAmB,KAC1B,KAAK,CAAC,SAAS,CAkXjB,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Returns `RouteSpec[]` — caller applies them to Hono via `apply_route_specs`.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* These REST flows remain here, each with a concrete reason to stay REST
|
|
7
7
|
* rather than moving to `auth/account_actions.ts`:
|
|
8
8
|
*
|
|
9
9
|
* - `POST /login` — issues a signed `Set-Cookie` and pre-handler rate-limits
|
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
* - `POST /logout` — clears the session cookie.
|
|
12
12
|
* - `POST /password` — cookie clear + revoke-all cascade; rate-limit-shaped
|
|
13
13
|
* error envelope on 429.
|
|
14
|
-
* - `GET /verify` — empty-body nginx `auth_request` probe. Programmatic
|
|
15
|
-
* callers should use the `account_verify` RPC action for the typed payload.
|
|
16
14
|
*
|
|
17
15
|
* Session listing/revocation and API token CRUD are on the RPC endpoint —
|
|
18
16
|
* see `auth/account_actions.ts`. Signup is in `auth/signup_routes.ts`. Defaults are
|
|
@@ -21,23 +19,23 @@
|
|
|
21
19
|
*
|
|
22
20
|
* @module
|
|
23
21
|
*/
|
|
24
|
-
import {
|
|
22
|
+
import { clear_session_cookie_header, session_cookie_header } from './session_cookie.js';
|
|
25
23
|
import { RoleGrantSummaryJson, to_session_account } from './account_schema.js';
|
|
26
24
|
import { account_status_route_shape, create_account_route_shapes, DEFAULT_MAX_SESSIONS } from './account_route_schema.js';
|
|
27
|
-
import { query_session_revoke_all_for_account, query_session_revoke_by_hash_unscoped } from './session_queries.js';
|
|
28
|
-
import { query_account_by_username_or_email, query_update_account_password } from './account_queries.js';
|
|
25
|
+
import { create_capped_session, query_session_revoke_all_for_account, query_session_revoke_by_hash_unscoped } from './session_queries.js';
|
|
26
|
+
import { query_account_by_id, query_account_by_username_or_email, query_account_lock_verified, query_update_account_password } from './account_queries.js';
|
|
29
27
|
import { query_revoke_all_api_tokens_for_account } from './api_token_queries.js';
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import { attach_route_handler
|
|
33
|
-
import { route_fail, route_ok
|
|
34
|
-
import { get_client_ip } from '../http/client_ip.js';
|
|
28
|
+
import { build_request_context, get_public_account, resolve_acting_actor } from './request_context.js';
|
|
29
|
+
import { resolved_auth_session_hash } from './resolved_auth.js';
|
|
30
|
+
import { attach_route_handler } from '../http/route_spec.js';
|
|
31
|
+
import { route_fail, route_ok } from '../http/route_result.js';
|
|
35
32
|
import { rate_limit_ip_key } from '../http/ip_canonical.js';
|
|
36
33
|
import { parse_acting } from '../http/auth_shape.js';
|
|
37
34
|
import { reserve_optional } from '../rate_limiter.js';
|
|
38
35
|
import { start_fail_floor, warn_if_fail_floor_disabled } from './fail_floor.js';
|
|
39
36
|
import { close_connections_after_commit, queue_connection_close } from '../actions/connection_closer.js';
|
|
40
|
-
import { REST_AUTHENTICATION_REQUIRED_BOOTSTRAP, REST_INVALID_CREDENTIALS, REST_RATE_LIMIT_EXCEEDED } from '../http/error_schemas.js';
|
|
37
|
+
import { REST_AUTHENTICATION_REQUIRED_BOOTSTRAP, REST_INVALID_CREDENTIALS, REST_INVALID_QUERY_PARAMS, REST_RATE_LIMIT_EXCEEDED } from '../http/error_schemas.js';
|
|
38
|
+
import { query_first } from '../http/request_target.js';
|
|
41
39
|
/**
|
|
42
40
|
* Create the account status route spec.
|
|
43
41
|
*
|
|
@@ -51,7 +49,7 @@ import { REST_AUTHENTICATION_REQUIRED_BOOTSTRAP, REST_INVALID_CREDENTIALS, REST_
|
|
|
51
49
|
* its verification state, and the acting actor's role grants; the route
|
|
52
50
|
* already answers anonymous callers, so that answer is the refusal — a 403
|
|
53
51
|
* would tell the holder nothing that dropping the header doesn't. The handler
|
|
54
|
-
* reads the credential through `
|
|
52
|
+
* reads the credential through `get_public_account`, which applies it.
|
|
55
53
|
*
|
|
56
54
|
* This eliminates the need for a separate `/health` fetch on page load —
|
|
57
55
|
* the frontend gets both session state and bootstrap availability in one request.
|
|
@@ -67,16 +65,16 @@ export const create_account_status_route_spec = (options) => {
|
|
|
67
65
|
return attach_route_handler({
|
|
68
66
|
...account_status_route_shape,
|
|
69
67
|
path: options?.path ?? account_status_route_shape.path
|
|
70
|
-
}, async (
|
|
68
|
+
}, async (route) => {
|
|
71
69
|
// a narrowed token is the anonymous caller here, never a refusal
|
|
72
|
-
const account_id =
|
|
70
|
+
const account_id = get_public_account(route)?.id;
|
|
73
71
|
if (!account_id)
|
|
74
72
|
return fail_anonymous();
|
|
75
73
|
// Honor a pre-populated request context. The dispatcher's authorization
|
|
76
74
|
// phase doesn't run for `auth: 'none'` routes, but a caller (test
|
|
77
75
|
// harness, or future middleware) may still populate the context — use
|
|
78
76
|
// it directly to avoid redundant lookups.
|
|
79
|
-
const existing =
|
|
77
|
+
const existing = route.auth;
|
|
80
78
|
if (existing && existing.account.id === account_id) {
|
|
81
79
|
const role_grants = existing.role_grants.map((p) => ({
|
|
82
80
|
id: p.id,
|
|
@@ -99,35 +97,41 @@ export const create_account_status_route_spec = (options) => {
|
|
|
99
97
|
// surface a persona picker. The selector goes through the `ActingActor`
|
|
100
98
|
// schema, lowercased; a malformed value is a missing persona —
|
|
101
99
|
// account-only, never a default-actor resolve (as on the Rust spine).
|
|
102
|
-
|
|
100
|
+
// A query that doesn't decode is refused here, where it is read —
|
|
101
|
+
// after the anonymous 401, so a caller with no account learns nothing
|
|
102
|
+
// of the query.
|
|
103
|
+
if (!route.query_pairs.ok)
|
|
104
|
+
return route_fail(REST_INVALID_QUERY_PARAMS);
|
|
105
|
+
const acting_raw = query_first(route.query_pairs.value, 'acting');
|
|
103
106
|
const acting = parse_acting(acting_raw);
|
|
107
|
+
// The account read again for the answer, live (`deleted_at IS NULL`),
|
|
108
|
+
// as the Rust twin's summary read is: one deleted or purged since the
|
|
109
|
+
// credential leg is the anonymous caller.
|
|
110
|
+
const account = await query_account_by_id(route, account_id);
|
|
111
|
+
if (!account)
|
|
112
|
+
return fail_anonymous();
|
|
104
113
|
const acting_result = acting_raw !== undefined && acting === undefined
|
|
105
114
|
? null
|
|
106
|
-
: await resolve_acting_actor(route,
|
|
115
|
+
: await resolve_acting_actor(route, account.id, acting);
|
|
107
116
|
if (acting_result?.ok) {
|
|
108
|
-
const ctx = await build_request_context(route,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
});
|
|
124
|
-
}
|
|
117
|
+
const ctx = await build_request_context(route, account, acting_result.actor);
|
|
118
|
+
const role_grants = ctx.role_grants.map((p) => ({
|
|
119
|
+
id: p.id,
|
|
120
|
+
role: p.role,
|
|
121
|
+
scope_kind: p.scope_kind,
|
|
122
|
+
scope_id: p.scope_id,
|
|
123
|
+
created_at: p.created_at,
|
|
124
|
+
expires_at: p.expires_at,
|
|
125
|
+
granted_by: p.granted_by
|
|
126
|
+
}));
|
|
127
|
+
return route_ok({
|
|
128
|
+
account: to_session_account(ctx.account),
|
|
129
|
+
actor: { id: ctx.actor.id, name: ctx.actor.name },
|
|
130
|
+
role_grants
|
|
131
|
+
});
|
|
125
132
|
}
|
|
126
|
-
const account_ctx = await build_account_context(route, account_id);
|
|
127
|
-
if (!account_ctx)
|
|
128
|
-
return fail_anonymous();
|
|
129
133
|
return route_ok({
|
|
130
|
-
account: to_session_account(
|
|
134
|
+
account: to_session_account(account),
|
|
131
135
|
actor: null,
|
|
132
136
|
role_grants: []
|
|
133
137
|
});
|
|
@@ -158,8 +162,8 @@ export const DEFAULT_LOGIN_FAIL_JITTER_MS = 25;
|
|
|
158
162
|
* Create account route specs for session-based auth.
|
|
159
163
|
*
|
|
160
164
|
* The returned specs cover the REST flows that stay after the RPC migration:
|
|
161
|
-
* `/status` (account info + bootstrap availability), `/
|
|
162
|
-
*
|
|
165
|
+
* `/status` (account info + bootstrap availability), `/login`, `/logout`,
|
|
166
|
+
* `/password`. `/status` is bundled
|
|
163
167
|
* here (relative path, prefixed to `/api/account/status` by the caller) so
|
|
164
168
|
* every account surface serves it, matching the Rust `account_router`.
|
|
165
169
|
* Self-service session/token management is on `auth/account_actions.ts`.
|
|
@@ -181,7 +185,7 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
181
185
|
const { keyring, password, connection_closer } = deps;
|
|
182
186
|
const { session_options, login_ip_rate_limiter, login_account_rate_limiter, max_sessions = DEFAULT_MAX_SESSIONS, login_fail_floor_ms = DEFAULT_LOGIN_FAIL_FLOOR_MS, login_fail_jitter_ms = DEFAULT_LOGIN_FAIL_JITTER_MS, bootstrap_status } = options;
|
|
183
187
|
warn_if_fail_floor_disabled('login', login_fail_floor_ms, deps.log);
|
|
184
|
-
const [
|
|
188
|
+
const [login_shape, logout_shape, password_shape] = create_account_route_shapes({
|
|
185
189
|
login_account_rate_limited: login_account_rate_limiter !== null
|
|
186
190
|
});
|
|
187
191
|
return [
|
|
@@ -190,12 +194,7 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
190
194
|
// it — matching the Rust `account_router`. The standalone
|
|
191
195
|
// `create_account_status_route_spec` stays the building block.
|
|
192
196
|
create_account_status_route_spec({ bootstrap_status }),
|
|
193
|
-
attach_route_handler(
|
|
194
|
-
require_request_context(c);
|
|
195
|
-
// the probe's answer is its status alone, an empty body
|
|
196
|
-
return route_raw(c.body(null, 200));
|
|
197
|
-
}),
|
|
198
|
-
attach_route_handler(login_shape, async (c, route) => {
|
|
197
|
+
attach_route_handler(login_shape, async (route) => {
|
|
199
198
|
// Per-IP rate limit (before any DB/password work). Reserved, not
|
|
200
199
|
// checked: the attempt counts against the cap from here until it
|
|
201
200
|
// settles, so a concurrent burst can't all pass before any of it
|
|
@@ -208,9 +207,9 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
208
207
|
// address exceed its cap meanwhile. The `finally` releases whatever
|
|
209
208
|
// no branch recorded.
|
|
210
209
|
// keyed by the address's rate-limit key (an IPv6 client's /64)
|
|
211
|
-
const ip_key = login_ip_rate_limiter ? rate_limit_ip_key(
|
|
210
|
+
const ip_key = login_ip_rate_limiter ? rate_limit_ip_key(route.client_ip) : null;
|
|
212
211
|
const ip_reserved = await reserve_optional(login_ip_rate_limiter, ip_key, {
|
|
213
|
-
signal:
|
|
212
|
+
signal: route.signal
|
|
214
213
|
});
|
|
215
214
|
if (!ip_reserved.ok) {
|
|
216
215
|
return route_fail(REST_RATE_LIMIT_EXCEEDED, { retry_after: ip_reserved.retry_after });
|
|
@@ -219,17 +218,17 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
219
218
|
try {
|
|
220
219
|
// `UsernameProvided` canonicalizes via `.trim().toLowerCase()` at
|
|
221
220
|
// parse time — the validated value lands canonical in
|
|
222
|
-
// `
|
|
221
|
+
// `route.input`, so the per-account rate-limit key,
|
|
223
222
|
// DB lookup, and audit metadata see one form. See
|
|
224
223
|
// `primitive_schemas.ts` for the schema-layer canonicalization.
|
|
225
|
-
const { username, password: pw } =
|
|
224
|
+
const { username, password: pw } = route.input;
|
|
226
225
|
// DB lookup first so we can key the per-account rate limit by a canonical value
|
|
227
226
|
// (account.id) rather than the submitted identifier. Otherwise an attacker could
|
|
228
227
|
// alternate between username and email to double the per-account bucket.
|
|
229
228
|
const account = await query_account_by_username_or_email(route, username);
|
|
230
229
|
const account_rate_key = account ? account.id : username;
|
|
231
230
|
// Per-account rate limit (after DB lookup so the key is canonical)
|
|
232
|
-
const account_reserved = await reserve_optional(login_account_rate_limiter, account_rate_key, { signal:
|
|
231
|
+
const account_reserved = await reserve_optional(login_account_rate_limiter, account_rate_key, { signal: route.signal });
|
|
233
232
|
if (!account_reserved.ok) {
|
|
234
233
|
return route_fail(REST_RATE_LIMIT_EXCEEDED, {
|
|
235
234
|
retry_after: account_reserved.retry_after
|
|
@@ -249,26 +248,61 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
249
248
|
await deps.audit.emit(route, {
|
|
250
249
|
event_type: 'login',
|
|
251
250
|
outcome: 'failure',
|
|
252
|
-
ip:
|
|
251
|
+
ip: route.client_ip,
|
|
253
252
|
metadata: { username }
|
|
254
253
|
});
|
|
255
254
|
await delay;
|
|
256
255
|
return route_fail(REST_INVALID_CREDENTIALS);
|
|
257
256
|
}
|
|
258
257
|
const valid = await password.verify_password(pw, account.password_hash);
|
|
259
|
-
|
|
258
|
+
// The session INSERT and the cap eviction are the route's only
|
|
259
|
+
// writes, and only atomic together: one transaction around just
|
|
260
|
+
// them (the route is `transaction: false`, so the reservation
|
|
261
|
+
// waits above and the Argon2 verify held no connection). Twin of
|
|
262
|
+
// the Rust login's transaction around `create_capped_session`. It
|
|
263
|
+
// first locks the account row as the verify read it — live, the
|
|
264
|
+
// verified hash — so a password change or a delete that committed
|
|
265
|
+
// since mints nothing, and one still to commit waits and then
|
|
266
|
+
// revokes this session (`query_account_lock_verified`). The
|
|
267
|
+
// cookie line is formatted inside it, so a value the formatter
|
|
268
|
+
// refuses rolls the session back, and rides the success, which is
|
|
269
|
+
// answered only once the commit has landed.
|
|
270
|
+
const minted = valid
|
|
271
|
+
? await route.db.transaction(async (tx) => {
|
|
272
|
+
const tx_deps = { db: tx };
|
|
273
|
+
if (!(await query_account_lock_verified(tx_deps, account.id, account.password_hash))) {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
const session = await create_capped_session({
|
|
277
|
+
keyring,
|
|
278
|
+
deps: tx_deps,
|
|
279
|
+
account_id: account.id,
|
|
280
|
+
session_options,
|
|
281
|
+
max_sessions
|
|
282
|
+
});
|
|
283
|
+
return {
|
|
284
|
+
evicted: session.evicted,
|
|
285
|
+
set_cookie: session_cookie_header(session.cookie_value, session_options)
|
|
286
|
+
};
|
|
287
|
+
})
|
|
288
|
+
: null;
|
|
289
|
+
// A wrong password, and a right one whose account changed under
|
|
290
|
+
// it, are one refusal: the same answer, charge, and audit row, so
|
|
291
|
+
// the caller can't learn the password was right a moment ago.
|
|
292
|
+
if (!minted) {
|
|
260
293
|
ip_reserved.reservation.record();
|
|
261
294
|
account_reservation?.record();
|
|
262
295
|
await deps.audit.emit(route, {
|
|
263
296
|
event_type: 'login',
|
|
264
297
|
outcome: 'failure',
|
|
265
298
|
account_id: account.id,
|
|
266
|
-
ip:
|
|
299
|
+
ip: route.client_ip,
|
|
267
300
|
metadata: { username }
|
|
268
301
|
});
|
|
269
302
|
await delay;
|
|
270
303
|
return route_fail(REST_INVALID_CREDENTIALS);
|
|
271
304
|
}
|
|
305
|
+
const { evicted, set_cookie } = minted;
|
|
272
306
|
// Successful login — clear the account-grain failure history only.
|
|
273
307
|
// The IP aggregate is deliberately left standing: it is the
|
|
274
308
|
// distributed-spray backstop, so a success on one account must not
|
|
@@ -279,19 +313,6 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
279
313
|
account_reservation?.release();
|
|
280
314
|
if (login_account_rate_limiter)
|
|
281
315
|
login_account_rate_limiter.reset(account_rate_key);
|
|
282
|
-
// The session INSERT and the cap eviction are the route's only
|
|
283
|
-
// writes, and only atomic together: one transaction around just
|
|
284
|
-
// them (the route is `transaction: false`, so the reservation
|
|
285
|
-
// waits above and the Argon2 verify held no connection). Twin of
|
|
286
|
-
// the Rust login's transaction around `create_capped_session`.
|
|
287
|
-
const evicted = await route.db.transaction((tx) => create_session_and_set_cookie({
|
|
288
|
-
keyring,
|
|
289
|
-
deps: { db: tx },
|
|
290
|
-
c,
|
|
291
|
-
account_id: account.id,
|
|
292
|
-
session_options,
|
|
293
|
-
max_sessions
|
|
294
|
-
}));
|
|
295
316
|
// The sessions the cap evicted are gone from the table, but not
|
|
296
317
|
// from the connections they opened — a WebSocket keeps the
|
|
297
318
|
// authority it resolved at upgrade, and an SSE stream never
|
|
@@ -306,20 +327,20 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
306
327
|
await deps.audit.emit(route, {
|
|
307
328
|
event_type: 'login',
|
|
308
329
|
account_id: account.id,
|
|
309
|
-
ip:
|
|
330
|
+
ip: route.client_ip
|
|
310
331
|
});
|
|
311
|
-
return route_ok({ ok: true });
|
|
332
|
+
return route_ok({ ok: true }, { set_cookie: [set_cookie] });
|
|
312
333
|
}
|
|
313
334
|
finally {
|
|
314
335
|
ip_reserved.reservation.release();
|
|
315
336
|
account_reservation?.release();
|
|
316
337
|
}
|
|
317
338
|
}),
|
|
318
|
-
attach_route_handler(logout_shape, async (
|
|
319
|
-
const ctx =
|
|
339
|
+
attach_route_handler(logout_shape, async (route) => {
|
|
340
|
+
const ctx = route.auth;
|
|
320
341
|
// the shape admits only a session credential, so this is its hash
|
|
321
342
|
// (the Rust `account_logout` reads the same value)
|
|
322
|
-
const session_hash = resolved_auth_session_hash(
|
|
343
|
+
const session_hash = resolved_auth_session_hash(route.credential);
|
|
323
344
|
if (session_hash !== null) {
|
|
324
345
|
await query_session_revoke_by_hash_unscoped(route, session_hash);
|
|
325
346
|
// Close this account's live connections once the revoke has
|
|
@@ -335,39 +356,40 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
335
356
|
account_id: ctx.account.id
|
|
336
357
|
});
|
|
337
358
|
}
|
|
338
|
-
clear_session_cookie(c, session_options);
|
|
339
359
|
// Account-grain operation — no `actor_id` (which actor was
|
|
340
360
|
// resolved per-request is incidental to "this account ended
|
|
341
361
|
// its session"). Mirrors `login`.
|
|
342
362
|
await deps.audit.emit(route, {
|
|
343
363
|
event_type: 'logout',
|
|
344
364
|
account_id: ctx.account.id,
|
|
345
|
-
ip:
|
|
365
|
+
ip: route.client_ip
|
|
346
366
|
});
|
|
347
|
-
|
|
367
|
+
// the clear rides the success, answered once the revoke and this
|
|
368
|
+
// row have committed — a rollback clears nothing
|
|
369
|
+
return route_ok({ ok: true, username: ctx.account.username }, { set_cookie: [clear_session_cookie_header(session_options)] });
|
|
348
370
|
}),
|
|
349
|
-
attach_route_handler(password_shape, async (
|
|
371
|
+
attach_route_handler(password_shape, async (route) => {
|
|
350
372
|
// Per-IP rate limit (before argon2 work). Reserved, not checked:
|
|
351
373
|
// the attempt counts against the shared login limiters from here
|
|
352
374
|
// until it settles, so a concurrent burst of guesses at
|
|
353
375
|
// `current_password` can't all pass before any of it records. The
|
|
354
376
|
// `finally` releases whatever no branch recorded.
|
|
355
377
|
// keyed by the address's rate-limit key (an IPv6 client's /64)
|
|
356
|
-
const ip_key = login_ip_rate_limiter ? rate_limit_ip_key(
|
|
378
|
+
const ip_key = login_ip_rate_limiter ? rate_limit_ip_key(route.client_ip) : null;
|
|
357
379
|
const ip_reserved = await reserve_optional(login_ip_rate_limiter, ip_key, {
|
|
358
|
-
signal:
|
|
380
|
+
signal: route.signal
|
|
359
381
|
});
|
|
360
382
|
if (!ip_reserved.ok) {
|
|
361
383
|
return route_fail(REST_RATE_LIMIT_EXCEEDED, { retry_after: ip_reserved.retry_after });
|
|
362
384
|
}
|
|
363
385
|
let account_reservation = null;
|
|
364
386
|
try {
|
|
365
|
-
const ctx =
|
|
366
|
-
const { current_password, new_password } =
|
|
387
|
+
const ctx = route.auth;
|
|
388
|
+
const { current_password, new_password } = route.input;
|
|
367
389
|
// Defense in depth — see `docs/security.md` §Credential-channel gating.
|
|
368
|
-
const credential_type =
|
|
390
|
+
const credential_type = route.credential?.credential_type;
|
|
369
391
|
// per-account rate limit (after context resolution, before argon2 work)
|
|
370
|
-
const account_reserved = await reserve_optional(login_account_rate_limiter, ctx.account.id, { signal:
|
|
392
|
+
const account_reserved = await reserve_optional(login_account_rate_limiter, ctx.account.id, { signal: route.signal });
|
|
371
393
|
if (!account_reserved.ok) {
|
|
372
394
|
return route_fail(REST_RATE_LIMIT_EXCEEDED, {
|
|
373
395
|
retry_after: account_reserved.retry_after
|
|
@@ -382,7 +404,7 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
382
404
|
event_type: 'password_change',
|
|
383
405
|
outcome: 'failure',
|
|
384
406
|
account_id: ctx.account.id,
|
|
385
|
-
ip:
|
|
407
|
+
ip: route.client_ip,
|
|
386
408
|
metadata: { credential_type }
|
|
387
409
|
});
|
|
388
410
|
return route_fail(REST_INVALID_CREDENTIALS);
|
|
@@ -442,7 +464,7 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
442
464
|
event_type: 'password_change',
|
|
443
465
|
outcome: 'failure',
|
|
444
466
|
account_id: ctx.account.id,
|
|
445
|
-
ip:
|
|
467
|
+
ip: route.client_ip,
|
|
446
468
|
metadata: { reason: 'concurrent_change', credential_type }
|
|
447
469
|
});
|
|
448
470
|
return route_fail(REST_INVALID_CREDENTIALS);
|
|
@@ -455,7 +477,6 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
455
477
|
// not depend on the fail-open audit write below; the audit
|
|
456
478
|
// listeners repeat it on the announced `password_change` row.
|
|
457
479
|
close_connections_after_commit(connection_closer, { kind: 'account', account_id: ctx.account.id }, deps.log);
|
|
458
|
-
clear_session_cookie(c, session_options);
|
|
459
480
|
// Account-grain operation — no `actor_id`. The password is
|
|
460
481
|
// account-level state; which per-request actor was resolved
|
|
461
482
|
// has no semantic bearing on "this account changed its
|
|
@@ -463,10 +484,10 @@ export const create_account_route_specs = (deps, options) => {
|
|
|
463
484
|
await deps.audit.emit(route, {
|
|
464
485
|
event_type: 'password_change',
|
|
465
486
|
account_id: ctx.account.id,
|
|
466
|
-
ip:
|
|
487
|
+
ip: route.client_ip,
|
|
467
488
|
metadata: { sessions_revoked, tokens_revoked, credential_type }
|
|
468
489
|
});
|
|
469
|
-
return route_ok({ ok: true, sessions_revoked, tokens_revoked });
|
|
490
|
+
return route_ok({ ok: true, sessions_revoked, tokens_revoked }, { set_cookie: [clear_session_cookie_header(session_options)] });
|
|
470
491
|
}
|
|
471
492
|
finally {
|
|
472
493
|
ip_reserved.reservation.release();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin_actions.d.ts","sourceRoot":"","sources":["../../src/lib/auth/admin_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAIjG,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"admin_actions.d.ts","sourceRoot":"","sources":["../../src/lib/auth/admin_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAIjG,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,kBAAkB,CAAC;AAwD1B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AA2D3D,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,yBAAyB,EAC/B,UAAS,kBAAuB,KAC9B,KAAK,CAAC,SAAS,CAmpBjB,CAAC"}
|