Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@arcjet/inspect

Package Overview
Dependencies
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arcjet/inspect

Arcjet utilities for inspecting decisions made an the SDK

latest
Source
npmnpm
Version
1.0.0-beta.13
Version published
Maintainers
3
Created
Source
Arcjet Logo

@arcjet/inspect

npm badge

Arcjet utilities for inspecting decisions made by an SDK.

What is this?

Arcjet attaches lots of metadata to every decision. This package exists to more easily interact with Arcjet decisions for common patterns.

When should I use this?

You can access metadata on decisions directly but you can use this package for common patterns.

Install

This package is ESM only. Install with npm in Node.js:

npm install @arcjet/inspect

Example

import http from "node:http";
import arcjet, { detectBot } from "@arcjet/next";
import { isMissingUserAgent } from "@arcjet/inspect";

// Get your Arcjet key at <https://app.arcjet.com>.
// Set it as an environment variable instead of hard coding it.
const arcjetKey = process.env.ARCJET_KEY;

if (!arcjetKey) {
  throw new Error("Cannot find `ARCJET_KEY` environment variable");
}

const aj = arcjet({
  key: arcjetKey,
  rules: [
    // `detectBot` lets you manage automated clients and bots.
    detectBot({ allow: [], mode: "LIVE" }),
  ],
});

const server = http.createServer(async function (
  request: http.IncomingMessage,
  response: http.ServerResponse,
) {
  const decision = await aj.protect(request);

  if (decision.isDenied()) {
    response.writeHead(403, { "Content-Type": "application/json" });
    response.end(JSON.stringify({ message: "Forbidden" }));
    return;
  }

  if (decision.results.some(isMissingUserAgent)) {
    response.writeHead(403, { "Content-Type": "application/json" });
    response.end(JSON.stringify({ message: "You are a bot!" }));
    return;
  }

  response.writeHead(200, { "Content-Type": "application/json" });
  response.end(JSON.stringify({ message: "Hello world" }));
});

server.listen(8000);

License

Apache License, Version 2.0 © Arcjet Labs, Inc.

Keywords

arcjet

FAQs

Package last updated on 07 Oct 2025

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