arcjet js
v1.0.0-alpha.34
ArcJet은 개발자가 몇 줄의 코드로 앱을 보호 할 수 있도록 도와줍니다. 속도 제한, 봇 보호, 이메일 검증 및 일반적인 공격에 대한 방어를 구현합니다.
JS 용 다양한 ArcJet 오픈 소스 패키지를 포함하는 Monorepo입니다.
@arcjet/bun 패키지를 사용하십시오.npm:@arcjet/deno 패키지를 사용하십시오.@arcjet/nest 패키지를 사용하십시오.@arcjet/next 패키지를 사용하십시오. JS Quick Start Guide.@arcjet/node 패키지를 사용하십시오.@arcjet/remix 패키지를 사용하십시오.@arcjet/sveltekit 패키지를 사용하십시오. Discord 서버에 가입하거나 지원을 위해 연락하십시오.
https://example.arcjet.com (소스 코드)에서 Arcjet Protected 앱을 사용해보십시오.
docs.arcjet.com에서 문서를 읽으십시오.
아래의 ArcJet 요율 제한 예제는 로그인 된 경우 ID를 기반으로 사용자를 식별하는 경로에 토큰 버킷 속도 제한 규칙을 적용합니다. 버킷은 10 초마다 최대 10 개의 토큰과 리필로 구성됩니다. 각 요청은 5 개의 토큰을 소비합니다.
자세한 내용은 Arcjet Next.js 요율 제한 문서를 참조하십시오.
import arcjet , { tokenBucket } from "@arcjet/next" ;
import { NextResponse } from "next/server" ;
const aj = arcjet ( {
key : process . env . ARCJET_KEY ! , // Get your site key from https://app.arcjet.com
characteristics : [ "userId" ] , // track requests by a custom user ID
rules : [
// Create a token bucket rate limit. Other algorithms are supported.
tokenBucket ( {
mode : "LIVE" , // will block requests. Use "DRY_RUN" to log only
refillRate : 5 , // refill 5 tokens per interval
interval : 10 , // refill every 10 seconds
capacity : 10 , // bucket maximum capacity of 10 tokens
} ) ,
] ,
} ) ;
export async function GET ( req : Request ) {
const userId = "user123" ; // Replace with your authenticated user ID
const decision = await aj . protect ( req , { userId , requested : 5 } ) ; // Deduct 5 tokens from the bucket
console . log ( "Arcjet decision" , decision ) ;
if ( decision . isDenied ( ) ) {
return NextResponse . json (
{ error : "Too Many Requests" , reason : decision . reason } ,
{ status : 429 } ,
) ;
}
return NextResponse . json ( { message : "Hello world" } ) ;
}아래 ArcJet Bot Protection 예제는 고객의 모든 요청에 대해 403 금지 된 응답을 반환합니다.
자세한 내용은 ArcJet Node.js BOT 보호 문서를 참조하십시오.
import arcjet , { detectBot } from "@arcjet/node" ;
import http from "node:http" ;
const aj = arcjet ( {
key : process . env . ARCJET_KEY ! , // Get your site key from https://app.arcjet.com
rules : [
detectBot ( {
mode : "LIVE" , // will block requests. Use "DRY_RUN" to log only
// configured with a list of bots to allow from
// https://arcjet.com/bot-list
allow : [ ] , // "allow none" will block all detected bots
} ) ,
] ,
} ) ;
const server = http . createServer ( async function (
req : http . IncomingMessage ,
res : http . ServerResponse ,
) {
const decision = await aj . protect ( req ) ;
console . log ( "Arcjet decision" , 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 ( { message : "Hello world" } ) ) ;
}
} ) ;
server . listen ( 8000 ) ; 이 저장소의 다양한 패키지에 대한 소스 코드를 제공하므로 아래 카테고리 및 설명을 통해 특정 코드를 찾을 수 있습니다.
@arcjet/bun : sdk for bun.sh.@arcjet/deno : deno를위한 sdk.@arcjet/nest : sdk for nestjs.@arcjet/next : sdk for the next.js 프레임 워크.@arcjet/node : node.js의 sdk@arcjet/remix : 리믹스 용 SDK.@arcjet/sveltekit : sveltekit의 sdk.@arcjet/analyze : 로컬 분석 엔진.@arcjet/headers : 헤더 클래스의 Arcjet 확장.@arcjet/ip : 요청의 원래 IP를 찾기위한 유틸리티.@arcjet/redact : 문자열의 편집 및 부정확 한 민감한 정보.nosecone : 안전한 헤더로 Response 보호하십시오.@nosecone/next : 보안 헤더로 다음.js 응용 프로그램을 보호하십시오.@nosecone/sveltekit : 보안 헤더로 sveltekit 응용 프로그램을 보호하십시오.arcjet : JS SDK Core.@arcjet/body : node.js incomingMessage에서 신체를 추출하는 유틸리티.@arcjet/decorate : 정보로 응답을 장식하는 유틸리티.@arcjet/duration : 구문 분석 기간 문자열을 몇 초 내 정수로 유틸리티합니다.@arcjet/env : arcjet 변수에 대한 환경 감지.@arcjet/logger : Pino 구조화 된 로거 인터페이스를 반영하는 경량 로거.@arcjet/protocol : js 인터페이스 ArcJet 프로토콜로.@arcjet/runtime : 런타임 감지.@arcjet/sprintf : util.format 에 대한 플랫폼 독립적 교체.@arcjet/transport : ArcJet 프로토콜을위한 전송 메커니즘.@arcjet/eslint-config : 프로젝트에 대한 사용자 정의 eslint 구성.@arcjet/redact-wasm : 민감한 정보 편집 감지 엔진.@arcjet/rollup-config : 프로젝트에 대한 사용자 정의 롤업 구성.@arcjet/tsconfig : 프로젝트를위한 맞춤형 tsconfig. 이 저장소는 ArcJet 지원 정책을 따릅니다.
이 저장소는 ArcJet 보안 정책을 따릅니다.
Apache 라이센스, 버전 2.0에 따라 라이센스.