abuseipdb-client 0.1.63 → 0.1.65

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/dist/index.mjs CHANGED
@@ -33,572 +33,572 @@ function __classPrivateFieldSet(receiver, state, value, kind, f) {
33
33
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
34
34
  }
35
35
 
36
- /**
37
- * I'm patching the type definitions for isISO31661Alpha2 because
38
- * it is returning some encapsulated object.
39
- */
40
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
- const _isISO31661Alpha2 = isISO31661Alpha2
42
- .default;
43
- /**
44
- * Predicate function that verifies if a given array contains only valid ISO 3166-1 Alpha 2 countries.
45
- * @param arr Array of ISO 3166-1 Alpha 2 countries as string.
46
- * @returns Boolean if elements of the given array are valid.
47
- * @group Helpers
48
- */
49
- const isArrISO31661Alpha2 = (arr) => arr
50
- .map(el => _isISO31661Alpha2(el))
51
- .reduce((acc, curr) => {
52
- if (curr) {
53
- acc = true;
54
- }
55
- return acc;
36
+ /**
37
+ * I'm patching the type definitions for isISO31661Alpha2 because
38
+ * it is returning some encapsulated object.
39
+ */
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ const _isISO31661Alpha2 = isISO31661Alpha2
42
+ .default;
43
+ /**
44
+ * Predicate function that verifies if a given array contains only valid ISO 3166-1 Alpha 2 countries.
45
+ * @param arr Array of ISO 3166-1 Alpha 2 countries as string.
46
+ * @returns Boolean if elements of the given array are valid.
47
+ * @group Helpers
48
+ */
49
+ const isArrISO31661Alpha2 = (arr) => arr
50
+ .map(el => _isISO31661Alpha2(el))
51
+ .reduce((acc, curr) => {
52
+ if (curr) {
53
+ acc = true;
54
+ }
55
+ return acc;
56
56
  }, false);
57
57
 
58
- /**
59
- * Removes a boolean query string parameter when its value is set to `false`.
60
- * Currently, the AbuseIPDB's API treats boolean query strings as `true` regardless of its value,
61
- * this function filter those values in order to return the right response.
62
- * The `Check` and `Blacklist` as text endpoints have such booleans.
63
- */
64
- const filterBooleanAPIQueryStrings = (schema, parameter) => {
65
- const newSchema = { ...schema };
66
- if (schema[parameter] === false) {
67
- delete newSchema[parameter];
68
- }
69
- return newSchema;
70
- };
71
- const abuseIPDBClientRequiredSchema = z.object({
72
- /** Client API Key, must be generated at AbuseIPDB's client dashboard. */
73
- apiKey: z.string().min(1),
74
- });
75
- const abuseIPDBClientOptionsSchema = z.object({
76
- /**
77
- * Overrides the default AbuseIPDB base API url, can be used to proxy client requests.
78
- * @defaultValue `https://api.abuseipdb.com/api/v2`
79
- */
80
- url: z.string().optional(),
81
- });
82
- /**
83
- * @group Input - Validator
84
- */
85
- const abuseIPDBClientSchema = abuseIPDBClientRequiredSchema.merge(abuseIPDBClientOptionsSchema);
86
- z.object({
87
- /** Client API Key. */
88
- apiKey: z.string(),
89
- /**
90
- * Base API URL.
91
- * @defaultValue `https://api.abuseipdb.com/api/v2`
92
- */
93
- url: z.string(),
94
- });
95
- const checkRequiredSchema = z.object({
96
- /** Single IPv4/IPv6 address. */
97
- ipAddress: z
98
- .string()
99
- .refine(isIP, { message: 'Must be a valid IPv4/IPv6 Address' }),
100
- });
101
- const checkOptionsSchema = z.object({
102
- /** Show latest reports based on `n` days. Accepted values between 1 and 365, defaults to `30` by the API. */
103
- maxAgeInDays: z.number().int().min(1).max(365).optional(),
104
- /** 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. */
105
- verbose: z.boolean().optional(),
106
- });
107
- /**
108
- * @group Input - Validator
109
- */
110
- const checkSchema = checkRequiredSchema
111
- .merge(checkOptionsSchema)
112
- .transform(schema => filterBooleanAPIQueryStrings(schema, 'verbose'));
113
- const reportsRequiredSchema = z.object({
114
- /** Single IPv4/IPv6 address. */
115
- ipAddress: z
116
- .string()
117
- .refine(isIP, { message: 'Must be a valid IPv4/IPv6 Address' }),
118
- });
119
- const reportsOptionsSchema = z.object({
120
- /** Show latest reports based on `n` days. Accepted values between 1 and 365, defaults to `30` by the API. */
121
- maxAgeInDays: z.number().int().min(1).max(365).optional(),
122
- /** Pagination number based on the `perPage` parameter. Minimum accepted value is 1, defaults to `1` by the API. */
123
- page: z.number().int().min(1).optional(),
124
- /** Amount of reports per page. Accepted values between 1 and 100, defaults to `25` by the API. */
125
- perPage: z.number().int().min(1).max(100).optional(),
126
- });
127
- /**
128
- * @group Input - Validator
129
- */
130
- const reportsSchema = reportsRequiredSchema.merge(reportsOptionsSchema);
131
- const blacklistOptionsSchema = z.object({
132
- /** Minimum confidence percentage value. Accepted values between 25 and 100, defaults to `100` by the API. Requires a subscription to use this feature. */
133
- confidenceMinimum: z.number().int().min(25).max(100).optional(),
134
- /**
135
- * Limits the amount of returned reports. Accepted values between 1 and 500000, defaults to `10000` by the API.
136
- * The value is capped by your current subscription tier. (10k Standard, 100k Basic, 500k Premium).
137
- */
138
- limit: z.number().int().min(1).max(500000).optional(),
139
- /** Returns the response as a text list, instead of JSON structure. Result is wrapped in a `ClientResponse` */
140
- plaintext: z.boolean().optional(),
141
- /**
142
- * Filters the reports based on a given array of ISO 3166-1 Alpha-2 countries, including only the given list.
143
- * Requires a subscription to use this feature.
144
- * `onlyCountries` and `exceptCountries` are mutually exclusive, only one can be defined at a time. */
145
- onlyCountries: z.array(z.string()).optional(),
146
- /**
147
- * Filters the reports based on a given array of ISO 3166-1 Alpha-2 countries, excluding only the given list.
148
- * Requires a subscription to use this feature.
149
- * `onlyCountries` and `exceptCountries` are mutually exclusive, only one can be defined at a time. */
150
- exceptCountries: z.array(z.string()).optional(),
151
- });
152
- /**
153
- * @group Input - Validator
154
- */
155
- const blacklistSchema = blacklistOptionsSchema
156
- .transform(schema => filterBooleanAPIQueryStrings(schema, 'plaintext'))
157
- .superRefine((schemaValues, ctx) => {
158
- // Countries declaration are optional, skip validation if this is the case.
159
- if (!(schemaValues.onlyCountries ?? schemaValues.exceptCountries)) {
160
- return;
161
- }
162
- if (schemaValues.onlyCountries && schemaValues.exceptCountries) {
163
- ctx.addIssue({
164
- code: z.ZodIssueCode.custom,
165
- message: '`exceptCountries` and `onlyCountries` are mutually exclusive, only one can be defined at a time.',
166
- });
167
- return;
168
- }
169
- const countriesParams = ['onlyCountries', 'exceptCountries'];
170
- for (const countryParam of countriesParams) {
171
- const countriesArr = schemaValues[countryParam];
172
- if (!countriesArr) {
173
- continue;
174
- }
175
- if (countriesArr.length === 0) {
176
- ctx.addIssue({
177
- code: z.ZodIssueCode.too_small,
178
- minimum: 1,
179
- type: 'array',
180
- inclusive: true,
181
- message: `[${countryParam}] Atleast one country must be specified.`,
182
- });
183
- continue;
184
- }
185
- if (!isArrISO31661Alpha2(countriesArr)) {
186
- ctx.addIssue({
187
- code: z.ZodIssueCode.custom,
188
- message: `[${countryParam}] Countries must be valid ISO 3166-1 Alpha-2 codes.`,
189
- });
190
- }
191
- }
192
- });
193
- const reportRequiredSchema = z.object({
194
- /** Single IPv4/IPv6 address. */
195
- ip: z.string().refine(isIP, { message: 'Must be a valid IPv4/IPv6 Address' }),
196
- /** Array of categories */
197
- categories: z.array(z.number().int().min(1).max(23)).min(1).max(30),
198
- });
199
- const reportOptionsSchema = z.object({
200
- /** Message to be added to the report, limited to 1024 characters. */
201
- comment: z.string().max(1024).optional(),
202
- });
203
- /**
204
- * @group Input - Validator
205
- */
206
- const reportSchema = reportRequiredSchema.merge(reportOptionsSchema);
207
- const checkBlockRequiredSchema = z.object({
208
- /**
209
- * Single IPv4/IPv6 address block in CIDR format.
210
- * The value is capped by your current subscription tier. (Up to /24 on Standard, /20 on Basic, /16 on Premium).
211
- */
212
- network: z
213
- .string()
214
- .refine(isIPRange, { message: 'Must be a valid CIDR block' }),
215
- });
216
- const checkBlockOptionsSchema = z.object({
217
- /**
218
- * Show latest reports based on `n` days. Accepted values between 1 and 365, defaults to `30` by the API.
219
- * The value is capped by your current subscription tier. (Up to 30 on Standard, 60 on Basic, 365 on Premium).
220
- */
221
- maxAgeInDays: z.number().int().min(1).max(365).optional(),
222
- });
223
- /**
224
- * @group Input - Validator
225
- */
226
- const checkBlockSchema = checkBlockRequiredSchema.merge(checkBlockOptionsSchema);
227
- const bulkReportRequiredSchema = z.object({
228
- /** Report CSV filepath to be sent. */
229
- csv: z.string(),
230
- });
231
- /**
232
- * @group Input - Validator
233
- */
234
- const bulkReportSchema = bulkReportRequiredSchema;
235
- /** Single IPv4/IPv6 address. */
236
- const clearAddressRequiredSchema = z
237
- .string()
238
- .refine(isIP, { message: 'Must be a valid IPv4/IPv6 Address' });
239
- /**
240
- * @group Input - Validator
241
- */
58
+ /**
59
+ * Removes a boolean query string parameter when its value is set to `false`.
60
+ * Currently, the AbuseIPDB's API treats boolean query strings as `true` regardless of its value,
61
+ * this function filter those values in order to return the right response.
62
+ * The `Check` and `Blacklist` as text endpoints have such booleans.
63
+ */
64
+ const filterBooleanAPIQueryStrings = (schema, parameter) => {
65
+ const newSchema = { ...schema };
66
+ if (schema[parameter] === false) {
67
+ delete newSchema[parameter];
68
+ }
69
+ return newSchema;
70
+ };
71
+ const abuseIPDBClientRequiredSchema = z.object({
72
+ /** Client API Key, must be generated at AbuseIPDB's client dashboard. */
73
+ apiKey: z.string().min(1),
74
+ });
75
+ const abuseIPDBClientOptionsSchema = z.object({
76
+ /**
77
+ * Overrides the default AbuseIPDB base API url, can be used to proxy client requests.
78
+ * @defaultValue `https://api.abuseipdb.com/api/v2`
79
+ */
80
+ url: z.string().optional(),
81
+ });
82
+ /**
83
+ * @group Input - Validator
84
+ */
85
+ const abuseIPDBClientSchema = abuseIPDBClientRequiredSchema.merge(abuseIPDBClientOptionsSchema);
86
+ z.object({
87
+ /** Client API Key. */
88
+ apiKey: z.string(),
89
+ /**
90
+ * Base API URL.
91
+ * @defaultValue `https://api.abuseipdb.com/api/v2`
92
+ */
93
+ url: z.string(),
94
+ });
95
+ const checkRequiredSchema = z.object({
96
+ /** Single IPv4/IPv6 address. */
97
+ ipAddress: z
98
+ .string()
99
+ .refine(isIP, { message: 'Must be a valid IPv4/IPv6 Address' }),
100
+ });
101
+ const checkOptionsSchema = z.object({
102
+ /** Show latest reports based on `n` days. Accepted values between 1 and 365, defaults to `30` by the API. */
103
+ maxAgeInDays: z.number().int().min(1).max(365).optional(),
104
+ /** 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. */
105
+ verbose: z.boolean().optional(),
106
+ });
107
+ /**
108
+ * @group Input - Validator
109
+ */
110
+ const checkSchema = checkRequiredSchema
111
+ .merge(checkOptionsSchema)
112
+ .transform(schema => filterBooleanAPIQueryStrings(schema, 'verbose'));
113
+ const reportsRequiredSchema = z.object({
114
+ /** Single IPv4/IPv6 address. */
115
+ ipAddress: z
116
+ .string()
117
+ .refine(isIP, { message: 'Must be a valid IPv4/IPv6 Address' }),
118
+ });
119
+ const reportsOptionsSchema = z.object({
120
+ /** Show latest reports based on `n` days. Accepted values between 1 and 365, defaults to `30` by the API. */
121
+ maxAgeInDays: z.number().int().min(1).max(365).optional(),
122
+ /** Pagination number based on the `perPage` parameter. Minimum accepted value is 1, defaults to `1` by the API. */
123
+ page: z.number().int().min(1).optional(),
124
+ /** Amount of reports per page. Accepted values between 1 and 100, defaults to `25` by the API. */
125
+ perPage: z.number().int().min(1).max(100).optional(),
126
+ });
127
+ /**
128
+ * @group Input - Validator
129
+ */
130
+ const reportsSchema = reportsRequiredSchema.merge(reportsOptionsSchema);
131
+ const blacklistOptionsSchema = z.object({
132
+ /** Minimum confidence percentage value. Accepted values between 25 and 100, defaults to `100` by the API. Requires a subscription to use this feature. */
133
+ confidenceMinimum: z.number().int().min(25).max(100).optional(),
134
+ /**
135
+ * Limits the amount of returned reports. Accepted values between 1 and 500000, defaults to `10000` by the API.
136
+ * The value is capped by your current subscription tier. (10k Standard, 100k Basic, 500k Premium).
137
+ */
138
+ limit: z.number().int().min(1).max(500000).optional(),
139
+ /** Returns the response as a text list, instead of JSON structure. Result is wrapped in a `ClientResponse` */
140
+ plaintext: z.boolean().optional(),
141
+ /**
142
+ * Filters the reports based on a given array of ISO 3166-1 Alpha-2 countries, including only the given list.
143
+ * Requires a subscription to use this feature.
144
+ * `onlyCountries` and `exceptCountries` are mutually exclusive, only one can be defined at a time. */
145
+ onlyCountries: z.array(z.string()).optional(),
146
+ /**
147
+ * Filters the reports based on a given array of ISO 3166-1 Alpha-2 countries, excluding only the given list.
148
+ * Requires a subscription to use this feature.
149
+ * `onlyCountries` and `exceptCountries` are mutually exclusive, only one can be defined at a time. */
150
+ exceptCountries: z.array(z.string()).optional(),
151
+ });
152
+ /**
153
+ * @group Input - Validator
154
+ */
155
+ const blacklistSchema = blacklistOptionsSchema
156
+ .transform(schema => filterBooleanAPIQueryStrings(schema, 'plaintext'))
157
+ .superRefine((schemaValues, ctx) => {
158
+ // Countries declaration are optional, skip validation if this is the case.
159
+ if (!(schemaValues.onlyCountries ?? schemaValues.exceptCountries)) {
160
+ return;
161
+ }
162
+ if (schemaValues.onlyCountries && schemaValues.exceptCountries) {
163
+ ctx.addIssue({
164
+ code: z.ZodIssueCode.custom,
165
+ message: '`exceptCountries` and `onlyCountries` are mutually exclusive, only one can be defined at a time.',
166
+ });
167
+ return;
168
+ }
169
+ const countriesParams = ['onlyCountries', 'exceptCountries'];
170
+ for (const countryParam of countriesParams) {
171
+ const countriesArr = schemaValues[countryParam];
172
+ if (!countriesArr) {
173
+ continue;
174
+ }
175
+ if (countriesArr.length === 0) {
176
+ ctx.addIssue({
177
+ code: z.ZodIssueCode.too_small,
178
+ minimum: 1,
179
+ type: 'array',
180
+ inclusive: true,
181
+ message: `[${countryParam}] Atleast one country must be specified.`,
182
+ });
183
+ continue;
184
+ }
185
+ if (!isArrISO31661Alpha2(countriesArr)) {
186
+ ctx.addIssue({
187
+ code: z.ZodIssueCode.custom,
188
+ message: `[${countryParam}] Countries must be valid ISO 3166-1 Alpha-2 codes.`,
189
+ });
190
+ }
191
+ }
192
+ });
193
+ const reportRequiredSchema = z.object({
194
+ /** Single IPv4/IPv6 address. */
195
+ ip: z.string().refine(isIP, { message: 'Must be a valid IPv4/IPv6 Address' }),
196
+ /** Array of categories */
197
+ categories: z.array(z.number().int().min(1).max(23)).min(1).max(30),
198
+ });
199
+ const reportOptionsSchema = z.object({
200
+ /** Message to be added to the report, limited to 1024 characters. */
201
+ comment: z.string().max(1024).optional(),
202
+ });
203
+ /**
204
+ * @group Input - Validator
205
+ */
206
+ const reportSchema = reportRequiredSchema.merge(reportOptionsSchema);
207
+ const checkBlockRequiredSchema = z.object({
208
+ /**
209
+ * Single IPv4/IPv6 address block in CIDR format.
210
+ * The value is capped by your current subscription tier. (Up to /24 on Standard, /20 on Basic, /16 on Premium).
211
+ */
212
+ network: z
213
+ .string()
214
+ .refine(isIPRange, { message: 'Must be a valid CIDR block' }),
215
+ });
216
+ const checkBlockOptionsSchema = z.object({
217
+ /**
218
+ * Show latest reports based on `n` days. Accepted values between 1 and 365, defaults to `30` by the API.
219
+ * The value is capped by your current subscription tier. (Up to 30 on Standard, 60 on Basic, 365 on Premium).
220
+ */
221
+ maxAgeInDays: z.number().int().min(1).max(365).optional(),
222
+ });
223
+ /**
224
+ * @group Input - Validator
225
+ */
226
+ const checkBlockSchema = checkBlockRequiredSchema.merge(checkBlockOptionsSchema);
227
+ const bulkReportRequiredSchema = z.object({
228
+ /** Report CSV filepath to be sent. */
229
+ csv: z.string(),
230
+ });
231
+ /**
232
+ * @group Input - Validator
233
+ */
234
+ const bulkReportSchema = bulkReportRequiredSchema;
235
+ /** Single IPv4/IPv6 address. */
236
+ const clearAddressRequiredSchema = z
237
+ .string()
238
+ .refine(isIP, { message: 'Must be a valid IPv4/IPv6 Address' });
239
+ /**
240
+ * @group Input - Validator
241
+ */
242
242
  const clearAddressSchema = z.object({ ipAddress: clearAddressRequiredSchema });
243
243
 
244
- /**
245
- * Base URL used to make client calls, defaults to AbuseIPDB's APIv2 Endpoint.
246
- * Can be changed when instatiating a new AbuseIPDBClient through the URL param.
247
- * @see {@link AbuseIPDBClientOptions}
248
- * @group Constants
249
- */
244
+ /**
245
+ * Base URL used to make client calls, defaults to AbuseIPDB's APIv2 Endpoint.
246
+ * Can be changed when instatiating a new AbuseIPDBClient through the URL param.
247
+ * @see {@link AbuseIPDBClientOptions}
248
+ * @group Constants
249
+ */
250
250
  const BASE_URL = 'https://api.abuseipdb.com/api/v2';
251
251
 
252
- var _AbuseIPDBClient_instances, _AbuseIPDBClient_headers, _AbuseIPDBClient_apiKey, _AbuseIPDBClient_url, _AbuseIPDBClient_setHeaders, _AbuseIPDBClient_buildResponseHeaders, _AbuseIPDBClient_formatResponse, _AbuseIPDBClient_requestData, _AbuseIPDBClient_formatRequestBulkReport, _AbuseIPDBClient_formatUrl, _AbuseIPDBClient_validateData, _AbuseIPDBClient_handleRequest;
253
- const ENDPOINTS = {
254
- check: {
255
- method: 'GET',
256
- schema: checkSchema,
257
- },
258
- reports: {
259
- method: 'GET',
260
- schema: reportsSchema,
261
- },
262
- blacklist: {
263
- method: 'GET',
264
- schema: blacklistSchema,
265
- },
266
- report: {
267
- method: 'POST',
268
- schema: reportSchema,
269
- },
270
- 'check-block': {
271
- method: 'GET',
272
- schema: checkBlockSchema,
273
- },
274
- 'bulk-report': {
275
- method: 'POST',
276
- schema: bulkReportSchema,
277
- },
278
- 'clear-address': {
279
- method: 'DELETE',
280
- schema: clearAddressSchema,
281
- },
282
- };
283
- /**
284
- * @group Client
285
- */
286
- class AbuseIPDBClient {
287
- /**
288
- * Creates a new AbuseIPDB client, requires an API key from AbuseIPDB's dashboard.
289
- * @param apiKey AbuseIPDB client API key.
290
- * @param options Optional parameters - {@link AbuseIPDBClientOptions}
291
- */
292
- constructor(apiKey, options) {
293
- _AbuseIPDBClient_instances.add(this);
294
- _AbuseIPDBClient_headers.set(this, void 0);
295
- _AbuseIPDBClient_apiKey.set(this, void 0);
296
- _AbuseIPDBClient_url.set(this, void 0);
297
- const params = { apiKey, ...options };
298
- const validatedParams = __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_validateData).call(this, params, abuseIPDBClientSchema);
299
- __classPrivateFieldSet(this, _AbuseIPDBClient_apiKey, validatedParams.apiKey, "f");
300
- __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_setHeaders).call(this, validatedParams.apiKey);
301
- if (validatedParams?.url) {
302
- __classPrivateFieldSet(this, _AbuseIPDBClient_url, validatedParams.url, "f");
303
- return;
304
- }
305
- __classPrivateFieldSet(this, _AbuseIPDBClient_url, BASE_URL, "f");
306
- }
307
- /**
308
- * Returns the current client config.
309
- */
310
- getConfig() {
311
- return {
312
- apiKey: __classPrivateFieldGet(this, _AbuseIPDBClient_apiKey, "f"),
313
- url: __classPrivateFieldGet(this, _AbuseIPDBClient_url, "f"),
314
- };
315
- }
316
- /**
317
- * @see [Check API Endpoint](https://docs.abuseipdb.com/#check-endpoint)
318
- * @param ipAddress Single IPv4/IPv6 address to be verified.
319
- * @param options Optional parameters - {@link CheckOptions}
320
- */
321
- async check(ipAddress, options) {
322
- return __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_handleRequest).call(this, 'check', {
323
- ipAddress,
324
- ...options,
325
- });
326
- }
327
- /**
328
- * @see [Reports API Endpoint](https://docs.abuseipdb.com/#reports-endpoint)
329
- * @param ipAddress Single IPv4/IPv6 address to be verified.
330
- * @param options Optional parameters - {@link ReportsOptions}
331
- * @beta
332
- */
333
- async reports(ipAddress, options) {
334
- return __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_handleRequest).call(this, 'reports', { ipAddress, ...options });
335
- }
336
- /**
337
- * @see [Blacklist API Endpoint](https://docs.abuseipdb.com/#blacklist-endpoint)
338
- * @param options Optional parameters - {@link BlacklistOptions}
339
- */
340
- async blacklist(options) {
341
- return __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_handleRequest).call(this, 'blacklist', { ...options });
342
- }
343
- /**
344
- * @see [Report API Endpoint](https://docs.abuseipdb.com/#report-endpoint)
345
- * @param ip Single IPv4/IPv6 address to be verified.
346
- * @param categories Array of categories to be reported.
347
- * @param options Optional parameters - {@link ReportOptions}
348
- */
349
- async report(ip, categories, options) {
350
- return __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_handleRequest).call(this, 'report', { ip, categories, ...options });
351
- }
352
- /**
353
- * @see [Check-Block API Endpoint](https://docs.abuseipdb.com/#check-block-endpoint)
354
- * @param network Single IPv4/IPv6 address block in CIDR format.
355
- * @param options Optional parameters - {@link CheckBlockOptions}
356
- */
357
- async checkBlock(network, options) {
358
- return __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_handleRequest).call(this, 'check-block', { network, ...options });
359
- }
360
- /**
361
- * @see [Bulk-Report API Endpoint](https://docs.abuseipdb.com/#bulk-report-endpoint)
362
- * @param csv CSV filepath to be sent.
363
- */
364
- async bulkReport(csv) {
365
- return __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_handleRequest).call(this, 'bulk-report', { csv });
366
- }
367
- /**
368
- * @see [Clear-Address API Endpoint](https://docs.abuseipdb.com/#clear-address-endpoint)
369
- * @param ipAddress Single IPv4/IPv6 address.
370
- */
371
- async clearAddress(ipAddress) {
372
- return __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_handleRequest).call(this, 'clear-address', { ipAddress });
373
- }
374
- }
375
- _AbuseIPDBClient_headers = new WeakMap(), _AbuseIPDBClient_apiKey = new WeakMap(), _AbuseIPDBClient_url = new WeakMap(), _AbuseIPDBClient_instances = new WeakSet(), _AbuseIPDBClient_setHeaders = function _AbuseIPDBClient_setHeaders(apiKey) {
376
- __classPrivateFieldSet(this, _AbuseIPDBClient_headers, {
377
- Key: apiKey,
378
- Accept: 'application/json',
379
- }, "f");
380
- }, _AbuseIPDBClient_buildResponseHeaders = function _AbuseIPDBClient_buildResponseHeaders(response) {
381
- const headersJson = {};
382
- // From fetch response.
383
- headersJson.url = response.url;
384
- headersJson.status = response.status;
385
- headersJson.statusText = response.statusText;
386
- // From AbuseIPDB API HTTP headers.
387
- const rateLimitKeys = [
388
- 'retry-after',
389
- 'x-ratelimit-limit',
390
- 'x-ratelimit-remaining',
391
- 'x-ratelimit-reset',
392
- 'x-generated-at',
393
- ];
394
- for (const key of rateLimitKeys) {
395
- const value = response.headers.get(key);
396
- if (value) {
397
- headersJson[key] = value;
398
- }
399
- }
400
- return headersJson;
401
- }, _AbuseIPDBClient_formatResponse = async function _AbuseIPDBClient_formatResponse(fetchAPIResponse) {
402
- const headers = __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_buildResponseHeaders).call(this, fetchAPIResponse);
403
- let formattedResponse;
404
- /**
405
- * The `x-generated-at` header is present on blacklist API text endpoint response, it
406
- * is formatted here to keep consistency.
407
- * @see {@link APIBlacklistEndpointTextResponse}
408
- */
409
- if (headers['x-generated-at']) {
410
- const xGeneratedAt = headers['x-generated-at'];
411
- delete headers['x-generated-at'];
412
- const bodyWithMeta = {
413
- meta: {
414
- generatedAt: xGeneratedAt,
415
- },
416
- data: await fetchAPIResponse.text(),
417
- };
418
- formattedResponse = {
419
- headers,
420
- result: bodyWithMeta,
421
- };
422
- }
423
- else {
424
- const body = await fetchAPIResponse.json();
425
- if (body.errors) {
426
- formattedResponse = { headers, error: body };
427
- }
428
- else {
429
- formattedResponse = {
430
- headers,
431
- result: body,
432
- };
433
- }
434
- }
435
- return formattedResponse;
436
- }, _AbuseIPDBClient_requestData = async function _AbuseIPDBClient_requestData(url, method, headers, body) {
437
- return fetch(url, {
438
- method,
439
- headers,
440
- body,
441
- });
442
- }, _AbuseIPDBClient_formatRequestBulkReport = function _AbuseIPDBClient_formatRequestBulkReport(headers, data) {
443
- const { csv } = data;
444
- const file = fileFromSync(csv);
445
- const formData = new FormData();
446
- formData.append('csv', file);
447
- return {
448
- headers,
449
- body: formData,
450
- };
451
- }, _AbuseIPDBClient_formatUrl = function _AbuseIPDBClient_formatUrl(uri, params) {
452
- const url = new URL(`${__classPrivateFieldGet(this, _AbuseIPDBClient_url, "f")}/${uri}`);
453
- for (const key of Object.keys(params ?? {})) {
454
- url.searchParams.append(key, params?.[key]);
455
- }
456
- return url.href;
457
- }, _AbuseIPDBClient_validateData = function _AbuseIPDBClient_validateData(parameters, schema) {
458
- const result = schema.safeParse(parameters);
459
- if (!result.success) {
460
- throw result.error;
461
- }
462
- else {
463
- return result.data;
464
- }
465
- }, _AbuseIPDBClient_handleRequest = async function _AbuseIPDBClient_handleRequest(endpointURI, parameters) {
466
- const { method, schema } = ENDPOINTS[endpointURI];
467
- // Validates the input parameters given by the client.
468
- const validatedInput = __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_validateData).call(this, parameters, schema);
469
- let response;
470
- if (endpointURI === 'bulk-report') {
471
- // There is no need to append QueryParams for the bulk-report endpoint, so it is removed here.
472
- const url = __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_formatUrl).call(this, endpointURI);
473
- const { headers, body } = __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_formatRequestBulkReport).call(this, __classPrivateFieldGet(this, _AbuseIPDBClient_headers, "f"), parameters);
474
- response = await __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_requestData).call(this, url, method, headers, body);
475
- }
476
- else {
477
- const url = __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_formatUrl).call(this, endpointURI, validatedInput);
478
- response = await __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_requestData).call(this, url, method, __classPrivateFieldGet(this, _AbuseIPDBClient_headers, "f"));
479
- }
480
- // Transforms the API fetch response to the library format.
481
- const formattedResponseData = await __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_formatResponse).call(this, response);
482
- return formattedResponseData;
252
+ var _AbuseIPDBClient_instances, _AbuseIPDBClient_headers, _AbuseIPDBClient_apiKey, _AbuseIPDBClient_url, _AbuseIPDBClient_setHeaders, _AbuseIPDBClient_buildResponseHeaders, _AbuseIPDBClient_formatResponse, _AbuseIPDBClient_requestData, _AbuseIPDBClient_formatRequestBulkReport, _AbuseIPDBClient_formatUrl, _AbuseIPDBClient_validateData, _AbuseIPDBClient_handleRequest;
253
+ const ENDPOINTS = {
254
+ check: {
255
+ method: 'GET',
256
+ schema: checkSchema,
257
+ },
258
+ reports: {
259
+ method: 'GET',
260
+ schema: reportsSchema,
261
+ },
262
+ blacklist: {
263
+ method: 'GET',
264
+ schema: blacklistSchema,
265
+ },
266
+ report: {
267
+ method: 'POST',
268
+ schema: reportSchema,
269
+ },
270
+ 'check-block': {
271
+ method: 'GET',
272
+ schema: checkBlockSchema,
273
+ },
274
+ 'bulk-report': {
275
+ method: 'POST',
276
+ schema: bulkReportSchema,
277
+ },
278
+ 'clear-address': {
279
+ method: 'DELETE',
280
+ schema: clearAddressSchema,
281
+ },
282
+ };
283
+ /**
284
+ * @group Client
285
+ */
286
+ class AbuseIPDBClient {
287
+ /**
288
+ * Creates a new AbuseIPDB client, requires an API key from AbuseIPDB's dashboard.
289
+ * @param apiKey AbuseIPDB client API key.
290
+ * @param options Optional parameters - {@link AbuseIPDBClientOptions}
291
+ */
292
+ constructor(apiKey, options) {
293
+ _AbuseIPDBClient_instances.add(this);
294
+ _AbuseIPDBClient_headers.set(this, void 0);
295
+ _AbuseIPDBClient_apiKey.set(this, void 0);
296
+ _AbuseIPDBClient_url.set(this, void 0);
297
+ const params = { apiKey, ...options };
298
+ const validatedParams = __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_validateData).call(this, params, abuseIPDBClientSchema);
299
+ __classPrivateFieldSet(this, _AbuseIPDBClient_apiKey, validatedParams.apiKey, "f");
300
+ __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_setHeaders).call(this, validatedParams.apiKey);
301
+ if (validatedParams?.url) {
302
+ __classPrivateFieldSet(this, _AbuseIPDBClient_url, validatedParams.url, "f");
303
+ return;
304
+ }
305
+ __classPrivateFieldSet(this, _AbuseIPDBClient_url, BASE_URL, "f");
306
+ }
307
+ /**
308
+ * Returns the current client config.
309
+ */
310
+ getConfig() {
311
+ return {
312
+ apiKey: __classPrivateFieldGet(this, _AbuseIPDBClient_apiKey, "f"),
313
+ url: __classPrivateFieldGet(this, _AbuseIPDBClient_url, "f"),
314
+ };
315
+ }
316
+ /**
317
+ * @see [Check API Endpoint](https://docs.abuseipdb.com/#check-endpoint)
318
+ * @param ipAddress Single IPv4/IPv6 address to be verified.
319
+ * @param options Optional parameters - {@link CheckOptions}
320
+ */
321
+ async check(ipAddress, options) {
322
+ return __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_handleRequest).call(this, 'check', {
323
+ ipAddress,
324
+ ...options,
325
+ });
326
+ }
327
+ /**
328
+ * @see [Reports API Endpoint](https://docs.abuseipdb.com/#reports-endpoint)
329
+ * @param ipAddress Single IPv4/IPv6 address to be verified.
330
+ * @param options Optional parameters - {@link ReportsOptions}
331
+ * @beta
332
+ */
333
+ async reports(ipAddress, options) {
334
+ return __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_handleRequest).call(this, 'reports', { ipAddress, ...options });
335
+ }
336
+ /**
337
+ * @see [Blacklist API Endpoint](https://docs.abuseipdb.com/#blacklist-endpoint)
338
+ * @param options Optional parameters - {@link BlacklistOptions}
339
+ */
340
+ async blacklist(options) {
341
+ return __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_handleRequest).call(this, 'blacklist', { ...options });
342
+ }
343
+ /**
344
+ * @see [Report API Endpoint](https://docs.abuseipdb.com/#report-endpoint)
345
+ * @param ip Single IPv4/IPv6 address to be verified.
346
+ * @param categories Array of categories to be reported.
347
+ * @param options Optional parameters - {@link ReportOptions}
348
+ */
349
+ async report(ip, categories, options) {
350
+ return __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_handleRequest).call(this, 'report', { ip, categories, ...options });
351
+ }
352
+ /**
353
+ * @see [Check-Block API Endpoint](https://docs.abuseipdb.com/#check-block-endpoint)
354
+ * @param network Single IPv4/IPv6 address block in CIDR format.
355
+ * @param options Optional parameters - {@link CheckBlockOptions}
356
+ */
357
+ async checkBlock(network, options) {
358
+ return __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_handleRequest).call(this, 'check-block', { network, ...options });
359
+ }
360
+ /**
361
+ * @see [Bulk-Report API Endpoint](https://docs.abuseipdb.com/#bulk-report-endpoint)
362
+ * @param csv CSV filepath to be sent.
363
+ */
364
+ async bulkReport(csv) {
365
+ return __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_handleRequest).call(this, 'bulk-report', { csv });
366
+ }
367
+ /**
368
+ * @see [Clear-Address API Endpoint](https://docs.abuseipdb.com/#clear-address-endpoint)
369
+ * @param ipAddress Single IPv4/IPv6 address.
370
+ */
371
+ async clearAddress(ipAddress) {
372
+ return __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_handleRequest).call(this, 'clear-address', { ipAddress });
373
+ }
374
+ }
375
+ _AbuseIPDBClient_headers = new WeakMap(), _AbuseIPDBClient_apiKey = new WeakMap(), _AbuseIPDBClient_url = new WeakMap(), _AbuseIPDBClient_instances = new WeakSet(), _AbuseIPDBClient_setHeaders = function _AbuseIPDBClient_setHeaders(apiKey) {
376
+ __classPrivateFieldSet(this, _AbuseIPDBClient_headers, {
377
+ Key: apiKey,
378
+ Accept: 'application/json',
379
+ }, "f");
380
+ }, _AbuseIPDBClient_buildResponseHeaders = function _AbuseIPDBClient_buildResponseHeaders(response) {
381
+ const headersJson = {};
382
+ // From fetch response.
383
+ headersJson.url = response.url;
384
+ headersJson.status = response.status;
385
+ headersJson.statusText = response.statusText;
386
+ // From AbuseIPDB API HTTP headers.
387
+ const rateLimitKeys = [
388
+ 'retry-after',
389
+ 'x-ratelimit-limit',
390
+ 'x-ratelimit-remaining',
391
+ 'x-ratelimit-reset',
392
+ 'x-generated-at',
393
+ ];
394
+ for (const key of rateLimitKeys) {
395
+ const value = response.headers.get(key);
396
+ if (value) {
397
+ headersJson[key] = value;
398
+ }
399
+ }
400
+ return headersJson;
401
+ }, _AbuseIPDBClient_formatResponse = async function _AbuseIPDBClient_formatResponse(fetchAPIResponse) {
402
+ const headers = __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_buildResponseHeaders).call(this, fetchAPIResponse);
403
+ let formattedResponse;
404
+ /**
405
+ * The `x-generated-at` header is present on blacklist API text endpoint response, it
406
+ * is formatted here to keep consistency.
407
+ * @see {@link APIBlacklistEndpointTextResponse}
408
+ */
409
+ if (headers['x-generated-at']) {
410
+ const xGeneratedAt = headers['x-generated-at'];
411
+ delete headers['x-generated-at'];
412
+ const bodyWithMeta = {
413
+ meta: {
414
+ generatedAt: xGeneratedAt,
415
+ },
416
+ data: await fetchAPIResponse.text(),
417
+ };
418
+ formattedResponse = {
419
+ headers,
420
+ result: bodyWithMeta,
421
+ };
422
+ }
423
+ else {
424
+ const body = await fetchAPIResponse.json();
425
+ if (body.errors) {
426
+ formattedResponse = { headers, error: body };
427
+ }
428
+ else {
429
+ formattedResponse = {
430
+ headers,
431
+ result: body,
432
+ };
433
+ }
434
+ }
435
+ return formattedResponse;
436
+ }, _AbuseIPDBClient_requestData = async function _AbuseIPDBClient_requestData(url, method, headers, body) {
437
+ return fetch(url, {
438
+ method,
439
+ headers,
440
+ body,
441
+ });
442
+ }, _AbuseIPDBClient_formatRequestBulkReport = function _AbuseIPDBClient_formatRequestBulkReport(headers, data) {
443
+ const { csv } = data;
444
+ const file = fileFromSync(csv);
445
+ const formData = new FormData();
446
+ formData.append('csv', file);
447
+ return {
448
+ headers,
449
+ body: formData,
450
+ };
451
+ }, _AbuseIPDBClient_formatUrl = function _AbuseIPDBClient_formatUrl(uri, params) {
452
+ const url = new URL(`${__classPrivateFieldGet(this, _AbuseIPDBClient_url, "f")}/${uri}`);
453
+ for (const key of Object.keys(params ?? {})) {
454
+ url.searchParams.append(key, params?.[key]);
455
+ }
456
+ return url.href;
457
+ }, _AbuseIPDBClient_validateData = function _AbuseIPDBClient_validateData(parameters, schema) {
458
+ const result = schema.safeParse(parameters);
459
+ if (!result.success) {
460
+ throw result.error;
461
+ }
462
+ else {
463
+ return result.data;
464
+ }
465
+ }, _AbuseIPDBClient_handleRequest = async function _AbuseIPDBClient_handleRequest(endpointURI, parameters) {
466
+ const { method, schema } = ENDPOINTS[endpointURI];
467
+ // Validates the input parameters given by the client.
468
+ const validatedInput = __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_validateData).call(this, parameters, schema);
469
+ let response;
470
+ if (endpointURI === 'bulk-report') {
471
+ // There is no need to append QueryParams for the bulk-report endpoint, so it is removed here.
472
+ const url = __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_formatUrl).call(this, endpointURI);
473
+ const { headers, body } = __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_formatRequestBulkReport).call(this, __classPrivateFieldGet(this, _AbuseIPDBClient_headers, "f"), parameters);
474
+ response = await __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_requestData).call(this, url, method, headers, body);
475
+ }
476
+ else {
477
+ const url = __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_formatUrl).call(this, endpointURI, validatedInput);
478
+ response = await __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_requestData).call(this, url, method, __classPrivateFieldGet(this, _AbuseIPDBClient_headers, "f"));
479
+ }
480
+ // Transforms the API fetch response to the library format.
481
+ const formattedResponseData = await __classPrivateFieldGet(this, _AbuseIPDBClient_instances, "m", _AbuseIPDBClient_formatResponse).call(this, response);
482
+ return formattedResponseData;
483
483
  };
484
484
 
485
- /**
486
- * AbuseIPDB Report Category types.
487
- * @see [AbuseIPDB Report Categories](https://www.abuseipdb.com/categories)
488
- * @enum
489
- * @group AbuseIPDB API Response
490
- * @example
491
- * ```typescript
492
- * import { ReportCategory } from 'abuseipdb-client';
493
- *
494
- * // `ReportCategory` enum can be used to populate an array of categories.
495
- * const categories: Array<ReportCategory> = [
496
- * ReportCategory.WebSpam,
497
- * ReportCategory.BadWebBot,
498
- * ReportCategory.BruteForce,
499
- * ];
500
- *
501
- * // Which translates to:
502
- * // categories = [ 10, 19, 18 ].
503
- *
504
- * // That way, it is possible to call the `report` endpoint using this reference directly:
505
- * client.report('127.0.0.1', categories);
506
- * ```
507
- */
508
- var ReportCategory;
509
- (function (ReportCategory) {
510
- /**
511
- * Altering DNS records resulting in improper redirection.
512
- */
513
- ReportCategory[ReportCategory["DNSCompromise"] = 1] = "DNSCompromise";
514
- /**
515
- * Falsifying domain server cache (cache poisoning).
516
- */
517
- ReportCategory[ReportCategory["DNSPoisoning"] = 2] = "DNSPoisoning";
518
- /**
519
- * Fraudulent orders.
520
- */
521
- ReportCategory[ReportCategory["FraudOrders"] = 3] = "FraudOrders";
522
- /**
523
- * Participating in distributed denial-of-service (usually part of botnet).
524
- */
525
- ReportCategory[ReportCategory["DDOSAttack"] = 4] = "DDOSAttack";
526
- /**
527
- * FTP Brute force attempt.
528
- */
529
- ReportCategory[ReportCategory["FTPBruteForce"] = 5] = "FTPBruteForce";
530
- /**
531
- * Oversized IP packet.
532
- */
533
- ReportCategory[ReportCategory["PingOfDeath"] = 6] = "PingOfDeath";
534
- /**
535
- * Phishing websites and/or email.
536
- */
537
- ReportCategory[ReportCategory["Phishing"] = 7] = "Phishing";
538
- /**
539
- * Voice-over-IP fraud.
540
- */
541
- ReportCategory[ReportCategory["FraudVoIP"] = 8] = "FraudVoIP";
542
- /**
543
- * Open proxy, open relay, or Tor exit node.
544
- */
545
- ReportCategory[ReportCategory["OpenProxy"] = 9] = "OpenProxy";
546
- /**
547
- * Comment/forum spam, HTTP referer spam, or other CMS spam.
548
- */
549
- ReportCategory[ReportCategory["WebSpam"] = 10] = "WebSpam";
550
- /**
551
- * 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.
552
- */
553
- ReportCategory[ReportCategory["EmailSpam"] = 11] = "EmailSpam";
554
- /**
555
- * CMS blog comment spam.
556
- */
557
- ReportCategory[ReportCategory["BlogSpam"] = 12] = "BlogSpam";
558
- /**
559
- * VPN IP address.
560
- */
561
- ReportCategory[ReportCategory["VPNIP"] = 13] = "VPNIP";
562
- /**
563
- * Scanning for open ports and vulnerable services.
564
- */
565
- ReportCategory[ReportCategory["PortScan"] = 14] = "PortScan";
566
- /**
567
- * General hacking attempt.
568
- */
569
- ReportCategory[ReportCategory["Hacking"] = 15] = "Hacking";
570
- /**
571
- * Attempts at SQL injection.
572
- */
573
- ReportCategory[ReportCategory["SQLInjection"] = 16] = "SQLInjection";
574
- /**
575
- * Email sender spoofing.
576
- */
577
- ReportCategory[ReportCategory["Spoofing"] = 17] = "Spoofing";
578
- /**
579
- * Credential brute-force attacks on webpage logins and services like SSH, FTP, SIP, SMTP, RDP, etc. This category is seperate from DDoS attacks.
580
- */
581
- ReportCategory[ReportCategory["BruteForce"] = 18] = "BruteForce";
582
- /**
583
- * 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.
584
- */
585
- ReportCategory[ReportCategory["BadWebBot"] = 19] = "BadWebBot";
586
- /**
587
- * 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.
588
- */
589
- ReportCategory[ReportCategory["ExploitedHost"] = 20] = "ExploitedHost";
590
- /**
591
- * 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.
592
- */
593
- ReportCategory[ReportCategory["WebAppAttack"] = 21] = "WebAppAttack";
594
- /**
595
- * Secure Shell (SSH) abuse. Use this category in combination with more specific categories.
596
- */
597
- ReportCategory[ReportCategory["SSH"] = 22] = "SSH";
598
- /**
599
- * Abuse was targeted at an "Internet of Things" type device. Include information about what type of device was targeted in the comments.
600
- */
601
- ReportCategory[ReportCategory["IOTTargeted"] = 23] = "IOTTargeted";
485
+ /**
486
+ * AbuseIPDB Report Category types.
487
+ * @see [AbuseIPDB Report Categories](https://www.abuseipdb.com/categories)
488
+ * @enum
489
+ * @group AbuseIPDB API Response
490
+ * @example
491
+ * ```typescript
492
+ * import { ReportCategory } from 'abuseipdb-client';
493
+ *
494
+ * // `ReportCategory` enum can be used to populate an array of categories.
495
+ * const categories: Array<ReportCategory> = [
496
+ * ReportCategory.WebSpam,
497
+ * ReportCategory.BadWebBot,
498
+ * ReportCategory.BruteForce,
499
+ * ];
500
+ *
501
+ * // Which translates to:
502
+ * // categories = [ 10, 19, 18 ].
503
+ *
504
+ * // That way, it is possible to call the `report` endpoint using this reference directly:
505
+ * client.report('127.0.0.1', categories);
506
+ * ```
507
+ */
508
+ var ReportCategory;
509
+ (function (ReportCategory) {
510
+ /**
511
+ * Altering DNS records resulting in improper redirection.
512
+ */
513
+ ReportCategory[ReportCategory["DNSCompromise"] = 1] = "DNSCompromise";
514
+ /**
515
+ * Falsifying domain server cache (cache poisoning).
516
+ */
517
+ ReportCategory[ReportCategory["DNSPoisoning"] = 2] = "DNSPoisoning";
518
+ /**
519
+ * Fraudulent orders.
520
+ */
521
+ ReportCategory[ReportCategory["FraudOrders"] = 3] = "FraudOrders";
522
+ /**
523
+ * Participating in distributed denial-of-service (usually part of botnet).
524
+ */
525
+ ReportCategory[ReportCategory["DDOSAttack"] = 4] = "DDOSAttack";
526
+ /**
527
+ * FTP Brute force attempt.
528
+ */
529
+ ReportCategory[ReportCategory["FTPBruteForce"] = 5] = "FTPBruteForce";
530
+ /**
531
+ * Oversized IP packet.
532
+ */
533
+ ReportCategory[ReportCategory["PingOfDeath"] = 6] = "PingOfDeath";
534
+ /**
535
+ * Phishing websites and/or email.
536
+ */
537
+ ReportCategory[ReportCategory["Phishing"] = 7] = "Phishing";
538
+ /**
539
+ * Voice-over-IP fraud.
540
+ */
541
+ ReportCategory[ReportCategory["FraudVoIP"] = 8] = "FraudVoIP";
542
+ /**
543
+ * Open proxy, open relay, or Tor exit node.
544
+ */
545
+ ReportCategory[ReportCategory["OpenProxy"] = 9] = "OpenProxy";
546
+ /**
547
+ * Comment/forum spam, HTTP referer spam, or other CMS spam.
548
+ */
549
+ ReportCategory[ReportCategory["WebSpam"] = 10] = "WebSpam";
550
+ /**
551
+ * 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.
552
+ */
553
+ ReportCategory[ReportCategory["EmailSpam"] = 11] = "EmailSpam";
554
+ /**
555
+ * CMS blog comment spam.
556
+ */
557
+ ReportCategory[ReportCategory["BlogSpam"] = 12] = "BlogSpam";
558
+ /**
559
+ * VPN IP address.
560
+ */
561
+ ReportCategory[ReportCategory["VPNIP"] = 13] = "VPNIP";
562
+ /**
563
+ * Scanning for open ports and vulnerable services.
564
+ */
565
+ ReportCategory[ReportCategory["PortScan"] = 14] = "PortScan";
566
+ /**
567
+ * General hacking attempt.
568
+ */
569
+ ReportCategory[ReportCategory["Hacking"] = 15] = "Hacking";
570
+ /**
571
+ * Attempts at SQL injection.
572
+ */
573
+ ReportCategory[ReportCategory["SQLInjection"] = 16] = "SQLInjection";
574
+ /**
575
+ * Email sender spoofing.
576
+ */
577
+ ReportCategory[ReportCategory["Spoofing"] = 17] = "Spoofing";
578
+ /**
579
+ * Credential brute-force attacks on webpage logins and services like SSH, FTP, SIP, SMTP, RDP, etc. This category is seperate from DDoS attacks.
580
+ */
581
+ ReportCategory[ReportCategory["BruteForce"] = 18] = "BruteForce";
582
+ /**
583
+ * 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.
584
+ */
585
+ ReportCategory[ReportCategory["BadWebBot"] = 19] = "BadWebBot";
586
+ /**
587
+ * 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.
588
+ */
589
+ ReportCategory[ReportCategory["ExploitedHost"] = 20] = "ExploitedHost";
590
+ /**
591
+ * 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.
592
+ */
593
+ ReportCategory[ReportCategory["WebAppAttack"] = 21] = "WebAppAttack";
594
+ /**
595
+ * Secure Shell (SSH) abuse. Use this category in combination with more specific categories.
596
+ */
597
+ ReportCategory[ReportCategory["SSH"] = 22] = "SSH";
598
+ /**
599
+ * Abuse was targeted at an "Internet of Things" type device. Include information about what type of device was targeted in the comments.
600
+ */
601
+ ReportCategory[ReportCategory["IOTTargeted"] = 23] = "IOTTargeted";
602
602
  })(ReportCategory || (ReportCategory = {}));
603
603
 
604
604
  export { AbuseIPDBClient, BASE_URL, ReportCategory, abuseIPDBClientSchema, blacklistSchema, bulkReportSchema, checkBlockSchema, checkSchema, clearAddressSchema, isArrISO31661Alpha2, reportSchema, reportsSchema };