auth/cell_grant_actions.ts

Cell-grant ACL RPC handlers.

Three request_response actions bound to specs in auth/cell_grant_action_specs.ts:

Grant management is manage-tier only (can_manage_cell = admin / owner). Editor-grant holders may edit a cell's content + relations but cannot manage its grants — delegating the share list would let an editor widen access or mint peer editors and escape the manager's authority.

  • cell_grant_create — admin / owner only. Validates role-shaped principals against the role schema; rejects owner-as-principal. Actor-shaped principals carry a pre-resolved actor_id (callers pick via actor_search). Idempotent — re-granting the same principal updates level via UPSERT.
  • cell_grant_revoke — admin / owner, plus self for actor-shaped grants ("leave shared cell"). Returns still_admitted computed by re-running can_view_cell against the remaining grants.
  • cell_grant_list — admin / owner only. Viewers and editors alike get the IDOR-mask 404 (the share list is the manager's to curate).

All three 404 with cell_not_found on cell-miss / cell-unviewable, and with cell_grant_not_found on grant-miss, mirroring the existence-leak guards in auth/cell_actions.ts.

Audit events cell_grant_create / cell_grant_revoke carry IDs only (no display-name snapshots); see auth/cell_grant_audit_metadata.ts.

view source

Declarations
#

3 declarations

CellGrantActionDeps
#

auth/cell_grant_actions.ts view source

CellGrantActionDeps import type {CellGrantActionDeps} from '@fuzdev/fuz_app/auth/cell_grant_actions.js';

Dependencies for create_cell_grant_actions.

roles is the role schema — read for the role-validity gate on cell_grant_create. The other slots match CellActionDeps so audit-log emit goes through the same fire-and-forget plumbing.

log

Structured logger instance.

type Logger

audit

Bound audit emitter for fire-and-forget audit writes.

type AuditEmitter

roles

type RoleSchemaResult

create_cell_grant_actions
#

to_grant_json
#

auth/cell_grant_actions.ts view source

(row: CellGrantRow): { id: string & $brand<"Uuid">; cell_id: string & $brand<"Uuid">; level: "viewer" | "editor"; actor_id: (string & $brand<"Uuid">) | null; role: string | null; scope_id: (string & $brand<...>) | null; granted_by: (string & $brand<...>) | null; created_at: string; } import {to_grant_json} from '@fuzdev/fuz_app/auth/cell_grant_actions.js';

row

returns

{ id: string & $brand<"Uuid">; cell_id: string & $brand<"Uuid">; level: "viewer" | "editor"; actor_id: (string & $brand<"Uuid">) | null; role: string | null; scope_id: (string & $brand<...>) | null; granted_by: (string & $brand<...>) | null; created_at: string; }

Depends on
#

Imported by
#