Arcjet helps developers protect their apps in just a few lines of
code. Implement rate limiting, bot protection, email verification, and defense
against common attacks.
This is the Arcjet TypeScript and JavaScript SDK core.
Generally, you'll want to use the Arcjet SDK for your specific framework, such
as @arcjet/next for Next.js. However, this package
can be used to interact with Arcjet if your framework does not have an
integration.
Installation
npm install -S arcjet
Example
import http from"http";
import arcjet, { createRemoteClient } from"arcjet";
import { baseUrl } from"@arcjet/env";
import { createConnectTransport } from"@connectrpc/connect-node";
const aj = arcjet({
// Get your site key from https://app.arcjet.com// and set it as an environment variable rather than hard coding.// See: https://www.npmjs.com/package/dotenvkey: process.env.ARCJET_KEY,
rules: [],
client: createRemoteClient({
transport: createConnectTransport({
baseUrl: baseUrl(process.env),
httpVersion: "2",
}),
}),
});
const server = http.createServer(asyncfunction (
req: http.IncomingMessage,
res: http.ServerResponse,
) {
// Any sort of additional context that might want to be included for the// execution of `protect()`. This is mostly only useful for writing adapters.const ctx = {};
// Construct an object with Arcjet request detailsconst path = newURL(req.url || "", `http://${req.headers.host}`);
const details = {
ip: req.socket.remoteAddress,
method: req.method,
host: req.headers.host,
path: path.pathname,
};
const decision = await aj.protect(ctx, details);
console.log(decision);
if (decision.isDenied()) {
res.writeHead(403, { "Content-Type": "application/json" });
res.end(JSON.stringify({ error: "Forbidden" }));
} else {
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify({ data: "Hello World!" }));
}
});
server.listen(8000);
bump @typescript-eslint/eslint-plugin from 7.16.1 to 7.17.0 (#1164) (06344e7)
bump @typescript-eslint/parser from 7.16.1 to 7.17.0 (#1165) (40adc5b)
bump eslint-config-turbo from 2.0.6 to 2.0.9 (#1159) (1e7a59f)
dev: bump @rollup/wasm-node from 4.18.1 to 4.19.0 (#1160) (7062ca0)
dev: bump typescript from 5.5.3 to 5.5.4 (#1166) (644e3a6)
example: bump @clerk/nextjs from 5.2.5 to 5.2.6 in /examples/nextjs-14-permit in the dependencies group (#1173) (2dd29a7)
example: bump hono from 4.4.13 to 4.5.1 in /examples/nodejs-hono-rl in the dependencies group across 1 directory (#1158) (797d8b8)
example: bump postcss from 8.4.39 to 8.4.40 in /examples/nextjs-14-app-dir-validate-email in the dependencies group (#1177) (926f84e)
example: bump postcss from 8.4.39 to 8.4.40 in /examples/nextjs-14-clerk-rl in the dependencies group across 1 directory (#1180) (47b6e7d)
example: bump tailwindcss from 3.4.4 to 3.4.6 in /examples/nextjs-14-app-dir-validate-email in the dependencies group across 1 directory (#1139) (ee1938b)
example: bump tailwindcss from 3.4.5 to 3.4.6 in /examples/nextjs-14-app-dir-rl in the dependencies group (#1152) (282448a)
example: bump tailwindcss from 3.4.5 to 3.4.6 in /examples/nextjs-14-decorate in the dependencies group (#1148) (1149de9)
example: bump tailwindcss from 3.4.5 to 3.4.6 in /examples/nextjs-14-ip-details in the dependencies group (#1147) (c77aa6b)
example: bump tailwindcss from 3.4.5 to 3.4.6 in /examples/nextjs-14-nextauth-4 in the dependencies group (#1145) (a97525b)
example: bump tailwindcss from 3.4.5 to 3.4.6 in /examples/nextjs-14-pages-wrap in the dependencies group (#1151) (d9291c6)
example: bump the dependencies group across 1 directory with 2 updates (#1171) (e2bfd35)
example: bump the dependencies group across 1 directory with 2 updates (#1179) (1240621)
example: bump the dependencies group across 1 directory with 3 updates (#1163) (213a7c8)
example: bump the dependencies group across 1 directory with 3 updates (#1178) (9bc5f1e)
example: bump the dependencies group across 1 directory with 3 updates (#1181) (f01ec2c)
example: bump the dependencies group across 1 directory with 5 updates (#1167) (f3c8ca7)
example: bump the dependencies group across 1 directory with 6 updates (#1169) (a02a74c)
🧹 Miscellaneous Chores
examples: Add Next.js app with Permit.io for dynamic Arcjet rules (#1067) (6939878)
FAQs
Arcjet TypeScript and JavaScript SDK core
The npm package arcjet receives a total of 974 weekly downloads. As such, arcjet popularity was classified as not popular.
We found that arcjet demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 2 open source maintainers collaborating on the project.
Package last updated on 24 Jul 2024
Did you know?
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.
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
By Kush Pandya, Philipp Burckhardt, Kirill Boychenko, Orlando Barrera - Oct 31, 2024