api-turnstile 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -34
- package/package.json +16 -14
package/README.md
CHANGED
|
@@ -1,58 +1,119 @@
|
|
|
1
|
-
#
|
|
1
|
+
# API Turnstile — CAPTCHA-Free API Bot Protection & Abuse Prevention
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
<div align="center">
|
|
4
|
+
<img src="https://sentinel.risksignal.name.ng/sentinel-logo.png" alt="Sentinel Logo" width="120" />
|
|
5
|
+
<h3>The Deterministic Trust Layer for Modern APIs</h3>
|
|
6
|
+
<p>Cloudflare Turnstile protects browsers. <b>Sentinel protects APIs.</b></p>
|
|
7
|
+
<p>
|
|
8
|
+
<a href="https://www.npmjs.com/package/api-turnstile"><img src="https://img.shields.io/npm/v/api-turnstile?color=orange&style=flat-square" alt="NPM Version" /></a>
|
|
9
|
+
<a href="https://github.com/00xf5/sentinelapinpm/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/api-turnstile?style=flat-square" alt="MIT License" /></a>
|
|
10
|
+
<a href="https://sentinel.risksignal.name.ng"><img src="https://img.shields.io/badge/latency-<50ms-green?style=flat-square" alt="Latency" /></a>
|
|
11
|
+
</p>
|
|
12
|
+
</div>
|
|
5
13
|
|
|
6
|
-
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
> **CAPTCHA-free API bot protection for Node.js and serverless APIs.**
|
|
17
|
+
> **Block bots, scripts, credential stuffing, and automation attacks — without rate limits or CAPTCHAs.**
|
|
18
|
+
> **API Turnstile is a Cloudflare Turnstile alternative built specifically for APIs.**
|
|
19
|
+
|
|
20
|
+
## What Is API Turnstile?
|
|
21
|
+
|
|
22
|
+
API Turnstile is an API bot protection and abuse prevention middleware for Node.js, Express, Next.js, Bun, and serverless environments.
|
|
23
|
+
It blocks automated attacks such as credential stuffing, fake account creation, payment fraud, and API scraping — without CAPTCHAs or browser JavaScript.
|
|
24
|
+
|
|
25
|
+
## 🚀 Key Features
|
|
26
|
+
|
|
27
|
+
- **⚡ Sub-50ms Latency**: Built on a globally distributed decision engine.
|
|
28
|
+
- **🛡️ Adaptive Defenses**: Automatically escalates cryptographic challenges (BWT) for suspicious IPs.
|
|
29
|
+
- **🔌 Multi-Framework**: First-class support for Node.js (Express/Fastify) and Edge Runtimes (Next.js/Bun).
|
|
30
|
+
- **🕹️ CLI Intelligence**: Stream live traffic decisions directly to your terminal with `sentinel tail`.
|
|
31
|
+
- **🎯 Outcome-Based**: Focuses on business results (e.g., bot reduction, capital saved) rather than just "block counts".
|
|
32
|
+
|
|
33
|
+
## 📦 Installation
|
|
7
34
|
|
|
8
35
|
```bash
|
|
9
36
|
npm install api-turnstile
|
|
10
37
|
```
|
|
11
38
|
|
|
12
|
-
## Quick Start
|
|
39
|
+
## 🛠️ Quick Start
|
|
13
40
|
|
|
41
|
+
### Express / Node.js
|
|
14
42
|
```javascript
|
|
15
43
|
import { sentinel } from 'api-turnstile';
|
|
44
|
+
import express from 'express';
|
|
45
|
+
|
|
46
|
+
const app = express();
|
|
16
47
|
|
|
17
48
|
app.use(sentinel({
|
|
18
|
-
apiKey:
|
|
19
|
-
protect: ['/
|
|
49
|
+
apiKey: 'your_api_key',
|
|
50
|
+
protect: ['/api/v1/auth/*', '/v1/payments'],
|
|
51
|
+
profile: 'api'
|
|
20
52
|
}));
|
|
21
53
|
```
|
|
22
54
|
|
|
23
|
-
|
|
55
|
+
### Next.js Edge Middleware
|
|
56
|
+
```javascript
|
|
57
|
+
// middleware.ts
|
|
58
|
+
import { sentinelEdge } from 'api-turnstile/middleware/next';
|
|
24
59
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
60
|
+
export default sentinelEdge({
|
|
61
|
+
apiKey: process.env.SENTINEL_KEY,
|
|
62
|
+
protect: {
|
|
63
|
+
'/api/auth/*': 'strict',
|
|
64
|
+
'/api/public/*': 'monitor'
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
```
|
|
30
68
|
|
|
31
|
-
##
|
|
69
|
+
## ⚙️ Configuration Deep Dive
|
|
70
|
+
|
|
71
|
+
| Option | Type | Default | Description |
|
|
72
|
+
| :--- | :--- | :--- | :--- |
|
|
73
|
+
| `apiKey` | `string` | **Required** | Your Sentinel API key. |
|
|
74
|
+
| `protect` | `string[] \| Object` | `[]` | Paths to protect. Supports wildcards (`*`) and per-path modes. |
|
|
75
|
+
| `profile` | `string` | `'api'` | Protection profile: `api`, `signup`, `payments`, `crypto`. |
|
|
76
|
+
| `fail` | `'open' \| 'closed'` | `'closed'` | Strategy if the Sentinel API is unreachable. |
|
|
77
|
+
| `bwt.enabled` | `boolean` | `true` | Enable Behavioral Work Tokens (Adaptive PoW). |
|
|
78
|
+
| `onBlock` | `function` | Default 403 response | Custom handler for blocked requests. |
|
|
79
|
+
|
|
80
|
+
### Protection Modes
|
|
81
|
+
- **`monitor`**: Logs activity but never blocks. Ideal for initial onboarding.
|
|
82
|
+
- **`balanced`**: Blocks obvious bots and high-risk signals.
|
|
83
|
+
- **`strict`**: Enforces zero-tolerance for automation and proxy traffic.
|
|
84
|
+
|
|
85
|
+
## 💻 Sentinel CLI
|
|
86
|
+
|
|
87
|
+
The package includes a powerful CLI for real-time forensics and monitoring.
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Install globally
|
|
91
|
+
npm install -g api-turnstile
|
|
92
|
+
|
|
93
|
+
# Stream live decisions in real-time
|
|
94
|
+
sentinel tail --key YOUR_API_KEY
|
|
95
|
+
|
|
96
|
+
# Perform an immediate forensic check on an IP
|
|
97
|
+
sentinel check 1.2.3.4
|
|
98
|
+
|
|
99
|
+
# View security outcomes and ROI stats
|
|
100
|
+
sentinel stats
|
|
101
|
+
```
|
|
32
102
|
|
|
33
|
-
|
|
34
|
-
|-----------|------------|
|
|
35
|
-
| Express / Node | `sentinel(config)` |
|
|
36
|
-
| Fastify | `sentinelFastify(config)` |
|
|
37
|
-
| Hono / Bun | `sentinelHono(config)` |
|
|
38
|
-
| Next.js Edge | `sentinelEdge(config)` |
|
|
103
|
+
## 🧠 Behavioral Work Tokens (BWT)
|
|
39
104
|
|
|
40
|
-
|
|
105
|
+
BWT is Sentinel's secret weapon. When an IP is deemed "unstable" (not yet high-risk enough to block), Sentinel issues a cryptographic challenge.
|
|
41
106
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
| `protect` | Array of paths or path-to-mode mapping |
|
|
46
|
-
| `profile` | Security profile (`api`, `signup`, `payments`, `crypto`) |
|
|
47
|
-
| `webhooks` | Optional URL for block notifications |
|
|
48
|
-
| `fail` | Strategy if API is down (`open`, `closed`) |
|
|
107
|
+
1. Legitimate clients (using this SDK) solve the challenge in the background (~5ms overhead).
|
|
108
|
+
2. Bot scripts (Headless Chrome, curl, python-requests) fail to solve the token.
|
|
109
|
+
3. Your server rejects the request before it ever hits your business logic.
|
|
49
110
|
|
|
50
|
-
## Links
|
|
111
|
+
## 🔗 Links
|
|
51
112
|
|
|
52
|
-
- [Dashboard & API
|
|
53
|
-
- [
|
|
54
|
-
- [GitHub Repository](https://github.com/00xf5/sentinelapinpm)
|
|
113
|
+
- **[Dashboard & API Management](https://sentinel.risksignal.name.ng)**
|
|
114
|
+
- **[Documentation](https://sentinel.risksignal.name.ng/docs)**
|
|
115
|
+
- **[GitHub Repository](https://github.com/00xf5/sentinelapinpm)**
|
|
55
116
|
|
|
56
|
-
## License
|
|
117
|
+
## 📄 License
|
|
57
118
|
|
|
58
|
-
MIT
|
|
119
|
+
MIT © [Sentinel Security](https://sentinel.risksignal.name.ng)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "api-turnstile",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.5",
|
|
4
|
+
"description": "CAPTCHA-free API bot protection and abuse prevention middleware for Node.js, Express, Next.js, and serverless APIs.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"bin": {
|
|
@@ -14,17 +14,19 @@
|
|
|
14
14
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
|
-
"api",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
17
|
+
"api security",
|
|
18
|
+
"api bot protection",
|
|
19
|
+
"api abuse prevention",
|
|
20
|
+
"anti bot",
|
|
21
|
+
"bot protection",
|
|
22
|
+
"captcha free",
|
|
23
|
+
"cloudflare turnstile alternative",
|
|
24
|
+
"credential stuffing",
|
|
25
|
+
"signup fraud",
|
|
26
|
+
"rate limiting alternative",
|
|
27
|
+
"express middleware",
|
|
28
|
+
"nextjs api",
|
|
29
|
+
"serverless security"
|
|
28
30
|
],
|
|
29
31
|
"author": "Sentinel Security",
|
|
30
32
|
"license": "MIT",
|
|
@@ -62,4 +64,4 @@
|
|
|
62
64
|
"engines": {
|
|
63
65
|
"node": ">=18.0.0"
|
|
64
66
|
}
|
|
65
|
-
}
|
|
67
|
+
}
|