vpndetection-web 1.3.0 → 1.4.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 +6 -3
- package/dist/generated/types.gen.d.ts +12 -3
- package/dist/shapes.d.ts +1 -1
- package/dist/shapes.js +2 -2
- package/dist/transport.d.ts +1 -1
- package/dist/transport.js +4 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,10 +7,10 @@ The official browser client library for the [VPNDetection](https://vpndetection.
|
|
|
7
7
|
|
|
8
8
|
It tells you whether an IP address is a VPN, residential proxy, Tor node, relay or hosting server.
|
|
9
9
|
|
|
10
|
-
**An API key in a web page is public.** Anyone who opens the page can read it from the page's source or its network requests, and spend your allowance with it. In a page, use no key, or call the API from your own server and hand the page its answer. A key belongs only where the person it belongs to is the only one who can read it: their own browser extension, or an internal tool.
|
|
11
|
-
|
|
12
10
|
## Getting Started
|
|
13
11
|
|
|
12
|
+
**An API key in a web page is public.** Anyone who opens the page can read it from the page's source or its network requests and use it as you would: spend your plan's lookups and, if the key may download databases, download every database your organization is licensed for. In a page, use no key, or call the API from your own server and hand the page its answer. A key belongs only where the person it belongs to is the only one who can read it, such as their own browser extension or an internal tool, and there a key that may only look up.
|
|
13
|
+
|
|
14
14
|
```bash
|
|
15
15
|
npm install vpndetection-web
|
|
16
16
|
```
|
|
@@ -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.
|
|
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:
|
|
@@ -434,15 +434,24 @@ export type EntitlementApikey = {
|
|
|
434
434
|
};
|
|
435
435
|
export type EntitlementPlan = {
|
|
436
436
|
/**
|
|
437
|
-
* The plan the organization is on
|
|
438
|
-
*
|
|
437
|
+
* The plan the organization is on, as an identifier that is never
|
|
438
|
+
* renamed or reused: `free` for the free plan, or a paid plan's key.
|
|
439
|
+
* Compare against it and show `name`. On `free`, usage counts the
|
|
439
440
|
* day's lookups answered with every field, its daily trial.
|
|
440
441
|
*
|
|
441
442
|
*/
|
|
442
443
|
key: string;
|
|
444
|
+
/**
|
|
445
|
+
* The plan's name, as the site and console show it: `Unlimited` for
|
|
446
|
+
* the free plan. Show this rather than a name built from `key`: a
|
|
447
|
+
* plan's name can change, and its key never does.
|
|
448
|
+
*
|
|
449
|
+
*/
|
|
450
|
+
name: string;
|
|
443
451
|
/**
|
|
444
452
|
* The field tier, which decides how much of a lookup answer comes
|
|
445
|
-
* back; `free` is the free plan's.
|
|
453
|
+
* back; `free` is the free plan's. This list never gains a value: a
|
|
454
|
+
* new plan reports one of these. What each tier includes is documented
|
|
446
455
|
* on the lookup endpoint rather than repeated here, so there is one
|
|
447
456
|
* place it can be wrong.
|
|
448
457
|
*
|
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,7 +12,7 @@ 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',
|
|
@@ -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/transport.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare function checkTimeout(timeoutMs: number | undefined): number | un
|
|
|
34
34
|
*/
|
|
35
35
|
export declare function checkRetries(retries: number | null | undefined): number | undefined;
|
|
36
36
|
/** How many batch requests may be in flight, refused where it is set: p-limit throws a bare TypeError. */
|
|
37
|
-
export declare function checkConcurrency(concurrency: number | undefined): number | undefined;
|
|
37
|
+
export declare function checkConcurrency(concurrency: number | null | undefined): number | undefined;
|
|
38
38
|
/**
|
|
39
39
|
* Bound one attempt, and report an expiry as our own error rather than the
|
|
40
40
|
* runtime's `TimeoutError`, whose message says nothing about which call gave up.
|
package/dist/transport.js
CHANGED
|
@@ -69,7 +69,10 @@ export function checkRetries(retries) {
|
|
|
69
69
|
}
|
|
70
70
|
/** How many batch requests may be in flight, refused where it is set: p-limit throws a bare TypeError. */
|
|
71
71
|
export function checkConcurrency(concurrency) {
|
|
72
|
-
if (concurrency
|
|
72
|
+
if (concurrency === undefined || concurrency === null) {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
if (!(typeof concurrency === 'number' && concurrency >= 1
|
|
73
76
|
&& (Number.isInteger(concurrency) || concurrency === Infinity))) {
|
|
74
77
|
throw new VPNDetectionError('bad_request', `concurrency must be a whole number of at least 1, got ${String(concurrency)}`);
|
|
75
78
|
}
|
package/package.json
CHANGED