vpndetection-express 2.0.40 → 2.1.1
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 +17 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ blockCondition: [{ isTor: true }, { isResproxy: true }] // a list
|
|
|
55
55
|
blockCondition: { isBot: true } // a bot, such as a crawler, on every plan
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
Values are matched by equality, strings without regard to case. An array means any-of. `{ gte, gt, lte, lt }` compares numbers, and every bound you give must hold, so two of them are a range. A member the answer holds as a list (`web`, `pubproxy.protocols`, `bittorrent.clients`, `bot.agents`, `bot.categories`)
|
|
58
|
+
Values are matched by equality, strings without regard to case. An array means any-of. `{ gte, gt, lte, lt }` compares numbers, and every bound you give must hold, so two of them are a range. A member the answer holds as a list (`web`, `pubproxy.protocols`, `bittorrent.clients`, `bot.agents`, `bot.categories`) matches when any element does: `{ pubproxy: { protocols: 'socks5' } }` matches a proxy that speaks SOCKS5 among others, and an object term such as `{ web: { port: 443 } }` must match one element in full. Members you set to `false` or `null` are ignored, so a condition states the signals you act on; one that constrains nothing would match every request, and is refused when the middleware is created rather than silently blocking all your traffic.
|
|
59
59
|
|
|
60
60
|
Replace the refusal with `onBlocked`:
|
|
61
61
|
|
|
@@ -67,6 +67,20 @@ app.use(vpndetection({
|
|
|
67
67
|
}));
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
+
## Let a verified crawler through
|
|
71
|
+
|
|
72
|
+
`allowBots` sends each request's own `User-Agent` with its lookup, and a request whose answer's `userAgent.verdict` is `verified`, a crawler its operator vouches for such as Googlebot from Google's addresses, is never blocked, whatever `blockCondition` matches. The answer is still on `req.vpndetection`:
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
app.use(vpndetection({
|
|
76
|
+
apiKey: process.env.VPNDETECTION_API_KEY,
|
|
77
|
+
blockCondition: { isBot: true },
|
|
78
|
+
allowBots: true,
|
|
79
|
+
}));
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
A client claiming to be a crawler from an address its operator does not vouch for reads `spoofed`, so `blockCondition: { userAgent: { verdict: 'spoofed' } }` refuses a forged crawler. A request with no `User-Agent` sends none. It is off by default, and then no agent is sent and the cache keeps one answer per address rather than one per address and agent. A verdict needs a paid plan or the trial: a served answer without one is reported once under `onMissingField`.
|
|
83
|
+
|
|
70
84
|
## Where the client address comes from
|
|
71
85
|
|
|
72
86
|
Get this setting right, or none of the above works.
|
|
@@ -139,7 +153,7 @@ Beyond a few million distinct visitors a day, stop calling the API per request:
|
|
|
139
153
|
|
|
140
154
|
## Absent is not false
|
|
141
155
|
|
|
142
|
-
Unlimited, with a key or without one, leaves out `isHosting`, `isCdn`, the four proxy flags, the carrier, satellite and service flags, `bot`, `company` and `abuse`, and of the detail behind each flag it answers only Tor's and relay's. A field your plan does not include is `undefined`, which means "not in your plan" rather than "checked, and no".
|
|
156
|
+
Unlimited, with a key or without one, leaves out `isHosting`, `isCdn`, the four proxy flags, the carrier, satellite and service flags, `bot`, `userAgent`, `company` and `abuse`, and of the detail behind each flag it answers only Tor's and relay's. A field your plan does not include is `undefined`, which means "not in your plan" rather than "checked, and no".
|
|
143
157
|
|
|
144
158
|
```js
|
|
145
159
|
req.vpndetection.result.isHosting ?? false // when you only want the flag
|
|
@@ -155,7 +169,7 @@ There are official VPNDetection client libraries available for many languages in
|
|
|
155
169
|
|
|
156
170
|
VPN Detection API: Accurate anonymity detection identifying VPNs, residential proxies, hosting servers, Tor nodes, CDNs, relays and more.
|
|
157
171
|
|
|
158
|
-
[<img src="https://s3.vpndetection.io/vpndetection-public/brand/
|
|
172
|
+
[<picture><source media="(prefers-color-scheme: dark)" srcset="https://s3.vpndetection.io/vpndetection-public/brand/logo-dark.svg"><img src="https://s3.vpndetection.io/vpndetection-public/brand/logo.svg" alt="VPNDetection" height="40"/></picture>](https://vpndetection.io/)
|
|
159
173
|
|
|
160
174
|
## License
|
|
161
175
|
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { bindSelectors, createCore } from 'vpndetection/middleware';
|
|
|
11
11
|
* `failClosed`.
|
|
12
12
|
*/
|
|
13
13
|
export function vpndetection(options = {}) {
|
|
14
|
-
const core = createCore(options, defaultIpSelector);
|
|
14
|
+
const core = createCore(options, defaultIpSelector, selectors.userAgentSelector);
|
|
15
15
|
const onBlocked = options.onBlocked ?? refuse;
|
|
16
16
|
return (req, res, next) => {
|
|
17
17
|
core.evaluate(req).then((lookup) => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AA2BpE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,UAAmB,EAAE;IAC9C,MAAM,IAAI,GAAG,UAAU,CAAU,OAAO,EAAE,iBAAiB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AA2BpE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,UAAmB,EAAE;IAC9C,MAAM,IAAI,GAAG,UAAU,CAAU,OAAO,EAAE,iBAAiB,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAC1F,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC;IAC9C,OAAO,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;QACvD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YAC/B,IAAI,MAAM,KAAK,SAAS,EAAE,CA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+1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vpndetection-express",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Official Express middleware for the VPNDetection API. Detect VPNs, proxies, Tor, hosting and CDN visitors on every request.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"node": ">=22"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"vpndetection": "^5.
|
|
47
|
+
"vpndetection": "^5.21.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"express": ">=4.18"
|