vpndetection-web 1.8.0 → 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 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, `is_bot` (whether a bot such as a crawler uses the address), `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:
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), every 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. The plans 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' });
@@ -93,8 +93,8 @@ const results = await client.lookupBatch(['66.249.66.1', '45.83.91.1'], {
93
93
 
94
94
  ```js
95
95
  const ent = await client.myEntitlement();
96
- console.log(ent.plan.name); // Max, what to show
97
- console.log(ent.plan.key); // max, what to compare against
96
+ console.log(ent.plan.name); // Data, what to show
97
+ console.log(ent.plan.key); // data_4, what to compare against
98
98
  console.log(ent.usage.requests); // 580
99
99
  console.log(ent.usage.window_end); // when the allowance resets
100
100
  ```
@@ -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
@@ -287,7 +287,7 @@ There are official VPNDetection client libraries available for many languages in
287
287
 
288
288
  VPN Detection API: Accurate anonymity detection identifying VPNs, residential proxies, hosting servers, Tor nodes, CDNs, relays and more.
289
289
 
290
- [<img src="https://s3.vpndetection.io/vpndetection-public/brand/mark.svg" alt="VPNDetection" height="64"/>](https://vpndetection.io/)
290
+ [<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/)
291
291
 
292
292
  ## License
293
293
 
@@ -30,7 +30,7 @@ export type LookupResponse = {
30
30
  */
31
31
  is_vpn: boolean;
32
32
  /**
33
- * Whether the address belongs to a hosting or cloud provider. Paid plans.
33
+ * Whether the address belongs to a hosting or cloud provider. On a paid plan.
34
34
  */
35
35
  is_hosting?: boolean;
36
36
  /**
@@ -42,27 +42,27 @@ export type LookupResponse = {
42
42
  */
43
43
  is_tor?: boolean;
44
44
  /**
45
- * Whether the address belongs to a CDN. Paid plans.
45
+ * Whether the address belongs to a CDN. On a paid plan.
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. Every answer, with or without a key.
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
  /**
53
- * Whether the address was seen in a residential proxy pool. Paid plans.
53
+ * Whether the address was seen in a residential proxy pool. On a paid plan.
54
54
  */
55
55
  is_resproxy?: boolean;
56
56
  /**
57
- * Whether the address is one a datacenter proxy service sells or runs on, a proxy company's own ranges included. Paid plans.
57
+ * Whether the address is one a datacenter proxy service sells or runs on, a proxy company's own ranges included. On a paid plan.
58
58
  */
59
59
  is_dcproxy?: boolean;
60
60
  /**
61
- * Whether the address was seen in a mobile proxy pool. Paid plans.
61
+ * Whether the address was seen in a mobile proxy pool. On a paid plan.
62
62
  */
63
63
  is_mobproxy?: boolean;
64
64
  /**
65
- * Whether a public proxy, one anyone can connect through, listens on the address or sends its traffic out from it. Paid plans.
65
+ * Whether a public proxy, one anyone can connect through, listens on the address or sends its traffic out from it. On a paid plan.
66
66
  */
67
67
  is_pubproxy?: boolean;
68
68
  /**
@@ -70,40 +70,40 @@ export type LookupResponse = {
70
70
  */
71
71
  is_anycast?: boolean;
72
72
  /**
73
- * Whether the address is a mobile carrier's, where many phones can share one address. Paid plans.
73
+ * Whether the address is a mobile carrier's, where many phones can share one address. On a paid plan.
74
74
  */
75
75
  is_carrier?: boolean;
76
76
  /**
77
- * Whether the address is a satellite operator's. Paid plans.
77
+ * Whether the address is a satellite operator's. On a paid plan.
78
78
  */
79
79
  is_satellite?: boolean;
80
80
  /**
81
- * Whether an SSH server answered on the address. Paid plans.
81
+ * Whether an SSH server answered on the address. On a paid plan.
82
82
  */
83
83
  is_ssh?: boolean;
84
84
  /**
85
- * Whether a mail server answered on the address. Paid plans.
85
+ * Whether a mail server answered on the address. On a paid plan.
86
86
  */
87
87
  is_smtp?: boolean;
88
88
  /**
89
- * Whether a web server answered on the address, on port 80 or 443. Paid plans.
89
+ * Whether a web server answered on the address, on port 80 or 443. On a paid plan.
90
90
  */
91
91
  is_web?: boolean;
92
92
  /**
93
- * Whether an open DNS resolver answered on the address. Paid plans.
93
+ * Whether an open DNS resolver answered on the address. On a paid plan.
94
94
  */
95
95
  is_dns_resolver?: boolean;
96
96
  /**
97
- * Whether a BitTorrent client was seen on the address in the last 90 days. Paid plans.
97
+ * Whether a BitTorrent client was seen on the address in the last 90 days. On a paid plan.
98
98
  */
99
99
  is_bittorrent?: boolean;
100
100
  /**
101
- * Detail for `is_vpn`. Empty when `is_vpn` is false. Paid plans.
101
+ * Detail for `is_vpn`. Empty when `is_vpn` is false. On a paid plan.
102
102
  *
103
103
  */
104
104
  vpn?: VpnDetail;
105
105
  /**
106
- * Detail for `is_hosting`. Empty when false. Paid plans.
106
+ * Detail for `is_hosting`. Empty when false. On a paid plan.
107
107
  */
108
108
  hosting?: ClassDetail;
109
109
  /**
@@ -118,55 +118,55 @@ export type LookupResponse = {
118
118
  */
119
119
  tor?: ClassDetail;
120
120
  /**
121
- * Detail for `is_cdn`. Empty when false. Paid plans.
121
+ * Detail for `is_cdn`. Empty when false. On a paid plan.
122
122
  */
123
123
  cdn?: ClassDetail;
124
124
  /**
125
- * Detail for `is_bot`. Empty when false. Paid plans.
125
+ * Detail for `is_bot`. Empty when false. On a paid plan.
126
126
  */
127
127
  bot?: BotDetail;
128
128
  /**
129
- * Detail for `is_resproxy`. Empty when false. Paid plans.
129
+ * Detail for `is_resproxy`. Empty when false. On a paid plan.
130
130
  */
131
131
  resproxy?: ProxyDetail;
132
132
  /**
133
- * Detail for `is_dcproxy`. Empty when false. Paid plans.
133
+ * Detail for `is_dcproxy`. Empty when false. On a paid plan.
134
134
  */
135
135
  dcproxy?: ProxyDetail;
136
136
  /**
137
- * Detail for `is_mobproxy`. Empty when false. Paid plans.
137
+ * Detail for `is_mobproxy`. Empty when false. On a paid plan.
138
138
  */
139
139
  mobproxy?: ProxyDetail;
140
140
  /**
141
- * Detail for `is_pubproxy`. Empty when false. Paid plans.
141
+ * Detail for `is_pubproxy`. Empty when false. On a paid plan.
142
142
  */
143
143
  pubproxy?: PubproxyDetail;
144
144
  /**
145
- * Detail for `is_carrier`. Empty when false. Paid plans.
145
+ * Detail for `is_carrier`. Empty when false. On a paid plan.
146
146
  */
147
147
  carrier?: CarrierDetail;
148
148
  /**
149
- * Detail for `is_satellite`. Empty when false. Paid plans.
149
+ * Detail for `is_satellite`. Empty when false. On a paid plan.
150
150
  */
151
151
  satellite?: SatelliteDetail;
152
152
  /**
153
- * Detail for `is_ssh`. Empty when false. Paid plans.
153
+ * Detail for `is_ssh`. Empty when false. On a paid plan.
154
154
  */
155
155
  ssh?: SshDetail;
156
156
  /**
157
- * Detail for `is_smtp`. Empty when false. Paid plans.
157
+ * Detail for `is_smtp`. Empty when false. On a paid plan.
158
158
  */
159
159
  smtp?: SmtpDetail;
160
160
  /**
161
- * Detail for `is_web`: a row per port that answered, lowest first, and `[]` when false. Paid plans.
161
+ * Detail for `is_web`: a row per port that answered, lowest first, and `[]` when false. On a paid plan.
162
162
  */
163
163
  web?: Array<WebDetail>;
164
164
  /**
165
- * Detail for `is_dns_resolver`. Empty when false. Paid plans.
165
+ * Detail for `is_dns_resolver`. Empty when false. On a paid plan.
166
166
  */
167
167
  dns_resolver?: DnsResolverDetail;
168
168
  /**
169
- * Detail for `is_bittorrent`. Empty when false. Paid plans.
169
+ * Detail for `is_bittorrent`. Empty when false. On a paid plan.
170
170
  */
171
171
  bittorrent?: BitTorrentDetail;
172
172
  location?: Location;
@@ -466,43 +466,43 @@ export type Location = {
466
466
  */
467
467
  flag_unicode: string;
468
468
  /**
469
- * Region (state or province). Paid plans.
469
+ * Region (state or province). On a paid plan.
470
470
  */
471
471
  region?: string;
472
472
  /**
473
- * ISO 3166-2 region code. Paid plans.
473
+ * ISO 3166-2 region code. On a paid plan.
474
474
  */
475
475
  region_code?: string;
476
476
  /**
477
- * City. Paid plans.
477
+ * City. On a paid plan.
478
478
  */
479
479
  city?: string;
480
480
  /**
481
- * Postal code. Paid plans.
481
+ * Postal code. On a paid plan.
482
482
  */
483
483
  postal_code?: string;
484
484
  /**
485
- * Latitude of the city. Paid plans.
485
+ * Latitude of the city. On a paid plan.
486
486
  */
487
487
  latitude?: number;
488
488
  /**
489
- * Longitude of the city. Paid plans.
489
+ * Longitude of the city. On a paid plan.
490
490
  */
491
491
  longitude?: number;
492
492
  /**
493
- * Radius in km holding the true location with 67% confidence; 20000 for an address announced everywhere, as an anycast one is. Paid plans.
493
+ * Radius in km holding the true location with 67% confidence; 20000 for an address announced everywhere, as an anycast one is. On a paid plan.
494
494
  */
495
495
  accuracy_radius?: number;
496
496
  /**
497
- * GeoNames ID of the city. Paid plans.
497
+ * GeoNames ID of the city. On a paid plan.
498
498
  */
499
499
  geoname_id?: string;
500
500
  /**
501
- * US TV market (DMA) code, empty outside the US. Paid plans.
501
+ * US TV market (DMA) code, empty outside the US. On a paid plan.
502
502
  */
503
503
  dma_code?: string;
504
504
  /**
505
- * The day the range's location last changed. Paid plans.
505
+ * The day the range's location last changed. On a paid plan.
506
506
  */
507
507
  last_changed?: string;
508
508
  };
@@ -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: string;
532
+ type?: string;
533
533
  /**
534
534
  * The announced BGP prefix that covers the address, the most specific when several do.
535
535
  */
@@ -876,7 +876,7 @@ export type BitTorrentDetail = {
876
876
  clients?: Array<string>;
877
877
  };
878
878
  /**
879
- * Who uses the address, from our IP Company database. Paid plans. Every
879
+ * Who uses the address, from our IP Company database. On a paid plan. Every
880
880
  * key is present whenever the object is: empty strings where no record
881
881
  * covers the address.
882
882
  *
@@ -901,7 +901,7 @@ export type Company = {
901
901
  };
902
902
  /**
903
903
  * Where to report abuse from the address, from our IP Abuse Contact
904
- * database. Paid plans. Every key is present whenever the object is: empty
904
+ * database. On a paid plan. Every key is present whenever the object is: empty
905
905
  * strings where no record covers the address.
906
906
  *
907
907
  */
@@ -980,7 +980,8 @@ export type EntitlementPlan = {
980
980
  * The plan the organization is on, as an identifier that is never
981
981
  * renamed or reused: `free` for the free plan, or a paid plan's key.
982
982
  * Compare against it and show `name`. On `free`, usage counts its
983
- * trial, the lookups answered with every field.
983
+ * trial, the lookups answered with every field. The Data plan is a key
984
+ * per quota, `data_1` to `data_7`, each named Data.
984
985
  *
985
986
  */
986
987
  key: string;
@@ -1023,11 +1024,15 @@ export type EntitlementUsage = {
1023
1024
  */
1024
1025
  hard_limit: number | null;
1025
1026
  /**
1026
- * When the current allowance period began.
1027
+ * When the current allowance period began. On the free plan, when
1028
+ * its trial began, or now before a first lookup starts it.
1029
+ *
1027
1030
  */
1028
1031
  window_start: string;
1029
1032
  /**
1030
- * When the allowance next resets.
1033
+ * When the allowance next resets. On the free plan, when its trial
1034
+ * ends, which it does once.
1035
+ *
1031
1036
  */
1032
1037
  window_end: string;
1033
1038
  };
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", "type", "prefix", "country", "rpki_status"];
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', 'type', 'prefix', 'country', 'rpki_status'];
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
- function typed(value, required, types) {
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
- return v === undefined || v === null ? !required.includes(member) : isKind(v, kind);
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
- /** The AS announcing an address. Every answer carries `country` and `rpki_status`. */
4
- export type Asn = Omit<WireAsn, 'country' | 'rpki_status'> & Partial<Pick<WireAsn, 'country' | 'rpki_status'>>;
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. Every plan includes this; `bot` says whose.
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
  /**
@@ -80,7 +86,7 @@ export interface Result {
80
86
  bittorrent?: BitTorrentDetail;
81
87
  /**
82
88
  * Whose bot uses the address, what it does and whether its operator vouches for the address.
83
- * Paid plans. `agents` and `categories` keep the API's order.
89
+ * On a paid plan. `agents` and `categories` keep the API's order.
84
90
  */
85
91
  bot?: BotDetail;
86
92
  /**
@@ -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: LookupResponse): Result;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vpndetection-web",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
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",