@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
|
@@ -44,13 +44,12 @@
|
|
|
44
44
|
* transaction, a failure row on the pool). `audit.notify` (SSE/WS broadcast)
|
|
45
45
|
* fires post-commit in both paths.
|
|
46
46
|
*
|
|
47
|
-
* WS notifications
|
|
48
|
-
* `notification_sender`
|
|
47
|
+
* WS notifications go through the handler context's sender
|
|
48
|
+
* (`ctx.notification_sender`), queued post-commit (`queue_offer_notification`,
|
|
49
|
+
* `queue_supersede_notifications`): offer lifecycle transitions notify the
|
|
49
50
|
* counterparty, `role_grant_revoke` notifies the revokee (`role_grant_revoked`)
|
|
50
|
-
* plus each superseded
|
|
51
|
-
*
|
|
52
|
-
* against its spec's schema before it is sent, a mismatch logged
|
|
53
|
-
* (`create_validated_notification_sender`). `role_grant_revoke` of a global
|
|
51
|
+
* plus both parties of each superseded pending offer, and an accept each
|
|
52
|
+
* superseded sibling's grantor. `role_grant_revoke` of a global
|
|
54
53
|
* grant also closes the revokee's connections gated on the role through
|
|
55
54
|
* `deps.connection_closer`, after the commit.
|
|
56
55
|
*
|
|
@@ -63,13 +62,44 @@ import { queue_connection_close } from '../actions/connection_closer.js';
|
|
|
63
62
|
import { builtin_role_specs, is_builtin_role, ROLE_ADMIN, ROLE_KEEPER, role_has_grant_path } from './role_schema.js';
|
|
64
63
|
import { GRANT_PATH_ADMIN } from './grant_path_schema.js';
|
|
65
64
|
import { ROLE_GRANT_OFFER_DEFAULT_TTL_MS, to_role_grant_offer_json } from './role_grant_offer_schema.js';
|
|
66
|
-
import { query_role_grant_offer_create, query_role_grant_offer_decline, query_role_grant_offer_retract, query_role_grant_offer_list, query_role_grant_offer_history_for_account, query_accept_offer, RoleGrantOfferActorAccountMismatchError, RoleGrantOfferActorMismatchError, RoleGrantOfferGrantorNotActiveError, RoleGrantOfferRecipientNotActiveError, RoleGrantOfferAlreadyTerminalError, RoleGrantOfferBuiltinRefusedError, RoleGrantOfferExpiredError, RoleGrantOfferNotFoundError, RoleGrantOfferSelfTargetError,
|
|
67
|
-
import { query_account_has_active_global_role, query_account_has_global_role,
|
|
68
|
-
import {
|
|
65
|
+
import { query_role_grant_offer_create, query_role_grant_offer_decline, query_role_grant_offer_retract, query_role_grant_offer_list, query_role_grant_offer_history_for_account, query_accept_offer, RoleGrantOfferActorAccountMismatchError, RoleGrantOfferActorMismatchError, RoleGrantOfferGrantorNotActiveError, RoleGrantOfferRecipientNotActiveError, RoleGrantOfferAlreadyTerminalError, RoleGrantOfferBuiltinRefusedError, RoleGrantOfferExpiredError, RoleGrantOfferNotFoundError, RoleGrantOfferSelfTargetError, query_revoke_role_grant } from './role_grant_offer_queries.js';
|
|
66
|
+
import { query_account_has_active_global_role, query_account_has_global_role, query_count_active_accounts_with_global_role_locked, query_create_role_grant, query_role_grant_find_active_role_for_actor } from './role_grant_queries.js';
|
|
67
|
+
import { query_active_actors_by_account } from './account_queries.js';
|
|
69
68
|
import { has_scoped_role } from './request_context.js';
|
|
70
|
-
import { build_role_grant_offer_accepted_notification, build_role_grant_offer_declined_notification, build_role_grant_offer_received_notification, build_role_grant_offer_retracted_notification,
|
|
69
|
+
import { build_role_grant_offer_accepted_notification, build_role_grant_offer_declined_notification, build_role_grant_offer_received_notification, build_role_grant_offer_retracted_notification, build_role_grant_revoked_notification, queue_offer_notification, queue_supersede_notifications } from './role_grant_offer_notifications.js';
|
|
71
70
|
import { ERROR_AUTHENTICATION_REQUIRED, ERROR_INSUFFICIENT_PERMISSIONS, ERROR_ROLE_GRANT_NOT_FOUND, ERROR_ROLE_NOT_WEB_GRANTABLE } from '../http/error_schemas.js';
|
|
72
71
|
import { ERROR_CANNOT_REVOKE_KEEPER_ADMIN, ERROR_CANNOT_REVOKE_LAST_ADMIN, ERROR_ROLE_GRANT_BUILTIN_SCOPED, ERROR_ROLE_GRANT_OFFER_ACTOR_ACCOUNT_MISMATCH, ERROR_ROLE_GRANT_OFFER_ACTOR_MISMATCH, ERROR_ROLE_GRANT_OFFER_EXPIRED, ERROR_ROLE_GRANT_OFFER_NOT_AUTHORIZED, ERROR_ROLE_GRANT_OFFER_NOT_FOUND, ERROR_ROLE_GRANT_OFFER_ROLE_NOT_GRANTABLE, ERROR_ROLE_GRANT_OFFER_SELF_TARGET, ERROR_ROLE_GRANT_OFFER_TERMINAL, role_grant_offer_create_action_spec, role_grant_offer_accept_action_spec, role_grant_offer_decline_action_spec, role_grant_offer_retract_action_spec, role_grant_offer_list_action_spec, role_grant_offer_history_action_spec, role_grant_revoke_action_spec, role_grant_assign_action_spec } from './role_grant_offer_action_specs.js';
|
|
72
|
+
/**
|
|
73
|
+
* Emit one `role_grant_offer_supersede` audit row per offer a cascade ended —
|
|
74
|
+
* the revokes (`role_grant_revoke` and the self-service disable, both
|
|
75
|
+
* `'role_grant_revoked'` with the revoked grant as `cause_id`) and account
|
|
76
|
+
* removal (`'account_deleted'`, the removed account). The acting pair is the
|
|
77
|
+
* caller's; the target pair is the offer's recipient (`to_account_id`, and
|
|
78
|
+
* `to_actor_id` when the offer named an actor). Twin of the Rust
|
|
79
|
+
* `emit_supersede_audits`.
|
|
80
|
+
*
|
|
81
|
+
* @param ctx - the handler context; the rows are the caller's
|
|
82
|
+
* @param audit - the emitter
|
|
83
|
+
* @param superseded - the offers the cascade ended
|
|
84
|
+
* @param reason - why they were superseded
|
|
85
|
+
* @param cause_id - the row that caused it
|
|
86
|
+
*/
|
|
87
|
+
export const emit_supersede_audits = async (ctx, audit, superseded, reason, cause_id) => {
|
|
88
|
+
for (const offer of superseded) {
|
|
89
|
+
await audit.emit_role_grant_target(ctx, ctx.auth, {
|
|
90
|
+
event_type: 'role_grant_offer_supersede',
|
|
91
|
+
target_account_id: offer.to_account_id,
|
|
92
|
+
target_actor_id: offer.to_actor_id,
|
|
93
|
+
metadata: {
|
|
94
|
+
offer_id: offer.id,
|
|
95
|
+
role: offer.role,
|
|
96
|
+
scope_id: offer.scope_id,
|
|
97
|
+
reason,
|
|
98
|
+
cause_id
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
};
|
|
73
103
|
// -- Helpers ----------------------------------------------------------------
|
|
74
104
|
/**
|
|
75
105
|
* Fan out a batch of pre-written audit rows to the bound emitter's
|
|
@@ -109,17 +139,12 @@ const default_authorize = async (auth, _input, _deps, _ctx) => {
|
|
|
109
139
|
* Create the role-grant-offer RPC actions: the offer-lifecycle methods plus
|
|
110
140
|
* `role_grant_revoke` and the immediate `role_grant_assign`.
|
|
111
141
|
*
|
|
112
|
-
* @param deps - `RevokingActionFactoryDeps
|
|
142
|
+
* @param deps - `RevokingActionFactoryDeps`: `log`, `audit`, and the `connection_closer` a revoked global grant closes the revokee's role-gated connections through. WS notifications go through the handler context's `notification_sender`, not a dep
|
|
113
143
|
* @param options - role registry, default TTL, authorization override
|
|
114
144
|
* @returns the `RpcAction` array to spread into a `create_rpc_endpoint` call
|
|
115
145
|
*/
|
|
116
146
|
export const create_role_grant_offer_actions = (deps, options = {}) => {
|
|
117
147
|
const { log, audit, connection_closer } = deps;
|
|
118
|
-
// under DEV each notification sent is checked against its spec's params
|
|
119
|
-
// schema, a mismatch logged, as DEV output validation does
|
|
120
|
-
const notification_sender = deps.notification_sender
|
|
121
|
-
? create_validated_notification_sender(deps.notification_sender, log)
|
|
122
|
-
: null;
|
|
123
148
|
const role_specs = options.roles?.role_specs ?? builtin_role_specs;
|
|
124
149
|
const default_ttl_ms = options.default_ttl_ms ?? ROLE_GRANT_OFFER_DEFAULT_TTL_MS;
|
|
125
150
|
const authorize = options.authorize ?? default_authorize;
|
|
@@ -299,11 +324,7 @@ export const create_role_grant_offer_actions = (deps, options = {}) => {
|
|
|
299
324
|
}
|
|
300
325
|
});
|
|
301
326
|
const offer_json = to_role_grant_offer_json(offer);
|
|
302
|
-
|
|
303
|
-
emit_after_commit(ctx, () => {
|
|
304
|
-
notification_sender.send_to_account(offer.to_account_id, build_role_grant_offer_received_notification({ offer: offer_json }));
|
|
305
|
-
});
|
|
306
|
-
}
|
|
327
|
+
queue_offer_notification(ctx, offer.to_account_id, build_role_grant_offer_received_notification({ offer: offer_json }));
|
|
307
328
|
return { offer: offer_json };
|
|
308
329
|
};
|
|
309
330
|
const accept_handler = async (input, ctx) => {
|
|
@@ -335,47 +356,36 @@ export const create_role_grant_offer_actions = (deps, options = {}) => {
|
|
|
335
356
|
if (err instanceof RoleGrantOfferBuiltinRefusedError) {
|
|
336
357
|
throw await refuse_builtin_accept(ctx, auth, err);
|
|
337
358
|
}
|
|
359
|
+
// The caller's own account was deleted while the request was in flight:
|
|
360
|
+
// refused as the dead credential it now is, as offer-create refuses a
|
|
361
|
+
// grantor deleted in flight, with no audit row from an account that is gone.
|
|
362
|
+
if (err instanceof RoleGrantOfferRecipientNotActiveError) {
|
|
363
|
+
throw jsonrpc_errors.unauthenticated('unauthenticated', {
|
|
364
|
+
reason: ERROR_AUTHENTICATION_REQUIRED
|
|
365
|
+
});
|
|
366
|
+
}
|
|
338
367
|
throw err;
|
|
339
368
|
}
|
|
340
|
-
// Look up the grantor's account_id inside the transaction so the
|
|
341
|
-
// post-commit notification has a valid target. One cheap SELECT by
|
|
342
|
-
// PK — the alternative (widening `query_accept_offer` again) would
|
|
343
|
-
// bleed transport concerns into the query layer. A replay
|
|
344
|
-
// (`created: false`) notifies nothing, so it skips the lookup.
|
|
345
|
-
const grantor_actor = notification_sender && result.created
|
|
346
|
-
? await query_actor_by_id(ctx, result.offer.from_actor_id)
|
|
347
|
-
: null;
|
|
348
|
-
const grantor_account_id = grantor_actor?.account_id ?? null;
|
|
349
369
|
const offer_json = to_role_grant_offer_json(result.offer);
|
|
350
|
-
const supersede_payloads = result.superseded_offers.map((sib) => ({
|
|
351
|
-
offer: to_role_grant_offer_json(sib),
|
|
352
|
-
from_account_id: sib.from_account_id
|
|
353
|
-
}));
|
|
354
370
|
// Audit events are written in-transaction by query_accept_offer; wire
|
|
355
371
|
// them through `audit.notify` post-commit so SSE/WS broadcasts fire.
|
|
356
|
-
// WS notifications
|
|
357
|
-
// grantor sees "accepted" and each superseded grantor sees
|
|
358
|
-
// only once the accept has durably committed — and never if
|
|
359
|
-
// back (the dispatch site discards `post_commit_effects` on
|
|
360
|
-
// A replay (or a race loser) wrote nothing — the accept that
|
|
361
|
-
// grant already audited it and notified the grantor — so it
|
|
362
|
-
// nothing; repeating the notification would let any replay send
|
|
363
|
-
// without bound.
|
|
372
|
+
// The WS notifications are queued behind them on the same post-commit
|
|
373
|
+
// queue, so the grantor sees "accepted" and each superseded grantor sees
|
|
374
|
+
// "supersede" only once the accept has durably committed — and never if
|
|
375
|
+
// it rolls back (the dispatch site discards `post_commit_effects` on
|
|
376
|
+
// rollback). A replay (or a race loser) wrote nothing — the accept that
|
|
377
|
+
// minted the grant already audited it and notified the grantor — so it
|
|
378
|
+
// queues nothing; repeating the notification would let any replay send
|
|
379
|
+
// them without bound. Only the siblings' grantors hear the supersede: their
|
|
380
|
+
// recipient is the caller, whose answer lists `superseded_offer_ids`.
|
|
364
381
|
if (result.created) {
|
|
365
382
|
emit_after_commit(ctx, () => {
|
|
366
383
|
fan_out_audit_events(result.audit_events, audit);
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
notification_sender.send_to_account(sib.from_account_id, build_role_grant_offer_supersede_notification({
|
|
373
|
-
offer: sib.offer,
|
|
374
|
-
reason: 'sibling_accepted',
|
|
375
|
-
cause_id: result.offer.id
|
|
376
|
-
}));
|
|
377
|
-
}
|
|
378
|
-
}
|
|
384
|
+
});
|
|
385
|
+
queue_offer_notification(ctx, result.from_account_id, build_role_grant_offer_accepted_notification({ offer: offer_json }));
|
|
386
|
+
queue_supersede_notifications(ctx, result.superseded_offers, 'sibling_accepted', {
|
|
387
|
+
grantor: { kind: 'id', id: result.offer.id },
|
|
388
|
+
recipient: null
|
|
379
389
|
});
|
|
380
390
|
}
|
|
381
391
|
return {
|
|
@@ -416,15 +426,10 @@ export const create_role_grant_offer_actions = (deps, options = {}) => {
|
|
|
416
426
|
}
|
|
417
427
|
});
|
|
418
428
|
const offer_json = to_role_grant_offer_json(declined);
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
// in the RETURNING above.
|
|
424
|
-
emit_after_commit(ctx, () => {
|
|
425
|
-
notification_sender.send_to_account(declined.from_account_id, build_role_grant_offer_declined_notification({ offer: offer_json }));
|
|
426
|
-
});
|
|
427
|
-
}
|
|
429
|
+
// Grantor's account_id rides on `declined.from_account_id` from the
|
|
430
|
+
// decline RETURNING — no second SELECT needed. The decline reason rides
|
|
431
|
+
// along on `offer.decline_reason` — the DB set it in the RETURNING above.
|
|
432
|
+
queue_offer_notification(ctx, declined.from_account_id, build_role_grant_offer_declined_notification({ offer: offer_json }));
|
|
428
433
|
// the terminal offer, as accept answers its own
|
|
429
434
|
return { offer: offer_json };
|
|
430
435
|
};
|
|
@@ -458,11 +463,7 @@ export const create_role_grant_offer_actions = (deps, options = {}) => {
|
|
|
458
463
|
}
|
|
459
464
|
});
|
|
460
465
|
const offer_json = to_role_grant_offer_json(retracted);
|
|
461
|
-
|
|
462
|
-
emit_after_commit(ctx, () => {
|
|
463
|
-
notification_sender.send_to_account(retracted.to_account_id, build_role_grant_offer_retracted_notification({ offer: offer_json }));
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
+
queue_offer_notification(ctx, retracted.to_account_id, build_role_grant_offer_retracted_notification({ offer: offer_json }));
|
|
466
467
|
// the terminal offer, as accept answers its own
|
|
467
468
|
return { offer: offer_json };
|
|
468
469
|
};
|
|
@@ -535,24 +536,23 @@ export const create_role_grant_offer_actions = (deps, options = {}) => {
|
|
|
535
536
|
});
|
|
536
537
|
}
|
|
537
538
|
if ((await query_account_has_active_global_role(ctx, target_account_id, ROLE_ADMIN)) &&
|
|
538
|
-
(await
|
|
539
|
+
(await query_count_active_accounts_with_global_role_locked(ctx, ROLE_ADMIN, input.role_grant_id)) === 0) {
|
|
539
540
|
await emit_revoke_failure();
|
|
540
541
|
throw jsonrpc_errors.forbidden("cannot revoke the last admin's admin grant", {
|
|
541
542
|
reason: ERROR_CANNOT_REVOKE_LAST_ADMIN
|
|
542
543
|
});
|
|
543
544
|
}
|
|
544
545
|
}
|
|
546
|
+
// The revoke ends the revokee's incoming siblings and every offer its
|
|
547
|
+
// actor made, taking the revokee's account row and then those offers
|
|
548
|
+
// before the grant (`query_revoke_role_grant` has the order). After the
|
|
549
|
+
// guard, which holds an admin revokee's row already.
|
|
545
550
|
const result = await query_revoke_role_grant(ctx, input.role_grant_id, input.actor_id, auth.actor.id, input.reason ?? null);
|
|
546
551
|
if (!result) {
|
|
547
552
|
// Raced with another revoker or the role_grant was revoked between
|
|
548
553
|
// the IDOR check and the UPDATE.
|
|
549
554
|
throw jsonrpc_errors.not_found('role_grant', { reason: ERROR_ROLE_GRANT_NOT_FOUND });
|
|
550
555
|
}
|
|
551
|
-
// The revokee's own pending offers end with the grant: an offer records
|
|
552
|
-
// no authority, so one made under this grant would still confer on
|
|
553
|
-
// accept. Every outgoing offer of the actor goes, superseded like the
|
|
554
|
-
// revokee's incoming siblings (same reason, same cause, same fan-out).
|
|
555
|
-
result.superseded_offers.push(...(await query_role_grant_offer_supersede_outgoing(ctx, [input.actor_id])));
|
|
556
556
|
// Close the revokee's connections gated on the role once the revoke has
|
|
557
557
|
// committed — queued, so never before the commit or on rollback, and not
|
|
558
558
|
// riding on the audit row's announcement below (the revocation guard
|
|
@@ -576,48 +576,23 @@ export const create_role_grant_offer_actions = (deps, options = {}) => {
|
|
|
576
576
|
reason: input.reason ?? undefined
|
|
577
577
|
}
|
|
578
578
|
});
|
|
579
|
-
// Supersede cascade —
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}
|
|
597
|
-
if (notification_sender) {
|
|
598
|
-
const superseded = result.superseded_offers.map((o) => ({
|
|
599
|
-
offer: to_role_grant_offer_json(o),
|
|
600
|
-
from_account_id: o.from_account_id
|
|
601
|
-
}));
|
|
602
|
-
const cause_id = result.id;
|
|
603
|
-
const reason = input.reason ?? null;
|
|
604
|
-
emit_after_commit(ctx, () => {
|
|
605
|
-
notification_sender.send_to_account(target_account_id, build_role_grant_revoked_notification({
|
|
606
|
-
role_grant_id: result.id,
|
|
607
|
-
role: result.role,
|
|
608
|
-
scope_kind: result.scope_kind,
|
|
609
|
-
scope_id: result.scope_id,
|
|
610
|
-
reason
|
|
611
|
-
}));
|
|
612
|
-
for (const sib of superseded) {
|
|
613
|
-
notification_sender.send_to_account(sib.from_account_id, build_role_grant_offer_supersede_notification({
|
|
614
|
-
offer: sib.offer,
|
|
615
|
-
reason: 'role_grant_revoked',
|
|
616
|
-
cause_id
|
|
617
|
-
}));
|
|
618
|
-
}
|
|
619
|
-
});
|
|
620
|
-
}
|
|
579
|
+
// Supersede cascade — one row per offer the revoke ended.
|
|
580
|
+
await emit_supersede_audits(ctx, audit, result.superseded_offers, 'role_grant_revoked', result.id);
|
|
581
|
+
queue_offer_notification(ctx, target_account_id, build_role_grant_revoked_notification({
|
|
582
|
+
role_grant_id: result.id,
|
|
583
|
+
role: result.role,
|
|
584
|
+
scope_kind: result.scope_kind,
|
|
585
|
+
scope_id: result.scope_id,
|
|
586
|
+
reason: input.reason ?? null
|
|
587
|
+
}));
|
|
588
|
+
// Both parties of each superseded offer: the revokee is the recipient of
|
|
589
|
+
// its incoming siblings and the grantor of its outgoing offers, and the
|
|
590
|
+
// other party of each is told as well.
|
|
591
|
+
const revoked_grant = { kind: 'id', id: result.id };
|
|
592
|
+
queue_supersede_notifications(ctx, result.superseded_offers, 'role_grant_revoked', {
|
|
593
|
+
grantor: revoked_grant,
|
|
594
|
+
recipient: revoked_grant
|
|
595
|
+
});
|
|
621
596
|
return { ok: true, revoked: true };
|
|
622
597
|
};
|
|
623
598
|
// The immediate admin-only conferral path — the consent-free sibling of
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Role grant offer WebSocket notification specs, builders, and the
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Role grant offer WebSocket notification specs, builders, and the helpers
|
|
3
|
+
* the handlers queue them with (`queue_offer_notification`,
|
|
4
|
+
* `queue_supersede_notifications`).
|
|
5
5
|
*
|
|
6
6
|
* These `RemoteNotificationActionSpec`s cover the consentful-role-grants
|
|
7
7
|
* lifecycle events the server pushes to affected accounts:
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* - `role_grant_offer_retracted` → recipient's sockets when a grantor retracts
|
|
11
11
|
* - `role_grant_offer_accepted` → grantor's sockets when the recipient accepts
|
|
12
12
|
* - `role_grant_offer_declined` → grantor's sockets when the recipient declines
|
|
13
|
-
* - `role_grant_offer_supersede` →
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* - `role_grant_offer_supersede` → each live party to a pending offer a
|
|
14
|
+
* cascade ended — a sibling accept, a revoke, an account removal — but the
|
|
15
|
+
* one the cascade's own answer or socket close already covers
|
|
16
16
|
* - `role_grant_revoked` → revokee's sockets when one of their active
|
|
17
17
|
* role_grants is revoked by the `role_grant_revoke` action (companion to the
|
|
18
18
|
* `role_grant_revoke` audit event)
|
|
@@ -29,10 +29,9 @@
|
|
|
29
29
|
* action set of an RPC list that carries the role_grant_offer actions, so the
|
|
30
30
|
* surface lists them on the WS endpoint as `remote_notification` methods. An
|
|
31
31
|
* inbound frame for one is still answered `method_not_found`, as no handler is
|
|
32
|
-
* registered. Under DEV,
|
|
33
|
-
* `
|
|
34
|
-
* against its spec's `input
|
|
35
|
-
* production sends unchecked.
|
|
32
|
+
* registered. Under DEV, `perform_action` hands every action handler a sender
|
|
33
|
+
* wrapped in `create_validated_notification_sender`, so each params object
|
|
34
|
+
* sent is checked against its spec's `input`; production sends unchecked.
|
|
36
35
|
*
|
|
37
36
|
* @module
|
|
38
37
|
*/
|
|
@@ -42,23 +41,9 @@ import { type Uuid } from '../primitive_schemas.js';
|
|
|
42
41
|
import type { Action } from '../actions/action_types.js';
|
|
43
42
|
import type { EventSpec } from '../realtime/sse.js';
|
|
44
43
|
import type { JsonrpcNotification } from '../http/jsonrpc.js';
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
* `ConnectionRegistry` satisfies this interface — its
|
|
50
|
-
* `send_to_account(account_id, message)` signature accepts the broader
|
|
51
|
-
* `JsonrpcMessageFromServerToClient` type, which is contravariantly
|
|
52
|
-
* compatible with `JsonrpcNotification` here. The interface stays local so
|
|
53
|
-
* handlers don't couple to the concrete registry, and tests can inject a
|
|
54
|
-
* capturing stub with no WS machinery.
|
|
55
|
-
*
|
|
56
|
-
* Returns the number of sockets the notification was sent to — callers
|
|
57
|
-
* typically ignore it (used by telemetry / tests).
|
|
58
|
-
*/
|
|
59
|
-
export interface NotificationSender {
|
|
60
|
-
send_to_account: (account_id: Uuid, message: JsonrpcNotification) => number;
|
|
61
|
-
}
|
|
44
|
+
import { type EmitAfterCommitContext } from '../http/pending_effects.js';
|
|
45
|
+
import type { NotificationSender } from '../actions/notification_sender.js';
|
|
46
|
+
import { type SupersededOffer } from './role_grant_offer_schema.js';
|
|
62
47
|
export declare const ROLE_GRANT_OFFER_RECEIVED_NOTIFICATION_METHOD = "role_grant_offer_received";
|
|
63
48
|
export declare const ROLE_GRANT_OFFER_RETRACTED_NOTIFICATION_METHOD = "role_grant_offer_retracted";
|
|
64
49
|
export declare const ROLE_GRANT_OFFER_ACCEPTED_NOTIFICATION_METHOD = "role_grant_offer_accepted";
|
|
@@ -158,14 +143,17 @@ export declare const RoleGrantOfferDeclinedParams: import("@fuzdev/fuz_schema/sc
|
|
|
158
143
|
}>;
|
|
159
144
|
export type RoleGrantOfferDeclinedParams = Infer<typeof RoleGrantOfferDeclinedParams>;
|
|
160
145
|
/**
|
|
161
|
-
* Params for `role_grant_offer_supersede
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* the
|
|
166
|
-
* the
|
|
167
|
-
*
|
|
168
|
-
*
|
|
146
|
+
* Params for `role_grant_offer_supersede`, sent to a party of a pending offer
|
|
147
|
+
* a cascade ended: a sibling accept (`reason: 'sibling_accepted'`), a revoke of
|
|
148
|
+
* the recipient's grant or of any grant of the grantor's actor
|
|
149
|
+
* (`reason: 'role_grant_revoked'`), or the removal of either party's account
|
|
150
|
+
* (`reason: 'account_deleted'`). `cause_id` points at the accepted offer, the
|
|
151
|
+
* revoked role_grant, or the removed account respectively — the `cause_id` of
|
|
152
|
+
* the offer's `role_grant_offer_supersede` audit row — except on a recipient's
|
|
153
|
+
* frame of its grantor's account removal, where it is the offer's grantor
|
|
154
|
+
* actor (`from_actor_id`), an id the recipient already holds. The audit
|
|
155
|
+
* metadata's reason set is wider: a consumer's scope teardown audits
|
|
156
|
+
* `scope_destroyed`, which no notification carries.
|
|
169
157
|
*/
|
|
170
158
|
export declare const RoleGrantOfferSupersedeParams: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
171
159
|
offer: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
|
|
@@ -186,7 +174,7 @@ export declare const RoleGrantOfferSupersedeParams: import("@fuzdev/fuz_schema/s
|
|
|
186
174
|
superseded_at: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>>;
|
|
187
175
|
resulting_role_grant_id: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").BrandSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>, "Uuid">>;
|
|
188
176
|
}>;
|
|
189
|
-
reason: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["sibling_accepted", "role_grant_revoked", "
|
|
177
|
+
reason: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["sibling_accepted", "role_grant_revoked", "account_deleted"]>;
|
|
190
178
|
cause_id: import("@fuzdev/fuz_schema/schema.ts").BrandSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>, "Uuid">;
|
|
191
179
|
}>;
|
|
192
180
|
export type RoleGrantOfferSupersedeParams = Infer<typeof RoleGrantOfferSupersedeParams>;
|
|
@@ -351,7 +339,7 @@ export declare const role_grant_offer_supersede_notification_spec: {
|
|
|
351
339
|
superseded_at: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>>;
|
|
352
340
|
resulting_role_grant_id: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").BrandSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>, "Uuid">>;
|
|
353
341
|
}>;
|
|
354
|
-
reason: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["sibling_accepted", "role_grant_revoked", "
|
|
342
|
+
reason: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["sibling_accepted", "role_grant_revoked", "account_deleted"]>;
|
|
355
343
|
cause_id: import("@fuzdev/fuz_schema/schema.ts").BrandSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>, "Uuid">;
|
|
356
344
|
}>;
|
|
357
345
|
output: import("@fuzdev/fuz_schema/schema.ts").VoidSchema;
|
|
@@ -398,7 +386,8 @@ export declare const role_grant_offer_notification_specs: Array<EventSpec>;
|
|
|
398
386
|
* a mismatch logged as an error the way DEV output validation logs one; the
|
|
399
387
|
* notification is sent either way, unchanged. A method that is no
|
|
400
388
|
* role_grant_offer notification passes unchecked. In production the sender is
|
|
401
|
-
* returned as it is.
|
|
389
|
+
* returned as it is. `perform_action` wraps the sender of every handler
|
|
390
|
+
* context, so every send site is checked whichever factory it sits in.
|
|
402
391
|
*
|
|
403
392
|
* @param sender - the sender to wrap
|
|
404
393
|
* @param log - where a mismatch is logged
|
|
@@ -411,4 +400,64 @@ export declare const build_role_grant_offer_accepted_notification: (params: Role
|
|
|
411
400
|
export declare const build_role_grant_offer_declined_notification: (params: RoleGrantOfferDeclinedParams) => JsonrpcNotification;
|
|
412
401
|
export declare const build_role_grant_offer_supersede_notification: (params: RoleGrantOfferSupersedeParams) => JsonrpcNotification;
|
|
413
402
|
export declare const build_role_grant_revoked_notification: (params: RoleGrantRevokedParams) => JsonrpcNotification;
|
|
403
|
+
/**
|
|
404
|
+
* What the queue helpers read of a handler context; `ActionContext` satisfies
|
|
405
|
+
* it.
|
|
406
|
+
*/
|
|
407
|
+
export interface NotificationQueueContext extends EmitAfterCommitContext {
|
|
408
|
+
notification_sender: NotificationSender;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Queue `message` to every socket bound to `account_id`, sent once the
|
|
412
|
+
* handler's transaction commits and dropped when it rolls back, so a
|
|
413
|
+
* notification never announces state that never landed.
|
|
414
|
+
*
|
|
415
|
+
* Twin of the Rust spine's `queue_offer_notification`.
|
|
416
|
+
*
|
|
417
|
+
* @param ctx - the handler context, whose sender the send goes through
|
|
418
|
+
* @param account_id - the recipient account
|
|
419
|
+
* @param message - the notification, from one of the builders above
|
|
420
|
+
*/
|
|
421
|
+
export declare const queue_offer_notification: (ctx: NotificationQueueContext, account_id: Uuid, message: JsonrpcNotification) => void;
|
|
422
|
+
/**
|
|
423
|
+
* The `cause_id` a party of a superseded offer is sent: an id the cascade
|
|
424
|
+
* names (`id` — the accepted offer, the revoked role_grant, the removed
|
|
425
|
+
* account), or the offer's own grantor actor (`from_actor`, an id its
|
|
426
|
+
* recipient already holds). Twin of the Rust `SupersedeCause`.
|
|
427
|
+
*/
|
|
428
|
+
export type SupersedeCause = {
|
|
429
|
+
kind: 'id';
|
|
430
|
+
id: Uuid;
|
|
431
|
+
} | {
|
|
432
|
+
kind: 'from_actor';
|
|
433
|
+
};
|
|
434
|
+
/**
|
|
435
|
+
* Which parties of a superseded offer a cascade tells, and the `cause_id`
|
|
436
|
+
* each is sent; `null` leaves that party out. A party the cascade's own answer
|
|
437
|
+
* covers (the accepting recipient) or whose account it removes (its
|
|
438
|
+
* connections close) is left out by the call site, which knows which side
|
|
439
|
+
* that party is on. A recipient told of its grantor's account removal is sent
|
|
440
|
+
* the grantor's actor, never the account id, which no recipient sees
|
|
441
|
+
* otherwise. Twin of the Rust `SupersedeAudience`.
|
|
442
|
+
*/
|
|
443
|
+
export interface SupersedeAudience {
|
|
444
|
+
grantor: SupersedeCause | null;
|
|
445
|
+
recipient: SupersedeCause | null;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Queue a `role_grant_offer_supersede` notification to the parties of each
|
|
449
|
+
* superseded offer `audience` names, each with its own `cause_id` — the
|
|
450
|
+
* grantor (`from_account_id`, off the cascade's `RETURNING`) and the recipient
|
|
451
|
+
* (`to_account_id`). Sent in the cascade's row order, which is the order of
|
|
452
|
+
* its audit rows, each offer's parties together and its grantor ahead of its
|
|
453
|
+
* recipient — one fixed order, so both spines send a cascade's frames alike.
|
|
454
|
+
*
|
|
455
|
+
* Twin of the Rust spine's `queue_supersede_notifications`.
|
|
456
|
+
*
|
|
457
|
+
* @param ctx - the handler context, whose sender the sends go through
|
|
458
|
+
* @param superseded - the offers the cascade superseded
|
|
459
|
+
* @param reason - why they were superseded
|
|
460
|
+
* @param audience - which party of each offer is told, and the `cause_id` it is sent
|
|
461
|
+
*/
|
|
462
|
+
export declare const queue_supersede_notifications: (ctx: NotificationQueueContext, superseded: ReadonlyArray<SupersededOffer>, reason: RoleGrantOfferSupersedeParams["reason"], audience: SupersedeAudience) => void;
|
|
414
463
|
//# sourceMappingURL=role_grant_offer_notifications.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role_grant_offer_notifications.d.ts","sourceRoot":"","sources":["../../src/lib/auth/role_grant_offer_notifications.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"role_grant_offer_notifications.d.ts","sourceRoot":"","sources":["../../src/lib/auth/role_grant_offer_notifications.ts"],"names":[],"mappings":"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"}
|