@fuzdev/fuz_app 0.55.0 → 0.57.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 +211 -155
- 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 +19 -0
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +20 -14
- 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 +110 -44
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +92 -287
- 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 +44 -38
- 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 +2 -10
- package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
- package/dist/actions/register_ws_endpoint.js +32 -10
- 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 +673 -442
- 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 +8 -14
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +26 -32
- package/dist/auth/account_queries.d.ts +46 -13
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +73 -33
- package/dist/auth/account_routes.d.ts +4 -3
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +58 -33
- package/dist/auth/account_schema.d.ts +46 -54
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +21 -48
- package/dist/auth/admin_action_specs.d.ts +55 -21
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +42 -26
- package/dist/auth/admin_actions.d.ts +14 -21
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +47 -44
- 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 -87
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +17 -96
- 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 +48 -42
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +56 -43
- 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/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 -47
- 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 +1 -1
- package/dist/auth/daemon_token_middleware.js +3 -3
- 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 -32
- 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 +5 -2
- package/dist/auth/migrations.d.ts +22 -7
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +64 -25
- package/dist/auth/request_context.d.ts +157 -170
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +224 -268
- package/dist/auth/{permit_offer_action_specs.d.ts → role_grant_offer_action_specs.d.ts} +130 -100
- 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/{permit_offer_actions.js → role_grant_offer_actions.js} +153 -140
- package/dist/auth/{permit_offer_notifications.d.ts → role_grant_offer_notifications.d.ts} +80 -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/{permit_offer_queries.d.ts → role_grant_offer_queries.d.ts} +64 -64
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -0
- package/dist/auth/{permit_offer_queries.js → role_grant_offer_queries.js} +136 -123
- 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} +55 -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 +4 -1
- package/dist/auth/self_service_role_action_specs.d.ts.map +1 -1
- package/dist/auth/self_service_role_action_specs.js +2 -2
- package/dist/auth/self_service_role_actions.d.ts +35 -29
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +58 -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 +1 -1
- package/dist/db/migrate.js +1 -1
- package/dist/dev/setup.d.ts +2 -2
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +4 -4
- package/dist/env/load.d.ts +1 -1
- package/dist/env/load.js +1 -1
- package/dist/hono_context.d.ts +27 -45
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +14 -28
- package/dist/http/CLAUDE.md +235 -121
- 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 +72 -39
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +81 -33
- 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 +89 -75
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +54 -72
- package/dist/http/schema_helpers.d.ts +3 -14
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +2 -14
- package/dist/http/surface.d.ts +2 -10
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +3 -4
- 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 +35 -40
- package/dist/server/validate_nginx.d.ts +1 -1
- package/dist/server/validate_nginx.js +1 -1
- package/dist/testing/CLAUDE.md +50 -38
- 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 +87 -85
- 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 +16 -15
- 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 +36 -36
- 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 +22 -19
- 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 +8 -7
- package/dist/testing/entities.d.ts.map +1 -1
- package/dist/testing/entities.js +21 -18
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +13 -14
- package/dist/testing/integration_helpers.d.ts +4 -4
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +20 -18
- package/dist/testing/middleware.d.ts +4 -4
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +12 -11
- package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
- package/dist/testing/rpc_attack_surface.js +40 -24
- 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 +14 -6
- package/dist/testing/surface_invariants.d.ts.map +1 -1
- package/dist/testing/surface_invariants.js +119 -43
- 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 +19 -11
- 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 +60 -60
- package/dist/ui/{PermitOfferForm.svelte → RoleGrantOfferForm.svelte} +27 -26
- package/dist/ui/{PermitOfferForm.svelte.d.ts → RoleGrantOfferForm.svelte.d.ts} +7 -7
- 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 +18 -18
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.js +16 -16
- 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} +30 -30
- 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} +18 -18
- 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 -258
- 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_notifications.d.ts.map +0 -1
- package/dist/auth/permit_offer_notifications.js +0 -182
- package/dist/auth/permit_offer_queries.d.ts.map +0 -1
- package/dist/auth/permit_offer_schema.d.ts +0 -125
- package/dist/auth/permit_offer_schema.d.ts.map +0 -1
- package/dist/auth/permit_queries.d.ts +0 -222
- package/dist/auth/permit_queries.d.ts.map +0 -1
- package/dist/auth/permit_queries.js +0 -305
- 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 -27
- package/dist/auth/route_guards.d.ts.map +0 -1
- package/dist/auth/route_guards.js +0 -38
- 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.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
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* **Chain idempotency, not migration idempotency**: the chain-tx wraps every
|
|
25
25
|
* migration replayed in a single boot, so an individual migration may
|
|
26
26
|
* temporarily produce intermediate state that a later migration reverses
|
|
27
|
-
* (e.g. v0's `
|
|
27
|
+
* (e.g. v0's `ROLE_GRANT_INDEXES` recreates an index that v1 drops; chain-tx
|
|
28
28
|
* hides this from observers). What matters is that the *committed end state*
|
|
29
29
|
* matches; the in-tx steps may not be individually idempotent against an
|
|
30
30
|
* arbitrary mid-chain target.
|
package/dist/db/migrate.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* **Chain idempotency, not migration idempotency**: the chain-tx wraps every
|
|
25
25
|
* migration replayed in a single boot, so an individual migration may
|
|
26
26
|
* temporarily produce intermediate state that a later migration reverses
|
|
27
|
-
* (e.g. v0's `
|
|
27
|
+
* (e.g. v0's `ROLE_GRANT_INDEXES` recreates an index that v1 drops; chain-tx
|
|
28
28
|
* hides this from observers). What matters is that the *committed end state*
|
|
29
29
|
* matches; the in-tx steps may not be individually idempotent against an
|
|
30
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":"AAA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AM,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
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
11
|
import { query_account_by_username, query_actors_by_account, query_create_account_with_actor, } from '../auth/account_queries.js';
|
|
12
|
-
import {
|
|
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) => {
|
|
@@ -300,7 +300,7 @@ export const seed_dev_account = async (deps, input, options) => {
|
|
|
300
300
|
// Dev seed is single-actor by construction; pick the first.
|
|
301
301
|
const actor = actors[0];
|
|
302
302
|
for (const role of input.roles ?? []) {
|
|
303
|
-
await
|
|
303
|
+
await query_create_role_grant(query_deps, {
|
|
304
304
|
actor_id: actor.id,
|
|
305
305
|
role,
|
|
306
306
|
granted_by: null,
|
|
@@ -316,7 +316,7 @@ export const seed_dev_account = async (deps, input, options) => {
|
|
|
316
316
|
password_hash,
|
|
317
317
|
});
|
|
318
318
|
for (const role of input.roles ?? []) {
|
|
319
|
-
await
|
|
319
|
+
await query_create_role_grant(query_deps, {
|
|
320
320
|
actor_id: actor.id,
|
|
321
321
|
role,
|
|
322
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,13 +12,20 @@
|
|
|
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. */
|
|
@@ -49,39 +56,6 @@ export declare const ACCOUNT_ID_KEY = "auth_account_id";
|
|
|
49
56
|
* silently bypass the live build.
|
|
50
57
|
*/
|
|
51
58
|
export declare const TEST_CONTEXT_PRESET_KEY = "test_context_preset";
|
|
52
|
-
/**
|
|
53
|
-
* Cached parsed JSON request body, keyed by `'cached_request_body'`.
|
|
54
|
-
*
|
|
55
|
-
* Written by `read_raw_acting` (in the dispatcher's authorization
|
|
56
|
-
* phase) when it pre-parses the body to extract the `acting` field;
|
|
57
|
-
* read by `create_input_validation` so the input-validation step does
|
|
58
|
-
* not pay for a second `JSON.parse` on the same Hono-cached body text.
|
|
59
|
-
*
|
|
60
|
-
* Decouples our pipeline from Hono's internal `bodyCache` shape: Hono
|
|
61
|
-
* caches the body *text* (so a second `c.req.json()` call doesn't
|
|
62
|
-
* re-read the request stream), but each call still re-runs
|
|
63
|
-
* `JSON.parse(text)`. Storing the parsed value here saves the second
|
|
64
|
-
* parse and keeps fuz_app from depending on undocumented Hono
|
|
65
|
-
* implementation details.
|
|
66
|
-
*
|
|
67
|
-
* Three states:
|
|
68
|
-
*
|
|
69
|
-
* - Key absent — body has not been pre-parsed yet (the route had no
|
|
70
|
-
* `acting` to extract, or the request is GET).
|
|
71
|
-
* - `{ok: true, body: unknown}` — pre-parse succeeded; the parsed
|
|
72
|
-
* value (object, primitive, or array) is in `body`.
|
|
73
|
-
* - `{ok: false}` — pre-parse threw (malformed JSON). The downstream
|
|
74
|
-
* input-validation step short-circuits with `ERROR_INVALID_JSON_BODY`
|
|
75
|
-
* instead of re-parsing.
|
|
76
|
-
*/
|
|
77
|
-
export declare const CACHED_REQUEST_BODY_KEY = "cached_request_body";
|
|
78
|
-
/** The shape stored under `CACHED_REQUEST_BODY_KEY`. */
|
|
79
|
-
export type CachedRequestBody = {
|
|
80
|
-
ok: true;
|
|
81
|
-
body: unknown;
|
|
82
|
-
} | {
|
|
83
|
-
ok: false;
|
|
84
|
-
};
|
|
85
59
|
declare module 'hono' {
|
|
86
60
|
interface ContextVariableMap {
|
|
87
61
|
/** Resolved client IP, set by the trusted proxy middleware. */
|
|
@@ -116,24 +90,32 @@ declare module 'hono' {
|
|
|
116
90
|
*/
|
|
117
91
|
auth_api_token_id: string | null;
|
|
118
92
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
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.
|
|
122
99
|
*/
|
|
123
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>>;
|
|
124
113
|
/**
|
|
125
114
|
* Set to `true` by test harnesses that pre-populate `request_context`
|
|
126
115
|
* to bypass the dispatcher's DB-backed actor resolution. Read by
|
|
127
116
|
* `apply_authorization_phase`. Production middleware never sets this.
|
|
128
117
|
*/
|
|
129
118
|
test_context_preset: boolean;
|
|
130
|
-
/**
|
|
131
|
-
* Pre-parsed JSON request body cache. Written by `read_raw_acting`
|
|
132
|
-
* (the dispatcher's `acting` extractor) and read by
|
|
133
|
-
* `create_input_validation` so the same body is not parsed twice.
|
|
134
|
-
* See `CACHED_REQUEST_BODY_KEY` for state semantics.
|
|
135
|
-
*/
|
|
136
|
-
cached_request_body: CachedRequestBody;
|
|
137
119
|
}
|
|
138
120
|
}
|
|
139
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,cA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AE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC;;;;;;;;;;WAUG;QACH,mBAAmB,EAAE,KAAK,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD;;;;WAIG;QACH,mBAAmB,EAAE,OAAO,CAAC;KAC7B;CACD"}
|
package/dist/hono_context.js
CHANGED
|
@@ -11,8 +11,20 @@
|
|
|
11
11
|
* @module
|
|
12
12
|
*/
|
|
13
13
|
import { z } from 'zod';
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
import { CREDENTIAL_TYPE_API_TOKEN, CREDENTIAL_TYPE_DAEMON_TOKEN, CREDENTIAL_TYPE_SESSION, } from './auth/credential_type_schema.js';
|
|
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
|
+
*/
|
|
23
|
+
export const CREDENTIAL_TYPES = [
|
|
24
|
+
CREDENTIAL_TYPE_SESSION,
|
|
25
|
+
CREDENTIAL_TYPE_API_TOKEN,
|
|
26
|
+
CREDENTIAL_TYPE_DAEMON_TOKEN,
|
|
27
|
+
];
|
|
16
28
|
/** Credential type — how a request was authenticated. */
|
|
17
29
|
export const CredentialType = z.enum(CREDENTIAL_TYPES);
|
|
18
30
|
/** Hono context variable name for the credential type. */
|
|
@@ -43,29 +55,3 @@ export const ACCOUNT_ID_KEY = 'auth_account_id';
|
|
|
43
55
|
* silently bypass the live build.
|
|
44
56
|
*/
|
|
45
57
|
export const TEST_CONTEXT_PRESET_KEY = 'test_context_preset';
|
|
46
|
-
/**
|
|
47
|
-
* Cached parsed JSON request body, keyed by `'cached_request_body'`.
|
|
48
|
-
*
|
|
49
|
-
* Written by `read_raw_acting` (in the dispatcher's authorization
|
|
50
|
-
* phase) when it pre-parses the body to extract the `acting` field;
|
|
51
|
-
* read by `create_input_validation` so the input-validation step does
|
|
52
|
-
* not pay for a second `JSON.parse` on the same Hono-cached body text.
|
|
53
|
-
*
|
|
54
|
-
* Decouples our pipeline from Hono's internal `bodyCache` shape: Hono
|
|
55
|
-
* caches the body *text* (so a second `c.req.json()` call doesn't
|
|
56
|
-
* re-read the request stream), but each call still re-runs
|
|
57
|
-
* `JSON.parse(text)`. Storing the parsed value here saves the second
|
|
58
|
-
* parse and keeps fuz_app from depending on undocumented Hono
|
|
59
|
-
* implementation details.
|
|
60
|
-
*
|
|
61
|
-
* Three states:
|
|
62
|
-
*
|
|
63
|
-
* - Key absent — body has not been pre-parsed yet (the route had no
|
|
64
|
-
* `acting` to extract, or the request is GET).
|
|
65
|
-
* - `{ok: true, body: unknown}` — pre-parse succeeded; the parsed
|
|
66
|
-
* value (object, primitive, or array) is in `body`.
|
|
67
|
-
* - `{ok: false}` — pre-parse threw (malformed JSON). The downstream
|
|
68
|
-
* input-validation step short-circuits with `ERROR_INVALID_JSON_BODY`
|
|
69
|
-
* instead of re-parsing.
|
|
70
|
-
*/
|
|
71
|
-
export const CACHED_REQUEST_BODY_KEY = 'cached_request_body';
|