vpndetection-fastify 2.0.41 → 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
|
@@ -58,7 +58,7 @@ blockCondition: [{ isTor: true }, { isResproxy: true }] // a list
|
|
|
58
58
|
blockCondition: { isBot: true } // a bot, such as a crawler, on every plan
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
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`)
|
|
61
|
+
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.
|
|
62
62
|
|
|
63
63
|
Replace the refusal with `onBlocked`:
|
|
64
64
|
|
|
@@ -72,6 +72,20 @@ await app.register(vpndetection, {
|
|
|
72
72
|
|
|
73
73
|
`onBlocked` may be async; it is awaited, so the route handler never runs.
|
|
74
74
|
|
|
75
|
+
## Let a verified crawler through
|
|
76
|
+
|
|
77
|
+
`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 `request.vpndetection`:
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
await app.register(vpndetection, {
|
|
81
|
+
apiKey: process.env.VPNDETECTION_API_KEY,
|
|
82
|
+
blockCondition: { isBot: true },
|
|
83
|
+
allowBots: true,
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
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`.
|
|
88
|
+
|
|
75
89
|
## Where the client address comes from
|
|
76
90
|
|
|
77
91
|
Get this setting right, or none of the above works.
|
|
@@ -169,7 +183,7 @@ Beyond a few million distinct visitors a day, stop calling the API per request:
|
|
|
169
183
|
|
|
170
184
|
## Absent is not false
|
|
171
185
|
|
|
172
|
-
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".
|
|
186
|
+
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".
|
|
173
187
|
|
|
174
188
|
```js
|
|
175
189
|
request.vpndetection.result.isHosting ?? false // when you only want the flag
|
|
@@ -185,7 +199,7 @@ There are official VPNDetection client libraries available for many languages in
|
|
|
185
199
|
|
|
186
200
|
VPN Detection API: Accurate anonymity detection identifying VPNs, residential proxies, hosting servers, Tor nodes, CDNs, relays and more.
|
|
187
201
|
|
|
188
|
-
[<img src="https://s3.vpndetection.io/vpndetection-public/brand/
|
|
202
|
+
[<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/)
|
|
189
203
|
|
|
190
204
|
## License
|
|
191
205
|
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import fp from 'fastify-plugin';
|
|
|
18
18
|
* replaces the outer one on the routes it covers.
|
|
19
19
|
*/
|
|
20
20
|
export const vpndetection = fp(async (fastify, options) => {
|
|
21
|
-
const core = createCore(options, defaultIpSelector);
|
|
21
|
+
const core = createCore(options, defaultIpSelector, selectors.userAgentSelector);
|
|
22
22
|
const onBlocked = options.onBlocked ?? refuse;
|
|
23
23
|
// Decorated up front so the property exists on every request object
|
|
24
24
|
// rather than being added per request, which deoptimizes the shape
|
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;AAIpE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAsBhC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAgC,EAAE,CACvD,KAAK,EAAE,OAAwB,EAAE,OAAgB,EAAE,EAAE;IACjD,MAAM,IAAI,GAAG,UAAU,CAAiB,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;AAIpE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAsBhC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAgC,EAAE,CACvD,KAAK,EAAE,OAAwB,EAAE,OAAgB,EAAE,EAAE;IACjD,MAAM,IAAI,GAAG,UAAU,CAAiB,OAAO,EAAE,iBAAiB,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACjG,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A2E;AAC3E,0EAA0E;AAC1E,MAAM,SAAS,GAAG,aAAa,CAAiB,IAAI,CAAC,CAAC;AAEtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA+B,SAAS,CAAC,iBAAiB,CAAC;AAEzF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GACpB,SAAS,CAAC,aAAa,CAAC;AAE9B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GACvB,SAAS,CAAC,gBAAgB,CAAC;AAEjC,SAAS,MAAM,CAAC,QAAwB,EAAE,KAAmB;IACzD,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,eAAe,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vpndetection-fastify",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Official Fastify plugin for the VPNDetection API. Detect VPNs, proxies, Tor, hosting and CDN visitors on every request.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"fastify-plugin": "^5.0.1",
|
|
48
|
-
"vpndetection": "^5.
|
|
48
|
+
"vpndetection": "^5.21.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"fastify": "4.x || 5.x"
|