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

0.6.3 • 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 "Decision points" section of your Cerbos Hub workspace.

import { Embedded } from "@cerbos/embedded";

const cerbos = new Embedded(
  fetch("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

Readme

Keywords

none

Package Sidebar

Install

npm i @cerbos/embedded

Weekly Downloads

94

Version

0.6.3

License

Apache-2.0

Unpacked Size

800 kB

Total Files

123

Last publish

Collaborators

  • ahaines
  • alexolivier