Cerbos JavaScript SDK
    Preparing search index...

    Loads an embedded policy decision point bundle from a given source.

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    Constructors

    • Load an embedded policy decision point (PDP) bundle from a given source.

      Parameters

      • source: Source

        WebAssembly binary code of an embedded PDP bundle, or a URL or HTTP response from which to stream it.

      • options: Options = {}

        Additional settings.

      Returns Loader

      Bundle download URLs are available in the "Embedded" section of the "Decision points" page of your Cerbos Hub workspace.

      The bundle will be loaded in the background when the loader is created. If loading fails, then the first request from the client using the loader will throw an error. To detect failure to load the bundle before making any requests, provide an Options.onError callback or await the Loader.active method.

      Fetch an embedded PDP bundle via HTTP in a supported browser or Node.js:

      const loader = new Loader("https://lite.cerbos.cloud/bundle?workspace=...&label=...");
      

      Read an embedded PDP bundle from disk in Node.js:

      import { readFile } from "fs/promises";

      const loader = new Loader(readFile("policies.wasm"));

      Load an embedded PDP bundle from a precompiled WebAssembly module (requires a bundler):

      import bundle from "bundle.wasm";

      const loader = new Loader(bundle);

    Methods