@cerbos/embedded
Version:
Client library for interacting with embedded Cerbos policy decision points generated by Cerbos Hub from server-side Node.js and browser-based applications
32 lines • 1.15 kB
JavaScript
import { Client } from "@cerbos/core";
import { Loader } from "./loader.js";
/**
* A client for interacting with an embedded Cerbos policy decision point (PDP).
*
* @remarks
* Embedded PDP bundles are WebAssembly modules downloaded from {@link https://www.cerbos.dev/product-cerbos-hub | Cerbos Hub}.
* Bundle download URLs are available in the "Embedded" section of the "Decision points" page of your Cerbos Hub workspace.
*
* See {@link @cerbos/core!Client | the parent class} for available methods.
*/
export class Embedded extends Client {
/**
* The {@link Loader} used to load the embedded policy decision point bundle.
*/
loader;
constructor(loaderOrSource, options) {
const loader = loaderOrSource instanceof Loader
? loaderOrSource
: new Loader(loaderOrSource, options);
super(loader["~transport"], {
headers: loader["~options"].headers,
userAgent: loader["~userAgent"],
});
this.loader = loader;
}
/** @internal */
get ["~updateSignal"]() {
return this.loader["~active"];
}
}
//# sourceMappingURL=client.js.map