@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
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
* schema declared `acting?: ActingActor` (reference equality with the
|
|
16
16
|
* canonical `ActingActor` schema) or the auth requires role_grants
|
|
17
17
|
* (`role` / `keeper`), `apply_authorization_phase` resolves the actor
|
|
18
|
-
* against the resolved account
|
|
18
|
+
* against the resolved account plus the validated `acting` value via
|
|
19
19
|
* `resolve_acting_actor`, builds the `{account, actor, role_grants}`
|
|
20
20
|
* context via `build_request_context`, and sets it on
|
|
21
21
|
* `REQUEST_CONTEXT_KEY` before auth guards fire. Authenticated routes
|
|
22
|
-
* that don't need an actor still get an account-only context
|
|
23
|
-
*
|
|
22
|
+
* that don't need an actor still get an account-only context, so handler
|
|
23
|
+
* signatures stay uniform. The account is the row the credential leg
|
|
24
|
+
* read (`ResolvedAuth.account`) — the phase does not read it again.
|
|
24
25
|
*
|
|
25
26
|
* Account-grain operations (logout, password_change, account_verify,
|
|
26
27
|
* etc.) declare neither `acting` nor role_grant-requiring auth, so no actor
|
|
@@ -29,9 +30,9 @@
|
|
|
29
30
|
* which is what makes multi-actor logout work without first picking a
|
|
30
31
|
* persona.
|
|
31
32
|
*
|
|
32
|
-
* `build_request_context` loads
|
|
33
|
-
* the
|
|
34
|
-
* reloads role_grants on an existing context.
|
|
33
|
+
* `build_request_context` loads the acting actor's role_grants onto the
|
|
34
|
+
* account and the actor `resolve_acting_actor` read off that account.
|
|
35
|
+
* `refresh_role_grants` reloads role_grants on an existing context.
|
|
35
36
|
*
|
|
36
37
|
* @module
|
|
37
38
|
*/
|
|
@@ -42,7 +43,7 @@ import type { QueryDeps } from '../db/query_deps.js';
|
|
|
42
43
|
import { type ResolvedAuth } from './resolved_auth.js';
|
|
43
44
|
import type { RouteSpec } from '../http/route_spec.js';
|
|
44
45
|
import { type RouteAuth } from '../http/auth_shape.js';
|
|
45
|
-
import { ERROR_ACTOR_REQUIRED, ERROR_ACTOR_NOT_ON_ACCOUNT, ERROR_NO_ACTORS_ON_ACCOUNT
|
|
46
|
+
import { ERROR_AUTHENTICATION_REQUIRED, ERROR_ACTOR_REQUIRED, ERROR_ACTOR_NOT_ON_ACCOUNT, ERROR_NO_ACTORS_ON_ACCOUNT } from '../http/error_schemas.js';
|
|
46
47
|
/**
|
|
47
48
|
* The resolved identity context for an authenticated request.
|
|
48
49
|
*
|
|
@@ -54,8 +55,9 @@ import { ERROR_ACTOR_REQUIRED, ERROR_ACTOR_NOT_ON_ACCOUNT, ERROR_NO_ACTORS_ON_AC
|
|
|
54
55
|
* `actor: null` as "no role_grants" so callers don't have to narrow.
|
|
55
56
|
*
|
|
56
57
|
* Multi-actor invariant: when populated, `actor.account_id === account.id`.
|
|
57
|
-
* `
|
|
58
|
-
*
|
|
58
|
+
* `resolve_acting_actor` picks the actor from the account's own active
|
|
59
|
+
* actors, and the dispatcher's authorization phase rejects with
|
|
60
|
+
* `actor_not_on_account` before reaching the handler.
|
|
59
61
|
*/
|
|
60
62
|
export interface RequestContext {
|
|
61
63
|
account: Account;
|
|
@@ -164,15 +166,18 @@ export declare const has_scoped_role: (ctx: RequestContext | null, role: string,
|
|
|
164
166
|
*/
|
|
165
167
|
export declare const has_any_scoped_role: (ctx: RequestContext | null, roles: ReadonlyArray<string>, scope_id: string | null, now?: Date) => boolean;
|
|
166
168
|
/**
|
|
167
|
-
* Result of `resolve_acting_actor` — either
|
|
168
|
-
* error the caller maps to an HTTP response.
|
|
169
|
+
* Result of `resolve_acting_actor` — either the actor, as read, or a
|
|
170
|
+
* structured error the caller maps to an HTTP response.
|
|
169
171
|
*/
|
|
170
172
|
export type ResolveActingActorResult = {
|
|
171
173
|
ok: true;
|
|
172
|
-
|
|
174
|
+
actor: Actor;
|
|
173
175
|
} | {
|
|
174
176
|
ok: false;
|
|
175
177
|
reason: 'no_actors';
|
|
178
|
+
} | {
|
|
179
|
+
ok: false;
|
|
180
|
+
reason: 'account_removed';
|
|
176
181
|
} | {
|
|
177
182
|
ok: false;
|
|
178
183
|
reason: 'actor_required';
|
|
@@ -192,9 +197,10 @@ export type ResolveActingActorResult = {
|
|
|
192
197
|
* (from the request payload). Applies the uniform resolution rules:
|
|
193
198
|
*
|
|
194
199
|
* - `acting_actor_id` omitted + 1 actor → use it.
|
|
195
|
-
* -
|
|
200
|
+
* - 0 actors → `no_actors` when the account is still live (defensive —
|
|
196
201
|
* signup / bootstrap always create an actor in the same tx, so this
|
|
197
|
-
* is a server error)
|
|
202
|
+
* is a server error), `account_removed` when it is tombstoned or gone:
|
|
203
|
+
* removed since its credential was read, its actors with it.
|
|
198
204
|
* - `acting_actor_id` omitted + multiple actors → `actor_required` with
|
|
199
205
|
* the available list so the client can prompt; never pick silently.
|
|
200
206
|
* - `acting_actor_id` present + matches an actor on the account → use it.
|
|
@@ -202,6 +208,10 @@ export type ResolveActingActorResult = {
|
|
|
202
208
|
* The available list is intentionally not echoed in this branch (treat
|
|
203
209
|
* as opaque rejection).
|
|
204
210
|
*
|
|
211
|
+
* The actor comes back as the row the account's actor list read, so the
|
|
212
|
+
* caller builds on it without reading it again — one read, as on the Rust
|
|
213
|
+
* spine, which leaves no window for the actor to vanish between two.
|
|
214
|
+
*
|
|
205
215
|
* `acting_actor_id` is compared lowercased, the form actor ids are stored and
|
|
206
216
|
* read back in, so a caller passing an id that skipped the `Uuid` schema
|
|
207
217
|
* still matches its actor whatever its case.
|
|
@@ -284,10 +294,10 @@ export declare const create_request_context_middleware: (deps: QueryDeps, option
|
|
|
284
294
|
*/
|
|
285
295
|
export declare const token_scope_surface_denial: (c: Context, capability: string) => Response | null;
|
|
286
296
|
/**
|
|
287
|
-
* The account
|
|
288
|
-
* the credential (`reads_credential`) — may act on
|
|
289
|
-
* caller **and for a scope-narrowed API token**.
|
|
290
|
-
* anonymous-admitting disposition — the downgrade the Rust
|
|
297
|
+
* The account a public route — one that answers anonymous callers and reads
|
|
298
|
+
* the credential (`reads_credential`) — may act on, as the credential leg read
|
|
299
|
+
* it: `null` for the anonymous caller **and for a scope-narrowed API token**.
|
|
300
|
+
* Rule 3 in its anonymous-admitting disposition — the downgrade the Rust
|
|
291
301
|
* `AuthGate::public_request_context` applies.
|
|
292
302
|
*
|
|
293
303
|
* A narrowed token reaches no non-RPC surface that reads account data
|
|
@@ -303,11 +313,11 @@ export declare const token_scope_surface_denial: (c: Context, capability: string
|
|
|
303
313
|
* the scope, so it reads the full credential.
|
|
304
314
|
*
|
|
305
315
|
* @param route - the handler's `RouteContext`, or anything carrying its `credential`
|
|
306
|
-
* @returns the account
|
|
316
|
+
* @returns the account the credential resolved, or `null` for an anonymous caller or a narrowed token
|
|
307
317
|
*/
|
|
308
|
-
export declare const
|
|
318
|
+
export declare const get_public_account: (route: {
|
|
309
319
|
readonly credential: ResolvedAuth | null;
|
|
310
|
-
}) =>
|
|
320
|
+
}) => Account | null;
|
|
311
321
|
/**
|
|
312
322
|
* Create middleware refusing a route to a credential whose scope does not admit
|
|
313
323
|
* `capability`.
|
|
@@ -399,44 +409,26 @@ export declare const require_credential_types: (credential_types: ReadonlyArray<
|
|
|
399
409
|
*/
|
|
400
410
|
export declare const refresh_role_grants: (ctx: RequestContext, deps: QueryDeps) => Promise<RequestContext>;
|
|
401
411
|
/**
|
|
402
|
-
* Build
|
|
403
|
-
*
|
|
412
|
+
* Build an actor-bound `RequestContext` from the account the credential
|
|
413
|
+
* resolved and the actor `resolve_acting_actor` read off it, loading the
|
|
414
|
+
* actor's active role_grants.
|
|
404
415
|
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
416
|
+
* Reads only the grants: the account is the credential leg's row
|
|
417
|
+
* (`ResolvedAuth.account`) and the actor the account's own actor list read,
|
|
418
|
+
* so neither is read twice in a request and there is no torn read between
|
|
419
|
+
* the reads — a delete landing after them is the handler's to meet, as on
|
|
420
|
+
* the Rust spine.
|
|
410
421
|
*
|
|
411
|
-
* Called by the
|
|
412
|
-
*
|
|
413
|
-
* `
|
|
422
|
+
* Called by the dispatcher's authorization phase for routes that need an
|
|
423
|
+
* acting actor; account-grain routes get `{account, actor: null,
|
|
424
|
+
* role_grants: []}` with no read at all.
|
|
414
425
|
*
|
|
415
426
|
* @param deps - query dependencies
|
|
416
|
-
* @param
|
|
417
|
-
* @param
|
|
418
|
-
* @returns
|
|
427
|
+
* @param account - the account the credential resolved
|
|
428
|
+
* @param actor - the acting actor, one of `account`'s active actors
|
|
429
|
+
* @returns the actor-bound request context
|
|
419
430
|
*/
|
|
420
|
-
export declare const build_request_context: (deps: QueryDeps,
|
|
421
|
-
/**
|
|
422
|
-
* Build an account-only `RequestContext` (no actor, no role_grants) from
|
|
423
|
-
* an account id.
|
|
424
|
-
*
|
|
425
|
-
* Used by the dispatcher's authorization phase for authenticated routes
|
|
426
|
-
* that don't need an acting actor — account-grain operations (logout,
|
|
427
|
-
* password change, account self-service). Lets handlers read
|
|
428
|
-
* `auth.account.id` / `auth.account.username` uniformly with role_grant-bound
|
|
429
|
-
* routes; the cost is one extra `query_account_by_id` per request.
|
|
430
|
-
*
|
|
431
|
-
* Returns `null` when the account row is missing (e.g. deleted between
|
|
432
|
-
* the auth middleware's session lookup and the dispatcher) — caller
|
|
433
|
-
* surfaces that as a 500 since it represents a torn read.
|
|
434
|
-
*
|
|
435
|
-
* @param deps - query dependencies
|
|
436
|
-
* @param account_id - the account to build context for
|
|
437
|
-
* @returns an account-only request context, or `null` if the account is missing
|
|
438
|
-
*/
|
|
439
|
-
export declare const build_account_context: (deps: QueryDeps, account_id: string) => Promise<RequestContext | null>;
|
|
431
|
+
export declare const build_request_context: (deps: QueryDeps, account: Account, actor: Actor) => Promise<RequestActorContext>;
|
|
440
432
|
/**
|
|
441
433
|
* Resolution-failure shape returned by `apply_authorization_phase`. Each
|
|
442
434
|
* transport binds this to the appropriate wire shape — REST emits the body
|
|
@@ -457,9 +449,9 @@ export type AuthorizationFailureBody = {
|
|
|
457
449
|
} | {
|
|
458
450
|
error: typeof ERROR_ACTOR_NOT_ON_ACCOUNT;
|
|
459
451
|
} | {
|
|
460
|
-
error: typeof
|
|
452
|
+
error: typeof ERROR_AUTHENTICATION_REQUIRED;
|
|
461
453
|
} | {
|
|
462
|
-
error: typeof
|
|
454
|
+
error: typeof ERROR_NO_ACTORS_ON_ACCOUNT;
|
|
463
455
|
};
|
|
464
456
|
/**
|
|
465
457
|
* Result of the authorization phase. Pure data — the auth domain stops
|
|
@@ -472,18 +464,19 @@ export type AuthorizationFailureBody = {
|
|
|
472
464
|
* access on an `'optional'` axis. Public and unauthenticated collapse
|
|
473
465
|
* to the same null `request_context`; every transport already treated
|
|
474
466
|
* them identically.
|
|
475
|
-
* - **`{ok: false, status, body}`** — 400/500 failure. `status` is
|
|
476
|
-
* narrowed to the
|
|
477
|
-
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
467
|
+
* - **`{ok: false, status, body}`** — 400/401/500 failure. `status` is
|
|
468
|
+
* narrowed to the values the auth phase emits, so Hono's `c.json` status
|
|
469
|
+
* overload accepts the literals directly. The 401 is the dead credential's
|
|
470
|
+
* `authentication_required`: the account was removed since the credential
|
|
471
|
+
* leg read it. The one 500 is `no_actors_on_account`: a live account listed
|
|
472
|
+
* no active actor.
|
|
480
473
|
*/
|
|
481
474
|
export type AuthorizationResult = {
|
|
482
475
|
ok: true;
|
|
483
476
|
request_context: RequestContext | null;
|
|
484
477
|
} | {
|
|
485
478
|
ok: false;
|
|
486
|
-
status: 400 | 500;
|
|
479
|
+
status: 400 | 401 | 500;
|
|
487
480
|
body: AuthorizationFailureBody;
|
|
488
481
|
};
|
|
489
482
|
/**
|
|
@@ -494,33 +487,39 @@ export type AuthorizationResult = {
|
|
|
494
487
|
* input validation 400.
|
|
495
488
|
*
|
|
496
489
|
* Pure data — the function does not touch a Hono context. Each transport
|
|
497
|
-
* passes
|
|
490
|
+
* passes the account its credential resolved (`ResolvedAuth.account`) and
|
|
498
491
|
* binds the returned `AuthorizationResult` to its wire shape. The REST
|
|
499
492
|
* pipeline additionally writes `REQUEST_CONTEXT_KEY` on `c` for downstream
|
|
500
493
|
* `require_role` / `require_credential_types` middleware that still reads
|
|
501
494
|
* the resolved context off the Hono context.
|
|
502
495
|
*
|
|
496
|
+
* The account is never read here: the context is built on the credential
|
|
497
|
+
* leg's row, so a request reads its account once, as on the Rust spine,
|
|
498
|
+
* whose `apply_authorization_phase` takes the resolved account the same way.
|
|
499
|
+
*
|
|
503
500
|
* Branching by `auth.account` × `auth.actor`:
|
|
504
501
|
*
|
|
505
502
|
* - Both `'none'` → `{ok: true, request_context: null}`. Public actions
|
|
506
503
|
* never see a `RequestContext`.
|
|
507
|
-
* - `
|
|
504
|
+
* - `account == null` on any non-public route → same null
|
|
508
505
|
* `request_context`. The `'required'` callers were already rejected at
|
|
509
506
|
* the pre-authorization gate in the dispatcher; only genuine anonymous
|
|
510
507
|
* access on an `'optional'` axis lands here.
|
|
511
|
-
* - `actor === 'none'` →
|
|
512
|
-
*
|
|
508
|
+
* - `actor === 'none'` → an account-only context, `{account, actor: null,
|
|
509
|
+
* role_grants: []}`.
|
|
513
510
|
* - `actor === 'required'` → resolves the actor from `acting_value` (or
|
|
514
|
-
* single-actor account); failures map to 400 / 500.
|
|
511
|
+
* single-actor account); failures map to 400 / 401 / 500.
|
|
515
512
|
* - `actor === 'optional'` → same as `'required'` except multi-actor
|
|
516
513
|
* accounts without an `acting` value fall back to account-only context
|
|
517
514
|
* (no `actor_required` 400). Bad `acting` ids still 400.
|
|
518
515
|
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
516
|
+
* An account removed since the credential leg read it takes its actors with
|
|
517
|
+
* it: an actor-grain route then finds none, and answers the dead credential's
|
|
518
|
+
* 401 `ERROR_AUTHENTICATION_REQUIRED`, as a request that arrived after the
|
|
519
|
+
* removal does. The one 500 is `ERROR_NO_ACTORS_ON_ACCOUNT`: a live account
|
|
520
|
+
* with no active actor, a signup invariant violation.
|
|
522
521
|
*/
|
|
523
|
-
export declare const apply_authorization_phase: (deps: QueryDeps,
|
|
522
|
+
export declare const apply_authorization_phase: (deps: QueryDeps, account: Account | null, auth: RouteAuth, acting_value: string | undefined) => Promise<AuthorizationResult>;
|
|
524
523
|
/**
|
|
525
524
|
* Run the authorization phase on a Hono request: resolve the acting actor from
|
|
526
525
|
* `acting` against the authenticated account, and set the resulting
|
|
@@ -543,8 +542,9 @@ export declare const apply_authorization_phase: (deps: QueryDeps, account_id: st
|
|
|
543
542
|
* @param deps - query deps for actor resolution
|
|
544
543
|
* @param auth - the route's auth shape
|
|
545
544
|
* @param acting - the `acting` selector, already through `parse_acting`; `undefined` when absent
|
|
546
|
-
* @returns the refusal to answer (`400` actor selection, `
|
|
547
|
-
*
|
|
545
|
+
* @returns the refusal to answer (`400` actor selection, `401` an account
|
|
546
|
+
* removed since its credential was read, `500` a live account with no active
|
|
547
|
+
* actor), or nothing when the request may proceed
|
|
548
548
|
*/
|
|
549
549
|
export declare const run_authorization_phase: (c: Context, deps: QueryDeps, auth: RouteAuth, acting: string | undefined) => Promise<Response | void>;
|
|
550
550
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request_context.d.ts","sourceRoot":"","sources":["../../src/lib/auth/request_context.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"request_context.d.ts","sourceRoot":"","sources":["../../src/lib/auth/request_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,MA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