🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@entropy0/express

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@entropy0/express

Entropy0 Trust Control Plane middleware for Express.js — gate requests through trust evaluation before your server processes them.

latest
Source
npmnpm
Version
0.1.8
Version published
Maintainers
1
Created
Source

@entropy0/express

Entropy0 Trust Control Plane middleware for Express.js.

Evaluates an incoming request's target domain through the Entropy0 /v1/decide endpoint and routes it to the appropriate handler based on the recommended action — before your application logic runs.

Try it live → — scan any domain instantly, no sign-up required. Get a free API key at entropy0.ai/signup — no credit card required.

Install

npm install @entropy0/express

Usage

import express from "express";
import { entropy0Guard } from "@entropy0/express";

const app = express();

app.use(
  entropy0Guard({
    apiKey: process.env.ENTROPY0_API_KEY!,
    policy: "balanced",
  })
);

app.get("/proxy", (req, res) => {
  // Only reached if action is "proceed" or "proceed_with_caution"
  // req.entropy0 contains the full decision if caution was flagged
  res.json({ ok: true });
});

Custom action handlers

app.use(
  "/outbound",
  entropy0Guard({
    apiKey: process.env.ENTROPY0_API_KEY!,
    policy: "strict",

    // Extract target from a query param instead of req.hostname
    getTarget: (req) => {
      const url = req.query.url as string;
      return url ? { type: "url", value: url } : null;
    },

    // Describe the interaction context
    getInteraction: (req) => ({
      kind: "fetch",
      mode: "read_only",
      sensitivity: req.user?.role === "admin" ? "high" : "medium",
    }),

    onProceed:  (_req, _res, next, _result) => next(),
    onCaution:  (req, res, next, result)    => { req.entropy0 = result; next(); },
    onSandbox:  (_req, res) => res.status(403).json({ blocked: true, reason: "sandbox" }),
    onEscalate: (_req, res) => res.status(403).json({ blocked: true, reason: "review_required" }),
    onDeny:     (_req, res) => res.status(403).json({ blocked: true, reason: "deny" }),

    // Fail open on API errors (default) — swap for fail closed if needed
    onError: (_req, _res, next, err) => {
      console.error("Entropy0 check failed:", err);
      next();
    },

    timeoutMs: 3000,
  })
);
ActionDefault behaviorMeaning
proceednext()Normal interaction is safe
proceed_with_cautionnext() + attaches req.entropy0Continue with reduced trust assumptions
sandbox403Interact only in an isolated environment
escalate_to_human403Pause automation and request human review
deny403Do not proceed under this policy

All handlers are overridable. Override onSandbox or onEscalate to queue for review instead of blocking.

TypeScript

Full type exports — DecisionResult, TargetDescriptor, InteractionDescriptor, Entropy0Options.

req.entropy0 is automatically typed via Express namespace augmentation.

Requirements

  • Node.js 18+
  • Express 4+

Keywords

express

FAQs

Package last updated on 22 May 2026

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