Skip to main content
These examples describe the current Bijection CLI and SDK source. Use builds from the same source commit for these APIs. The public CLI and npm SDK are published independently and may lag this reference.
The example decides access with labels, roles and grants alone, and declares no guards. Labels decide who may know a fact. A role decides what its holder may do. A guard would add a refusal of acts the roles would otherwise allow, such as “only the account’s owner renames it”.

Label the data and declare roles

bijection/roles.ts
Labels and roles take no names: the tree places this module at roles, so they are roles.crm, roles.reader, roles.writer and roles.admin. Every customer function runs under: crm. A function’s allow names the roles that may enter it: customers.associate and customers.rename take allow: [writer], and customers.directory takes allow: [reader, writer]. The continuation customers.renamed has no allow, so it is internal: only the delivery of its task reaches it. The receiver clears crm, so a task may carry customer data to the CRM.

Manage members

bijection/team.ts
Placed at team, the library contributes team.invite, team.revoke, team.me and team.list. Its grants, directory and invitations sit at its roster, crm, which every role it manages clears: a person’s grant never sits at public. Declare the administrator in the app’s founders and choose the founder when creating the installation.
After the founder signs in, use team.invite with the recipient’s principal ID (the person:… ID ctx.frame.as.id answers for them) and role. bijection.lock beside bijection/app.ts lists every exposed path with its allow and under, the grave acts it can perform and the guards on it. Run bijection check --write-lock, then review and commit it before deploying. Grants covers roles and grants in full. Continue to perform an operation.