@cerbos/embedded
TypeScript icon, indicating that this package has built-in type declarations

0.7.2 • Public • Published

@cerbos/embedded

npm

Client library for interacting with embedded Cerbos policy decision points (PDPs) generated by Cerbos Hub from server-side Node.js and browser-based applications.

Prerequisites

Installation

$ npm install @cerbos/embedded

Example usage

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: "user@example.com",
    roles: ["USER"],
    attr: { tier: "PREMIUM" },
  },
  resource: {
    kind: "document",
    id: "1",
    attr: { owner: "user@example.com" },
  },
  action: "view",
}); // => true

For more details, see the Embedded class documentation.

Further reading

Get help

Package Sidebar

Install

npm i @cerbos/embedded

Weekly Downloads

133

Version

0.7.2

License

Apache-2.0

Unpacked Size

854 kB

Total Files

128

Last publish

Collaborators

  • ahaines
  • alexolivier
  • cerbosdev