@fuzdev/fuz_app 0.181.0 → 0.183.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/README.md +2 -0
- package/dist/actions/CLAUDE.md +28 -10
- package/dist/actions/action_rpc.d.ts +11 -1
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +3 -2
- package/dist/actions/action_types.d.ts +16 -1
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +1 -1
- package/dist/actions/notification_sender.d.ts +83 -0
- package/dist/actions/notification_sender.d.ts.map +1 -0
- package/dist/actions/notification_sender.js +85 -0
- package/dist/actions/perform_action.d.ts +9 -0
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +22 -13
- package/dist/actions/register_action_ws.d.ts +14 -0
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +3 -2
- package/dist/actions/ws_socket_session.d.ts +3 -0
- package/dist/actions/ws_socket_session.d.ts.map +1 -1
- package/dist/actions/ws_socket_session.js +2 -1
- package/dist/auth/CLAUDE.md +113 -70
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +13 -3
- package/dist/auth/account_queries.d.ts +158 -16
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +189 -18
- package/dist/auth/account_routes.d.ts +6 -4
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +98 -92
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +93 -45
- package/dist/auth/api_token_queries.d.ts +13 -5
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +24 -9
- package/dist/auth/audit_emitter.d.ts +75 -84
- package/dist/auth/audit_emitter.d.ts.map +1 -1
- package/dist/auth/audit_emitter.js +83 -71
- package/dist/auth/audit_log_schema.d.ts +10 -5
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +22 -6
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +3 -2
- package/dist/auth/bootstrap_account.d.ts +31 -13
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +34 -15
- package/dist/auth/bootstrap_routes.d.ts +1 -1
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +7 -14
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +12 -1
- package/dist/auth/deps.d.ts +18 -5
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/deps.js +3 -2
- package/dist/auth/request_context.d.ts +73 -73
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +78 -96
- package/dist/auth/resolved_auth.d.ts +16 -11
- package/dist/auth/resolved_auth.d.ts.map +1 -1
- package/dist/auth/resolved_auth.js +6 -6
- package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +2 -1
- package/dist/auth/role_grant_offer_actions.d.ts +32 -12
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +91 -116
- package/dist/auth/role_grant_offer_notifications.d.ts +87 -38
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_notifications.js +75 -22
- package/dist/auth/role_grant_offer_queries.d.ts +155 -18
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +262 -73
- package/dist/auth/role_grant_offer_schema.js +1 -1
- package/dist/auth/role_grant_queries.d.ts +43 -52
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +50 -74
- package/dist/auth/role_grant_sql.d.ts +21 -0
- package/dist/auth/role_grant_sql.d.ts.map +1 -1
- package/dist/auth/role_grant_sql.js +21 -0
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +17 -21
- package/dist/auth/session_queries.d.ts +40 -16
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +68 -29
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +90 -38
- package/dist/auth/standard_rpc_actions.d.ts +6 -19
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/standard_rpc_actions.js +5 -6
- package/dist/auth/token_scope.d.ts +1 -1
- package/dist/auth/token_scope.js +1 -1
- package/dist/db/sql_columns.d.ts +1 -1
- package/dist/db/sql_columns.js +1 -1
- package/dist/http/CLAUDE.md +22 -16
- package/dist/http/auth_shape.d.ts +1 -1
- package/dist/http/db_routes.d.ts +7 -22
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +72 -72
- package/dist/http/error_schemas.d.ts +9 -21
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +14 -24
- package/dist/http/pending_effects.d.ts +42 -4
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +34 -4
- package/dist/http/route_spec.d.ts +2 -2
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +3 -1
- package/dist/server/app_server.d.ts +69 -18
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +74 -10
- package/dist/server/serve_fact_route.d.ts +3 -3
- package/dist/server/serve_fact_route.js +12 -12
- package/dist/testing/CLAUDE.md +259 -790
- package/dist/testing/adversarial_404.d.ts +6 -1
- package/dist/testing/adversarial_404.d.ts.map +1 -1
- package/dist/testing/adversarial_404.js +38 -17
- package/dist/testing/app_server.d.ts +20 -140
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +48 -125
- package/dist/testing/audit_drift_guard.d.ts +11 -6
- package/dist/testing/audit_drift_guard.d.ts.map +1 -1
- package/dist/testing/audit_drift_guard.js +15 -8
- package/dist/testing/auth_apps.js +1 -1
- package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/account_lifecycle.js +43 -0
- package/dist/testing/cross_backend/audit_cross_helpers.d.ts +12 -9
- package/dist/testing/cross_backend/audit_cross_helpers.d.ts.map +1 -1
- package/dist/testing/cross_backend/audit_cross_helpers.js +13 -14
- package/dist/testing/cross_backend/capabilities.d.ts +9 -6
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/capabilities.js +11 -7
- package/dist/testing/cross_backend/capability_mounts.d.ts +103 -0
- package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -0
- package/dist/testing/cross_backend/capability_mounts.js +423 -0
- package/dist/testing/cross_backend/cell_moderate.js +2 -2
- package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_relations.js +12 -11
- package/dist/testing/cross_backend/conformance_principal.d.ts +54 -0
- package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -0
- package/dist/testing/cross_backend/conformance_principal.js +283 -0
- package/dist/testing/cross_backend/conformance_table.d.ts +2 -50
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/conformance_table.js +2 -270
- package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -1
- package/dist/testing/cross_backend/credential_deadline.js +2 -0
- package/dist/testing/cross_backend/credential_wire.d.ts +1 -1
- package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -1
- package/dist/testing/cross_backend/db_state_diff.d.ts +72 -0
- package/dist/testing/cross_backend/db_state_diff.d.ts.map +1 -0
- package/dist/testing/cross_backend/db_state_diff.js +444 -0
- package/dist/testing/cross_backend/declared_skips.d.ts +68 -0
- package/dist/testing/cross_backend/declared_skips.d.ts.map +1 -0
- package/dist/testing/cross_backend/declared_skips.js +132 -0
- package/dist/testing/cross_backend/default_spine_surface.d.ts +1 -26
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +2 -6
- package/dist/testing/cross_backend/differential.d.ts +11 -2
- package/dist/testing/cross_backend/differential.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential.js +35 -11
- package/dist/testing/cross_backend/differential_normalize.d.ts +12 -0
- package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
- package/dist/testing/cross_backend/differential_normalize.js +16 -0
- package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -10
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +4 -4
- package/dist/testing/cross_backend/in_process_setup.d.ts +22 -12
- package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/in_process_setup.js +151 -134
- package/dist/testing/cross_backend/login_security.d.ts +12 -0
- package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
- package/dist/testing/cross_backend/login_security.js +21 -4
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +0 -2
- package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -1
- package/dist/testing/cross_backend/request_target_conformance_wire.js +3 -1
- package/dist/testing/cross_backend/revocation_drivers.d.ts +18 -5
- package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
- package/dist/testing/cross_backend/revocation_drivers.js +18 -10
- package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +1 -1
- package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +33 -1
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +5 -4
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +183 -30
- package/dist/testing/cross_backend/role_grant_participation.js +4 -4
- package/dist/testing/cross_backend/rpc_adversarial.js +1 -1
- package/dist/testing/cross_backend/session_cap.d.ts +2 -2
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +48 -16
- package/dist/testing/cross_backend/setup.d.ts +31 -1
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +32 -1
- package/dist/testing/cross_backend/spine_suites.d.ts +123 -12
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +454 -57
- package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
- package/dist/testing/cross_backend/sse_round_trip.d.ts +9 -1
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +123 -27
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +4 -2
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +59 -27
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +66 -42
- package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
- package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
- package/dist/testing/cross_backend/transport_composition.js +7 -3
- package/dist/testing/cross_backend/ws_round_trip.d.ts +5 -0
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +54 -8
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +3 -0
- package/dist/testing/db.d.ts +0 -32
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +0 -86
- package/dist/testing/db_entities.d.ts +14 -0
- package/dist/testing/db_entities.d.ts.map +1 -1
- package/dist/testing/db_entities.js +17 -0
- package/dist/testing/db_invariant_queries.d.ts +259 -0
- package/dist/testing/db_invariant_queries.d.ts.map +1 -0
- package/dist/testing/db_invariant_queries.js +400 -0
- package/dist/testing/db_invariants.d.ts +106 -0
- package/dist/testing/db_invariants.d.ts.map +1 -0
- package/dist/testing/db_invariants.gen.sql.d.ts +11 -0
- package/dist/testing/db_invariants.gen.sql.d.ts.map +1 -0
- package/dist/testing/db_invariants.gen.sql.js +13 -0
- package/dist/testing/db_invariants.js +141 -0
- package/dist/testing/db_invariants.sql +152 -0
- package/dist/testing/describe_db.d.ts +36 -0
- package/dist/testing/describe_db.d.ts.map +1 -0
- package/dist/testing/describe_db.js +71 -0
- package/dist/testing/integration.d.ts +6 -9
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +9 -13
- package/dist/testing/integration_helpers.d.ts +1 -1
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/middleware.d.ts +1 -1
- package/dist/testing/middleware.js +5 -5
- package/dist/testing/rate_limiting.d.ts +1 -1
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +3 -2
- package/dist/testing/resolved_auth.d.ts +3 -1
- package/dist/testing/resolved_auth.d.ts.map +1 -1
- package/dist/testing/resolved_auth.js +4 -4
- package/dist/testing/role_grant_helpers.d.ts +1 -1
- package/dist/testing/role_grant_helpers.d.ts.map +1 -1
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +3 -0
- package/dist/testing/rpc_attack_surface.d.ts +8 -6
- package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
- package/dist/testing/rpc_attack_surface.js +69 -6
- 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 +3 -0
- package/dist/testing/sse_round_trip.d.ts +1 -1
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +13 -4
- package/dist/testing/stubs.d.ts +4 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +15 -7
- package/dist/testing/test_app.d.ts +166 -0
- package/dist/testing/test_app.d.ts.map +1 -0
- package/dist/testing/test_app.js +124 -0
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +8 -4
- package/package.json +1 -1
package/dist/http/CLAUDE.md
CHANGED
|
@@ -66,7 +66,7 @@ consumers.
|
|
|
66
66
|
- `input: AnySchema` — request body schema; `literal(null)` for no body, and on every `GET` (`apply_route_specs` refuses any other)
|
|
67
67
|
- `output: AnySchema` — success response schema
|
|
68
68
|
- `mints_credential?: boolean` — the route issues a session cookie while declaring no auth (login, signup, bootstrap); assembly refuses it outside `AUTH_MIDDLEWARE_PATH`, as it does any route whose `auth.account` is not `'none'` (`assert_credential_routes_in_auth_scope` in `auth/middleware.ts`)
|
|
69
|
-
- `reads_credential?: boolean` — the handler reads the resolved account while the route declares no auth gate, answering an anonymous caller itself (account status, the cell-scoped fact read, `create_rpc_endpoint`'s pair, whose dispatcher gates per action); held inside `AUTH_MIDDLEWARE_PATH` by the same assertion. Such a handler reads the account through `
|
|
69
|
+
- `reads_credential?: boolean` — the handler reads the resolved account while the route declares no auth gate, answering an anonymous caller itself (account status, the cell-scoped fact read, `create_rpc_endpoint`'s pair, whose dispatcher gates per action); held inside `AUTH_MIDDLEWARE_PATH` by the same assertion. Such a handler reads the account through `get_public_account` (`auth/request_context.ts`), which answers a scope-narrowed token as anonymous — the RPC pair excepted, its dispatcher gating each method
|
|
70
70
|
- `rate_limit?: RateLimitKey` — metadata only (`'ip' | 'account' | 'both'`); auto-derives 429
|
|
71
71
|
- `errors?: ReadonlyArray<RestErrorDef>` — the handler's own error definitions (`rest_error`); joins the route error map beside the derived and middleware ones
|
|
72
72
|
- `jsonrpc?: boolean` — the route answers JSON-RPC envelopes, not REST bodies; set by `create_rpc_endpoint`, read by the DEV error check and `assert_response_matches_spec`
|
|
@@ -209,7 +209,7 @@ interface RouteContext<TAuth, TInput, TParams, TQuery> {
|
|
|
209
209
|
answers 500, not a handler running on `null`).
|
|
210
210
|
- **`route.credential`** is the whole resolved credential. A
|
|
211
211
|
`reads_credential` route never reads the account off it: it calls
|
|
212
|
-
`
|
|
212
|
+
`get_public_account(route)` (`auth/request_context.ts`), which answers
|
|
213
213
|
a scope-narrowed API token as the anonymous caller
|
|
214
214
|
(`src/test/auth/token_scope_surface_census.test.ts` holds every route
|
|
215
215
|
module to that).
|
|
@@ -270,7 +270,7 @@ declares any), so every stage after it answers with them:
|
|
|
270
270
|
1. **Params validation** — `spec.params` → `validated_params` context var; mismatch returns 400 `ERROR_INVALID_ROUTE_PARAMS` with `issues`. Each param is decoded strictly from the raw target first (`read_request_route_params`): an escape that doesn't decode is the same 400 with no `issues`, whatever the schema
|
|
271
271
|
2. **Query validation** — `spec.query` → `validated_query`; mismatch returns 400 `ERROR_INVALID_QUERY_PARAMS`. The query is decoded strictly first (`read_request_query_pairs`): an escape that doesn't decode, in any key or value, is the same 400
|
|
272
272
|
3. **Pre-authorization auth guards** — every gate that reads only what the auth middleware set, in coarse-to-fine order: `require_auth` (401 `ERROR_AUTHENTICATION_REQUIRED`) when `auth.account === 'required'` or `auth.actor === 'required'`; `require_credential_types(types)` (403 `ERROR_CREDENTIAL_TYPE_REQUIRED` with `required_credential_types: ReadonlyArray<string>`) when `auth.credential_types?.length`; `require_token_scope(capability)` (403 `ERROR_TOKEN_SCOPE_REQUIRED` with `required_scope`, the token-scope refusal) when `auth.required_scope` names a capability. All fire before any body parsing — so a caller they refuse never sees route-shape information from input parse failures — and before actor resolution, so a wrong channel costs no DB work and never learns account state (e.g. that the account is multi-actor). The `AuthGuardResolver` (e.g. `fuz_auth_guard_resolver` from `auth/auth_guard_resolver.ts`) returns this set as `pre_authorization: Array<MiddlewareHandler>`.
|
|
273
|
-
4. **Authorization phase** — when `spec.auth.actor !== 'none'`, resolves the acting actor against the resolved credential's account (`get_resolved_auth`, set by the auth middleware) plus the `acting` selector (`validated_query.acting` on GETs; read off the raw body on mutations, since body validation now runs after the gates), builds `RequestContext` via `build_request_context`, and sets `REQUEST_CONTEXT_KEY`. When `auth.account !== 'none' && auth.actor === 'none'`, an account-only context is built. Resolution failures return 400 `ERROR_ACTOR_REQUIRED` (with `available[]`) or `ERROR_ACTOR_NOT_ON_ACCOUNT` (or 500 `ERROR_NO_ACTORS_ON_ACCOUNT` on signup-invariant violation
|
|
273
|
+
4. **Authorization phase** — when `spec.auth.actor !== 'none'`, resolves the acting actor against the resolved credential's account (`get_resolved_auth`, set by the auth middleware) plus the `acting` selector (`validated_query.acting` on GETs; read off the raw body on mutations, since body validation now runs after the gates), builds `RequestContext` via `build_request_context`, and sets `REQUEST_CONTEXT_KEY`. When `auth.account !== 'none' && auth.actor === 'none'`, an account-only context is built. Resolution failures return 400 `ERROR_ACTOR_REQUIRED` (with `available[]`) or `ERROR_ACTOR_NOT_ON_ACCOUNT` (or 500 `ERROR_NO_ACTORS_ON_ACCOUNT` on signup-invariant violation — a live account with no actor — and 401 `ERROR_AUTHENTICATION_REQUIRED` when the account was deleted or purged after the credential leg read it). The phase builds on the account row that leg read, reading the account again only to tell a removed account from one with no actor. Public routes (`account: 'none' && actor: 'none'`) skip this phase entirely.
|
|
274
274
|
5. **Post-authorization auth guards** — `require_role(roles)` (403 `ERROR_INSUFFICIENT_PERMISSIONS` with `required_roles: ReadonlyArray<string>`) when `auth.roles?.length`. The only gate in this phase, because it is the only one that reads `REQUEST_CONTEXT_KEY` (populated by step 4) rather than the auth middleware's own context vars. Multi-role specs admit any-of via `has_any_scoped_role(ctx, roles, null)`.
|
|
275
275
|
6. **Input validation** — JSON body parsed (`read_json_body`) + validated; mismatch returns 400 `ERROR_INVALID_JSON_BODY` (not JSON, or JSON the Rust spine refuses — `parse_json_text`) or `ERROR_INVALID_REQUEST_BODY` (schema failure with `issues`). Every schema refusal's `issues` are `WireIssue`s (`to_wire_issues`, `schema_issues.ts`), sent under DEV only (`dev_only`). Skipped on a null input (`is_null_schema`: `literal(null)`), which every `GET` has — `apply_route_specs` refuses a `GET` with any other input. The validated input lands on `c.var.validated_input`.
|
|
276
276
|
7. **Handler** — wrapped in transaction when `use_transaction` (see above), receives `RouteContext`; its result is prepared inside the transaction and emitted after the commit (`prepare_route_response`, `emit_route_response`)
|
|
@@ -354,7 +354,7 @@ definitions (`defs`) and the status map they group into (`schemas`):
|
|
|
354
354
|
1. **Derived** — `derive_route_errors({method, auth, has_input?, has_params?, has_query?, rate_limit?})`, narrowed to the slots the route has:
|
|
355
355
|
- a body — `input` not null, `method` not `GET` (registration refuses a `GET` with an input; a surface built from specs alone derives none for one) → 400 `invalid_request_body`, `invalid_json_body`
|
|
356
356
|
- `params` → 400 `invalid_route_params`; `query` → 400 `invalid_query_params`
|
|
357
|
-
- `auth.actor !== 'none'` → 400 `actor_required`, `actor_not_on_account`, 500 `no_actors_on_account`, `
|
|
357
|
+
- `auth.actor !== 'none'` → 400 `actor_required`, `actor_not_on_account`, 500 `no_actors_on_account`, 401 `authentication_required` (an account removed after the credential leg read it — declared on an actor-optional route too) — what the dispatcher's authorization phase emits on routes whose input declares `acting?: ActingActor` (per registry-time invariant 2)
|
|
358
358
|
- `auth.account === 'required'` or `auth.actor === 'required'` → 401 `authentication_required` (`REST_AUTHENTICATION_REQUIRED`), the only body the pre-authorization gate answers
|
|
359
359
|
- `auth.required_scope` → 403 `token_scope_required`; `auth.credential_types?.length` → 403 `credential_type_required`; `auth.roles?.length` → 403 `insufficient_permissions` — in the order the gates fire, each carrying what the route demanded
|
|
360
360
|
- `rate_limit` → 429 `rate_limit_exceeded` (`retry_after`, a non-negative integer of seconds)
|
|
@@ -685,7 +685,7 @@ interface EmitAfterCommitContext {
|
|
|
685
685
|
// post_commit_effects: Array<() => void | Promise<void>>
|
|
686
686
|
```
|
|
687
687
|
|
|
688
|
-
- **`pending_effects: Array<Promise<void>>`** — eager. Producers push the in-flight `Promise<void>` for fire-and-forget pool writes already running: audit
|
|
688
|
+
- **`pending_effects: Array<Promise<void>>`** — eager. Producers push the in-flight `Promise<void>` for fire-and-forget pool writes already running: failure audit rows via `AppDeps.audit`, session-touch UPDATE, api-token usage tracking. The pool write is rollback-resilient by virtue of running outside the request transaction; pushing the in-flight handle lets test mode (`await_pending_effects: true`) await it, and `AppServer.close` awaits the flushes production leaves running, bounded (`shutdown_drain_timeout_ms`). Drain: `flush_pending_effects(effects, log, on_rejection?)`.
|
|
689
689
|
- **`post_commit_effects: Array<() => void | Promise<void>>`** — deferred. Producers go through `emit_after_commit(ctx, fn)` exclusively; raw thunks should not be pushed directly. The flush middleware (in `server/app_server.ts` and the per-message WS dispatcher in `actions/ws_socket_session.ts`) is the only site that invokes each thunk, after the wrapping `db.transaction` resolves. Drain: `flush_post_commit_effects(effects, log)`.
|
|
690
690
|
|
|
691
691
|
### Why split
|
|
@@ -711,17 +711,22 @@ threw, so a thrown handler (rolling back its transaction) would still fire the
|
|
|
711
711
|
thunk it queued. So the contract is **two-sided**: both dispatch sites
|
|
712
712
|
(`http/route_spec.ts`, `actions/perform_action.ts`) wrap their handler in the
|
|
713
713
|
shared `dispatch_with_post_commit_rollback` helper, which discards
|
|
714
|
-
`post_commit_effects` on a handler throw
|
|
715
|
-
|
|
714
|
+
`post_commit_effects` on a handler throw, and a `transaction: false` handler
|
|
715
|
+
that opens its own transaction (`/login`, `/password`, signup, bootstrap) runs
|
|
716
|
+
it through `transaction_with_post_commit_rollback`, the same truncation around
|
|
717
|
+
just that transaction — so a handler that catches its transaction's failure
|
|
718
|
+
and answers a refusal still discards what it queued. `emit_after_commit` thus
|
|
719
|
+
reads as **"run iff the wrapping transaction commits."** The eager `pending_effects`
|
|
716
720
|
queue is the deliberate opposite (survives rollback — attempt audits). The full
|
|
717
721
|
two-sided contract + Rust-twin parity note live on the helper's TSDoc in
|
|
718
722
|
`http/pending_effects.ts`.
|
|
719
723
|
|
|
720
724
|
```typescript
|
|
721
|
-
emit_after_commit(ctx, () => notification_sender.send_to_account(account_id, msg));
|
|
725
|
+
emit_after_commit(ctx, () => ctx.notification_sender.send_to_account(account_id, msg));
|
|
722
726
|
```
|
|
723
727
|
|
|
724
|
-
Used for WS sends (`
|
|
728
|
+
Used for WS sends (`ctx.notification_sender`, through
|
|
729
|
+
`queue_offer_notification` / `queue_supersede_notifications` for the
|
|
725
730
|
role-grant-offer notifications — see `auth/CLAUDE.md` §WS notifications),
|
|
726
731
|
a revocation's connection closes (`queue_connection_close` — see
|
|
727
732
|
`actions/CLAUDE.md` §Connection closer), the audit emitter's listener fan-out
|
|
@@ -760,8 +765,7 @@ Auth-aware variants (account status, bootstrap status) live in `auth/` —
|
|
|
760
765
|
table browser; the factory is domain-agnostic.
|
|
761
766
|
|
|
762
767
|
`create_db_route_specs(deps, {db_type, db_name, browsable_tables, extra_stats?, log?, non_deletable_tables?})` —
|
|
763
|
-
`deps` is `DbRouteDeps`,
|
|
764
|
-
`http/db_routes.ts` so this directory stays auth-free (`ctx.deps` satisfies it):
|
|
768
|
+
`deps` is `DbRouteDeps`, `{audit: Pick<AuditEmitter, 'emit'>}` (`ctx.deps` satisfies it):
|
|
765
769
|
|
|
766
770
|
- `GET /health` — connected probe + table count (schema-wide by design — a did-migrations-run diagnostic) + optional `extra_stats(db)`. Returns `{connected: false}` at 503 on failure
|
|
767
771
|
- `GET /tables` — list browsable tables with row counts
|
|
@@ -823,11 +827,13 @@ instead of discovering the refusal — `ui/table_state.svelte.ts` gates on
|
|
|
823
827
|
`can_delete`. `primary_key` stays a truthful report of the key shape; a policy
|
|
824
828
|
exclusion must not masquerade as one.
|
|
825
829
|
|
|
826
|
-
**Every successful row delete is audited.** The `DELETE` handler
|
|
827
|
-
`deps.audit.
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
830
|
+
**Every successful row delete is audited.** The `DELETE` handler writes its
|
|
831
|
+
`db_admin_row_delete` row with `deps.audit.emit` in the route's transaction,
|
|
832
|
+
after the savepoint's `try` (so a refused audit write fails the request rather
|
|
833
|
+
than reading as a row refusal): the row lands iff the delete commits, and a
|
|
834
|
+
refused row rolls the delete back, as on the Rust twin. Remounted with
|
|
835
|
+
`transaction: false`, the handler opens a transaction around just the delete
|
|
836
|
+
and its row (`transaction_with_post_commit_rollback`). Account-grain attribution (the browser's gate is account-grain,
|
|
831
837
|
so no actor is claimed), metadata `{table, pk_column, id}`. Refusals emit
|
|
832
838
|
nothing. The completeness gate covers the event via the
|
|
833
839
|
`db_routes.db.test.ts` emission tests (excluded-with-justification in
|
|
@@ -134,7 +134,7 @@ export interface RouteAuth {
|
|
|
134
134
|
* RPC endpoint runs its own per-method check inside the dispatcher, the
|
|
135
135
|
* `reads_credential` routes that answer anonymous callers (account status,
|
|
136
136
|
* the cell-scoped fact read) can't take the field and answer a narrowed
|
|
137
|
-
* token as anonymous in their handler (`
|
|
137
|
+
* token as anonymous in their handler (`get_public_account`), and the
|
|
138
138
|
* server-status route admits a narrowed token by design — and all are
|
|
139
139
|
* route specs too.
|
|
140
140
|
*
|
package/dist/http/db_routes.d.ts
CHANGED
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
12
|
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
13
|
-
import { type Uuid } from '../primitive_schemas.js';
|
|
14
13
|
import type { Db, DbType } from '../db/db.js';
|
|
15
14
|
import { type RouteSpec } from './route_spec.js';
|
|
15
|
+
import type { AuditEmitter } from '../auth/audit_emitter.js';
|
|
16
16
|
/**
|
|
17
17
|
* Table metadata from `information_schema`.
|
|
18
18
|
*/
|
|
@@ -93,31 +93,16 @@ export declare const NON_BROWSABLE_TABLES: ReadonlyArray<string>;
|
|
|
93
93
|
*/
|
|
94
94
|
export declare const NON_DELETABLE_TABLES: ReadonlyArray<string>;
|
|
95
95
|
/**
|
|
96
|
-
* Capabilities the db routes need — a narrow
|
|
97
|
-
* (`auth/deps.ts`)
|
|
98
|
-
* `auth/audit_emitter.ts` `AuditEmitter` (and therefore `AppDeps.audit` /
|
|
99
|
-
* `RouteFactoryDeps.audit`) satisfies `audit` structurally.
|
|
96
|
+
* Capabilities the db routes need — a narrow slice of `AppDeps`
|
|
97
|
+
* (`auth/deps.ts`); `AppDeps.audit` / `RouteFactoryDeps.audit` satisfy it.
|
|
100
98
|
*/
|
|
101
99
|
export interface DbRouteDeps {
|
|
102
100
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
* written on the pool because the request transaction has ended by then.
|
|
107
|
-
* The flush awaits the returned promise.
|
|
101
|
+
* The row-`DELETE` handler writes its `db_admin_row_delete` success row in
|
|
102
|
+
* the route's transaction, after the delete, so the row and the delete
|
|
103
|
+
* commit together or not at all.
|
|
108
104
|
*/
|
|
109
|
-
audit:
|
|
110
|
-
emit_pool: (input: {
|
|
111
|
-
event_type: 'db_admin_row_delete';
|
|
112
|
-
account_id: Uuid | null;
|
|
113
|
-
ip: string;
|
|
114
|
-
metadata: {
|
|
115
|
-
table: string;
|
|
116
|
-
pk_column: string;
|
|
117
|
-
id: string;
|
|
118
|
-
};
|
|
119
|
-
}) => Promise<void>;
|
|
120
|
-
};
|
|
105
|
+
audit: Pick<AuditEmitter, 'emit'>;
|
|
121
106
|
}
|
|
122
107
|
/**
|
|
123
108
|
* Per-factory configuration for db routes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db_routes.d.ts","sourceRoot":"","sources":["../../src/lib/http/db_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"db_routes.d.ts","sourceRoot":"","sources":["../../src/lib/http/db_routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAA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AW,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3D,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,oBAAoB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC7C;AA2CD;;GAEG;AACH,eAAO,MAAM,qBAAqB,GACjC,MAAM,WAAW,EACjB,SAAS,cAAc,KACrB,KAAK,CAAC,SAAS,CA8VjB,CAAC"}
|
package/dist/http/db_routes.js
CHANGED
|
@@ -14,10 +14,10 @@ import { array, boolean, integer, literal, loose_object, max_value, min_value, n
|
|
|
14
14
|
import { ActingActor } from '../primitive_schemas.js';
|
|
15
15
|
import { define_route } from './route_spec.js';
|
|
16
16
|
import { route_fail, route_ok } from './route_result.js';
|
|
17
|
+
import { transaction_with_post_commit_rollback } from './pending_effects.js';
|
|
17
18
|
import { REST_DATABASE_CONNECTION_FAILED, REST_FOREIGN_KEY_VIOLATION, REST_ROW_NOT_FOUND, REST_TABLE_NO_PRIMARY_KEY, REST_TABLE_NOT_DELETABLE, REST_TABLE_NOT_FOUND } from './error_schemas.js';
|
|
18
19
|
import { assert_valid_sql_identifier, VALID_SQL_IDENTIFIER } from '../db/sql_identifier.js';
|
|
19
20
|
import { pg_error_code } from '../db/pg_error.js';
|
|
20
|
-
import { emit_after_commit } from './pending_effects.js';
|
|
21
21
|
// the spellings `query_int` reads as an integer: decimal digits with an optional sign
|
|
22
22
|
const QUERY_INT_PATTERN = /^[+-]?\d+$/;
|
|
23
23
|
/**
|
|
@@ -367,82 +367,82 @@ export const create_db_route_specs = (deps, options) => {
|
|
|
367
367
|
return route_fail(REST_TABLE_NO_PRIMARY_KEY);
|
|
368
368
|
}
|
|
369
369
|
const pk_column = pk_columns[0];
|
|
370
|
-
// The
|
|
371
|
-
//
|
|
372
|
-
//
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
await
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
370
|
+
// The delete and its audit row are one transaction: the route's, or —
|
|
371
|
+
// remounted with `transaction: false` — one opened here around just
|
|
372
|
+
// them, so the row is written with the delete either way.
|
|
373
|
+
const delete_row = async (tx_ctx) => {
|
|
374
|
+
// The refusals below answer from a failed DELETE, which on PostgreSQL
|
|
375
|
+
// aborts the route's transaction — its COMMIT would come back as a
|
|
376
|
+
// ROLLBACK, which the pg driver throws on (`db/db_pg.ts`). A savepoint
|
|
377
|
+
// keeps the refusal's failure out of the transaction.
|
|
378
|
+
await tx_ctx.db.query('SAVEPOINT db_admin_row_delete');
|
|
379
|
+
let deleted_id;
|
|
380
|
+
try {
|
|
381
|
+
// Typed PK compare, twinning the Rust spine: `$1` travels as an
|
|
382
|
+
// untyped text-format parameter, so PG infers the PK column's
|
|
383
|
+
// type and coerces the id with that type's input function —
|
|
384
|
+
// index-scan deletes and canonical per-type semantics (citext
|
|
385
|
+
// case-insensitivity, char(n) padding, any valid uuid spelling).
|
|
386
|
+
// An id that cannot be a value of the PK type errors at bind
|
|
387
|
+
// (22P02/22003), mapped below to the same 404 as a typed miss.
|
|
388
|
+
// `RETURNING "<pk>"::text` reads back only the PK cell — the
|
|
389
|
+
// deleted row's other values (e.g. a bytea column) are never
|
|
390
|
+
// materialized — so the audit trail records the row's canonical
|
|
391
|
+
// PK rendering rather than whatever spelling the URL supplied.
|
|
392
|
+
const pk_ident = assert_valid_sql_identifier(pk_column);
|
|
393
|
+
const result = await tx_ctx.db.query(`DELETE FROM "${assert_valid_sql_identifier(name)}" WHERE "${pk_ident}" = $1 RETURNING "${pk_ident}"::text AS pk_text`, [id]);
|
|
394
|
+
if (result.length === 0) {
|
|
395
|
+
return route_fail(REST_ROW_NOT_FOUND);
|
|
396
|
+
}
|
|
397
|
+
deleted_id = result[0].pk_text;
|
|
398
|
+
}
|
|
399
|
+
catch (err) {
|
|
400
|
+
const code = pg_error_code(err);
|
|
401
|
+
// 22P02 invalid_text_representation / 22003 numeric_value_out_of_range
|
|
402
|
+
// / 22021 character_not_in_repertoire: the id cannot be coerced
|
|
403
|
+
// to the PK column's type — or cannot even be a text value (a
|
|
404
|
+
// NUL byte, rejected by the server encoding whatever the PK
|
|
405
|
+
// type) — so no row can match; answer with the same masked 404
|
|
406
|
+
// as a typed miss.
|
|
407
|
+
const uncoercible = code === '22P02' || code === '22003' || code === '22021';
|
|
408
|
+
// 23503 foreign_key_violation / 23001 restrict_violation — the
|
|
409
|
+
// same referencing-row refusal. Which one depends on the
|
|
410
|
+
// constraint: `ON DELETE RESTRICT` raises 23001 on PG 18, PGlite
|
|
411
|
+
// and pglet (23503 on PG ≤17), and `NO ACTION` — the default,
|
|
412
|
+
// when the constraint names no action — raises 23503 on all of
|
|
413
|
+
// them.
|
|
414
|
+
const referenced = code === '23503' || code === '23001';
|
|
415
|
+
// anything else fails the request, and the route's transaction
|
|
416
|
+
// rolls back whole
|
|
417
|
+
if (!uncoercible && !referenced)
|
|
418
|
+
throw err;
|
|
419
|
+
// the refusal answers normally, so the transaction must commit
|
|
420
|
+
await tx_ctx.db.query('ROLLBACK TO SAVEPOINT db_admin_row_delete');
|
|
421
|
+
if (uncoercible) {
|
|
422
|
+
return route_fail(REST_ROW_NOT_FOUND);
|
|
423
|
+
}
|
|
424
|
+
const pg_err = err;
|
|
425
|
+
log?.warn('Foreign key violation:', pg_err.detail, pg_err.constraint);
|
|
426
|
+
return route_fail(REST_FOREIGN_KEY_VIOLATION);
|
|
395
427
|
}
|
|
396
|
-
const deleted_id = result[0].pk_text;
|
|
397
428
|
// The trail for the trail-adjacent surface: every successful row
|
|
398
|
-
// delete through this endpoint is audited
|
|
399
|
-
//
|
|
400
|
-
//
|
|
401
|
-
//
|
|
402
|
-
//
|
|
403
|
-
//
|
|
404
|
-
|
|
405
|
-
// is claimed.
|
|
406
|
-
const account_id = route.auth.account.id;
|
|
407
|
-
const ip = route.client_ip;
|
|
408
|
-
emit_after_commit(route, () => deps.audit.emit_pool({
|
|
429
|
+
// delete through this endpoint is audited, in the route's
|
|
430
|
+
// transaction, so the row commits with the delete or neither does.
|
|
431
|
+
// Outside the savepoint's `try`, so a refused audit write fails the
|
|
432
|
+
// request (and rolls the delete back) rather than reading as a row
|
|
433
|
+
// refusal. Account-grain attribution — the browser is a raw storage
|
|
434
|
+
// surface, so no actor is claimed.
|
|
435
|
+
await deps.audit.emit(tx_ctx, {
|
|
409
436
|
event_type: 'db_admin_row_delete',
|
|
410
|
-
account_id,
|
|
411
|
-
ip,
|
|
437
|
+
account_id: route.auth.account.id,
|
|
438
|
+
ip: route.client_ip,
|
|
412
439
|
metadata: { table: name, pk_column, id: deleted_id }
|
|
413
|
-
})
|
|
440
|
+
});
|
|
414
441
|
return route_ok({ success: true });
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
// / 22021 character_not_in_repertoire: the id cannot be coerced
|
|
420
|
-
// to the PK column's type — or cannot even be a text value (a
|
|
421
|
-
// NUL byte, rejected by the server encoding whatever the PK
|
|
422
|
-
// type) — so no row can match; answer with the same masked 404
|
|
423
|
-
// as a typed miss.
|
|
424
|
-
const uncoercible = code === '22P02' || code === '22003' || code === '22021';
|
|
425
|
-
// 23503 foreign_key_violation / 23001 restrict_violation — the
|
|
426
|
-
// same referencing-row refusal. Which one depends on the
|
|
427
|
-
// constraint: `ON DELETE RESTRICT` raises 23001 on PG 18, PGlite
|
|
428
|
-
// and pglet (23503 on PG ≤17), and `NO ACTION` — the default,
|
|
429
|
-
// when the constraint names no action — raises 23503 on all of
|
|
430
|
-
// them.
|
|
431
|
-
const referenced = code === '23503' || code === '23001';
|
|
432
|
-
// anything else fails the request, and the route's transaction
|
|
433
|
-
// rolls back whole
|
|
434
|
-
if (!uncoercible && !referenced)
|
|
435
|
-
throw err;
|
|
436
|
-
// the refusal answers normally, so the transaction must commit
|
|
437
|
-
if (savepoint)
|
|
438
|
-
await route.db.query('ROLLBACK TO SAVEPOINT db_admin_row_delete');
|
|
439
|
-
if (uncoercible) {
|
|
440
|
-
return route_fail(REST_ROW_NOT_FOUND);
|
|
441
|
-
}
|
|
442
|
-
const pg_err = err;
|
|
443
|
-
log?.warn('Foreign key violation:', pg_err.detail, pg_err.constraint);
|
|
444
|
-
return route_fail(REST_FOREIGN_KEY_VIOLATION);
|
|
445
|
-
}
|
|
442
|
+
};
|
|
443
|
+
return route.db.in_transaction
|
|
444
|
+
? delete_row(route)
|
|
445
|
+
: transaction_with_post_commit_rollback(route, delete_row);
|
|
446
446
|
}
|
|
447
447
|
})
|
|
448
448
|
];
|
|
@@ -136,22 +136,10 @@ export declare const ERROR_ACTOR_NOT_ON_ACCOUNT: "actor_not_on_account";
|
|
|
136
136
|
* violation — signup / bootstrap always create an actor in the same
|
|
137
137
|
* transaction. Surfaced from the dispatcher's authorization phase as a
|
|
138
138
|
* 500 so the operator sees the corruption signal rather than a confusing
|
|
139
|
-
* 4xx.
|
|
140
|
-
*
|
|
139
|
+
* 4xx. An account removed after its credential was read reaches it too: the
|
|
140
|
+
* removal takes the account's actors with it.
|
|
141
141
|
*/
|
|
142
142
|
export declare const ERROR_NO_ACTORS_ON_ACCOUNT: "no_actors_on_account";
|
|
143
|
-
/**
|
|
144
|
-
* Authentication validated an account, but a follow-up read in the
|
|
145
|
-
* authorization phase came back null — the account or its named actor
|
|
146
|
-
* row was deleted between the credential check and the dispatcher's
|
|
147
|
-
* `build_request_context` / `build_account_context` step. Torn read,
|
|
148
|
-
* not a missing-actor invariant violation. Surfaced as 500 so the
|
|
149
|
-
* operator sees the race signal; clients can retry. Distinct from
|
|
150
|
-
* `ERROR_ACCOUNT_NOT_FOUND` (stale token referencing a long-deleted
|
|
151
|
-
* account, raised at credential validation) and
|
|
152
|
-
* `ERROR_NO_ACTORS_ON_ACCOUNT` (the actor list enumerated empty).
|
|
153
|
-
*/
|
|
154
|
-
export declare const ERROR_ACCOUNT_VANISHED: "account_vanished";
|
|
155
143
|
/** Keeper account ID set but account row not found. */
|
|
156
144
|
export declare const ERROR_KEEPER_ACCOUNT_NOT_FOUND: "keeper_account_not_found";
|
|
157
145
|
/** Bootstrap lock already acquired — system already bootstrapped. */
|
|
@@ -406,8 +394,6 @@ export declare const REST_RATE_LIMIT_EXCEEDED: RestErrorDef<429, "rate_limit_exc
|
|
|
406
394
|
}>;
|
|
407
395
|
/** The account's actors enumerated empty, a signup invariant broken. */
|
|
408
396
|
export declare const REST_NO_ACTORS_ON_ACCOUNT: RestErrorDef<500, "no_actors_on_account", Record<never, never>>;
|
|
409
|
-
/** The account or actor row was deleted between credential validation and the actor read. */
|
|
410
|
-
export declare const REST_ACCOUNT_VANISHED: RestErrorDef<500, "account_vanished", Record<never, never>>;
|
|
411
397
|
export declare const REST_INTERNAL_ERROR: RestErrorDef<500, "internal_error", Record<never, never>>;
|
|
412
398
|
/** Bootstrap's token matched and its file couldn't be burned; the bootstrap rolled back. */
|
|
413
399
|
export declare const REST_TOKEN_FILE_UNDELETABLE: RestErrorDef<500, "token_file_undeletable", Record<never, never>>;
|
|
@@ -454,9 +440,11 @@ export interface DeriveRouteErrorsOptions {
|
|
|
454
440
|
* the body's errors there either.
|
|
455
441
|
* - **`params`**: 400 `invalid_route_params`. **`query`**: 400
|
|
456
442
|
* `invalid_query_params`.
|
|
457
|
-
* - **`auth.account === 'required'`** or **`auth.actor
|
|
443
|
+
* - **`auth.account === 'required'`** or **`auth.actor !== 'none'`**: 401
|
|
458
444
|
* `authentication_required` — the pre-authorization gate's refusal when the
|
|
459
|
-
* credential isn't there
|
|
445
|
+
* credential isn't there, and the authorization phase's when the account it
|
|
446
|
+
* resolved was removed before the phase listed its actors. An optional
|
|
447
|
+
* account with no actor axis does not derive 401.
|
|
460
448
|
* - **`auth.required_scope`**: 403 `token_scope_required` (carrying
|
|
461
449
|
* `required_scope`). **`auth.credential_types?.length`**: 403
|
|
462
450
|
* `credential_type_required` (carrying `required_credential_types`).
|
|
@@ -464,9 +452,9 @@ export interface DeriveRouteErrorsOptions {
|
|
|
464
452
|
* `required_roles`). In the order the gates fire; a route with more than
|
|
465
453
|
* one has each.
|
|
466
454
|
* - **`auth.actor !== 'none'`**: 400 `actor_required` and
|
|
467
|
-
* `actor_not_on_account`, and 500 `no_actors_on_account`
|
|
468
|
-
*
|
|
469
|
-
*
|
|
455
|
+
* `actor_not_on_account`, and 500 `no_actors_on_account` — what the
|
|
456
|
+
* dispatcher's authorization phase emits when it resolves an actor (its 401
|
|
457
|
+
* is the rule above).
|
|
470
458
|
* - **`rate_limit`**: 429 `rate_limit_exceeded` (with `retry_after`).
|
|
471
459
|
* - **`POST`**: 415 `unsupported_content_type` (see
|
|
472
460
|
* `is_post_content_type_refused` in `http/simple_request.ts`).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error_schemas.d.ts","sourceRoot":"","sources":["../../src/lib/http/error_schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAYN,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAInD,4CAA4C;AAC5C,eAAO,MAAM,0BAA0B,EAAG,sBAA+B,CAAC;AAE1E,uDAAuD;AACvD,eAAO,MAAM,uBAAuB,EAAG,mBAA4B,CAAC;AAEpE,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;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACxC,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,yEAAyE;IACzE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,YAAY,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,mBAAmB,GAAI,gEAOjC,wBAAwB,KAAG,KAAK,CAAC,YAAY,CAoC/C,CAAC"}
|
|
@@ -140,22 +140,10 @@ export const ERROR_ACTOR_NOT_ON_ACCOUNT = 'actor_not_on_account';
|
|
|
140
140
|
* violation — signup / bootstrap always create an actor in the same
|
|
141
141
|
* transaction. Surfaced from the dispatcher's authorization phase as a
|
|
142
142
|
* 500 so the operator sees the corruption signal rather than a confusing
|
|
143
|
-
* 4xx.
|
|
144
|
-
*
|
|
143
|
+
* 4xx. An account removed after its credential was read reaches it too: the
|
|
144
|
+
* removal takes the account's actors with it.
|
|
145
145
|
*/
|
|
146
146
|
export const ERROR_NO_ACTORS_ON_ACCOUNT = 'no_actors_on_account';
|
|
147
|
-
/**
|
|
148
|
-
* Authentication validated an account, but a follow-up read in the
|
|
149
|
-
* authorization phase came back null — the account or its named actor
|
|
150
|
-
* row was deleted between the credential check and the dispatcher's
|
|
151
|
-
* `build_request_context` / `build_account_context` step. Torn read,
|
|
152
|
-
* not a missing-actor invariant violation. Surfaced as 500 so the
|
|
153
|
-
* operator sees the race signal; clients can retry. Distinct from
|
|
154
|
-
* `ERROR_ACCOUNT_NOT_FOUND` (stale token referencing a long-deleted
|
|
155
|
-
* account, raised at credential validation) and
|
|
156
|
-
* `ERROR_NO_ACTORS_ON_ACCOUNT` (the actor list enumerated empty).
|
|
157
|
-
*/
|
|
158
|
-
export const ERROR_ACCOUNT_VANISHED = 'account_vanished';
|
|
159
147
|
// --- Keeper / daemon token ---
|
|
160
148
|
/** Keeper account ID set but account row not found. */
|
|
161
149
|
export const ERROR_KEEPER_ACCOUNT_NOT_FOUND = 'keeper_account_not_found';
|
|
@@ -422,8 +410,6 @@ export const REST_RATE_LIMIT_EXCEEDED = rest_error(429, ERROR_RATE_LIMIT_EXCEEDE
|
|
|
422
410
|
// 500: the authorization phase, and the catch layer any route can answer with
|
|
423
411
|
/** The account's actors enumerated empty, a signup invariant broken. */
|
|
424
412
|
export const REST_NO_ACTORS_ON_ACCOUNT = rest_error(500, ERROR_NO_ACTORS_ON_ACCOUNT);
|
|
425
|
-
/** The account or actor row was deleted between credential validation and the actor read. */
|
|
426
|
-
export const REST_ACCOUNT_VANISHED = rest_error(500, ERROR_ACCOUNT_VANISHED);
|
|
427
413
|
export const REST_INTERNAL_ERROR = rest_error(500, ERROR_INTERNAL_ERROR);
|
|
428
414
|
/** Bootstrap's token matched and its file couldn't be burned; the bootstrap rolled back. */
|
|
429
415
|
export const REST_TOKEN_FILE_UNDELETABLE = rest_error(500, ERROR_TOKEN_FILE_UNDELETABLE);
|
|
@@ -453,9 +439,11 @@ export const REST_DB_UNREACHABLE = rest_error(503, ERROR_DB_UNREACHABLE);
|
|
|
453
439
|
* the body's errors there either.
|
|
454
440
|
* - **`params`**: 400 `invalid_route_params`. **`query`**: 400
|
|
455
441
|
* `invalid_query_params`.
|
|
456
|
-
* - **`auth.account === 'required'`** or **`auth.actor
|
|
442
|
+
* - **`auth.account === 'required'`** or **`auth.actor !== 'none'`**: 401
|
|
457
443
|
* `authentication_required` — the pre-authorization gate's refusal when the
|
|
458
|
-
* credential isn't there
|
|
444
|
+
* credential isn't there, and the authorization phase's when the account it
|
|
445
|
+
* resolved was removed before the phase listed its actors. An optional
|
|
446
|
+
* account with no actor axis does not derive 401.
|
|
459
447
|
* - **`auth.required_scope`**: 403 `token_scope_required` (carrying
|
|
460
448
|
* `required_scope`). **`auth.credential_types?.length`**: 403
|
|
461
449
|
* `credential_type_required` (carrying `required_credential_types`).
|
|
@@ -463,9 +451,9 @@ export const REST_DB_UNREACHABLE = rest_error(503, ERROR_DB_UNREACHABLE);
|
|
|
463
451
|
* `required_roles`). In the order the gates fire; a route with more than
|
|
464
452
|
* one has each.
|
|
465
453
|
* - **`auth.actor !== 'none'`**: 400 `actor_required` and
|
|
466
|
-
* `actor_not_on_account`, and 500 `no_actors_on_account`
|
|
467
|
-
*
|
|
468
|
-
*
|
|
454
|
+
* `actor_not_on_account`, and 500 `no_actors_on_account` — what the
|
|
455
|
+
* dispatcher's authorization phase emits when it resolves an actor (its 401
|
|
456
|
+
* is the rule above).
|
|
469
457
|
* - **`rate_limit`**: 429 `rate_limit_exceeded` (with `retry_after`).
|
|
470
458
|
* - **`POST`**: 415 `unsupported_content_type` (see
|
|
471
459
|
* `is_post_content_type_refused` in `http/simple_request.ts`).
|
|
@@ -485,13 +473,15 @@ export const derive_route_errors = ({ method, auth, has_input = false, has_param
|
|
|
485
473
|
if (has_query)
|
|
486
474
|
defs.push(REST_INVALID_QUERY_PARAMS);
|
|
487
475
|
if (needs_actor(auth)) {
|
|
488
|
-
defs.push(REST_ACTOR_REQUIRED, REST_ACTOR_NOT_ON_ACCOUNT, REST_NO_ACTORS_ON_ACCOUNT
|
|
476
|
+
defs.push(REST_ACTOR_REQUIRED, REST_ACTOR_NOT_ON_ACCOUNT, REST_NO_ACTORS_ON_ACCOUNT);
|
|
489
477
|
}
|
|
490
478
|
// 401 fires when the dispatcher's pre-authorization gate rejects an
|
|
491
479
|
// unauthenticated caller — `account === 'required'` (no credential) or
|
|
492
480
|
// `actor === 'required'` (no credential to resolve an actor against,
|
|
493
|
-
// per registry-time invariant 3 forbidding accountless actors in v1)
|
|
494
|
-
|
|
481
|
+
// per registry-time invariant 3 forbidding accountless actors in v1) — and
|
|
482
|
+
// when the authorization phase, resolving an actor, finds the account
|
|
483
|
+
// removed since its credential was read
|
|
484
|
+
if (auth.account === 'required' || needs_actor(auth)) {
|
|
495
485
|
defs.push(REST_AUTHENTICATION_REQUIRED);
|
|
496
486
|
}
|
|
497
487
|
// 403 fires from any of three gates: the token-scope refusal
|