@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
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
14
14
|
import { z } from 'zod';
|
|
15
|
-
import type
|
|
15
|
+
import { type RouteAuth } from './auth_shape.js';
|
|
16
16
|
/** Request body failed Zod validation. */
|
|
17
17
|
export declare const ERROR_INVALID_REQUEST_BODY: "invalid_request_body";
|
|
18
18
|
/** Request body is not valid JSON or not an object. */
|
|
@@ -25,6 +25,16 @@ export declare const ERROR_INVALID_QUERY_PARAMS: "invalid_query_params";
|
|
|
25
25
|
export declare const ERROR_AUTHENTICATION_REQUIRED: "authentication_required";
|
|
26
26
|
/** Authenticated but missing required role. */
|
|
27
27
|
export declare const ERROR_INSUFFICIENT_PERMISSIONS: "insufficient_permissions";
|
|
28
|
+
/**
|
|
29
|
+
* Route requires a credential type the request didn't arrive on.
|
|
30
|
+
* Symmetric with `ERROR_INSUFFICIENT_PERMISSIONS` + `required_roles`:
|
|
31
|
+
* the body carries `required_credential_types: ReadonlyArray<string>`
|
|
32
|
+
* — what the route demanded, not what arrived. Today the only
|
|
33
|
+
* credential gate is keeper (`['daemon_token']`); future gates
|
|
34
|
+
* (`agent_token`, `group_actor_token`) reuse the same literal and
|
|
35
|
+
* label themselves through the array.
|
|
36
|
+
*/
|
|
37
|
+
export declare const ERROR_CREDENTIAL_TYPE_REQUIRED: "credential_type_required";
|
|
28
38
|
/** Rate limiter rejected the request. */
|
|
29
39
|
export declare const ERROR_RATE_LIMIT_EXCEEDED: "rate_limit_exceeded";
|
|
30
40
|
/** Username or password is wrong (intentionally vague for enumeration prevention). */
|
|
@@ -41,8 +51,39 @@ export declare const ERROR_BEARER_REJECTED_BROWSER: "bearer_token_rejected_in_br
|
|
|
41
51
|
export declare const ERROR_INVALID_TOKEN: "invalid_token";
|
|
42
52
|
/** Token references a deleted account. */
|
|
43
53
|
export declare const ERROR_ACCOUNT_NOT_FOUND: "account_not_found";
|
|
44
|
-
/**
|
|
45
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Multi-actor account requires the request to carry an explicit `acting`
|
|
56
|
+
* field naming the actor the request is acting as, so the dispatcher's
|
|
57
|
+
* authorization phase doesn't pick a default actor silently. Returned
|
|
58
|
+
* with the available actors so the client can prompt.
|
|
59
|
+
*/
|
|
60
|
+
export declare const ERROR_ACTOR_REQUIRED: "actor_required";
|
|
61
|
+
/**
|
|
62
|
+
* Supplied `acting` field does not name an actor on the authenticated
|
|
63
|
+
* account.
|
|
64
|
+
*/
|
|
65
|
+
export declare const ERROR_ACTOR_NOT_ON_ACCOUNT: "actor_not_on_account";
|
|
66
|
+
/**
|
|
67
|
+
* Authenticated account exists but has no actors. Server invariant
|
|
68
|
+
* violation — signup / bootstrap always create an actor in the same
|
|
69
|
+
* transaction. Surfaced from the dispatcher's authorization phase as a
|
|
70
|
+
* 500 so the operator sees the corruption signal rather than a confusing
|
|
71
|
+
* 4xx. Distinct from `ERROR_ACCOUNT_VANISHED`: the actor list was
|
|
72
|
+
* enumerated successfully and came back empty.
|
|
73
|
+
*/
|
|
74
|
+
export declare const ERROR_NO_ACTORS_ON_ACCOUNT: "no_actors_on_account";
|
|
75
|
+
/**
|
|
76
|
+
* Authentication validated an account, but a follow-up read in the
|
|
77
|
+
* authorization phase came back null — the account or its named actor
|
|
78
|
+
* row was deleted between the credential check and the dispatcher's
|
|
79
|
+
* `build_request_context` / `build_account_context` step. Torn read,
|
|
80
|
+
* not a missing-actor invariant violation. Surfaced as 500 so the
|
|
81
|
+
* operator sees the race signal; clients can retry. Distinct from
|
|
82
|
+
* `ERROR_ACCOUNT_NOT_FOUND` (stale token referencing a long-deleted
|
|
83
|
+
* account, raised at credential validation) and
|
|
84
|
+
* `ERROR_NO_ACTORS_ON_ACCOUNT` (the actor list enumerated empty).
|
|
85
|
+
*/
|
|
86
|
+
export declare const ERROR_ACCOUNT_VANISHED: "account_vanished";
|
|
46
87
|
/** Daemon token header present but malformed or not matching current/previous token. */
|
|
47
88
|
export declare const ERROR_INVALID_DAEMON_TOKEN: "invalid_daemon_token";
|
|
48
89
|
/** Daemon token valid but keeper account not yet resolved (pre-bootstrap). */
|
|
@@ -71,8 +112,8 @@ export declare const ERROR_INVITE_ACCOUNT_EXISTS_USERNAME: "invite_account_exist
|
|
|
71
112
|
export declare const ERROR_INVITE_ACCOUNT_EXISTS_EMAIL: "invite_account_exists_email";
|
|
72
113
|
/** Admin tried to grant a role that is not web-grantable. */
|
|
73
114
|
export declare const ERROR_ROLE_NOT_WEB_GRANTABLE: "role_not_web_grantable";
|
|
74
|
-
/**
|
|
75
|
-
export declare const
|
|
115
|
+
/** Role grant ID not found or not owned by the target actor. */
|
|
116
|
+
export declare const ERROR_ROLE_GRANT_NOT_FOUND: "role_grant_not_found";
|
|
76
117
|
/** Query parameter `event_type` is not a valid audit event type. */
|
|
77
118
|
export declare const ERROR_INVALID_EVENT_TYPE: "invalid_event_type";
|
|
78
119
|
/** DELETE blocked by a foreign key constraint. */
|
|
@@ -104,18 +145,37 @@ export declare const ValidationError: z.ZodObject<{
|
|
|
104
145
|
}, z.core.$loose>>;
|
|
105
146
|
}, z.core.$loose>;
|
|
106
147
|
export type ValidationError = z.infer<typeof ValidationError>;
|
|
107
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* Permission error — returned by `require_role()` and the dispatcher's
|
|
150
|
+
* post-authorization role gate when the actor's role_grants don't include any
|
|
151
|
+
* of the route's `auth.roles`.
|
|
152
|
+
*
|
|
153
|
+
* `required_roles` carries the full disjunction the route declared
|
|
154
|
+
* (`auth.roles` from the new flat-record shape). Single-role specs surface
|
|
155
|
+
* as a one-element array; multi-role disjunctions show every admittable
|
|
156
|
+
* role so clients can render targeted copy ("requires admin or steward").
|
|
157
|
+
*/
|
|
108
158
|
export declare const PermissionError: z.ZodObject<{
|
|
109
159
|
error: z.ZodLiteral<"insufficient_permissions">;
|
|
110
|
-
|
|
160
|
+
required_roles: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
111
161
|
}, z.core.$loose>;
|
|
112
162
|
export type PermissionError = z.infer<typeof PermissionError>;
|
|
113
|
-
/**
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Credential-type error — returned by the dispatcher's post-authorization
|
|
165
|
+
* credential gate (and the `require_credential_types` REST middleware) when
|
|
166
|
+
* the request's credential type isn't in the route's
|
|
167
|
+
* `auth.credential_types` allowlist.
|
|
168
|
+
*
|
|
169
|
+
* `required_credential_types` carries what the route declared
|
|
170
|
+
* (`['daemon_token']` for keeper; future gates carry their own labels).
|
|
171
|
+
* Symmetric with `PermissionError`'s `required_roles`: clients see what
|
|
172
|
+
* the route demanded, not what their credential is.
|
|
173
|
+
*/
|
|
174
|
+
export declare const CredentialTypeRequiredError: z.ZodObject<{
|
|
175
|
+
error: z.ZodLiteral<"credential_type_required">;
|
|
176
|
+
required_credential_types: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
117
177
|
}, z.core.$loose>;
|
|
118
|
-
export type
|
|
178
|
+
export type CredentialTypeRequiredError = z.infer<typeof CredentialTypeRequiredError>;
|
|
119
179
|
/** Rate limit error — returned when a rate limiter rejects the request. */
|
|
120
180
|
export declare const RateLimitError: z.ZodObject<{
|
|
121
181
|
error: z.ZodLiteral<"rate_limit_exceeded">;
|
|
@@ -132,6 +192,44 @@ export declare const ForeignKeyError: z.ZodObject<{
|
|
|
132
192
|
error: z.ZodLiteral<"foreign_key_violation">;
|
|
133
193
|
}, z.core.$loose>;
|
|
134
194
|
export type ForeignKeyError = z.infer<typeof ForeignKeyError>;
|
|
195
|
+
/**
|
|
196
|
+
* Authorization-phase failure shapes. Surfaced when the dispatcher's
|
|
197
|
+
* `apply_authorization_phase` rejects a request before the handler runs —
|
|
198
|
+
* the route is acting-aware (input declares `acting?: ActingActor` or
|
|
199
|
+
* auth requires role_grants), but actor resolution failed.
|
|
200
|
+
*
|
|
201
|
+
* 400: `actor_required` (with `available[]`) for unspecified-actor on
|
|
202
|
+
* a multi-actor account; `actor_not_on_account` for a supplied actor
|
|
203
|
+
* id that doesn't belong to the authenticated account.
|
|
204
|
+
*
|
|
205
|
+
* 500: `no_actors_on_account` for a signup-invariant violation (the
|
|
206
|
+
* actor list enumerated empty); `account_vanished` for a torn-read
|
|
207
|
+
* race (account/actor row deleted between credential validation and
|
|
208
|
+
* the dispatcher's follow-up read).
|
|
209
|
+
*
|
|
210
|
+
* Used by `derive_error_schemas` when `auth.actor !== 'none'` so the
|
|
211
|
+
* merged error surface matches what the dispatcher actually emits.
|
|
212
|
+
*/
|
|
213
|
+
export declare const ActorRequiredError: z.ZodObject<{
|
|
214
|
+
error: z.ZodLiteral<"actor_required">;
|
|
215
|
+
available: z.ZodArray<z.ZodObject<{
|
|
216
|
+
id: z.ZodString;
|
|
217
|
+
name: z.ZodString;
|
|
218
|
+
}, z.core.$loose>>;
|
|
219
|
+
}, z.core.$loose>;
|
|
220
|
+
export type ActorRequiredError = z.infer<typeof ActorRequiredError>;
|
|
221
|
+
export declare const ActorNotOnAccountError: z.ZodObject<{
|
|
222
|
+
error: z.ZodLiteral<"actor_not_on_account">;
|
|
223
|
+
}, z.core.$loose>;
|
|
224
|
+
export type ActorNotOnAccountError = z.infer<typeof ActorNotOnAccountError>;
|
|
225
|
+
export declare const NoActorsOnAccountError: z.ZodObject<{
|
|
226
|
+
error: z.ZodLiteral<"no_actors_on_account">;
|
|
227
|
+
}, z.core.$loose>;
|
|
228
|
+
export type NoActorsOnAccountError = z.infer<typeof NoActorsOnAccountError>;
|
|
229
|
+
export declare const AccountVanishedError: z.ZodObject<{
|
|
230
|
+
error: z.ZodLiteral<"account_vanished">;
|
|
231
|
+
}, z.core.$loose>;
|
|
232
|
+
export type AccountVanishedError = z.infer<typeof AccountVanishedError>;
|
|
135
233
|
/**
|
|
136
234
|
* Error schema map — maps HTTP status codes to Zod schemas.
|
|
137
235
|
*
|
|
@@ -161,12 +259,27 @@ export type RateLimitKey = z.infer<typeof RateLimitKey>;
|
|
|
161
259
|
* Route handlers can declare additional error schemas via `RouteSpec.errors`;
|
|
162
260
|
* explicit entries override auto-derived ones for the same status code.
|
|
163
261
|
*
|
|
164
|
-
* Derivation rules:
|
|
165
|
-
* - **Has input
|
|
166
|
-
* -
|
|
167
|
-
* -
|
|
168
|
-
*
|
|
169
|
-
* -
|
|
262
|
+
* Derivation rules under the new flat-record auth shape:
|
|
263
|
+
* - **Has input / params / query schema**: 400 (`ValidationError`).
|
|
264
|
+
* - **`auth.account === 'required'`** or **`auth.actor === 'required'`**: 401
|
|
265
|
+
* (`ApiError`) — pre-validation 401 fires when the credential isn't there.
|
|
266
|
+
* `'optional'` does not derive 401.
|
|
267
|
+
* - **`auth.roles?.length`**: 403 (`PermissionError` carrying `required_roles`).
|
|
268
|
+
* - **`auth.credential_types?.length`**: 403 (`CredentialTypeRequiredError`
|
|
269
|
+
* carrying `required_credential_types` — symmetric with `PermissionError`).
|
|
270
|
+
* Today the only credential gate is keeper; future gates reuse the literal.
|
|
271
|
+
* - **`auth.actor !== 'none'`** (`'optional'` or `'required'`): extends 400
|
|
272
|
+
* with `ActorRequiredError` / `ActorNotOnAccountError` and adds 500 union
|
|
273
|
+
* of `NoActorsOnAccountError` / `AccountVanishedError`. The dispatcher's
|
|
274
|
+
* authorization phase emits these whenever it tries to resolve an actor.
|
|
275
|
+
* - **rate_limit**: 429 (`RateLimitError` with `retry_after`).
|
|
170
276
|
*/
|
|
171
|
-
export
|
|
277
|
+
export interface DeriveErrorSchemasOptions {
|
|
278
|
+
auth: RouteAuth;
|
|
279
|
+
has_input?: boolean;
|
|
280
|
+
has_params?: boolean;
|
|
281
|
+
has_query?: boolean;
|
|
282
|
+
rate_limit?: RateLimitKey;
|
|
283
|
+
}
|
|
284
|
+
export declare const derive_error_schemas: ({ auth, has_input, has_params, has_query, rate_limit, }: DeriveErrorSchemasOptions) => RouteErrorSchemas;
|
|
172
285
|
//# sourceMappingURL=error_schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error_schemas.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/error_schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"error_schemas.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/error_schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAc,KAAK,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAI5D,0CAA0C;AAC1C,eAAO,MAAM,0BAA0B,EAAG,sBAA+B,CAAC;AAE1E,uDAAuD;AACvD,eAAO,MAAM,uBAAuB,EAAG,mBAA4B,CAAC;AAEpE,6CAA6C;AAC7C,eAAO,MAAM,0BAA0B,EAAG,sBAA+B,CAAC;AAE1E,8CAA8C;AAC9C,eAAO,MAAM,0BAA0B,EAAG,sBAA+B,CAAC;AAI1E,wCAAwC;AACxC,eAAO,MAAM,6BAA6B,EAAG,yBAAkC,CAAC;AAEhF,+CAA+C;AAC/C,eAAO,MAAM,8BAA8B,EAAG,0BAAmC,CAAC;AAElF;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,EAAG,0BAAmC,CAAC;AAElF,yCAAyC;AACzC,eAAO,MAAM,yBAAyB,EAAG,qBAA8B,CAAC;AAExE,sFAAsF;AACtF,eAAO,MAAM,yBAAyB,EAAG,qBAA8B,CAAC;AAExE,qDAAqD;AACrD,eAAO,MAAM,uBAAuB,EAAG,mBAA4B,CAAC;AAIpE,uCAAuC;AACvC,eAAO,MAAM,sBAAsB,EAAG,kBAA2B,CAAC;AAElE,wCAAwC;AACxC,eAAO,MAAM,uBAAuB,EAAG,mBAA4B,CAAC;AAEpE,sEAAsE;AACtE,eAAO,M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AO,CAAC;IACpB,UAAU,CAAC,EAAE,YAAY,CAAC;CAC1B;AAED,eAAO,MAAM,oBAAoB,GAAI,yDAMlC,yBAAyB,KAAG,iBAwC9B,CAAC"}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
14
14
|
import { z } from 'zod';
|
|
15
|
+
import { needs_actor } from './auth_shape.js';
|
|
15
16
|
// --- Core: Validation (auto-derived by route spec middleware) ---
|
|
16
17
|
/** Request body failed Zod validation. */
|
|
17
18
|
export const ERROR_INVALID_REQUEST_BODY = 'invalid_request_body';
|
|
@@ -26,6 +27,16 @@ export const ERROR_INVALID_QUERY_PARAMS = 'invalid_query_params';
|
|
|
26
27
|
export const ERROR_AUTHENTICATION_REQUIRED = 'authentication_required';
|
|
27
28
|
/** Authenticated but missing required role. */
|
|
28
29
|
export const ERROR_INSUFFICIENT_PERMISSIONS = 'insufficient_permissions';
|
|
30
|
+
/**
|
|
31
|
+
* Route requires a credential type the request didn't arrive on.
|
|
32
|
+
* Symmetric with `ERROR_INSUFFICIENT_PERMISSIONS` + `required_roles`:
|
|
33
|
+
* the body carries `required_credential_types: ReadonlyArray<string>`
|
|
34
|
+
* — what the route demanded, not what arrived. Today the only
|
|
35
|
+
* credential gate is keeper (`['daemon_token']`); future gates
|
|
36
|
+
* (`agent_token`, `group_actor_token`) reuse the same literal and
|
|
37
|
+
* label themselves through the array.
|
|
38
|
+
*/
|
|
39
|
+
export const ERROR_CREDENTIAL_TYPE_REQUIRED = 'credential_type_required';
|
|
29
40
|
/** Rate limiter rejected the request. */
|
|
30
41
|
export const ERROR_RATE_LIMIT_EXCEEDED = 'rate_limit_exceeded';
|
|
31
42
|
/** Username or password is wrong (intentionally vague for enumeration prevention). */
|
|
@@ -43,9 +54,40 @@ export const ERROR_BEARER_REJECTED_BROWSER = 'bearer_token_rejected_in_browser_c
|
|
|
43
54
|
export const ERROR_INVALID_TOKEN = 'invalid_token';
|
|
44
55
|
/** Token references a deleted account. */
|
|
45
56
|
export const ERROR_ACCOUNT_NOT_FOUND = 'account_not_found';
|
|
57
|
+
/**
|
|
58
|
+
* Multi-actor account requires the request to carry an explicit `acting`
|
|
59
|
+
* field naming the actor the request is acting as, so the dispatcher's
|
|
60
|
+
* authorization phase doesn't pick a default actor silently. Returned
|
|
61
|
+
* with the available actors so the client can prompt.
|
|
62
|
+
*/
|
|
63
|
+
export const ERROR_ACTOR_REQUIRED = 'actor_required';
|
|
64
|
+
/**
|
|
65
|
+
* Supplied `acting` field does not name an actor on the authenticated
|
|
66
|
+
* account.
|
|
67
|
+
*/
|
|
68
|
+
export const ERROR_ACTOR_NOT_ON_ACCOUNT = 'actor_not_on_account';
|
|
69
|
+
/**
|
|
70
|
+
* Authenticated account exists but has no actors. Server invariant
|
|
71
|
+
* violation — signup / bootstrap always create an actor in the same
|
|
72
|
+
* transaction. Surfaced from the dispatcher's authorization phase as a
|
|
73
|
+
* 500 so the operator sees the corruption signal rather than a confusing
|
|
74
|
+
* 4xx. Distinct from `ERROR_ACCOUNT_VANISHED`: the actor list was
|
|
75
|
+
* enumerated successfully and came back empty.
|
|
76
|
+
*/
|
|
77
|
+
export const ERROR_NO_ACTORS_ON_ACCOUNT = 'no_actors_on_account';
|
|
78
|
+
/**
|
|
79
|
+
* Authentication validated an account, but a follow-up read in the
|
|
80
|
+
* authorization phase came back null — the account or its named actor
|
|
81
|
+
* row was deleted between the credential check and the dispatcher's
|
|
82
|
+
* `build_request_context` / `build_account_context` step. Torn read,
|
|
83
|
+
* not a missing-actor invariant violation. Surfaced as 500 so the
|
|
84
|
+
* operator sees the race signal; clients can retry. Distinct from
|
|
85
|
+
* `ERROR_ACCOUNT_NOT_FOUND` (stale token referencing a long-deleted
|
|
86
|
+
* account, raised at credential validation) and
|
|
87
|
+
* `ERROR_NO_ACTORS_ON_ACCOUNT` (the actor list enumerated empty).
|
|
88
|
+
*/
|
|
89
|
+
export const ERROR_ACCOUNT_VANISHED = 'account_vanished';
|
|
46
90
|
// --- Keeper / daemon token ---
|
|
47
|
-
/** Keeper routes require daemon_token credential type. */
|
|
48
|
-
export const ERROR_KEEPER_REQUIRES_DAEMON_TOKEN = 'keeper_requires_daemon_token';
|
|
49
91
|
/** Daemon token header present but malformed or not matching current/previous token. */
|
|
50
92
|
export const ERROR_INVALID_DAEMON_TOKEN = 'invalid_daemon_token';
|
|
51
93
|
/** Daemon token valid but keeper account not yet resolved (pre-bootstrap). */
|
|
@@ -77,8 +119,8 @@ export const ERROR_INVITE_ACCOUNT_EXISTS_EMAIL = 'invite_account_exists_email';
|
|
|
77
119
|
// --- Admin routes ---
|
|
78
120
|
/** Admin tried to grant a role that is not web-grantable. */
|
|
79
121
|
export const ERROR_ROLE_NOT_WEB_GRANTABLE = 'role_not_web_grantable';
|
|
80
|
-
/**
|
|
81
|
-
export const
|
|
122
|
+
/** Role grant ID not found or not owned by the target actor. */
|
|
123
|
+
export const ERROR_ROLE_GRANT_NOT_FOUND = 'role_grant_not_found';
|
|
82
124
|
/** Query parameter `event_type` is not a valid audit event type. */
|
|
83
125
|
export const ERROR_INVALID_EVENT_TYPE = 'invalid_event_type';
|
|
84
126
|
// --- DB table browser ---
|
|
@@ -109,15 +151,34 @@ export const ValidationError = z.looseObject({
|
|
|
109
151
|
path: z.array(z.union([z.string(), z.number()])),
|
|
110
152
|
})),
|
|
111
153
|
});
|
|
112
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Permission error — returned by `require_role()` and the dispatcher's
|
|
156
|
+
* post-authorization role gate when the actor's role_grants don't include any
|
|
157
|
+
* of the route's `auth.roles`.
|
|
158
|
+
*
|
|
159
|
+
* `required_roles` carries the full disjunction the route declared
|
|
160
|
+
* (`auth.roles` from the new flat-record shape). Single-role specs surface
|
|
161
|
+
* as a one-element array; multi-role disjunctions show every admittable
|
|
162
|
+
* role so clients can render targeted copy ("requires admin or steward").
|
|
163
|
+
*/
|
|
113
164
|
export const PermissionError = z.looseObject({
|
|
114
165
|
error: z.literal(ERROR_INSUFFICIENT_PERMISSIONS),
|
|
115
|
-
|
|
166
|
+
required_roles: z.array(z.string()).readonly(),
|
|
116
167
|
});
|
|
117
|
-
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Credential-type error — returned by the dispatcher's post-authorization
|
|
170
|
+
* credential gate (and the `require_credential_types` REST middleware) when
|
|
171
|
+
* the request's credential type isn't in the route's
|
|
172
|
+
* `auth.credential_types` allowlist.
|
|
173
|
+
*
|
|
174
|
+
* `required_credential_types` carries what the route declared
|
|
175
|
+
* (`['daemon_token']` for keeper; future gates carry their own labels).
|
|
176
|
+
* Symmetric with `PermissionError`'s `required_roles`: clients see what
|
|
177
|
+
* the route demanded, not what their credential is.
|
|
178
|
+
*/
|
|
179
|
+
export const CredentialTypeRequiredError = z.looseObject({
|
|
180
|
+
error: z.literal(ERROR_CREDENTIAL_TYPE_REQUIRED),
|
|
181
|
+
required_credential_types: z.array(z.string()).readonly(),
|
|
121
182
|
});
|
|
122
183
|
/** Rate limit error — returned when a rate limiter rejects the request. */
|
|
123
184
|
export const RateLimitError = z.looseObject({
|
|
@@ -132,6 +193,37 @@ export const PayloadTooLargeError = z.looseObject({
|
|
|
132
193
|
export const ForeignKeyError = z.looseObject({
|
|
133
194
|
error: z.literal(ERROR_FOREIGN_KEY_VIOLATION),
|
|
134
195
|
});
|
|
196
|
+
/**
|
|
197
|
+
* Authorization-phase failure shapes. Surfaced when the dispatcher's
|
|
198
|
+
* `apply_authorization_phase` rejects a request before the handler runs —
|
|
199
|
+
* the route is acting-aware (input declares `acting?: ActingActor` or
|
|
200
|
+
* auth requires role_grants), but actor resolution failed.
|
|
201
|
+
*
|
|
202
|
+
* 400: `actor_required` (with `available[]`) for unspecified-actor on
|
|
203
|
+
* a multi-actor account; `actor_not_on_account` for a supplied actor
|
|
204
|
+
* id that doesn't belong to the authenticated account.
|
|
205
|
+
*
|
|
206
|
+
* 500: `no_actors_on_account` for a signup-invariant violation (the
|
|
207
|
+
* actor list enumerated empty); `account_vanished` for a torn-read
|
|
208
|
+
* race (account/actor row deleted between credential validation and
|
|
209
|
+
* the dispatcher's follow-up read).
|
|
210
|
+
*
|
|
211
|
+
* Used by `derive_error_schemas` when `auth.actor !== 'none'` so the
|
|
212
|
+
* merged error surface matches what the dispatcher actually emits.
|
|
213
|
+
*/
|
|
214
|
+
export const ActorRequiredError = z.looseObject({
|
|
215
|
+
error: z.literal(ERROR_ACTOR_REQUIRED),
|
|
216
|
+
available: z.array(z.looseObject({ id: z.string(), name: z.string() })),
|
|
217
|
+
});
|
|
218
|
+
export const ActorNotOnAccountError = z.looseObject({
|
|
219
|
+
error: z.literal(ERROR_ACTOR_NOT_ON_ACCOUNT),
|
|
220
|
+
});
|
|
221
|
+
export const NoActorsOnAccountError = z.looseObject({
|
|
222
|
+
error: z.literal(ERROR_NO_ACTORS_ON_ACCOUNT),
|
|
223
|
+
});
|
|
224
|
+
export const AccountVanishedError = z.looseObject({
|
|
225
|
+
error: z.literal(ERROR_ACCOUNT_VANISHED),
|
|
226
|
+
});
|
|
135
227
|
/**
|
|
136
228
|
* Rate limit key type — declares what a route or RPC action's rate limiter
|
|
137
229
|
* is keyed on.
|
|
@@ -143,39 +235,39 @@ export const ForeignKeyError = z.looseObject({
|
|
|
143
235
|
* - `'both'` — both keys.
|
|
144
236
|
*/
|
|
145
237
|
export const RateLimitKey = z.enum(['ip', 'account', 'both']);
|
|
146
|
-
|
|
147
|
-
* Derive error schemas from a route's auth requirement, input schema, and rate limit config.
|
|
148
|
-
*
|
|
149
|
-
* Returns the error schemas that middleware will auto-produce for this route.
|
|
150
|
-
* Route handlers can declare additional error schemas via `RouteSpec.errors`;
|
|
151
|
-
* explicit entries override auto-derived ones for the same status code.
|
|
152
|
-
*
|
|
153
|
-
* Derivation rules:
|
|
154
|
-
* - **Has input schema** (non-null) or **has params schema** or **has query schema**: 400 (validation error with issues)
|
|
155
|
-
* - **auth: authenticated**: 401
|
|
156
|
-
* - **auth: role**: 401 + 403 (with `required_role`)
|
|
157
|
-
* - **auth: keeper**: 401 + 403 (keeper-specific)
|
|
158
|
-
* - **rate_limit**: 429 (rate limit exceeded with `retry_after`)
|
|
159
|
-
*/
|
|
160
|
-
export const derive_error_schemas = (auth, has_input, has_params = false, has_query = false, rate_limit) => {
|
|
238
|
+
export const derive_error_schemas = ({ auth, has_input = false, has_params = false, has_query = false, rate_limit, }) => {
|
|
161
239
|
const errors = {};
|
|
162
|
-
|
|
240
|
+
const has_validation = has_input || has_params || has_query;
|
|
241
|
+
if (needs_actor(auth)) {
|
|
242
|
+
errors[400] = has_validation
|
|
243
|
+
? z.union([ValidationError, ActorRequiredError, ActorNotOnAccountError])
|
|
244
|
+
: z.union([ActorRequiredError, ActorNotOnAccountError]);
|
|
245
|
+
errors[500] = z.union([NoActorsOnAccountError, AccountVanishedError]);
|
|
246
|
+
}
|
|
247
|
+
else if (has_validation) {
|
|
163
248
|
errors[400] = ValidationError;
|
|
164
249
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
250
|
+
// 401 fires when the dispatcher's pre-validation gate rejects an
|
|
251
|
+
// unauthenticated caller — `account === 'required'` (no credential) or
|
|
252
|
+
// `actor === 'required'` (no credential to resolve an actor against,
|
|
253
|
+
// per registry-time invariant 3 forbidding accountless actors in v1).
|
|
254
|
+
if (auth.account === 'required' || auth.actor === 'required') {
|
|
255
|
+
errors[401] = ApiError;
|
|
256
|
+
}
|
|
257
|
+
// 403 fires when `auth.roles` or `auth.credential_types` rejects a
|
|
258
|
+
// resolved request context. With both axes set, the 403 body could be
|
|
259
|
+
// either shape — emit the union so DEV-mode error-schema validation
|
|
260
|
+
// accepts whichever the dispatcher produced.
|
|
261
|
+
const has_role_gate = !!auth.roles?.length;
|
|
262
|
+
const has_credential_gate = !!auth.credential_types?.length;
|
|
263
|
+
if (has_role_gate && has_credential_gate) {
|
|
264
|
+
errors[403] = z.union([PermissionError, CredentialTypeRequiredError]);
|
|
265
|
+
}
|
|
266
|
+
else if (has_role_gate) {
|
|
267
|
+
errors[403] = PermissionError;
|
|
268
|
+
}
|
|
269
|
+
else if (has_credential_gate) {
|
|
270
|
+
errors[403] = CredentialTypeRequiredError;
|
|
179
271
|
}
|
|
180
272
|
if (rate_limit) {
|
|
181
273
|
errors[429] = RateLimitError;
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @module
|
|
18
18
|
*/
|
|
19
|
+
import type { ContentfulStatusCode } from 'hono/utils/http-status';
|
|
19
20
|
import { type JsonrpcErrorCode, type JsonrpcErrorObject } from './jsonrpc.js';
|
|
20
21
|
/** Default message for unknown errors. */
|
|
21
22
|
export declare const UNKNOWN_ERROR_MESSAGE = "unknown error";
|
|
@@ -97,13 +98,37 @@ export declare const HTTP_STATUS_TO_JSONRPC_ERROR_CODE: Record<number, JsonrpcEr
|
|
|
97
98
|
* Map a JSON-RPC error code to an HTTP status code.
|
|
98
99
|
*
|
|
99
100
|
* Returns 500 for unrecognized codes (consumer-defined codes
|
|
100
|
-
* without a mapping default to internal server error).
|
|
101
|
+
* without a mapping default to internal server error). The return
|
|
102
|
+
* is narrowed to Hono's `ContentfulStatusCode` so call sites can
|
|
103
|
+
* pass the result to `c.json(body, status)` without `as any` —
|
|
104
|
+
* 499 (nginx "client closed request") is non-standard and gets
|
|
105
|
+
* absorbed by the cast here rather than at every dispatcher branch.
|
|
101
106
|
*/
|
|
102
|
-
export declare const jsonrpc_error_code_to_http_status: (code: JsonrpcErrorCode) =>
|
|
107
|
+
export declare const jsonrpc_error_code_to_http_status: (code: JsonrpcErrorCode) => ContentfulStatusCode;
|
|
103
108
|
/**
|
|
104
109
|
* Map an HTTP status code to a JSON-RPC error code.
|
|
105
110
|
*
|
|
106
111
|
* Returns `internal_error` (-32603) for unrecognized status codes.
|
|
107
112
|
*/
|
|
108
113
|
export declare const http_status_to_jsonrpc_error_code: (status: number) => JsonrpcErrorCode;
|
|
114
|
+
/**
|
|
115
|
+
* Reverse map of `JSONRPC_ERROR_CODES` — JSON-RPC error code → name.
|
|
116
|
+
*
|
|
117
|
+
* Used by REST emitters that need a stable string identifier for the
|
|
118
|
+
* code in their flat-shape error body (`{error: '<name>', ...}`)
|
|
119
|
+
* without inventing a separate vocabulary. Built once at module load
|
|
120
|
+
* from the canonical `JSONRPC_ERROR_CODES` map so the two cannot drift.
|
|
121
|
+
*
|
|
122
|
+
* Consumer-defined codes outside the standard taxonomy are not present;
|
|
123
|
+
* `jsonrpc_error_code_to_name` falls back to `'internal_error'` so the
|
|
124
|
+
* REST shape always carries some reason rather than `undefined`.
|
|
125
|
+
*/
|
|
126
|
+
export declare const JSONRPC_ERROR_CODE_TO_NAME: Readonly<Record<number, JsonrpcErrorName>>;
|
|
127
|
+
/**
|
|
128
|
+
* Map a JSON-RPC error code to its canonical name (`'not_found'`,
|
|
129
|
+
* `'forbidden'`, etc.). Falls back to `'internal_error'` for codes
|
|
130
|
+
* outside the standard taxonomy so REST emitters that read this for
|
|
131
|
+
* their `error` field always have a stable string to emit.
|
|
132
|
+
*/
|
|
133
|
+
export declare const jsonrpc_error_code_to_name: (code: JsonrpcErrorCode) => JsonrpcErrorName;
|
|
109
134
|
//# sourceMappingURL=jsonrpc_errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonrpc_errors.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/jsonrpc_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAMN,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,MAAM,cAAc,CAAC;AAEtB,0CAA0C;AAC1C,eAAO,MAAM,qBAAqB,kBAAkB,CAAC;AAErD,sEAAsE;AACtE,MAAM,MAA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AlB,kBAAkB;iDAAlB,kBAAkB;kDAAlB,kBAAkB;4CAAlB,kBAAkB;4CAAlB,kBAAkB;2CAAlB,kBAAkB;mDAAlB,kBAAkB;+CAAlB,kBAAkB;sDAAlB,kBAAkB;0CAAlB,kBAAkB;iDAAlB,kBAAkB;oDAAlB,kBAAkB;CA2BqC,CAAC;AAI3F;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAkBpE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAMzC,CAAC;AAEvC;;;;;;;;;GASG;AACH,eAAO,MAAM,iCAAiC,GAAI,MAAM,gBAAgB,KAAG,oBACQ,CAAC;AAEpF;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,GAAI,QAAQ,MAAM,KAAG,gBACa,CAAC;AAEjF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAMjF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GAAI,MAAM,gBAAgB,KAAG,gBACL,CAAC"}
|
|
@@ -242,12 +242,36 @@ export const HTTP_STATUS_TO_JSONRPC_ERROR_CODE = Object.fromEntries(Object.entri
|
|
|
242
242
|
* Map a JSON-RPC error code to an HTTP status code.
|
|
243
243
|
*
|
|
244
244
|
* Returns 500 for unrecognized codes (consumer-defined codes
|
|
245
|
-
* without a mapping default to internal server error).
|
|
245
|
+
* without a mapping default to internal server error). The return
|
|
246
|
+
* is narrowed to Hono's `ContentfulStatusCode` so call sites can
|
|
247
|
+
* pass the result to `c.json(body, status)` without `as any` —
|
|
248
|
+
* 499 (nginx "client closed request") is non-standard and gets
|
|
249
|
+
* absorbed by the cast here rather than at every dispatcher branch.
|
|
246
250
|
*/
|
|
247
|
-
export const jsonrpc_error_code_to_http_status = (code) => JSONRPC_ERROR_CODE_TO_HTTP_STATUS[code] ?? 500;
|
|
251
|
+
export const jsonrpc_error_code_to_http_status = (code) => (JSONRPC_ERROR_CODE_TO_HTTP_STATUS[code] ?? 500);
|
|
248
252
|
/**
|
|
249
253
|
* Map an HTTP status code to a JSON-RPC error code.
|
|
250
254
|
*
|
|
251
255
|
* Returns `internal_error` (-32603) for unrecognized status codes.
|
|
252
256
|
*/
|
|
253
257
|
export const http_status_to_jsonrpc_error_code = (status) => HTTP_STATUS_TO_JSONRPC_ERROR_CODE[status] ?? JSONRPC_ERROR_CODES.internal_error;
|
|
258
|
+
/**
|
|
259
|
+
* Reverse map of `JSONRPC_ERROR_CODES` — JSON-RPC error code → name.
|
|
260
|
+
*
|
|
261
|
+
* Used by REST emitters that need a stable string identifier for the
|
|
262
|
+
* code in their flat-shape error body (`{error: '<name>', ...}`)
|
|
263
|
+
* without inventing a separate vocabulary. Built once at module load
|
|
264
|
+
* from the canonical `JSONRPC_ERROR_CODES` map so the two cannot drift.
|
|
265
|
+
*
|
|
266
|
+
* Consumer-defined codes outside the standard taxonomy are not present;
|
|
267
|
+
* `jsonrpc_error_code_to_name` falls back to `'internal_error'` so the
|
|
268
|
+
* REST shape always carries some reason rather than `undefined`.
|
|
269
|
+
*/
|
|
270
|
+
export const JSONRPC_ERROR_CODE_TO_NAME = Object.freeze(Object.fromEntries(Object.entries(JSONRPC_ERROR_CODES).map(([name, code]) => [code, name])));
|
|
271
|
+
/**
|
|
272
|
+
* Map a JSON-RPC error code to its canonical name (`'not_found'`,
|
|
273
|
+
* `'forbidden'`, etc.). Falls back to `'internal_error'` for codes
|
|
274
|
+
* outside the standard taxonomy so REST emitters that read this for
|
|
275
|
+
* their `error` field always have a stable string to emit.
|
|
276
|
+
*/
|
|
277
|
+
export const jsonrpc_error_code_to_name = (code) => JSONRPC_ERROR_CODE_TO_NAME[code] ?? 'internal_error';
|