vpndetection-web 1.2.2 → 1.3.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
@@ -7,10 +7,10 @@ The official browser client library for the [VPNDetection](https://vpndetection.
7
7
 
8
8
  It tells you whether an IP address is a VPN, residential proxy, Tor node, relay or hosting server.
9
9
 
10
- **An API key in a web page is public.** Anyone who opens the page can read it from the page's source or its network requests, and spend your allowance with it. In a page, use no key, or call the API from your own server and hand the page its answer. A key belongs only where the person it belongs to is the only one who can read it: their own browser extension, or an internal tool.
11
-
12
10
  ## Getting Started
13
11
 
12
+ **An API key in a web page is public.** Anyone who opens the page can read it from the page's source or its network requests and use it as you would: spend your plan's lookups and, if the key may download databases, download every database your organization is licensed for. In a page, use no key, or call the API from your own server and hand the page its answer. A key belongs only where the person it belongs to is the only one who can read it, such as their own browser extension or an internal tool, and there a key that may only look up.
13
+
14
14
  ```bash
15
15
  npm install vpndetection-web
16
16
  ```
@@ -48,7 +48,7 @@ console.log(result.asn?.name); // who runs the announcing network
48
48
 
49
49
  ### With an API key
50
50
 
51
- Where the key stays private (see above), every paid plan answers every field: `is_hosting`, `is_cdn` and the four proxy flags as well, and the provider, confidence and last-seen detail behind each flag. The plans differ only in how many lookups they include, and a free account tries every field, 100 lookups a day. Create a key in the [console](https://app.vpndetection.io), then pass it in:
51
+ Where the key stays private (see above), every paid plan answers every field: `is_hosting`, `is_cdn` and the four proxy flags as well, and the provider (its ID and its name), confidence and last-seen detail behind each flag. The plans differ only in how many lookups they include, and a free account tries every field, 100 lookups a day. Create a key in the [console](https://app.vpndetection.io), then pass it in:
52
52
 
53
53
  ```js
54
54
  const client = new VPNDetection({ apiKey: 'your-api-key' });
package/dist/bogon.d.ts CHANGED
@@ -21,8 +21,7 @@ export declare function unmapped(ip: string): string;
21
21
  * every flag present and false, every detail object present and empty, and
22
22
  * `location` and `asn` with every key empty, as the API answers a bogon.
23
23
  *
24
- * `isBogon` is set so a caller can always tell a locally computed answer from a
25
- * served one. Note this is deliberately the WIDEST shape regardless of your
24
+ * `isBogon` is true, as the API answers reserved space. Note this is deliberately the WIDEST shape regardless of your
26
25
  * plan, so do not infer which fields your plan includes from a bogon answer.
27
26
  */
28
27
  export declare function bogonResult(ip: string): Result;
package/dist/bogon.js CHANGED
@@ -39,8 +39,7 @@ export function unmapped(ip) {
39
39
  * every flag present and false, every detail object present and empty, and
40
40
  * `location` and `asn` with every key empty, as the API answers a bogon.
41
41
  *
42
- * `isBogon` is set so a caller can always tell a locally computed answer from a
43
- * served one. Note this is deliberately the WIDEST shape regardless of your
42
+ * `isBogon` is true, as the API answers reserved space. Note this is deliberately the WIDEST shape regardless of your
44
43
  * plan, so do not infer which fields your plan includes from a bogon answer.
45
44
  */
46
45
  export function bogonResult(ip) {
package/dist/client.d.ts CHANGED
@@ -148,8 +148,10 @@ export declare class VPNDetection {
148
148
  * `concurrency` below 1 is refused as `bad_request` before anything is sent.
149
149
  * An IPv4-mapped address is looked up as the IPv4 address it carries, and its
150
150
  * answer keyed as you passed it. The batch endpoint needs a paid plan:
151
- * without a key every address sent to it carries an `unauthorized` error,
152
- * and a free-plan key's batch of two or more a `bad_request` (HTTP 402).
151
+ * without a key every address in a request of two or more carries an
152
+ * `unauthorized` error, and a free-plan key's request of two or more a
153
+ * `bad_request` (HTTP 402). A request of one address is answered as its
154
+ * lookup would be.
153
155
  */
154
156
  lookupBatch(ips: Iterable<string>, options?: BatchOptions): Promise<Map<string, Result | VPNDetectionError>>;
155
157
  private unstored;
package/dist/client.js CHANGED
@@ -196,8 +196,10 @@ export class VPNDetection {
196
196
  * `concurrency` below 1 is refused as `bad_request` before anything is sent.
197
197
  * An IPv4-mapped address is looked up as the IPv4 address it carries, and its
198
198
  * answer keyed as you passed it. The batch endpoint needs a paid plan:
199
- * without a key every address sent to it carries an `unauthorized` error,
200
- * and a free-plan key's batch of two or more a `bad_request` (HTTP 402).
199
+ * without a key every address in a request of two or more carries an
200
+ * `unauthorized` error, and a free-plan key's request of two or more a
201
+ * `bad_request` (HTTP 402). A request of one address is answered as its
202
+ * lookup would be.
201
203
  */
202
204
  async lookupBatch(ips, options = {}) {
203
205
  const concurrency = checkConcurrency(options.concurrency);
@@ -60,8 +60,8 @@ export declare const lookupMyIp: <ThrowOnError extends boolean = false>(options?
60
60
  *
61
61
  * A batch needs a paid plan: without a key the call is refused with `401`,
62
62
  * and with a key on the free plan with `402`, unless it names one address,
63
- * which is answered as `GET /{ip}` would answer it. Unlimited looks up one
64
- * address at a time.
63
+ * which is answered as `GET /{ip}` would answer it, under the same rate
64
+ * limit. Unlimited looks up one address at a time.
65
65
  *
66
66
  */
67
67
  export declare const lookupBatch: <ThrowOnError extends boolean = false>(options: Options<LookupBatchData, ThrowOnError>) => RequestResult<LookupBatchResponses, LookupBatchErrors, ThrowOnError>;
@@ -72,8 +72,8 @@ export const lookupMyIp = (options) => (options?.client ?? client).get({
72
72
  *
73
73
  * A batch needs a paid plan: without a key the call is refused with `401`,
74
74
  * and with a key on the free plan with `402`, unless it names one address,
75
- * which is answered as `GET /{ip}` would answer it. Unlimited looks up one
76
- * address at a time.
75
+ * which is answered as `GET /{ip}` would answer it, under the same rate
76
+ * limit. Unlimited looks up one address at a time.
77
77
  *
78
78
  */
79
79
  export const lookupBatch = (options) => (options.client ?? client).post({
@@ -2,8 +2,8 @@ export type ClientOptions = {
2
2
  baseUrl: 'https://api.vpndetection.io' | (string & {});
3
3
  };
4
4
  /**
5
- * The union of every tier's answer. Every answer carries `ip`, `is_vpn`,
6
- * the Tor and relay members, `location` and `asn`, with or without a key;
5
+ * The union of every tier's answer. Every answer carries `ip`, `is_bogon`,
6
+ * `is_vpn`, the Tor and relay members, `location` and `asn`, with or without a key;
7
7
  * each remaining field is present when your tier includes it, and absent
8
8
  * otherwise. A client that must work across plans should treat an absent
9
9
  * flag as unknown rather than as `false`.
@@ -14,6 +14,13 @@ export type LookupResponse = {
14
14
  * The address that was looked up, normalized.
15
15
  */
16
16
  ip: string;
17
+ /**
18
+ * Whether the address is reserved space (RFC 1918, loopback, link-local,
19
+ * documentation ranges and their IPv6 equivalents), answered from the
20
+ * address alone. Every answer, with or without a key.
21
+ *
22
+ */
23
+ is_bogon?: boolean;
17
24
  /**
18
25
  * Whether the address is VPN infrastructure. Keys off presence in the
19
26
  * VPN dataset, so an unattributed range with no provider is still
@@ -68,8 +75,8 @@ export type LookupResponse = {
68
75
  relay?: ClassDetail;
69
76
  /**
70
77
  * Detail for `is_tor`. Empty when false. Every answer, with or without a
71
- * key. The tor dataset carries no provider, so `provider` is always an
72
- * empty string.
78
+ * key. The tor dataset carries no provider, so `provider` and
79
+ * `provider_name` are always empty strings.
73
80
  *
74
81
  */
75
82
  tor?: ClassDetail;
@@ -155,9 +162,15 @@ export type BatchLookupError = {
155
162
  */
156
163
  export type VpnDetail = {
157
164
  /**
158
- * The VPN provider, or an empty string for an unattributed range.
165
+ * The VPN provider's ID, or an empty string for an unattributed range.
159
166
  */
160
167
  provider?: string;
168
+ /**
169
+ * The name the provider catalog gives the provider, beside the ID to key on;
170
+ * an empty string where the catalog names none or the range is unattributed.
171
+ *
172
+ */
173
+ provider_name?: string;
161
174
  /**
162
175
  * The most recent date this address was observed as VPN infrastructure.
163
176
  */
@@ -184,9 +197,15 @@ export type VpnDetail = {
184
197
  */
185
198
  export type ClassDetail = {
186
199
  /**
187
- * The provider, or an empty string where the dataset has none.
200
+ * The provider's ID, or an empty string where the dataset has none.
188
201
  */
189
202
  provider?: string;
203
+ /**
204
+ * The name the provider catalog gives the provider; an empty string where the
205
+ * catalog names none or the dataset has no provider.
206
+ *
207
+ */
208
+ provider_name?: string;
190
209
  /**
191
210
  * How strongly the classification is supported.
192
211
  */
@@ -206,9 +225,15 @@ export type ClassDetail = {
206
225
  */
207
226
  export type ProxyDetail = {
208
227
  /**
209
- * The proxy network, or an empty string where unattributed.
228
+ * The proxy network's ID, or an empty string where unattributed.
210
229
  */
211
230
  provider?: string;
231
+ /**
232
+ * The name the provider catalog gives the proxy network; an empty string where
233
+ * the catalog names none or the address is unattributed.
234
+ *
235
+ */
236
+ provider_name?: string;
212
237
  /**
213
238
  * The earliest date within the window this address was seen in the
214
239
  * pool, as of its last day in the window once it has left.
@@ -671,7 +696,9 @@ export type LookupBatchErrors = {
671
696
  */
672
697
  400: LookupError;
673
698
  /**
674
- * No API key was presented, or the one presented is unknown, revoked, or expired.
699
+ * No API key was presented for more than one address, or the one
700
+ * presented is unknown, revoked, or expired.
701
+ *
675
702
  */
676
703
  401: LookupError;
677
704
  /**
package/dist/shapes.js CHANGED
@@ -15,21 +15,21 @@ export const ENTITLEMENT_APIKEY_MEMBERS = ['id', 'allowed_cidrs'];
15
15
  export const ENTITLEMENT_PLAN_MEMBERS = ['key', 'tier'];
16
16
  export const ENTITLEMENT_USAGE_MEMBERS = ['requests', 'quota', 'window_start', 'window_end'];
17
17
  export const LOOKUP_TYPES = {
18
- ip: 'string', is_vpn: 'boolean', is_hosting: 'boolean', is_relay: 'boolean', is_tor: 'boolean',
18
+ ip: 'string', is_bogon: 'boolean', is_vpn: 'boolean', is_hosting: 'boolean', is_relay: 'boolean', is_tor: 'boolean',
19
19
  is_cdn: 'boolean', is_resproxy: 'boolean', is_dcproxy: 'boolean', is_mobproxy: 'boolean',
20
20
  is_pubproxy: 'boolean', vpn: 'object', hosting: 'object', relay: 'object', tor: 'object', cdn: 'object',
21
21
  resproxy: 'object', dcproxy: 'object', mobproxy: 'object', pubproxy: 'object', location: 'object',
22
22
  asn: 'object', trial_expired: 'boolean',
23
23
  };
24
24
  export const VPN_DETAIL_TYPES = {
25
- provider: 'string', last_seen: 'date', confidence: 'string', method: 'string',
25
+ provider: 'string', provider_name: 'string', last_seen: 'date', confidence: 'string', method: 'string',
26
26
  };
27
27
  export const CLASS_DETAIL_TYPES = {
28
- provider: 'string', confidence: 'string', last_seen: 'date',
28
+ provider: 'string', provider_name: 'string', confidence: 'string', last_seen: 'date',
29
29
  };
30
30
  export const PROXY_DETAIL_TYPES = {
31
- provider: 'string', first_seen: 'date', last_seen: 'date', hits: 'integer', hits_days_pct: 'integer',
32
- providers_num: 'integer',
31
+ provider: 'string', provider_name: 'string', first_seen: 'date', last_seen: 'date', hits: 'integer',
32
+ hits_days_pct: 'integer', providers_num: 'integer',
33
33
  };
34
34
  export const PUBPROXY_DETAIL_TYPES = {
35
35
  entry: 'boolean', exit: 'boolean', protocols: 'array', num_ports: 'integer', num_proxies: 'integer',
@@ -34,7 +34,7 @@ export declare function checkTimeout(timeoutMs: number | undefined): number | un
34
34
  */
35
35
  export declare function checkRetries(retries: number | null | undefined): number | undefined;
36
36
  /** How many batch requests may be in flight, refused where it is set: p-limit throws a bare TypeError. */
37
- export declare function checkConcurrency(concurrency: number | undefined): number | undefined;
37
+ export declare function checkConcurrency(concurrency: number | null | undefined): number | undefined;
38
38
  /**
39
39
  * Bound one attempt, and report an expiry as our own error rather than the
40
40
  * runtime's `TimeoutError`, whose message says nothing about which call gave up.
package/dist/transport.js CHANGED
@@ -69,7 +69,10 @@ export function checkRetries(retries) {
69
69
  }
70
70
  /** How many batch requests may be in flight, refused where it is set: p-limit throws a bare TypeError. */
71
71
  export function checkConcurrency(concurrency) {
72
- if (concurrency !== undefined && !(typeof concurrency === 'number' && concurrency >= 1
72
+ if (concurrency === undefined || concurrency === null) {
73
+ return undefined;
74
+ }
75
+ if (!(typeof concurrency === 'number' && concurrency >= 1
73
76
  && (Number.isInteger(concurrency) || concurrency === Infinity))) {
74
77
  throw new VPNDetectionError('bad_request', `concurrency must be a whole number of at least 1, got ${String(concurrency)}`);
75
78
  }
package/dist/types.d.ts CHANGED
@@ -16,7 +16,10 @@ export interface Result {
16
16
  ip: string;
17
17
  /** Whether the address is VPN infrastructure. Every plan includes this. */
18
18
  isVpn: boolean;
19
- /** Set when this answer was computed locally rather than served. */
19
+ /**
20
+ * Whether the address is reserved space (private, loopback, documentation and the like), which
21
+ * this package answers locally without a request. A served answer carries the API's own `is_bogon`.
22
+ */
20
23
  isBogon: boolean;
21
24
  isHosting?: boolean;
22
25
  isRelay?: boolean;
package/dist/types.js CHANGED
@@ -6,7 +6,7 @@ export function toResult(body) {
6
6
  const r = {
7
7
  ip: body.ip,
8
8
  isVpn: body.is_vpn,
9
- isBogon: false,
9
+ isBogon: body.is_bogon === true,
10
10
  raw: body,
11
11
  };
12
12
  copyFlag(body, r, 'is_hosting', 'isHosting');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vpndetection-web",
3
- "version": "1.2.2",
3
+ "version": "1.3.1",
4
4
  "description": "Official browser client library for the VPNDetection API. Detect VPNs, proxies, Tor, hosting and CDN IPs.",
5
5
  "type": "module",
6
6
  "license": "MIT",