UNPKG

@cerbos/grpc

Version:

Client library for interacting with the Cerbos policy decision point service over gRPC from server-side Node.js applications

55 lines (37 loc) 1.32 kB
# @cerbos/grpc [![npm](https://img.shields.io/npm/v/@cerbos/grpc?style=flat-square)](https://www.npmjs.com/package/@cerbos/grpc) Client library for interacting with the Cerbos policy decision point service over gRPC from server-side Node.js applications. ## Prerequisites - Cerbos 0.16+ - Node.js 22+ ## Installation ```console $ npm install @cerbos/grpc ``` ## Example usage ```typescript import { GRPC } from "@cerbos/grpc"; const cerbos = new GRPC("localhost:3593", { tls: false }); 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 `GRPC` class documentation](https://cerbos.github.io/cerbos-sdk-javascript/classes/_cerbos_grpc.GRPC.html). ## CommonJS support This package is ESM-only, but may be `require`d from CommonJS modules in Node.js versions 22.15+ and 24+. ## Further reading - [API reference](https://cerbos.github.io/cerbos-sdk-javascript/modules/_cerbos_grpc.html) - [Cerbos documentation](https://docs.cerbos.dev) ## Get help - [Join the Cerbos community on Slack](https://go.cerbos.io/slack) - [Email us at help@cerbos.dev](mailto:help@cerbos.dev)