vpndetection-web 1.8.1 → 1.9.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 +3 -3
- package/dist/generated/types.gen.d.ts +3 -3
- package/dist/shapes.d.ts +2 -1
- package/dist/shapes.js +18 -9
- package/dist/types.d.ts +13 -6
- package/dist/types.js +5 -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
|
-
**No API key needed to start.** Unlimited, the free plan, answers `ip`, `is_vpn`, Tor and relay detection, `
|
|
33
|
+
**No API key needed to start.** Unlimited, the free plan, answers `ip`, `is_vpn`, Tor and relay detection, `is_anycast`, `hostname` (the reverse DNS name), country-level `location` and `asn` with the AS's country and RPKI status, with no daily or monthly cap, with a key or without one. 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 account tries every field. Create a key in the [console](https://app.vpndetection.io), then pass it in:
|
|
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 account tries 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' });
|
|
@@ -270,7 +270,7 @@ 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
|
-
Unlimited 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 free-plan key's answer carries `trialExpired`, true once its trial is spent, and a paid key's carries `capReached`, true once its organization's overage cap is reached and the answer has Unlimited's. A field your key does not include is `undefined`, which means "not in your plan" rather than "checked, and no".
|
|
273
|
+
Unlimited leaves 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 it answers only Tor's and relay's; it leaves 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-plan key's answer carries `trialExpired`, true once its trial is spent, and a paid key's carries `capReached`, true once its organization's overage cap is reached and the answer has Unlimited's. 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
|
|
@@ -46,7 +46,7 @@ export type LookupResponse = {
|
|
|
46
46
|
*/
|
|
47
47
|
is_cdn?: boolean;
|
|
48
48
|
/**
|
|
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.
|
|
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. On a paid plan.
|
|
50
50
|
*/
|
|
51
51
|
is_bot?: boolean;
|
|
52
52
|
/**
|
|
@@ -527,9 +527,9 @@ export type Asn = {
|
|
|
527
527
|
*/
|
|
528
528
|
domain: string;
|
|
529
529
|
/**
|
|
530
|
-
* The kind of network the AS runs: isp, hosting, education, government or business.
|
|
530
|
+
* The kind of network the AS runs: isp, hosting, education, government or business. On a paid plan.
|
|
531
531
|
*/
|
|
532
|
-
type
|
|
532
|
+
type?: string;
|
|
533
533
|
/**
|
|
534
534
|
* The announced BGP prefix that covers the address, the most specific when several do.
|
|
535
535
|
*/
|
package/dist/shapes.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const LOOKUP_MEMBERS: readonly ["ip", "is_vpn"];
|
|
2
2
|
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", "
|
|
3
|
+
export declare const ASN_MEMBERS: readonly ["asn", "name", "domain", "prefix", "country", "rpki_status"];
|
|
4
|
+
export declare const ASN_NOT_NULL: readonly ["type"];
|
|
4
5
|
export declare const COMPANY_MEMBERS: readonly ["name", "domain"];
|
|
5
6
|
export declare const ABUSE_CONTACT_MEMBERS: readonly ["email"];
|
|
6
7
|
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
|
@@ -7,7 +7,9 @@ export const LOCATION_MEMBERS = [
|
|
|
7
7
|
'continent', 'continent_name', 'country', 'country_name', 'timezone', 'currency_code', 'currency_name',
|
|
8
8
|
'currency_symbol', 'flag_emoji', 'flag_unicode',
|
|
9
9
|
];
|
|
10
|
-
export const ASN_MEMBERS = ['asn', 'name', 'domain', '
|
|
10
|
+
export const ASN_MEMBERS = ['asn', 'name', 'domain', 'prefix', 'country', 'rpki_status'];
|
|
11
|
+
// A paid plan's member, which an answer may omit and may never send as null: the spec required it until 2026.11.26.
|
|
12
|
+
export const ASN_NOT_NULL = ['type'];
|
|
11
13
|
export const COMPANY_MEMBERS = ['name', 'domain'];
|
|
12
14
|
export const ABUSE_CONTACT_MEMBERS = ['email'];
|
|
13
15
|
export const WEB_DETAIL_MEMBERS = [
|
|
@@ -149,10 +151,17 @@ function isDay(year, month, day) {
|
|
|
149
151
|
return date.getUTCFullYear() === Number(year) && date.getUTCMonth() === Number(month) - 1
|
|
150
152
|
&& date.getUTCDate() === Number(day);
|
|
151
153
|
}
|
|
152
|
-
|
|
154
|
+
// A member in `notNull` may be absent but never null, as one the spec once required.
|
|
155
|
+
function typed(value, required, types, notNull = []) {
|
|
153
156
|
return hasMembers(value, required) && Object.entries(types).every(([member, kind]) => {
|
|
154
157
|
const v = value[member];
|
|
155
|
-
|
|
158
|
+
if (v === undefined) {
|
|
159
|
+
return !required.includes(member);
|
|
160
|
+
}
|
|
161
|
+
if (v === null) {
|
|
162
|
+
return !required.includes(member) && !notNull.includes(member);
|
|
163
|
+
}
|
|
164
|
+
return isKind(v, kind);
|
|
156
165
|
});
|
|
157
166
|
}
|
|
158
167
|
function every(value, valid) {
|
|
@@ -177,11 +186,11 @@ const DETAILS = [
|
|
|
177
186
|
['bittorrent', BITTORRENT_DETAIL_TYPES], ['bot', BOT_DETAIL_TYPES],
|
|
178
187
|
];
|
|
179
188
|
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],
|
|
189
|
+
['location', LOCATION_MEMBERS, LOCATION_TYPES, []],
|
|
190
|
+
['asn', ASN_MEMBERS, ASN_TYPES, ASN_NOT_NULL],
|
|
191
|
+
['company', COMPANY_MEMBERS, COMPANY_TYPES, []],
|
|
192
|
+
['abuse', ABUSE_CONTACT_MEMBERS, ABUSE_CONTACT_TYPES, []],
|
|
193
|
+
['user_agent', USER_AGENT_MEMBERS, USER_AGENT_TYPES, []],
|
|
185
194
|
];
|
|
186
195
|
export function isLookup(data) {
|
|
187
196
|
return typed(data, LOOKUP_MEMBERS, LOOKUP_TYPES)
|
|
@@ -190,7 +199,7 @@ export function isLookup(data) {
|
|
|
190
199
|
&& optional(data['bittorrent'], (bittorrent) => lists(bittorrent, 'clients', isString))
|
|
191
200
|
&& optional(data['bot'], (bot) => lists(bot, 'agents', isString) && lists(bot, 'categories', isString))
|
|
192
201
|
&& 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)));
|
|
202
|
+
&& SHARED.every(([member, required, types, notNull]) => optional(data[member], (o) => typed(o, required, types, notNull)));
|
|
194
203
|
}
|
|
195
204
|
/** Both maps present. An entry in either is judged on its own, as that address's answer. */
|
|
196
205
|
export function isBatch(data) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
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
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The AS announcing an address. Every answer carries `country` and `rpki_status`. `type` is a
|
|
5
|
+
* paid plan's: an Unlimited answer omits it, so it is an empty string in a `Result`'s `asn` and
|
|
6
|
+
* 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'>>;
|
|
5
9
|
/** A lookup's answer as it came off the wire. */
|
|
6
10
|
export type LookupResponse = Omit<WireLookupResponse, 'asn'> & {
|
|
7
11
|
asn?: Asn;
|
|
@@ -13,7 +17,8 @@ export type LookupResponse = Omit<WireLookupResponse, 'asn'> & {
|
|
|
13
17
|
* could not check", so `undefined` and `false` are genuinely different answers:
|
|
14
18
|
* `undefined` is "not in your plan", `false` is "checked, and no". Use
|
|
15
19
|
* `?? false` when you only care whether the address is flagged. The same holds
|
|
16
|
-
* inside `location` and `asn`, whose paid members are absent on Unlimited.
|
|
20
|
+
* inside `location` and `asn`, whose paid members are absent on Unlimited, bar `asn.type`: its
|
|
21
|
+
* type is `string`, so it reads as an empty string there.
|
|
17
22
|
*
|
|
18
23
|
* A detail object that is present but empty (`{}`, and `web`'s `[]`) means the
|
|
19
24
|
* flag above it is false. A populated one always carries every one of its keys.
|
|
@@ -47,7 +52,8 @@ export interface Result {
|
|
|
47
52
|
isBittorrent?: boolean;
|
|
48
53
|
/**
|
|
49
54
|
* 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.
|
|
55
|
+
* crawler, an uptime monitor or a webhook sender. On a paid plan or the trial: absent on
|
|
56
|
+
* Unlimited. `bot` says whose.
|
|
51
57
|
*/
|
|
52
58
|
isBot?: boolean;
|
|
53
59
|
/**
|
|
@@ -97,7 +103,8 @@ export interface Result {
|
|
|
97
103
|
location?: Location;
|
|
98
104
|
/**
|
|
99
105
|
* 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
|
|
106
|
+
* does. `country` and `rpki_status` are on every plan too; `type` is a paid plan's, an empty
|
|
107
|
+
* string on Unlimited.
|
|
101
108
|
*/
|
|
102
109
|
asn?: Asn;
|
|
103
110
|
/** The organization the address is assigned to. */
|
|
@@ -112,4 +119,4 @@ export interface Result {
|
|
|
112
119
|
/** The response exactly as it came off the wire, with its original names. */
|
|
113
120
|
raw: LookupResponse;
|
|
114
121
|
}
|
|
115
|
-
export declare function toResult(body:
|
|
122
|
+
export declare function toResult(body: WireLookupResponse): Result;
|
package/dist/types.js
CHANGED
|
@@ -20,6 +20,11 @@ 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 Unlimited's answer omits 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
|
+
}
|
|
23
28
|
out['isBogon'] = body.is_bogon === true;
|
|
24
29
|
out['raw'] = body;
|
|
25
30
|
return out;
|
package/package.json
CHANGED