@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
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Permit offer RPC action specs — declarative contract for the
|
|
3
|
-
* consentful-permits surface (offer lifecycle + admin revoke).
|
|
4
|
-
*
|
|
5
|
-
* Import this module for the specs, Input/Output schemas, `ERROR_OFFER_*`
|
|
6
|
-
* reason constants, and the `all_permit_offer_action_specs` registry.
|
|
7
|
-
* Handlers live in `auth/permit_offer_actions.ts`.
|
|
8
|
-
*
|
|
9
|
-
* Authorization enforcement: offer-lifecycle specs declare
|
|
10
|
-
* `auth: 'authenticated'` and rely on `query_*` IDOR guards or in-handler
|
|
11
|
-
* policy checks (e.g. `permit_offer_list`/`_history` elevate to admin only
|
|
12
|
-
* when inspecting another account — an input-dependent check that can't be
|
|
13
|
-
* expressed at the spec level). `permit_revoke` declares
|
|
14
|
-
* `auth: {role: 'admin'}` — the RPC dispatcher's per-spec `check_action_auth`
|
|
15
|
-
* gates it before the handler runs even though the endpoint hosts non-admin
|
|
16
|
-
* methods alongside.
|
|
17
|
-
*
|
|
18
|
-
* @module
|
|
19
|
-
*/
|
|
20
|
-
import { z } from 'zod';
|
|
21
|
-
import { Uuid } from '@fuzdev/fuz_util/id.js';
|
|
22
|
-
import { ERROR_ACCOUNT_NOT_FOUND, ERROR_PERMIT_NOT_FOUND, ERROR_ROLE_NOT_WEB_GRANTABLE, } from '../http/error_schemas.js';
|
|
23
|
-
import { RoleName } from './role_schema.js';
|
|
24
|
-
import { PERMIT_OFFER_MESSAGE_LENGTH_MAX, PermitOfferJson } from './permit_offer_schema.js';
|
|
25
|
-
import { PERMIT_REVOKED_REASON_LENGTH_MAX } from './account_schema.js';
|
|
26
|
-
/** Error reason — caller tried to offer themselves a permit. */
|
|
27
|
-
export const ERROR_OFFER_SELF_TARGET = 'offer_self_target';
|
|
28
|
-
/** Error reason — offer is declined, retracted, or superseded. */
|
|
29
|
-
export const ERROR_OFFER_TERMINAL = 'offer_terminal';
|
|
30
|
-
/** Error reason — offer's `expires_at` has passed. */
|
|
31
|
-
export const ERROR_OFFER_EXPIRED = 'offer_expired';
|
|
32
|
-
/** Error reason — offer does not exist or belongs to a different recipient (404-over-403 IDOR mask). */
|
|
33
|
-
export const ERROR_OFFER_NOT_FOUND = 'offer_not_found';
|
|
34
|
-
/** Error reason — the offered role is not `web_grantable` (nobody may offer it via this surface). */
|
|
35
|
-
export const ERROR_OFFER_ROLE_NOT_GRANTABLE = 'offer_role_not_grantable';
|
|
36
|
-
/** Error reason — caller is not authorized to offer this role (default policy: caller lacks the role; consumer `authorize` callback may add further policy). */
|
|
37
|
-
export const ERROR_OFFER_NOT_AUTHORIZED = 'offer_not_authorized';
|
|
38
|
-
// -- Input/output schemas ---------------------------------------------------
|
|
39
|
-
/** Input for `permit_offer_create`. */
|
|
40
|
-
export const PermitOfferCreateInput = z.strictObject({
|
|
41
|
-
to_account_id: Uuid.meta({ description: 'Account id of the recipient.' }),
|
|
42
|
-
role: RoleName.meta({ description: 'Role being offered.' }),
|
|
43
|
-
scope_id: Uuid.nullish().meta({
|
|
44
|
-
description: 'Scope id for resource-scoped grants (e.g. classroom id). `null` for global.',
|
|
45
|
-
}),
|
|
46
|
-
message: z
|
|
47
|
-
.string()
|
|
48
|
-
.max(PERMIT_OFFER_MESSAGE_LENGTH_MAX)
|
|
49
|
-
.nullish()
|
|
50
|
-
.meta({ description: 'Optional free-form note from the grantor.' }),
|
|
51
|
-
});
|
|
52
|
-
/** Input for `permit_offer_accept`. */
|
|
53
|
-
export const PermitOfferAcceptInput = z.strictObject({
|
|
54
|
-
offer_id: Uuid.meta({ description: 'The offer to accept.' }),
|
|
55
|
-
});
|
|
56
|
-
/** Input for `permit_offer_decline`. */
|
|
57
|
-
export const PermitOfferDeclineInput = z.strictObject({
|
|
58
|
-
offer_id: Uuid.meta({ description: 'The offer to decline.' }),
|
|
59
|
-
reason: z
|
|
60
|
-
.string()
|
|
61
|
-
.max(PERMIT_OFFER_MESSAGE_LENGTH_MAX)
|
|
62
|
-
.nullish()
|
|
63
|
-
.meta({ description: 'Optional free-form reason given on decline.' }),
|
|
64
|
-
});
|
|
65
|
-
/** Input for `permit_offer_retract`. */
|
|
66
|
-
export const PermitOfferRetractInput = z.strictObject({
|
|
67
|
-
offer_id: Uuid.meta({ description: 'The offer to retract.' }),
|
|
68
|
-
});
|
|
69
|
-
/** Input for `permit_offer_list`. `account_id` is admin-only (inspect another account's inbox). */
|
|
70
|
-
export const PermitOfferListInput = z.strictObject({
|
|
71
|
-
account_id: Uuid.nullish().meta({
|
|
72
|
-
description: 'Admin-only — list offers for another account. Defaults to the caller.',
|
|
73
|
-
}),
|
|
74
|
-
});
|
|
75
|
-
/**
|
|
76
|
-
* Input for `permit_revoke`. Admin-only mutation that revokes an active
|
|
77
|
-
* permit on a target actor. `actor_id` is the natural key — permits are
|
|
78
|
-
* actor-scoped, and the admin UI reads `row.actor.id` straight from the
|
|
79
|
-
* listing. Deriving `actor_id` from `account_id` would collapse under
|
|
80
|
-
* multi-actor accounts.
|
|
81
|
-
*/
|
|
82
|
-
export const PermitRevokeInput = z.strictObject({
|
|
83
|
-
actor_id: Uuid.meta({ description: 'Actor whose permit to revoke.' }),
|
|
84
|
-
permit_id: Uuid.meta({ description: 'The permit to revoke.' }),
|
|
85
|
-
reason: z.string().max(PERMIT_REVOKED_REASON_LENGTH_MAX).nullish().meta({
|
|
86
|
-
description: 'Optional free-form reason; stamped on `permit.revoked_reason` and surfaced on the revokee WS notification.',
|
|
87
|
-
}),
|
|
88
|
-
});
|
|
89
|
-
/**
|
|
90
|
-
* Input for `permit_offer_history`. Returns every offer involving the account
|
|
91
|
-
* in either direction (recipient or grantor), including terminal rows, newest
|
|
92
|
-
* first. `account_id` is admin-only.
|
|
93
|
-
*/
|
|
94
|
-
export const PermitOfferHistoryInput = z.strictObject({
|
|
95
|
-
account_id: Uuid.nullish().meta({
|
|
96
|
-
description: 'Admin-only — history for another account. Defaults to the caller.',
|
|
97
|
-
}),
|
|
98
|
-
limit: z.number().int().min(1).max(500).nullish().meta({
|
|
99
|
-
description: 'Max rows to return (default 100).',
|
|
100
|
-
}),
|
|
101
|
-
offset: z.number().int().min(0).nullish().meta({
|
|
102
|
-
description: 'Pagination offset (default 0).',
|
|
103
|
-
}),
|
|
104
|
-
});
|
|
105
|
-
/** Output for `permit_offer_create`. */
|
|
106
|
-
export const PermitOfferCreateOutput = z.strictObject({
|
|
107
|
-
offer: PermitOfferJson,
|
|
108
|
-
});
|
|
109
|
-
/** Output for `permit_offer_accept`. */
|
|
110
|
-
export const PermitOfferAcceptOutput = z.strictObject({
|
|
111
|
-
permit_id: Uuid,
|
|
112
|
-
offer: PermitOfferJson,
|
|
113
|
-
superseded_offer_ids: z.array(Uuid),
|
|
114
|
-
});
|
|
115
|
-
/** Output for `permit_offer_decline` / `permit_offer_retract`. */
|
|
116
|
-
export const PermitOfferOkOutput = z.strictObject({ ok: z.literal(true) });
|
|
117
|
-
/** Output for `permit_offer_list`. */
|
|
118
|
-
export const PermitOfferListOutput = z.strictObject({ offers: z.array(PermitOfferJson) });
|
|
119
|
-
/** Output for `permit_offer_history`. */
|
|
120
|
-
export const PermitOfferHistoryOutput = z.strictObject({ offers: z.array(PermitOfferJson) });
|
|
121
|
-
/** Output for `permit_revoke`. */
|
|
122
|
-
export const PermitRevokeOutput = z.strictObject({
|
|
123
|
-
ok: z.literal(true),
|
|
124
|
-
revoked: z.literal(true),
|
|
125
|
-
});
|
|
126
|
-
// -- Action specs -----------------------------------------------------------
|
|
127
|
-
export const permit_offer_create_action_spec = {
|
|
128
|
-
method: 'permit_offer_create',
|
|
129
|
-
kind: 'request_response',
|
|
130
|
-
initiator: 'frontend',
|
|
131
|
-
auth: 'authenticated',
|
|
132
|
-
side_effects: true,
|
|
133
|
-
input: PermitOfferCreateInput,
|
|
134
|
-
output: PermitOfferCreateOutput,
|
|
135
|
-
async: true,
|
|
136
|
-
description: 'Offer a permit to another account. Grantor must hold the offered role (or pass a consumer authorize callback); role must be web_grantable.',
|
|
137
|
-
error_reasons: [
|
|
138
|
-
ERROR_OFFER_SELF_TARGET,
|
|
139
|
-
ERROR_OFFER_ROLE_NOT_GRANTABLE,
|
|
140
|
-
ERROR_OFFER_NOT_AUTHORIZED,
|
|
141
|
-
],
|
|
142
|
-
};
|
|
143
|
-
export const permit_offer_accept_action_spec = {
|
|
144
|
-
method: 'permit_offer_accept',
|
|
145
|
-
kind: 'request_response',
|
|
146
|
-
initiator: 'frontend',
|
|
147
|
-
auth: 'authenticated',
|
|
148
|
-
side_effects: true,
|
|
149
|
-
input: PermitOfferAcceptInput,
|
|
150
|
-
output: PermitOfferAcceptOutput,
|
|
151
|
-
async: true,
|
|
152
|
-
description: 'Accept an offer. Atomically marks the offer accepted, inserts the permit, and supersedes sibling pending offers for the same (account, role, scope).',
|
|
153
|
-
error_reasons: [ERROR_OFFER_NOT_FOUND, ERROR_OFFER_TERMINAL, ERROR_OFFER_EXPIRED],
|
|
154
|
-
};
|
|
155
|
-
export const permit_offer_decline_action_spec = {
|
|
156
|
-
method: 'permit_offer_decline',
|
|
157
|
-
kind: 'request_response',
|
|
158
|
-
initiator: 'frontend',
|
|
159
|
-
auth: 'authenticated',
|
|
160
|
-
side_effects: true,
|
|
161
|
-
input: PermitOfferDeclineInput,
|
|
162
|
-
output: PermitOfferOkOutput,
|
|
163
|
-
async: true,
|
|
164
|
-
description: 'Decline an offer. Recipient-only.',
|
|
165
|
-
error_reasons: [ERROR_OFFER_NOT_FOUND, ERROR_OFFER_TERMINAL],
|
|
166
|
-
};
|
|
167
|
-
export const permit_offer_retract_action_spec = {
|
|
168
|
-
method: 'permit_offer_retract',
|
|
169
|
-
kind: 'request_response',
|
|
170
|
-
initiator: 'frontend',
|
|
171
|
-
auth: 'authenticated',
|
|
172
|
-
side_effects: true,
|
|
173
|
-
input: PermitOfferRetractInput,
|
|
174
|
-
output: PermitOfferOkOutput,
|
|
175
|
-
async: true,
|
|
176
|
-
description: 'Retract an offer. Grantor-only, pre-decision.',
|
|
177
|
-
error_reasons: [ERROR_OFFER_NOT_FOUND, ERROR_OFFER_TERMINAL],
|
|
178
|
-
};
|
|
179
|
-
export const permit_offer_list_action_spec = {
|
|
180
|
-
method: 'permit_offer_list',
|
|
181
|
-
kind: 'request_response',
|
|
182
|
-
initiator: 'frontend',
|
|
183
|
-
auth: 'authenticated',
|
|
184
|
-
side_effects: false,
|
|
185
|
-
input: PermitOfferListInput,
|
|
186
|
-
output: PermitOfferListOutput,
|
|
187
|
-
async: true,
|
|
188
|
-
description: 'List pending, non-expired offers for the caller. Admins may pass `account_id` to inspect another account.',
|
|
189
|
-
};
|
|
190
|
-
export const permit_offer_history_action_spec = {
|
|
191
|
-
method: 'permit_offer_history',
|
|
192
|
-
kind: 'request_response',
|
|
193
|
-
initiator: 'frontend',
|
|
194
|
-
auth: 'authenticated',
|
|
195
|
-
side_effects: false,
|
|
196
|
-
input: PermitOfferHistoryInput,
|
|
197
|
-
output: PermitOfferHistoryOutput,
|
|
198
|
-
async: true,
|
|
199
|
-
description: 'List every offer involving the caller (either direction), including terminal rows, newest first. Admins may pass `account_id` to inspect another account.',
|
|
200
|
-
};
|
|
201
|
-
export const permit_revoke_action_spec = {
|
|
202
|
-
method: 'permit_revoke',
|
|
203
|
-
kind: 'request_response',
|
|
204
|
-
initiator: 'frontend',
|
|
205
|
-
auth: { role: 'admin' },
|
|
206
|
-
side_effects: true,
|
|
207
|
-
input: PermitRevokeInput,
|
|
208
|
-
output: PermitRevokeOutput,
|
|
209
|
-
async: true,
|
|
210
|
-
description: 'Revoke an active permit on a target actor. Admin-only. Supersedes any pending offers for the same (account, role, scope). Fires permit_revoke + permit_offer_supersede notifications.',
|
|
211
|
-
error_reasons: [ERROR_PERMIT_NOT_FOUND, ERROR_ACCOUNT_NOT_FOUND, ERROR_ROLE_NOT_WEB_GRANTABLE],
|
|
212
|
-
rate_limit: 'account',
|
|
213
|
-
};
|
|
214
|
-
/**
|
|
215
|
-
* All permit-offer action specs — a codegen-ready registry. Consumers spread
|
|
216
|
-
* this into their own action-spec array to include offer lifecycle + revoke
|
|
217
|
-
* methods in a typed client surface.
|
|
218
|
-
*/
|
|
219
|
-
export const all_permit_offer_action_specs = [
|
|
220
|
-
permit_offer_create_action_spec,
|
|
221
|
-
permit_offer_accept_action_spec,
|
|
222
|
-
permit_offer_decline_action_spec,
|
|
223
|
-
permit_offer_retract_action_spec,
|
|
224
|
-
permit_offer_list_action_spec,
|
|
225
|
-
permit_offer_history_action_spec,
|
|
226
|
-
permit_revoke_action_spec,
|
|
227
|
-
];
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Permit offer RPC action handlers — the consentful-permits action surface.
|
|
3
|
-
*
|
|
4
|
-
* Seven actions: six offer-lifecycle methods (create / accept / decline /
|
|
5
|
-
* retract / list / history) plus `permit_revoke` (admin-only). All mount
|
|
6
|
-
* on a consumer's JSON-RPC endpoint via `create_rpc_endpoint`. The action
|
|
7
|
-
* specs themselves live in `auth/permit_offer_action_specs.ts`. Mutations
|
|
8
|
-
* declare `side_effects: true` so the RPC dispatcher wraps the handler in
|
|
9
|
-
* a DB transaction; `permit_offer_list` and `permit_offer_history` declare
|
|
10
|
-
* `side_effects: false` so they are addressable via GET.
|
|
11
|
-
*
|
|
12
|
-
* Authorization:
|
|
13
|
-
* - `permit_offer_create` — the grantor must hold an active permit for the
|
|
14
|
-
* role being offered, and that role must be `web_grantable`. Consumers
|
|
15
|
-
* needing a richer policy (e.g., "teacher may offer student in *their*
|
|
16
|
-
* classroom") pass an `authorize` callback that overrides the default.
|
|
17
|
-
* - `permit_offer_accept` / `permit_offer_decline` — keyed to the caller's
|
|
18
|
-
* account; `query_*` helpers enforce the IDOR guard.
|
|
19
|
-
* - `permit_offer_retract` — keyed to the caller's actor.
|
|
20
|
-
* - `permit_offer_list` / `permit_offer_history` — self by default;
|
|
21
|
-
* `{account_id}` is admin-only.
|
|
22
|
-
* - `permit_revoke` — spec-level `auth: {role: 'admin'}`; the RPC
|
|
23
|
-
* dispatcher rejects non-admin callers before the handler runs.
|
|
24
|
-
* `web_grantable` gate prevents revoking keeper/daemon-scoped roles
|
|
25
|
-
* via this surface. Keys on `actor_id` to survive multi-actor accounts.
|
|
26
|
-
*
|
|
27
|
-
* Audit events are emitted in-transaction by the query layer (atomic with
|
|
28
|
-
* the permit write on accept/revoke) or by the handler via
|
|
29
|
-
* `audit_log_fire_and_forget` for single-event lifecycle transitions.
|
|
30
|
-
* `on_audit_event` (SSE broadcast) fires post-commit in both paths.
|
|
31
|
-
*
|
|
32
|
-
* WS notifications fan out post-commit via `emit_after_commit` when a
|
|
33
|
-
* `notification_sender` is wired: offer lifecycle transitions notify the
|
|
34
|
-
* counterparty, `permit_revoke` notifies the revokee plus each superseded
|
|
35
|
-
* pending offer's grantor.
|
|
36
|
-
*
|
|
37
|
-
* @module
|
|
38
|
-
*/
|
|
39
|
-
import { type ActionContext, type RpcAction } from '../actions/action_rpc.js';
|
|
40
|
-
import { type RoleSchemaResult } from './role_schema.js';
|
|
41
|
-
import { type RequestContext } from './request_context.js';
|
|
42
|
-
import type { RouteFactoryDeps } from './deps.js';
|
|
43
|
-
import { type NotificationSender } from './permit_offer_notifications.js';
|
|
44
|
-
/**
|
|
45
|
-
* Authorization callback for `permit_offer_create`. Returns `true` to allow,
|
|
46
|
-
* `false` to reject (handler converts to `forbidden`).
|
|
47
|
-
*
|
|
48
|
-
* Provided with the fully-resolved request context and the parsed input
|
|
49
|
-
* (pre-TTL, pre-normalization). Consumers override the default to implement
|
|
50
|
-
* policies like "teacher may offer classroom_student only in classrooms they
|
|
51
|
-
* teach".
|
|
52
|
-
*/
|
|
53
|
-
export type PermitOfferCreateAuthorize = (auth: RequestContext, input: {
|
|
54
|
-
to_account_id: string;
|
|
55
|
-
role: string;
|
|
56
|
-
scope_id: string | null;
|
|
57
|
-
}, deps: Pick<RouteFactoryDeps, 'log'>, ctx: ActionContext) => boolean | Promise<boolean>;
|
|
58
|
-
/** Options for `create_permit_offer_actions`. */
|
|
59
|
-
export interface PermitOfferActionOptions {
|
|
60
|
-
/**
|
|
61
|
-
* Role schema result from `create_role_schema()`. Defaults to builtin roles only.
|
|
62
|
-
* The `role_options` map is read for `web_grantable` lookups.
|
|
63
|
-
*/
|
|
64
|
-
roles?: RoleSchemaResult;
|
|
65
|
-
/** TTL applied to newly-created offers. Defaults to `PERMIT_OFFER_DEFAULT_TTL_MS`. */
|
|
66
|
-
default_ttl_ms?: number;
|
|
67
|
-
/**
|
|
68
|
-
* Custom authorization for `permit_offer_create`. The default requires the
|
|
69
|
-
* caller to hold an active permit for the offered role *and* the role to
|
|
70
|
-
* be `web_grantable`. Consumers with richer policies (scope-aware, chained
|
|
71
|
-
* roles) override this.
|
|
72
|
-
*/
|
|
73
|
-
authorize?: PermitOfferCreateAuthorize;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Authorization callback that admits any admin and otherwise falls back to
|
|
77
|
-
* the symmetric default (caller must hold the offered role globally).
|
|
78
|
-
*
|
|
79
|
-
* The `web_grantable` filter in `create_handler` runs **before** the
|
|
80
|
-
* `authorize` callback, so this never sees non-web-grantable roles. Drop
|
|
81
|
-
* into `create_permit_offer_actions({authorize: authorize_admin_or_holder})`
|
|
82
|
-
* (or any factory that forwards `authorize`, e.g. `create_standard_rpc_actions`)
|
|
83
|
-
* for the common "admins offer anything; users offer what they hold"
|
|
84
|
-
* pattern. Scope-aware policies (e.g. classroom_teacher offering
|
|
85
|
-
* classroom_student in their own scope) wrap this and short-circuit `true`
|
|
86
|
-
* before delegating.
|
|
87
|
-
*/
|
|
88
|
-
export declare const authorize_admin_or_holder: PermitOfferCreateAuthorize;
|
|
89
|
-
/**
|
|
90
|
-
* Dependencies for `create_permit_offer_actions`.
|
|
91
|
-
*
|
|
92
|
-
* `notification_sender` is optional — when absent, WS fan-out is silently
|
|
93
|
-
* skipped. Consumers wiring `BackendWebsocketTransport` assign its instance
|
|
94
|
-
* directly (the transport's `send_to_account` signature accepts the broader
|
|
95
|
-
* `JsonrpcMessageFromServerToClient`, which is contravariantly compatible).
|
|
96
|
-
*/
|
|
97
|
-
export interface PermitOfferActionDeps extends Pick<RouteFactoryDeps, 'log' | 'on_audit_event' | 'audit_log_config'> {
|
|
98
|
-
/** Optional WS fan-out primitive. `null` or absent → notifications skipped. */
|
|
99
|
-
notification_sender?: NotificationSender | null;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Create the seven permit-offer RPC actions (six offer-lifecycle methods
|
|
103
|
-
* plus `permit_revoke`).
|
|
104
|
-
*
|
|
105
|
-
* @param deps - `PermitOfferActionDeps` — `log`, `on_audit_event`, optional `audit_log_config` (slice of `AppDeps`); optional `notification_sender` for WS fan-out
|
|
106
|
-
* @param options - role schema, default TTL, authorization override
|
|
107
|
-
* @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
|
|
108
|
-
*/
|
|
109
|
-
export declare const create_permit_offer_actions: (deps: PermitOfferActionDeps, options?: PermitOfferActionOptions) => Array<RpcAction>;
|
|
110
|
-
//# sourceMappingURL=permit_offer_actions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permit_offer_actions.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/permit_offer_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAa,KAAK,aAAa,EAAE,KAAK,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAGxF,OAAO,EAAmC,KAAK,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAkBzF,OAAO,EAA4B,KAAK,cAAc,EAAC,MAAM,sBAAsB,CAAC;AACpF,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAChD,OAAO,EAON,KAAK,kBAAkB,EACvB,MAAM,iCAAiC,CAAC;AAmCzC;;;;;;;;GAQG;AACH,MAAM,MAAM,0BAA0B,GAAG,CACxC,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAC,EACrE,IAAI,EAAE,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,EACnC,GAAG,EAAE,aAAa,KACd,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEhC,iDAAiD;AACjD,MAAM,WAAW,wBAAwB;IACxC;;;OAGG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,sFAAsF;IACtF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,0BAA0B,CAAC;CACvC;AA4BD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,EAAE,0BASvC,CAAC;AAcF;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAClD,gBAAgB,EAChB,KAAK,GAAG,gBAAgB,GAAG,kBAAkB,CAC7C;IACA,+EAA+E;IAC/E,mBAAmB,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAChD;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GACvC,MAAM,qBAAqB,EAC3B,UAAS,wBAA6B,KACpC,KAAK,CAAC,SAAS,CAudjB,CAAC"}
|