abuseipdb-client 0.1.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/LICENSE +16 -0
- package/README.md +189 -0
- package/dist/index.js +5292 -0
- package/dist/index.mjs +602 -0
- package/dist/types/index.d.ts +754 -0
- package/package.json +93 -0
|
@@ -0,0 +1,754 @@
|
|
|
1
|
+
import { DocWithErrors } from 'jsonapi-typescript';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Utility type, represents a non empty array.
|
|
6
|
+
* @group Helpers
|
|
7
|
+
*/
|
|
8
|
+
type NonEmptyArr<T> = [T, ...T[]];
|
|
9
|
+
/**
|
|
10
|
+
* Wrapper for IPDB's JSON API error response.
|
|
11
|
+
* This empty interface is used for renaming the DocWithErrors external import.
|
|
12
|
+
* @group AbuseIPDB API Response
|
|
13
|
+
*/
|
|
14
|
+
interface APIResponseError extends DocWithErrors {
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Client response for parsed IPDB's API endpoints.
|
|
18
|
+
* @group Client Wrapper
|
|
19
|
+
*/
|
|
20
|
+
interface ClientResponse<T extends APIResponse> {
|
|
21
|
+
headers: ClientHeaders;
|
|
22
|
+
result?: Extract<APIResponse, T>;
|
|
23
|
+
error?: APIResponseError;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Wrapper for client headers, includes some of the fetch response fields and API rate limit headers.
|
|
27
|
+
* @group Client Wrapper
|
|
28
|
+
*/
|
|
29
|
+
interface ClientHeaders extends ClientAPIRateLimitHTTPHeaders, ClientFetchResponseHeaders {
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* IPDB's API rate-limit HTTP headers.
|
|
33
|
+
* @group Client Wrapper
|
|
34
|
+
*/
|
|
35
|
+
interface ClientAPIRateLimitHTTPHeaders {
|
|
36
|
+
'retry-after'?: string;
|
|
37
|
+
'x-ratelimit-limit': string;
|
|
38
|
+
'x-ratelimit-remaining': string;
|
|
39
|
+
'x-ratelimit-reset'?: string;
|
|
40
|
+
'x-generated-at'?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Fetch fields extracted from the API response.
|
|
44
|
+
* @group Client Wrapper
|
|
45
|
+
*/
|
|
46
|
+
interface ClientFetchResponseHeaders {
|
|
47
|
+
url: string;
|
|
48
|
+
status: number;
|
|
49
|
+
statusText: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Union of all IPDB API responses.
|
|
53
|
+
* @group AbuseIPDB API Response
|
|
54
|
+
*/
|
|
55
|
+
type APIResponse = APICheckEndpointResponse | APIReportsEndpointResponse | APIBlacklistEndpointResponse | APIBlacklistEndpointTextResponse | APIReportEndpointResponse | APICheckBlockEndpointResponse | APIBulkReportEndpointResponse | APIClearAddressEndpointResponse | APIServerErrorResultResponse;
|
|
56
|
+
/**
|
|
57
|
+
* AbuseIPDB's Check endpoint JSON structure.
|
|
58
|
+
* @see [Check Endpoint API](https://docs.abuseipdb.com/#check-endpoint)
|
|
59
|
+
* @group AbuseIPDB API Response
|
|
60
|
+
*/
|
|
61
|
+
interface APICheckEndpointResponse {
|
|
62
|
+
data: {
|
|
63
|
+
ipAddress: string;
|
|
64
|
+
isPublic: boolean;
|
|
65
|
+
ipVersion?: number;
|
|
66
|
+
isWhitelisted: boolean;
|
|
67
|
+
abuseConfidenceScore: number;
|
|
68
|
+
countryCode: string | null;
|
|
69
|
+
countryName?: string | null;
|
|
70
|
+
usageType: UsageType;
|
|
71
|
+
isp: string;
|
|
72
|
+
domain: string | null;
|
|
73
|
+
hostnames: Array<string>;
|
|
74
|
+
totalReports: number;
|
|
75
|
+
numDistinctUsers: number;
|
|
76
|
+
lastReportedAt: string;
|
|
77
|
+
reports: Array<ReportsEntity>;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* AbuseIPDB's Reports endpoint JSON structure.
|
|
82
|
+
* @see [Reports Endpoint API](https://docs.abuseipdb.com/#reports-endpoint)
|
|
83
|
+
* @group AbuseIPDB API Response
|
|
84
|
+
*/
|
|
85
|
+
interface APIReportsEndpointResponse {
|
|
86
|
+
data: {
|
|
87
|
+
total: number;
|
|
88
|
+
page: number;
|
|
89
|
+
count: number;
|
|
90
|
+
perPage: number;
|
|
91
|
+
lastPage: number;
|
|
92
|
+
nextPageUrl: string | null;
|
|
93
|
+
previousPageUrl: string | null;
|
|
94
|
+
results: Array<ReportsEntity>;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* AbuseIPDB's Blacklist endpoint JSON structure.
|
|
99
|
+
* @see [Blacklist JSON Endpoint API](https://docs.abuseipdb.com/#blacklist-endpoint)
|
|
100
|
+
* @group AbuseIPDB API Response
|
|
101
|
+
*/
|
|
102
|
+
interface APIBlacklistEndpointResponse {
|
|
103
|
+
meta: {
|
|
104
|
+
generatedAt: string;
|
|
105
|
+
};
|
|
106
|
+
data: [
|
|
107
|
+
{
|
|
108
|
+
ipAddress: string;
|
|
109
|
+
countryCode: string;
|
|
110
|
+
abuseConfidenceScore: number;
|
|
111
|
+
lastReportedAt: string;
|
|
112
|
+
}
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* AbuseIPDB's Blacklist endpoint text structure.
|
|
117
|
+
* For the blacklist endpoint as plaintext, the `x-generated-at` API header is included, but
|
|
118
|
+
* for keeping consistency over the client wrapped responses, it is moved to the `meta`
|
|
119
|
+
* attribute, and the text body content is wrapped in a `data` attribute.
|
|
120
|
+
* @see [Blacklist Text Endpoint API](https://docs.abuseipdb.com/#plaintext-blacklist)
|
|
121
|
+
* @group AbuseIPDB API Response
|
|
122
|
+
*/
|
|
123
|
+
interface APIBlacklistEndpointTextResponse {
|
|
124
|
+
meta: {
|
|
125
|
+
generatedAt: string;
|
|
126
|
+
};
|
|
127
|
+
data: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* AbuseIPDB's Report endpoint JSON structure.
|
|
131
|
+
* @see [Report Endpoint API](https://docs.abuseipdb.com/#report-endpoint)
|
|
132
|
+
* @group AbuseIPDB API Response
|
|
133
|
+
*/
|
|
134
|
+
interface APIReportEndpointResponse {
|
|
135
|
+
data: {
|
|
136
|
+
ipAddress: string;
|
|
137
|
+
abuseConfidenceScore: number;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* AbuseIPDB's Check-Block endpoint JSON structure.
|
|
142
|
+
* @see [Check-Block Endpoint API](https://docs.abuseipdb.com/#check-block-endpoint)
|
|
143
|
+
* @group AbuseIPDB API Response
|
|
144
|
+
*/
|
|
145
|
+
interface APICheckBlockEndpointResponse {
|
|
146
|
+
data: {
|
|
147
|
+
networkAddress: string;
|
|
148
|
+
netmask: string;
|
|
149
|
+
minAddress: string;
|
|
150
|
+
maxAddress: string;
|
|
151
|
+
numPossibleHosts: number;
|
|
152
|
+
addressSpaceDesc: string;
|
|
153
|
+
reportedAddress: NonEmptyArr<ReportedAddressEntity>;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* AbuseIPDB's Bulk-Report endpoint JSON structure.
|
|
158
|
+
* @see [Bulk-Report Endpoint API](https://docs.abuseipdb.com/#bulk-report-endpoint)
|
|
159
|
+
* @group AbuseIPDB API Response
|
|
160
|
+
*/
|
|
161
|
+
interface APIBulkReportEndpointResponse {
|
|
162
|
+
data: {
|
|
163
|
+
savedReports: number;
|
|
164
|
+
invalidReports: Array<InvalidReportsEntity>;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* AbuseIPDB's Clear-Address endpoint JSON structure.
|
|
169
|
+
* @see [Clear-Address Endpoint API](https://docs.abuseipdb.com/#clear-address-endpoint)
|
|
170
|
+
* @group AbuseIPDB API Response
|
|
171
|
+
*/
|
|
172
|
+
interface APIClearAddressEndpointResponse {
|
|
173
|
+
data: {
|
|
174
|
+
numReportsDeleted: number;
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* AbuseIPDB's Server Error message structure.
|
|
179
|
+
* When a server error occurs (5xx), there's a message string
|
|
180
|
+
* present on the result response structure.
|
|
181
|
+
* This is not the same as the `APIResponseError` object.
|
|
182
|
+
* @group AbuseIPDB API Response
|
|
183
|
+
*/
|
|
184
|
+
interface APIServerErrorResultResponse {
|
|
185
|
+
message: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Possible `usageTypes` values as defined by the Check Endpoint documentation.
|
|
189
|
+
* @see [Check Endpoint usageType](https://docs.abuseipdb.com/#check-endpoint)
|
|
190
|
+
* @group AbuseIPDB API Response
|
|
191
|
+
*/
|
|
192
|
+
type UsageType = 'Commercial' | 'Organization' | 'Government' | 'Military' | 'University/College/School' | 'Library' | 'Content Delivery Network' | 'Fixed Line ISP' | 'Mobile ISP' | 'Data Center/Web Hosting/Transit' | 'Search Engine Spider' | 'Reserved';
|
|
193
|
+
/**
|
|
194
|
+
* @group AbuseIPDB API Response
|
|
195
|
+
*/
|
|
196
|
+
interface ReportsEntity {
|
|
197
|
+
reportedAt: string;
|
|
198
|
+
comment: string;
|
|
199
|
+
categories: NonEmptyArr<ReportCategory>;
|
|
200
|
+
reporterId: number;
|
|
201
|
+
reporterCountryCode: string;
|
|
202
|
+
reporterCountryName: string;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* @group AbuseIPDB API Response
|
|
206
|
+
*/
|
|
207
|
+
interface ReportedAddressEntity {
|
|
208
|
+
ipAddress: string;
|
|
209
|
+
numReports: number;
|
|
210
|
+
mostRecentReport: string;
|
|
211
|
+
abuseConfidenceScore: number;
|
|
212
|
+
countryCode: string | null;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* @group AbuseIPDB API Response
|
|
216
|
+
*/
|
|
217
|
+
interface InvalidReportsEntity {
|
|
218
|
+
error: string;
|
|
219
|
+
input: string;
|
|
220
|
+
rowNumber: number;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* AbuseIPDB Report Category types.
|
|
224
|
+
* @see [AbuseIPDB Report Categories](https://www.abuseipdb.com/categories)
|
|
225
|
+
* @enum
|
|
226
|
+
* @group AbuseIPDB API Response
|
|
227
|
+
* @example
|
|
228
|
+
* ```typescript
|
|
229
|
+
* import { ReportCategory } from 'abuseipdb-client';
|
|
230
|
+
*
|
|
231
|
+
* // `ReportCategory` enum can be used to populate an array of categories.
|
|
232
|
+
* const categories: Array<ReportCategory> = [
|
|
233
|
+
* ReportCategory.WebSpam,
|
|
234
|
+
* ReportCategory.BadWebBot,
|
|
235
|
+
* ReportCategory.BruteForce,
|
|
236
|
+
* ];
|
|
237
|
+
*
|
|
238
|
+
* // Which translates to:
|
|
239
|
+
* // categories = [ 10, 19, 18 ].
|
|
240
|
+
*
|
|
241
|
+
* // That way, it is possible to call the `report` endpoint using this reference directly:
|
|
242
|
+
* client.report('127.0.0.1', categories);
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
declare enum ReportCategory {
|
|
246
|
+
/**
|
|
247
|
+
* Altering DNS records resulting in improper redirection.
|
|
248
|
+
*/
|
|
249
|
+
DNSCompromise = 1,
|
|
250
|
+
/**
|
|
251
|
+
* Falsifying domain server cache (cache poisoning).
|
|
252
|
+
*/
|
|
253
|
+
DNSPoisoning = 2,
|
|
254
|
+
/**
|
|
255
|
+
* Fraudulent orders.
|
|
256
|
+
*/
|
|
257
|
+
FraudOrders = 3,
|
|
258
|
+
/**
|
|
259
|
+
* Participating in distributed denial-of-service (usually part of botnet).
|
|
260
|
+
*/
|
|
261
|
+
DDOSAttack = 4,
|
|
262
|
+
/**
|
|
263
|
+
* FTP Brute force attempt.
|
|
264
|
+
*/
|
|
265
|
+
FTPBruteForce = 5,
|
|
266
|
+
/**
|
|
267
|
+
* Oversized IP packet.
|
|
268
|
+
*/
|
|
269
|
+
PingOfDeath = 6,
|
|
270
|
+
/**
|
|
271
|
+
* Phishing websites and/or email.
|
|
272
|
+
*/
|
|
273
|
+
Phishing = 7,
|
|
274
|
+
/**
|
|
275
|
+
* Voice-over-IP fraud.
|
|
276
|
+
*/
|
|
277
|
+
FraudVoIP = 8,
|
|
278
|
+
/**
|
|
279
|
+
* Open proxy, open relay, or Tor exit node.
|
|
280
|
+
*/
|
|
281
|
+
OpenProxy = 9,
|
|
282
|
+
/**
|
|
283
|
+
* Comment/forum spam, HTTP referer spam, or other CMS spam.
|
|
284
|
+
*/
|
|
285
|
+
WebSpam = 10,
|
|
286
|
+
/**
|
|
287
|
+
* Spam email content, infected attachments, and phishing emails. Note: Limit comments to only relevent information (instead of log dumps) and be sure to remove PII if you want to remain anonymous.
|
|
288
|
+
*/
|
|
289
|
+
EmailSpam = 11,
|
|
290
|
+
/**
|
|
291
|
+
* CMS blog comment spam.
|
|
292
|
+
*/
|
|
293
|
+
BlogSpam = 12,
|
|
294
|
+
/**
|
|
295
|
+
* VPN IP address.
|
|
296
|
+
*/
|
|
297
|
+
VPNIP = 13,
|
|
298
|
+
/**
|
|
299
|
+
* Scanning for open ports and vulnerable services.
|
|
300
|
+
*/
|
|
301
|
+
PortScan = 14,
|
|
302
|
+
/**
|
|
303
|
+
* General hacking attempt.
|
|
304
|
+
*/
|
|
305
|
+
Hacking = 15,
|
|
306
|
+
/**
|
|
307
|
+
* Attempts at SQL injection.
|
|
308
|
+
*/
|
|
309
|
+
SQLInjection = 16,
|
|
310
|
+
/**
|
|
311
|
+
* Email sender spoofing.
|
|
312
|
+
*/
|
|
313
|
+
Spoofing = 17,
|
|
314
|
+
/**
|
|
315
|
+
* Credential brute-force attacks on webpage logins and services like SSH, FTP, SIP, SMTP, RDP, etc. This category is seperate from DDoS attacks.
|
|
316
|
+
*/
|
|
317
|
+
BruteForce = 18,
|
|
318
|
+
/**
|
|
319
|
+
* Webpage scraping (for email addresses, content, etc) and crawlers that do not honor robots.txt. Excessive requests and user agent spoofing can also be reported here.
|
|
320
|
+
*/
|
|
321
|
+
BadWebBot = 19,
|
|
322
|
+
/**
|
|
323
|
+
* Host is likely infected with malware and being used for other attacks or to host malicious content. The host owner may not be aware of the compromise. This category is often used in combination with other attack categories.
|
|
324
|
+
*/
|
|
325
|
+
ExploitedHost = 20,
|
|
326
|
+
/**
|
|
327
|
+
* Attempts to probe for or exploit installed web applications such as a CMS like WordPress/Drupal, e-commerce solutions, forum software, phpMyAdmin and various other software plugins/solutions.
|
|
328
|
+
*/
|
|
329
|
+
WebAppAttack = 21,
|
|
330
|
+
/**
|
|
331
|
+
* Secure Shell (SSH) abuse. Use this category in combination with more specific categories.
|
|
332
|
+
*/
|
|
333
|
+
SSH = 22,
|
|
334
|
+
/**
|
|
335
|
+
* Abuse was targeted at an "Internet of Things" type device. Include information about what type of device was targeted in the comments.
|
|
336
|
+
*/
|
|
337
|
+
IOTTargeted = 23
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
declare const abuseIPDBClientOptionsSchema: z.ZodObject<{
|
|
341
|
+
/**
|
|
342
|
+
* Overrides the default AbuseIPDB base API url, can be used to proxy client requests.
|
|
343
|
+
* @defaultValue `https://api.abuseipdb.com/api/v2`
|
|
344
|
+
*/
|
|
345
|
+
url: z.ZodOptional<z.ZodString>;
|
|
346
|
+
}, "strip", z.ZodTypeAny, {
|
|
347
|
+
url?: string | undefined;
|
|
348
|
+
}, {
|
|
349
|
+
url?: string | undefined;
|
|
350
|
+
}>;
|
|
351
|
+
/**
|
|
352
|
+
* AbuseIPDBClient instance optional parameters.
|
|
353
|
+
* @group Input - Optional Parameter
|
|
354
|
+
*/
|
|
355
|
+
interface AbuseIPDBClientOptions extends z.TypeOf<typeof abuseIPDBClientOptionsSchema> {
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* @group Input - Validator
|
|
359
|
+
*/
|
|
360
|
+
declare const abuseIPDBClientSchema: z.ZodObject<z.extendShape<{
|
|
361
|
+
/** Client API Key, must be generated at AbuseIPDB's client dashboard. */
|
|
362
|
+
apiKey: z.ZodString;
|
|
363
|
+
}, {
|
|
364
|
+
/**
|
|
365
|
+
* Overrides the default AbuseIPDB base API url, can be used to proxy client requests.
|
|
366
|
+
* @defaultValue `https://api.abuseipdb.com/api/v2`
|
|
367
|
+
*/
|
|
368
|
+
url: z.ZodOptional<z.ZodString>;
|
|
369
|
+
}>, "strip", z.ZodTypeAny, {
|
|
370
|
+
url?: string | undefined;
|
|
371
|
+
apiKey: string;
|
|
372
|
+
}, {
|
|
373
|
+
url?: string | undefined;
|
|
374
|
+
apiKey: string;
|
|
375
|
+
}>;
|
|
376
|
+
declare const abuseIPDBClientConfigSchema: z.ZodObject<{
|
|
377
|
+
/** Client API Key. */
|
|
378
|
+
apiKey: z.ZodString;
|
|
379
|
+
/**
|
|
380
|
+
* Base API URL.
|
|
381
|
+
* @defaultValue `https://api.abuseipdb.com/api/v2`
|
|
382
|
+
*/
|
|
383
|
+
url: z.ZodString;
|
|
384
|
+
}, "strip", z.ZodTypeAny, {
|
|
385
|
+
apiKey: string;
|
|
386
|
+
url: string;
|
|
387
|
+
}, {
|
|
388
|
+
apiKey: string;
|
|
389
|
+
url: string;
|
|
390
|
+
}>;
|
|
391
|
+
/**
|
|
392
|
+
* AbuseIPDBClient instance configuration variables.
|
|
393
|
+
* @group Client
|
|
394
|
+
*/
|
|
395
|
+
interface AbuseIPDBClientConfig extends z.TypeOf<typeof abuseIPDBClientConfigSchema> {
|
|
396
|
+
}
|
|
397
|
+
declare const checkOptionsSchema: z.ZodObject<{
|
|
398
|
+
/** Show latest reports based on `n` days. Accepted values between 1 and 365, defaults to `30` by the API. */
|
|
399
|
+
maxAgeInDays: z.ZodOptional<z.ZodNumber>;
|
|
400
|
+
/** Includes in the client response all the reports (Limited to 10,000) and country name entries, based on the `maxAgeInDays` parameter. Defaults to `false` by the API. */
|
|
401
|
+
verbose: z.ZodOptional<z.ZodBoolean>;
|
|
402
|
+
}, "strip", z.ZodTypeAny, {
|
|
403
|
+
maxAgeInDays?: number | undefined;
|
|
404
|
+
verbose?: boolean | undefined;
|
|
405
|
+
}, {
|
|
406
|
+
maxAgeInDays?: number | undefined;
|
|
407
|
+
verbose?: boolean | undefined;
|
|
408
|
+
}>;
|
|
409
|
+
/**
|
|
410
|
+
* Check endpoint optional parameters.
|
|
411
|
+
* @group Input - Optional Parameter
|
|
412
|
+
*/
|
|
413
|
+
interface CheckOptions extends z.TypeOf<typeof checkOptionsSchema> {
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* @group Input - Validator
|
|
417
|
+
*/
|
|
418
|
+
declare const checkSchema: z.ZodEffects<z.ZodObject<z.extendShape<{
|
|
419
|
+
/** Single IPv4/IPv6 address. */
|
|
420
|
+
ipAddress: z.ZodEffects<z.ZodString, string, string>;
|
|
421
|
+
}, {
|
|
422
|
+
/** Show latest reports based on `n` days. Accepted values between 1 and 365, defaults to `30` by the API. */
|
|
423
|
+
maxAgeInDays: z.ZodOptional<z.ZodNumber>;
|
|
424
|
+
/** Includes in the client response all the reports (Limited to 10,000) and country name entries, based on the `maxAgeInDays` parameter. Defaults to `false` by the API. */
|
|
425
|
+
verbose: z.ZodOptional<z.ZodBoolean>;
|
|
426
|
+
}>, "strip", z.ZodTypeAny, {
|
|
427
|
+
maxAgeInDays?: number | undefined;
|
|
428
|
+
verbose?: boolean | undefined;
|
|
429
|
+
ipAddress: string;
|
|
430
|
+
}, {
|
|
431
|
+
maxAgeInDays?: number | undefined;
|
|
432
|
+
verbose?: boolean | undefined;
|
|
433
|
+
ipAddress: string;
|
|
434
|
+
}>, any, {
|
|
435
|
+
maxAgeInDays?: number | undefined;
|
|
436
|
+
verbose?: boolean | undefined;
|
|
437
|
+
ipAddress: string;
|
|
438
|
+
}>;
|
|
439
|
+
declare const reportsOptionsSchema: z.ZodObject<{
|
|
440
|
+
/** Show latest reports based on `n` days. Accepted values between 1 and 365, defaults to `30` by the API. */
|
|
441
|
+
maxAgeInDays: z.ZodOptional<z.ZodNumber>;
|
|
442
|
+
/** Pagination number based on the `perPage` parameter. Minimum accepted value is 1, defaults to `1` by the API. */
|
|
443
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
444
|
+
/** Amount of reports per page. Accepted values between 1 and 100, defaults to `25` by the API. */
|
|
445
|
+
perPage: z.ZodOptional<z.ZodNumber>;
|
|
446
|
+
}, "strip", z.ZodTypeAny, {
|
|
447
|
+
maxAgeInDays?: number | undefined;
|
|
448
|
+
page?: number | undefined;
|
|
449
|
+
perPage?: number | undefined;
|
|
450
|
+
}, {
|
|
451
|
+
maxAgeInDays?: number | undefined;
|
|
452
|
+
page?: number | undefined;
|
|
453
|
+
perPage?: number | undefined;
|
|
454
|
+
}>;
|
|
455
|
+
/**
|
|
456
|
+
* Reports endpoint optional parameters.
|
|
457
|
+
* @group Input - Optional Parameter
|
|
458
|
+
*/
|
|
459
|
+
interface ReportsOptions extends z.infer<typeof reportsOptionsSchema> {
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* @group Input - Validator
|
|
463
|
+
*/
|
|
464
|
+
declare const reportsSchema: z.ZodObject<z.extendShape<{
|
|
465
|
+
/** Single IPv4/IPv6 address. */
|
|
466
|
+
ipAddress: z.ZodEffects<z.ZodString, string, string>;
|
|
467
|
+
}, {
|
|
468
|
+
/** Show latest reports based on `n` days. Accepted values between 1 and 365, defaults to `30` by the API. */
|
|
469
|
+
maxAgeInDays: z.ZodOptional<z.ZodNumber>;
|
|
470
|
+
/** Pagination number based on the `perPage` parameter. Minimum accepted value is 1, defaults to `1` by the API. */
|
|
471
|
+
page: z.ZodOptional<z.ZodNumber>;
|
|
472
|
+
/** Amount of reports per page. Accepted values between 1 and 100, defaults to `25` by the API. */
|
|
473
|
+
perPage: z.ZodOptional<z.ZodNumber>;
|
|
474
|
+
}>, "strip", z.ZodTypeAny, {
|
|
475
|
+
maxAgeInDays?: number | undefined;
|
|
476
|
+
page?: number | undefined;
|
|
477
|
+
perPage?: number | undefined;
|
|
478
|
+
ipAddress: string;
|
|
479
|
+
}, {
|
|
480
|
+
maxAgeInDays?: number | undefined;
|
|
481
|
+
page?: number | undefined;
|
|
482
|
+
perPage?: number | undefined;
|
|
483
|
+
ipAddress: string;
|
|
484
|
+
}>;
|
|
485
|
+
declare const blacklistOptionsSchema: z.ZodObject<{
|
|
486
|
+
/** Minimum confidence percentage value. Accepted values between 25 and 100, defaults to `100` by the API. Requires a subscription to use this feature. */
|
|
487
|
+
confidenceMinimum: z.ZodOptional<z.ZodNumber>;
|
|
488
|
+
/**
|
|
489
|
+
* Limits the amount of returned reports. Accepted values between 1 and 500000, defaults to `10000` by the API.
|
|
490
|
+
* The value is capped by your current subscription tier. (10k Standard, 100k Basic, 500k Premium).
|
|
491
|
+
*/
|
|
492
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
493
|
+
/** Returns the response as a text list, instead of JSON structure. Result is wrapped in a `ClientResponse` */
|
|
494
|
+
plaintext: z.ZodOptional<z.ZodBoolean>;
|
|
495
|
+
/**
|
|
496
|
+
* Filters the reports based on a given array of ISO 3166-1 Alpha-2 countries, including only the given list.
|
|
497
|
+
* Requires a subscription to use this feature.
|
|
498
|
+
* `onlyCountries` and `exceptCountries` are mutually exclusive, only one can be defined at a time. */
|
|
499
|
+
onlyCountries: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
500
|
+
/**
|
|
501
|
+
* Filters the reports based on a given array of ISO 3166-1 Alpha-2 countries, excluding only the given list.
|
|
502
|
+
* Requires a subscription to use this feature.
|
|
503
|
+
* `onlyCountries` and `exceptCountries` are mutually exclusive, only one can be defined at a time. */
|
|
504
|
+
exceptCountries: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
505
|
+
}, "strip", z.ZodTypeAny, {
|
|
506
|
+
confidenceMinimum?: number | undefined;
|
|
507
|
+
limit?: number | undefined;
|
|
508
|
+
plaintext?: boolean | undefined;
|
|
509
|
+
onlyCountries?: string[] | undefined;
|
|
510
|
+
exceptCountries?: string[] | undefined;
|
|
511
|
+
}, {
|
|
512
|
+
confidenceMinimum?: number | undefined;
|
|
513
|
+
limit?: number | undefined;
|
|
514
|
+
plaintext?: boolean | undefined;
|
|
515
|
+
onlyCountries?: string[] | undefined;
|
|
516
|
+
exceptCountries?: string[] | undefined;
|
|
517
|
+
}>;
|
|
518
|
+
/**
|
|
519
|
+
* @group Input - Validator
|
|
520
|
+
*/
|
|
521
|
+
declare const blacklistSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
522
|
+
/** Minimum confidence percentage value. Accepted values between 25 and 100, defaults to `100` by the API. Requires a subscription to use this feature. */
|
|
523
|
+
confidenceMinimum: z.ZodOptional<z.ZodNumber>;
|
|
524
|
+
/**
|
|
525
|
+
* Limits the amount of returned reports. Accepted values between 1 and 500000, defaults to `10000` by the API.
|
|
526
|
+
* The value is capped by your current subscription tier. (10k Standard, 100k Basic, 500k Premium).
|
|
527
|
+
*/
|
|
528
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
529
|
+
/** Returns the response as a text list, instead of JSON structure. Result is wrapped in a `ClientResponse` */
|
|
530
|
+
plaintext: z.ZodOptional<z.ZodBoolean>;
|
|
531
|
+
/**
|
|
532
|
+
* Filters the reports based on a given array of ISO 3166-1 Alpha-2 countries, including only the given list.
|
|
533
|
+
* Requires a subscription to use this feature.
|
|
534
|
+
* `onlyCountries` and `exceptCountries` are mutually exclusive, only one can be defined at a time. */
|
|
535
|
+
onlyCountries: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
536
|
+
/**
|
|
537
|
+
* Filters the reports based on a given array of ISO 3166-1 Alpha-2 countries, excluding only the given list.
|
|
538
|
+
* Requires a subscription to use this feature.
|
|
539
|
+
* `onlyCountries` and `exceptCountries` are mutually exclusive, only one can be defined at a time. */
|
|
540
|
+
exceptCountries: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
541
|
+
}, "strip", z.ZodTypeAny, {
|
|
542
|
+
confidenceMinimum?: number | undefined;
|
|
543
|
+
limit?: number | undefined;
|
|
544
|
+
plaintext?: boolean | undefined;
|
|
545
|
+
onlyCountries?: string[] | undefined;
|
|
546
|
+
exceptCountries?: string[] | undefined;
|
|
547
|
+
}, {
|
|
548
|
+
confidenceMinimum?: number | undefined;
|
|
549
|
+
limit?: number | undefined;
|
|
550
|
+
plaintext?: boolean | undefined;
|
|
551
|
+
onlyCountries?: string[] | undefined;
|
|
552
|
+
exceptCountries?: string[] | undefined;
|
|
553
|
+
}>, any, {
|
|
554
|
+
confidenceMinimum?: number | undefined;
|
|
555
|
+
limit?: number | undefined;
|
|
556
|
+
plaintext?: boolean | undefined;
|
|
557
|
+
onlyCountries?: string[] | undefined;
|
|
558
|
+
exceptCountries?: string[] | undefined;
|
|
559
|
+
}>, any, {
|
|
560
|
+
confidenceMinimum?: number | undefined;
|
|
561
|
+
limit?: number | undefined;
|
|
562
|
+
plaintext?: boolean | undefined;
|
|
563
|
+
onlyCountries?: string[] | undefined;
|
|
564
|
+
exceptCountries?: string[] | undefined;
|
|
565
|
+
}>;
|
|
566
|
+
/**
|
|
567
|
+
* Blacklist endpoint optional parameters.
|
|
568
|
+
* @group Input - Optional Parameter
|
|
569
|
+
*/
|
|
570
|
+
interface BlacklistOptions extends z.TypeOf<typeof blacklistOptionsSchema> {
|
|
571
|
+
}
|
|
572
|
+
declare const reportOptionsSchema: z.ZodObject<{
|
|
573
|
+
/** Message to be added to the report, limited to 1024 characters. */
|
|
574
|
+
comment: z.ZodOptional<z.ZodString>;
|
|
575
|
+
}, "strip", z.ZodTypeAny, {
|
|
576
|
+
comment?: string | undefined;
|
|
577
|
+
}, {
|
|
578
|
+
comment?: string | undefined;
|
|
579
|
+
}>;
|
|
580
|
+
/**
|
|
581
|
+
* Report endpoint optional parameters.
|
|
582
|
+
* @group Input - Optional Parameter
|
|
583
|
+
*/
|
|
584
|
+
interface ReportOptions extends z.TypeOf<typeof reportOptionsSchema> {
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* @group Input - Validator
|
|
588
|
+
*/
|
|
589
|
+
declare const reportSchema: z.ZodObject<z.extendShape<{
|
|
590
|
+
/** Single IPv4/IPv6 address. */
|
|
591
|
+
ip: z.ZodEffects<z.ZodString, string, string>;
|
|
592
|
+
/** Array of categories */
|
|
593
|
+
categories: z.ZodArray<z.ZodNumber, "many">;
|
|
594
|
+
}, {
|
|
595
|
+
/** Message to be added to the report, limited to 1024 characters. */
|
|
596
|
+
comment: z.ZodOptional<z.ZodString>;
|
|
597
|
+
}>, "strip", z.ZodTypeAny, {
|
|
598
|
+
comment?: string | undefined;
|
|
599
|
+
ip: string;
|
|
600
|
+
categories: number[];
|
|
601
|
+
}, {
|
|
602
|
+
comment?: string | undefined;
|
|
603
|
+
ip: string;
|
|
604
|
+
categories: number[];
|
|
605
|
+
}>;
|
|
606
|
+
declare const checkBlockOptionsSchema: z.ZodObject<{
|
|
607
|
+
/**
|
|
608
|
+
* Show latest reports based on `n` days. Accepted values between 1 and 365, defaults to `30` by the API.
|
|
609
|
+
* The value is capped by your current subscription tier. (Up to 30 on Standard, 60 on Basic, 365 on Premium).
|
|
610
|
+
*/
|
|
611
|
+
maxAgeInDays: z.ZodOptional<z.ZodNumber>;
|
|
612
|
+
}, "strip", z.ZodTypeAny, {
|
|
613
|
+
maxAgeInDays?: number | undefined;
|
|
614
|
+
}, {
|
|
615
|
+
maxAgeInDays?: number | undefined;
|
|
616
|
+
}>;
|
|
617
|
+
/**
|
|
618
|
+
* Check-Block endpoint optional parameters.
|
|
619
|
+
* @group Input - Optional Parameter
|
|
620
|
+
*/
|
|
621
|
+
interface CheckBlockOptions extends z.TypeOf<typeof checkBlockOptionsSchema> {
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* @group Input - Validator
|
|
625
|
+
*/
|
|
626
|
+
declare const checkBlockSchema: z.ZodObject<z.extendShape<{
|
|
627
|
+
/**
|
|
628
|
+
* Single IPv4/IPv6 address block in CIDR format.
|
|
629
|
+
* The value is capped by your current subscription tier. (Up to /24 on Standard, /20 on Basic, /16 on Premium).
|
|
630
|
+
*/
|
|
631
|
+
network: z.ZodEffects<z.ZodString, string, string>;
|
|
632
|
+
}, {
|
|
633
|
+
/**
|
|
634
|
+
* Show latest reports based on `n` days. Accepted values between 1 and 365, defaults to `30` by the API.
|
|
635
|
+
* The value is capped by your current subscription tier. (Up to 30 on Standard, 60 on Basic, 365 on Premium).
|
|
636
|
+
*/
|
|
637
|
+
maxAgeInDays: z.ZodOptional<z.ZodNumber>;
|
|
638
|
+
}>, "strip", z.ZodTypeAny, {
|
|
639
|
+
maxAgeInDays?: number | undefined;
|
|
640
|
+
network: string;
|
|
641
|
+
}, {
|
|
642
|
+
maxAgeInDays?: number | undefined;
|
|
643
|
+
network: string;
|
|
644
|
+
}>;
|
|
645
|
+
/**
|
|
646
|
+
* @group Input - Validator
|
|
647
|
+
*/
|
|
648
|
+
declare const bulkReportSchema: z.ZodObject<{
|
|
649
|
+
/** Report CSV filepath to be sent. */
|
|
650
|
+
csv: z.ZodString;
|
|
651
|
+
}, "strip", z.ZodTypeAny, {
|
|
652
|
+
csv: string;
|
|
653
|
+
}, {
|
|
654
|
+
csv: string;
|
|
655
|
+
}>;
|
|
656
|
+
/**
|
|
657
|
+
* @group Input - Validator
|
|
658
|
+
*/
|
|
659
|
+
declare const clearAddressSchema: z.ZodObject<{
|
|
660
|
+
ipAddress: z.ZodEffects<z.ZodString, string, string>;
|
|
661
|
+
}, "strip", z.ZodTypeAny, {
|
|
662
|
+
ipAddress: string;
|
|
663
|
+
}, {
|
|
664
|
+
ipAddress: string;
|
|
665
|
+
}>;
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* @internal
|
|
669
|
+
* @group Internal
|
|
670
|
+
*/
|
|
671
|
+
type EndpointURIS = 'check' | 'reports' | 'blacklist' | 'report' | 'check-block' | 'bulk-report' | 'clear-address';
|
|
672
|
+
/**
|
|
673
|
+
* @internal
|
|
674
|
+
* @group Internal
|
|
675
|
+
*/
|
|
676
|
+
type ClientAPIHeaders = {
|
|
677
|
+
Key: string;
|
|
678
|
+
Accept: string;
|
|
679
|
+
};
|
|
680
|
+
/**
|
|
681
|
+
* @group Client
|
|
682
|
+
*/
|
|
683
|
+
declare class AbuseIPDBClient {
|
|
684
|
+
#private;
|
|
685
|
+
/**
|
|
686
|
+
* Creates a new AbuseIPDB client, requires an API key from AbuseIPDB's dashboard.
|
|
687
|
+
* @param apiKey AbuseIPDB client API key.
|
|
688
|
+
* @param options Optional parameters - {@link AbuseIPDBClientOptions}
|
|
689
|
+
*/
|
|
690
|
+
constructor(apiKey: string, options?: AbuseIPDBClientOptions);
|
|
691
|
+
/**
|
|
692
|
+
* Returns the current client config.
|
|
693
|
+
*/
|
|
694
|
+
getConfig(): AbuseIPDBClientConfig;
|
|
695
|
+
/**
|
|
696
|
+
* @see [Check API Endpoint](https://docs.abuseipdb.com/#check-endpoint)
|
|
697
|
+
* @param ipAddress Single IPv4/IPv6 address to be verified.
|
|
698
|
+
* @param options Optional parameters - {@link CheckOptions}
|
|
699
|
+
*/
|
|
700
|
+
check(ipAddress: string, options?: CheckOptions): Promise<ClientResponse<APICheckEndpointResponse>>;
|
|
701
|
+
/**
|
|
702
|
+
* @see [Reports API Endpoint](https://docs.abuseipdb.com/#reports-endpoint)
|
|
703
|
+
* @param ipAddress Single IPv4/IPv6 address to be verified.
|
|
704
|
+
* @param options Optional parameters - {@link ReportsOptions}
|
|
705
|
+
* @beta
|
|
706
|
+
*/
|
|
707
|
+
reports(ipAddress: string, options?: ReportsOptions): Promise<ClientResponse<APIReportsEndpointResponse>>;
|
|
708
|
+
/**
|
|
709
|
+
* @see [Blacklist API Endpoint](https://docs.abuseipdb.com/#blacklist-endpoint)
|
|
710
|
+
* @param options Optional parameters - {@link BlacklistOptions}
|
|
711
|
+
*/
|
|
712
|
+
blacklist(options?: BlacklistOptions): Promise<ClientResponse<APIBlacklistEndpointResponse>>;
|
|
713
|
+
/**
|
|
714
|
+
* @see [Report API Endpoint](https://docs.abuseipdb.com/#report-endpoint)
|
|
715
|
+
* @param ip Single IPv4/IPv6 address to be verified.
|
|
716
|
+
* @param categories Array of categories to be reported.
|
|
717
|
+
* @param options Optional parameters - {@link ReportOptions}
|
|
718
|
+
*/
|
|
719
|
+
report(ip: string, categories: Array<ReportCategory>, options?: ReportOptions): Promise<ClientResponse<APIReportEndpointResponse>>;
|
|
720
|
+
/**
|
|
721
|
+
* @see [Check-Block API Endpoint](https://docs.abuseipdb.com/#check-block-endpoint)
|
|
722
|
+
* @param network Single IPv4/IPv6 address block in CIDR format.
|
|
723
|
+
* @param options Optional parameters - {@link CheckBlockOptions}
|
|
724
|
+
*/
|
|
725
|
+
checkBlock(network: string, options?: CheckBlockOptions): Promise<ClientResponse<APICheckBlockEndpointResponse>>;
|
|
726
|
+
/**
|
|
727
|
+
* @see [Bulk-Report API Endpoint](https://docs.abuseipdb.com/#bulk-report-endpoint)
|
|
728
|
+
* @param csv CSV filepath to be sent.
|
|
729
|
+
*/
|
|
730
|
+
bulkReport(csv: string): Promise<ClientResponse<APIBulkReportEndpointResponse>>;
|
|
731
|
+
/**
|
|
732
|
+
* @see [Clear-Address API Endpoint](https://docs.abuseipdb.com/#clear-address-endpoint)
|
|
733
|
+
* @param ipAddress Single IPv4/IPv6 address.
|
|
734
|
+
*/
|
|
735
|
+
clearAddress(ipAddress: string): Promise<ClientResponse<APIClearAddressEndpointResponse>>;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Base URL used to make client calls, defaults to AbuseIPDB's APIv2 Endpoint.
|
|
740
|
+
* Can be changed when instatiating a new AbuseIPDBClient through the URL param.
|
|
741
|
+
* @see {@link AbuseIPDBClientOptions}
|
|
742
|
+
* @group Constants
|
|
743
|
+
*/
|
|
744
|
+
declare const BASE_URL = "https://api.abuseipdb.com/api/v2";
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* Predicate function that verifies if a given array contains only valid ISO 3166-1 Alpha 2 countries.
|
|
748
|
+
* @param arr Array of ISO 3166-1 Alpha 2 countries as string.
|
|
749
|
+
* @returns Boolean if elements of the given array are valid.
|
|
750
|
+
* @group Helpers
|
|
751
|
+
*/
|
|
752
|
+
declare const isArrISO31661Alpha2: (arr: Array<string>) => boolean;
|
|
753
|
+
|
|
754
|
+
export { APIBlacklistEndpointResponse, APIBlacklistEndpointTextResponse, APIBulkReportEndpointResponse, APICheckBlockEndpointResponse, APICheckEndpointResponse, APIClearAddressEndpointResponse, APIReportEndpointResponse, APIReportsEndpointResponse, APIResponse, APIResponseError, APIServerErrorResultResponse, AbuseIPDBClient, AbuseIPDBClientConfig, AbuseIPDBClientOptions, BASE_URL, BlacklistOptions, CheckBlockOptions, CheckOptions, ClientAPIHeaders, ClientAPIRateLimitHTTPHeaders, ClientFetchResponseHeaders, ClientHeaders, ClientResponse, EndpointURIS, InvalidReportsEntity, NonEmptyArr, ReportCategory, ReportOptions, ReportedAddressEntity, ReportsEntity, ReportsOptions, UsageType, abuseIPDBClientSchema, blacklistSchema, bulkReportSchema, checkBlockSchema, checkSchema, clearAddressSchema, isArrISO31661Alpha2, reportSchema, reportsSchema };
|