Function: permissionsFor()
permissionsFor(
principal,input?):PrincipalPermissions
Defined in: packages/contracts/src/permissions/generate.ts:86
Derives one principal's permissions from the table.
- It calls exactly the
requestsubjects that list a participant it hosts, never a wildcard, and only when the serving module is hosted elsewhere: an edge between two modules of one deployable is carried in process and is absent from the broker file. - It serves
request.*.<module>.>for each module it hosts that serves a row. The serve grant is built from the module token, never from the principal's name, which differs (credentialhostsidentity). - It publishes
event.<tenant>.<module>.<aggregate>.<verb>.v<n>for each event whose publishing module it hosts. - It subscribes to an event's key only when a participant it hosts is listed in the
row's
subscribedBy, which is core NATS and best effort. A durable reader gets no subscribe grant: it pulls through its JetStream consumer, onto its own inbox. - It sends exactly the commands that list a participant it hosts, each by its full key.
An agent's principal subscribes to
agent.<instanceId>.admin.>for its own instance and answers there; it is granted nothing else but its inbox. - Each principal receives its replies and acknowledgements on its own inbox,
_INBOX.<principal>.>(see inboxPrefix), and on no one else's. - JetStream is split in two (see
streamGrants): the host of STREAM_DECLARER creates and updates each stream and creates its consumers; the host of a consumer's module reads the configuration, pulls and acknowledges. - A standing grant adds nothing: it is an authority inside a module, not a subject.
Parameters
principal
string
A principal in the input.
input?
PermissionInput = ESTATE
Defaults to the real estate. Call verifyEstate first.
Returns
The grants, sorted so output is stable.