vpndetection-web 1.3.1 → 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
@@ -74,13 +74,16 @@ It is never cached, since which address the browser is calling from is the quest
74
74
 
75
75
  ```js
76
76
  const ent = await client.myEntitlement();
77
- console.log(ent.plan.key); // max
77
+ console.log(ent.plan.name); // Max, what to show
78
+ console.log(ent.plan.key); // max, what to compare against
78
79
  console.log(ent.usage.requests); // 580
79
80
  console.log(ent.usage.window_end); // when the allowance resets
80
81
  ```
81
82
 
82
83
  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 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.
83
84
 
85
+ 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.
86
+
84
87
  ### Batch lookup
85
88
 
86
89
  Look up as many addresses as you like in one call. Bogons and cached answers are handled locally, and the rest go to the batch endpoint in chunks of up to 1000, in parallel. The batch endpoint needs a paid plan:
@@ -246,12 +249,13 @@ The library is ES2022 and needs only what a browser has, `fetch` and, for PKCE,
246
249
 
247
250
  ### Absent is not false
248
251
 
249
- 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".
250
253
 
251
254
  ```js
252
255
  result.isHosting ?? false // when you only want the flag
253
256
  result.isHosting === undefined // on Unlimited: not in your plan
254
257
  result.trialExpired === true // a free-plan key's daily trial is spent
258
+ result.capReached === true // a paid key past its overage cap
255
259
  ```
256
260
 
257
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;
@@ -434,15 +442,24 @@ export type EntitlementApikey = {
434
442
  };
435
443
  export type EntitlementPlan = {
436
444
  /**
437
- * The plan the organization is on: `free` for the free plan,
438
- * Unlimited, or a paid plan's key. On `free`, usage counts the
445
+ * The plan the organization is on, as an identifier that is never
446
+ * renamed or reused: `free` for the free plan, or a paid plan's key.
447
+ * Compare against it and show `name`. On `free`, usage counts the
439
448
  * day's lookups answered with every field, its daily trial.
440
449
  *
441
450
  */
442
451
  key: string;
452
+ /**
453
+ * The plan's name, as the site and console show it: `Unlimited` for
454
+ * the free plan. Show this rather than a name built from `key`: a
455
+ * plan's name can change, and its key never does.
456
+ *
457
+ */
458
+ name: string;
443
459
  /**
444
460
  * The field tier, which decides how much of a lookup answer comes
445
- * back; `free` is the free plan's. What each tier includes is documented
461
+ * back; `free` is the free plan's. This list never gains a value: a
462
+ * new plan reports one of these. What each tier includes is documented
446
463
  * on the lookup endpoint rather than repeated here, so there is one
447
464
  * place it can be wrong.
448
465
  *
@@ -461,9 +478,12 @@ export type EntitlementUsage = {
461
478
  */
462
479
  quota: number;
463
480
  /**
464
- * Where we stop serving. NULL means never, which is the normal state
465
- * of an uncapped paid plan and is not the same as zero. Above the
466
- * 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.
467
487
  *
468
488
  */
469
489
  hard_limit: number | null;
@@ -615,16 +635,17 @@ export type LookupIpErrors = {
615
635
  401: LookupError;
616
636
  /**
617
637
  * The key restricts which source addresses may use it and this
618
- * request came from none of them, or the key was sent over plain
619
- * HTTP, where anyone on the network path could read it. Rotate a key
620
- * 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.
621
642
  *
622
643
  */
623
644
  403: LookupError;
624
645
  /**
625
- * Either a rate limit or a paid plan's overage cap. `Retry-After` is
626
- * present for the former and absent for the latter, and is the only
627
- * 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`.
628
649
  *
629
650
  */
630
651
  429: LookupError;
@@ -656,16 +677,17 @@ export type LookupMyIpErrors = {
656
677
  401: LookupError;
657
678
  /**
658
679
  * The key restricts which source addresses may use it and this
659
- * request came from none of them, or the key was sent over plain
660
- * HTTP, where anyone on the network path could read it. Rotate a key
661
- * 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.
662
684
  *
663
685
  */
664
686
  403: LookupError;
665
687
  /**
666
- * Either a rate limit or a paid plan's overage cap. `Retry-After` is
667
- * present for the former and absent for the latter, and is the only
668
- * 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`.
669
691
  *
670
692
  */
671
693
  429: LookupError;
@@ -709,9 +731,10 @@ export type LookupBatchErrors = {
709
731
  402: LookupError;
710
732
  /**
711
733
  * The key restricts which source addresses may use it and this
712
- * request came from none of them, or the key was sent over plain
713
- * HTTP, where anyone on the network path could read it. Rotate a key
714
- * 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.
715
738
  *
716
739
  */
717
740
  403: LookupError;
@@ -721,7 +744,7 @@ export type LookupBatchErrors = {
721
744
  413: LookupError;
722
745
  /**
723
746
  * The rate limit refused the whole call. Always transient and always
724
- * 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
725
748
  * `200` instead.
726
749
  *
727
750
  */
@@ -751,7 +774,8 @@ export type MyEntitlementErrors = {
751
774
  401: EntitlementError;
752
775
  /**
753
776
  * The key restricts which source addresses may use it, and this
754
- * 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.
755
779
  *
756
780
  */
757
781
  403: EntitlementError;
package/dist/shapes.d.ts CHANGED
@@ -5,7 +5,7 @@ export declare const BATCH_MEMBERS: readonly ["results", "errors"];
5
5
  export declare const BATCH_ERROR_MEMBERS: readonly ["status", "error"];
6
6
  export declare const ENTITLEMENT_MEMBERS: readonly ["org_id", "apikey", "plan", "usage"];
7
7
  export declare const ENTITLEMENT_APIKEY_MEMBERS: readonly ["id", "allowed_cidrs"];
8
- export declare const ENTITLEMENT_PLAN_MEMBERS: readonly ["key", "tier"];
8
+ export declare const ENTITLEMENT_PLAN_MEMBERS: readonly ["key", "name", "tier"];
9
9
  export declare const ENTITLEMENT_USAGE_MEMBERS: readonly ["requests", "quota", "window_start", "window_end"];
10
10
  type Kind = 'string' | 'integer' | 'boolean' | 'object' | 'array' | 'date' | 'date-time';
11
11
  export declare const LOOKUP_TYPES: Record<string, Kind>;
package/dist/shapes.js CHANGED
@@ -12,14 +12,14 @@ export const BATCH_MEMBERS = ['results', 'errors'];
12
12
  export const BATCH_ERROR_MEMBERS = ['status', 'error'];
13
13
  export const ENTITLEMENT_MEMBERS = ['org_id', 'apikey', 'plan', 'usage'];
14
14
  export const ENTITLEMENT_APIKEY_MEMBERS = ['id', 'allowed_cidrs'];
15
- export const ENTITLEMENT_PLAN_MEMBERS = ['key', 'tier'];
15
+ export const ENTITLEMENT_PLAN_MEMBERS = ['key', 'name', 'tier'];
16
16
  export const ENTITLEMENT_USAGE_MEMBERS = ['requests', 'quota', 'window_start', 'window_end'];
17
17
  export const LOOKUP_TYPES = {
18
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
- 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',
@@ -46,7 +46,7 @@ export const ENTITLEMENT_TYPES = {
46
46
  export const ENTITLEMENT_APIKEY_TYPES = {
47
47
  id: 'string', expires: 'date-time', allowed_cidrs: 'array',
48
48
  };
49
- export const ENTITLEMENT_PLAN_TYPES = { key: 'string', tier: 'string' };
49
+ export const ENTITLEMENT_PLAN_TYPES = { key: 'string', name: 'string', tier: 'string' };
50
50
  export const ENTITLEMENT_USAGE_TYPES = {
51
51
  requests: 'integer', quota: 'integer', hard_limit: 'integer', window_start: 'date-time',
52
52
  window_end: 'date-time',
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.3.1",
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",