Load Cerbos policies from YAML or JSON files.
$ npm install @cerbos/files
import { readDirectory, readPolicy, readSchema } from "@cerbos/files";
const policy = await readPolicy("path/to/policy.yaml");
// => { apiVersion: "api.cerbos.dev/v1", ... }
const schema = await readSchema("_schemas/path/to/schema.json");
// => { id: "path/to/schema.json", definition: "..." }
const { policies, schemas } = await readDirectory("path/to/directory");
// => { policies: [...], schemas: [...] }
For more details, see the package documentation.
This package is ESM-only, but may be required from CommonJS modules in Node.js versions 20.19.5+, 22.15+, and 24+.