vpndetection-web 1.4.0 → 1.5.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
@@ -249,12 +249,13 @@ The library is ES2022 and needs only what a browser has, `fetch` and, for PKCE,
249
249
 
250
250
  ### Absent is not false
251
251
 
252
- Unlimited leaves out `isHosting`, `isCdn` and the four proxy flags, 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 daily trial is spent. A field your key does not include is `undefined`, which means "not in your plan" rather than "checked, and no".
252
+ Unlimited leaves out `isHosting`, `isCdn` and the four proxy flags, 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 daily 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".
253
253
 
254
254
  ```js
255
255
  result.isHosting ?? false // when you only want the flag
256
256
  result.isHosting === undefined // on Unlimited: not in your plan
257
257
  result.trialExpired === true // a free-plan key's daily trial is spent
258
+ result.capReached === true // a paid key past its overage cap
258
259
  ```
259
260
 
260
261
  ## Other Libraries
@@ -50,13 +50,12 @@ export declare const lookupMyIp: <ThrowOnError extends boolean = false>(options?
50
50
  * normalized form. An address that could not be answered sits in `errors`
51
51
  * with the status and message the single lookup would have given, and
52
52
  * never disturbs the others: a string that is not an address is a `400`
53
- * there, and an overage cap reached part way through leaves the remaining
54
- * entries as `429`s.
53
+ * there. An overage cap reached part way through answers the remaining
54
+ * entries with Unlimited's fields and `cap_reached` `true`, in `results`.
55
55
  *
56
56
  * The call itself fails only for the reasons below, and a `429` on the
57
57
  * call always carries `Retry-After`: the batch is admitted or refused
58
- * whole by the rate limit, so a per-entry `429` is always the overage cap
59
- * and never a throttle.
58
+ * whole by the rate limit, never per entry.
60
59
  *
61
60
  * A batch needs a paid plan: without a key the call is refused with `401`,
62
61
  * and with a key on the free plan with `402`, unless it names one address,
@@ -62,13 +62,12 @@ export const lookupMyIp = (options) => (options?.client ?? client).get({
62
62
  * normalized form. An address that could not be answered sits in `errors`
63
63
  * with the status and message the single lookup would have given, and
64
64
  * never disturbs the others: a string that is not an address is a `400`
65
- * there, and an overage cap reached part way through leaves the remaining
66
- * entries as `429`s.
65
+ * there. An overage cap reached part way through answers the remaining
66
+ * entries with Unlimited's fields and `cap_reached` `true`, in `results`.
67
67
  *
68
68
  * The call itself fails only for the reasons below, and a `429` on the
69
69
  * call always carries `Retry-After`: the batch is admitted or refused
70
- * whole by the rate limit, so a per-entry `429` is always the overage cap
71
- * and never a throttle.
70
+ * whole by the rate limit, never per entry.
72
71
  *
73
72
  * A batch needs a paid plan: without a key the call is refused with `401`,
74
73
  * and with a key on the free plan with `402`, unless it names one address,
@@ -109,6 +109,15 @@ export type LookupResponse = {
109
109
  *
110
110
  */
111
111
  trial_expired?: boolean;
112
+ /**
113
+ * On every answer to a key on a paid plan, and on no other: `false`
114
+ * while the answer has every field, `true` once its organization's
115
+ * overage cap is reached and the answer has Unlimited's. Lookups
116
+ * answered past the cap are not billed; raising or removing the cap in
117
+ * Billing turns it `false` again.
118
+ *
119
+ */
120
+ cap_reached?: boolean;
112
121
  };
113
122
  export type BatchLookupRequest = {
114
123
  /**
@@ -143,9 +152,8 @@ export type BatchLookupResponse = {
143
152
  export type BatchLookupError = {
144
153
  /**
145
154
  * The HTTP status `GET /{ip}` would have answered for this entry: `400`
146
- * for a string that is not an address, `429` for a reached overage cap,
147
- * `500` when the VPN dataset could not be consulted. A `429` here is
148
- * never a throttle; the whole call is refused instead.
155
+ * for a string that is not an address, `500` when the VPN dataset could
156
+ * not be consulted.
149
157
  *
150
158
  */
151
159
  status: number;
@@ -470,9 +478,12 @@ export type EntitlementUsage = {
470
478
  */
471
479
  quota: number;
472
480
  /**
473
- * Where we stop serving. NULL means never, which is the normal state
474
- * of an uncapped paid plan and is not the same as zero. Above the
475
- * quota and below this, requests are served and billed as overage.
481
+ * Where full answers stop: past it, a paid key is answered with
482
+ * Unlimited's fields and `cap_reached: true`, uncharged, until the
483
+ * window ends or the cap is raised. NULL means never, which is the
484
+ * normal state of an uncapped paid plan and is not the same as zero.
485
+ * Above the quota and below this, requests are served and billed as
486
+ * overage.
476
487
  *
477
488
  */
478
489
  hard_limit: number | null;
@@ -624,16 +635,17 @@ export type LookupIpErrors = {
624
635
  401: LookupError;
625
636
  /**
626
637
  * The key restricts which source addresses may use it and this
627
- * request came from none of them, or the key was sent over plain
628
- * HTTP, where anyone on the network path could read it. Rotate a key
629
- * that was.
638
+ * request came from none of them, or the key lacks the `ip.lookup`
639
+ * scope (IP lookup, in the console's key settings), or the key was
640
+ * sent over plain HTTP, where anyone on the network path could read
641
+ * it. Rotate a key that was.
630
642
  *
631
643
  */
632
644
  403: LookupError;
633
645
  /**
634
- * Either a rate limit or a paid plan's overage cap. `Retry-After` is
635
- * present for the former and absent for the latter, and is the only
636
- * way to tell them apart.
646
+ * A rate limit, always with `Retry-After`. A paid plan's overage cap is
647
+ * never a `429`: it answers `200` with Unlimited's fields and
648
+ * `cap_reached` `true`.
637
649
  *
638
650
  */
639
651
  429: LookupError;
@@ -665,16 +677,17 @@ export type LookupMyIpErrors = {
665
677
  401: LookupError;
666
678
  /**
667
679
  * The key restricts which source addresses may use it and this
668
- * request came from none of them, or the key was sent over plain
669
- * HTTP, where anyone on the network path could read it. Rotate a key
670
- * that was.
680
+ * request came from none of them, or the key lacks the `ip.lookup`
681
+ * scope (IP lookup, in the console's key settings), or the key was
682
+ * sent over plain HTTP, where anyone on the network path could read
683
+ * it. Rotate a key that was.
671
684
  *
672
685
  */
673
686
  403: LookupError;
674
687
  /**
675
- * Either a rate limit or a paid plan's overage cap. `Retry-After` is
676
- * present for the former and absent for the latter, and is the only
677
- * way to tell them apart.
688
+ * A rate limit, always with `Retry-After`. A paid plan's overage cap is
689
+ * never a `429`: it answers `200` with Unlimited's fields and
690
+ * `cap_reached` `true`.
678
691
  *
679
692
  */
680
693
  429: LookupError;
@@ -718,9 +731,10 @@ export type LookupBatchErrors = {
718
731
  402: LookupError;
719
732
  /**
720
733
  * The key restricts which source addresses may use it and this
721
- * request came from none of them, or the key was sent over plain
722
- * HTTP, where anyone on the network path could read it. Rotate a key
723
- * that was.
734
+ * request came from none of them, or the key lacks the `ip.lookup`
735
+ * scope (IP lookup, in the console's key settings), or the key was
736
+ * sent over plain HTTP, where anyone on the network path could read
737
+ * it. Rotate a key that was.
724
738
  *
725
739
  */
726
740
  403: LookupError;
@@ -730,7 +744,7 @@ export type LookupBatchErrors = {
730
744
  413: LookupError;
731
745
  /**
732
746
  * The rate limit refused the whole call. Always transient and always
733
- * with `Retry-After`; a reached overage cap is reported per entry in a
747
+ * with `Retry-After`; a reached overage cap answers each entry in a
734
748
  * `200` instead.
735
749
  *
736
750
  */
@@ -760,7 +774,8 @@ export type MyEntitlementErrors = {
760
774
  401: EntitlementError;
761
775
  /**
762
776
  * The key restricts which source addresses may use it, and this
763
- * request did not come from one of them.
777
+ * request did not come from one of them; or the key was sent over
778
+ * plain HTTP, which is refused whatever the key.
764
779
  *
765
780
  */
766
781
  403: EntitlementError;
package/dist/shapes.js CHANGED
@@ -19,7 +19,7 @@ export const LOOKUP_TYPES = {
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
- asn: 'object', trial_expired: 'boolean',
22
+ asn: 'object', trial_expired: 'boolean', cap_reached: 'boolean',
23
23
  };
24
24
  export const VPN_DETAIL_TYPES = {
25
25
  provider: 'string', provider_name: 'string', last_seen: 'date', confidence: 'string', method: 'string',
package/dist/types.d.ts CHANGED
@@ -35,6 +35,12 @@ export interface Result {
35
35
  * Unlimited's.
36
36
  */
37
37
  trialExpired?: boolean;
38
+ /**
39
+ * On answers to a key on a paid plan only: `false` while the answer has every field, `true`
40
+ * once its organization's overage cap is reached and the answer has Unlimited's. Lookups
41
+ * answered past the cap are not billed.
42
+ */
43
+ capReached?: boolean;
38
44
  vpn?: VpnDetail;
39
45
  hosting?: ClassDetail;
40
46
  relay?: ClassDetail;
package/dist/types.js CHANGED
@@ -18,6 +18,7 @@ export function toResult(body) {
18
18
  copyFlag(body, r, 'is_mobproxy', 'isMobproxy');
19
19
  copyFlag(body, r, 'is_pubproxy', 'isPubproxy');
20
20
  copyFlag(body, r, 'trial_expired', 'trialExpired');
21
+ copyFlag(body, r, 'cap_reached', 'capReached');
21
22
  copyDetail(body, r, 'vpn', 'vpn');
22
23
  copyDetail(body, r, 'hosting', 'hosting');
23
24
  copyDetail(body, r, 'relay', 'relay');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vpndetection-web",
3
- "version": "1.4.0",
3
+ "version": "1.5.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",