Client library for interacting with embedded Cerbos policy decision points (PDPs) generated by Cerbos Hub from server-side Node.js and browser-based applications.
- Node.js 18+
- A Cerbos Hub account
$ npm install @cerbos/embedded
URLs to download embedded PDP bundles are available from the "Embedded" section of the "Decision points" page of your Cerbos Hub workspace.
import { AutoUpdatingLoader, Embedded } from "@cerbos/embedded";
const cerbos = new Embedded(
new AutoUpdatingLoader(
"https://lite.cerbos.cloud/bundle?workspace=...&label=...",
),
);
await cerbos.isAllowed({
principal: {
id: "[email protected]",
roles: ["USER"],
attr: { tier: "PREMIUM" },
},
resource: {
kind: "document",
id: "1",
attr: { owner: "[email protected]" },
},
action: "view",
}); // => true
For more details, see the Embedded
class documentation.