The ability names
The target type the abilities receive
ReadonlyabilitiesThe abilities, keyed by ability name. before is not a legal ability name.
ReadonlynameThe policy's name — lowercase kebab-case (^[a-z][a-z0-9-]*$), unique
within one application. It is the policy's identity: every entry point
looks a policy up by this name.
OptionalbeforeRuns before the ability's check, for a signed-in principal only.
Return true to allow, undefined to fall through to the ability's
check, anything else — false, null, a non-boolean — to deny. A throw
or rejection denies.
The signed-in principal
The ability being evaluated
The target, when one was supplied
true, undefined, or a deny
A named authorization policy: a set of abilities over one target type, plus an optional
beforehook that may allow or deny every ability of the policy (an administrator bypass, a suspended-account block).The bare
PolicyDefinition—A = string,T = never— is the type-erased form a registry stores. Two typing choices make every typed policy assignable to it understrictFunctionTypes:beforeis a METHOD signature, which TypeScript checks bivariantly, and the target defaults tonever, so a check written forPostis assignable to a check overnever.Example
Since
0.9.0