internetdata-web 1.5.1 → 1.7.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 +25 -6
- package/dist/client.d.ts +33 -7
- package/dist/client.js +102 -24
- package/dist/generated/types.gen.d.ts +80 -75
- package/dist/index.d.ts +1 -1
- package/dist/shapes.js +17 -17
- package/dist/store.d.ts +5 -3
- package/dist/store.js +8 -6
- package/dist/transport.d.ts +5 -0
- package/dist/transport.js +7 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ console.log(result.company.name); // who the address belongs to
|
|
|
48
48
|
|
|
49
49
|
### With an API key
|
|
50
50
|
|
|
51
|
-
Where the key stays private (see above),
|
|
51
|
+
Where the key stays private (see above), a paid plan answers every field: `is_vpn`, `is_hosting`, `is_cdn` and the four proxy flags as well, city-level location, the whois records, `user_agent` (whether a user agent you send is borne out by the address: see below) and the 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.internetdata.io), then pass it in:
|
|
52
52
|
|
|
53
53
|
```js
|
|
54
54
|
const client = new InternetData({ apiKey: 'your-api-key' });
|
|
@@ -85,12 +85,31 @@ console.log(result.ip); // the address we saw this call come from: in a page,
|
|
|
85
85
|
|
|
86
86
|
It is never cached, since which address the browser is calling from is the question, and a laptop moves between networks.
|
|
87
87
|
|
|
88
|
+
### A visitor's user agent
|
|
89
|
+
|
|
90
|
+
Pass the `User-Agent` of the client you are deciding on, and on a paid plan or the trial the answer's `userAgent` names the agent it claims to be and whether this address bears that out: `verified` when the agent's operator vouches for the address, `spoofed` when it does not, `unverifiable` for a bot nothing can confirm, `not_bot` for a browser, an app or a script. Check for the values you know: one the API adds later comes back as the string it served.
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
const result = await client.lookup('66.249.66.1', {
|
|
94
|
+
userAgent: 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
|
|
95
|
+
});
|
|
96
|
+
console.log(result.userAgent); // { agent: 'Googlebot', kind: 'bot', verdict: 'verified' }
|
|
97
|
+
|
|
98
|
+
const mine = await client.myIp({ userAgent: navigator.userAgent });
|
|
99
|
+
|
|
100
|
+
const results = await client.lookupBatch(['66.249.66.1', '146.70.116.130'], {
|
|
101
|
+
userAgents: { '66.249.66.1': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)' },
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`userAgents` is keyed by each address as you pass it in the list, as an object or a `Map`. An empty user agent sends none, a long one is sent whole, and the agent is never kept. An answer to a user agent is cached apart from the address's plain answer and from another agent's. A private or reserved address is still answered locally and carries no `userAgent`; neither does an answer without every field.
|
|
106
|
+
|
|
88
107
|
### Your plan and usage
|
|
89
108
|
|
|
90
109
|
```js
|
|
91
110
|
const ent = await client.myEntitlement();
|
|
92
|
-
console.log(ent.plan.key); //
|
|
93
|
-
console.log(ent.plan.name); //
|
|
111
|
+
console.log(ent.plan.key); // data_4
|
|
112
|
+
console.log(ent.plan.name); // Data, the name to show
|
|
94
113
|
console.log(ent.usage.requests); // 580
|
|
95
114
|
console.log(ent.usage.window_end); // when the allowance resets
|
|
96
115
|
```
|
|
@@ -179,7 +198,7 @@ const store = {
|
|
|
179
198
|
const client = new InternetData({ cache: { store: store } });
|
|
180
199
|
```
|
|
181
200
|
|
|
182
|
-
`set` is told how long the answer stays fresh, and dropping it after that is the store's job. Each `key` carries a hash of the client's API key and base URL beside the address, so clients holding different keys can share one store without reading each other's answers. Bogons, errors, `myIp`, `myEntitlement` and the AS and domain lookups are never stored, and a store that fails costs a request, never an answer: a `get` that throws reads as a miss, and a `set` that throws is ignored.
|
|
201
|
+
`set` is told how long the answer stays fresh, and dropping it after that is the store's job. Each `key` carries a hash of the client's API key and base URL beside the address, and the user agent sent with it, if any, so clients holding different keys can share one store without reading each other's answers. Bogons, errors, `myIp`, `myEntitlement` and the AS and domain lookups are never stored, and a store that fails costs a request, never an answer: a `get` that throws reads as a miss, and a `set` that throws is ignored.
|
|
183
202
|
|
|
184
203
|
### Private and reserved addresses
|
|
185
204
|
|
|
@@ -279,9 +298,9 @@ There are official InternetData client libraries available for many languages in
|
|
|
279
298
|
|
|
280
299
|
## About InternetData
|
|
281
300
|
|
|
282
|
-
Geolocation, anonymity, ownership and
|
|
301
|
+
Geolocation, anonymity, ownership, network, service and domain data for any IP address, AS or domain, by API or as databases you download.
|
|
283
302
|
|
|
284
|
-
[<img src="https://s3.internetdata.io/internetdata-public/brand/
|
|
303
|
+
[<picture><source media="(prefers-color-scheme: dark)" srcset="https://s3.internetdata.io/internetdata-public/brand/logo-dark.svg"><img src="https://s3.internetdata.io/internetdata-public/brand/logo.svg" alt="InternetData" height="40"/></picture>](https://internetdata.io/)
|
|
285
304
|
|
|
286
305
|
## License
|
|
287
306
|
|
package/dist/client.d.ts
CHANGED
|
@@ -47,17 +47,32 @@ export interface Options {
|
|
|
47
47
|
/** Override the HTTP implementation, mostly for tests. Defaults to the global `fetch`. */
|
|
48
48
|
fetch?: typeof globalThis.fetch;
|
|
49
49
|
}
|
|
50
|
-
/** Per-call overrides for
|
|
51
|
-
export interface
|
|
50
|
+
/** Per-call overrides for one call. Anything omitted falls back to the client's setting. */
|
|
51
|
+
export interface CallOptions {
|
|
52
52
|
/** Retry attempts for a transient failure, a whole number from 0. */
|
|
53
53
|
retries?: number;
|
|
54
54
|
/** How long one attempt may take before it is abandoned, in milliseconds. */
|
|
55
55
|
timeoutMs?: number;
|
|
56
56
|
}
|
|
57
|
+
/** Per-call options for `lookup` and `myIp`. */
|
|
58
|
+
export interface LookupOptions extends CallOptions {
|
|
59
|
+
/**
|
|
60
|
+
* The `User-Agent` of the client that came from this address. With every field, on a paid
|
|
61
|
+
* plan or the trial, the answer's `userAgent` then names the agent it claims to be and whether
|
|
62
|
+
* this address bears that out. The empty string sends none, and a longer one than the API's
|
|
63
|
+
* 1024 characters is sent whole for the API to cut.
|
|
64
|
+
*/
|
|
65
|
+
userAgent?: string;
|
|
66
|
+
}
|
|
57
67
|
/** Per-call overrides for one batch. Anything omitted falls back to the client's setting. */
|
|
58
|
-
export interface BatchOptions extends
|
|
68
|
+
export interface BatchOptions extends CallOptions {
|
|
59
69
|
/** Concurrent batch requests for THIS batch only. */
|
|
60
70
|
concurrency?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Each address's `User-Agent`, keyed by the address as you pass it in `ips`, sent as
|
|
73
|
+
* `lookup`'s `userAgent` is. An address left out, or given the empty string, sends none.
|
|
74
|
+
*/
|
|
75
|
+
userAgents?: Readonly<Record<string, string>> | ReadonlyMap<string, string>;
|
|
61
76
|
}
|
|
62
77
|
/**
|
|
63
78
|
* A client for the InternetData API, for a browser: a page's own scripts, a web
|
|
@@ -101,6 +116,10 @@ export declare class InternetData {
|
|
|
101
116
|
* address it carries: judged, sent and cached as that, so the answer names
|
|
102
117
|
* `8.8.8.8`. Anything that is not an IP address is refused as `bad_request`
|
|
103
118
|
* before it is sent: an AS is `lookupAsn`'s, and a domain `lookupDomain`'s.
|
|
119
|
+
*
|
|
120
|
+
* With `userAgent`, the answer is cached, stored and shared on the address and
|
|
121
|
+
* that agent together: apart from the address's plain answer and from another
|
|
122
|
+
* agent's. A bogon's answer carries no `userAgent`.
|
|
104
123
|
*/
|
|
105
124
|
lookup(ip: string, options?: LookupOptions): Promise<Result>;
|
|
106
125
|
private answer;
|
|
@@ -116,7 +135,8 @@ export declare class InternetData {
|
|
|
116
135
|
*
|
|
117
136
|
* Deliberately NOT cached. The cache is keyed by address, and which
|
|
118
137
|
* address this is IS the question: a device that moves between networks
|
|
119
|
-
* would otherwise be told where it used to be.
|
|
138
|
+
* would otherwise be told where it used to be. `userAgent` is sent as
|
|
139
|
+
* `lookup` sends it.
|
|
120
140
|
*/
|
|
121
141
|
myIp(options?: LookupOptions): Promise<Result>;
|
|
122
142
|
/**
|
|
@@ -127,7 +147,7 @@ export declare class InternetData {
|
|
|
127
147
|
* Sent as given and not cached. The API refuses a number it cannot read as
|
|
128
148
|
* `bad_request`.
|
|
129
149
|
*/
|
|
130
|
-
lookupAsn(asn: number, options?:
|
|
150
|
+
lookupAsn(asn: number, options?: CallOptions): Promise<AsnResult>;
|
|
131
151
|
/**
|
|
132
152
|
* What InternetData knows about one domain: on every plan whether it is
|
|
133
153
|
* registered and which DNS record types it has, and on a paid one the
|
|
@@ -137,7 +157,7 @@ export declare class InternetData {
|
|
|
137
157
|
* Sent as given and not cached. The API refuses a name it cannot read as
|
|
138
158
|
* `bad_request`.
|
|
139
159
|
*/
|
|
140
|
-
lookupDomain(domain: string, options?:
|
|
160
|
+
lookupDomain(domain: string, options?: CallOptions): Promise<DomainResult>;
|
|
141
161
|
/**
|
|
142
162
|
* What this client's key is entitled to, and how much of it has been used.
|
|
143
163
|
*
|
|
@@ -157,7 +177,7 @@ export declare class InternetData {
|
|
|
157
177
|
* Deliberately NOT cached: the whole point is what has been spent, and a
|
|
158
178
|
* cached answer is a wrong one within seconds of the next request.
|
|
159
179
|
*/
|
|
160
|
-
myEntitlement(options?:
|
|
180
|
+
myEntitlement(options?: CallOptions): Promise<Entitlement>;
|
|
161
181
|
/**
|
|
162
182
|
* Look many addresses up in as few requests as possible.
|
|
163
183
|
*
|
|
@@ -179,6 +199,12 @@ export declare class InternetData {
|
|
|
179
199
|
* `unauthorized` error, and a free-plan key's request of two or more a
|
|
180
200
|
* `bad_request` (HTTP 402). A request of one address is answered as its
|
|
181
201
|
* lookup would be.
|
|
202
|
+
*
|
|
203
|
+
* `userAgents` sends each address's agent, as `user_agents` keyed by the address
|
|
204
|
+
* as the request sends it (an IPv4-mapped one as the IPv4 address it carries),
|
|
205
|
+
* and only in a request where one of its addresses has one. Each address's
|
|
206
|
+
* answer is cached, stored and shared on the address and its agent together,
|
|
207
|
+
* as `lookup`'s is.
|
|
182
208
|
*/
|
|
183
209
|
lookupBatch(ips: Iterable<string>, options?: BatchOptions): Promise<Map<string, Result | InternetDataError>>;
|
|
184
210
|
private unstored;
|
package/dist/client.js
CHANGED
|
@@ -7,7 +7,7 @@ import { errorFromEntry, InternetDataError } from './errors.js';
|
|
|
7
7
|
import { OauthApi } from './oauth.js';
|
|
8
8
|
import { isAsnLookup, isBatch, isBatchError, isDomainLookup, isEntitlement, isLookup } from './shapes.js';
|
|
9
9
|
import { isCacheStore, lifeMs, storeScope, StoreTier } from './store.js';
|
|
10
|
-
import { asError, checkConcurrency, checkRetries, checkTimeout, deadline, readable, withRetry, } from './transport.js';
|
|
10
|
+
import { asError, checkConcurrency, checkRetries, checkTimeout, deadline, readable, strictEncode, withRetry, } from './transport.js';
|
|
11
11
|
import { toAsnResult, toDomainResult, toResult, } from './types.js';
|
|
12
12
|
export const DEFAULT_BASE_URL = 'https://api.internetdata.io';
|
|
13
13
|
// fetch has no whole-request limit of its own, so without this a hung API would
|
|
@@ -25,9 +25,11 @@ const BATCH_MAX = 1000;
|
|
|
25
25
|
*/
|
|
26
26
|
export class InternetData {
|
|
27
27
|
client;
|
|
28
|
-
// Keyed by address
|
|
29
|
-
//
|
|
30
|
-
//
|
|
28
|
+
// Keyed by address, and by the user agent sent with it (`cacheKey`): an
|
|
29
|
+
// answer to one carries that agent's verdict. The context is how a call
|
|
30
|
+
// sends the request when the key has none in flight: `fetch()` runs it
|
|
31
|
+
// synchronously, so a batch knows which addresses it leads before it builds
|
|
32
|
+
// a chunk.
|
|
31
33
|
cache;
|
|
32
34
|
store;
|
|
33
35
|
limit;
|
|
@@ -106,11 +108,16 @@ export class InternetData {
|
|
|
106
108
|
* address it carries: judged, sent and cached as that, so the answer names
|
|
107
109
|
* `8.8.8.8`. Anything that is not an IP address is refused as `bad_request`
|
|
108
110
|
* before it is sent: an AS is `lookupAsn`'s, and a domain `lookupDomain`'s.
|
|
111
|
+
*
|
|
112
|
+
* With `userAgent`, the answer is cached, stored and shared on the address and
|
|
113
|
+
* that agent together: apart from the address's plain answer and from another
|
|
114
|
+
* agent's. A bogon's answer carries no `userAgent`.
|
|
109
115
|
*/
|
|
110
116
|
async lookup(ip, options = {}) {
|
|
111
117
|
// First, or a bogon and a cached address would answer any value.
|
|
112
118
|
checkTimeout(options.timeoutMs);
|
|
113
119
|
checkRetries(options.retries);
|
|
120
|
+
const agent = checkUserAgent(options.userAgent);
|
|
114
121
|
// The API answers an AS or a domain at this path too, in a shape this
|
|
115
122
|
// call cannot read, so one sent here would fail as three retried server errors.
|
|
116
123
|
if (typeof ip !== 'string' || !isAddress(unmapped(ip))) {
|
|
@@ -122,25 +129,27 @@ export class InternetData {
|
|
|
122
129
|
return bogonResult(addr);
|
|
123
130
|
}
|
|
124
131
|
if (this.cache === null) {
|
|
125
|
-
return this.serve(addr, options);
|
|
132
|
+
return this.serve(addr, agent, options);
|
|
126
133
|
}
|
|
127
|
-
return (await this.cache.fetch(addr,
|
|
134
|
+
return (await this.cache.fetch(cacheKey(addr, agent), {
|
|
135
|
+
context: () => this.answer(addr, agent, options),
|
|
136
|
+
}));
|
|
128
137
|
}
|
|
129
138
|
// A miss in memory: the store's answer if it holds one, else the API's, kept.
|
|
130
|
-
async answer(ip, options) {
|
|
131
|
-
const stored = await this.store?.get(ip);
|
|
139
|
+
async answer(ip, agent, options) {
|
|
140
|
+
const stored = await this.store?.get(ip, agent);
|
|
132
141
|
if (stored !== undefined) {
|
|
133
142
|
return stored;
|
|
134
143
|
}
|
|
135
|
-
const served = await this.serve(ip, options);
|
|
136
|
-
await this.store?.set(ip, served);
|
|
144
|
+
const served = await this.serve(ip, agent, options);
|
|
145
|
+
await this.store?.set(ip, agent, served);
|
|
137
146
|
return served;
|
|
138
147
|
}
|
|
139
|
-
async serve(ip, options) {
|
|
148
|
+
async serve(ip, agent, options) {
|
|
140
149
|
const timeoutMs = options.timeoutMs ?? this.timeoutMs;
|
|
141
150
|
return withRetry(options.retries ?? this.retries, async () => {
|
|
142
151
|
const res = await deadline(timeoutMs, (signal) => lookupIp({
|
|
143
|
-
client: this.client, path: { ip: ip }, signal: signal,
|
|
152
|
+
client: this.client, path: { ip: ip }, signal: signal, ...agentQuery(agent),
|
|
144
153
|
}));
|
|
145
154
|
return toResult(readable(res, isLookup));
|
|
146
155
|
});
|
|
@@ -156,13 +165,16 @@ export class InternetData {
|
|
|
156
165
|
*
|
|
157
166
|
* Deliberately NOT cached. The cache is keyed by address, and which
|
|
158
167
|
* address this is IS the question: a device that moves between networks
|
|
159
|
-
* would otherwise be told where it used to be.
|
|
168
|
+
* would otherwise be told where it used to be. `userAgent` is sent as
|
|
169
|
+
* `lookup` sends it.
|
|
160
170
|
*/
|
|
161
171
|
async myIp(options = {}) {
|
|
162
172
|
const timeoutMs = checkTimeout(options.timeoutMs) ?? this.timeoutMs;
|
|
163
|
-
|
|
173
|
+
const retries = checkRetries(options.retries) ?? this.retries;
|
|
174
|
+
const agent = checkUserAgent(options.userAgent);
|
|
175
|
+
return withRetry(retries, async () => {
|
|
164
176
|
const res = await deadline(timeoutMs, (signal) => lookupMyIp({
|
|
165
|
-
client: this.client, signal: signal,
|
|
177
|
+
client: this.client, signal: signal, ...agentQuery(agent),
|
|
166
178
|
}));
|
|
167
179
|
return toResult(readable(res, isLookup));
|
|
168
180
|
});
|
|
@@ -251,11 +263,18 @@ export class InternetData {
|
|
|
251
263
|
* `unauthorized` error, and a free-plan key's request of two or more a
|
|
252
264
|
* `bad_request` (HTTP 402). A request of one address is answered as its
|
|
253
265
|
* lookup would be.
|
|
266
|
+
*
|
|
267
|
+
* `userAgents` sends each address's agent, as `user_agents` keyed by the address
|
|
268
|
+
* as the request sends it (an IPv4-mapped one as the IPv4 address it carries),
|
|
269
|
+
* and only in a request where one of its addresses has one. Each address's
|
|
270
|
+
* answer is cached, stored and shared on the address and its agent together,
|
|
271
|
+
* as `lookup`'s is.
|
|
254
272
|
*/
|
|
255
273
|
async lookupBatch(ips, options = {}) {
|
|
256
274
|
const concurrency = checkConcurrency(options.concurrency);
|
|
257
275
|
checkTimeout(options.timeoutMs);
|
|
258
276
|
checkRetries(options.retries);
|
|
277
|
+
const agents = checkUserAgents(options.userAgents);
|
|
259
278
|
const asked = [...new Set(ips)];
|
|
260
279
|
const unique = [...new Set(asked.map(unmapped))];
|
|
261
280
|
const out = new Map();
|
|
@@ -271,7 +290,8 @@ export class InternetData {
|
|
|
271
290
|
out.set(ip, bogonResult(ip));
|
|
272
291
|
continue;
|
|
273
292
|
}
|
|
274
|
-
const
|
|
293
|
+
const key = cacheKey(ip, agents.get(ip));
|
|
294
|
+
const hit = this.cache?.get(key);
|
|
275
295
|
if (hit !== undefined) {
|
|
276
296
|
out.set(ip, hit);
|
|
277
297
|
continue;
|
|
@@ -280,7 +300,7 @@ export class InternetData {
|
|
|
280
300
|
pending.push(ip);
|
|
281
301
|
continue;
|
|
282
302
|
}
|
|
283
|
-
shared.push([ip, this.cache.fetch(
|
|
303
|
+
shared.push([ip, this.cache.fetch(key, {
|
|
284
304
|
context: () => {
|
|
285
305
|
const landing = deferred();
|
|
286
306
|
led.set(ip, landing);
|
|
@@ -289,7 +309,7 @@ export class InternetData {
|
|
|
289
309
|
},
|
|
290
310
|
})]);
|
|
291
311
|
}
|
|
292
|
-
const sending = this.store === null ? pending : await this.unstored(pending, led);
|
|
312
|
+
const sending = this.store === null ? pending : await this.unstored(pending, agents, led);
|
|
293
313
|
// A per-call concurrency gets its own limiter; without one the call
|
|
294
314
|
// would share the instance's budget and silently ignore the override.
|
|
295
315
|
const limit = concurrency === undefined ? this.limit : pLimit(concurrency);
|
|
@@ -300,7 +320,7 @@ export class InternetData {
|
|
|
300
320
|
await Promise.all([
|
|
301
321
|
...chunks.map((chunk) => limit(async () => {
|
|
302
322
|
const kept = [];
|
|
303
|
-
for (const [ip, answer] of await this.lookupChunk(chunk, options)) {
|
|
323
|
+
for (const [ip, answer] of await this.lookupChunk(chunk, agents, options)) {
|
|
304
324
|
const landing = led.get(ip);
|
|
305
325
|
if (landing === undefined) {
|
|
306
326
|
out.set(ip, answer);
|
|
@@ -312,7 +332,7 @@ export class InternetData {
|
|
|
312
332
|
landing.resolve(answer);
|
|
313
333
|
}
|
|
314
334
|
if (this.store !== null && !(answer instanceof InternetDataError)) {
|
|
315
|
-
kept.push(this.store.set(ip, answer));
|
|
335
|
+
kept.push(this.store.set(ip, agents.get(ip), answer));
|
|
316
336
|
}
|
|
317
337
|
}
|
|
318
338
|
await Promise.all(kept);
|
|
@@ -333,8 +353,8 @@ export class InternetData {
|
|
|
333
353
|
}
|
|
334
354
|
// The addresses this batch leads that the store does not hold, in the order
|
|
335
355
|
// given. One the store holds lands at once, as a request's answer would.
|
|
336
|
-
async unstored(ips, led) {
|
|
337
|
-
const stored = await Promise.all(ips.map((ip) => this.store.get(ip)));
|
|
356
|
+
async unstored(ips, agents, led) {
|
|
357
|
+
const stored = await Promise.all(ips.map((ip) => this.store.get(ip, agents.get(ip))));
|
|
338
358
|
return ips.filter((ip, i) => {
|
|
339
359
|
const hit = stored[i];
|
|
340
360
|
if (hit === undefined) {
|
|
@@ -348,14 +368,15 @@ export class InternetData {
|
|
|
348
368
|
// chunk-level failure - the call refused, the transport failing, the
|
|
349
369
|
// retries exhausted - becomes every address's error, exactly as it would
|
|
350
370
|
// have been had each been looked up alone.
|
|
351
|
-
async lookupChunk(chunk, options) {
|
|
371
|
+
async lookupChunk(chunk, agents, options) {
|
|
352
372
|
const out = new Map();
|
|
353
373
|
const timeoutMs = options.timeoutMs ?? this.timeoutMs;
|
|
374
|
+
const request = batchRequest(chunk, agents);
|
|
354
375
|
let body;
|
|
355
376
|
try {
|
|
356
377
|
body = await withRetry(options.retries ?? this.retries, async () => {
|
|
357
378
|
const res = await deadline(timeoutMs, (signal) => lookupBatch({
|
|
358
|
-
client: this.client, body:
|
|
379
|
+
client: this.client, body: request, signal: signal,
|
|
359
380
|
}));
|
|
360
381
|
return readable(res, isBatch);
|
|
361
382
|
});
|
|
@@ -445,6 +466,63 @@ function checkCacheOption(name, value) {
|
|
|
445
466
|
}
|
|
446
467
|
return value;
|
|
447
468
|
}
|
|
469
|
+
/** The agent a call sends, `undefined` for none: the empty string is none, as the API reads `user_agent=`. */
|
|
470
|
+
function checkUserAgent(userAgent) {
|
|
471
|
+
if (userAgent === undefined || userAgent === null || userAgent === '') {
|
|
472
|
+
return undefined;
|
|
473
|
+
}
|
|
474
|
+
if (typeof userAgent !== 'string') {
|
|
475
|
+
throw new InternetDataError('bad_request', `userAgent must be a string, got ${typeof userAgent}`);
|
|
476
|
+
}
|
|
477
|
+
return userAgent;
|
|
478
|
+
}
|
|
479
|
+
/** A batch's user agents, keyed by each address as the batch sends it, every empty one dropped. */
|
|
480
|
+
function checkUserAgents(userAgents) {
|
|
481
|
+
const agents = new Map();
|
|
482
|
+
if (userAgents === undefined || userAgents === null) {
|
|
483
|
+
return agents;
|
|
484
|
+
}
|
|
485
|
+
if (typeof userAgents !== 'object') {
|
|
486
|
+
throw new InternetDataError('bad_request', `userAgents must map addresses to agents, got ${typeof userAgents}`);
|
|
487
|
+
}
|
|
488
|
+
const entries = userAgents instanceof Map ? [...userAgents.entries()] : Object.entries(userAgents);
|
|
489
|
+
for (const [ip, agent] of entries) {
|
|
490
|
+
const checked = checkUserAgent(agent);
|
|
491
|
+
if (checked !== undefined) {
|
|
492
|
+
agents.set(unmapped(String(ip)), checked);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return agents;
|
|
496
|
+
}
|
|
497
|
+
// An answer to an address with an agent carries that agent's verdict, so it is
|
|
498
|
+
// never served for the address alone or for another agent. The address alone
|
|
499
|
+
// stays the key of a lookup sending none.
|
|
500
|
+
function cacheKey(ip, agent) {
|
|
501
|
+
return agent === undefined ? ip : JSON.stringify([ip, agent]);
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* One chunk's body: `user_agents` only when an address of THIS chunk has one, never
|
|
505
|
+
* `{}`, keyed by each address exactly as `ips` sends it.
|
|
506
|
+
*/
|
|
507
|
+
function batchRequest(chunk, agents) {
|
|
508
|
+
const sent = chunk.filter((ip) => agents.has(ip)).map((ip) => [ip, agents.get(ip)]);
|
|
509
|
+
return sent.length === 0 ? { ips: chunk } : { ips: chunk, user_agents: Object.fromEntries(sent) };
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* The query a lookup sends its agent in, every reserved character percent-encoded,
|
|
513
|
+
* `+` among them, which a server reads as a space. Set by hand, so nothing checks
|
|
514
|
+
* the spec's 1024-character bound before the API cuts it.
|
|
515
|
+
*/
|
|
516
|
+
function agentQuery(agent) {
|
|
517
|
+
if (agent === undefined) {
|
|
518
|
+
return {};
|
|
519
|
+
}
|
|
520
|
+
return { query: { user_agent: agent }, querySerializer: strictQuery };
|
|
521
|
+
}
|
|
522
|
+
function strictQuery(query) {
|
|
523
|
+
return Object.entries(query).filter(([, value]) => value !== undefined && value !== null)
|
|
524
|
+
.map(([name, value]) => `${strictEncode(name)}=${strictEncode(String(value))}`).join('&');
|
|
525
|
+
}
|
|
448
526
|
function unreadableEntry(ip) {
|
|
449
527
|
return new InternetDataError('server_error', `unreadable batch answer for ${ip}, status 200`, 200);
|
|
450
528
|
}
|
|
@@ -128,7 +128,7 @@ export type LookupResponse = {
|
|
|
128
128
|
*/
|
|
129
129
|
is_bogon: boolean;
|
|
130
130
|
/**
|
|
131
|
-
* In VPN IP: a VPN service's server.
|
|
131
|
+
* In VPN IP: a VPN service's server. On a paid plan or the trial.
|
|
132
132
|
*/
|
|
133
133
|
is_vpn?: boolean;
|
|
134
134
|
/**
|
|
@@ -140,27 +140,27 @@ export type LookupResponse = {
|
|
|
140
140
|
*/
|
|
141
141
|
is_relay: boolean;
|
|
142
142
|
/**
|
|
143
|
-
* In Residential Proxy IP's 90-day window: a residential proxy exit.
|
|
143
|
+
* In Residential Proxy IP's 90-day window: a residential proxy exit. On a paid plan or the trial.
|
|
144
144
|
*/
|
|
145
145
|
is_resproxy?: boolean;
|
|
146
146
|
/**
|
|
147
|
-
* In Datacenter Proxy IP's 90-day window.
|
|
147
|
+
* In Datacenter Proxy IP's 90-day window. On a paid plan or the trial.
|
|
148
148
|
*/
|
|
149
149
|
is_dcproxy?: boolean;
|
|
150
150
|
/**
|
|
151
|
-
* In Mobile Proxy IP's 90-day window.
|
|
151
|
+
* In Mobile Proxy IP's 90-day window. On a paid plan or the trial.
|
|
152
152
|
*/
|
|
153
153
|
is_mobproxy?: boolean;
|
|
154
154
|
/**
|
|
155
|
-
* In Public Proxy IP: a public proxy listens here, or its traffic left from here.
|
|
155
|
+
* In Public Proxy IP: a public proxy listens here, or its traffic left from here. On a paid plan or the trial.
|
|
156
156
|
*/
|
|
157
157
|
is_pubproxy?: boolean;
|
|
158
158
|
/**
|
|
159
|
-
* In Hosting IP: a hosting or cloud network.
|
|
159
|
+
* In Hosting IP: a hosting or cloud network. On a paid plan or the trial.
|
|
160
160
|
*/
|
|
161
161
|
is_hosting?: boolean;
|
|
162
162
|
/**
|
|
163
|
-
* In CDN IP: a content delivery network.
|
|
163
|
+
* In CDN IP: a content delivery network. On a paid plan or the trial.
|
|
164
164
|
*/
|
|
165
165
|
is_cdn?: boolean;
|
|
166
166
|
/**
|
|
@@ -200,7 +200,7 @@ export type LookupResponse = {
|
|
|
200
200
|
*/
|
|
201
201
|
is_bittorrent: boolean;
|
|
202
202
|
/**
|
|
203
|
-
* VPN IP's row, `{}` when `is_vpn` is false.
|
|
203
|
+
* VPN IP's row, `{}` when `is_vpn` is false. On a paid plan or the trial.
|
|
204
204
|
*/
|
|
205
205
|
vpn?: ClassDetail;
|
|
206
206
|
/**
|
|
@@ -212,59 +212,59 @@ export type LookupResponse = {
|
|
|
212
212
|
*/
|
|
213
213
|
relay: ClassDetail;
|
|
214
214
|
/**
|
|
215
|
-
* `{}` when `is_resproxy` is false.
|
|
215
|
+
* `{}` when `is_resproxy` is false. On a paid plan or the trial.
|
|
216
216
|
*/
|
|
217
217
|
resproxy?: ProxyDetail;
|
|
218
218
|
/**
|
|
219
|
-
* `{}` when `is_dcproxy` is false.
|
|
219
|
+
* `{}` when `is_dcproxy` is false. On a paid plan or the trial.
|
|
220
220
|
*/
|
|
221
221
|
dcproxy?: ProxyDetail;
|
|
222
222
|
/**
|
|
223
|
-
* `{}` when `is_mobproxy` is false.
|
|
223
|
+
* `{}` when `is_mobproxy` is false. On a paid plan or the trial.
|
|
224
224
|
*/
|
|
225
225
|
mobproxy?: ProxyDetail;
|
|
226
226
|
/**
|
|
227
|
-
* `{}` when `is_pubproxy` is false.
|
|
227
|
+
* `{}` when `is_pubproxy` is false. On a paid plan or the trial.
|
|
228
228
|
*/
|
|
229
229
|
pubproxy?: PubproxyDetail;
|
|
230
230
|
/**
|
|
231
|
-
* `{}` when `is_hosting` is false.
|
|
231
|
+
* `{}` when `is_hosting` is false. On a paid plan or the trial.
|
|
232
232
|
*/
|
|
233
233
|
hosting?: ClassDetail;
|
|
234
234
|
/**
|
|
235
|
-
* `{}` when `is_cdn` is false.
|
|
235
|
+
* `{}` when `is_cdn` is false. On a paid plan or the trial.
|
|
236
236
|
*/
|
|
237
237
|
cdn?: ClassDetail;
|
|
238
238
|
/**
|
|
239
|
-
* `{}` when `is_bot` is false.
|
|
239
|
+
* `{}` when `is_bot` is false. On a paid plan or the trial.
|
|
240
240
|
*/
|
|
241
241
|
bot?: BotDetail;
|
|
242
242
|
/**
|
|
243
|
-
* `{}` when `is_carrier` is false.
|
|
243
|
+
* `{}` when `is_carrier` is false. On a paid plan or the trial.
|
|
244
244
|
*/
|
|
245
245
|
carrier?: CarrierDetail;
|
|
246
246
|
/**
|
|
247
|
-
* `{}` when `is_satellite` is false.
|
|
247
|
+
* `{}` when `is_satellite` is false. On a paid plan or the trial.
|
|
248
248
|
*/
|
|
249
249
|
satellite?: SatelliteDetail;
|
|
250
250
|
/**
|
|
251
|
-
* `{}` when `is_ssh` is false.
|
|
251
|
+
* `{}` when `is_ssh` is false. On a paid plan or the trial.
|
|
252
252
|
*/
|
|
253
253
|
ssh?: SshDetail;
|
|
254
254
|
/**
|
|
255
|
-
* `{}` when `is_smtp` is false.
|
|
255
|
+
* `{}` when `is_smtp` is false. On a paid plan or the trial.
|
|
256
256
|
*/
|
|
257
257
|
smtp?: SmtpDetail;
|
|
258
258
|
/**
|
|
259
|
-
* A row per port that answered, lowest first; `[]` when `is_web` is false.
|
|
259
|
+
* A row per port that answered, lowest first; `[]` when `is_web` is false. On a paid plan or the trial.
|
|
260
260
|
*/
|
|
261
261
|
web?: Array<WebDetail>;
|
|
262
262
|
/**
|
|
263
|
-
* `{}` when `is_dns_resolver` is false.
|
|
263
|
+
* `{}` when `is_dns_resolver` is false. On a paid plan or the trial.
|
|
264
264
|
*/
|
|
265
265
|
dns_resolver?: DnsResolverDetail;
|
|
266
266
|
/**
|
|
267
|
-
* `{}` when `is_bittorrent` is false.
|
|
267
|
+
* `{}` when `is_bittorrent` is false. On a paid plan or the trial.
|
|
268
268
|
*/
|
|
269
269
|
bittorrent?: BitTorrentDetail;
|
|
270
270
|
location: Location;
|
|
@@ -696,43 +696,43 @@ export type Location = {
|
|
|
696
696
|
*/
|
|
697
697
|
flag_unicode: string;
|
|
698
698
|
/**
|
|
699
|
-
* Region (state or province).
|
|
699
|
+
* Region (state or province). On a paid plan or the trial.
|
|
700
700
|
*/
|
|
701
701
|
region?: string;
|
|
702
702
|
/**
|
|
703
|
-
* ISO 3166-2 region code.
|
|
703
|
+
* ISO 3166-2 region code. On a paid plan or the trial.
|
|
704
704
|
*/
|
|
705
705
|
region_code?: string;
|
|
706
706
|
/**
|
|
707
|
-
* City.
|
|
707
|
+
* City. On a paid plan or the trial.
|
|
708
708
|
*/
|
|
709
709
|
city?: string;
|
|
710
710
|
/**
|
|
711
|
-
* Postal code.
|
|
711
|
+
* Postal code. On a paid plan or the trial.
|
|
712
712
|
*/
|
|
713
713
|
postal_code?: string;
|
|
714
714
|
/**
|
|
715
|
-
* Latitude of the city.
|
|
715
|
+
* Latitude of the city. On a paid plan or the trial.
|
|
716
716
|
*/
|
|
717
717
|
latitude?: number;
|
|
718
718
|
/**
|
|
719
|
-
* Longitude of the city.
|
|
719
|
+
* Longitude of the city. On a paid plan or the trial.
|
|
720
720
|
*/
|
|
721
721
|
longitude?: number;
|
|
722
722
|
/**
|
|
723
|
-
* Radius in km holding the true location with 67% confidence.
|
|
723
|
+
* Radius in km holding the true location with 67% confidence. On a paid plan or the trial.
|
|
724
724
|
*/
|
|
725
725
|
accuracy_radius?: number;
|
|
726
726
|
/**
|
|
727
|
-
* GeoNames ID of the city.
|
|
727
|
+
* GeoNames ID of the city. On a paid plan or the trial.
|
|
728
728
|
*/
|
|
729
729
|
geoname_id?: string;
|
|
730
730
|
/**
|
|
731
|
-
* US TV market (DMA) code.
|
|
731
|
+
* US TV market (DMA) code. On a paid plan or the trial.
|
|
732
732
|
*/
|
|
733
733
|
dma_code?: string;
|
|
734
734
|
/**
|
|
735
|
-
* The day the range's location last changed.
|
|
735
|
+
* The day the range's location last changed. On a paid plan or the trial.
|
|
736
736
|
*/
|
|
737
737
|
last_changed?: string;
|
|
738
738
|
};
|
|
@@ -782,11 +782,11 @@ export type Company = {
|
|
|
782
782
|
*/
|
|
783
783
|
domain: string;
|
|
784
784
|
/**
|
|
785
|
-
* What kind of organization: hosting, isp, business, education, government.
|
|
785
|
+
* What kind of organization: hosting, isp, business, education, government. On a paid plan or the trial.
|
|
786
786
|
*/
|
|
787
787
|
type?: string;
|
|
788
788
|
/**
|
|
789
|
-
* ISO 3166 country code.
|
|
789
|
+
* ISO 3166 country code. On a paid plan or the trial.
|
|
790
790
|
*/
|
|
791
791
|
country?: string;
|
|
792
792
|
};
|
|
@@ -799,36 +799,36 @@ export type AbuseContact = {
|
|
|
799
799
|
*/
|
|
800
800
|
email: string;
|
|
801
801
|
/**
|
|
802
|
-
* The contact.
|
|
802
|
+
* The contact. On a paid plan or the trial.
|
|
803
803
|
*/
|
|
804
804
|
name?: string;
|
|
805
805
|
/**
|
|
806
|
-
* Its phone number.
|
|
806
|
+
* Its phone number. On a paid plan or the trial.
|
|
807
807
|
*/
|
|
808
808
|
phone?: string;
|
|
809
809
|
/**
|
|
810
|
-
* Its postal address.
|
|
810
|
+
* Its postal address. On a paid plan or the trial.
|
|
811
811
|
*/
|
|
812
812
|
address?: string;
|
|
813
813
|
/**
|
|
814
|
-
* ISO 3166 country code.
|
|
814
|
+
* ISO 3166 country code. On a paid plan or the trial.
|
|
815
815
|
*/
|
|
816
816
|
country?: string;
|
|
817
817
|
/**
|
|
818
|
-
* The registry block it was derived from.
|
|
818
|
+
* The registry block it was derived from. On a paid plan or the trial.
|
|
819
819
|
*/
|
|
820
820
|
network?: string;
|
|
821
821
|
/**
|
|
822
|
-
* ARIN reports the contact answered its yearly validation.
|
|
822
|
+
* ARIN reports the contact answered its yearly validation. On a paid plan or the trial.
|
|
823
823
|
*/
|
|
824
824
|
validated?: boolean;
|
|
825
825
|
/**
|
|
826
|
-
* Since when it has not.
|
|
826
|
+
* Since when it has not. On a paid plan or the trial.
|
|
827
827
|
*/
|
|
828
828
|
unvalidated_since?: string;
|
|
829
829
|
};
|
|
830
830
|
/**
|
|
831
|
-
* IP Whois's most specific record covering the address.
|
|
831
|
+
* IP Whois's most specific record covering the address. On a paid plan or the trial.
|
|
832
832
|
*/
|
|
833
833
|
export type Whois = {
|
|
834
834
|
/**
|
|
@@ -869,7 +869,7 @@ export type Whois = {
|
|
|
869
869
|
asn: number;
|
|
870
870
|
};
|
|
871
871
|
/**
|
|
872
|
-
* IP RWHOIS's most specific network covering the address.
|
|
872
|
+
* IP RWHOIS's most specific network covering the address. On a paid plan or the trial.
|
|
873
873
|
*/
|
|
874
874
|
export type Rwhois = {
|
|
875
875
|
/**
|
|
@@ -898,7 +898,7 @@ export type Rwhois = {
|
|
|
898
898
|
abuse_email: string;
|
|
899
899
|
};
|
|
900
900
|
/**
|
|
901
|
-
* From IP Hosted Domains: how many registered domains resolve to the address, and the 10 most popular. Its database lists up to 1,000 an address.
|
|
901
|
+
* From IP Hosted Domains: how many registered domains resolve to the address, and the 10 most popular. Its database lists up to 1,000 an address. On a paid plan or the trial.
|
|
902
902
|
*/
|
|
903
903
|
export type HostedDomains = {
|
|
904
904
|
/**
|
|
@@ -911,7 +911,7 @@ export type HostedDomains = {
|
|
|
911
911
|
domains?: Array<string>;
|
|
912
912
|
};
|
|
913
913
|
/**
|
|
914
|
-
* From ASN Hosted Domains: how many registered domains the AS hosts, and the 10 most popular. Its database lists up to 1,000 an AS.
|
|
914
|
+
* From ASN Hosted Domains: how many registered domains the AS hosts, and the 10 most popular. Its database lists up to 1,000 an AS. On a paid plan or the trial.
|
|
915
915
|
*/
|
|
916
916
|
export type AsnHostedDomains = {
|
|
917
917
|
/**
|
|
@@ -952,73 +952,73 @@ export type AsnLookupResponse = {
|
|
|
952
952
|
*/
|
|
953
953
|
domain: string;
|
|
954
954
|
/**
|
|
955
|
-
* The kind of network it runs.
|
|
955
|
+
* The kind of network it runs. On a paid plan or the trial.
|
|
956
956
|
*/
|
|
957
957
|
type?: string;
|
|
958
958
|
/**
|
|
959
|
-
* IPv4 addresses it announces.
|
|
959
|
+
* IPv4 addresses it announces. On a paid plan or the trial.
|
|
960
960
|
*/
|
|
961
961
|
num_ips?: number;
|
|
962
962
|
/**
|
|
963
|
-
* IPv4 prefixes it announces.
|
|
963
|
+
* IPv4 prefixes it announces. On a paid plan or the trial.
|
|
964
964
|
*/
|
|
965
965
|
num_prefixes4?: number;
|
|
966
966
|
/**
|
|
967
|
-
* IPv6 prefixes it announces.
|
|
967
|
+
* IPv6 prefixes it announces. On a paid plan or the trial.
|
|
968
968
|
*/
|
|
969
969
|
num_prefixes6?: number;
|
|
970
970
|
/**
|
|
971
|
-
* Its announcements RPKI calls valid.
|
|
971
|
+
* Its announcements RPKI calls valid. On a paid plan or the trial.
|
|
972
972
|
*/
|
|
973
973
|
rpki_valid?: number;
|
|
974
974
|
/**
|
|
975
|
-
* Invalid.
|
|
975
|
+
* Invalid. On a paid plan or the trial.
|
|
976
976
|
*/
|
|
977
977
|
rpki_invalid?: number;
|
|
978
978
|
/**
|
|
979
|
-
* With no RPKI record.
|
|
979
|
+
* With no RPKI record. On a paid plan or the trial.
|
|
980
980
|
*/
|
|
981
981
|
rpki_not_found?: number;
|
|
982
982
|
/**
|
|
983
|
-
* Its ASN Whois record, every column, empty where the registry states nothing.
|
|
983
|
+
* Its ASN Whois record, every column, empty where the registry states nothing. On a paid plan or the trial.
|
|
984
984
|
*/
|
|
985
985
|
whois?: {
|
|
986
986
|
[key: string]: string;
|
|
987
987
|
};
|
|
988
988
|
/**
|
|
989
|
-
* What it announces, IPv4 then IPv6, up to 20000 a family.
|
|
989
|
+
* What it announces, IPv4 then IPv6, up to 20000 a family. On a paid plan or the trial.
|
|
990
990
|
*/
|
|
991
991
|
prefixes?: Array<AsnPrefix>;
|
|
992
992
|
/**
|
|
993
|
-
* Its rank in ASN Extended, by customer cone, 1 the largest; `0` for an AS seen in no AS path.
|
|
993
|
+
* Its rank in ASN Extended, by customer cone, 1 the largest; `0` for an AS seen in no AS path. On a paid plan or the trial.
|
|
994
994
|
*/
|
|
995
995
|
rank?: number;
|
|
996
996
|
/**
|
|
997
|
-
* Whether it is one of the transit-free networks at the top of the hierarchy, which get transit from no one and peer with each other.
|
|
997
|
+
* Whether it is one of the transit-free networks at the top of the hierarchy, which get transit from no one and peer with each other. On a paid plan or the trial.
|
|
998
998
|
*/
|
|
999
999
|
tier1?: boolean;
|
|
1000
1000
|
/**
|
|
1001
|
-
* How many AS numbers it gets transit from.
|
|
1001
|
+
* How many AS numbers it gets transit from. On a paid plan or the trial.
|
|
1002
1002
|
*/
|
|
1003
1003
|
num_upstreams?: number;
|
|
1004
1004
|
/**
|
|
1005
|
-
* Those AS numbers, ascending, up to 20000.
|
|
1005
|
+
* Those AS numbers, ascending, up to 20000. On a paid plan or the trial.
|
|
1006
1006
|
*/
|
|
1007
1007
|
upstreams?: Array<number>;
|
|
1008
1008
|
/**
|
|
1009
|
-
* How many AS numbers it exchanges its own and its customers' routes with.
|
|
1009
|
+
* How many AS numbers it exchanges its own and its customers' routes with. On a paid plan or the trial.
|
|
1010
1010
|
*/
|
|
1011
1011
|
num_peers?: number;
|
|
1012
1012
|
/**
|
|
1013
|
-
* Those AS numbers, ascending, up to 20000.
|
|
1013
|
+
* Those AS numbers, ascending, up to 20000. On a paid plan or the trial.
|
|
1014
1014
|
*/
|
|
1015
1015
|
peers?: Array<number>;
|
|
1016
1016
|
/**
|
|
1017
|
-
* How many AS numbers it provides transit to.
|
|
1017
|
+
* How many AS numbers it provides transit to. On a paid plan or the trial.
|
|
1018
1018
|
*/
|
|
1019
1019
|
num_downstreams?: number;
|
|
1020
1020
|
/**
|
|
1021
|
-
* Those AS numbers, ascending, up to 20000.
|
|
1021
|
+
* Those AS numbers, ascending, up to 20000. On a paid plan or the trial.
|
|
1022
1022
|
*/
|
|
1023
1023
|
downstreams?: Array<number>;
|
|
1024
1024
|
hosted_domains?: AsnHostedDomains;
|
|
@@ -1074,7 +1074,7 @@ export type DomainLookupResponse = {
|
|
|
1074
1074
|
*/
|
|
1075
1075
|
is_registered: boolean;
|
|
1076
1076
|
/**
|
|
1077
|
-
* In Disposable Domain.
|
|
1077
|
+
* In Disposable Domain. On a paid plan or the trial.
|
|
1078
1078
|
*/
|
|
1079
1079
|
is_disposable?: boolean;
|
|
1080
1080
|
/**
|
|
@@ -1099,13 +1099,13 @@ export type DomainLookupResponse = {
|
|
|
1099
1099
|
has_cname: boolean;
|
|
1100
1100
|
dns?: DomainDns;
|
|
1101
1101
|
/**
|
|
1102
|
-
* The network announcing each address in `dns.a` and then `dns.aaaa`, from IP ASN; `[]` where it resolves to none.
|
|
1102
|
+
* The network announcing each address in `dns.a` and then `dns.aaaa`, from IP ASN; `[]` where it resolves to none. On a paid plan or the trial.
|
|
1103
1103
|
*/
|
|
1104
1104
|
hosting?: Array<DomainHost>;
|
|
1105
1105
|
cohosted_domains?: CohostedDomains;
|
|
1106
1106
|
ip_ranges?: DomainIpRanges;
|
|
1107
1107
|
/**
|
|
1108
|
-
* `{}` when `is_disposable` is false.
|
|
1108
|
+
* `{}` when `is_disposable` is false. On a paid plan or the trial.
|
|
1109
1109
|
*/
|
|
1110
1110
|
disposable?: DisposableDetail;
|
|
1111
1111
|
web?: DomainWeb;
|
|
@@ -1134,7 +1134,7 @@ export type DomainHost = {
|
|
|
1134
1134
|
asn: Asn;
|
|
1135
1135
|
};
|
|
1136
1136
|
/**
|
|
1137
|
-
* From IP Hosted Domains: the other registered domains on the domain's first IPv4 address, how many and the 10 most popular.
|
|
1137
|
+
* From IP Hosted Domains: the other registered domains on the domain's first IPv4 address, how many and the 10 most popular. On a paid plan or the trial.
|
|
1138
1138
|
*/
|
|
1139
1139
|
export type CohostedDomains = {
|
|
1140
1140
|
/**
|
|
@@ -1151,7 +1151,7 @@ export type CohostedDomains = {
|
|
|
1151
1151
|
domains: Array<string>;
|
|
1152
1152
|
};
|
|
1153
1153
|
/**
|
|
1154
|
-
* What our crawl last read of the domain's own home page, every member empty where it holds none.
|
|
1154
|
+
* What our crawl last read of the domain's own home page, every member empty where it holds none. On a paid plan or the trial.
|
|
1155
1155
|
*/
|
|
1156
1156
|
export type DomainWeb = {
|
|
1157
1157
|
/**
|
|
@@ -1167,7 +1167,7 @@ export type DomainWeb = {
|
|
|
1167
1167
|
*/
|
|
1168
1168
|
description: string;
|
|
1169
1169
|
/**
|
|
1170
|
-
* The day it was last read.
|
|
1170
|
+
* The day it was last read, empty when the crawl holds no page.
|
|
1171
1171
|
*/
|
|
1172
1172
|
last_seen: string;
|
|
1173
1173
|
links: DomainWebLinks;
|
|
@@ -1186,7 +1186,7 @@ export type DomainWebLinks = {
|
|
|
1186
1186
|
hosts: Array<string>;
|
|
1187
1187
|
};
|
|
1188
1188
|
/**
|
|
1189
|
-
* The registered domains whose home page redirects to this one, how many and the 10 most popular.
|
|
1189
|
+
* The registered domains whose home page redirects to this one, how many and the 10 most popular. On a paid plan or the trial.
|
|
1190
1190
|
*/
|
|
1191
1191
|
export type DomainRedirects = {
|
|
1192
1192
|
/**
|
|
@@ -1199,7 +1199,7 @@ export type DomainRedirects = {
|
|
|
1199
1199
|
domains: Array<string>;
|
|
1200
1200
|
};
|
|
1201
1201
|
/**
|
|
1202
|
-
* The registered domains whose home page links to this one, how many and the 10 most popular.
|
|
1202
|
+
* The registered domains whose home page links to this one, how many and the 10 most popular. On a paid plan or the trial.
|
|
1203
1203
|
*/
|
|
1204
1204
|
export type DomainBacklinks = {
|
|
1205
1205
|
/**
|
|
@@ -1212,7 +1212,7 @@ export type DomainBacklinks = {
|
|
|
1212
1212
|
domains: Array<string>;
|
|
1213
1213
|
};
|
|
1214
1214
|
/**
|
|
1215
|
-
* Its records in Domain DNS, up to 100 a type.
|
|
1215
|
+
* Its records in Domain DNS, up to 100 a type. On a paid plan or the trial.
|
|
1216
1216
|
*/
|
|
1217
1217
|
export type DomainDns = {
|
|
1218
1218
|
a: Array<DnsAddressRecord>;
|
|
@@ -1266,7 +1266,7 @@ export type DnsCnameRecord = {
|
|
|
1266
1266
|
last_seen: string;
|
|
1267
1267
|
};
|
|
1268
1268
|
/**
|
|
1269
|
-
* The organization's IP ranges, from Domain IP Ranges.
|
|
1269
|
+
* The organization's IP ranges, from Domain IP Ranges. On a paid plan or the trial.
|
|
1270
1270
|
*/
|
|
1271
1271
|
export type DomainIpRanges = {
|
|
1272
1272
|
/**
|
|
@@ -1407,7 +1407,8 @@ export type EntitlementPlan = {
|
|
|
1407
1407
|
* The plan the organization is on, as an identifier that is never
|
|
1408
1408
|
* renamed or reused: `free` for the free plan, or a paid plan's key.
|
|
1409
1409
|
* Compare against it and show `name`. On `free`, usage counts its
|
|
1410
|
-
* trial, the lookups answered with every field.
|
|
1410
|
+
* trial, the lookups answered with every field. The Data plan is a key
|
|
1411
|
+
* per quota, `data_1` to `data_7`, each named Data.
|
|
1411
1412
|
*
|
|
1412
1413
|
*/
|
|
1413
1414
|
key: string;
|
|
@@ -1450,11 +1451,15 @@ export type EntitlementUsage = {
|
|
|
1450
1451
|
*/
|
|
1451
1452
|
hard_limit: number | null;
|
|
1452
1453
|
/**
|
|
1453
|
-
* When the current allowance period began.
|
|
1454
|
+
* When the current allowance period began. On the free plan, when
|
|
1455
|
+
* its trial began, or now before a first lookup starts it.
|
|
1456
|
+
*
|
|
1454
1457
|
*/
|
|
1455
1458
|
window_start: string;
|
|
1456
1459
|
/**
|
|
1457
|
-
* When the allowance next resets.
|
|
1460
|
+
* When the allowance next resets. On the free plan, when its trial
|
|
1461
|
+
* ends, which it does once.
|
|
1462
|
+
*
|
|
1458
1463
|
*/
|
|
1459
1464
|
window_end: string;
|
|
1460
1465
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { InternetData, DEFAULT_BASE_URL } from './client.js';
|
|
2
|
-
export type { Options, CacheOptions, LookupOptions, BatchOptions } from './client.js';
|
|
2
|
+
export type { Options, CacheOptions, CallOptions, LookupOptions, BatchOptions } from './client.js';
|
|
3
3
|
export type { CacheStore } from './store.js';
|
|
4
4
|
export { OauthApi } from './oauth.js';
|
|
5
5
|
export type { OauthOptions, AuthorizationUrlOptions, OauthMetadata, TokenResponse, Pkce } from './oauth.js';
|
package/dist/shapes.js
CHANGED
|
@@ -63,19 +63,19 @@ export const LOOKUP_TYPES = {
|
|
|
63
63
|
hosted_domains: 'object', user_agent: 'object', trial_expired: FLAG, cap_reached: FLAG,
|
|
64
64
|
};
|
|
65
65
|
export const CLASS_DETAIL_TYPES = {
|
|
66
|
-
provider: 'string', provider_name: 'string', confidence: 'string', last_seen: '
|
|
66
|
+
provider: 'string', provider_name: 'string', confidence: 'string', last_seen: 'date',
|
|
67
67
|
};
|
|
68
68
|
export const PROXY_DETAIL_TYPES = {
|
|
69
|
-
provider: 'string', provider_name: 'string', first_seen: '
|
|
69
|
+
provider: 'string', provider_name: 'string', first_seen: 'date', last_seen: 'date', hits: 'integer',
|
|
70
70
|
hits_days_pct: 'integer', providers_num: 'integer',
|
|
71
71
|
};
|
|
72
72
|
export const PUBPROXY_DETAIL_TYPES = {
|
|
73
73
|
entry: 'boolean', exit: 'boolean', protocols: 'array', num_ports: 'integer', num_proxies: 'integer',
|
|
74
|
-
last_seen: '
|
|
74
|
+
last_seen: 'date', last_usable: 'string',
|
|
75
75
|
};
|
|
76
76
|
export const BOT_DETAIL_TYPES = {
|
|
77
77
|
provider: 'string', provider_name: 'string', agents: 'array', categories: 'array', verified: 'boolean',
|
|
78
|
-
identity: 'string', verified_by: 'string', confidence: 'string', first_seen: '
|
|
78
|
+
identity: 'string', verified_by: 'string', confidence: 'string', first_seen: 'date', last_seen: 'date',
|
|
79
79
|
};
|
|
80
80
|
export const USER_AGENT_VERDICT_TYPES = {
|
|
81
81
|
agent: 'string', kind: 'string', verdict: 'string',
|
|
@@ -88,24 +88,24 @@ export const SATELLITE_DETAIL_TYPES = {
|
|
|
88
88
|
asn: 'integer', confidence: 'string',
|
|
89
89
|
};
|
|
90
90
|
export const SSH_DETAIL_TYPES = {
|
|
91
|
-
port: 'integer', banner: 'string', host_key_fp: 'string', session_ok: 'boolean', first_seen: '
|
|
92
|
-
last_seen: '
|
|
91
|
+
port: 'integer', banner: 'string', host_key_fp: 'string', session_ok: 'boolean', first_seen: 'date',
|
|
92
|
+
last_seen: 'date',
|
|
93
93
|
};
|
|
94
94
|
export const SMTP_DETAIL_TYPES = {
|
|
95
|
-
port: 'integer', banner: 'string', session_ok: 'boolean', first_seen: '
|
|
95
|
+
port: 'integer', banner: 'string', session_ok: 'boolean', first_seen: 'date', last_seen: 'date',
|
|
96
96
|
};
|
|
97
97
|
export const WEB_DETAIL_TYPES = {
|
|
98
98
|
port: 'integer', tls_ok: 'boolean', session_ok: 'boolean', status_code: 'integer', server: 'string',
|
|
99
99
|
location: 'string', title: 'string', cert_subject_cn: 'string', cert_subject_o: 'string',
|
|
100
|
-
cert_issuer_dn: 'string', cert_browser_trusted: 'boolean', tls_version: 'string', first_seen: '
|
|
101
|
-
last_seen: '
|
|
100
|
+
cert_issuer_dn: 'string', cert_browser_trusted: 'boolean', tls_version: 'string', first_seen: 'date',
|
|
101
|
+
last_seen: 'date',
|
|
102
102
|
};
|
|
103
103
|
export const DNS_RESOLVER_DETAIL_TYPES = {
|
|
104
104
|
port: 'integer', recursion_available: 'boolean', rcode: 'integer', answer_correct: 'boolean',
|
|
105
|
-
first_seen: '
|
|
105
|
+
first_seen: 'date', last_seen: 'date',
|
|
106
106
|
};
|
|
107
107
|
export const BITTORRENT_DETAIL_TYPES = {
|
|
108
|
-
verified: 'boolean', id_matches_ip: 'boolean', first_seen: '
|
|
108
|
+
verified: 'boolean', id_matches_ip: 'boolean', first_seen: 'date', last_seen: 'date',
|
|
109
109
|
last_reachable: 'string', days_seen: 'integer', num_ports: 'integer', peak_num_ports: 'integer',
|
|
110
110
|
indexer: 'boolean', clients: 'array',
|
|
111
111
|
};
|
|
@@ -143,7 +143,7 @@ export const ASN_LOOKUP_TYPES = {
|
|
|
143
143
|
cap_reached: FLAG,
|
|
144
144
|
};
|
|
145
145
|
export const ASN_PREFIX_TYPES = {
|
|
146
|
-
prefix: 'string', peer_count: 'integer', rpki_status: 'string', first_seen: '
|
|
146
|
+
prefix: 'string', peer_count: 'integer', rpki_status: 'string', first_seen: 'date', country: 'string',
|
|
147
147
|
size: 'integer', other_origins: 'array',
|
|
148
148
|
};
|
|
149
149
|
export const DOMAIN_LOOKUP_TYPES = {
|
|
@@ -155,12 +155,12 @@ export const DOMAIN_LOOKUP_TYPES = {
|
|
|
155
155
|
export const DOMAIN_DNS_TYPES = {
|
|
156
156
|
a: 'array', aaaa: 'array', mx: 'array', ns: 'array', cname: 'array',
|
|
157
157
|
};
|
|
158
|
-
export const DNS_ADDRESS_RECORD_TYPES = { ip: 'string', last_seen: '
|
|
158
|
+
export const DNS_ADDRESS_RECORD_TYPES = { ip: 'string', last_seen: 'date' };
|
|
159
159
|
export const DNS_MX_RECORD_TYPES = {
|
|
160
|
-
priority: 'integer', host: 'string', last_seen: '
|
|
160
|
+
priority: 'integer', host: 'string', last_seen: 'date',
|
|
161
161
|
};
|
|
162
|
-
export const DNS_NS_RECORD_TYPES = { host: 'string', last_seen: '
|
|
163
|
-
export const DNS_CNAME_RECORD_TYPES = { target: 'string', last_seen: '
|
|
162
|
+
export const DNS_NS_RECORD_TYPES = { host: 'string', last_seen: 'date' };
|
|
163
|
+
export const DNS_CNAME_RECORD_TYPES = { target: 'string', last_seen: 'date' };
|
|
164
164
|
export const DOMAIN_IP_RANGES_TYPES = {
|
|
165
165
|
domain: 'string', redirects_to: 'string', total: 'integer', ipv4: 'integer', ranges: 'array',
|
|
166
166
|
};
|
|
@@ -176,7 +176,7 @@ export const DOMAIN_WEB_LINKS_TYPES = { total: 'integer', hosts: 'array' };
|
|
|
176
176
|
export const DOMAIN_REDIRECTS_TYPES = { total: 'integer', domains: 'array' };
|
|
177
177
|
export const DOMAIN_BACKLINKS_TYPES = { total: 'integer', domains: 'array' };
|
|
178
178
|
export const DISPOSABLE_DETAIL_TYPES = {
|
|
179
|
-
confidence: 'string', providers: 'array', first_seen: '
|
|
179
|
+
confidence: 'string', providers: 'array', first_seen: 'date', last_seen: 'date',
|
|
180
180
|
};
|
|
181
181
|
export const BATCH_ERROR_TYPES = { status: 'integer', error: 'string' };
|
|
182
182
|
export const ENTITLEMENT_TYPES = {
|
package/dist/store.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ import { type Result } from './types.js';
|
|
|
6
6
|
*
|
|
7
7
|
* `key` is the address with a hash of the client's API key and base URL in front of
|
|
8
8
|
* it, so clients holding different keys, and so entitled to different fields, can
|
|
9
|
-
* share one store without ever reading each other's answers.
|
|
9
|
+
* share one store without ever reading each other's answers. A lookup sending a user
|
|
10
|
+
* agent appends it, `?user_agent=` and the agent percent-encoded, since its answer
|
|
11
|
+
* carries that agent's verdict. `set` is handed how long
|
|
10
12
|
* the answer stays fresh; dropping it once that has passed is the store's job.
|
|
11
13
|
*/
|
|
12
14
|
export interface CacheStore {
|
|
@@ -25,8 +27,8 @@ export declare class StoreTier {
|
|
|
25
27
|
private readonly scope;
|
|
26
28
|
private readonly ttlMs;
|
|
27
29
|
constructor(store: CacheStore, scope: string, ttlMs: number);
|
|
28
|
-
get(ip: string): Promise<Result | undefined>;
|
|
29
|
-
set(ip: string, result: Result): Promise<void>;
|
|
30
|
+
get(ip: string, agent: string | undefined): Promise<Result | undefined>;
|
|
31
|
+
set(ip: string, agent: string | undefined, result: Result): Promise<void>;
|
|
30
32
|
private keyFor;
|
|
31
33
|
}
|
|
32
34
|
/**
|
package/dist/store.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isLookup } from './shapes.js';
|
|
2
|
+
import { strictEncode } from './transport.js';
|
|
2
3
|
import { toResult } from './types.js';
|
|
3
4
|
/**
|
|
4
5
|
* The client's side of a `CacheStore`. A store is a cache, never a source of
|
|
@@ -16,10 +17,10 @@ export class StoreTier {
|
|
|
16
17
|
this.scope = scope;
|
|
17
18
|
this.ttlMs = ttlMs;
|
|
18
19
|
}
|
|
19
|
-
async get(ip) {
|
|
20
|
+
async get(ip, agent) {
|
|
20
21
|
let stored;
|
|
21
22
|
try {
|
|
22
|
-
stored = await this.store.get(this.keyFor(ip));
|
|
23
|
+
stored = await this.store.get(this.keyFor(ip, agent));
|
|
23
24
|
}
|
|
24
25
|
catch {
|
|
25
26
|
return undefined;
|
|
@@ -30,16 +31,17 @@ export class StoreTier {
|
|
|
30
31
|
const raw = stored.raw;
|
|
31
32
|
return isLookup(raw) ? toResult(raw) : undefined;
|
|
32
33
|
}
|
|
33
|
-
async set(ip, result) {
|
|
34
|
+
async set(ip, agent, result) {
|
|
34
35
|
try {
|
|
35
|
-
await this.store.set(this.keyFor(ip), result, lifeMs(result, this.ttlMs));
|
|
36
|
+
await this.store.set(this.keyFor(ip, agent), result, lifeMs(result, this.ttlMs));
|
|
36
37
|
}
|
|
37
38
|
catch {
|
|
38
39
|
// Costs a request on the next miss, nothing more.
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
|
-
keyFor(ip) {
|
|
42
|
-
|
|
42
|
+
keyFor(ip, agent) {
|
|
43
|
+
const key = `${this.scope}:${ip}`;
|
|
44
|
+
return agent === undefined ? key : `${key}?user_agent=${strictEncode(agent)}`;
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
/**
|
package/dist/transport.d.ts
CHANGED
|
@@ -48,4 +48,9 @@ export declare function checkConcurrency(concurrency: number | null | undefined)
|
|
|
48
48
|
*/
|
|
49
49
|
export declare function deadline<T>(timeoutMs: number, fn: (signal: AbortSignal) => Promise<T>): Promise<T>;
|
|
50
50
|
export declare function withRetry<T>(retries: number, fn: () => Promise<T>): Promise<T>;
|
|
51
|
+
/**
|
|
52
|
+
* `encodeURIComponent`, and `!'()*` too, so every reserved character goes out
|
|
53
|
+
* percent-encoded: `+` among them, which a server reads as a space.
|
|
54
|
+
*/
|
|
55
|
+
export declare function strictEncode(value: string): string;
|
|
51
56
|
export declare function asError(err: unknown): InternetDataError;
|
package/dist/transport.js
CHANGED
|
@@ -135,6 +135,13 @@ export async function withRetry(retries, fn) {
|
|
|
135
135
|
throw asError(err);
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* `encodeURIComponent`, and `!'()*` too, so every reserved character goes out
|
|
140
|
+
* percent-encoded: `+` among them, which a server reads as a space.
|
|
141
|
+
*/
|
|
142
|
+
export function strictEncode(value) {
|
|
143
|
+
return encodeURIComponent(value).replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
144
|
+
}
|
|
138
145
|
export function asError(err) {
|
|
139
146
|
if (err instanceof InternetDataError) {
|
|
140
147
|
return err;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "internetdata-web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Official browser client library for the InternetData API. Look up IP addresses, ASNs and domains from a page or a browser extension.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@hey-api/openapi-ts": "^0.99.0",
|
|
56
|
-
"@mslmio/eslint-config": "^
|
|
57
|
-
"eslint": "^10.
|
|
56
|
+
"@mslmio/eslint-config": "^2.6.2",
|
|
57
|
+
"eslint": "^10.15.0",
|
|
58
58
|
"playwright-core": "1.62.1",
|
|
59
59
|
"typescript": "^6.0.3"
|
|
60
60
|
},
|