@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
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Role grant offer database queries.
|
|
3
|
+
*
|
|
4
|
+
* Covers the offer side of the consentful-role-grants flow: create (with
|
|
5
|
+
* re-offer upsert), decline, retract, list, find-pending, sweep-expired,
|
|
6
|
+
* and the atomic `query_accept_offer` that bridges offer → role_grant.
|
|
7
|
+
*
|
|
8
|
+
* IDOR guards are expressed in each helper's signature — decline/accept
|
|
9
|
+
* require the recipient's `to_account_id`, retract requires the grantor's
|
|
10
|
+
* `from_actor_id`.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import type { Uuid } from '@fuzdev/fuz_util/id.js';
|
|
15
|
+
import type { QueryDeps } from '../db/query_deps.js';
|
|
16
|
+
import type { RoleGrant } from './account_schema.js';
|
|
17
|
+
import { type CreateRoleGrantOfferInput, type RoleGrantOffer, type SupersededOffer } from './role_grant_offer_schema.js';
|
|
18
|
+
import type { AuditLogEvent } from './audit_log_schema.js';
|
|
19
|
+
/**
|
|
20
|
+
* Error thrown by offer-lifecycle queries when the offer is in a non-pending
|
|
21
|
+
* state (accepted / declined / retracted / superseded) and therefore not
|
|
22
|
+
* actionable. Distinct from `RoleGrantOfferExpiredError` — expiry has its own
|
|
23
|
+
* user-facing story ("ask the grantor to re-send") so it travels separately.
|
|
24
|
+
*/
|
|
25
|
+
export declare class RoleGrantOfferAlreadyTerminalError extends Error {
|
|
26
|
+
constructor(offer_id: string);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Error thrown when an offer's `expires_at` has passed. The accept path
|
|
30
|
+
* enforces this independently of the sweep — a stale offer past its expiry
|
|
31
|
+
* must not be accepted, even in the race window between expiry and the
|
|
32
|
+
* sweep stamping the audit event.
|
|
33
|
+
*/
|
|
34
|
+
export declare class RoleGrantOfferExpiredError extends Error {
|
|
35
|
+
constructor(offer_id: string);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Error thrown when an offer cannot be located for the caller. Covers both
|
|
39
|
+
* "offer does not exist" and "offer belongs to a different recipient"
|
|
40
|
+
* (IDOR guard) — the standard 404-over-403 pattern that avoids disclosing
|
|
41
|
+
* whether an offer id exists.
|
|
42
|
+
*/
|
|
43
|
+
export declare class RoleGrantOfferNotFoundError extends Error {
|
|
44
|
+
constructor(offer_id: string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Error thrown when a grantor attempts to offer a role_grant to their own account.
|
|
48
|
+
*
|
|
49
|
+
* Enforced via a single SELECT on the grantor's `actor.account_id` (rather
|
|
50
|
+
* than via a CHECK constraint or a denormalized column). Resolving from the
|
|
51
|
+
* grantor side keeps the check multi-actor-correct: under multi-actor the
|
|
52
|
+
* recipient account may host many actors, but the grantor → account binding
|
|
53
|
+
* remains 1:1 by definition of `actor`.
|
|
54
|
+
*/
|
|
55
|
+
export declare class RoleGrantOfferSelfTargetError extends Error {
|
|
56
|
+
constructor();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Error thrown when an actor-targeted offer is being accepted by an actor
|
|
60
|
+
* other than `offer.to_actor_id`. Distinct from `RoleGrantOfferNotFoundError`
|
|
61
|
+
* (the IDOR mask): once an offer has been resolved to the recipient account,
|
|
62
|
+
* a wrong-actor accept on a same-account actor is a contract violation, not
|
|
63
|
+
* a privacy boundary — surface a specific error so the client UI can
|
|
64
|
+
* distinguish "this offer isn't for you" from "no such offer".
|
|
65
|
+
*/
|
|
66
|
+
export declare class RoleGrantOfferActorMismatchError extends Error {
|
|
67
|
+
constructor(offer_id: string);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Error thrown when `query_role_grant_offer_create` is called with a
|
|
71
|
+
* `to_actor_id` that does not exist or does not belong to `to_account_id`.
|
|
72
|
+
* Surfaces the actor↔account binding mismatch at the boundary instead of
|
|
73
|
+
* letting the FK silently disagree with the recipient field.
|
|
74
|
+
*/
|
|
75
|
+
export declare class RoleGrantOfferActorAccountMismatchError extends Error {
|
|
76
|
+
constructor();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create a new role_grant offer, or refresh an existing pending offer for the
|
|
80
|
+
* same `(to_account_id, role, scope_id, from_actor_id)` tuple.
|
|
81
|
+
*
|
|
82
|
+
* Re-offer semantics: a second call by the same grantor with the same
|
|
83
|
+
* `(to_account, role, scope)` while pending upserts the existing row,
|
|
84
|
+
* refreshing `message` and `expires_at` (and `to_actor_id` — supplying
|
|
85
|
+
* a different `to_actor_id` on re-offer narrows the existing row to the
|
|
86
|
+
* named actor; supplying null widens it back to account-grain). A
|
|
87
|
+
* different grantor offering the same `(to_account, role, scope)` creates
|
|
88
|
+
* a distinct row — multiple pending grantors coexist. After a terminal
|
|
89
|
+
* state, a re-offer is a fresh INSERT.
|
|
90
|
+
*
|
|
91
|
+
* Self-offer rejection: throws `RoleGrantOfferSelfTargetError` if the offering
|
|
92
|
+
* actor belongs to the recipient account.
|
|
93
|
+
*
|
|
94
|
+
* Actor-targeted offers: when `to_actor_id` is supplied,
|
|
95
|
+
* `query_accept_offer` rejects any actor other than the named one. Closes
|
|
96
|
+
* the audit hole where offer-shape events would otherwise leave
|
|
97
|
+
* `target_actor_id` null even when the recipient binding is known at
|
|
98
|
+
* offer time. The actor↔account binding is verified here in one SELECT.
|
|
99
|
+
*
|
|
100
|
+
* @mutates `role_grant_offer` table - inserts a new offer or upserts the matching pending row
|
|
101
|
+
* @throws RoleGrantOfferSelfTargetError if the offering actor belongs to `to_account_id`
|
|
102
|
+
* @throws RoleGrantOfferActorAccountMismatchError if `to_actor_id` is set but does not belong to `to_account_id`
|
|
103
|
+
*/
|
|
104
|
+
export declare const query_role_grant_offer_create: (deps: QueryDeps, input: CreateRoleGrantOfferInput) => Promise<RoleGrantOffer>;
|
|
105
|
+
/** Result of `query_role_grant_offer_decline` — the declined offer plus the grantor's `account_id`. */
|
|
106
|
+
export interface DeclinedOffer extends RoleGrantOffer {
|
|
107
|
+
/**
|
|
108
|
+
* Grantor's `account_id`, resolved via a join on `actor` so the audit
|
|
109
|
+
* envelope's `target_account_id` (decline is *to* the grantor) and the
|
|
110
|
+
* post-commit notification target are both addressable without a
|
|
111
|
+
* second round-trip.
|
|
112
|
+
*/
|
|
113
|
+
from_account_id: Uuid;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Mark an offer declined.
|
|
117
|
+
*
|
|
118
|
+
* Guarded by `to_account_id` (IDOR). Returns `null` if the offer does not
|
|
119
|
+
* exist or belongs to a different account. Throws
|
|
120
|
+
* `RoleGrantOfferAlreadyTerminalError` if the offer exists for the caller but
|
|
121
|
+
* is already in a terminal state.
|
|
122
|
+
*
|
|
123
|
+
* Returns the declined offer with the grantor's `from_account_id` joined
|
|
124
|
+
* in via CTE — the decline audit envelope populates **both**
|
|
125
|
+
* `target_actor_id` (the grantor actor) and `target_account_id` (the
|
|
126
|
+
* grantor account), satisfying the "both populated → same account"
|
|
127
|
+
* invariant the audit-log column comments describe.
|
|
128
|
+
*
|
|
129
|
+
* @mutates `role_grant_offer` row - sets `declined_at` and `decline_reason`
|
|
130
|
+
* @throws RoleGrantOfferAlreadyTerminalError if the offer is already accepted, declined, retracted, or superseded
|
|
131
|
+
*/
|
|
132
|
+
export declare const query_role_grant_offer_decline: (deps: QueryDeps, offer_id: string, to_account_id: string, reason: string | null) => Promise<DeclinedOffer | null>;
|
|
133
|
+
/**
|
|
134
|
+
* Mark an offer retracted by the grantor.
|
|
135
|
+
*
|
|
136
|
+
* Guarded by `from_actor_id` (IDOR). Returns `null` if the offer does not
|
|
137
|
+
* exist or was issued by a different actor. Throws
|
|
138
|
+
* `RoleGrantOfferAlreadyTerminalError` if the offer exists for this grantor
|
|
139
|
+
* but is already in a terminal state.
|
|
140
|
+
*
|
|
141
|
+
* @mutates `role_grant_offer` row - sets `retracted_at`
|
|
142
|
+
* @throws RoleGrantOfferAlreadyTerminalError if the offer is already accepted, declined, retracted, or superseded
|
|
143
|
+
*/
|
|
144
|
+
export declare const query_role_grant_offer_retract: (deps: QueryDeps, offer_id: string, from_actor_id: string) => Promise<RoleGrantOffer | null>;
|
|
145
|
+
/**
|
|
146
|
+
* List pending, non-expired offers for an account, soonest expiry first.
|
|
147
|
+
*
|
|
148
|
+
* Expired offers are filtered server-side (`expires_at > NOW()`) so the
|
|
149
|
+
* inbox never surfaces a row that can no longer be accepted. The periodic
|
|
150
|
+
* sweep (`query_role_grant_offer_sweep_expired`) handles audit tombstoning.
|
|
151
|
+
*/
|
|
152
|
+
export declare const query_role_grant_offer_list: (deps: QueryDeps, to_account_id: string) => Promise<Array<RoleGrantOffer>>;
|
|
153
|
+
/**
|
|
154
|
+
* List every offer involving an account (either direction), newest first.
|
|
155
|
+
*
|
|
156
|
+
* Includes terminal offers — used by the grantor-side admin / history view.
|
|
157
|
+
*/
|
|
158
|
+
export declare const query_role_grant_offer_history_for_account: (deps: QueryDeps, account_id: string, limit?: number, offset?: number) => Promise<Array<RoleGrantOffer>>;
|
|
159
|
+
/**
|
|
160
|
+
* Look up a pending offer by id. Returns `null` if the offer is terminal,
|
|
161
|
+
* expired (server-side filter), or missing.
|
|
162
|
+
*/
|
|
163
|
+
export declare const query_role_grant_offer_find_pending: (deps: QueryDeps, offer_id: string) => Promise<RoleGrantOffer | null>;
|
|
164
|
+
/**
|
|
165
|
+
* Return pending offers whose `expires_at` has passed.
|
|
166
|
+
*
|
|
167
|
+
* Callers fire `role_grant_offer_expire` audit events for each row. The schema
|
|
168
|
+
* does not tombstone the row, so callers are responsible for their own
|
|
169
|
+
* idempotency (e.g. check whether a `role_grant_offer_expire` audit event
|
|
170
|
+
* already exists for the offer id).
|
|
171
|
+
*/
|
|
172
|
+
export declare const query_role_grant_offer_sweep_expired: (deps: QueryDeps) => Promise<Array<RoleGrantOffer>>;
|
|
173
|
+
/** Input for `query_accept_offer`. */
|
|
174
|
+
export interface AcceptOfferInput {
|
|
175
|
+
offer_id: Uuid;
|
|
176
|
+
/** Account of the accepting recipient — IDOR guard against another account accepting the offer. */
|
|
177
|
+
to_account_id: Uuid;
|
|
178
|
+
/**
|
|
179
|
+
* Accepting actor — the actor that will hold the resulting role_grant.
|
|
180
|
+
* Must belong to `to_account_id`; the query verifies and throws if not
|
|
181
|
+
* (defense-in-depth — the action handler passes `auth.actor.id` which
|
|
182
|
+
* is session-bound, but the query enforces the invariant for all
|
|
183
|
+
* callers including tests and future direct consumers).
|
|
184
|
+
*
|
|
185
|
+
* Required because under multi-actor an account may host many actors;
|
|
186
|
+
* the resulting role_grant must bind to the actor that actually accepted,
|
|
187
|
+
* not "an" actor on the account picked by query order.
|
|
188
|
+
*/
|
|
189
|
+
actor_id: Uuid;
|
|
190
|
+
/** Optional IP to stamp on the audit events. */
|
|
191
|
+
ip?: string | null;
|
|
192
|
+
}
|
|
193
|
+
/** Result of `query_accept_offer` — the role_grant produced (new or pre-existing on race), plus the (now-accepted) offer. */
|
|
194
|
+
export interface AcceptOfferResult {
|
|
195
|
+
role_grant: RoleGrant;
|
|
196
|
+
offer: RoleGrantOffer;
|
|
197
|
+
/** `true` if this call is the one that accepted the offer (new role_grant inserted); `false` on a race returning the already-created role_grant. */
|
|
198
|
+
created: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Sibling offers superseded by this accept — empty on the race-loser path.
|
|
201
|
+
* Each entry carries its grantor's `from_account_id` so the caller can
|
|
202
|
+
* fan out `role_grant_offer_supersede` notifications without a second
|
|
203
|
+
* round-trip.
|
|
204
|
+
*/
|
|
205
|
+
superseded_offers: Array<SupersededOffer>;
|
|
206
|
+
/** Audit events emitted in-transaction — fed back through `audit.notify` by the caller, which fans out to `audit.on_event_chain`. Includes one `role_grant_offer_supersede` per superseded sibling. */
|
|
207
|
+
audit_events: Array<AuditLogEvent>;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Accept an offer atomically: mark accepted, insert the role_grant, stamp
|
|
211
|
+
* `resulting_role_grant_id`, supersede sibling pending offers for the same
|
|
212
|
+
* `(to_account, role, scope)`, and emit `role_grant_offer_accept` +
|
|
213
|
+
* `role_grant_create` + one `role_grant_offer_supersede` per sibling. Must run
|
|
214
|
+
* inside a transaction — the caller's route spec should declare
|
|
215
|
+
* `transaction: true` (or wrap explicitly).
|
|
216
|
+
*
|
|
217
|
+
* Idempotent on race: if a second concurrent call observes the offer
|
|
218
|
+
* already accepted, returns the existing role_grant rather than creating a
|
|
219
|
+
* duplicate or throwing.
|
|
220
|
+
*
|
|
221
|
+
* Error map:
|
|
222
|
+
* - `RoleGrantOfferNotFoundError` — offer does not exist, or belongs to a
|
|
223
|
+
* different recipient (IDOR guard). The offer row is untouched.
|
|
224
|
+
* - `RoleGrantOfferAlreadyTerminalError` — offer is declined, retracted, or
|
|
225
|
+
* superseded.
|
|
226
|
+
* - `RoleGrantOfferExpiredError` — offer is pending but past `expires_at`.
|
|
227
|
+
*
|
|
228
|
+
* Sibling supersede is what closes the "accept a pre-revoke sibling offer
|
|
229
|
+
* to bypass a revoke" path: once A is accepted, B/C/... can no longer be
|
|
230
|
+
* accepted even if the resulting role_grant is later revoked.
|
|
231
|
+
*
|
|
232
|
+
* @mutates `role_grant_offer` row - stamps `accepted_at` and `resulting_role_grant_id`
|
|
233
|
+
* @mutates `role_grant` table - inserts the resulting role_grant (idempotent on race)
|
|
234
|
+
* @mutates `role_grant_offer` siblings - stamps `superseded_at` on every other pending offer for the tuple
|
|
235
|
+
* @mutates `audit_log` table - emits `role_grant_offer_accept` + `role_grant_create` + one `role_grant_offer_supersede` per sibling
|
|
236
|
+
* @throws RoleGrantOfferNotFoundError if the offer is missing or belongs to another recipient
|
|
237
|
+
* @throws RoleGrantOfferAlreadyTerminalError if the offer is declined, retracted, or superseded
|
|
238
|
+
* @throws RoleGrantOfferExpiredError if the offer is pending but past `expires_at`
|
|
239
|
+
* @throws Error if the accepting `actor_id` does not belong to `to_account_id`, or invariant assertions fail
|
|
240
|
+
*/
|
|
241
|
+
export declare const query_accept_offer: (deps: QueryDeps, input: AcceptOfferInput) => Promise<AcceptOfferResult>;
|
|
242
|
+
//# sourceMappingURL=role_grant_offer_queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"role_grant_offer_queries.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/auth/role_grant_offer_queries.ts"],"names":[],"mappings":"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"}
|