@fuzdev/fuz_app 0.55.0 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/CLAUDE.md +211 -155
- package/dist/actions/action_bridge.d.ts +8 -5
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +1 -11
- package/dist/actions/action_codegen.d.ts +19 -0
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +20 -14
- package/dist/actions/action_registry.d.ts.map +1 -1
- package/dist/actions/action_registry.js +5 -2
- package/dist/actions/action_rpc.d.ts +110 -44
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +92 -287
- package/dist/actions/action_spec.d.ts +55 -16
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/actions/action_spec.js +16 -11
- package/dist/actions/action_types.d.ts +28 -60
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +13 -5
- package/dist/actions/broadcast_api.d.ts +2 -2
- package/dist/actions/broadcast_api.js +2 -2
- package/dist/actions/compile_action_registry.d.ts +50 -0
- package/dist/actions/compile_action_registry.d.ts.map +1 -0
- package/dist/actions/compile_action_registry.js +69 -0
- package/dist/actions/heartbeat.d.ts +8 -4
- package/dist/actions/heartbeat.d.ts.map +1 -1
- package/dist/actions/heartbeat.js +5 -4
- package/dist/actions/perform_action.d.ts +145 -0
- package/dist/actions/perform_action.d.ts.map +1 -0
- package/dist/actions/perform_action.js +258 -0
- package/dist/actions/register_action_ws.d.ts +44 -38
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +101 -159
- package/dist/actions/register_ws_endpoint.d.ts +2 -10
- package/dist/actions/register_ws_endpoint.d.ts.map +1 -1
- package/dist/actions/register_ws_endpoint.js +32 -10
- package/dist/actions/transports_ws_auth_guard.d.ts +1 -1
- package/dist/actions/transports_ws_auth_guard.js +1 -1
- package/dist/actions/transports_ws_backend.d.ts +1 -1
- package/dist/actions/transports_ws_backend.js +1 -1
- package/dist/auth/CLAUDE.md +673 -442
- package/dist/auth/account_action_specs.d.ts +28 -7
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +7 -7
- package/dist/auth/account_actions.d.ts +8 -14
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +26 -32
- package/dist/auth/account_queries.d.ts +46 -13
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +73 -33
- package/dist/auth/account_routes.d.ts +4 -3
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +58 -33
- package/dist/auth/account_schema.d.ts +46 -54
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +21 -48
- package/dist/auth/admin_action_specs.d.ts +55 -21
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +42 -26
- package/dist/auth/admin_actions.d.ts +14 -21
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +47 -44
- package/dist/auth/audit_emitter.d.ts +160 -0
- package/dist/auth/audit_emitter.d.ts.map +1 -0
- package/dist/auth/audit_emitter.js +83 -0
- package/dist/auth/audit_log_queries.d.ts +17 -87
- package/dist/auth/audit_log_queries.d.ts.map +1 -1
- package/dist/auth/audit_log_queries.js +17 -96
- package/dist/auth/audit_log_routes.d.ts +1 -1
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +7 -3
- package/dist/auth/audit_log_schema.d.ts +48 -42
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +56 -43
- package/dist/auth/auth_guard_resolver.d.ts +44 -0
- package/dist/auth/auth_guard_resolver.d.ts.map +1 -0
- package/dist/auth/auth_guard_resolver.js +56 -0
- package/dist/auth/bootstrap_account.d.ts +7 -7
- package/dist/auth/bootstrap_account.d.ts.map +1 -1
- package/dist/auth/bootstrap_account.js +7 -7
- package/dist/auth/bootstrap_routes.d.ts.map +1 -1
- package/dist/auth/bootstrap_routes.js +11 -10
- package/dist/auth/cleanup.d.ts +20 -26
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +33 -47
- package/dist/auth/credential_type_schema.d.ts +115 -0
- package/dist/auth/credential_type_schema.d.ts.map +1 -0
- package/dist/auth/credential_type_schema.js +127 -0
- package/dist/auth/daemon_token_middleware.d.ts +1 -1
- package/dist/auth/daemon_token_middleware.js +3 -3
- package/dist/auth/ddl.d.ts +2 -2
- package/dist/auth/ddl.d.ts.map +1 -1
- package/dist/auth/ddl.js +6 -6
- package/dist/auth/deps.d.ts +7 -32
- package/dist/auth/deps.d.ts.map +1 -1
- package/dist/auth/grant_path_schema.d.ts +117 -0
- package/dist/auth/grant_path_schema.d.ts.map +1 -0
- package/dist/auth/grant_path_schema.js +137 -0
- package/dist/auth/invite_queries.d.ts +12 -1
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +12 -1
- package/dist/auth/invite_schema.d.ts +1 -1
- package/dist/auth/invite_schema.d.ts.map +1 -1
- package/dist/auth/invite_schema.js +1 -1
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +5 -2
- package/dist/auth/migrations.d.ts +22 -7
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +64 -25
- package/dist/auth/request_context.d.ts +157 -170
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +224 -268
- package/dist/auth/{permit_offer_action_specs.d.ts → role_grant_offer_action_specs.d.ts} +130 -100
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -0
- package/dist/auth/role_grant_offer_action_specs.js +262 -0
- package/dist/auth/role_grant_offer_actions.d.ts +104 -0
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -0
- package/dist/auth/{permit_offer_actions.js → role_grant_offer_actions.js} +153 -140
- package/dist/auth/{permit_offer_notifications.d.ts → role_grant_offer_notifications.d.ts} +80 -70
- package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -0
- package/dist/auth/role_grant_offer_notifications.js +182 -0
- package/dist/auth/{permit_offer_queries.d.ts → role_grant_offer_queries.d.ts} +64 -64
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -0
- package/dist/auth/{permit_offer_queries.js → role_grant_offer_queries.js} +136 -123
- package/dist/auth/role_grant_offer_schema.d.ts +150 -0
- package/dist/auth/role_grant_offer_schema.d.ts.map +1 -0
- package/dist/auth/{permit_offer_schema.js → role_grant_offer_schema.js} +55 -36
- package/dist/auth/role_grant_queries.d.ts +231 -0
- package/dist/auth/role_grant_queries.d.ts.map +1 -0
- package/dist/auth/role_grant_queries.js +320 -0
- package/dist/auth/role_schema.d.ts +150 -40
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +144 -45
- package/dist/auth/scope_kind_schema.d.ts +96 -0
- package/dist/auth/scope_kind_schema.d.ts.map +1 -0
- package/dist/auth/scope_kind_schema.js +94 -0
- package/dist/auth/self_service_role_action_specs.d.ts +4 -1
- package/dist/auth/self_service_role_action_specs.d.ts.map +1 -1
- package/dist/auth/self_service_role_action_specs.js +2 -2
- package/dist/auth/self_service_role_actions.d.ts +35 -29
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +58 -48
- package/dist/auth/session_cookie.d.ts +43 -6
- package/dist/auth/session_cookie.d.ts.map +1 -1
- package/dist/auth/session_cookie.js +31 -5
- package/dist/auth/session_middleware.d.ts +37 -3
- package/dist/auth/session_middleware.d.ts.map +1 -1
- package/dist/auth/session_middleware.js +33 -7
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +48 -19
- package/dist/auth/standard_action_specs.d.ts +2 -2
- package/dist/auth/standard_action_specs.js +4 -4
- package/dist/auth/standard_rpc_actions.d.ts +23 -19
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/standard_rpc_actions.js +12 -12
- package/dist/db/migrate.d.ts +1 -1
- package/dist/db/migrate.js +1 -1
- package/dist/dev/setup.d.ts +2 -2
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +4 -4
- package/dist/env/load.d.ts +1 -1
- package/dist/env/load.js +1 -1
- package/dist/hono_context.d.ts +27 -45
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +14 -28
- package/dist/http/CLAUDE.md +235 -121
- package/dist/http/auth_shape.d.ts +191 -0
- package/dist/http/auth_shape.d.ts.map +1 -0
- package/dist/http/auth_shape.js +237 -0
- package/dist/http/common_routes.js +3 -3
- package/dist/http/db_routes.d.ts +4 -0
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +44 -7
- package/dist/http/error_schemas.d.ts +72 -39
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +81 -33
- package/dist/http/pending_effects.d.ts +71 -18
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +87 -18
- package/dist/http/proxy.d.ts +52 -5
- package/dist/http/proxy.d.ts.map +1 -1
- package/dist/http/proxy.js +92 -14
- package/dist/http/route_spec.d.ts +89 -75
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +54 -72
- package/dist/http/schema_helpers.d.ts +3 -14
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +2 -14
- package/dist/http/surface.d.ts +2 -10
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +3 -4
- package/dist/http/surface_query.d.ts +39 -35
- package/dist/http/surface_query.d.ts.map +1 -1
- package/dist/http/surface_query.js +79 -36
- package/dist/primitive_schemas.d.ts +39 -0
- package/dist/primitive_schemas.d.ts.map +1 -0
- package/dist/primitive_schemas.js +40 -0
- package/dist/realtime/sse_auth_guard.d.ts +5 -5
- package/dist/realtime/sse_auth_guard.js +9 -9
- package/dist/runtime/mock.d.ts +1 -1
- package/dist/runtime/mock.js +1 -1
- package/dist/server/app_backend.d.ts +14 -11
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +12 -8
- package/dist/server/app_server.d.ts +7 -7
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +35 -40
- package/dist/server/validate_nginx.d.ts +1 -1
- package/dist/server/validate_nginx.js +1 -1
- package/dist/testing/CLAUDE.md +50 -38
- package/dist/testing/admin_integration.d.ts +5 -6
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +87 -85
- package/dist/testing/app_server.d.ts +11 -14
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +16 -15
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +2 -1
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +15 -9
- package/dist/testing/audit_completeness.d.ts +2 -2
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +36 -36
- package/dist/testing/auth_apps.d.ts +5 -4
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +22 -19
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +5 -5
- package/dist/testing/db.d.ts +1 -1
- package/dist/testing/db.d.ts.map +1 -1
- package/dist/testing/db.js +4 -4
- package/dist/testing/db_entities.d.ts +22 -0
- package/dist/testing/db_entities.d.ts.map +1 -0
- package/dist/testing/db_entities.js +28 -0
- package/dist/testing/entities.d.ts +8 -7
- package/dist/testing/entities.d.ts.map +1 -1
- package/dist/testing/entities.js +21 -18
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +13 -14
- package/dist/testing/integration_helpers.d.ts +4 -4
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +20 -18
- package/dist/testing/middleware.d.ts +4 -4
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +12 -11
- package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
- package/dist/testing/rpc_attack_surface.js +40 -24
- package/dist/testing/rpc_round_trip.d.ts +1 -1
- package/dist/testing/rpc_round_trip.d.ts.map +1 -1
- package/dist/testing/rpc_round_trip.js +14 -13
- package/dist/testing/sse_round_trip.d.ts +3 -4
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +7 -11
- package/dist/testing/standard.d.ts +1 -1
- package/dist/testing/stubs.d.ts +25 -0
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +43 -2
- package/dist/testing/surface_invariants.d.ts +14 -6
- package/dist/testing/surface_invariants.d.ts.map +1 -1
- package/dist/testing/surface_invariants.js +119 -43
- package/dist/testing/ws_round_trip.d.ts +12 -13
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +19 -11
- package/dist/ui/AdminAccounts.svelte +23 -20
- package/dist/ui/AdminOverview.svelte +15 -13
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
- package/dist/ui/{AdminPermitHistory.svelte → AdminRoleGrantHistory.svelte} +12 -12
- package/dist/ui/AdminRoleGrantHistory.svelte.d.ts +4 -0
- package/dist/ui/AdminRoleGrantHistory.svelte.d.ts.map +1 -0
- package/dist/ui/BootstrapForm.svelte +1 -1
- package/dist/ui/CLAUDE.md +60 -60
- package/dist/ui/{PermitOfferForm.svelte → RoleGrantOfferForm.svelte} +27 -26
- package/dist/ui/{PermitOfferForm.svelte.d.ts → RoleGrantOfferForm.svelte.d.ts} +7 -7
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -0
- package/dist/ui/{PermitOfferHistory.svelte → RoleGrantOfferHistory.svelte} +12 -12
- package/dist/ui/{PermitOfferHistory.svelte.d.ts → RoleGrantOfferHistory.svelte.d.ts} +4 -4
- package/dist/ui/RoleGrantOfferHistory.svelte.d.ts.map +1 -0
- package/dist/ui/{PermitOfferInbox.svelte → RoleGrantOfferInbox.svelte} +14 -14
- package/dist/ui/{PermitOfferInbox.svelte.d.ts → RoleGrantOfferInbox.svelte.d.ts} +4 -4
- package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -0
- package/dist/ui/SignupForm.svelte +1 -1
- package/dist/ui/SurfaceExplorer.svelte +35 -15
- package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.d.ts +2 -3
- package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.js +2 -3
- package/dist/ui/admin_accounts_state.svelte.d.ts +18 -18
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.js +16 -16
- package/dist/ui/admin_rpc_adapters.d.ts +20 -20
- package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
- package/dist/ui/admin_rpc_adapters.js +17 -17
- package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
- package/dist/ui/admin_sessions_state.svelte.js +2 -2
- package/dist/ui/audit_log_state.svelte.d.ts +7 -7
- package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.js +6 -6
- package/dist/ui/auth_state.svelte.d.ts +3 -3
- package/dist/ui/auth_state.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.js +6 -6
- package/dist/ui/format_scope.d.ts +2 -2
- package/dist/ui/format_scope.js +2 -2
- package/dist/ui/{permit_offers_state.svelte.d.ts → role_grant_offers_state.svelte.d.ts} +30 -30
- package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -0
- package/dist/ui/{permit_offers_state.svelte.js → role_grant_offers_state.svelte.js} +18 -18
- package/dist/ui/ui_format.js +2 -2
- package/package.json +3 -3
- package/dist/auth/permit_offer_action_specs.d.ts.map +0 -1
- package/dist/auth/permit_offer_action_specs.js +0 -258
- package/dist/auth/permit_offer_actions.d.ts +0 -110
- package/dist/auth/permit_offer_actions.d.ts.map +0 -1
- package/dist/auth/permit_offer_notifications.d.ts.map +0 -1
- package/dist/auth/permit_offer_notifications.js +0 -182
- package/dist/auth/permit_offer_queries.d.ts.map +0 -1
- package/dist/auth/permit_offer_schema.d.ts +0 -125
- package/dist/auth/permit_offer_schema.d.ts.map +0 -1
- package/dist/auth/permit_queries.d.ts +0 -222
- package/dist/auth/permit_queries.d.ts.map +0 -1
- package/dist/auth/permit_queries.js +0 -305
- package/dist/auth/require_keeper.d.ts +0 -20
- package/dist/auth/require_keeper.d.ts.map +0 -1
- package/dist/auth/require_keeper.js +0 -35
- package/dist/auth/route_guards.d.ts +0 -27
- package/dist/auth/route_guards.d.ts.map +0 -1
- package/dist/auth/route_guards.js +0 -38
- package/dist/auth/session_lifecycle.d.ts +0 -37
- package/dist/auth/session_lifecycle.d.ts.map +0 -1
- package/dist/auth/session_lifecycle.js +0 -29
- package/dist/ui/AdminPermitHistory.svelte.d.ts +0 -4
- package/dist/ui/AdminPermitHistory.svelte.d.ts.map +0 -1
- package/dist/ui/PermitOfferForm.svelte.d.ts.map +0 -1
- package/dist/ui/PermitOfferHistory.svelte.d.ts.map +0 -1
- package/dist/ui/PermitOfferInbox.svelte.d.ts.map +0 -1
- package/dist/ui/permit_offers_state.svelte.d.ts.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Reactive state for the consentful-
|
|
2
|
+
* Reactive state for the consentful-role-grants offer flow.
|
|
3
3
|
*
|
|
4
4
|
* Maintains one offer cache keyed by id, seeded by the RPC list/history
|
|
5
|
-
* actions and kept live by the six
|
|
5
|
+
* actions and kept live by the six role-grant-offer WebSocket notifications.
|
|
6
6
|
* `incoming` (recipient-side pending) and `outgoing` (grantor-side pending)
|
|
7
7
|
* are derived views; `history` is the full cache ordered newest-first for
|
|
8
8
|
* the grantor/admin history view.
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { create_context } from '@fuzdev/fuz_ui/context_helpers.js';
|
|
19
19
|
import { Loadable } from './loadable.svelte.js';
|
|
20
|
-
import {
|
|
20
|
+
import { ROLE_GRANT_OFFER_ACCEPTED_NOTIFICATION_METHOD, ROLE_GRANT_OFFER_DECLINED_NOTIFICATION_METHOD, ROLE_GRANT_OFFER_RECEIVED_NOTIFICATION_METHOD, ROLE_GRANT_OFFER_RETRACTED_NOTIFICATION_METHOD, ROLE_GRANT_OFFER_SUPERSEDE_NOTIFICATION_METHOD, ROLE_GRANT_REVOKE_NOTIFICATION_METHOD, } from '../auth/role_grant_offer_notifications.js';
|
|
21
21
|
/**
|
|
22
|
-
* Svelte context for `
|
|
23
|
-
* Use `
|
|
24
|
-
* `
|
|
22
|
+
* Svelte context for `RoleGrantOffersState`.
|
|
23
|
+
* Use `role_grant_offers_state_context.set(state)` in the provider and
|
|
24
|
+
* `role_grant_offers_state_context.get()` to access.
|
|
25
25
|
*/
|
|
26
|
-
export const
|
|
26
|
+
export const role_grant_offers_state_context = create_context();
|
|
27
27
|
const is_terminal = (o) => o.accepted_at !== null ||
|
|
28
28
|
o.declined_at !== null ||
|
|
29
29
|
o.retracted_at !== null ||
|
|
30
30
|
o.superseded_at !== null;
|
|
31
|
-
export class
|
|
31
|
+
export class RoleGrantOffersState extends Loadable {
|
|
32
32
|
#rpc;
|
|
33
33
|
#get_account_id;
|
|
34
34
|
#get_actor_id;
|
|
@@ -155,23 +155,23 @@ export class PermitOffersState extends Loadable {
|
|
|
155
155
|
*/
|
|
156
156
|
apply_notification(notification) {
|
|
157
157
|
switch (notification.method) {
|
|
158
|
-
case
|
|
159
|
-
case
|
|
160
|
-
case
|
|
161
|
-
case
|
|
162
|
-
case
|
|
158
|
+
case ROLE_GRANT_OFFER_RECEIVED_NOTIFICATION_METHOD:
|
|
159
|
+
case ROLE_GRANT_OFFER_RETRACTED_NOTIFICATION_METHOD:
|
|
160
|
+
case ROLE_GRANT_OFFER_ACCEPTED_NOTIFICATION_METHOD:
|
|
161
|
+
case ROLE_GRANT_OFFER_DECLINED_NOTIFICATION_METHOD:
|
|
162
|
+
case ROLE_GRANT_OFFER_SUPERSEDE_NOTIFICATION_METHOD: {
|
|
163
163
|
const params = notification.params;
|
|
164
164
|
if (!params || typeof params !== 'object' || !('offer' in params))
|
|
165
165
|
return;
|
|
166
166
|
const offer = params.offer;
|
|
167
|
-
if (!
|
|
167
|
+
if (!is_role_grant_offer_like(offer))
|
|
168
168
|
return;
|
|
169
169
|
this.#merge_offers([offer]);
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
case
|
|
173
|
-
//
|
|
174
|
-
// is unaffected. Consumers handle it in an auth/
|
|
172
|
+
case ROLE_GRANT_REVOKE_NOTIFICATION_METHOD:
|
|
173
|
+
// role_grant_revoke is a role-grant-lifecycle event — the offer cache
|
|
174
|
+
// is unaffected. Consumers handle it in an auth/role_grants state.
|
|
175
175
|
return;
|
|
176
176
|
default:
|
|
177
177
|
// unrelated notifications — ignore silently.
|
|
@@ -198,7 +198,7 @@ export class PermitOffersState extends Loadable {
|
|
|
198
198
|
this.#offers = next;
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
|
-
const
|
|
201
|
+
const is_role_grant_offer_like = (value) => !!value &&
|
|
202
202
|
typeof value === 'object' &&
|
|
203
203
|
typeof value.id === 'string' &&
|
|
204
204
|
typeof value.to_account_id === 'string' &&
|
package/dist/ui/ui_format.js
CHANGED
|
@@ -159,9 +159,9 @@ export const format_audit_metadata = (event_type, metadata) => {
|
|
|
159
159
|
return metadata.token_id ? `token: ${truncate_middle(metadata.token_id, 12)}` : '';
|
|
160
160
|
case 'token_revoke_all':
|
|
161
161
|
return metadata.count != null ? `${metadata.count} tokens` : '';
|
|
162
|
-
case '
|
|
162
|
+
case 'role_grant_create':
|
|
163
163
|
return metadata.role ? `role: ${metadata.role}` : '';
|
|
164
|
-
case '
|
|
164
|
+
case 'role_grant_revoke':
|
|
165
165
|
return metadata.role ? `role: ${metadata.role}` : '';
|
|
166
166
|
case 'invite_create':
|
|
167
167
|
return [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuzdev/fuz_app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.0",
|
|
4
4
|
"description": "fullstack app library",
|
|
5
5
|
"glyph": "🗝",
|
|
6
6
|
"logo": "logo.svg",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"node": ">=24.14"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@electric-sql/pglite": ">=0.
|
|
25
|
+
"@electric-sql/pglite": ">=0.4",
|
|
26
26
|
"@fuzdev/blake3_wasm": ">=0.1.0",
|
|
27
27
|
"@fuzdev/fuz_util": ">=0.53.4",
|
|
28
28
|
"@node-rs/argon2": ">=2",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@electric-sql/pglite": "^0.
|
|
44
|
+
"@electric-sql/pglite": "^0.4.5",
|
|
45
45
|
"@fuzdev/blake3_wasm": "^0.1.0",
|
|
46
46
|
"@fuzdev/fuz_code": "^0.45.1",
|
|
47
47
|
"@fuzdev/fuz_css": "^0.59.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permit_offer_action_specs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/permit_offer_action_specs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAGtB,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,2BAA2B,CAAC;AAMzE,gEAAgE;AAChE,eAAO,MAAM,uBAAuB,EAAG,mBAA4B,CAAC;AACpE,kEAAkE;A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;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBP,CAAC;AAEtC,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;CAWR,CAAC;AAEtC,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;CAWR,CAAC;AAEtC,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAWL,CAAC;AAEtC,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAWR,CAAC;AAEtC,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;CAaD,CAAC;AAEtC;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,EAAE,KAAK,CAAC,yBAAyB,CAQ1E,CAAC"}
|
|
@@ -1,258 +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 post-authorization
|
|
15
|
-
* auth gate (`check_action_auth_post_authorization`) rejects non-admin
|
|
16
|
-
* callers before the handler runs even though the endpoint hosts non-admin
|
|
17
|
-
* methods alongside.
|
|
18
|
-
*
|
|
19
|
-
* @module
|
|
20
|
-
*/
|
|
21
|
-
import { z } from 'zod';
|
|
22
|
-
import { Uuid } from '@fuzdev/fuz_util/id.js';
|
|
23
|
-
import { ERROR_PERMIT_NOT_FOUND, ERROR_ROLE_NOT_WEB_GRANTABLE } from '../http/error_schemas.js';
|
|
24
|
-
import { RoleName } from './role_schema.js';
|
|
25
|
-
import { PERMIT_OFFER_MESSAGE_LENGTH_MAX, PermitOfferJson } from './permit_offer_schema.js';
|
|
26
|
-
import { ActingActor, PERMIT_REVOKED_REASON_LENGTH_MAX } from './account_schema.js';
|
|
27
|
-
/** Error reason — caller tried to offer themselves a permit. */
|
|
28
|
-
export const ERROR_OFFER_SELF_TARGET = 'offer_self_target';
|
|
29
|
-
/** Error reason — offer is declined, retracted, or superseded. */
|
|
30
|
-
export const ERROR_OFFER_TERMINAL = 'offer_terminal';
|
|
31
|
-
/** Error reason — offer's `expires_at` has passed. */
|
|
32
|
-
export const ERROR_OFFER_EXPIRED = 'offer_expired';
|
|
33
|
-
/** Error reason — offer does not exist or belongs to a different recipient (404-over-403 IDOR mask). */
|
|
34
|
-
export const ERROR_OFFER_NOT_FOUND = 'offer_not_found';
|
|
35
|
-
/** Error reason — the offered role is not `web_grantable` (nobody may offer it via this surface). */
|
|
36
|
-
export const ERROR_OFFER_ROLE_NOT_GRANTABLE = 'offer_role_not_grantable';
|
|
37
|
-
/** Error reason — caller is not authorized to offer this role (default policy: caller lacks the role; consumer `authorize` callback may add further policy). */
|
|
38
|
-
export const ERROR_OFFER_NOT_AUTHORIZED = 'offer_not_authorized';
|
|
39
|
-
/** Error reason — actor-targeted offer was accepted by an actor other than `to_actor_id`. */
|
|
40
|
-
export const ERROR_OFFER_ACTOR_MISMATCH = 'offer_actor_mismatch';
|
|
41
|
-
/** Error reason — `permit_offer_create` was called with a `to_actor_id` that does not belong to `to_account_id`. */
|
|
42
|
-
export const ERROR_OFFER_ACTOR_ACCOUNT_MISMATCH = 'offer_actor_account_mismatch';
|
|
43
|
-
// -- Input/output schemas ---------------------------------------------------
|
|
44
|
-
/**
|
|
45
|
-
* Input for `permit_offer_create`.
|
|
46
|
-
*
|
|
47
|
-
* `to_actor_id` (optional) narrows the offer to a specific actor on the
|
|
48
|
-
* recipient account. When supplied, `permit_offer_accept` will only admit
|
|
49
|
-
* the named actor — wrong-actor accepts reject with
|
|
50
|
-
* `offer_actor_mismatch`. The audit envelope's `target_actor_id` is
|
|
51
|
-
* stamped from this column on the create / supersede / expire / retract
|
|
52
|
-
* events. Omit (or pass null) for the account-grain default — any actor
|
|
53
|
-
* on `to_account_id` may accept.
|
|
54
|
-
*/
|
|
55
|
-
export const PermitOfferCreateInput = z.strictObject({
|
|
56
|
-
to_account_id: Uuid.meta({ description: 'Account id of the recipient.' }),
|
|
57
|
-
to_actor_id: Uuid.nullish().meta({
|
|
58
|
-
description: 'Optional actor-grain target on the recipient account. When set, only this actor may accept and the audit envelope carries it on offer-shape events. Must belong to `to_account_id`.',
|
|
59
|
-
}),
|
|
60
|
-
role: RoleName.meta({ description: 'Role being offered.' }),
|
|
61
|
-
scope_id: Uuid.nullish().meta({
|
|
62
|
-
description: 'Scope id for resource-scoped grants (e.g. classroom id). `null` for global.',
|
|
63
|
-
}),
|
|
64
|
-
message: z
|
|
65
|
-
.string()
|
|
66
|
-
.max(PERMIT_OFFER_MESSAGE_LENGTH_MAX)
|
|
67
|
-
.nullish()
|
|
68
|
-
.meta({ description: 'Optional free-form note from the grantor.' }),
|
|
69
|
-
acting: ActingActor,
|
|
70
|
-
});
|
|
71
|
-
/** Input for `permit_offer_accept`. */
|
|
72
|
-
export const PermitOfferAcceptInput = z.strictObject({
|
|
73
|
-
offer_id: Uuid.meta({ description: 'The offer to accept.' }),
|
|
74
|
-
acting: ActingActor,
|
|
75
|
-
});
|
|
76
|
-
/** Input for `permit_offer_decline`. */
|
|
77
|
-
export const PermitOfferDeclineInput = z.strictObject({
|
|
78
|
-
offer_id: Uuid.meta({ description: 'The offer to decline.' }),
|
|
79
|
-
reason: z
|
|
80
|
-
.string()
|
|
81
|
-
.max(PERMIT_OFFER_MESSAGE_LENGTH_MAX)
|
|
82
|
-
.nullish()
|
|
83
|
-
.meta({ description: 'Optional free-form reason given on decline.' }),
|
|
84
|
-
acting: ActingActor,
|
|
85
|
-
});
|
|
86
|
-
/** Input for `permit_offer_retract`. */
|
|
87
|
-
export const PermitOfferRetractInput = z.strictObject({
|
|
88
|
-
offer_id: Uuid.meta({ description: 'The offer to retract.' }),
|
|
89
|
-
acting: ActingActor,
|
|
90
|
-
});
|
|
91
|
-
/** Input for `permit_offer_list`. `account_id` is admin-only (inspect another account's inbox). */
|
|
92
|
-
export const PermitOfferListInput = z.strictObject({
|
|
93
|
-
account_id: Uuid.nullish().meta({
|
|
94
|
-
description: 'Admin-only — list offers for another account. Defaults to the caller.',
|
|
95
|
-
}),
|
|
96
|
-
acting: ActingActor,
|
|
97
|
-
});
|
|
98
|
-
/**
|
|
99
|
-
* Input for `permit_revoke`. Admin-only mutation that revokes an active
|
|
100
|
-
* permit on a target actor. `actor_id` is the natural key — permits are
|
|
101
|
-
* actor-scoped, and the admin UI reads `row.actor.id` straight from the
|
|
102
|
-
* listing. Deriving `actor_id` from `account_id` would collapse under
|
|
103
|
-
* multi-actor accounts.
|
|
104
|
-
*/
|
|
105
|
-
export const PermitRevokeInput = z.strictObject({
|
|
106
|
-
actor_id: Uuid.meta({ description: 'Actor whose permit to revoke.' }),
|
|
107
|
-
permit_id: Uuid.meta({ description: 'The permit to revoke.' }),
|
|
108
|
-
reason: z.string().max(PERMIT_REVOKED_REASON_LENGTH_MAX).nullish().meta({
|
|
109
|
-
description: 'Optional free-form reason; stamped on `permit.revoked_reason` and surfaced on the revokee WS notification.',
|
|
110
|
-
}),
|
|
111
|
-
acting: ActingActor,
|
|
112
|
-
});
|
|
113
|
-
/**
|
|
114
|
-
* Input for `permit_offer_history`. Returns every offer involving the account
|
|
115
|
-
* in either direction (recipient or grantor), including terminal rows, newest
|
|
116
|
-
* first. `account_id` is admin-only.
|
|
117
|
-
*/
|
|
118
|
-
export const PermitOfferHistoryInput = z.strictObject({
|
|
119
|
-
account_id: Uuid.nullish().meta({
|
|
120
|
-
description: 'Admin-only — history for another account. Defaults to the caller.',
|
|
121
|
-
}),
|
|
122
|
-
limit: z.number().int().min(1).max(500).nullish().meta({
|
|
123
|
-
description: 'Max rows to return (default 100).',
|
|
124
|
-
}),
|
|
125
|
-
offset: z.number().int().min(0).nullish().meta({
|
|
126
|
-
description: 'Pagination offset (default 0).',
|
|
127
|
-
}),
|
|
128
|
-
acting: ActingActor,
|
|
129
|
-
});
|
|
130
|
-
/** Output for `permit_offer_create`. */
|
|
131
|
-
export const PermitOfferCreateOutput = z.strictObject({
|
|
132
|
-
offer: PermitOfferJson,
|
|
133
|
-
});
|
|
134
|
-
/** Output for `permit_offer_accept`. */
|
|
135
|
-
export const PermitOfferAcceptOutput = z.strictObject({
|
|
136
|
-
permit_id: Uuid,
|
|
137
|
-
offer: PermitOfferJson,
|
|
138
|
-
superseded_offer_ids: z.array(Uuid),
|
|
139
|
-
});
|
|
140
|
-
/** Output for `permit_offer_decline` / `permit_offer_retract`. */
|
|
141
|
-
export const PermitOfferOkOutput = z.strictObject({ ok: z.literal(true) });
|
|
142
|
-
/** Output for `permit_offer_list`. */
|
|
143
|
-
export const PermitOfferListOutput = z.strictObject({ offers: z.array(PermitOfferJson) });
|
|
144
|
-
/** Output for `permit_offer_history`. */
|
|
145
|
-
export const PermitOfferHistoryOutput = z.strictObject({ offers: z.array(PermitOfferJson) });
|
|
146
|
-
/** Output for `permit_revoke`. */
|
|
147
|
-
export const PermitRevokeOutput = z.strictObject({
|
|
148
|
-
ok: z.literal(true),
|
|
149
|
-
revoked: z.literal(true),
|
|
150
|
-
});
|
|
151
|
-
// -- Action specs -----------------------------------------------------------
|
|
152
|
-
export const permit_offer_create_action_spec = {
|
|
153
|
-
method: 'permit_offer_create',
|
|
154
|
-
kind: 'request_response',
|
|
155
|
-
initiator: 'frontend',
|
|
156
|
-
auth: 'authenticated',
|
|
157
|
-
side_effects: true,
|
|
158
|
-
input: PermitOfferCreateInput,
|
|
159
|
-
output: PermitOfferCreateOutput,
|
|
160
|
-
async: true,
|
|
161
|
-
description: 'Offer a permit to another account. Grantor must hold the offered role (or pass a consumer authorize callback); role must be web_grantable.',
|
|
162
|
-
error_reasons: [
|
|
163
|
-
ERROR_OFFER_SELF_TARGET,
|
|
164
|
-
ERROR_OFFER_ROLE_NOT_GRANTABLE,
|
|
165
|
-
ERROR_OFFER_NOT_AUTHORIZED,
|
|
166
|
-
ERROR_OFFER_ACTOR_ACCOUNT_MISMATCH,
|
|
167
|
-
],
|
|
168
|
-
};
|
|
169
|
-
export const permit_offer_accept_action_spec = {
|
|
170
|
-
method: 'permit_offer_accept',
|
|
171
|
-
kind: 'request_response',
|
|
172
|
-
initiator: 'frontend',
|
|
173
|
-
auth: 'authenticated',
|
|
174
|
-
side_effects: true,
|
|
175
|
-
input: PermitOfferAcceptInput,
|
|
176
|
-
output: PermitOfferAcceptOutput,
|
|
177
|
-
async: true,
|
|
178
|
-
description: 'Accept an offer. Atomically marks the offer accepted, inserts the permit, and supersedes sibling pending offers for the same (account, role, scope).',
|
|
179
|
-
error_reasons: [
|
|
180
|
-
ERROR_OFFER_NOT_FOUND,
|
|
181
|
-
ERROR_OFFER_TERMINAL,
|
|
182
|
-
ERROR_OFFER_EXPIRED,
|
|
183
|
-
ERROR_OFFER_ACTOR_MISMATCH,
|
|
184
|
-
],
|
|
185
|
-
};
|
|
186
|
-
export const permit_offer_decline_action_spec = {
|
|
187
|
-
method: 'permit_offer_decline',
|
|
188
|
-
kind: 'request_response',
|
|
189
|
-
initiator: 'frontend',
|
|
190
|
-
auth: 'authenticated',
|
|
191
|
-
side_effects: true,
|
|
192
|
-
input: PermitOfferDeclineInput,
|
|
193
|
-
output: PermitOfferOkOutput,
|
|
194
|
-
async: true,
|
|
195
|
-
description: 'Decline an offer. Recipient-only.',
|
|
196
|
-
error_reasons: [ERROR_OFFER_NOT_FOUND, ERROR_OFFER_TERMINAL],
|
|
197
|
-
};
|
|
198
|
-
export const permit_offer_retract_action_spec = {
|
|
199
|
-
method: 'permit_offer_retract',
|
|
200
|
-
kind: 'request_response',
|
|
201
|
-
initiator: 'frontend',
|
|
202
|
-
auth: 'authenticated',
|
|
203
|
-
side_effects: true,
|
|
204
|
-
input: PermitOfferRetractInput,
|
|
205
|
-
output: PermitOfferOkOutput,
|
|
206
|
-
async: true,
|
|
207
|
-
description: 'Retract an offer. Grantor-only, pre-decision.',
|
|
208
|
-
error_reasons: [ERROR_OFFER_NOT_FOUND, ERROR_OFFER_TERMINAL],
|
|
209
|
-
};
|
|
210
|
-
export const permit_offer_list_action_spec = {
|
|
211
|
-
method: 'permit_offer_list',
|
|
212
|
-
kind: 'request_response',
|
|
213
|
-
initiator: 'frontend',
|
|
214
|
-
auth: 'authenticated',
|
|
215
|
-
side_effects: false,
|
|
216
|
-
input: PermitOfferListInput,
|
|
217
|
-
output: PermitOfferListOutput,
|
|
218
|
-
async: true,
|
|
219
|
-
description: 'List pending, non-expired offers for the caller. Admins may pass `account_id` to inspect another account.',
|
|
220
|
-
};
|
|
221
|
-
export const permit_offer_history_action_spec = {
|
|
222
|
-
method: 'permit_offer_history',
|
|
223
|
-
kind: 'request_response',
|
|
224
|
-
initiator: 'frontend',
|
|
225
|
-
auth: 'authenticated',
|
|
226
|
-
side_effects: false,
|
|
227
|
-
input: PermitOfferHistoryInput,
|
|
228
|
-
output: PermitOfferHistoryOutput,
|
|
229
|
-
async: true,
|
|
230
|
-
description: 'List every offer involving the caller (either direction), including terminal rows, newest first. Admins may pass `account_id` to inspect another account.',
|
|
231
|
-
};
|
|
232
|
-
export const permit_revoke_action_spec = {
|
|
233
|
-
method: 'permit_revoke',
|
|
234
|
-
kind: 'request_response',
|
|
235
|
-
initiator: 'frontend',
|
|
236
|
-
auth: { role: 'admin' },
|
|
237
|
-
side_effects: true,
|
|
238
|
-
input: PermitRevokeInput,
|
|
239
|
-
output: PermitRevokeOutput,
|
|
240
|
-
async: true,
|
|
241
|
-
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.',
|
|
242
|
-
error_reasons: [ERROR_PERMIT_NOT_FOUND, ERROR_ROLE_NOT_WEB_GRANTABLE],
|
|
243
|
-
rate_limit: 'account',
|
|
244
|
-
};
|
|
245
|
-
/**
|
|
246
|
-
* All permit-offer action specs — a codegen-ready registry. Consumers spread
|
|
247
|
-
* this into their own action-spec array to include offer lifecycle + revoke
|
|
248
|
-
* methods in a typed client surface.
|
|
249
|
-
*/
|
|
250
|
-
export const all_permit_offer_action_specs = [
|
|
251
|
-
permit_offer_create_action_spec,
|
|
252
|
-
permit_offer_accept_action_spec,
|
|
253
|
-
permit_offer_decline_action_spec,
|
|
254
|
-
permit_offer_retract_action_spec,
|
|
255
|
-
permit_offer_list_action_spec,
|
|
256
|
-
permit_offer_history_action_spec,
|
|
257
|
-
permit_revoke_action_spec,
|
|
258
|
-
];
|
|
@@ -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 { AuditEmitDeps, 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 AuditEmitDeps {
|
|
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,EAGN,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAmC,KAAK,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAoBzF,OAAO,EAIN,KAAK,cAAc,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,WAAW,CAAC;AAC/D,OAAO,EAON,KAAK,kBAAkB,EACvB,MAAM,iCAAiC,CAAC;AAiCzC;;;;;;;;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;AAIF;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC3D,+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,CA4cjB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permit_offer_notifications.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/permit_offer_notifications.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAC,CA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