@fuzdev/fuz_app 0.54.0 → 0.56.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 +214 -103
- package/dist/actions/action_bridge.d.ts +8 -5
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +1 -11
- package/dist/actions/action_codegen.d.ts +32 -0
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +35 -15
- package/dist/actions/action_registry.d.ts.map +1 -1
- package/dist/actions/action_registry.js +5 -2
- package/dist/actions/action_rpc.d.ts +141 -22
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +106 -187
- package/dist/actions/action_spec.d.ts +55 -16
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +16 -11
- package/dist/actions/action_types.d.ts +28 -60
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +13 -5
- package/dist/actions/broadcast_api.d.ts +2 -2
- package/dist/actions/broadcast_api.js +2 -2
- package/dist/actions/compile_action_registry.d.ts +50 -0
- package/dist/actions/compile_action_registry.d.ts.map +1 -0
- package/dist/actions/compile_action_registry.js +69 -0
- package/dist/actions/heartbeat.d.ts +8 -4
- package/dist/actions/heartbeat.d.ts.map +1 -1
- package/dist/actions/heartbeat.js +5 -4
- package/dist/actions/perform_action.d.ts +145 -0
- package/dist/actions/perform_action.d.ts.map +1 -0
- package/dist/actions/perform_action.js +258 -0
- package/dist/actions/register_action_ws.d.ts +46 -40
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +101 -159
- package/dist/actions/register_ws_endpoint.d.ts +15 -10
- package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
- package/dist/actions/register_ws_endpoint.js +54 -7
- package/dist/actions/transports.d.ts.map +1 -1
- package/dist/actions/transports.js +0 -4
- package/dist/actions/transports_ws_auth_guard.d.ts +1 -1
- package/dist/actions/transports_ws_auth_guard.js +1 -1
- package/dist/actions/transports_ws_backend.d.ts +1 -1
- package/dist/actions/transports_ws_backend.js +1 -1
- package/dist/auth/CLAUDE.md +794 -410
- package/dist/auth/account_action_specs.d.ts +28 -7
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +7 -7
- package/dist/auth/account_actions.d.ts +7 -13
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +26 -35
- package/dist/auth/account_queries.d.ts +52 -16
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +87 -38
- package/dist/auth/account_routes.d.ts +9 -11
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +118 -46
- package/dist/auth/account_schema.d.ts +46 -35
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +21 -28
- package/dist/auth/admin_action_specs.d.ts +100 -32
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +64 -33
- package/dist/auth/admin_actions.d.ts +13 -19
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +37 -41
- package/dist/auth/audit_emitter.d.ts +160 -0
- package/dist/auth/audit_emitter.d.ts.map +1 -0
- package/dist/auth/audit_emitter.js +83 -0
- package/dist/auth/audit_log_queries.d.ts +17 -48
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +20 -56
- 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 +7 -3
- package/dist/auth/audit_log_schema.d.ts +92 -32
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +75 -46
- package/dist/auth/auth_guard_resolver.d.ts +44 -0
- package/dist/auth/auth_guard_resolver.d.ts.map +1 -0
- package/dist/auth/auth_guard_resolver.js +56 -0
- package/dist/auth/bearer_auth.d.ts +9 -7
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +13 -21
- package/dist/auth/bootstrap_account.d.ts +7 -7
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +7 -7
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +11 -10
- package/dist/auth/cleanup.d.ts +20 -26
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +33 -42
- package/dist/auth/credential_type_schema.d.ts +115 -0
- package/dist/auth/credential_type_schema.d.ts.map +1 -0
- package/dist/auth/credential_type_schema.js +127 -0
- package/dist/auth/daemon_token_middleware.d.ts +23 -11
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +28 -22
- package/dist/auth/ddl.d.ts +2 -2
- package/dist/auth/ddl.d.ts.map +1 -1
- package/dist/auth/ddl.js +6 -6
- package/dist/auth/deps.d.ts +7 -18
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/grant_path_schema.d.ts +117 -0
- package/dist/auth/grant_path_schema.d.ts.map +1 -0
- package/dist/auth/grant_path_schema.js +137 -0
- package/dist/auth/invite_queries.d.ts +12 -1
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +12 -1
- package/dist/auth/invite_schema.d.ts +1 -1
- package/dist/auth/invite_schema.d.ts.map +1 -1
- package/dist/auth/invite_schema.js +1 -1
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +9 -4
- package/dist/auth/migrations.d.ts +37 -14
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +79 -32
- package/dist/auth/request_context.d.ts +331 -61
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +378 -95
- package/dist/auth/{permit_offer_action_specs.d.ts → role_grant_offer_action_specs.d.ts} +163 -94
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -0
- package/dist/auth/role_grant_offer_action_specs.js +262 -0
- package/dist/auth/role_grant_offer_actions.d.ts +104 -0
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -0
- package/dist/auth/role_grant_offer_actions.js +473 -0
- package/dist/auth/{permit_offer_notifications.d.ts → role_grant_offer_notifications.d.ts} +90 -70
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -0
- package/dist/auth/role_grant_offer_notifications.js +182 -0
- package/dist/auth/role_grant_offer_queries.d.ts +242 -0
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -0
- package/dist/auth/role_grant_offer_queries.js +533 -0
- package/dist/auth/role_grant_offer_schema.d.ts +150 -0
- package/dist/auth/role_grant_offer_schema.d.ts.map +1 -0
- package/dist/auth/{permit_offer_schema.js → role_grant_offer_schema.js} +60 -36
- package/dist/auth/role_grant_queries.d.ts +231 -0
- package/dist/auth/role_grant_queries.d.ts.map +1 -0
- package/dist/auth/role_grant_queries.js +320 -0
- package/dist/auth/role_schema.d.ts +150 -40
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +144 -45
- package/dist/auth/scope_kind_schema.d.ts +96 -0
- package/dist/auth/scope_kind_schema.d.ts.map +1 -0
- package/dist/auth/scope_kind_schema.js +94 -0
- package/dist/auth/self_service_role_action_specs.d.ts +6 -1
- package/dist/auth/self_service_role_action_specs.d.ts.map +1 -1
- package/dist/auth/self_service_role_action_specs.js +3 -1
- package/dist/auth/self_service_role_actions.d.ts +34 -27
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +68 -48
- package/dist/auth/session_cookie.d.ts +43 -6
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +31 -5
- package/dist/auth/session_middleware.d.ts +37 -3
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +33 -7
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +48 -19
- package/dist/auth/standard_action_specs.d.ts +2 -2
- package/dist/auth/standard_action_specs.js +4 -4
- package/dist/auth/standard_rpc_actions.d.ts +23 -19
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/standard_rpc_actions.js +12 -12
- package/dist/db/migrate.d.ts +12 -8
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +10 -7
- package/dist/dev/setup.d.ts +2 -2
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +9 -7
- package/dist/env/load.d.ts +1 -1
- package/dist/env/load.js +1 -1
- package/dist/hono_context.d.ts +64 -5
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +38 -2
- package/dist/http/CLAUDE.md +264 -87
- package/dist/http/auth_shape.d.ts +191 -0
- package/dist/http/auth_shape.d.ts.map +1 -0
- package/dist/http/auth_shape.js +237 -0
- package/dist/http/common_routes.js +3 -3
- package/dist/http/db_routes.d.ts +4 -0
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +44 -7
- package/dist/http/error_schemas.d.ts +132 -19
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +132 -40
- package/dist/http/jsonrpc_errors.d.ts +27 -2
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +26 -2
- package/dist/http/pending_effects.d.ts +71 -18
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +87 -18
- package/dist/http/proxy.d.ts +52 -5
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +92 -14
- package/dist/http/route_spec.d.ts +113 -41
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +130 -52
- package/dist/http/schema_helpers.d.ts +3 -2
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +9 -2
- package/dist/http/surface.d.ts +2 -1
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +1 -2
- package/dist/http/surface_query.d.ts +39 -35
- package/dist/http/surface_query.d.ts.map +1 -1
- package/dist/http/surface_query.js +79 -36
- package/dist/primitive_schemas.d.ts +39 -0
- package/dist/primitive_schemas.d.ts.map +1 -0
- package/dist/primitive_schemas.js +40 -0
- package/dist/realtime/sse_auth_guard.d.ts +5 -5
- package/dist/realtime/sse_auth_guard.js +9 -9
- package/dist/runtime/mock.d.ts +1 -1
- package/dist/runtime/mock.js +1 -1
- package/dist/server/app_backend.d.ts +14 -11
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +12 -8
- package/dist/server/app_server.d.ts +7 -7
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +36 -31
- package/dist/server/validate_nginx.d.ts +1 -1
- package/dist/server/validate_nginx.js +1 -1
- package/dist/testing/CLAUDE.md +73 -55
- package/dist/testing/admin_integration.d.ts +5 -6
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +100 -96
- package/dist/testing/adversarial_headers.js +1 -1
- package/dist/testing/app_server.d.ts +11 -14
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +18 -17
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +2 -1
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +15 -9
- package/dist/testing/audit_completeness.d.ts +2 -2
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +53 -39
- package/dist/testing/auth_apps.d.ts +5 -4
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +28 -22
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +5 -5
- package/dist/testing/db.d.ts +1 -1
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +4 -4
- package/dist/testing/db_entities.d.ts +22 -0
- package/dist/testing/db_entities.d.ts.map +1 -0
- package/dist/testing/db_entities.js +28 -0
- package/dist/testing/entities.d.ts +10 -8
- package/dist/testing/entities.d.ts.map +1 -1
- package/dist/testing/entities.js +22 -18
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +13 -14
- package/dist/testing/integration_helpers.d.ts +8 -6
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +29 -23
- package/dist/testing/middleware.d.ts +15 -11
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +75 -32
- package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
- package/dist/testing/rpc_attack_surface.js +40 -24
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +3 -1
- package/dist/testing/rpc_round_trip.d.ts +1 -1
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +14 -13
- package/dist/testing/sse_round_trip.d.ts +3 -4
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +7 -11
- package/dist/testing/standard.d.ts +1 -1
- package/dist/testing/stubs.d.ts +25 -0
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +43 -2
- package/dist/testing/surface_invariants.d.ts +2 -2
- package/dist/testing/ws_round_trip.d.ts +12 -13
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +24 -12
- package/dist/ui/AdminAccounts.svelte +23 -20
- package/dist/ui/AdminOverview.svelte +15 -13
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
- package/dist/ui/{AdminPermitHistory.svelte → AdminRoleGrantHistory.svelte} +12 -12
- package/dist/ui/AdminRoleGrantHistory.svelte.d.ts +4 -0
- package/dist/ui/AdminRoleGrantHistory.svelte.d.ts.map +1 -0
- package/dist/ui/BootstrapForm.svelte +1 -1
- package/dist/ui/CLAUDE.md +65 -59
- package/dist/ui/{PermitOfferForm.svelte → RoleGrantOfferForm.svelte} +37 -22
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts +20 -0
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -0
- package/dist/ui/{PermitOfferHistory.svelte → RoleGrantOfferHistory.svelte} +12 -12
- package/dist/ui/{PermitOfferHistory.svelte.d.ts → RoleGrantOfferHistory.svelte.d.ts} +4 -4
- package/dist/ui/RoleGrantOfferHistory.svelte.d.ts.map +1 -0
- package/dist/ui/{PermitOfferInbox.svelte → RoleGrantOfferInbox.svelte} +14 -14
- package/dist/ui/{PermitOfferInbox.svelte.d.ts → RoleGrantOfferInbox.svelte.d.ts} +4 -4
- package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -0
- package/dist/ui/SignupForm.svelte +1 -1
- package/dist/ui/SurfaceExplorer.svelte +35 -15
- package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.d.ts +2 -3
- package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.js +2 -3
- package/dist/ui/admin_accounts_state.svelte.d.ts +25 -18
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.js +28 -17
- package/dist/ui/admin_rpc_adapters.d.ts +20 -20
- package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
- package/dist/ui/admin_rpc_adapters.js +17 -17
- package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
- package/dist/ui/admin_sessions_state.svelte.js +2 -2
- package/dist/ui/audit_log_state.svelte.d.ts +7 -7
- package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.js +6 -6
- package/dist/ui/auth_state.svelte.d.ts +3 -3
- package/dist/ui/auth_state.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.js +6 -6
- package/dist/ui/format_scope.d.ts +2 -2
- package/dist/ui/format_scope.js +2 -2
- package/dist/ui/{permit_offers_state.svelte.d.ts → role_grant_offers_state.svelte.d.ts} +39 -31
- package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -0
- package/dist/ui/{permit_offers_state.svelte.js → role_grant_offers_state.svelte.js} +25 -19
- package/dist/ui/ui_format.js +2 -2
- package/package.json +3 -3
- package/dist/auth/permit_offer_action_specs.d.ts.map +0 -1
- package/dist/auth/permit_offer_action_specs.js +0 -227
- package/dist/auth/permit_offer_actions.d.ts +0 -110
- package/dist/auth/permit_offer_actions.d.ts.map +0 -1
- package/dist/auth/permit_offer_actions.js +0 -452
- package/dist/auth/permit_offer_notifications.d.ts.map +0 -1
- package/dist/auth/permit_offer_notifications.js +0 -182
- package/dist/auth/permit_offer_queries.d.ts +0 -183
- package/dist/auth/permit_offer_queries.d.ts.map +0 -1
- package/dist/auth/permit_offer_queries.js +0 -408
- package/dist/auth/permit_offer_schema.d.ts +0 -103
- package/dist/auth/permit_offer_schema.d.ts.map +0 -1
- package/dist/auth/permit_queries.d.ts +0 -210
- package/dist/auth/permit_queries.d.ts.map +0 -1
- package/dist/auth/permit_queries.js +0 -294
- package/dist/auth/require_keeper.d.ts +0 -20
- package/dist/auth/require_keeper.d.ts.map +0 -1
- package/dist/auth/require_keeper.js +0 -35
- package/dist/auth/route_guards.d.ts +0 -21
- package/dist/auth/route_guards.d.ts.map +0 -1
- package/dist/auth/route_guards.js +0 -32
- package/dist/auth/session_lifecycle.d.ts +0 -37
- package/dist/auth/session_lifecycle.d.ts.map +0 -1
- package/dist/auth/session_lifecycle.js +0 -29
- package/dist/ui/AdminPermitHistory.svelte.d.ts +0 -4
- package/dist/ui/AdminPermitHistory.svelte.d.ts.map +0 -1
- package/dist/ui/PermitOfferForm.svelte.d.ts +0 -14
- package/dist/ui/PermitOfferForm.svelte.d.ts.map +0 -1
- package/dist/ui/PermitOfferHistory.svelte.d.ts.map +0 -1
- package/dist/ui/PermitOfferInbox.svelte.d.ts.map +0 -1
- package/dist/ui/permit_offers_state.svelte.d.ts.map +0 -1
|
@@ -8,16 +8,15 @@
|
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
10
|
import { z } from 'zod';
|
|
11
|
-
import { create_session_and_set_cookie } from './
|
|
11
|
+
import { create_session_and_set_cookie } from './session_middleware.js';
|
|
12
12
|
import { query_create_account_with_actor } from './account_queries.js';
|
|
13
|
-
import { query_invite_find_unclaimed_match,
|
|
14
|
-
import { Username, Email } from '
|
|
13
|
+
import { query_invite_find_unclaimed_match, query_invite_claim_unscoped } from './invite_queries.js';
|
|
14
|
+
import { Username, Email } from '../primitive_schemas.js';
|
|
15
15
|
import { Password } from './password.js';
|
|
16
16
|
import { get_route_input } from '../http/route_spec.js';
|
|
17
17
|
import { get_client_ip } from '../http/proxy.js';
|
|
18
18
|
import { rate_limit_exceeded_response } from '../rate_limiter.js';
|
|
19
19
|
import { ERROR_NO_MATCHING_INVITE, ERROR_SIGNUP_CONFLICT, ERROR_INVALID_JSON_BODY, ERROR_INVALID_REQUEST_BODY, } from '../http/error_schemas.js';
|
|
20
|
-
import { audit_log_fire_and_forget } from './audit_log_queries.js';
|
|
21
20
|
import { is_pg_unique_violation } from '../db/pg_error.js';
|
|
22
21
|
// -- Input/output schemas ---------------------------------------------------
|
|
23
22
|
/** Input for `POST /signup`. `email` is optional and must match any referenced invite. */
|
|
@@ -44,7 +43,7 @@ export const create_signup_route_specs = (deps, options) => {
|
|
|
44
43
|
{
|
|
45
44
|
method: 'POST',
|
|
46
45
|
path: '/signup',
|
|
47
|
-
auth: {
|
|
46
|
+
auth: { account: 'none', actor: 'none' },
|
|
48
47
|
description: 'Create account (invite-gated or open signup)',
|
|
49
48
|
transaction: false, // manages its own transaction for TOCTOU safety
|
|
50
49
|
input: SignupInput,
|
|
@@ -75,24 +74,41 @@ export const create_signup_route_specs = (deps, options) => {
|
|
|
75
74
|
return rate_limit_exceeded_response(c, check.retry_after);
|
|
76
75
|
}
|
|
77
76
|
}
|
|
78
|
-
// Check for matching invite (unless open signup is enabled)
|
|
77
|
+
// Check for matching invite (unless open signup is enabled).
|
|
78
|
+
// `transaction: false` makes `route.db` the pool, which is
|
|
79
|
+
// what the pre-tx invite lookup wants.
|
|
79
80
|
let invite;
|
|
80
81
|
if (!app_settings.open_signup) {
|
|
81
|
-
invite = await query_invite_find_unclaimed_match({ db: route.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
invite = await query_invite_find_unclaimed_match({ db: route.db }, email ?? null, username);
|
|
83
|
+
}
|
|
84
|
+
const emit_failure_audit = (reason) => {
|
|
85
|
+
deps.audit.emit(route, {
|
|
86
|
+
event_type: 'signup',
|
|
87
|
+
outcome: 'failure',
|
|
88
|
+
ip: get_client_ip(c),
|
|
89
|
+
metadata: {
|
|
90
|
+
username,
|
|
91
|
+
reason,
|
|
92
|
+
...(invite && { invite_id: invite.id }),
|
|
93
|
+
...(email != null && { email }),
|
|
94
|
+
...(app_settings.open_signup && { open_signup: true }),
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
if (!app_settings.open_signup && !invite) {
|
|
99
|
+
if (ip_rate_limiter && ip)
|
|
100
|
+
ip_rate_limiter.record(ip);
|
|
101
|
+
if (signup_account_rate_limiter)
|
|
102
|
+
signup_account_rate_limiter.record(account_key);
|
|
103
|
+
emit_failure_audit('no_match');
|
|
104
|
+
return c.json({ error: ERROR_NO_MATCHING_INVITE }, 403);
|
|
89
105
|
}
|
|
90
106
|
// Create account, optionally claim invite, and create session atomically.
|
|
91
107
|
// Username/email uniqueness enforced by DB unique constraints.
|
|
92
108
|
const password_hash = await password.hash_password(pw);
|
|
93
109
|
let result;
|
|
94
110
|
try {
|
|
95
|
-
result = await route.
|
|
111
|
+
result = await route.db.transaction(async (tx) => {
|
|
96
112
|
const tx_deps = { db: tx };
|
|
97
113
|
const { account } = await query_create_account_with_actor(tx_deps, {
|
|
98
114
|
username,
|
|
@@ -100,9 +116,20 @@ export const create_signup_route_specs = (deps, options) => {
|
|
|
100
116
|
email,
|
|
101
117
|
});
|
|
102
118
|
if (invite) {
|
|
103
|
-
const claimed = await
|
|
119
|
+
const claimed = await query_invite_claim_unscoped(tx_deps, invite.id, account.id);
|
|
104
120
|
if (!claimed) {
|
|
105
|
-
// Race: invite was claimed between the find and this claim
|
|
121
|
+
// Race: invite was claimed between the find and this claim.
|
|
122
|
+
//
|
|
123
|
+
// SECURITY NOTE: this branch is largely shadowed by the account
|
|
124
|
+
// unique constraints. Because `query_invite_find_unclaimed_match`
|
|
125
|
+
// returns at most one invite for the (username, email) tuple, two
|
|
126
|
+
// concurrent signups satisfying the same find share the same
|
|
127
|
+
// username and/or email — and the case-insensitive partial uniques
|
|
128
|
+
// on `account.username` / `account.email` (`ACCOUNT_USERNAME_CI_INDEX`
|
|
129
|
+
// / `ACCOUNT_EMAIL_INDEX`) fire on the second `query_create_account_with_actor`
|
|
130
|
+
// before the claim runs. The audit emit is kept for defense-in-depth
|
|
131
|
+
// in case those constraints are loosened or the find query starts
|
|
132
|
+
// returning multiple invites for a single signup tuple.
|
|
106
133
|
throw new SignupConflictError(ERROR_NO_MATCHING_INVITE);
|
|
107
134
|
}
|
|
108
135
|
}
|
|
@@ -122,6 +149,7 @@ export const create_signup_route_specs = (deps, options) => {
|
|
|
122
149
|
ip_rate_limiter.record(ip);
|
|
123
150
|
if (signup_account_rate_limiter)
|
|
124
151
|
signup_account_rate_limiter.record(account_key);
|
|
152
|
+
emit_failure_audit('race_lost');
|
|
125
153
|
return c.json({ error: e.error }, 403);
|
|
126
154
|
}
|
|
127
155
|
// Unique constraint violation: username or email already exists.
|
|
@@ -130,6 +158,7 @@ export const create_signup_route_specs = (deps, options) => {
|
|
|
130
158
|
ip_rate_limiter.record(ip);
|
|
131
159
|
if (signup_account_rate_limiter)
|
|
132
160
|
signup_account_rate_limiter.record(account_key);
|
|
161
|
+
emit_failure_audit('signup_conflict');
|
|
133
162
|
return c.json({ error: ERROR_SIGNUP_CONFLICT }, 409);
|
|
134
163
|
}
|
|
135
164
|
throw e;
|
|
@@ -139,12 +168,12 @@ export const create_signup_route_specs = (deps, options) => {
|
|
|
139
168
|
ip_rate_limiter.reset(ip);
|
|
140
169
|
if (signup_account_rate_limiter)
|
|
141
170
|
signup_account_rate_limiter.reset(account_key);
|
|
142
|
-
|
|
171
|
+
deps.audit.emit(route, {
|
|
143
172
|
event_type: 'signup',
|
|
144
173
|
account_id: result.id,
|
|
145
174
|
ip: get_client_ip(c),
|
|
146
175
|
metadata: invite ? { invite_id: invite.id, username } : { open_signup: true, username },
|
|
147
|
-
}
|
|
176
|
+
});
|
|
148
177
|
return c.json({ ok: true });
|
|
149
178
|
},
|
|
150
179
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Aggregate spec list mirroring `create_standard_rpc_actions` on the backend.
|
|
3
3
|
*
|
|
4
4
|
* `create_standard_rpc_actions` (in `auth/standard_rpc_actions.ts`) bundles three
|
|
5
|
-
* action registries into one mounted RPC surface: admin +
|
|
5
|
+
* action registries into one mounted RPC surface: admin + role_grant_offer +
|
|
6
6
|
* account. Frontends mounting that surface need the matching spec list to
|
|
7
7
|
* feed `create_rpc_client` so the typed Proxy knows about every standard
|
|
8
8
|
* method.
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
import type { RequestResponseActionSpec } from '../actions/action_spec.js';
|
|
23
23
|
/**
|
|
24
24
|
* Combined spec registry for the standard RPC surface (admin +
|
|
25
|
-
*
|
|
25
|
+
* role_grant_offer + account). Symmetric with `create_standard_rpc_actions`.
|
|
26
26
|
*
|
|
27
27
|
* Spec count is the sum of the three sub-registries. Adding a method to
|
|
28
28
|
* any sub-registry surfaces here automatically.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Aggregate spec list mirroring `create_standard_rpc_actions` on the backend.
|
|
3
3
|
*
|
|
4
4
|
* `create_standard_rpc_actions` (in `auth/standard_rpc_actions.ts`) bundles three
|
|
5
|
-
* action registries into one mounted RPC surface: admin +
|
|
5
|
+
* action registries into one mounted RPC surface: admin + role_grant_offer +
|
|
6
6
|
* account. Frontends mounting that surface need the matching spec list to
|
|
7
7
|
* feed `create_rpc_client` so the typed Proxy knows about every standard
|
|
8
8
|
* method.
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
* @module
|
|
21
21
|
*/
|
|
22
22
|
import { all_admin_action_specs } from './admin_action_specs.js';
|
|
23
|
-
import {
|
|
23
|
+
import { all_role_grant_offer_action_specs } from './role_grant_offer_action_specs.js';
|
|
24
24
|
import { all_account_action_specs } from './account_action_specs.js';
|
|
25
25
|
/**
|
|
26
26
|
* Combined spec registry for the standard RPC surface (admin +
|
|
27
|
-
*
|
|
27
|
+
* role_grant_offer + account). Symmetric with `create_standard_rpc_actions`.
|
|
28
28
|
*
|
|
29
29
|
* Spec count is the sum of the three sub-registries. Adding a method to
|
|
30
30
|
* any sub-registry surfaces here automatically.
|
|
31
31
|
*/
|
|
32
32
|
export const all_standard_action_specs = [
|
|
33
33
|
...all_admin_action_specs,
|
|
34
|
-
...
|
|
34
|
+
...all_role_grant_offer_action_specs,
|
|
35
35
|
...all_account_action_specs,
|
|
36
36
|
];
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Combined admin +
|
|
2
|
+
* Combined admin + role-grant-offer + account RPC actions for fuz_app consumers.
|
|
3
3
|
*
|
|
4
4
|
* The canonical "standard" RPC surface: every stock fuz_app RPC action a
|
|
5
5
|
* typical web consumer wants on one endpoint. Consumers that want a
|
|
6
6
|
* narrower surface drop down to the per-domain factories directly
|
|
7
|
-
* (`create_admin_actions` / `
|
|
7
|
+
* (`create_admin_actions` / `create_role_grant_offer_actions` /
|
|
8
8
|
* `create_account_actions`).
|
|
9
9
|
*
|
|
10
|
-
* Option routing: shared `roles` flows to both admin and
|
|
10
|
+
* Option routing: shared `roles` flows to both admin and role-grant-offer;
|
|
11
11
|
* `app_settings` goes to admin only; `default_ttl_ms` and `authorize` go
|
|
12
|
-
* to
|
|
13
|
-
* `notification_sender` reaches
|
|
12
|
+
* to role-grant-offer only; `max_tokens` goes to account only;
|
|
13
|
+
* `notification_sender` reaches role-grant-offer transparently (admin + account
|
|
14
14
|
* ignore it).
|
|
15
15
|
*
|
|
16
16
|
* Paired with `create_admin_rpc_adapters` on the UI side.
|
|
@@ -18,39 +18,43 @@
|
|
|
18
18
|
* @module
|
|
19
19
|
*/
|
|
20
20
|
import { type AdminActionOptions } from './admin_actions.js';
|
|
21
|
-
import { type
|
|
21
|
+
import { type RoleGrantOfferActionOptions } from './role_grant_offer_actions.js';
|
|
22
22
|
import { type AccountActionOptions } from './account_actions.js';
|
|
23
|
+
import type { RouteFactoryDeps } from './deps.js';
|
|
24
|
+
import type { NotificationSender } from './role_grant_offer_notifications.js';
|
|
23
25
|
import type { RpcAction } from '../actions/action_rpc.js';
|
|
24
26
|
/**
|
|
25
27
|
* Options for `create_standard_rpc_actions`.
|
|
26
28
|
*
|
|
27
29
|
* Composes `AdminActionOptions` (`roles`, `app_settings`),
|
|
28
|
-
* `
|
|
30
|
+
* `RoleGrantOfferActionOptions` (`roles`, `default_ttl_ms`, `authorize`), and
|
|
29
31
|
* `AccountActionOptions` (`max_tokens`). `roles` is shared between admin
|
|
30
|
-
* and
|
|
32
|
+
* and role-grant-offer — the caller supplies it once and the helper threads
|
|
31
33
|
* the same reference to both.
|
|
32
34
|
*/
|
|
33
|
-
export interface StandardRpcActionsOptions extends AdminActionOptions,
|
|
35
|
+
export interface StandardRpcActionsOptions extends AdminActionOptions, RoleGrantOfferActionOptions, AccountActionOptions {
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
38
|
* Dependencies for `create_standard_rpc_actions`.
|
|
37
39
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
40
|
+
* Stack-standard `RouteFactoryDeps` slice (`log`, `audit`) plus an optional
|
|
41
|
+
* `notification_sender` consumed only by the role-grant-offer sub-factory
|
|
42
|
+
* for WS fan-out. Admin and account sub-factories ignore
|
|
43
|
+
* `notification_sender`.
|
|
42
44
|
*/
|
|
43
|
-
export
|
|
45
|
+
export interface StandardRpcActionsDeps extends Pick<RouteFactoryDeps, 'log' | 'audit'> {
|
|
46
|
+
notification_sender?: NotificationSender | null;
|
|
47
|
+
}
|
|
44
48
|
/**
|
|
45
|
-
* Build the combined admin +
|
|
49
|
+
* Build the combined admin + role-grant-offer + account RPC action set.
|
|
46
50
|
*
|
|
47
51
|
* Spreads `create_admin_actions(deps, {roles, app_settings})`,
|
|
48
|
-
* `
|
|
52
|
+
* `create_role_grant_offer_actions(deps, {roles, default_ttl_ms, authorize})`,
|
|
49
53
|
* and `create_account_actions(deps, {max_tokens})`. The shared `roles`
|
|
50
|
-
* option flows to admin +
|
|
54
|
+
* option flows to admin + role-grant-offer.
|
|
51
55
|
*
|
|
52
|
-
* @param deps - `StandardRpcActionsDeps` (`log`, `
|
|
53
|
-
* @param options - role schema, optional app-settings ref,
|
|
56
|
+
* @param deps - `StandardRpcActionsDeps` (`log`, `audit` from `RouteFactoryDeps`; optional `notification_sender` for WS fan-out)
|
|
57
|
+
* @param options - role schema, optional app-settings ref, role-grant-offer config, account config
|
|
54
58
|
* @returns RPC actions to pass as `rpc_endpoints` or spread into `create_rpc_endpoint`
|
|
55
59
|
*/
|
|
56
60
|
export declare const create_standard_rpc_actions: (deps: StandardRpcActionsDeps, options?: StandardRpcActionsOptions) => Array<RpcAction>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard_rpc_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/standard_rpc_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAuB,KAAK,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAEN,KAAK,
|
|
1
|
+
{"version":3,"file":"standard_rpc_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/standard_rpc_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAuB,KAAK,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAEN,KAAK,2BAA2B,EAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAyB,KAAK,oBAAoB,EAAC,MAAM,sBAAsB,CAAC;AACvF,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,qCAAqC,CAAC;AAC5E,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,WAAW,yBAChB,SAAQ,kBAAkB,EAAE,2BAA2B,EAAE,oBAAoB;CAAG;AAEjF;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,OAAO,CAAC;IACtF,mBAAmB,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAChD;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,GACvC,MAAM,sBAAsB,EAC5B,UAAS,yBAA8B,KACrC,KAAK,CAAC,SAAS,CAIjB,CAAC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Combined admin +
|
|
2
|
+
* Combined admin + role-grant-offer + account RPC actions for fuz_app consumers.
|
|
3
3
|
*
|
|
4
4
|
* The canonical "standard" RPC surface: every stock fuz_app RPC action a
|
|
5
5
|
* typical web consumer wants on one endpoint. Consumers that want a
|
|
6
6
|
* narrower surface drop down to the per-domain factories directly
|
|
7
|
-
* (`create_admin_actions` / `
|
|
7
|
+
* (`create_admin_actions` / `create_role_grant_offer_actions` /
|
|
8
8
|
* `create_account_actions`).
|
|
9
9
|
*
|
|
10
|
-
* Option routing: shared `roles` flows to both admin and
|
|
10
|
+
* Option routing: shared `roles` flows to both admin and role-grant-offer;
|
|
11
11
|
* `app_settings` goes to admin only; `default_ttl_ms` and `authorize` go
|
|
12
|
-
* to
|
|
13
|
-
* `notification_sender` reaches
|
|
12
|
+
* to role-grant-offer only; `max_tokens` goes to account only;
|
|
13
|
+
* `notification_sender` reaches role-grant-offer transparently (admin + account
|
|
14
14
|
* ignore it).
|
|
15
15
|
*
|
|
16
16
|
* Paired with `create_admin_rpc_adapters` on the UI side.
|
|
@@ -18,22 +18,22 @@
|
|
|
18
18
|
* @module
|
|
19
19
|
*/
|
|
20
20
|
import { create_admin_actions } from './admin_actions.js';
|
|
21
|
-
import {
|
|
21
|
+
import { create_role_grant_offer_actions, } from './role_grant_offer_actions.js';
|
|
22
22
|
import { create_account_actions } from './account_actions.js';
|
|
23
23
|
/**
|
|
24
|
-
* Build the combined admin +
|
|
24
|
+
* Build the combined admin + role-grant-offer + account RPC action set.
|
|
25
25
|
*
|
|
26
26
|
* Spreads `create_admin_actions(deps, {roles, app_settings})`,
|
|
27
|
-
* `
|
|
27
|
+
* `create_role_grant_offer_actions(deps, {roles, default_ttl_ms, authorize})`,
|
|
28
28
|
* and `create_account_actions(deps, {max_tokens})`. The shared `roles`
|
|
29
|
-
* option flows to admin +
|
|
29
|
+
* option flows to admin + role-grant-offer.
|
|
30
30
|
*
|
|
31
|
-
* @param deps - `StandardRpcActionsDeps` (`log`, `
|
|
32
|
-
* @param options - role schema, optional app-settings ref,
|
|
31
|
+
* @param deps - `StandardRpcActionsDeps` (`log`, `audit` from `RouteFactoryDeps`; optional `notification_sender` for WS fan-out)
|
|
32
|
+
* @param options - role schema, optional app-settings ref, role-grant-offer config, account config
|
|
33
33
|
* @returns RPC actions to pass as `rpc_endpoints` or spread into `create_rpc_endpoint`
|
|
34
34
|
*/
|
|
35
35
|
export const create_standard_rpc_actions = (deps, options = {}) => [
|
|
36
36
|
...create_admin_actions(deps, options),
|
|
37
|
-
...
|
|
37
|
+
...create_role_grant_offer_actions(deps, options),
|
|
38
38
|
...create_account_actions(deps, options),
|
|
39
39
|
];
|
package/dist/db/migrate.d.ts
CHANGED
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
* `(namespace, name, sequence, applied_at)` — and the runner verifies the
|
|
7
7
|
* applied list is a name-prefix of the code's migration array at boot.
|
|
8
8
|
*
|
|
9
|
-
* **
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* **Schema is not stabilized yet — append-only is NOT the rule.** While
|
|
10
|
+
* fuz_app is pre-stable, migration bodies, names, and positions can change
|
|
11
|
+
* freely between versions; consumers upgrading across a schema change are
|
|
12
|
+
* expected to drop and re-bootstrap their dev/test databases (production
|
|
13
|
+
* deployments are not yet a supported use case). Once the schema is
|
|
14
|
+
* declared stable a hard append-only-after-publish rule will apply and the
|
|
15
|
+
* cliff will be called out in that release's notes; until then, body edits
|
|
16
|
+
* to a published migration slip past the runner (no content hashing) by
|
|
17
|
+
* design — they're the recommended way to evolve the schema.
|
|
15
18
|
*
|
|
16
19
|
* **Chain-level transactions**: All pending migrations in a namespace run in
|
|
17
20
|
* a single transaction. Any failure rolls back every migration in that run —
|
|
@@ -21,7 +24,7 @@
|
|
|
21
24
|
* **Chain idempotency, not migration idempotency**: the chain-tx wraps every
|
|
22
25
|
* migration replayed in a single boot, so an individual migration may
|
|
23
26
|
* temporarily produce intermediate state that a later migration reverses
|
|
24
|
-
* (e.g. v0's `
|
|
27
|
+
* (e.g. v0's `ROLE_GRANT_INDEXES` recreates an index that v1 drops; chain-tx
|
|
25
28
|
* hides this from observers). What matters is that the *committed end state*
|
|
26
29
|
* matches; the in-tx steps may not be individually idempotent against an
|
|
27
30
|
* arbitrary mid-chain target.
|
|
@@ -53,7 +56,8 @@ export interface Migration {
|
|
|
53
56
|
/**
|
|
54
57
|
* A named group of ordered migrations.
|
|
55
58
|
*
|
|
56
|
-
* Array index = position in the chain.
|
|
59
|
+
* Array index = position in the chain. Pre-stable: bodies, names, and
|
|
60
|
+
* positions can change between versions (consumers re-bootstrap on upgrade).
|
|
57
61
|
*/
|
|
58
62
|
export interface MigrationNamespace {
|
|
59
63
|
namespace: string;
|
package/dist/db/migrate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/migrate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/db/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,KAAK,EAAC,EAAE,EAAC,MAAM,SAAS,CAAC;AAEhC;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAC7B;AAED,2DAA2D;AAC3D,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAC3B,sBAAsB,GACtB,sBAAsB,GACtB,mBAAmB,GACnB,kBAAkB,GAClB,2BAA2B,GAC3B,4BAA4B,GAC5B,sCAAsC,CAAC;AAE1C,8DAA8D;AAC9D,MAAM,WAAW,qBAAqB;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;gBAEnC,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;CAQtF;AA6ED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,cAAc,GAC1B,IAAI,EAAE,EACN,YAAY,KAAK,CAAC,kBAAkB,CAAC,KACnC,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAuFhC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,QAAQ,GACpB,IAAI,EAAE,EACN,IAAI,kBAAkB,EACtB,OAAO,aAAa,CAAC,MAAM,CAAC,KAC1B,OAAO,CAAC,IAAI,CA+Dd,CAAC"}
|
package/dist/db/migrate.js
CHANGED
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
* `(namespace, name, sequence, applied_at)` — and the runner verifies the
|
|
7
7
|
* applied list is a name-prefix of the code's migration array at boot.
|
|
8
8
|
*
|
|
9
|
-
* **
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
9
|
+
* **Schema is not stabilized yet — append-only is NOT the rule.** While
|
|
10
|
+
* fuz_app is pre-stable, migration bodies, names, and positions can change
|
|
11
|
+
* freely between versions; consumers upgrading across a schema change are
|
|
12
|
+
* expected to drop and re-bootstrap their dev/test databases (production
|
|
13
|
+
* deployments are not yet a supported use case). Once the schema is
|
|
14
|
+
* declared stable a hard append-only-after-publish rule will apply and the
|
|
15
|
+
* cliff will be called out in that release's notes; until then, body edits
|
|
16
|
+
* to a published migration slip past the runner (no content hashing) by
|
|
17
|
+
* design — they're the recommended way to evolve the schema.
|
|
15
18
|
*
|
|
16
19
|
* **Chain-level transactions**: All pending migrations in a namespace run in
|
|
17
20
|
* a single transaction. Any failure rolls back every migration in that run —
|
|
@@ -21,7 +24,7 @@
|
|
|
21
24
|
* **Chain idempotency, not migration idempotency**: the chain-tx wraps every
|
|
22
25
|
* migration replayed in a single boot, so an individual migration may
|
|
23
26
|
* temporarily produce intermediate state that a later migration reverses
|
|
24
|
-
* (e.g. v0's `
|
|
27
|
+
* (e.g. v0's `ROLE_GRANT_INDEXES` recreates an index that v1 drops; chain-tx
|
|
25
28
|
* hides this from observers). What matters is that the *committed end state*
|
|
26
29
|
* matches; the in-tx steps may not be individually idempotent against an
|
|
27
30
|
* arbitrary mid-chain target.
|
package/dist/dev/setup.d.ts
CHANGED
|
@@ -173,7 +173,7 @@ export interface SeedDevAccountInput {
|
|
|
173
173
|
username: string;
|
|
174
174
|
/** Account password. Policy is bypassed — any non-empty string is accepted. */
|
|
175
175
|
password: string;
|
|
176
|
-
/** Roles to grant via
|
|
176
|
+
/** Roles to grant via role_grant (idempotent). */
|
|
177
177
|
roles?: ReadonlyArray<string>;
|
|
178
178
|
}
|
|
179
179
|
/** Result of `seed_dev_account`. */
|
|
@@ -197,7 +197,7 @@ export interface SeedDevAccountDeps extends QueryDeps {
|
|
|
197
197
|
*
|
|
198
198
|
* Intended for `scripts/dev_setup.ts` — do not call in production.
|
|
199
199
|
*
|
|
200
|
-
* @mutates database - inserts an account/actor pair when missing and grants any requested role
|
|
200
|
+
* @mutates database - inserts an account/actor pair when missing and grants any requested role role_grants
|
|
201
201
|
* @throws Error if an existing account is found without an associated actor row
|
|
202
202
|
*/
|
|
203
203
|
export declare const seed_dev_account: (deps: SeedDevAccountDeps, input: SeedDevAccountInput, options?: {
|
package/dist/dev/setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/dev/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACX,WAAW,EACX,aAAa,EACb,OAAO,EACP,UAAU,EACV,YAAY,EACZ,WAAW,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAQnD;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAED,2CAA2C;AAC3C,eAAO,MAAM,oBAAoB,EAAE,WAIlC,CAAC;AAEF,kCAAkC;AAClC,MAAM,WAAW,cAAc;IAC9B,6DAA6D;IAC7D,OAAO,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,OAAO,EAAE,OAAO,CAAC;IACjB,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,yCAAyC;AACzC,MAAM,WAAW,gBAAgB;IAChC,kEAAkE;IAClE,OAAO,EAAE,OAAO,CAAC;IACjB,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,kCAAkC;AAClC,MAAM,WAAW,aAAa;IAC7B,+CAA+C;IAC/C,KAAK,EAAE,OAAO,CAAC;IACf,wEAAwE;IACxE,OAAO,EAAE,OAAO,CAAC;IACjB,0CAA0C;IAC1C,OAAO,EAAE,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;CACxC;AAED,oCAAoC;AACpC,MAAM,WAAW,eAAe;IAC/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B1B,CAAC;AAIF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAC3B,MAAM,WAAW,EACjB,SAAS,MAAM,EACf,UAAU,qBAAqB,KAC7B,OAAO,CAAC,aAAa,CAgBvB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,GAC1B,MAAM,WAAW,GAAG,UAAU,GAAG,YAAY,EAC7C,cAAc,MAAM,EACpB,UAAU,oBAAoB,KAC5B,OAAO,CAAC,aAAa,CA8CvB,CAAC;AAIF,mCAAmC;AACnC,MAAM,WAAW,mBAAmB;IACnC,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,KAAK,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC9B;AAED,oCAAoC;AACpC,MAAM,WAAW,oBAAoB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,2CAA2C;AAC3C,MAAM,WAAW,kBAAmB,SAAQ,SAAS;IACpD,oEAAoE;IACpE,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACrD;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,GAC5B,MAAM,kBAAkB,EACxB,OAAO,mBAAmB,EAC1B,UAAU;IAAC,GAAG,CAAC,EAAE,WAAW,CAAA;CAAC,KAC3B,OAAO,CAAC,oBAAoB,CAwC9B,CAAC"}
|
package/dist/dev/setup.js
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
|
-
import { query_account_by_username,
|
|
12
|
-
import {
|
|
11
|
+
import { query_account_by_username, query_actors_by_account, query_create_account_with_actor, } from '../auth/account_queries.js';
|
|
12
|
+
import { query_create_role_grant } from '../auth/role_grant_queries.js';
|
|
13
13
|
/** Default logger using bracket format. */
|
|
14
14
|
export const default_setup_logger = {
|
|
15
15
|
ok: (msg) => console.log(` [ok] ${msg}`),
|
|
@@ -284,7 +284,7 @@ export const reset_database = async (deps, database_url, options) => {
|
|
|
284
284
|
*
|
|
285
285
|
* Intended for `scripts/dev_setup.ts` — do not call in production.
|
|
286
286
|
*
|
|
287
|
-
* @mutates database - inserts an account/actor pair when missing and grants any requested role
|
|
287
|
+
* @mutates database - inserts an account/actor pair when missing and grants any requested role role_grants
|
|
288
288
|
* @throws Error if an existing account is found without an associated actor row
|
|
289
289
|
*/
|
|
290
290
|
export const seed_dev_account = async (deps, input, options) => {
|
|
@@ -292,13 +292,15 @@ export const seed_dev_account = async (deps, input, options) => {
|
|
|
292
292
|
const query_deps = { db: deps.db };
|
|
293
293
|
const existing = await query_account_by_username(query_deps, input.username);
|
|
294
294
|
if (existing) {
|
|
295
|
-
const
|
|
296
|
-
if (
|
|
295
|
+
const actors = await query_actors_by_account(query_deps, existing.id);
|
|
296
|
+
if (actors.length === 0) {
|
|
297
297
|
log.error(`dev account '${input.username}' exists but has no actor`);
|
|
298
298
|
throw new Error(`dev account '${input.username}' has no actor`);
|
|
299
299
|
}
|
|
300
|
+
// Dev seed is single-actor by construction; pick the first.
|
|
301
|
+
const actor = actors[0];
|
|
300
302
|
for (const role of input.roles ?? []) {
|
|
301
|
-
await
|
|
303
|
+
await query_create_role_grant(query_deps, {
|
|
302
304
|
actor_id: actor.id,
|
|
303
305
|
role,
|
|
304
306
|
granted_by: null,
|
|
@@ -314,7 +316,7 @@ export const seed_dev_account = async (deps, input, options) => {
|
|
|
314
316
|
password_hash,
|
|
315
317
|
});
|
|
316
318
|
for (const role of input.roles ?? []) {
|
|
317
|
-
await
|
|
319
|
+
await query_create_role_grant(query_deps, {
|
|
318
320
|
actor_id: actor.id,
|
|
319
321
|
role,
|
|
320
322
|
granted_by: null,
|
package/dist/env/load.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare class EnvValidationError extends Error {
|
|
|
35
35
|
* `error.all_undefined` before calling this.
|
|
36
36
|
*
|
|
37
37
|
* @param error - the env validation error
|
|
38
|
-
* @param label - optional prefix for log lines (e.g., '
|
|
38
|
+
* @param label - optional prefix for log lines (e.g., 'zap daemon', 'env')
|
|
39
39
|
*/
|
|
40
40
|
export declare const log_env_validation_error: (error: EnvValidationError, label?: string) => void;
|
|
41
41
|
/**
|
package/dist/env/load.js
CHANGED
|
@@ -42,7 +42,7 @@ export class EnvValidationError extends Error {
|
|
|
42
42
|
* `error.all_undefined` before calling this.
|
|
43
43
|
*
|
|
44
44
|
* @param error - the env validation error
|
|
45
|
-
* @param label - optional prefix for log lines (e.g., '
|
|
45
|
+
* @param label - optional prefix for log lines (e.g., 'zap daemon', 'env')
|
|
46
46
|
*/
|
|
47
47
|
export const log_env_validation_error = (error, label) => {
|
|
48
48
|
const prefix = label ? `[${label}] ` : '';
|
package/dist/hono_context.d.ts
CHANGED
|
@@ -12,19 +12,50 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { z } from 'zod';
|
|
14
14
|
import type { RequestContext } from './auth/request_context.js';
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* The credential types that can authenticate a request — the closed set
|
|
17
|
+
* of fuz_app builtins. The open registry on top
|
|
18
|
+
* (`create_credential_type_schema(consumer_types)`) is consulted at
|
|
19
|
+
* registry time by `create_role_schema` for `RoleSpec.required_credential_types`
|
|
20
|
+
* validation; the wire-validated `CredentialType` enum here stays
|
|
21
|
+
* narrow because middleware only ever sets one of the three builtins.
|
|
22
|
+
*/
|
|
16
23
|
export declare const CREDENTIAL_TYPES: readonly ["session", "api_token", "daemon_token"];
|
|
17
24
|
/** Credential type — how a request was authenticated. */
|
|
18
25
|
export declare const CredentialType: z.ZodEnum<{
|
|
26
|
+
daemon_token: "daemon_token";
|
|
19
27
|
session: "session";
|
|
20
28
|
api_token: "api_token";
|
|
21
|
-
daemon_token: "daemon_token";
|
|
22
29
|
}>;
|
|
23
30
|
export type CredentialType = z.infer<typeof CredentialType>;
|
|
24
31
|
/** Hono context variable name for the credential type. */
|
|
25
32
|
export declare const CREDENTIAL_TYPE_KEY = "credential_type";
|
|
26
33
|
/** Hono context variable name for the authenticated API token id. */
|
|
27
34
|
export declare const AUTH_API_TOKEN_ID_KEY = "auth_api_token_id";
|
|
35
|
+
/**
|
|
36
|
+
* Hono context variable name for the authenticated account id.
|
|
37
|
+
*
|
|
38
|
+
* Set by the auth middleware (session, bearer, or daemon token) on a valid
|
|
39
|
+
* credential. `null` for unauthenticated requests. The route-spec wrapper /
|
|
40
|
+
* RPC dispatcher's authorization phase reads this when resolving the acting
|
|
41
|
+
* actor; account-grain auth guards (`require_auth`) and account-grain handlers
|
|
42
|
+
* read it directly.
|
|
43
|
+
*/
|
|
44
|
+
export declare const ACCOUNT_ID_KEY = "auth_account_id";
|
|
45
|
+
/**
|
|
46
|
+
* Hono context variable name for the test-harness pre-baked context flag.
|
|
47
|
+
*
|
|
48
|
+
* Test harnesses (`create_test_app_from_specs`, `create_fake_hono_context`,
|
|
49
|
+
* the WS round-trip `connect()` helper, plus per-test middleware that
|
|
50
|
+
* pre-populates `REQUEST_CONTEXT_KEY`) set this to `true` so
|
|
51
|
+
* `apply_authorization_phase` skips its DB-backed actor resolution and
|
|
52
|
+
* trusts the supplied `RequestContext`. Production middleware never sets
|
|
53
|
+
* this key — only test code does. The flag is the explicit escape hatch
|
|
54
|
+
* that replaced the implicit "is `REQUEST_CONTEXT_KEY` already set?" probe,
|
|
55
|
+
* so that future production code consulting `REQUEST_CONTEXT_KEY` cannot
|
|
56
|
+
* silently bypass the live build.
|
|
57
|
+
*/
|
|
58
|
+
export declare const TEST_CONTEXT_PRESET_KEY = "test_context_preset";
|
|
28
59
|
declare module 'hono' {
|
|
29
60
|
interface ContextVariableMap {
|
|
30
61
|
/** Resolved client IP, set by the trusted proxy middleware. */
|
|
@@ -36,6 +67,13 @@ declare module 'hono' {
|
|
|
36
67
|
validated_query: unknown;
|
|
37
68
|
/** How the request was authenticated (`'session'`, `'api_token'`, or `'daemon_token'`). */
|
|
38
69
|
credential_type: CredentialType | null;
|
|
70
|
+
/**
|
|
71
|
+
* Authenticated account id. Set by the session / bearer / daemon-token
|
|
72
|
+
* middleware on a valid credential; `null` for unauthenticated requests.
|
|
73
|
+
* The dispatcher's authorization phase resolves the acting actor against
|
|
74
|
+
* this id; `require_auth` 401s when it is `null`.
|
|
75
|
+
*/
|
|
76
|
+
auth_account_id: string | null;
|
|
39
77
|
/**
|
|
40
78
|
* blake3 hash of the authenticated session token, or `null` for non-session
|
|
41
79
|
* credentials. Set by `create_request_context_middleware`. Used to scope
|
|
@@ -52,11 +90,32 @@ declare module 'hono' {
|
|
|
52
90
|
*/
|
|
53
91
|
auth_api_token_id: string | null;
|
|
54
92
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
93
|
+
* Eager fire-and-forget pool writes for this request — audit emits,
|
|
94
|
+
* session-touch UPDATE, api-token usage tracking. Producers push the
|
|
95
|
+
* in-flight `Promise<void>` directly. The flush middleware drains via
|
|
96
|
+
* `flush_pending_effects` after the handler returns. Initialized by
|
|
97
|
+
* `create_app_server`. In test mode (`await_pending_effects: true`),
|
|
98
|
+
* every promise resolves before the response returns.
|
|
58
99
|
*/
|
|
59
100
|
pending_effects: Array<Promise<void>>;
|
|
101
|
+
/**
|
|
102
|
+
* Post-commit thunks pushed via `emit_after_commit(ctx, fn)`. The
|
|
103
|
+
* flush middleware invokes each thunk after the handler returns —
|
|
104
|
+
* never inline — so notifications (WS sends, etc.) cannot fire
|
|
105
|
+
* mid-transaction. Producers do not push raw thunks directly. The
|
|
106
|
+
* flush owns per-thunk `try/catch` + `log.error` so a directly-pushed
|
|
107
|
+
* thunk (tests included) cannot escape the safety net.
|
|
108
|
+
* Initialized by `create_app_server`. In test mode
|
|
109
|
+
* (`await_pending_effects: true`), every thunk completes before the
|
|
110
|
+
* response returns.
|
|
111
|
+
*/
|
|
112
|
+
post_commit_effects: Array<() => void | Promise<void>>;
|
|
113
|
+
/**
|
|
114
|
+
* Set to `true` by test harnesses that pre-populate `request_context`
|
|
115
|
+
* to bypass the dispatcher's DB-backed actor resolution. Read by
|
|
116
|
+
* `apply_authorization_phase`. Production middleware never sets this.
|
|
117
|
+
*/
|
|
118
|
+
test_context_preset: boolean;
|
|
60
119
|
}
|
|
61
120
|
}
|
|
62
121
|
//# sourceMappingURL=hono_context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hono_context.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/hono_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"hono_context.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/hono_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAO9D;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,mDAInB,CAAC;AAEX,yDAAyD;AACzD,eAAO,MAAM,cAAc;;;;EAA2B,CAAC;AACvD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AAEzD;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,wBAAwB,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