JSPM

@cerbos/embedded-client

0.3.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 224
  • Score
    100M100P100Q92283F
  • License Apache-2.0

Client library for interacting with embedded Cerbos policy decision points from server-side Node.js and browser-based applications

Package Exports

  • @cerbos/embedded-client

Readme

@cerbos/embedded-client

npm

Client library for interacting with embedded Cerbos policy decision points (PDPs) from server-side Node.js and browser-based applications. Policy bundles are loaded from Cerbos Hub and executed by a WebAssembly module (@cerbos/embedded-server).

Prerequisites

Installation

$ npm install @cerbos/embedded-client

Example usage

With Vite:

import { fileURLToPath } from "node:url";
import { Embedded } from "@cerbos/embedded-client";
import wasm from "@cerbos/embedded-server/server.wasm?init";

const cerbos = new Embedded({
  policies: { ruleId: "B5LU9EVYN1MD" },
  wasm,
});

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.

CommonJS support

This package is ESM-only, but may be required from CommonJS modules in Node.js versions 20.19.5+, 22.15+, and 24+.

Further reading

Get help