grants
Import
Section titled “Import”import * as api from "@fungi.computer/ear-tag/grants";Exports
Section titled “Exports”| Kind | Export | Description |
|---|---|---|
| class | GrantsDefinitionError | Rejected when a host’s capability vocabulary violates defineGrants’
invariants. |
| type alias | GrantTargets | How a grant’s capability reaches resources. |
| type alias | Grant | One capability bound to the resources it may act on. |
| type alias | Scope | The bounded authority one key carries: 1 to 64 grants. |
| type alias | GrantVocabulary | Zod schemas and grant operations closed over one host’s capability vocabulary. |
| type alias | GrantsDefinition | A host’s capability vocabulary and its optional implied-capability classes. |
| function | defineGrants() | Declares one host’s capability vocabulary and the zod schemas and grant operations closed over it. |
GrantsDefinitionErrorclass
Section titled “GrantsDefinitionError”Rejected when a host’s capability vocabulary violates defineGrants’
invariants.
This error retains neither the rejected definition nor a foreign cause.
Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new GrantsDefinitionError(): GrantsDefinitionError;Creates a fresh bounded definition error.
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Error.constructor;Properties
Section titled “Properties”readonly name: "GrantsDefinitionError" = "GrantsDefinitionError";Stable public error name.
Overrides
Section titled “Overrides”Error.name;GrantTargetstype alias
Section titled “GrantTargets”type GrantTargets = | Readonly<{ kind: "all"; }> | Readonly<{ kind: "selected"; ids: readonly string[]; }>;How a grant’s capability reaches resources.
Granttype alias
Section titled “Grant”type Grant<Capability> = Readonly<{ capability: Capability; targets: GrantTargets;}>;One capability bound to the resources it may act on.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Capability extends string |
string |
Scopetype alias
Section titled “Scope”type Scope<Capability> = Readonly<{ grants: readonly Grant<Capability>[];}>;The bounded authority one key carries: 1 to 64 grants.
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Capability extends string |
string |
GrantVocabularytype alias
Section titled “GrantVocabulary”type GrantVocabulary<Capability> = Readonly<{ capabilityNameSchema: z.ZodType<Capability>; grantSchema: z.ZodType<Grant<Capability>>; scopeSchema: z.ZodType<Scope<Capability>>; canonicalGrants: (grants) => readonly Grant<Capability>[]; grantsAllow: (grants, capability, resourceId?) => boolean; grantsList: (grants, capability) => boolean; isSubset: (child, parent) => boolean;}>;Zod schemas and grant operations closed over one host’s capability vocabulary.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Capability extends string |
GrantsDefinitiontype alias
Section titled “GrantsDefinition”type GrantsDefinition<Capability> = Readonly<{ capabilities: Capability; implies?: Readonly< Partial<Record<Capability[number], readonly Capability[number][]>> >;}>;A host’s capability vocabulary and its optional implied-capability classes.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Capability extends readonly [string, ...string[]] |
defineGrants()function
Section titled “defineGrants()”function defineGrants<Capability>( definition,): GrantVocabulary<Capability[number]>;Declares one host’s capability vocabulary and the zod schemas and grant operations closed over it.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
Capability extends readonly [string, string] |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
definition |
GrantsDefinition<Capability> |
Returns
Section titled “Returns”GrantVocabulary<Capability[number]>
Throws
Section titled “Throws”GrantsDefinitionError When the vocabulary repeats a
capability, or implies names a capability outside it.