vpndetection 1.0.0 → 1.2.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 +11 -2
- package/dist/client.d.ts +52 -4
- package/dist/client.js +103 -7
- package/dist/client.js.map +1 -1
- package/dist/errors.js +6 -0
- package/dist/errors.js.map +1 -1
- package/dist/generated/index.d.ts +1 -1
- package/dist/generated/types.gen.d.ts +39 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -134,14 +134,23 @@ Note that `rate_limited` and `quota_exceeded` both arrive as HTTP 429 and are no
|
|
|
134
134
|
|
|
135
135
|
### Database downloads
|
|
136
136
|
|
|
137
|
-
If your key carries the `db.download` scope, the licensed datasets are available through `client.database
|
|
137
|
+
If your key carries the `db.download` scope, the licensed datasets are available through `client.database`. `download` fetches one to a path, streaming it straight to disk so that nothing bigger than a chunk is ever held in memory:
|
|
138
138
|
|
|
139
139
|
```js
|
|
140
140
|
const datasets = await client.database.list();
|
|
141
|
+
|
|
142
|
+
const written = await client.database.download('vpn_ip_extended_v1', 'mmdb', './vpn_ip_extended_v1.mmdb');
|
|
143
|
+
console.log(`${written} bytes`);
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Or take the time-limited link and run the transfer yourself, or take a small dataset as bytes:
|
|
147
|
+
|
|
148
|
+
```js
|
|
141
149
|
const url = await client.database.downloadUrl('vpn_ip_extended_v1', 'mmdb');
|
|
150
|
+
const bytes = await client.database.downloadBytes('cdn_ip_v1', 'csvgz');
|
|
142
151
|
```
|
|
143
152
|
|
|
144
|
-
`
|
|
153
|
+
`downloadBytes` holds the whole file in memory, and the catalog runs from `cdn_ip_v1` at 10 KB to `resproxy_ip_90d_v1` at 1.79 GB, so use `download` for anything you have not measured.
|
|
145
154
|
|
|
146
155
|
## Other Libraries
|
|
147
156
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
import type { Writable } from 'node:stream';
|
|
1
2
|
import type { Client } from './generated/client/index.js';
|
|
2
|
-
import type { DatasetMetadata, Download, LicensedDataset } from './generated/types.gen.js';
|
|
3
|
+
import type { DatabaseChecksumResponses, DatasetMetadata, Download, LicensedDataset } from './generated/types.gen.js';
|
|
3
4
|
import { VPNDetectionError } from './errors.js';
|
|
4
5
|
import { type Result } from './types.js';
|
|
6
|
+
/** The digests published alongside a dataset file. Which ones are present varies by dataset. */
|
|
7
|
+
export type DatasetChecksums = DatabaseChecksumResponses[200]['checksums'];
|
|
8
|
+
/** The formats a dataset is published in. Not every dataset is built in both. */
|
|
9
|
+
export type DatasetFormat = 'csvgz' | 'mmdb';
|
|
10
|
+
/**
|
|
11
|
+
* Where `download` puts the bytes: a path to write, or a stream you opened
|
|
12
|
+
* yourself and will close yourself.
|
|
13
|
+
*/
|
|
14
|
+
export type DownloadDestination = string | Writable;
|
|
5
15
|
export declare const DEFAULT_BASE_URL = "https://api.vpndetection.io";
|
|
6
16
|
export interface CacheOptions {
|
|
7
17
|
/** Maximum number of addresses held. Default 10000. */
|
|
@@ -80,10 +90,18 @@ export declare class VPNDetection {
|
|
|
80
90
|
export declare class DatabaseApi {
|
|
81
91
|
private readonly client;
|
|
82
92
|
private readonly retries;
|
|
83
|
-
|
|
93
|
+
private readonly fetchImpl;
|
|
94
|
+
constructor(client: Client, retries: number, fetchImpl: typeof globalThis.fetch);
|
|
84
95
|
list(): Promise<LicensedDataset[]>;
|
|
85
96
|
metadata(id: string): Promise<DatasetMetadata>;
|
|
86
|
-
|
|
97
|
+
/**
|
|
98
|
+
* The digests for one dataset file.
|
|
99
|
+
*
|
|
100
|
+
* Returns the whole set rather than one algorithm: which digests a dataset
|
|
101
|
+
* publishes is the API's choice, not ours, and picking one here is how the
|
|
102
|
+
* previous version came to return `undefined`.
|
|
103
|
+
*/
|
|
104
|
+
checksums(id: string, format: DatasetFormat): Promise<DatasetChecksums>;
|
|
87
105
|
downloads(): Promise<Download[]>;
|
|
88
106
|
/**
|
|
89
107
|
* The time-limited URL for one dataset file.
|
|
@@ -93,5 +111,35 @@ export declare class DatabaseApi {
|
|
|
93
111
|
* runs to gigabytes; the link authorizes the START of a transfer, so one
|
|
94
112
|
* already running is not interrupted when it lapses.
|
|
95
113
|
*/
|
|
96
|
-
downloadUrl(id: string, format:
|
|
114
|
+
downloadUrl(id: string, format: DatasetFormat): Promise<string>;
|
|
115
|
+
/**
|
|
116
|
+
* Download one dataset file, streaming it to `destination`.
|
|
117
|
+
*
|
|
118
|
+
* `destination` is either a path or a writable stream you opened yourself.
|
|
119
|
+
* A path is written through a neighboring `.part` file and renamed on
|
|
120
|
+
* completion, so a transfer that dies half way leaves no truncated file
|
|
121
|
+
* that reads as a whole dataset; a stream you pass is written as-is and
|
|
122
|
+
* stays yours to close. Nothing is ever held in memory beyond a single
|
|
123
|
+
* chunk, whatever the dataset weighs.
|
|
124
|
+
*
|
|
125
|
+
* Returns the number of bytes written.
|
|
126
|
+
*
|
|
127
|
+
* A failure DURING the transfer surfaces as the underlying error rather
|
|
128
|
+
* than a `VPNDetectionError`: a reset socket and a full disk are different
|
|
129
|
+
* problems and only one of them is ours.
|
|
130
|
+
*/
|
|
131
|
+
download(id: string, format: DatasetFormat, destination: DownloadDestination): Promise<number>;
|
|
132
|
+
/**
|
|
133
|
+
* Download one dataset file and hand back its bytes.
|
|
134
|
+
*
|
|
135
|
+
* **This holds the entire file in memory**, and the catalog spans five
|
|
136
|
+
* orders of magnitude: `cdn_ip_v1` is 10 KB and `relay_ip_v1` 78 KB, which
|
|
137
|
+
* are nothing, while `vpn_ip_extended_v1` is a 628 MB mmdb and
|
|
138
|
+
* `resproxy_ip_90d_v1` 1.79 GB of csv.gz, which will cost you that much
|
|
139
|
+
* resident memory in one allocation and can fail outright. Reach for this
|
|
140
|
+
* at the small end, where the bytes are going straight into a parser; use
|
|
141
|
+
* `download` for anything you have not measured.
|
|
142
|
+
*/
|
|
143
|
+
downloadBytes(id: string, format: DatasetFormat): Promise<Uint8Array>;
|
|
144
|
+
private fetchDatasetFile;
|
|
97
145
|
}
|
package/dist/client.js
CHANGED
|
@@ -2,7 +2,7 @@ import { LRUCache } from 'lru-cache';
|
|
|
2
2
|
import pLimit from 'p-limit';
|
|
3
3
|
import pRetry from 'p-retry';
|
|
4
4
|
import { createClient, createConfig } from './generated/client/index.js';
|
|
5
|
-
import { databaseChecksum, databaseMetadata, downloadDatabase, listDatabases, listDownloads, lookupIp, } from './generated/sdk.gen.js';
|
|
5
|
+
import { databaseChecksum, databaseMetadata, downloadDatabase as downloadRedirect, listDatabases, listDownloads, lookupIp, } from './generated/sdk.gen.js';
|
|
6
6
|
import { bogonResult, isBogon } from './bogon.js';
|
|
7
7
|
import { errorFromResponse, VPNDetectionError } from './errors.js';
|
|
8
8
|
import { toResult } from './types.js';
|
|
@@ -21,10 +21,14 @@ export class VPNDetection {
|
|
|
21
21
|
/** The licensed dataset downloads, for keys that carry the `db.download` scope. */
|
|
22
22
|
database;
|
|
23
23
|
constructor(options = {}) {
|
|
24
|
+
// Resolved once, because the download path calls object storage
|
|
25
|
+
// directly rather than through the generated client and has to reach
|
|
26
|
+
// the same implementation a test substituted.
|
|
27
|
+
const fetchImpl = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
24
28
|
this.client = createClient(createConfig({
|
|
25
29
|
baseUrl: options.baseUrl ?? DEFAULT_BASE_URL,
|
|
26
30
|
...(options.apiKey === undefined ? {} : { auth: () => options.apiKey }),
|
|
27
|
-
|
|
31
|
+
fetch: fetchImpl,
|
|
28
32
|
}));
|
|
29
33
|
this.cache = options.cache === false ? null : new LRUCache({
|
|
30
34
|
max: options.cache?.max ?? 10_000,
|
|
@@ -32,7 +36,7 @@ export class VPNDetection {
|
|
|
32
36
|
});
|
|
33
37
|
this.limit = pLimit(options.concurrency ?? 8);
|
|
34
38
|
this.retries = options.retries ?? 2;
|
|
35
|
-
this.database = new DatabaseApi(this.client, this.retries);
|
|
39
|
+
this.database = new DatabaseApi(this.client, this.retries, fetchImpl);
|
|
36
40
|
}
|
|
37
41
|
/**
|
|
38
42
|
* Whether an address is private, loopback, link-local, documentation,
|
|
@@ -101,9 +105,11 @@ export class VPNDetection {
|
|
|
101
105
|
export class DatabaseApi {
|
|
102
106
|
client;
|
|
103
107
|
retries;
|
|
104
|
-
|
|
108
|
+
fetchImpl;
|
|
109
|
+
constructor(client, retries, fetchImpl) {
|
|
105
110
|
this.client = client;
|
|
106
111
|
this.retries = retries;
|
|
112
|
+
this.fetchImpl = fetchImpl;
|
|
107
113
|
}
|
|
108
114
|
async list() {
|
|
109
115
|
return withRetry(this.retries, async () => {
|
|
@@ -117,12 +123,19 @@ export class DatabaseApi {
|
|
|
117
123
|
return unwrap(res);
|
|
118
124
|
});
|
|
119
125
|
}
|
|
120
|
-
|
|
126
|
+
/**
|
|
127
|
+
* The digests for one dataset file.
|
|
128
|
+
*
|
|
129
|
+
* Returns the whole set rather than one algorithm: which digests a dataset
|
|
130
|
+
* publishes is the API's choice, not ours, and picking one here is how the
|
|
131
|
+
* previous version came to return `undefined`.
|
|
132
|
+
*/
|
|
133
|
+
async checksums(id, format) {
|
|
121
134
|
return withRetry(this.retries, async () => {
|
|
122
135
|
const res = await databaseChecksum({
|
|
123
136
|
client: this.client, query: { id: id, format: format },
|
|
124
137
|
});
|
|
125
|
-
return unwrap(res).
|
|
138
|
+
return unwrap(res).checksums;
|
|
126
139
|
});
|
|
127
140
|
}
|
|
128
141
|
async downloads() {
|
|
@@ -141,7 +154,7 @@ export class DatabaseApi {
|
|
|
141
154
|
*/
|
|
142
155
|
async downloadUrl(id, format) {
|
|
143
156
|
return withRetry(this.retries, async () => {
|
|
144
|
-
const res = await
|
|
157
|
+
const res = await downloadRedirect({
|
|
145
158
|
client: this.client,
|
|
146
159
|
query: { id: id, format: format },
|
|
147
160
|
redirect: 'manual',
|
|
@@ -157,6 +170,89 @@ export class DatabaseApi {
|
|
|
157
170
|
throw new VPNDetectionError('server_error', 'expected a redirect to object storage', res.response.status);
|
|
158
171
|
});
|
|
159
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Download one dataset file, streaming it to `destination`.
|
|
175
|
+
*
|
|
176
|
+
* `destination` is either a path or a writable stream you opened yourself.
|
|
177
|
+
* A path is written through a neighboring `.part` file and renamed on
|
|
178
|
+
* completion, so a transfer that dies half way leaves no truncated file
|
|
179
|
+
* that reads as a whole dataset; a stream you pass is written as-is and
|
|
180
|
+
* stays yours to close. Nothing is ever held in memory beyond a single
|
|
181
|
+
* chunk, whatever the dataset weighs.
|
|
182
|
+
*
|
|
183
|
+
* Returns the number of bytes written.
|
|
184
|
+
*
|
|
185
|
+
* A failure DURING the transfer surfaces as the underlying error rather
|
|
186
|
+
* than a `VPNDetectionError`: a reset socket and a full disk are different
|
|
187
|
+
* problems and only one of them is ours.
|
|
188
|
+
*/
|
|
189
|
+
async download(id, format, destination) {
|
|
190
|
+
const res = await this.fetchDatasetFile(id, format);
|
|
191
|
+
if (res.body === null) {
|
|
192
|
+
throw new VPNDetectionError('server_error', 'object storage answered with no body', res.status);
|
|
193
|
+
}
|
|
194
|
+
const { Readable } = await import('node:stream');
|
|
195
|
+
const { pipeline } = await import('node:stream/promises');
|
|
196
|
+
// `node:stream/web` and the DOM lib declare the same runtime object as
|
|
197
|
+
// two unrelated types, so `fromWeb` needs it restated.
|
|
198
|
+
const source = Readable.fromWeb(res.body);
|
|
199
|
+
let bytes = 0;
|
|
200
|
+
async function* counted() {
|
|
201
|
+
for await (const chunk of source) {
|
|
202
|
+
bytes += chunk.length;
|
|
203
|
+
yield chunk;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (typeof destination !== 'string') {
|
|
207
|
+
await pipeline(counted(), destination);
|
|
208
|
+
return bytes;
|
|
209
|
+
}
|
|
210
|
+
const { createWriteStream } = await import('node:fs');
|
|
211
|
+
const { rename, unlink } = await import('node:fs/promises');
|
|
212
|
+
const partial = `${destination}.part`;
|
|
213
|
+
try {
|
|
214
|
+
await pipeline(counted(), createWriteStream(partial));
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
await unlink(partial).catch(() => { });
|
|
218
|
+
throw err;
|
|
219
|
+
}
|
|
220
|
+
await rename(partial, destination);
|
|
221
|
+
return bytes;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Download one dataset file and hand back its bytes.
|
|
225
|
+
*
|
|
226
|
+
* **This holds the entire file in memory**, and the catalog spans five
|
|
227
|
+
* orders of magnitude: `cdn_ip_v1` is 10 KB and `relay_ip_v1` 78 KB, which
|
|
228
|
+
* are nothing, while `vpn_ip_extended_v1` is a 628 MB mmdb and
|
|
229
|
+
* `resproxy_ip_90d_v1` 1.79 GB of csv.gz, which will cost you that much
|
|
230
|
+
* resident memory in one allocation and can fail outright. Reach for this
|
|
231
|
+
* at the small end, where the bytes are going straight into a parser; use
|
|
232
|
+
* `download` for anything you have not measured.
|
|
233
|
+
*/
|
|
234
|
+
async downloadBytes(id, format) {
|
|
235
|
+
const res = await this.fetchDatasetFile(id, format);
|
|
236
|
+
return new Uint8Array(await res.arrayBuffer());
|
|
237
|
+
}
|
|
238
|
+
// Follows the 302 as a SECOND, unauthenticated request: the presigned URL
|
|
239
|
+
// carries its own authorization, so forwarding the API key would hand a
|
|
240
|
+
// credential to a host that has no business holding it.
|
|
241
|
+
async fetchDatasetFile(id, format) {
|
|
242
|
+
const url = await this.downloadUrl(id, format);
|
|
243
|
+
return withRetry(this.retries, async () => {
|
|
244
|
+
const res = await this.fetchImpl(url);
|
|
245
|
+
if (!res.ok) {
|
|
246
|
+
// Left unread: the status is what separates a lapsed link from
|
|
247
|
+
// a refused one, and the body is not bounded by anything.
|
|
248
|
+
void res.body?.cancel();
|
|
249
|
+
throw errorFromResponse(res.status, res.headers, {
|
|
250
|
+
error: `object storage refused the download link with status ${res.status}`,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
return res;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
160
256
|
}
|
|
161
257
|
function unwrap(res) {
|
|
162
258
|
if (res.response === undefined) {
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,MAAM,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,MAAM,MAAM,SAAS,CAAC;AAK7B,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEzE,OAAO,EACH,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,IAAI,gBAAgB,EACxE,aAAa,EAAE,aAAa,EAAE,QAAQ,GACzC,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAe,MAAM,YAAY,CAAC;AAcnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,6BAA6B,CAAC;AAsC9D;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IACJ,MAAM,CAAS;IACf,KAAK,CAAkC;IACvC,KAAK,CAA4B;IACjC,OAAO,CAAS;IAEjC,mFAAmF;IAC1E,QAAQ,CAAc;IAE/B,YAAY,UAAmB,EAAE;QAC7B,gEAAgE;QAChE,qEAAqE;QACrE,8CAA8C;QAC9C,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,C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AC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;gBAC5D,CAAC;YACL,CAAC;SACJ,CAAC,CAAC;IACP,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;AACL,CAAC;AAED,SAAS,OAAO,CAAC,GAAY;IACzB,IAAI,GAAG,YAAY,iBAAiB,EAAE,CAAC;QACnC,OAAO,GAAG,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAI,GAA2B,EAAE,KAAK,CAAC;IAClD,IAAI,KAAK,YAAY,iBAAiB,EAAE,CAAC;QACrC,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,IAAI,iBAAiB,CAAC,SAAS,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9F,CAAC"}
|
package/dist/errors.js
CHANGED
|
@@ -33,6 +33,12 @@ export function errorFromResponse(status, headers, body) {
|
|
|
33
33
|
if (status === 403) {
|
|
34
34
|
return new VPNDetectionError('forbidden', message, status);
|
|
35
35
|
}
|
|
36
|
+
// Any other 4xx is a CLIENT error. Falling through to the server_error
|
|
37
|
+
// default would make it retryable, so a bad dataset id would be retried
|
|
38
|
+
// twice before failing. Only 5xx and transport failures are worth a retry.
|
|
39
|
+
if (status < 500) {
|
|
40
|
+
return new VPNDetectionError('bad_request', message, status);
|
|
41
|
+
}
|
|
36
42
|
return new VPNDetectionError('server_error', message, status);
|
|
37
43
|
}
|
|
38
44
|
// The two APIs behind this host answer with different envelopes: the lookup
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAkBA,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC/B,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,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;QAC3C,OAAO,OAAO,CAAC;IACnB,CAAC;IACD,wCAAwC;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { databaseChecksum, databaseMetadata, downloadDatabase, listDatabases, listDownloads, lookupIp, type Options } from './sdk.gen.js';
|
|
2
|
-
export type { ClassDetail, ClientOptions, DatabaseChecksumData, DatabaseChecksumError, DatabaseChecksumErrors, DatabaseChecksumResponse, DatabaseChecksumResponses, DatabaseMetadataData, DatabaseMetadataError, DatabaseMetadataErrors, DatabaseMetadataResponse, DatabaseMetadataResponses, DatasetFormatSize, DatasetMetadata, DatasetMetadataColumn, Download, DownloadDatabaseData, DownloadDatabaseError, DownloadDatabaseErrors, Error, LicensedDataset, ListDatabasesData, ListDatabasesError, ListDatabasesErrors, ListDatabasesResponse, ListDatabasesResponses, ListDownloadsData, ListDownloadsError, ListDownloadsErrors, ListDownloadsResponse, ListDownloadsResponses, LookupError, LookupIpData, LookupIpError, LookupIpErrors, LookupIpResponse, LookupIpResponses, LookupResponse, ProxyDetail, VpnDetail } from './types.gen.js';
|
|
2
|
+
export type { ClassDetail, ClientOptions, DatabaseChecksumData, DatabaseChecksumError, DatabaseChecksumErrors, DatabaseChecksumResponse, DatabaseChecksumResponses, DatabaseMetadataData, DatabaseMetadataError, DatabaseMetadataErrors, DatabaseMetadataResponse, DatabaseMetadataResponses, DatasetFormatSize, DatasetMetadata, DatasetMetadataColumn, Download, DownloadDatabaseData, DownloadDatabaseError, DownloadDatabaseErrors, Error, LicensedDataset, LicensedVersion, ListDatabasesData, ListDatabasesError, ListDatabasesErrors, ListDatabasesResponse, ListDatabasesResponses, ListDownloadsData, ListDownloadsError, ListDownloadsErrors, ListDownloadsResponse, ListDownloadsResponses, LookupError, LookupIpData, LookupIpError, LookupIpErrors, LookupIpResponse, LookupIpResponses, LookupResponse, ProxyDetail, VpnDetail } from './types.gen.js';
|
|
@@ -183,25 +183,57 @@ export type DatasetFormatSize = {
|
|
|
183
183
|
*/
|
|
184
184
|
bytes: number | null;
|
|
185
185
|
};
|
|
186
|
+
/**
|
|
187
|
+
* One dataset FAMILY your organization is licensed for. A license covers
|
|
188
|
+
* the family, while a download names a specific version, so the ids you
|
|
189
|
+
* pass to the download and checksum endpoints come from `versions`.
|
|
190
|
+
*
|
|
191
|
+
*/
|
|
186
192
|
export type LicensedDataset = {
|
|
187
|
-
|
|
193
|
+
/**
|
|
194
|
+
* The dataset family, e.g. `vpn_ip`. What the license is held against.
|
|
195
|
+
*/
|
|
196
|
+
base: string;
|
|
188
197
|
name: string;
|
|
189
198
|
summary?: string;
|
|
190
199
|
/**
|
|
191
|
-
*
|
|
200
|
+
* What your license permits you to do with the data.
|
|
192
201
|
*/
|
|
193
|
-
|
|
202
|
+
redistribution: 'evaluation' | 'internal' | 'redistribute';
|
|
203
|
+
starts?: string | null;
|
|
194
204
|
/**
|
|
195
|
-
*
|
|
205
|
+
* Null when the license does not expire.
|
|
196
206
|
*/
|
|
197
|
-
redistribution: 'evaluation' | 'internal' | 'redistribute';
|
|
198
|
-
starts?: string;
|
|
199
207
|
expires?: string | null;
|
|
200
208
|
/**
|
|
201
|
-
* False when the license has lapsed; downloads are refused
|
|
209
|
+
* False when the license has lapsed; downloads are refused.
|
|
202
210
|
*/
|
|
203
211
|
in_term: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* `licensed` is a live grant, `expired` one whose term has ended, and
|
|
214
|
+
* `unlicensed` a dataset published but never bought.
|
|
215
|
+
*
|
|
216
|
+
*/
|
|
217
|
+
standing: 'expired' | 'licensed' | 'unlicensed';
|
|
218
|
+
/**
|
|
219
|
+
* Every published version of this family. The `id` here is what the
|
|
220
|
+
* download and checksum endpoints take.
|
|
221
|
+
*
|
|
222
|
+
*/
|
|
223
|
+
versions: Array<LicensedVersion>;
|
|
224
|
+
};
|
|
225
|
+
export type LicensedVersion = {
|
|
226
|
+
/**
|
|
227
|
+
* The versioned dataset id, e.g. `vpn_ip_v1`. Pass this to download.
|
|
228
|
+
*/
|
|
229
|
+
id: string;
|
|
230
|
+
version: number;
|
|
231
|
+
summary?: string;
|
|
204
232
|
formats: Array<DatasetFormatSize>;
|
|
233
|
+
/**
|
|
234
|
+
* The formats an evaluation sample is published in, if any.
|
|
235
|
+
*/
|
|
236
|
+
sampleFormats?: Array<'csvgz' | 'mmdb'>;
|
|
205
237
|
};
|
|
206
238
|
export type Download = {
|
|
207
239
|
dataset_id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { VPNDetection, DatabaseApi, DEFAULT_BASE_URL } from './client.js';
|
|
2
|
-
export type { Options, CacheOptions, LookupOptions, BatchOptions } from './client.js';
|
|
2
|
+
export type { Options, CacheOptions, LookupOptions, BatchOptions, DatasetChecksums, DatasetFormat, DownloadDestination, } from './client.js';
|
|
3
3
|
export { isBogon } from './bogon.js';
|
|
4
4
|
export { VPNDetectionError } from './errors.js';
|
|
5
5
|
export type { ErrorKind } from './errors.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAK1E,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vpndetection",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Official Node.js client library for the VPNDetection API. Detect VPNs, proxies, Tor, hosting and CDN IPs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
".": {
|
|
34
34
|
"types": "./dist/index.d.ts",
|
|
35
35
|
"default": "./dist/index.js"
|
|
36
|
-
}
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
37
38
|
},
|
|
38
39
|
"files": [
|
|
39
40
|
"dist",
|