vpndetection-web 1.8.1 → 1.10.0
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 +10 -9
- package/dist/client.d.ts +12 -9
- package/dist/client.js +6 -5
- package/dist/generated/sdk.gen.d.ts +9 -7
- package/dist/generated/sdk.gen.js +9 -7
- package/dist/generated/types.gen.d.ts +49 -34
- package/dist/shapes.d.ts +4 -2
- package/dist/shapes.js +23 -11
- package/dist/store.d.ts +3 -2
- package/dist/store.js +3 -2
- package/dist/types.d.ts +32 -13
- package/dist/types.js +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ It runs in Chrome and Edge 109, Firefox 115 ESR and Safari 16.4 or newer. TypeSc
|
|
|
30
30
|
|
|
31
31
|
## Usage
|
|
32
32
|
|
|
33
|
-
**
|
|
33
|
+
**Lookups need no API key to try:** the free plan answers each address's first lookups of the day without one, with `ip`, `is_vpn`, Tor and relay detection, `is_anycast`, `hostname` (the reverse DNS name), and country-level `location` and `asn` with the AS's country and RPKI status. A free API key answers your organization's first lookups each day with every field, and the basics with no cap. The Data plan answers every field on every lookup. In a page the address calling is the visitor's, so `myIp` tells you about the visitor:
|
|
34
34
|
|
|
35
35
|
```js
|
|
36
36
|
import { VPNDetection } from 'vpndetection-web';
|
|
@@ -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), a paid plan answers every field: `is_hosting`, `is_cdn` and the four proxy flags as well, the carrier and satellite flags, the five service flags (SSH, SMTP, web, DNS resolver and BitTorrent), `bot` (whose bot it is and whether its operator vouches for the address), `user_agent` (whether a user agent you send is borne out by the address: see below), city-level `location`, the `company` and the `abuse` contact, and the provider (its ID and its name), confidence and last-seen detail behind each flag. Its quotas differ only in how many lookups they include, and a free
|
|
51
|
+
Where the key stays private (see above), a paid plan answers every field: `is_hosting`, `is_cdn`, `is_bot` and the four proxy flags as well, the carrier and satellite flags, the five service flags (SSH, SMTP, web, DNS resolver and BitTorrent), `bot` (whose bot it is and whether its operator vouches for the address), `user_agent` (whether a user agent you send is borne out by the address: see below), city-level `location`, the AS's `type`, the `company` and the `abuse` contact, and the provider (its ID and its name), confidence and last-seen detail behind each flag. Its quotas differ only in how many lookups they include, and a free key answers your organization's first lookups each day with every field. 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' });
|
|
@@ -72,7 +72,7 @@ It is never cached, since which address the browser is calling from is the quest
|
|
|
72
72
|
|
|
73
73
|
### A visitor's user agent
|
|
74
74
|
|
|
75
|
-
Pass the `User-Agent` of the client you are deciding on, and on a paid plan or
|
|
75
|
+
Pass the `User-Agent` of the client you are deciding on, and on a paid plan or a free key's full answers the answer's `userAgent` names the agent it claims to be and whether this address bears that out: `verified` when the agent's operator vouches for the address, `spoofed` when it does not, `unverifiable` for a bot nothing can confirm, `not_bot` for a browser, an app or a script. Check for the values you know: one the API adds later comes back as the string it served.
|
|
76
76
|
|
|
77
77
|
```js
|
|
78
78
|
const result = await client.lookup('66.249.66.1', {
|
|
@@ -99,7 +99,7 @@ console.log(ent.usage.requests); // 580
|
|
|
99
99
|
console.log(ent.usage.window_end); // when the allowance resets
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
-
Usage counts against the anniversary of your subscription on a paid plan, not the calendar month and not the billing period, and against the
|
|
102
|
+
Usage counts against the anniversary of your subscription on a paid plan, not the calendar month and not the billing period, and against the UTC day's lookups answered with every field on the free plan; it is the same number a lookup is gated on. `hard_limit` is null on an uncapped plan, which is not the same as zero. It needs a key, so it belongs where a key does.
|
|
103
103
|
|
|
104
104
|
Show `plan.name` and compare against `plan.key`: a plan's name can change, and its key never does. A `tier` the API adds later comes back as the string it served, so check for the values you know rather than assuming the list is complete.
|
|
105
105
|
|
|
@@ -148,7 +148,7 @@ const client = new VPNDetection({ cache: { max: 50_000, ttlMs: 6 * 60 * 60 * 100
|
|
|
148
148
|
const clientNoCache = new VPNDetection({ cache: false });
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
-
An answer with `trialExpired` or `capReached` true is cached for a minute at most, in memory and in a `store`, so a
|
|
151
|
+
An answer with `trialExpired` or `capReached` true is cached for a minute at most, in memory and in a `store`, so the next UTC day's full answers, a changed plan or a lifted cap reach you within a minute.
|
|
152
152
|
|
|
153
153
|
### Keeping answers across a reload
|
|
154
154
|
|
|
@@ -230,7 +230,7 @@ try {
|
|
|
230
230
|
|
|
231
231
|
`kind` is one of `bad_request`, `unauthorized`, `forbidden`, `rate_limited`, `quota_exceeded`, `server_error` or `network`.
|
|
232
232
|
|
|
233
|
-
Note that `rate_limited` and `quota_exceeded` both arrive as HTTP 429 and are not the same thing. A rate limit is when the API faces extreme traffic bursts and so retrying later works; but a spent quota needs your allowance raised or the window to roll over. The library retries rate limits for you, but not if your quota is exceeded.
|
|
233
|
+
Note that `rate_limited` and `quota_exceeded` both arrive as HTTP 429 and are not the same thing. A rate limit is when the API faces extreme traffic bursts and so retrying later works; but a spent quota needs your allowance raised or the window to roll over. The library retries rate limits for you, but not if your quota is exceeded. A lookup with no key past its address's lookups for the day is a spent quota: it is sent once and arrives as `quota_exceeded` with the API's own message, which says where to get a free key.
|
|
234
234
|
|
|
235
235
|
A request the browser never got an answer to is a retryable `network` error carrying what the browser said: offline, blocked by an extension, or refused by the page's Content-Security-Policy.
|
|
236
236
|
|
|
@@ -270,12 +270,13 @@ The library is ES2022 and needs only what a browser has, `fetch` and, for PKCE,
|
|
|
270
270
|
|
|
271
271
|
### Absent is not false
|
|
272
272
|
|
|
273
|
-
|
|
273
|
+
The basics, which a lookup without a key and a free key past your organization's full answers for the day both get, leave out `isHosting`, `isCdn`, `isBot`, the four proxy flags, the carrier, satellite and service flags, `bot`, `company` and `abuse`, and of the detail behind each flag they carry only Tor's and relay's; they leave out the AS's `type` too, which `result.asn.type` reads as an empty string while `result.raw.asn` shows it was not served. A free key's basics also leave out `is_vpn`, and carry `trialExpired`: true once your organization's full answers for the UTC day are used up. There `result.isVpn` reads `false`, which means "not in this answer", never "not a VPN", and `result.raw.is_vpn` is absent. A paid key's answer carries `capReached`, true once its organization's overage cap is reached and the answer has the basics and `isVpn`. A field your key does not include is `undefined`, which means "not in your plan" rather than "checked, and no".
|
|
274
274
|
|
|
275
275
|
```js
|
|
276
276
|
result.isHosting ?? false // when you only want the flag
|
|
277
|
-
result.isHosting === undefined //
|
|
278
|
-
result.trialExpired === true // a free
|
|
277
|
+
result.isHosting === undefined // in the basics: not in your plan
|
|
278
|
+
result.trialExpired === true // a free key past your organization's full answers for the day
|
|
279
|
+
'is_vpn' in result.raw // false when isVpn was not in the answer, whatever isVpn reads
|
|
279
280
|
result.capReached === true // a paid key past its overage cap
|
|
280
281
|
```
|
|
281
282
|
|
package/dist/client.d.ts
CHANGED
|
@@ -21,9 +21,11 @@ export interface CacheOptions {
|
|
|
21
21
|
}
|
|
22
22
|
export interface Options {
|
|
23
23
|
/**
|
|
24
|
-
* Your API key.
|
|
25
|
-
* `is_vpn`, the Tor and relay members,
|
|
26
|
-
*
|
|
24
|
+
* Your API key. Lookups need no key to try: the free plan answers each address's first
|
|
25
|
+
* lookups of the day without one, with `ip`, `is_vpn`, the Tor and relay members,
|
|
26
|
+
* `is_anycast`, `hostname`, `location` and `asn`. A free key answers your organization's first
|
|
27
|
+
* lookups each day with every field, then the same members without `is_vpn`, with no cap; a
|
|
28
|
+
* paid plan answers every field on every lookup. A batch needs a key on a paid plan.
|
|
27
29
|
* A key in a web page is readable by anyone who opens the page.
|
|
28
30
|
*/
|
|
29
31
|
apiKey?: string;
|
|
@@ -54,9 +56,9 @@ export interface CallOptions {
|
|
|
54
56
|
export interface LookupOptions extends CallOptions {
|
|
55
57
|
/**
|
|
56
58
|
* The `User-Agent` of the client that came from this address. With every field, on a paid
|
|
57
|
-
* plan or
|
|
58
|
-
* this address bears that out. The empty string sends none, and a longer
|
|
59
|
-
* 1024 characters is sent whole for the API to cut.
|
|
59
|
+
* plan or a free key's full answers, the answer's `userAgent` then names the agent it claims
|
|
60
|
+
* to be and whether this address bears that out. The empty string sends none, and a longer
|
|
61
|
+
* one than the API's 1024 characters is sent whole for the API to cut.
|
|
60
62
|
*/
|
|
61
63
|
userAgent?: string;
|
|
62
64
|
}
|
|
@@ -146,9 +148,10 @@ export declare class VPNDetection {
|
|
|
146
148
|
*
|
|
147
149
|
* Usage counts against the ALLOWANCE WINDOW - on a paid plan the
|
|
148
150
|
* anniversary of the subscription, not the calendar month and not the
|
|
149
|
-
* billing period, and on the free plan the
|
|
150
|
-
* number a lookup is gated on. It
|
|
151
|
-
* requests are counted in memory and
|
|
151
|
+
* billing period, and on the free plan the UTC day's lookups answered
|
|
152
|
+
* with every field - and it is the same number a lookup is gated on. It
|
|
153
|
+
* can lag by a few seconds, because requests are counted in memory and
|
|
154
|
+
* flushed in aggregate.
|
|
152
155
|
*
|
|
153
156
|
* Deliberately NOT cached: the whole point is what has been spent, and a
|
|
154
157
|
* cached answer is a wrong one within seconds of the next request.
|
package/dist/client.js
CHANGED
|
@@ -179,9 +179,10 @@ export class VPNDetection {
|
|
|
179
179
|
*
|
|
180
180
|
* Usage counts against the ALLOWANCE WINDOW - on a paid plan the
|
|
181
181
|
* anniversary of the subscription, not the calendar month and not the
|
|
182
|
-
* billing period, and on the free plan the
|
|
183
|
-
* number a lookup is gated on. It
|
|
184
|
-
* requests are counted in memory and
|
|
182
|
+
* billing period, and on the free plan the UTC day's lookups answered
|
|
183
|
+
* with every field - and it is the same number a lookup is gated on. It
|
|
184
|
+
* can lag by a few seconds, because requests are counted in memory and
|
|
185
|
+
* flushed in aggregate.
|
|
185
186
|
*
|
|
186
187
|
* Deliberately NOT cached: the whole point is what has been spent, and a
|
|
187
188
|
* cached answer is a wrong one within seconds of the next request.
|
|
@@ -396,8 +397,8 @@ function checkApiKey(apiKey) {
|
|
|
396
397
|
}
|
|
397
398
|
/**
|
|
398
399
|
* A cache size or TTL refused where it is set, `null` reading as unset. lru-cache
|
|
399
|
-
* reads a zero or NaN TTL as none, which would keep every answer for good, a
|
|
400
|
-
*
|
|
400
|
+
* reads a zero or NaN TTL as none, which would keep every answer for good, a free
|
|
401
|
+
* key's basics included, and a zero size as no bound; anything else not whole it throws
|
|
401
402
|
* a bare TypeError for.
|
|
402
403
|
*/
|
|
403
404
|
function checkCacheOption(name, value) {
|
|
@@ -17,9 +17,10 @@ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends
|
|
|
17
17
|
* Lookup
|
|
18
18
|
*
|
|
19
19
|
* Answers what is known about a single IPv4 or IPv6 address. Which fields
|
|
20
|
-
* come back is decided by the presented key; with no key, on
|
|
21
|
-
*
|
|
22
|
-
* `is_anycast`, `hostname`, `location` and `asn
|
|
20
|
+
* come back is decided by the presented key; with no key, on the free
|
|
21
|
+
* plan, the answer is `ip`, `is_vpn`, the Tor and relay members,
|
|
22
|
+
* `is_anycast`, `hostname`, `location` and `asn`; a free-plan key past its
|
|
23
|
+
* day's full answers gets the same without `is_vpn`.
|
|
23
24
|
*
|
|
24
25
|
*/
|
|
25
26
|
export declare const lookupIp: <ThrowOnError extends boolean = false>(options: Options<LookupIpData, ThrowOnError>) => RequestResult<LookupIpResponses, LookupIpErrors, ThrowOnError>;
|
|
@@ -51,16 +52,17 @@ export declare const lookupMyIp: <ThrowOnError extends boolean = false>(options?
|
|
|
51
52
|
* with the status and message the single lookup would have given, and
|
|
52
53
|
* never disturbs the others: a string that is not an address is a `400`
|
|
53
54
|
* there. An overage cap reached part way through answers the remaining
|
|
54
|
-
* entries with
|
|
55
|
+
* entries with the basics, `is_vpn` and `cap_reached` `true`, in `results`.
|
|
55
56
|
*
|
|
56
57
|
* The call itself fails only for the reasons below, and a `429` on the
|
|
57
|
-
* call
|
|
58
|
-
*
|
|
58
|
+
* call carries `Retry-After` unless a lookup with no key is past its
|
|
59
|
+
* address's daily allowance: the batch is admitted or refused whole,
|
|
60
|
+
* never per entry.
|
|
59
61
|
*
|
|
60
62
|
* A batch needs a paid plan: without a key the call is refused with `401`,
|
|
61
63
|
* and with a key on the free plan with `402`, unless it names one address,
|
|
62
64
|
* which is answered as `GET /{ip}` would answer it, under the same rate
|
|
63
|
-
* limit.
|
|
65
|
+
* limit. The free plan looks up one address at a time.
|
|
64
66
|
*
|
|
65
67
|
*/
|
|
66
68
|
export declare const lookupBatch: <ThrowOnError extends boolean = false>(options: Options<LookupBatchData, ThrowOnError>) => RequestResult<LookupBatchResponses, LookupBatchErrors, ThrowOnError>;
|
|
@@ -5,9 +5,10 @@ import { urlSearchParamsBodySerializer } from './client/index.js';
|
|
|
5
5
|
* Lookup
|
|
6
6
|
*
|
|
7
7
|
* Answers what is known about a single IPv4 or IPv6 address. Which fields
|
|
8
|
-
* come back is decided by the presented key; with no key, on
|
|
9
|
-
*
|
|
10
|
-
* `is_anycast`, `hostname`, `location` and `asn
|
|
8
|
+
* come back is decided by the presented key; with no key, on the free
|
|
9
|
+
* plan, the answer is `ip`, `is_vpn`, the Tor and relay members,
|
|
10
|
+
* `is_anycast`, `hostname`, `location` and `asn`; a free-plan key past its
|
|
11
|
+
* day's full answers gets the same without `is_vpn`.
|
|
11
12
|
*
|
|
12
13
|
*/
|
|
13
14
|
export const lookupIp = (options) => (options.client ?? client).get({
|
|
@@ -63,16 +64,17 @@ export const lookupMyIp = (options) => (options?.client ?? client).get({
|
|
|
63
64
|
* with the status and message the single lookup would have given, and
|
|
64
65
|
* never disturbs the others: a string that is not an address is a `400`
|
|
65
66
|
* there. An overage cap reached part way through answers the remaining
|
|
66
|
-
* entries with
|
|
67
|
+
* entries with the basics, `is_vpn` and `cap_reached` `true`, in `results`.
|
|
67
68
|
*
|
|
68
69
|
* The call itself fails only for the reasons below, and a `429` on the
|
|
69
|
-
* call
|
|
70
|
-
*
|
|
70
|
+
* call carries `Retry-After` unless a lookup with no key is past its
|
|
71
|
+
* address's daily allowance: the batch is admitted or refused whole,
|
|
72
|
+
* never per entry.
|
|
71
73
|
*
|
|
72
74
|
* A batch needs a paid plan: without a key the call is refused with `401`,
|
|
73
75
|
* and with a key on the free plan with `402`, unless it names one address,
|
|
74
76
|
* which is answered as `GET /{ip}` would answer it, under the same rate
|
|
75
|
-
* limit.
|
|
77
|
+
* limit. The free plan looks up one address at a time.
|
|
76
78
|
*
|
|
77
79
|
*/
|
|
78
80
|
export const lookupBatch = (options) => (options.client ?? client).post({
|
|
@@ -3,8 +3,9 @@ export type ClientOptions = {
|
|
|
3
3
|
};
|
|
4
4
|
/**
|
|
5
5
|
* The union of every tier's answer. Every answer carries `ip`, `is_bogon`,
|
|
6
|
-
*
|
|
7
|
-
* `asn`, with or without a key
|
|
6
|
+
* the Tor and relay members, `is_anycast`, `hostname`, `location` and
|
|
7
|
+
* `asn`, with or without a key, and `is_vpn` all but a free-plan key's past
|
|
8
|
+
* its day's full answers;
|
|
8
9
|
* each remaining field is present when your tier includes it, and absent
|
|
9
10
|
* otherwise. A client that must work across plans should treat an absent
|
|
10
11
|
* flag as unknown rather than as `false`.
|
|
@@ -25,10 +26,11 @@ export type LookupResponse = {
|
|
|
25
26
|
/**
|
|
26
27
|
* Whether the address is VPN infrastructure. Keys off presence in the
|
|
27
28
|
* VPN dataset, so an unattributed range with no provider is still
|
|
28
|
-
* `true`.
|
|
29
|
+
* `true`. Absent from a free-plan key's answer past its day's full
|
|
30
|
+
* answers.
|
|
29
31
|
*
|
|
30
32
|
*/
|
|
31
|
-
is_vpn
|
|
33
|
+
is_vpn?: boolean;
|
|
32
34
|
/**
|
|
33
35
|
* Whether the address belongs to a hosting or cloud provider. On a paid plan.
|
|
34
36
|
*/
|
|
@@ -46,7 +48,7 @@ export type LookupResponse = {
|
|
|
46
48
|
*/
|
|
47
49
|
is_cdn?: boolean;
|
|
48
50
|
/**
|
|
49
|
-
* Whether an automated client uses the address, such as a search engine's or an AI company's crawler, an uptime monitor, an internet scanner or a webhook sender. `bot` says whose, what it does and whether its operator vouches for the address.
|
|
51
|
+
* Whether an automated client uses the address, such as a search engine's or an AI company's crawler, an uptime monitor, an internet scanner or a webhook sender. `bot` says whose, what it does and whether its operator vouches for the address. On a paid plan.
|
|
50
52
|
*/
|
|
51
53
|
is_bot?: boolean;
|
|
52
54
|
/**
|
|
@@ -185,15 +187,15 @@ export type LookupResponse = {
|
|
|
185
187
|
user_agent?: UserAgentVerdict;
|
|
186
188
|
/**
|
|
187
189
|
* On every answer to a key on the free plan, and on no other: `false`
|
|
188
|
-
* while its organization's
|
|
189
|
-
* answer has
|
|
190
|
+
* while its organization's lookups of the UTC day answer every field,
|
|
191
|
+
* `true` once those are used up and the answer has the basics.
|
|
190
192
|
*
|
|
191
193
|
*/
|
|
192
194
|
trial_expired?: boolean;
|
|
193
195
|
/**
|
|
194
196
|
* On every answer to a key on a paid plan, and on no other: `false`
|
|
195
197
|
* while the answer has every field, `true` once its organization's
|
|
196
|
-
* overage cap is reached and the answer has
|
|
198
|
+
* overage cap is reached and the answer has the basics and `is_vpn`. Lookups
|
|
197
199
|
* answered past the cap are not billed; raising or removing the cap in
|
|
198
200
|
* Billing turns it `false` again.
|
|
199
201
|
*
|
|
@@ -352,9 +354,11 @@ export type ProxyDetail = {
|
|
|
352
354
|
*/
|
|
353
355
|
hits?: number;
|
|
354
356
|
/**
|
|
355
|
-
* The
|
|
356
|
-
* as of its last day in it once it
|
|
357
|
-
*
|
|
357
|
+
* The highest share of the window's days, in percent, on which any
|
|
358
|
+
* one proxy network saw the address, as of its last day in it once it
|
|
359
|
+
* has left. An address several networks share reads its busiest
|
|
360
|
+
* network's share, not the days they saw it on together. A high value
|
|
361
|
+
* means a stable pool member rather than a one-off sighting.
|
|
358
362
|
*
|
|
359
363
|
*/
|
|
360
364
|
hits_days_pct?: number;
|
|
@@ -527,9 +531,9 @@ export type Asn = {
|
|
|
527
531
|
*/
|
|
528
532
|
domain: string;
|
|
529
533
|
/**
|
|
530
|
-
* The kind of network the AS runs: isp, hosting, education, government or business.
|
|
534
|
+
* The kind of network the AS runs: isp, hosting, education, government or business. On a paid plan.
|
|
531
535
|
*/
|
|
532
|
-
type
|
|
536
|
+
type?: string;
|
|
533
537
|
/**
|
|
534
538
|
* The announced BGP prefix that covers the address, the most specific when several do.
|
|
535
539
|
*/
|
|
@@ -979,14 +983,14 @@ export type EntitlementPlan = {
|
|
|
979
983
|
/**
|
|
980
984
|
* The plan the organization is on, as an identifier that is never
|
|
981
985
|
* renamed or reused: `free` for the free plan, or a paid plan's key.
|
|
982
|
-
* Compare against it and show `name`. On `free`, usage counts
|
|
983
|
-
*
|
|
984
|
-
* per quota
|
|
986
|
+
* Compare against it and show `name`. On `free`, usage counts the UTC
|
|
987
|
+
* day's lookups answered with every field. The Data plan is a key
|
|
988
|
+
* per quota (`data_1`, `data_2` and on), each named Data.
|
|
985
989
|
*
|
|
986
990
|
*/
|
|
987
991
|
key: string;
|
|
988
992
|
/**
|
|
989
|
-
* The plan's name, as the site and console show it: `
|
|
993
|
+
* The plan's name, as the site and console show it: `Free` for
|
|
990
994
|
* the free plan. Show this rather than a name built from `key`: a
|
|
991
995
|
* plan's name can change, and its key never does.
|
|
992
996
|
*
|
|
@@ -1015,7 +1019,7 @@ export type EntitlementUsage = {
|
|
|
1015
1019
|
quota: number;
|
|
1016
1020
|
/**
|
|
1017
1021
|
* Where full answers stop: past it, a paid key is answered with
|
|
1018
|
-
*
|
|
1022
|
+
* the basics, `is_vpn` and `cap_reached: true`, uncharged, until the
|
|
1019
1023
|
* window ends or the cap is raised. NULL means never, which is the
|
|
1020
1024
|
* normal state of an uncapped paid plan and is not the same as zero.
|
|
1021
1025
|
* Above the quota and below this, requests are served and billed as
|
|
@@ -1024,14 +1028,14 @@ export type EntitlementUsage = {
|
|
|
1024
1028
|
*/
|
|
1025
1029
|
hard_limit: number | null;
|
|
1026
1030
|
/**
|
|
1027
|
-
* When the current allowance period began. On the free plan,
|
|
1028
|
-
*
|
|
1031
|
+
* When the current allowance period began. On the free plan, the
|
|
1032
|
+
* start of the UTC day.
|
|
1029
1033
|
*
|
|
1030
1034
|
*/
|
|
1031
1035
|
window_start: string;
|
|
1032
1036
|
/**
|
|
1033
|
-
* When the allowance next resets. On the free plan,
|
|
1034
|
-
*
|
|
1037
|
+
* When the allowance next resets. On the free plan, the start of the
|
|
1038
|
+
* next UTC day.
|
|
1035
1039
|
*
|
|
1036
1040
|
*/
|
|
1037
1041
|
window_end: string;
|
|
@@ -1164,7 +1168,7 @@ export type LookupIpData = {
|
|
|
1164
1168
|
query?: {
|
|
1165
1169
|
/**
|
|
1166
1170
|
* The `User-Agent` header of the request you are deciding on. With
|
|
1167
|
-
* every field, on a paid plan or
|
|
1171
|
+
* every field, on a paid plan or a free key's full answers, the answer then carries
|
|
1168
1172
|
* `user_agent`: the agent it names, and whether this address bears
|
|
1169
1173
|
* that out. Never kept, and nothing sent with a lookup feeds our data.
|
|
1170
1174
|
*
|
|
@@ -1192,9 +1196,11 @@ export type LookupIpErrors = {
|
|
|
1192
1196
|
*/
|
|
1193
1197
|
403: LookupError;
|
|
1194
1198
|
/**
|
|
1195
|
-
* A rate limit
|
|
1196
|
-
*
|
|
1197
|
-
*
|
|
1199
|
+
* A rate limit with `Retry-After`, or without it a lookup with no key
|
|
1200
|
+
* past its address's daily allowance, which a free API key answers past.
|
|
1201
|
+
* A paid plan's overage cap is never a `429` by itself: it answers `200`
|
|
1202
|
+
* with the basics, `is_vpn` and `cap_reached` `true`, and a burst past it is
|
|
1203
|
+
* rate limited as a free one is.
|
|
1198
1204
|
*
|
|
1199
1205
|
*/
|
|
1200
1206
|
429: LookupError;
|
|
@@ -1219,7 +1225,7 @@ export type LookupMyIpData = {
|
|
|
1219
1225
|
query?: {
|
|
1220
1226
|
/**
|
|
1221
1227
|
* The `User-Agent` header of the request you are deciding on. With
|
|
1222
|
-
* every field, on a paid plan or
|
|
1228
|
+
* every field, on a paid plan or a free key's full answers, the answer then carries
|
|
1223
1229
|
* `user_agent`: the agent it names, and whether this address bears
|
|
1224
1230
|
* that out. Never kept, and nothing sent with a lookup feeds our data.
|
|
1225
1231
|
*
|
|
@@ -1243,9 +1249,11 @@ export type LookupMyIpErrors = {
|
|
|
1243
1249
|
*/
|
|
1244
1250
|
403: LookupError;
|
|
1245
1251
|
/**
|
|
1246
|
-
* A rate limit
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1252
|
+
* A rate limit with `Retry-After`, or without it a lookup with no key
|
|
1253
|
+
* past its address's daily allowance, which a free API key answers past.
|
|
1254
|
+
* A paid plan's overage cap is never a `429` by itself: it answers `200`
|
|
1255
|
+
* with the basics, `is_vpn` and `cap_reached` `true`, and a burst past it is
|
|
1256
|
+
* rate limited as a free one is.
|
|
1249
1257
|
*
|
|
1250
1258
|
*/
|
|
1251
1259
|
429: LookupError;
|
|
@@ -1301,9 +1309,11 @@ export type LookupBatchErrors = {
|
|
|
1301
1309
|
*/
|
|
1302
1310
|
413: LookupError;
|
|
1303
1311
|
/**
|
|
1304
|
-
* The rate limit refused the whole call
|
|
1305
|
-
*
|
|
1306
|
-
*
|
|
1312
|
+
* The rate limit refused the whole call, transient and with
|
|
1313
|
+
* `Retry-After`, or a batch of one address with no key is past its
|
|
1314
|
+
* address's daily allowance, without it; a reached overage cap answers
|
|
1315
|
+
* each entry in a `200` instead, and a burst past it is rate limited as
|
|
1316
|
+
* a free one is.
|
|
1307
1317
|
*
|
|
1308
1318
|
*/
|
|
1309
1319
|
429: LookupError;
|
|
@@ -1348,7 +1358,12 @@ export type MyEntitlementErrors = {
|
|
|
1348
1358
|
export type MyEntitlementError = MyEntitlementErrors[keyof MyEntitlementErrors];
|
|
1349
1359
|
export type MyEntitlementResponses = {
|
|
1350
1360
|
/**
|
|
1351
|
-
* The key's entitlements and consumption.
|
|
1361
|
+
* The key's entitlements and consumption. On the free plan, Free,
|
|
1362
|
+
* usage is the UTC day's lookups answered with every field, against
|
|
1363
|
+
* its daily limit, and no hard limit, since nothing stops a lookup past
|
|
1364
|
+
* it: the basics have no cap. The daily limit is on the pricing
|
|
1365
|
+
* page, never fixed here.
|
|
1366
|
+
*
|
|
1352
1367
|
*/
|
|
1353
1368
|
200: Entitlement;
|
|
1354
1369
|
};
|
package/dist/shapes.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export declare const LOOKUP_MEMBERS: readonly ["ip"
|
|
1
|
+
export declare const LOOKUP_MEMBERS: readonly ["ip"];
|
|
2
|
+
export declare const LOOKUP_NOT_NULL: readonly ["is_vpn"];
|
|
2
3
|
export declare const LOCATION_MEMBERS: readonly ["continent", "continent_name", "country", "country_name", "timezone", "currency_code", "currency_name", "currency_symbol", "flag_emoji", "flag_unicode"];
|
|
3
|
-
export declare const ASN_MEMBERS: readonly ["asn", "name", "domain", "
|
|
4
|
+
export declare const ASN_MEMBERS: readonly ["asn", "name", "domain", "prefix", "country", "rpki_status"];
|
|
5
|
+
export declare const ASN_NOT_NULL: readonly ["type"];
|
|
4
6
|
export declare const COMPANY_MEMBERS: readonly ["name", "domain"];
|
|
5
7
|
export declare const ABUSE_CONTACT_MEMBERS: readonly ["email"];
|
|
6
8
|
export declare const WEB_DETAIL_MEMBERS: readonly ["port", "tls_ok", "session_ok", "status_code", "server", "location", "title", "cert_subject_cn", "cert_subject_o", "cert_issuer_dn", "cert_browser_trusted", "tls_version", "first_seen", "last_seen"];
|
package/dist/shapes.js
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
// the spec requires and never sends as null. The tests read them against the
|
|
3
3
|
// generated types, so a member the spec adds fails the suite until it is here.
|
|
4
4
|
import { hasMembers } from './transport.js';
|
|
5
|
-
export const LOOKUP_MEMBERS = ['ip'
|
|
5
|
+
export const LOOKUP_MEMBERS = ['ip'];
|
|
6
|
+
// A member an answer may omit and may never send as null: the spec required `is_vpn` until 2026.11.28,
|
|
7
|
+
// and a free key past its organization's full answers for the day gets the basics without it.
|
|
8
|
+
export const LOOKUP_NOT_NULL = ['is_vpn'];
|
|
6
9
|
export const LOCATION_MEMBERS = [
|
|
7
10
|
'continent', 'continent_name', 'country', 'country_name', 'timezone', 'currency_code', 'currency_name',
|
|
8
11
|
'currency_symbol', 'flag_emoji', 'flag_unicode',
|
|
9
12
|
];
|
|
10
|
-
export const ASN_MEMBERS = ['asn', 'name', 'domain', '
|
|
13
|
+
export const ASN_MEMBERS = ['asn', 'name', 'domain', 'prefix', 'country', 'rpki_status'];
|
|
14
|
+
// A paid plan's member, which an answer may omit and may never send as null: the spec required it until 2026.11.26.
|
|
15
|
+
export const ASN_NOT_NULL = ['type'];
|
|
11
16
|
export const COMPANY_MEMBERS = ['name', 'domain'];
|
|
12
17
|
export const ABUSE_CONTACT_MEMBERS = ['email'];
|
|
13
18
|
export const WEB_DETAIL_MEMBERS = [
|
|
@@ -149,10 +154,17 @@ function isDay(year, month, day) {
|
|
|
149
154
|
return date.getUTCFullYear() === Number(year) && date.getUTCMonth() === Number(month) - 1
|
|
150
155
|
&& date.getUTCDate() === Number(day);
|
|
151
156
|
}
|
|
152
|
-
|
|
157
|
+
// A member in `notNull` may be absent but never null, as one the spec once required.
|
|
158
|
+
function typed(value, required, types, notNull = []) {
|
|
153
159
|
return hasMembers(value, required) && Object.entries(types).every(([member, kind]) => {
|
|
154
160
|
const v = value[member];
|
|
155
|
-
|
|
161
|
+
if (v === undefined) {
|
|
162
|
+
return !required.includes(member);
|
|
163
|
+
}
|
|
164
|
+
if (v === null) {
|
|
165
|
+
return !required.includes(member) && !notNull.includes(member);
|
|
166
|
+
}
|
|
167
|
+
return isKind(v, kind);
|
|
156
168
|
});
|
|
157
169
|
}
|
|
158
170
|
function every(value, valid) {
|
|
@@ -177,20 +189,20 @@ const DETAILS = [
|
|
|
177
189
|
['bittorrent', BITTORRENT_DETAIL_TYPES], ['bot', BOT_DETAIL_TYPES],
|
|
178
190
|
];
|
|
179
191
|
const SHARED = [
|
|
180
|
-
['location', LOCATION_MEMBERS, LOCATION_TYPES],
|
|
181
|
-
['asn', ASN_MEMBERS, ASN_TYPES],
|
|
182
|
-
['company', COMPANY_MEMBERS, COMPANY_TYPES],
|
|
183
|
-
['abuse', ABUSE_CONTACT_MEMBERS, ABUSE_CONTACT_TYPES],
|
|
184
|
-
['user_agent', USER_AGENT_MEMBERS, USER_AGENT_TYPES],
|
|
192
|
+
['location', LOCATION_MEMBERS, LOCATION_TYPES, []],
|
|
193
|
+
['asn', ASN_MEMBERS, ASN_TYPES, ASN_NOT_NULL],
|
|
194
|
+
['company', COMPANY_MEMBERS, COMPANY_TYPES, []],
|
|
195
|
+
['abuse', ABUSE_CONTACT_MEMBERS, ABUSE_CONTACT_TYPES, []],
|
|
196
|
+
['user_agent', USER_AGENT_MEMBERS, USER_AGENT_TYPES, []],
|
|
185
197
|
];
|
|
186
198
|
export function isLookup(data) {
|
|
187
|
-
return typed(data, LOOKUP_MEMBERS, LOOKUP_TYPES)
|
|
199
|
+
return typed(data, LOOKUP_MEMBERS, LOOKUP_TYPES, LOOKUP_NOT_NULL)
|
|
188
200
|
&& DETAILS.every(([member, types]) => optional(data[member], (detail) => typed(detail, [], types)))
|
|
189
201
|
&& optional(data['pubproxy'], (pubproxy) => lists(pubproxy, 'protocols', isString))
|
|
190
202
|
&& optional(data['bittorrent'], (bittorrent) => lists(bittorrent, 'clients', isString))
|
|
191
203
|
&& optional(data['bot'], (bot) => lists(bot, 'agents', isString) && lists(bot, 'categories', isString))
|
|
192
204
|
&& optional(data['web'], (web) => every(web, (row) => typed(row, WEB_DETAIL_MEMBERS, WEB_DETAIL_TYPES)))
|
|
193
|
-
&& SHARED.every(([member, required, types]) => optional(data[member], (o) => typed(o, required, types)));
|
|
205
|
+
&& SHARED.every(([member, required, types, notNull]) => optional(data[member], (o) => typed(o, required, types, notNull)));
|
|
194
206
|
}
|
|
195
207
|
/** Both maps present. An entry in either is judged on its own, as that address's answer. */
|
|
196
208
|
export function isBatch(data) {
|
package/dist/store.d.ts
CHANGED
|
@@ -33,8 +33,9 @@ export declare class StoreTier {
|
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* How long an answer stays cached: the TTL, or at most a minute for one marked
|
|
36
|
-
* `trialExpired` or `capReached`, which
|
|
37
|
-
* cached, so a busy page past its
|
|
36
|
+
* `trialExpired` or `capReached`, which can change as soon as the organization's
|
|
37
|
+
* UTC day, plan or cap does. Still cached, so a busy page past its day's full answers
|
|
38
|
+
* does not send every repeat to the API.
|
|
38
39
|
*/
|
|
39
40
|
export declare function lifeMs(result: Result, ttlMs: number): number;
|
|
40
41
|
/**
|
package/dist/store.js
CHANGED
|
@@ -46,8 +46,9 @@ export class StoreTier {
|
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* How long an answer stays cached: the TTL, or at most a minute for one marked
|
|
49
|
-
* `trialExpired` or `capReached`, which
|
|
50
|
-
* cached, so a busy page past its
|
|
49
|
+
* `trialExpired` or `capReached`, which can change as soon as the organization's
|
|
50
|
+
* UTC day, plan or cap does. Still cached, so a busy page past its day's full answers
|
|
51
|
+
* does not send every repeat to the API.
|
|
51
52
|
*/
|
|
52
53
|
export function lifeMs(result, ttlMs) {
|
|
53
54
|
if (result.trialExpired === true || result.capReached === true) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import type { AbuseContact, Asn as WireAsn, BitTorrentDetail, BotDetail, CarrierDetail, ClassDetail, Company, DnsResolverDetail, Location, LookupResponse as WireLookupResponse, ProxyDetail, PubproxyDetail, SatelliteDetail, SmtpDetail, SshDetail, UserAgentVerdict, VpnDetail, WebDetail } from './generated/types.gen.js';
|
|
2
2
|
export type { AbuseContact, BitTorrentDetail, BotDetail, CarrierDetail, ClassDetail, Company, DnsResolverDetail, Location, ProxyDetail, PubproxyDetail, SatelliteDetail, SmtpDetail, SshDetail, UserAgentVerdict, VpnDetail, WebDetail, };
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The AS announcing an address. Every answer carries `country` and `rpki_status`. `type` is a
|
|
5
|
+
* paid plan's, and a free key's full answers': the basics omit it, so it is an empty string in a
|
|
6
|
+
* `Result`'s `asn` and absent from `raw.asn`, which holds what was served.
|
|
7
|
+
*/
|
|
8
|
+
export type Asn = Omit<WireAsn, 'country' | 'rpki_status' | 'type'> & Partial<Pick<WireAsn, 'country' | 'rpki_status'>> & Required<Pick<WireAsn, 'type'>>;
|
|
9
|
+
/**
|
|
10
|
+
* A lookup's answer as it came off the wire. `is_vpn` is absent from a free key's answer past its
|
|
11
|
+
* organization's full answers for the day, when `trial_expired` is true, though it is typed `boolean`
|
|
12
|
+
* as it was: `Result.isVpn` reads `false` then, and `raw` shows it was not served.
|
|
13
|
+
*/
|
|
14
|
+
export type LookupResponse = Omit<WireLookupResponse, 'asn' | 'is_vpn'> & {
|
|
7
15
|
asn?: Asn;
|
|
16
|
+
is_vpn: boolean;
|
|
8
17
|
};
|
|
9
18
|
/**
|
|
10
19
|
* What a lookup answers.
|
|
@@ -13,7 +22,9 @@ export type LookupResponse = Omit<WireLookupResponse, 'asn'> & {
|
|
|
13
22
|
* could not check", so `undefined` and `false` are genuinely different answers:
|
|
14
23
|
* `undefined` is "not in your plan", `false` is "checked, and no". Use
|
|
15
24
|
* `?? false` when you only care whether the address is flagged. The same holds
|
|
16
|
-
* inside `location` and `asn`, whose paid members are absent
|
|
25
|
+
* inside `location` and `asn`, whose paid members are absent from the basics, bar `asn.type`: its
|
|
26
|
+
* type is `string`, so it reads as an empty string there. `isVpn` is typed the same way, and reads
|
|
27
|
+
* `false` where the answer has no `is_vpn`.
|
|
17
28
|
*
|
|
18
29
|
* A detail object that is present but empty (`{}`, and `web`'s `[]`) means the
|
|
19
30
|
* flag above it is false. A populated one always carries every one of its keys.
|
|
@@ -21,7 +32,12 @@ export type LookupResponse = Omit<WireLookupResponse, 'asn'> & {
|
|
|
21
32
|
export interface Result {
|
|
22
33
|
/** The address that was looked up, normalized. */
|
|
23
34
|
ip: string;
|
|
24
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Whether the address is VPN infrastructure. Every answer carries this but one: a free key's
|
|
37
|
+
* answer past its organization's full answers for the day, when `trialExpired` is true, leaves
|
|
38
|
+
* it out. It reads `false` there, which means "not in this answer", never "not a VPN", and
|
|
39
|
+
* `raw.is_vpn` is absent.
|
|
40
|
+
*/
|
|
25
41
|
isVpn: boolean;
|
|
26
42
|
/**
|
|
27
43
|
* Whether the address is reserved space (private, loopback, documentation and the like), which
|
|
@@ -47,18 +63,20 @@ export interface Result {
|
|
|
47
63
|
isBittorrent?: boolean;
|
|
48
64
|
/**
|
|
49
65
|
* Whether an automated client uses the address, such as a search engine's or an AI company's
|
|
50
|
-
* crawler, an uptime monitor or a webhook sender.
|
|
66
|
+
* crawler, an uptime monitor or a webhook sender. On a paid plan or a free key's full answers:
|
|
67
|
+
* absent from the basics. `bot` says whose.
|
|
51
68
|
*/
|
|
52
69
|
isBot?: boolean;
|
|
53
70
|
/**
|
|
54
|
-
* On answers to a key on the free plan only: `false` while its organization's
|
|
55
|
-
* field
|
|
71
|
+
* On answers to a key on the free plan only: `false` while its organization's lookups of the
|
|
72
|
+
* UTC day answer every field, `true` once those are used up and the answer has the basics,
|
|
73
|
+
* without `isVpn`.
|
|
56
74
|
*/
|
|
57
75
|
trialExpired?: boolean;
|
|
58
76
|
/**
|
|
59
77
|
* On answers to a key on a paid plan only: `false` while the answer has every field, `true`
|
|
60
|
-
* once its organization's overage cap is reached and the answer has
|
|
61
|
-
* answered past the cap are not billed.
|
|
78
|
+
* once its organization's overage cap is reached and the answer has the basics and `isVpn`.
|
|
79
|
+
* Lookups answered past the cap are not billed.
|
|
62
80
|
*/
|
|
63
81
|
capReached?: boolean;
|
|
64
82
|
vpn?: VpnDetail;
|
|
@@ -97,7 +115,8 @@ export interface Result {
|
|
|
97
115
|
location?: Location;
|
|
98
116
|
/**
|
|
99
117
|
* The AS announcing the address, on every answer, with or without a key: `asn` is 0 where none
|
|
100
|
-
* does. `country` and `rpki_status` are on every plan too
|
|
118
|
+
* does. `country` and `rpki_status` are on every plan too; `type` is a paid plan's, an empty
|
|
119
|
+
* string in the basics.
|
|
101
120
|
*/
|
|
102
121
|
asn?: Asn;
|
|
103
122
|
/** The organization the address is assigned to. */
|
|
@@ -112,4 +131,4 @@ export interface Result {
|
|
|
112
131
|
/** The response exactly as it came off the wire, with its original names. */
|
|
113
132
|
raw: LookupResponse;
|
|
114
133
|
}
|
|
115
|
-
export declare function toResult(body:
|
|
134
|
+
export declare function toResult(body: WireLookupResponse): Result;
|
package/dist/types.js
CHANGED
|
@@ -20,6 +20,16 @@ export function toResult(body) {
|
|
|
20
20
|
out[to] = body[from];
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
// `Asn.type` keeps its `string`: the spec stopped requiring it and the basics omit it, so
|
|
24
|
+
// an absent one reads as empty here, in a copy that leaves `raw.asn` as served.
|
|
25
|
+
if (body.asn !== undefined && body.asn.type === undefined) {
|
|
26
|
+
out['asn'] = { ...body.asn, type: '' };
|
|
27
|
+
}
|
|
28
|
+
// `isVpn` keeps its `boolean` the same way: a free key past its day's full answers gets no `is_vpn`,
|
|
29
|
+
// which reads `false` here while `raw` shows it was not served.
|
|
30
|
+
if (body.is_vpn === undefined) {
|
|
31
|
+
out['isVpn'] = false;
|
|
32
|
+
}
|
|
23
33
|
out['isBogon'] = body.is_bogon === true;
|
|
24
34
|
out['raw'] = body;
|
|
25
35
|
return out;
|
package/package.json
CHANGED