vpndetection-next 2.1.30 → 2.2.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 CHANGED
@@ -90,7 +90,7 @@ blockCondition: [{ isTor: true }, { isResproxy: true }] // a list
90
90
  blockCondition: { isBot: true } // a bot, such as a crawler, on every plan
91
91
  ```
92
92
 
93
- 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`) is never matched, so block on its flag alone, such as `isBot`. 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 proxy is created rather than silently blocking all your traffic.
93
+ 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 proxy is created rather than silently blocking all your traffic.
94
94
 
95
95
  Replace the refusal with `onBlocked`. A redirect is usually friendlier than a 403:
96
96
 
@@ -98,6 +98,20 @@ Replace the refusal with `onBlocked`. A redirect is usually friendlier than a 40
98
98
  onBlocked: (request) => NextResponse.redirect(new URL('/no-vpn', request.url)),
99
99
  ```
100
100
 
101
+ ## Let a verified crawler through
102
+
103
+ `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 forwarded, its `user_agent` included:
104
+
105
+ ```ts
106
+ export const proxy = createProxy({
107
+ apiKey: process.env.VPNDETECTION_API_KEY,
108
+ blockCondition: { isBot: true },
109
+ allowBots: true,
110
+ });
111
+ ```
112
+
113
+ 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`.
114
+
101
115
  ## Doing other work in the same proxy
102
116
 
103
117
  Most apps already have a proxy. Use `createGuard` and call it from yours:
@@ -172,7 +186,7 @@ Beyond a few million distinct visitors a day, stop calling the API per request:
172
186
 
173
187
  ## Absent is not false
174
188
 
175
- 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 absent, which means "not in your plan" rather than "checked, and no".
189
+ Unlimited, with a key or without one, leaves out `isHosting`, `isCdn`, the four proxy flags, the carrier, satellite and service flags, `bot`, `user_agent`, `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 absent, which means "not in your plan" rather than "checked, and no".
176
190
 
177
191
  ```ts
178
192
  lookup.result?.is_hosting ?? false // when you only want the flag
@@ -188,7 +202,7 @@ There are official VPNDetection client libraries available for many languages in
188
202
 
189
203
  VPN Detection API: Accurate anonymity detection identifying VPNs, residential proxies, hosting servers, Tor nodes, CDNs, relays and more.
190
204
 
191
- [<img src="https://s3.vpndetection.io/vpndetection-public/brand/mark.svg" alt="VPNDetection" height="64"/>](https://vpndetection.io/)
205
+ [<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/)
192
206
 
193
207
  ## License
194
208
 
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ export function createProxy(options = {}) {
43
43
  * ```
44
44
  */
45
45
  export function createGuard(options = {}) {
46
- const core = createCore(options, defaultIpSelector);
46
+ const core = createCore(options, defaultIpSelector, selectors.userAgentSelector);
47
47
  const forwarding = options.forward !== false;
48
48
  const guard = async (request) => core.evaluate(request);
49
49
  /**
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;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAK9C;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAC;AA0B9C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,UAAmB,EAAE;IAC7C,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACnC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC;IAE9C,OAAO,KAAK,UAAU,KAAK,CAAC,OAAoB;QAC5C,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;QACpC,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YAClB,OAAO,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,WAAW,CAAC,UAAmB,EAAE;IAC7C,MAAM,IAAI,GAAG,UAAU,CAAc,OAAO,EAAE,iBAAiB,CAAC,CAAC;IACjE,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,KAAK,KAAK,CAAC;IAE7C,MAAM,KAAK,GAAG,KAAK,EAAE,OAAoB,EAA+B,EAAE,CACtE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;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AkB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AAC3H,CAAC;AAED,SAAS,WAAW,CAAC,MAAc;IAC/B,OAAO;QACH,GAAG,CAAC,MAAM,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;QACrD,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACnC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;YAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAyC;SAClE,CAAC;QACF,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACnE,OAAO,EAAE,MAAM,CAAC,OAAO;KAC1B,CAAC;AACN,CAAC;AAED,SAAS,MAAM;IACX,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;AAC1E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vpndetection-next",
3
- "version": "2.1.30",
3
+ "version": "2.2.1",
4
4
  "description": "Official Next.js proxy/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.19.2"
47
+ "vpndetection": "^5.21.0"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "next": ">=15"