Cerbos JavaScript SDK
    Preparing search index...

    Module @cerbos/embedded - v0.14.1

    @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.

    $ 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: "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.

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

    Classes

    AutoUpdatingLoader
    Embedded
    Loader
    LoadError

    Interfaces

    AutoUpdateOptions
    BundleMetadata
    Options

    Type aliases

    DecodedJWTPayload
    DecodeJWTPayload
    Source