Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cerbos/http

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cerbos/http

Client library for interacting with the Cerbos policy decision point over HTTP from browser-based applications

  • 0.9.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.9K
increased by7.91%
Maintainers
2
Weekly downloads
 
Created
Source

@cerbos/http

npm

Client library for interacting with the Cerbos policy decision point over HTTP.

This is primarily intended for use in browsers, and requires fetch to be available globally. If you're targeting old browsers, you'll need to apply a polyfill.

You can use it in server-side Node.js applications, but the gRPC client might be more appropriate.

  • For Node.js up to 17.4, you'll need a polyfill to make fetch happen.
  • From Node.js 17.5, you can instead enable the --experimental-fetch option at the command line or via NODE_OPTIONS.
  • From Node.js 18 onwards fetch is available without any additional configuration.

Prerequisites

  • Cerbos 0.16+
  • Node.js 14+
  • fetch

Installation

$ npm install @cerbos/http

or

$ yarn add @cerbos/http

Example usage

import { HTTP } from "@cerbos/http";

const cerbos = new HTTP("http://localhost:3592");

await cerbos.isAllowed({
  principal: {
    id: "user@example.com",
    roles: ["USER"],
    attributes: { tier: "PREMIUM" },
  },
  resource: {
    kind: "document",
    id: "1",
    attributes: { owner: "user@example.com" },
  },
  action: "view",
}); // => true

For more details, see the HTTP class documentation.

Further reading

Get help

FAQs

Package last updated on 15 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc