wb.security
WorkbookSecurity
8 methods
addPolicy
→ Promise<PolicyId>addPolicy(policy: Omit<AccessPolicy, 'id'>): Promise<PolicyId>;| Parameter | Type | Required |
|---|---|---|
| policy | Omit<AccessPolicy, 'id'> | required |
Add a new access policy. Rust enforces capability attenuation: the caller's effective workbook level must be >= the granted level. @returns The assigned PolicyId
removePolicy
→ Promise<void>removePolicy(id: PolicyId): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| id | PolicyId | required |
Remove a policy by ID. Idempotent at the store layer.
updatePolicy
→ Promise<void>updatePolicy(id: PolicyId, updates: Partial<Omit<AccessPolicy, 'id'>>): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| id | PolicyId | required |
| updates | Partial<Omit<AccessPolicy, 'id'>> | required |
Update fields on an existing policy. Attenuation re-runs when `level` is patched.
getPolicies
→ Promise<AccessPolicy[]>getPolicies(): Promise<AccessPolicy[]>;Get all policies currently on the document, in stable id-sorted order.
getEffectiveAccess
→ Promise<AccessLevel>getEffectiveAccess(principal: AccessPrincipal, target: AccessTarget): Promise<AccessLevel>;| Parameter | Type | Required |
|---|---|---|
| principal | AccessPrincipal | required |
| target | AccessTarget | required |
Get the effective access level for a principal at a target.
explainAccess
→ Promise<AccessExplanation>explainAccess(principal: AccessPrincipal, target: AccessTarget): Promise<AccessExplanation>;| Parameter | Type | Required |
|---|---|---|
| principal | AccessPrincipal | required |
| target | AccessTarget | required |
Explain why a principal has a given access level at a target. Returns the winning policy, reason, candidates, and any warnings.
applyTemplate
→ Promise<PolicyId[]>applyTemplate(templateId: string, options: Record<string, unknown>): Promise<PolicyId[]>;| Parameter | Type | Required |
|---|---|---|
| templateId | string | required |
| options | Record<string, unknown> | required |
Apply a named template, generating policies. The `templateId` is the Rust tagged-enum variant name (e.g. `protect_workbook`, `protect_sheet`, `agent_structure`); `options` merges into the wire payload under the same keys the Rust `Template` variant expects. @returns The PolicyIds of the generated policies.
removeTemplate
→ Promise<void>removeTemplate(templateId: string): Promise<void>;| Parameter | Type | Required |
|---|---|---|
| templateId | string | required |
Remove all policies generated by a template.