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);
detect common free/disposable email providers locally (#1096) (115d016), closes #1095
📦 Dependencies
Bump @typescript-eslint/eslint-plugin from 7.14.1 to 7.15.0 (#1063) (d4a1cfe)
Bump @typescript-eslint/eslint-plugin from 7.15.0 to 7.16.0 (#1091) (6bbcbe6)
bump @typescript-eslint/eslint-plugin from 7.16.0 to 7.16.1 (#1135) (6f4495a)
Bump @typescript-eslint/parser from 7.14.1 to 7.15.0 (#1064) (b6e2b0f)
Bump @typescript-eslint/parser from 7.15.0 to 7.16.0 (#1090) (c31957f)
bump @typescript-eslint/parser from 7.16.0 to 7.16.1 (#1132) (3feb40a)
Bump typeid-js from 0.7.0 to 1.0.0 (#1079) (fa276c5)
dev: Bump @edge-runtime/jest-environment from 2.3.10 to 3.0.0 (#1087) (1e6eb00)
dev: bump @edge-runtime/jest-environment from 3.0.0 to 3.0.1 (#1123) (9064240)
dev: Bump @rollup/wasm-node from 4.18.0 to 4.18.1 (#1092) (ffc298a)
dev: Bump bun-types from 1.1.17 to 1.1.18 (#1080) (6bb3483)
dev: bump bun-types from 1.1.18 to 1.1.20 (#1118) (dbf3826)
dev: Bump typescript from 5.5.2 to 5.5.3 (#1065) (ef05395)
example: Bump @clerk/nextjs from 5.1.6 to 5.2.2 in /examples/nextjs-14-clerk-rl in the dependencies group across 1 directory (#1082) (7ac1236)
example: Bump @clerk/nextjs from 5.1.6 to 5.2.2 in /examples/nextjs-14-clerk-shield in the dependencies group across 1 directory (#1081) (9b89f9b)
example: bump @clerk/nextjs from 5.2.2 to 5.2.3 in /examples/nextjs-14-clerk-rl in the dependencies group (#1119) (5fe9ef0)
example: bump @clerk/nextjs from 5.2.2 to 5.2.3 in /examples/nextjs-14-clerk-shield in the dependencies group (#1121) (baf55e0)
example: Bump hono from 4.4.11 to 4.4.12 in /examples/nodejs-hono-rl in the dependencies group (#1085) (3782001)
example: Bump hono from 4.4.12 to 4.4.13 in /examples/nodejs-hono-rl in the dependencies group (#1112) (49f8721)
example: Bump lucide-react from 0.399.0 to 0.400.0 in /examples/nextjs-14-authjs-5 in the dependencies group (#1066) (b44dd6a)
example: bump lucide-react from 0.407.0 to 0.408.0 in /examples/nextjs-14-authjs-5 in the dependencies group (#1116) (84bd181)
example: bump tailwindcss from 3.4.4 to 3.4.5 in /examples/nextjs-14-app-dir-rl in the dependencies group (#1124) (c73e955)
example: bump tailwindcss from 3.4.4 to 3.4.5 in /examples/nextjs-14-authjs-5 in the dependencies group (#1129) (74adca7)
example: bump tailwindcss from 3.4.4 to 3.4.5 in /examples/nextjs-14-clerk-rl in the dependencies group (#1125) (8aa2f53)
example: bump tailwindcss from 3.4.4 to 3.4.5 in /examples/nextjs-14-clerk-shield in the dependencies group (#1130) (6f76186)
example: bump tailwindcss from 3.4.4 to 3.4.5 in /examples/nextjs-14-decorate in the dependencies group (#1126) (b2d9a81)
example: bump tailwindcss from 3.4.4 to 3.4.5 in /examples/nextjs-14-ip-details in the dependencies group (#1127) (0251e74)
example: bump tailwindcss from 3.4.4 to 3.4.5 in /examples/nextjs-14-nextauth-4 in the dependencies group (#1128) (b7f0028)
example: bump tailwindcss from 3.4.4 to 3.4.5 in /examples/nextjs-14-pages-wrap in the dependencies group (#1131) (af3f8d6)
example: Bump the dependencies group across 1 directory with 2 updates (#1068) (bc86928)
example: Bump the dependencies group across 1 directory with 2 updates (#1071) (75df78a)
example: bump the dependencies group across 1 directory with 2 updates (#1117) (306d4f1)
example: Bump the dependencies group across 1 directory with 3 updates (#1072) (937b184)
example: Bump the dependencies group across 1 directory with 3 updates (#1108) (3714941)
example: Bump the dependencies group across 1 directory with 4 updates (#1106) (caaea7a)
example: Bump the dependencies group across 1 directory with 6 updates (#1109) (c877b39)
example: Bump the dependencies group in /examples/nextjs-14-app-dir-rl with 2 updates (#1104) (8cbde05)
example: Bump the dependencies group in /examples/nextjs-14-app-dir-validate-email with 2 updates (#1107) (298a70b)
example: Bump the dependencies group in /examples/nextjs-14-clerk-rl with 2 updates (#1102) (f1e7a4c)
example: Bump the dependencies group in /examples/nextjs-14-clerk-shield with 2 updates (#1101) (10184f9)
example: Bump the dependencies group in /examples/nextjs-14-decorate with 2 updates (#1111) (52394af)
example: Bump the dependencies group in /examples/nextjs-14-ip-details with 2 updates (#1105) (5127321)
example: Bump the dependencies group in /examples/nextjs-14-nextauth-4 with 2 updates (#1103) (8ef993f)
example: Bump the dependencies group in /examples/nextjs-14-openai with 2 updates (#1113) (89b3ccb)
example: bump the dependencies group in /examples/nextjs-14-openai with 2 updates (#1133) (d2ac694)
example: Bump the dependencies group in /examples/nextjs-14-pages-wrap with 2 updates (#1110) (fb05224)
example: bump the dependencies group in /examples/nextjs-14-react-hook-form with 2 updates (#1120) (729c886)
example: bump the dependencies group in /examples/nextjs-14-react-hook-form with 2 updates (#1134) (2fbe4d6)
example: Bump the dependencies group in /examples/sveltekit with 2 updates (#1093) (009591a)
example: bump the dependencies group in /examples/sveltekit with 2 updates (#1136) (c93a9eb)
🧹 Miscellaneous Chores
examples: Add example of testing APIs with Newman (#1083) (6b2ccf0)
examples: Show dynamic feature flags with LaunchDarkly (#1100) (d3bf356)
FAQs
Arcjet TypeScript and JavaScript SDK core
The npm package arcjet receives a total of 1,711 weekly downloads. As such, arcjet popularity was classified as 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 15 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.
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.