@corsair-dev/abuseipdb 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.
Files changed (45) hide show
  1. package/LICENSE +191 -0
  2. package/dist/api.test.d.ts +2 -0
  3. package/dist/api.test.d.ts.map +1 -0
  4. package/dist/client.d.ts +48 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/client.test.d.ts +2 -0
  7. package/dist/client.test.d.ts.map +1 -0
  8. package/dist/endpoints/blacklist.d.ts +10 -0
  9. package/dist/endpoints/blacklist.d.ts.map +1 -0
  10. package/dist/endpoints/check-block.d.ts +10 -0
  11. package/dist/endpoints/check-block.d.ts.map +1 -0
  12. package/dist/endpoints/check.d.ts +10 -0
  13. package/dist/endpoints/check.d.ts.map +1 -0
  14. package/dist/endpoints/clear-address.d.ts +10 -0
  15. package/dist/endpoints/clear-address.d.ts.map +1 -0
  16. package/dist/endpoints/index.d.ts +121 -0
  17. package/dist/endpoints/index.d.ts.map +1 -0
  18. package/dist/endpoints/output-validation.test.d.ts +2 -0
  19. package/dist/endpoints/output-validation.test.d.ts.map +1 -0
  20. package/dist/endpoints/report.d.ts +12 -0
  21. package/dist/endpoints/report.d.ts.map +1 -0
  22. package/dist/endpoints/reports.d.ts +9 -0
  23. package/dist/endpoints/reports.d.ts.map +1 -0
  24. package/dist/endpoints/types.d.ts +242 -0
  25. package/dist/endpoints/types.d.ts.map +1 -0
  26. package/dist/error-handlers.d.ts +50 -0
  27. package/dist/error-handlers.d.ts.map +1 -0
  28. package/dist/error-handlers.test.d.ts +2 -0
  29. package/dist/error-handlers.test.d.ts.map +1 -0
  30. package/dist/index.d.ts +186 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/integration.test.d.ts +2 -0
  34. package/dist/integration.test.d.ts.map +1 -0
  35. package/dist/operations.test.d.ts +2 -0
  36. package/dist/operations.test.d.ts.map +1 -0
  37. package/dist/schema/database.d.ts +24 -0
  38. package/dist/schema/database.d.ts.map +1 -0
  39. package/dist/schema/index.d.ts +26 -0
  40. package/dist/schema/index.d.ts.map +1 -0
  41. package/dist/schema.test.d.ts +2 -0
  42. package/dist/schema.test.d.ts.map +1 -0
  43. package/dist/tsup.config.d.ts +3 -0
  44. package/dist/tsup.config.d.ts.map +1 -0
  45. package/package.json +44 -0
package/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (which shall not include Communications that are clearly marked or
39
+ otherwise designated in writing by the copyright owner as "Not a Work").
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution".
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright (c) 2026 Corsair
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=api.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.test.d.ts","sourceRoot":"","sources":["../api.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Error thrown for any non-2xx AbuseIPDB response. Preserves the HTTP status,
3
+ * response body, and rate-limit headers from the underlying `ApiError` so
4
+ * `error-handlers.ts` can inspect them without re-requesting.
5
+ */
6
+ export declare class AbuseIPDBAPIError extends Error {
7
+ readonly code?: number | undefined;
8
+ readonly status?: number;
9
+ readonly statusText?: string;
10
+ /**
11
+ * The raw response body. Deliberately `unknown` — AbuseIPDB returns
12
+ * JSON:API-shaped errors (`{ errors: [{ detail, status, source }] }`)
13
+ * that don't map to a single known schema, so callers narrow it
14
+ * themselves (see error-handlers.ts).
15
+ */
16
+ readonly body?: unknown;
17
+ readonly retryAfter?: number;
18
+ readonly rateLimitReset?: number;
19
+ readonly rateLimitRemaining?: number;
20
+ readonly rateLimitLimit?: number;
21
+ constructor(message: string, code?: number | undefined, options?: {
22
+ cause?: Error;
23
+ });
24
+ }
25
+ /**
26
+ * Safely reads the stored API key from the account key manager.
27
+ *
28
+ * `ctx.keys.get_api_key()` throws (rather than returning null) when the
29
+ * account has no DEK at all — a fully valid state for accounts that only
30
+ * ever configure the key via plugin options and never touch the key
31
+ * manager, and must resolve to "no stored key" rather than abort the
32
+ * request.
33
+ *
34
+ * Anything else thrown (decryption failure, database error, ...) is a real
35
+ * operational problem, not an absent key, and must propagate.
36
+ */
37
+ export declare function tryGetStoredKey(getter: () => Promise<string | null | undefined>): Promise<string | undefined>;
38
+ /**
39
+ * AbuseIPDB API v2 base URL. All endpoints live under `/api/v2`.
40
+ */
41
+ export declare const ABUSEIPDB_API_BASE = "https://api.abuseipdb.com/api/v2";
42
+ export declare function makeAbuseIPDBRequest<T>(endpoint: string, apiKey: string, options?: {
43
+ method?: 'GET' | 'POST' | 'DELETE';
44
+ query?: Record<string, string | number | boolean | undefined>;
45
+ formBody?: Record<string, string | number | undefined>;
46
+ retries?: boolean;
47
+ }): Promise<T>;
48
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../client.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;aAiB1B,IAAI,CAAC,EAAE,MAAM;IAhB9B,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC;;;;;OAKG;IACH,SAAgB,IAAI,CAAC,EAAE,OAAO,CAAC;IAC/B,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,SAAgB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxC,SAAgB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5C,SAAgB,cAAc,CAAC,EAAE,MAAM,CAAC;gBAGvC,OAAO,EAAE,MAAM,EACC,IAAI,CAAC,EAAE,MAAM,YAAA,EAC7B,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;CAe5B;AASD;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CACpC,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAC9C,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAU7B;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,qCAAqC,CAAC;AAyCrE,wBAAsB,oBAAoB,CAAC,CAAC,EAC3C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IACR,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;CACb,GACJ,OAAO,CAAC,CAAC,CAAC,CAwEZ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=client.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../client.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import type { AbuseIPDBEndpoints } from '../index';
2
+ /**
3
+ * Download the blacklist of most-reported IPs, optionally filtered by
4
+ * confidence minimum, country, and IP version.
5
+ *
6
+ * API: GET /api/v2/blacklist
7
+ * Docs: https://docs.abuseipdb.com/#blacklist-endpoint
8
+ */
9
+ export declare const get: AbuseIPDBEndpoints['getBlacklist'];
10
+ //# sourceMappingURL=blacklist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blacklist.d.ts","sourceRoot":"","sources":["../../endpoints/blacklist.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD;;;;;;GAMG;AACH,eAAO,MAAM,GAAG,EAAE,kBAAkB,CAAC,cAAc,CA4ClD,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { AbuseIPDBEndpoints } from '../index';
2
+ /**
3
+ * Check a CIDR network block and list the addresses within it that have
4
+ * been reported to AbuseIPDB.
5
+ *
6
+ * API: GET /api/v2/check-block
7
+ * Docs: https://docs.abuseipdb.com/#check-block-endpoint
8
+ */
9
+ export declare const check: AbuseIPDBEndpoints['checkBlock'];
10
+ //# sourceMappingURL=check-block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-block.d.ts","sourceRoot":"","sources":["../../endpoints/check-block.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAInD;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,EAAE,kBAAkB,CAAC,YAAY,CAwBlD,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { AbuseIPDBEndpoints } from '../index';
2
+ /**
3
+ * Look up an IP address and get its abuse confidence score, country, ISP,
4
+ * usage type, and optionally recent reports (verbose).
5
+ *
6
+ * API: GET /api/v2/check
7
+ * Docs: https://docs.abuseipdb.com/#check-endpoint
8
+ */
9
+ export declare const check: AbuseIPDBEndpoints['checkIp'];
10
+ //# sourceMappingURL=check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../endpoints/check.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAInD;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,EAAE,kBAAkB,CAAC,SAAS,CAmD/C,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { AbuseIPDBEndpoints } from '../index';
2
+ /**
3
+ * Remove all reports for an IP address from your account, and return the
4
+ * number of reports that were deleted.
5
+ *
6
+ * API: DELETE /api/v2/clear-address
7
+ * Docs: https://docs.abuseipdb.com/#clear-address-endpoint
8
+ */
9
+ export declare const clear: AbuseIPDBEndpoints['clearAddress'];
10
+ //# sourceMappingURL=clear-address.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear-address.d.ts","sourceRoot":"","sources":["../../endpoints/clear-address.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAInD;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,EAAE,kBAAkB,CAAC,cAAc,CAuCpD,CAAC"}
@@ -0,0 +1,121 @@
1
+ export declare const CheckIp: {
2
+ check: (ctx: import("..").AbuseIPDBContext, args: {
3
+ ipAddress: string;
4
+ maxAgeInDays?: number | undefined;
5
+ verbose?: boolean | undefined;
6
+ }) => Promise<{
7
+ [x: string]: unknown;
8
+ ipAddress: string;
9
+ isPublic: boolean;
10
+ ipVersion: number;
11
+ isWhitelisted: boolean | null;
12
+ abuseConfidenceScore: number;
13
+ hostnames: string[];
14
+ isTor: boolean;
15
+ totalReports: number;
16
+ numDistinctUsers: number;
17
+ countryCode?: string | null | undefined;
18
+ countryName?: string | null | undefined;
19
+ usageType?: string | null | undefined;
20
+ isp?: string | null | undefined;
21
+ domain?: string | null | undefined;
22
+ lastReportedAt?: string | null | undefined;
23
+ reports?: {
24
+ [x: string]: unknown;
25
+ reportedAt: string;
26
+ categories: number[];
27
+ reporterId: number;
28
+ comment?: string | null | undefined;
29
+ reporterCountryCode?: string | null | undefined;
30
+ reporterCountryName?: string | null | undefined;
31
+ }[] | undefined;
32
+ }>;
33
+ };
34
+ export declare const Reports: {
35
+ list: (ctx: import("..").AbuseIPDBContext, args: {
36
+ ipAddress: string;
37
+ maxAgeInDays?: number | undefined;
38
+ page?: number | undefined;
39
+ perPage?: number | undefined;
40
+ }) => Promise<{
41
+ [x: string]: unknown;
42
+ total: number;
43
+ page: number;
44
+ count: number;
45
+ perPage: number;
46
+ lastPage: number;
47
+ results: {
48
+ [x: string]: unknown;
49
+ reportedAt: string;
50
+ categories: number[];
51
+ reporterId: number;
52
+ comment?: string | null | undefined;
53
+ reporterCountryCode?: string | null | undefined;
54
+ reporterCountryName?: string | null | undefined;
55
+ }[];
56
+ nextPageUrl?: string | null | undefined;
57
+ previousPageUrl?: string | null | undefined;
58
+ }>;
59
+ };
60
+ export declare const Blacklist: {
61
+ get: (ctx: import("..").AbuseIPDBContext, args: {
62
+ confidenceMinimum?: number | undefined;
63
+ limit?: number | undefined;
64
+ onlyCountries?: string[] | undefined;
65
+ exceptCountries?: string[] | undefined;
66
+ ipVersion?: 4 | 6 | undefined;
67
+ }) => Promise<{
68
+ generatedAt: string;
69
+ entries: {
70
+ [x: string]: unknown;
71
+ ipAddress: string;
72
+ abuseConfidenceScore: number;
73
+ lastReportedAt?: string | null | undefined;
74
+ countryCode?: string | null | undefined;
75
+ }[];
76
+ }>;
77
+ };
78
+ export declare const ReportIp: {
79
+ report: (ctx: import("..").AbuseIPDBContext, args: {
80
+ ip: string;
81
+ categories: number[];
82
+ comment?: string | undefined;
83
+ timestamp?: string | undefined;
84
+ }) => Promise<{
85
+ [x: string]: unknown;
86
+ ipAddress: string;
87
+ abuseConfidenceScore: number;
88
+ }>;
89
+ };
90
+ export declare const CheckBlock: {
91
+ check: (ctx: import("..").AbuseIPDBContext, args: {
92
+ network: string;
93
+ maxAgeInDays?: number | undefined;
94
+ }) => Promise<{
95
+ [x: string]: unknown;
96
+ networkAddress: string;
97
+ netmask: string;
98
+ minAddress: string;
99
+ maxAddress: string;
100
+ numPossibleHosts: number;
101
+ reportedAddress: {
102
+ [x: string]: unknown;
103
+ ipAddress: string;
104
+ numReports: number;
105
+ abuseConfidenceScore: number;
106
+ mostRecentReport?: string | null | undefined;
107
+ countryCode?: string | null | undefined;
108
+ }[];
109
+ addressSpaceDesc?: string | null | undefined;
110
+ }>;
111
+ };
112
+ export declare const ClearAddress: {
113
+ clear: (ctx: import("..").AbuseIPDBContext, args: {
114
+ ipAddress: string;
115
+ }) => Promise<{
116
+ [x: string]: unknown;
117
+ numReportsDeleted: number;
118
+ }>;
119
+ };
120
+ export * from './types';
121
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../endpoints/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEnB,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;CAEnB,CAAC;AAEF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;CAErB,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;;;;;;CAEpB,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;CAEtB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;CAExB,CAAC;AAEF,cAAc,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=output-validation.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-validation.test.d.ts","sourceRoot":"","sources":["../../endpoints/output-validation.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import type { AbuseIPDBEndpoints } from '../index';
2
+ /**
3
+ * Submit an abuse report for an IP address.
4
+ *
5
+ * The `categories` field accepts numeric category IDs (integers 1–30) —
6
+ * see https://www.abuseipdb.com/categories for the mapping.
7
+ *
8
+ * API: POST /api/v2/report
9
+ * Docs: https://docs.abuseipdb.com/#report-endpoint
10
+ */
11
+ export declare const report: AbuseIPDBEndpoints['reportIp'];
12
+ //# sourceMappingURL=report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../endpoints/report.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAInD;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,EAAE,kBAAkB,CAAC,UAAU,CA4CjD,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { AbuseIPDBEndpoints } from '../index';
2
+ /**
3
+ * Get a paginated list of abuse reports filed against a single IP address.
4
+ *
5
+ * API: GET /api/v2/reports
6
+ * Docs: https://docs.abuseipdb.com/#reports-endpoint
7
+ */
8
+ export declare const list: AbuseIPDBEndpoints['getReports'];
9
+ //# sourceMappingURL=reports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reports.d.ts","sourceRoot":"","sources":["../../endpoints/reports.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAInD;;;;;GAKG;AACH,eAAO,MAAM,IAAI,EAAE,kBAAkB,CAAC,YAAY,CA0BjD,CAAC"}
@@ -0,0 +1,242 @@
1
+ import { z } from 'zod';
2
+ export declare const CheckIpInputSchema: z.ZodObject<{
3
+ ipAddress: z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6]>;
4
+ maxAgeInDays: z.ZodOptional<z.ZodNumber>;
5
+ verbose: z.ZodOptional<z.ZodBoolean>;
6
+ }, z.core.$strip>;
7
+ export type CheckIpInput = z.infer<typeof CheckIpInputSchema>;
8
+ export declare const CheckIpResponseSchema: z.ZodObject<{
9
+ ipAddress: z.ZodString;
10
+ isPublic: z.ZodBoolean;
11
+ ipVersion: z.ZodNumber;
12
+ isWhitelisted: z.ZodNullable<z.ZodBoolean>;
13
+ abuseConfidenceScore: z.ZodNumber;
14
+ countryCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
15
+ countryName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
16
+ usageType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
17
+ isp: z.ZodOptional<z.ZodNullable<z.ZodString>>;
18
+ domain: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
+ hostnames: z.ZodArray<z.ZodString>;
20
+ isTor: z.ZodBoolean;
21
+ totalReports: z.ZodNumber;
22
+ numDistinctUsers: z.ZodNumber;
23
+ lastReportedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
+ reports: z.ZodOptional<z.ZodArray<z.ZodObject<{
25
+ reportedAt: z.ZodString;
26
+ comment: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
+ categories: z.ZodArray<z.ZodNumber>;
28
+ reporterId: z.ZodNumber;
29
+ reporterCountryCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
30
+ reporterCountryName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
31
+ }, z.core.$loose>>>;
32
+ }, z.core.$loose>;
33
+ export type CheckIpResponse = z.infer<typeof CheckIpResponseSchema>;
34
+ export declare const GetReportsInputSchema: z.ZodObject<{
35
+ ipAddress: z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6]>;
36
+ maxAgeInDays: z.ZodOptional<z.ZodNumber>;
37
+ page: z.ZodOptional<z.ZodNumber>;
38
+ perPage: z.ZodOptional<z.ZodNumber>;
39
+ }, z.core.$strip>;
40
+ export type GetReportsInput = z.infer<typeof GetReportsInputSchema>;
41
+ export declare const GetReportsResponseSchema: z.ZodObject<{
42
+ total: z.ZodNumber;
43
+ page: z.ZodNumber;
44
+ count: z.ZodNumber;
45
+ perPage: z.ZodNumber;
46
+ lastPage: z.ZodNumber;
47
+ nextPageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ previousPageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
49
+ results: z.ZodArray<z.ZodObject<{
50
+ reportedAt: z.ZodString;
51
+ comment: z.ZodOptional<z.ZodNullable<z.ZodString>>;
52
+ categories: z.ZodArray<z.ZodNumber>;
53
+ reporterId: z.ZodNumber;
54
+ reporterCountryCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
55
+ reporterCountryName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
56
+ }, z.core.$loose>>;
57
+ }, z.core.$loose>;
58
+ export type GetReportsResponse = z.infer<typeof GetReportsResponseSchema>;
59
+ export declare const GetBlacklistInputSchema: z.ZodObject<{
60
+ confidenceMinimum: z.ZodOptional<z.ZodNumber>;
61
+ limit: z.ZodOptional<z.ZodNumber>;
62
+ onlyCountries: z.ZodOptional<z.ZodArray<z.ZodString>>;
63
+ exceptCountries: z.ZodOptional<z.ZodArray<z.ZodString>>;
64
+ ipVersion: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<4>, z.ZodLiteral<6>]>>;
65
+ }, z.core.$strip>;
66
+ export type GetBlacklistInput = z.infer<typeof GetBlacklistInputSchema>;
67
+ export declare const GetBlacklistResponseSchema: z.ZodObject<{
68
+ generatedAt: z.ZodString;
69
+ entries: z.ZodArray<z.ZodObject<{
70
+ ipAddress: z.ZodString;
71
+ abuseConfidenceScore: z.ZodNumber;
72
+ lastReportedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
73
+ countryCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
74
+ }, z.core.$loose>>;
75
+ }, z.core.$strip>;
76
+ export type GetBlacklistResponse = z.infer<typeof GetBlacklistResponseSchema>;
77
+ export declare const ReportIpInputSchema: z.ZodObject<{
78
+ ip: z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6]>;
79
+ categories: z.ZodArray<z.ZodNumber>;
80
+ comment: z.ZodOptional<z.ZodString>;
81
+ timestamp: z.ZodOptional<z.ZodISODateTime>;
82
+ }, z.core.$strip>;
83
+ export type ReportIpInput = z.infer<typeof ReportIpInputSchema>;
84
+ export declare const ReportIpResponseSchema: z.ZodObject<{
85
+ ipAddress: z.ZodString;
86
+ abuseConfidenceScore: z.ZodNumber;
87
+ }, z.core.$loose>;
88
+ export type ReportIpResponse = z.infer<typeof ReportIpResponseSchema>;
89
+ export declare const CheckBlockInputSchema: z.ZodObject<{
90
+ network: z.ZodUnion<readonly [z.ZodCIDRv4, z.ZodCIDRv6]>;
91
+ maxAgeInDays: z.ZodOptional<z.ZodNumber>;
92
+ }, z.core.$strip>;
93
+ export type CheckBlockInput = z.infer<typeof CheckBlockInputSchema>;
94
+ export declare const CheckBlockResponseSchema: z.ZodObject<{
95
+ networkAddress: z.ZodString;
96
+ netmask: z.ZodString;
97
+ minAddress: z.ZodString;
98
+ maxAddress: z.ZodString;
99
+ numPossibleHosts: z.ZodNumber;
100
+ addressSpaceDesc: z.ZodOptional<z.ZodNullable<z.ZodString>>;
101
+ reportedAddress: z.ZodArray<z.ZodObject<{
102
+ ipAddress: z.ZodString;
103
+ numReports: z.ZodNumber;
104
+ mostRecentReport: z.ZodOptional<z.ZodNullable<z.ZodString>>;
105
+ abuseConfidenceScore: z.ZodNumber;
106
+ countryCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
107
+ }, z.core.$loose>>;
108
+ }, z.core.$loose>;
109
+ export type CheckBlockResponse = z.infer<typeof CheckBlockResponseSchema>;
110
+ export declare const ClearAddressInputSchema: z.ZodObject<{
111
+ ipAddress: z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6]>;
112
+ }, z.core.$strip>;
113
+ export type ClearAddressInput = z.infer<typeof ClearAddressInputSchema>;
114
+ export declare const ClearAddressResponseSchema: z.ZodObject<{
115
+ numReportsDeleted: z.ZodNumber;
116
+ }, z.core.$loose>;
117
+ export type ClearAddressResponse = z.infer<typeof ClearAddressResponseSchema>;
118
+ export type AbuseIPDBEndpointInputs = {
119
+ checkIp: CheckIpInput;
120
+ getReports: GetReportsInput;
121
+ getBlacklist: GetBlacklistInput;
122
+ reportIp: ReportIpInput;
123
+ checkBlock: CheckBlockInput;
124
+ clearAddress: ClearAddressInput;
125
+ };
126
+ export type AbuseIPDBEndpointOutputs = {
127
+ checkIp: CheckIpResponse;
128
+ getReports: GetReportsResponse;
129
+ getBlacklist: GetBlacklistResponse;
130
+ reportIp: ReportIpResponse;
131
+ checkBlock: CheckBlockResponse;
132
+ clearAddress: ClearAddressResponse;
133
+ };
134
+ export declare const AbuseIPDBEndpointInputSchemas: {
135
+ readonly checkIp: z.ZodObject<{
136
+ ipAddress: z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6]>;
137
+ maxAgeInDays: z.ZodOptional<z.ZodNumber>;
138
+ verbose: z.ZodOptional<z.ZodBoolean>;
139
+ }, z.core.$strip>;
140
+ readonly getReports: z.ZodObject<{
141
+ ipAddress: z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6]>;
142
+ maxAgeInDays: z.ZodOptional<z.ZodNumber>;
143
+ page: z.ZodOptional<z.ZodNumber>;
144
+ perPage: z.ZodOptional<z.ZodNumber>;
145
+ }, z.core.$strip>;
146
+ readonly getBlacklist: z.ZodObject<{
147
+ confidenceMinimum: z.ZodOptional<z.ZodNumber>;
148
+ limit: z.ZodOptional<z.ZodNumber>;
149
+ onlyCountries: z.ZodOptional<z.ZodArray<z.ZodString>>;
150
+ exceptCountries: z.ZodOptional<z.ZodArray<z.ZodString>>;
151
+ ipVersion: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<4>, z.ZodLiteral<6>]>>;
152
+ }, z.core.$strip>;
153
+ readonly reportIp: z.ZodObject<{
154
+ ip: z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6]>;
155
+ categories: z.ZodArray<z.ZodNumber>;
156
+ comment: z.ZodOptional<z.ZodString>;
157
+ timestamp: z.ZodOptional<z.ZodISODateTime>;
158
+ }, z.core.$strip>;
159
+ readonly checkBlock: z.ZodObject<{
160
+ network: z.ZodUnion<readonly [z.ZodCIDRv4, z.ZodCIDRv6]>;
161
+ maxAgeInDays: z.ZodOptional<z.ZodNumber>;
162
+ }, z.core.$strip>;
163
+ readonly clearAddress: z.ZodObject<{
164
+ ipAddress: z.ZodUnion<readonly [z.ZodIPv4, z.ZodIPv6]>;
165
+ }, z.core.$strip>;
166
+ };
167
+ export declare const AbuseIPDBEndpointOutputSchemas: {
168
+ readonly checkIp: z.ZodObject<{
169
+ ipAddress: z.ZodString;
170
+ isPublic: z.ZodBoolean;
171
+ ipVersion: z.ZodNumber;
172
+ isWhitelisted: z.ZodNullable<z.ZodBoolean>;
173
+ abuseConfidenceScore: z.ZodNumber;
174
+ countryCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
175
+ countryName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
176
+ usageType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
177
+ isp: z.ZodOptional<z.ZodNullable<z.ZodString>>;
178
+ domain: z.ZodOptional<z.ZodNullable<z.ZodString>>;
179
+ hostnames: z.ZodArray<z.ZodString>;
180
+ isTor: z.ZodBoolean;
181
+ totalReports: z.ZodNumber;
182
+ numDistinctUsers: z.ZodNumber;
183
+ lastReportedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
184
+ reports: z.ZodOptional<z.ZodArray<z.ZodObject<{
185
+ reportedAt: z.ZodString;
186
+ comment: z.ZodOptional<z.ZodNullable<z.ZodString>>;
187
+ categories: z.ZodArray<z.ZodNumber>;
188
+ reporterId: z.ZodNumber;
189
+ reporterCountryCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
190
+ reporterCountryName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
191
+ }, z.core.$loose>>>;
192
+ }, z.core.$loose>;
193
+ readonly getReports: z.ZodObject<{
194
+ total: z.ZodNumber;
195
+ page: z.ZodNumber;
196
+ count: z.ZodNumber;
197
+ perPage: z.ZodNumber;
198
+ lastPage: z.ZodNumber;
199
+ nextPageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
200
+ previousPageUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
201
+ results: z.ZodArray<z.ZodObject<{
202
+ reportedAt: z.ZodString;
203
+ comment: z.ZodOptional<z.ZodNullable<z.ZodString>>;
204
+ categories: z.ZodArray<z.ZodNumber>;
205
+ reporterId: z.ZodNumber;
206
+ reporterCountryCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
207
+ reporterCountryName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
208
+ }, z.core.$loose>>;
209
+ }, z.core.$loose>;
210
+ readonly getBlacklist: z.ZodObject<{
211
+ generatedAt: z.ZodString;
212
+ entries: z.ZodArray<z.ZodObject<{
213
+ ipAddress: z.ZodString;
214
+ abuseConfidenceScore: z.ZodNumber;
215
+ lastReportedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
216
+ countryCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
217
+ }, z.core.$loose>>;
218
+ }, z.core.$strip>;
219
+ readonly reportIp: z.ZodObject<{
220
+ ipAddress: z.ZodString;
221
+ abuseConfidenceScore: z.ZodNumber;
222
+ }, z.core.$loose>;
223
+ readonly checkBlock: z.ZodObject<{
224
+ networkAddress: z.ZodString;
225
+ netmask: z.ZodString;
226
+ minAddress: z.ZodString;
227
+ maxAddress: z.ZodString;
228
+ numPossibleHosts: z.ZodNumber;
229
+ addressSpaceDesc: z.ZodOptional<z.ZodNullable<z.ZodString>>;
230
+ reportedAddress: z.ZodArray<z.ZodObject<{
231
+ ipAddress: z.ZodString;
232
+ numReports: z.ZodNumber;
233
+ mostRecentReport: z.ZodOptional<z.ZodNullable<z.ZodString>>;
234
+ abuseConfidenceScore: z.ZodNumber;
235
+ countryCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
236
+ }, z.core.$loose>>;
237
+ }, z.core.$loose>;
238
+ readonly clearAddress: z.ZodObject<{
239
+ numReportsDeleted: z.ZodNumber;
240
+ }, z.core.$loose>;
241
+ };
242
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../endpoints/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,kBAAkB;;;;iBAa7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAa9D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;iBAmBzB,CAAC;AAEV,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAQpE,eAAO,MAAM,qBAAqB;;;;;iBA4BhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAIpE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;iBAW5B,CAAC;AAEV,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAS1E,eAAO,MAAM,uBAAuB;;;;;;iBAgClC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAWxE,eAAO,MAAM,0BAA0B;;;;;;;;iBAGrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAQ9E,eAAO,MAAM,mBAAmB;;;;;iBAkB9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,sBAAsB;;;iBAK1B,CAAC;AAEV,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAQtE,eAAO,MAAM,qBAAqB;;;iBAahC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAYpE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;iBAU5B,CAAC;AAEV,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAQ1E,eAAO,MAAM,uBAAuB;;iBAKlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,0BAA0B;;iBAI9B,CAAC;AAEV,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAM9E,MAAM,MAAM,uBAAuB,GAAG;IACrC,OAAO,EAAE,YAAY,CAAC;IACtB,UAAU,EAAE,eAAe,CAAC;IAC5B,YAAY,EAAE,iBAAiB,CAAC;IAChC,QAAQ,EAAE,aAAa,CAAC;IACxB,UAAU,EAAE,eAAe,CAAC;IAC5B,YAAY,EAAE,iBAAiB,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACtC,OAAO,EAAE,eAAe,CAAC;IACzB,UAAU,EAAE,kBAAkB,CAAC;IAC/B,YAAY,EAAE,oBAAoB,CAAC;IACnC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,YAAY,EAAE,oBAAoB,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOhC,CAAC;AAEX,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOjC,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Error handlers for the AbuseIPDB plugin.
3
+ *
4
+ * AbuseIPDB returns reliable HTTP status codes:
5
+ * - 401: invalid, missing, or unauthorized API key
6
+ * - 402: plan tier limit exceeded (e.g. check-block network too large)
7
+ * - 422: malformed/out-of-range parameter (e.g. maxAgeInDays > 365)
8
+ * - 429: daily per-endpoint rate limit exceeded (Retry-After header)
9
+ * - 5xx: internal server error
10
+ */
11
+ export declare const errorHandlers: {
12
+ RATE_LIMIT_ERROR: {
13
+ match: (error: Error) => boolean;
14
+ handler: (error: Error) => Promise<{
15
+ maxRetries: number;
16
+ headersRetryAfterMs: number | undefined;
17
+ }>;
18
+ };
19
+ AUTH_ERROR: {
20
+ match: (error: Error) => boolean;
21
+ handler: () => Promise<{
22
+ maxRetries: number;
23
+ }>;
24
+ };
25
+ PAYMENT_REQUIRED_ERROR: {
26
+ match: (error: Error) => boolean;
27
+ handler: () => Promise<{
28
+ maxRetries: number;
29
+ }>;
30
+ };
31
+ VALIDATION_ERROR: {
32
+ match: (error: Error) => boolean;
33
+ handler: () => Promise<{
34
+ maxRetries: number;
35
+ }>;
36
+ };
37
+ SERVER_ERROR: {
38
+ match: (error: Error) => boolean;
39
+ handler: () => Promise<{
40
+ maxRetries: number;
41
+ }>;
42
+ };
43
+ DEFAULT: {
44
+ match: () => true;
45
+ handler: (error: Error) => Promise<{
46
+ maxRetries: number;
47
+ }>;
48
+ };
49
+ };
50
+ //# sourceMappingURL=error-handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handlers.d.ts","sourceRoot":"","sources":["../error-handlers.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa;;uBAET,KAAK;yBAKG,KAAK;;;;;;uBAQb,KAAK;;;;;;uBAkBL,KAAK;;;;;;uBAeL,KAAK;;;;;;uBAcL,KAAK;;;;;;;yBAYG,KAAK;;;;CAKC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=error-handlers.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handlers.test.d.ts","sourceRoot":"","sources":["../error-handlers.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,186 @@
1
+ import type { BindEndpoints, CorsairEndpoint, CorsairErrorHandler, CorsairPlugin, CorsairPluginContext, KeyBuilderContext, PickAuth, PluginPermissionsConfig } from 'corsair/core';
2
+ import type { AbuseIPDBEndpointInputs, AbuseIPDBEndpointOutputs } from './endpoints/types';
3
+ import { AbuseIPDBSchema } from './schema';
4
+ export type AbuseIPDBPluginOptions = {
5
+ /** Authentication method. Only api_key is supported. */
6
+ authType?: PickAuth<'api_key'>;
7
+ /**
8
+ * AbuseIPDB account API key (from the dashboard). Sent in the `Key`
9
+ * header on every request.
10
+ */
11
+ key?: string;
12
+ /** Optional: lifecycle hooks for endpoints */
13
+ hooks?: InternalAbuseIPDBPlugin['hooks'];
14
+ /** Optional: custom error handlers (merged with defaults) */
15
+ errorHandlers?: CorsairErrorHandler;
16
+ /**
17
+ * Permission configuration for the AbuseIPDB plugin. The read-only
18
+ * endpoints (check, reports, blacklist, check-block) default to 'open';
19
+ * the write endpoints (report, clear-address) default to 'allow'.
20
+ */
21
+ permissions?: PluginPermissionsConfig<typeof abuseIPDBEndpointsNested>;
22
+ };
23
+ export type AbuseIPDBContext = CorsairPluginContext<typeof AbuseIPDBSchema, AbuseIPDBPluginOptions, undefined, typeof abuseIPDBAuthConfig>;
24
+ export type AbuseIPDBKeyBuilderContext = KeyBuilderContext<AbuseIPDBPluginOptions, typeof abuseIPDBAuthConfig>;
25
+ export type AbuseIPDBBoundEndpoints = BindEndpoints<typeof abuseIPDBEndpointsNested>;
26
+ type AbuseIPDBEndpoint<K extends keyof AbuseIPDBEndpointOutputs> = CorsairEndpoint<AbuseIPDBContext, AbuseIPDBEndpointInputs[K], AbuseIPDBEndpointOutputs[K]>;
27
+ export type AbuseIPDBEndpoints = {
28
+ checkIp: AbuseIPDBEndpoint<'checkIp'>;
29
+ getReports: AbuseIPDBEndpoint<'getReports'>;
30
+ getBlacklist: AbuseIPDBEndpoint<'getBlacklist'>;
31
+ reportIp: AbuseIPDBEndpoint<'reportIp'>;
32
+ checkBlock: AbuseIPDBEndpoint<'checkBlock'>;
33
+ clearAddress: AbuseIPDBEndpoint<'clearAddress'>;
34
+ };
35
+ declare const abuseIPDBEndpointsNested: {
36
+ readonly check: {
37
+ readonly ip: AbuseIPDBEndpoint<"checkIp">;
38
+ };
39
+ readonly reports: {
40
+ readonly list: AbuseIPDBEndpoint<"getReports">;
41
+ };
42
+ readonly blacklist: {
43
+ readonly get: AbuseIPDBEndpoint<"getBlacklist">;
44
+ };
45
+ readonly report: {
46
+ readonly ip: AbuseIPDBEndpoint<"reportIp">;
47
+ };
48
+ readonly block: {
49
+ readonly check: AbuseIPDBEndpoint<"checkBlock">;
50
+ };
51
+ readonly address: {
52
+ readonly clear: AbuseIPDBEndpoint<"clearAddress">;
53
+ };
54
+ };
55
+ declare const abuseIPDBWebhooksNested: {};
56
+ export declare const abuseIPDBEndpointSchemas: {
57
+ readonly 'check.ip': {
58
+ readonly input: import("zod").ZodObject<{
59
+ ipAddress: import("zod").ZodUnion<readonly [import("zod").ZodIPv4, import("zod").ZodIPv6]>;
60
+ maxAgeInDays: import("zod").ZodOptional<import("zod").ZodNumber>;
61
+ verbose: import("zod").ZodOptional<import("zod").ZodBoolean>;
62
+ }, import("zod/v4/core").$strip>;
63
+ readonly output: import("zod").ZodObject<{
64
+ ipAddress: import("zod").ZodString;
65
+ isPublic: import("zod").ZodBoolean;
66
+ ipVersion: import("zod").ZodNumber;
67
+ isWhitelisted: import("zod").ZodNullable<import("zod").ZodBoolean>;
68
+ abuseConfidenceScore: import("zod").ZodNumber;
69
+ countryCode: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
70
+ countryName: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
71
+ usageType: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
72
+ isp: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
73
+ domain: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
74
+ hostnames: import("zod").ZodArray<import("zod").ZodString>;
75
+ isTor: import("zod").ZodBoolean;
76
+ totalReports: import("zod").ZodNumber;
77
+ numDistinctUsers: import("zod").ZodNumber;
78
+ lastReportedAt: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
79
+ reports: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
80
+ reportedAt: import("zod").ZodString;
81
+ comment: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
82
+ categories: import("zod").ZodArray<import("zod").ZodNumber>;
83
+ reporterId: import("zod").ZodNumber;
84
+ reporterCountryCode: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
85
+ reporterCountryName: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
86
+ }, import("zod/v4/core").$loose>>>;
87
+ }, import("zod/v4/core").$loose>;
88
+ };
89
+ readonly 'reports.list': {
90
+ readonly input: import("zod").ZodObject<{
91
+ ipAddress: import("zod").ZodUnion<readonly [import("zod").ZodIPv4, import("zod").ZodIPv6]>;
92
+ maxAgeInDays: import("zod").ZodOptional<import("zod").ZodNumber>;
93
+ page: import("zod").ZodOptional<import("zod").ZodNumber>;
94
+ perPage: import("zod").ZodOptional<import("zod").ZodNumber>;
95
+ }, import("zod/v4/core").$strip>;
96
+ readonly output: import("zod").ZodObject<{
97
+ total: import("zod").ZodNumber;
98
+ page: import("zod").ZodNumber;
99
+ count: import("zod").ZodNumber;
100
+ perPage: import("zod").ZodNumber;
101
+ lastPage: import("zod").ZodNumber;
102
+ nextPageUrl: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
103
+ previousPageUrl: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
104
+ results: import("zod").ZodArray<import("zod").ZodObject<{
105
+ reportedAt: import("zod").ZodString;
106
+ comment: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
107
+ categories: import("zod").ZodArray<import("zod").ZodNumber>;
108
+ reporterId: import("zod").ZodNumber;
109
+ reporterCountryCode: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
110
+ reporterCountryName: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
111
+ }, import("zod/v4/core").$loose>>;
112
+ }, import("zod/v4/core").$loose>;
113
+ };
114
+ readonly 'blacklist.get': {
115
+ readonly input: import("zod").ZodObject<{
116
+ confidenceMinimum: import("zod").ZodOptional<import("zod").ZodNumber>;
117
+ limit: import("zod").ZodOptional<import("zod").ZodNumber>;
118
+ onlyCountries: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
119
+ exceptCountries: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
120
+ ipVersion: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodLiteral<4>, import("zod").ZodLiteral<6>]>>;
121
+ }, import("zod/v4/core").$strip>;
122
+ readonly output: import("zod").ZodObject<{
123
+ generatedAt: import("zod").ZodString;
124
+ entries: import("zod").ZodArray<import("zod").ZodObject<{
125
+ ipAddress: import("zod").ZodString;
126
+ abuseConfidenceScore: import("zod").ZodNumber;
127
+ lastReportedAt: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
128
+ countryCode: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
129
+ }, import("zod/v4/core").$loose>>;
130
+ }, import("zod/v4/core").$strip>;
131
+ };
132
+ readonly 'report.ip': {
133
+ readonly input: import("zod").ZodObject<{
134
+ ip: import("zod").ZodUnion<readonly [import("zod").ZodIPv4, import("zod").ZodIPv6]>;
135
+ categories: import("zod").ZodArray<import("zod").ZodNumber>;
136
+ comment: import("zod").ZodOptional<import("zod").ZodString>;
137
+ timestamp: import("zod").ZodOptional<import("zod").ZodISODateTime>;
138
+ }, import("zod/v4/core").$strip>;
139
+ readonly output: import("zod").ZodObject<{
140
+ ipAddress: import("zod").ZodString;
141
+ abuseConfidenceScore: import("zod").ZodNumber;
142
+ }, import("zod/v4/core").$loose>;
143
+ };
144
+ readonly 'block.check': {
145
+ readonly input: import("zod").ZodObject<{
146
+ network: import("zod").ZodUnion<readonly [import("zod").ZodCIDRv4, import("zod").ZodCIDRv6]>;
147
+ maxAgeInDays: import("zod").ZodOptional<import("zod").ZodNumber>;
148
+ }, import("zod/v4/core").$strip>;
149
+ readonly output: import("zod").ZodObject<{
150
+ networkAddress: import("zod").ZodString;
151
+ netmask: import("zod").ZodString;
152
+ minAddress: import("zod").ZodString;
153
+ maxAddress: import("zod").ZodString;
154
+ numPossibleHosts: import("zod").ZodNumber;
155
+ addressSpaceDesc: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
156
+ reportedAddress: import("zod").ZodArray<import("zod").ZodObject<{
157
+ ipAddress: import("zod").ZodString;
158
+ numReports: import("zod").ZodNumber;
159
+ mostRecentReport: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
160
+ abuseConfidenceScore: import("zod").ZodNumber;
161
+ countryCode: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
162
+ }, import("zod/v4/core").$loose>>;
163
+ }, import("zod/v4/core").$loose>;
164
+ };
165
+ readonly 'address.clear': {
166
+ readonly input: import("zod").ZodObject<{
167
+ ipAddress: import("zod").ZodUnion<readonly [import("zod").ZodIPv4, import("zod").ZodIPv6]>;
168
+ }, import("zod/v4/core").$strip>;
169
+ readonly output: import("zod").ZodObject<{
170
+ numReportsDeleted: import("zod").ZodNumber;
171
+ }, import("zod/v4/core").$loose>;
172
+ };
173
+ };
174
+ declare const defaultAuthType: "api_key";
175
+ export declare const abuseIPDBAuthConfig: {
176
+ readonly api_key: {
177
+ readonly account: readonly [];
178
+ };
179
+ };
180
+ export type BaseAbuseIPDBPlugin<T extends AbuseIPDBPluginOptions> = CorsairPlugin<'abuseipdb', typeof AbuseIPDBSchema, typeof abuseIPDBEndpointsNested, typeof abuseIPDBWebhooksNested, T, typeof defaultAuthType, typeof abuseIPDBAuthConfig>;
181
+ export type InternalAbuseIPDBPlugin = BaseAbuseIPDBPlugin<AbuseIPDBPluginOptions>;
182
+ export type ExternalAbuseIPDBPlugin<T extends AbuseIPDBPluginOptions> = BaseAbuseIPDBPlugin<T>;
183
+ export declare function abuseipdb<const T extends AbuseIPDBPluginOptions>(incomingOptions?: AbuseIPDBPluginOptions & T): ExternalAbuseIPDBPlugin<T>;
184
+ export type { AbuseIPDBEndpointInputs, AbuseIPDBEndpointOutputs, CheckBlockInput, CheckBlockResponse, CheckIpInput, CheckIpResponse, ClearAddressInput, ClearAddressResponse, GetBlacklistInput, GetBlacklistResponse, GetReportsInput, GetReportsResponse, ReportIpInput, ReportIpResponse, } from './endpoints/types';
185
+ export { CheckBlockInputSchema, CheckBlockResponseSchema, CheckIpInputSchema, CheckIpResponseSchema, ClearAddressInputSchema, ClearAddressResponseSchema, GetBlacklistInputSchema, GetBlacklistResponseSchema, GetReportsInputSchema, GetReportsResponseSchema, ReportIpInputSchema, ReportIpResponseSchema, } from './endpoints/types';
186
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,QAAQ,EAER,uBAAuB,EAGvB,MAAM,cAAc,CAAC;AAWtB,OAAO,KAAK,EACX,uBAAuB,EACvB,wBAAwB,EACxB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAM3C,MAAM,MAAM,sBAAsB,GAAG;IACpC,wDAAwD;IACxD,QAAQ,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC/B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,KAAK,CAAC,EAAE,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACzC,6DAA6D;IAC7D,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC;;;;OAIG;IACH,WAAW,CAAC,EAAE,uBAAuB,CAAC,OAAO,wBAAwB,CAAC,CAAC;CACvE,CAAC;AAMF,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAClD,OAAO,eAAe,EACtB,sBAAsB,EACtB,SAAS,EACT,OAAO,mBAAmB,CAC1B,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,iBAAiB,CACzD,sBAAsB,EACtB,OAAO,mBAAmB,CAC1B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,aAAa,CAClD,OAAO,wBAAwB,CAC/B,CAAC;AAEF,KAAK,iBAAiB,CAAC,CAAC,SAAS,MAAM,wBAAwB,IAC9D,eAAe,CACd,gBAAgB,EAChB,uBAAuB,CAAC,CAAC,CAAC,EAC1B,wBAAwB,CAAC,CAAC,CAAC,CAC3B,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG;IAChC,OAAO,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;IACtC,UAAU,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAC5C,YAAY,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAChD,QAAQ,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACxC,UAAU,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAC5C,YAAY,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;CAChD,CAAC;AAMF,QAAA,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;CAmBpB,CAAC;AAGX,QAAA,MAAM,uBAAuB,IAAc,CAAC;AAM5C,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BpC,CAAC;AA6CF,QAAA,MAAM,eAAe,WAAyC,CAAC;AAE/D,eAAO,MAAM,mBAAmB;;;;CAIK,CAAC;AAMtC,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,sBAAsB,IAC/D,aAAa,CACZ,WAAW,EACX,OAAO,eAAe,EACtB,OAAO,wBAAwB,EAC/B,OAAO,uBAAuB,EAC9B,CAAC,EACD,OAAO,eAAe,EACtB,OAAO,mBAAmB,CAC1B,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAClC,mBAAmB,CAAC,sBAAsB,CAAC,CAAC;AAE7C,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,sBAAsB,IACnE,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAMxB,wBAAgB,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,sBAAsB,EAC/D,eAAe,GAAE,sBAAsB,GAItC,CAAoC,GACnC,uBAAuB,CAAC,CAAC,CAAC,CAsC5B;AAMD,YAAY,EACX,uBAAuB,EACvB,wBAAwB,EACxB,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,gBAAgB,GAChB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACN,qBAAqB,EACrB,wBAAwB,EACxB,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{AuthMissingError as Be}from"corsair/core";import{ApiError as E,request as ee}from"corsair/http";var l=class extends Error{constructor(n,s,o){super(n,o);this.code=s;this.name="AbuseIPDBAPIError",o?.cause instanceof E&&(this.status=o.cause.status,this.statusText=o.cause.statusText,this.body=o.cause.body,this.retryAfter=o.cause.retryAfter,this.rateLimitReset=o.cause.rateLimitReset,this.rateLimitRemaining=o.cause.rateLimitRemaining,this.rateLimitLimit=o.cause.rateLimitLimit)}status;statusText;body;retryAfter;rateLimitReset;rateLimitRemaining;rateLimitLimit},te=/no dek found/i;async function C(t){try{return await t()??void 0}catch(r){if(r instanceof Error&&te.test(r.message))return;throw r}}var re="https://api.abuseipdb.com/api/v2",B=6,se={enabled:!0,maxRetries:0,initialRetryDelay:0,backoffMultiplier:1,headerNames:{retryAfter:"retry-after"}},oe=3e4;function ne(t){return!(t instanceof l)||t.status===void 0?!1:t.status>=500}function ie(t,r){let n=typeof t.retryAfter=="number"&&t.retryAfter>=0?t.retryAfter:2**r*1e3;return Math.min(n,oe)}async function p(t,r,n={}){let{method:s="GET",query:o,formBody:g,retries:X=s==="GET"}=n,Z={BASE:re,VERSION:"2.0.0",WITH_CREDENTIALS:!1,CREDENTIALS:"omit",TOKEN:void 0,HEADERS:{Key:r}},Q={method:s,url:t,query:o,body:g?new URLSearchParams(Object.entries(g).filter(([,a])=>a!==void 0).map(([a,d])=>[a,String(d)])).toString():void 0,mediaType:g?"application/x-www-form-urlencoded":void 0},R=async()=>{try{return await ee(Z,Q,{rateLimitConfig:se})}catch(a){throw a instanceof E?new l(a.message,a.status,{cause:a}):a instanceof Error?new l(a.message,void 0,{cause:a}):new l("Unknown error")}};if(!X)return await R();let P;for(let a=0;a<B;a++)try{return await R()}catch(d){if(P=d,!ne(d)||a===B-1)throw d;await new Promise(J=>setTimeout(J,ie(d,a)))}throw P}import{AuthMissingError as ue,logEventFromContext as de}from"corsair/core";import{z as le}from"zod";import{z as e}from"zod";var b=e.union([e.ipv4(),e.ipv6()]),D=e.object({ipAddress:b.describe("IPv4 or IPv6 address to check"),maxAgeInDays:e.number().int().min(1).max(365).optional().describe("Only consider reports from the last N days (1\u2013365)"),verbose:e.boolean().optional().describe("Include the full reports array")}),x=e.object({reportedAt:e.string(),comment:e.string().nullable().optional(),categories:e.array(e.number()),reporterId:e.number(),reporterCountryCode:e.string().nullable().optional(),reporterCountryName:e.string().nullable().optional()}).loose(),I=e.object({ipAddress:e.string(),isPublic:e.boolean(),ipVersion:e.number(),isWhitelisted:e.boolean().nullable(),abuseConfidenceScore:e.number(),countryCode:e.string().nullable().optional(),countryName:e.string().nullable().optional(),usageType:e.string().nullable().optional(),isp:e.string().nullable().optional(),domain:e.string().nullable().optional(),hostnames:e.array(e.string()),isTor:e.boolean(),totalReports:e.number(),numDistinctUsers:e.number(),lastReportedAt:e.string().nullable().optional(),reports:e.array(x).optional()}).loose(),S=e.object({ipAddress:b.describe("IPv4 or IPv6 address to fetch reports for"),maxAgeInDays:e.number().int().min(1).max(365).optional().describe("Only consider reports from the last N days (1\u2013365)"),page:e.number().int().min(1).optional().describe("Page number (starts at 1)"),perPage:e.number().int().min(1).max(100).optional().describe("Reports per page (1\u2013100)")}),ae=x,h=e.object({total:e.number(),page:e.number(),count:e.number(),perPage:e.number(),lastPage:e.number(),nextPageUrl:e.string().nullable().optional(),previousPageUrl:e.string().nullable().optional(),results:e.array(ae)}).loose(),w=e.object({confidenceMinimum:e.number().int().min(25).max(100).optional().describe("Minimum abuse confidence score (25\u2013100)"),limit:e.number().int().min(1).max(5e5).optional().describe("Maximum number of entries to return"),onlyCountries:e.array(e.string().regex(/^[A-Za-z]{2}$/)).optional().describe("Only include IPs from these ISO 3166 alpha-2 country codes"),exceptCountries:e.array(e.string().regex(/^[A-Za-z]{2}$/)).optional().describe("Exclude IPs from these ISO 3166 alpha-2 country codes"),ipVersion:e.union([e.literal(4),e.literal(6)]).optional().describe("Restrict to a single IP version (4 or 6)")}),pe=e.object({ipAddress:e.string(),abuseConfidenceScore:e.number(),lastReportedAt:e.string().nullable().optional(),countryCode:e.string().nullable().optional()}).loose(),y=e.object({generatedAt:e.string(),entries:e.array(pe)}),T=e.object({ip:b.describe("IPv4 or IPv6 address being reported"),categories:e.array(e.number().int().min(1).max(30)).min(1).describe("Abuse category IDs (integers 1\u201330)"),comment:e.string().optional().describe("Descriptive text of the attack; avoid any PII"),timestamp:e.iso.datetime({offset:!0}).optional().describe("ISO 8601 datetime of the attack, defaults to now")}),f=e.object({ipAddress:e.string(),abuseConfidenceScore:e.number()}).loose(),v=e.object({network:e.union([e.cidrv4(),e.cidrv6()]).describe('CIDR notation network block, e.g. "127.0.0.1/24"'),maxAgeInDays:e.number().int().min(1).max(365).optional().describe("Only consider reports from the last N days (1\u2013365)")}),ce=e.object({ipAddress:e.string(),numReports:e.number(),mostRecentReport:e.string().nullable().optional(),abuseConfidenceScore:e.number(),countryCode:e.string().nullable().optional()}).loose(),k=e.object({networkAddress:e.string(),netmask:e.string(),minAddress:e.string(),maxAddress:e.string(),numPossibleHosts:e.number(),addressSpaceDesc:e.string().nullable().optional(),reportedAddress:e.array(ce)}).loose(),O=e.object({ipAddress:b.describe("IPv4 or IPv6 address to clear reports for")}),A=e.object({numReportsDeleted:e.number()}).loose(),c={checkIp:D,getReports:S,getBlacklist:w,reportIp:T,checkBlock:v,clearAddress:O},u={checkIp:I,getReports:h,getBlacklist:y,reportIp:f,checkBlock:k,clearAddress:A};var L=async(t,r)=>{if(!t.key)throw new ue("abuseipdb","api_key");let n=await p("blacklist",t.key,{query:{confidenceMinimum:r.confidenceMinimum,limit:r.limit,onlyCountries:r.onlyCountries?.join(","),exceptCountries:r.exceptCountries?.join(","),ipVersion:r.ipVersion}}),s=le.string().parse(n.meta?.generatedAt),o=y.parse({generatedAt:s,entries:n.data});return await de(t,"abuseipdb.blacklist.get",{confidenceMinimum:r.confidenceMinimum??100,limit:r.limit},"completed"),o};import{AuthMissingError as me,logEventFromContext as be}from"corsair/core";var G=async(t,r)=>{if(!t.key)throw new me("abuseipdb","api_key");let n=await p("check",t.key,{query:{ipAddress:r.ipAddress,maxAgeInDays:r.maxAgeInDays,verbose:r.verbose?"":void 0}}),s=I.parse(n.data);if(t.db?.ipChecks)try{await t.db.ipChecks.upsertByEntityId(s.ipAddress,{ipAddress:s.ipAddress,abuseConfidenceScore:s.abuseConfidenceScore,isPublic:s.isPublic,ipVersion:s.ipVersion,countryCode:s.countryCode??null,countryName:s.countryName??null,usageType:s.usageType??null,isp:s.isp??null,domain:s.domain??null,isTor:s.isTor,totalReports:s.totalReports,numDistinctUsers:s.numDistinctUsers,checkedAt:new Date})}catch(o){console.warn("Failed to save IP check result to database:",o)}return await be(t,"abuseipdb.check.ip",{ipAddress:r.ipAddress},"completed"),s};import{AuthMissingError as Ie,logEventFromContext as he}from"corsair/core";var _=async(t,r)=>{if(!t.key)throw new Ie("abuseipdb","api_key");let n=await p("check-block",t.key,{query:{network:r.network,maxAgeInDays:r.maxAgeInDays}}),s=k.parse(n.data);return await he(t,"abuseipdb.block.check",{network:r.network},"completed"),s};import{AuthMissingError as ye,logEventFromContext as fe}from"corsair/core";var M=async(t,r)=>{if(!t.key)throw new ye("abuseipdb","api_key");let n=await p("clear-address",t.key,{method:"DELETE",query:{ipAddress:r.ipAddress}}),s=A.parse(n.data);if(t.db?.reports)try{await t.db.reports.deleteByEntityId(r.ipAddress)}catch(o){console.warn("Failed to remove report from database:",o)}if(t.db?.ipChecks)try{await t.db.ipChecks.deleteByEntityId(r.ipAddress)}catch(o){console.warn("Failed to remove IP check from database:",o)}return await fe(t,"abuseipdb.address.clear",{ipAddress:r.ipAddress},"completed"),s};import{AuthMissingError as ke,logEventFromContext as Ae}from"corsair/core";var q=async(t,r)=>{if(!t.key)throw new ke("abuseipdb","api_key");let n=await p("report",t.key,{method:"POST",formBody:{ip:r.ip,categories:r.categories.join(","),comment:r.comment,timestamp:r.timestamp}}),s=f.parse(n.data);if(t.db?.reports)try{await t.db.reports.upsertByEntityId(s.ipAddress,{ipAddress:s.ipAddress,abuseConfidenceScore:s.abuseConfidenceScore,reportedAt:new Date})}catch(o){console.warn("Failed to save report to database:",o)}return await Ae(t,"abuseipdb.report.ip",{ip:r.ip,categories:r.categories.join(",")},"completed"),s};import{AuthMissingError as ge,logEventFromContext as Re}from"corsair/core";var N=async(t,r)=>{if(!t.key)throw new ge("abuseipdb","api_key");let n=await p("reports",t.key,{query:{ipAddress:r.ipAddress,maxAgeInDays:r.maxAgeInDays,page:r.page,perPage:r.perPage}}),s=h.parse(n.data);return await Re(t,"abuseipdb.reports.list",{ipAddress:r.ipAddress,page:r.page??1},"completed"),s};var j={check:G},z={list:N},U={get:L},H={report:q},K={check:_},F={clear:M};function m(t){return t.status}function Pe(t){return t.retryAfter}var V={RATE_LIMIT_ERROR:{match:t=>{if(m(t)===429)return!0;let r=t.message.toLowerCase();return r.includes("429")||r.includes("rate limit")},handler:async t=>({maxRetries:0,headersRetryAfterMs:Pe(t)})},AUTH_ERROR:{match:t=>{if(m(t)===401)return!0;let r=t.message.toLowerCase();return r.includes("unauthorized")||r.includes("invalid api key")||r.includes("401")},handler:async()=>(console.warn("[ABUSEIPDB] Authentication failed \u2014 check that the API key is valid and active on your AbuseIPDB account."),{maxRetries:0})},PAYMENT_REQUIRED_ERROR:{match:t=>{if(m(t)===402)return!0;let r=t.message.toLowerCase();return r.includes("402")||r.includes("payment required")},handler:async()=>(console.warn("[ABUSEIPDB] Request rejected \u2014 the parameter exceeds your current plan tier (e.g. check-block network too large). Upgrade the plan or narrow the request."),{maxRetries:0})},VALIDATION_ERROR:{match:t=>{if(m(t)===422)return!0;let r=t.message.toLowerCase();return r.includes("422")||r.includes("unprocessable")},handler:async()=>(console.warn("[ABUSEIPDB] Request rejected \u2014 a parameter is missing, malformed, or out of range (see the error detail for the offending field)."),{maxRetries:0})},SERVER_ERROR:{match:t=>{let r=m(t);if(r!==void 0&&r>=500)return!0;let n=t.message.toLowerCase();return n.includes("500")||n.includes("internal server error")},handler:async()=>({maxRetries:0})},DEFAULT:{match:()=>!0,handler:async t=>(console.error(`[ABUSEIPDB] Unhandled error: ${t.message}`),{maxRetries:0})}};import{z as i}from"zod";var W=i.object({ipAddress:i.string(),abuseConfidenceScore:i.number(),isPublic:i.boolean(),ipVersion:i.number(),countryCode:i.string().nullable().optional(),countryName:i.string().nullable().optional(),usageType:i.string().nullable().optional(),isp:i.string().nullable().optional(),domain:i.string().nullable().optional(),isTor:i.boolean(),totalReports:i.number(),numDistinctUsers:i.number(),checkedAt:i.coerce.date().nullable().optional()}),Y=i.object({ipAddress:i.string(),abuseConfidenceScore:i.number(),reportedAt:i.coerce.date().nullable().optional()});var $={version:"1.0.0",entities:{ipChecks:W,reports:Y}};var Ee={check:{ip:j.check},reports:{list:z.list},blacklist:{get:U.get},report:{ip:H.report},block:{check:K.check},address:{clear:F.clear}},Ce={},De={"check.ip":{input:c.checkIp,output:u.checkIp},"reports.list":{input:c.getReports,output:u.getReports},"blacklist.get":{input:c.getBlacklist,output:u.getBlacklist},"report.ip":{input:c.reportIp,output:u.reportIp},"block.check":{input:c.checkBlock,output:u.checkBlock},"address.clear":{input:c.clearAddress,output:u.clearAddress}},xe={"check.ip":{riskLevel:"read",description:"Look up an IP address and get its abuse confidence score, country, ISP, usage type, and optionally recent reports"},"reports.list":{riskLevel:"read",description:"Get a paginated list of abuse reports filed against a single IP address"},"blacklist.get":{riskLevel:"read",description:"Download the blacklist of most-reported IPs, optionally filtered by confidence minimum, country, and IP version"},"report.ip":{riskLevel:"write",description:"Submit an abuse report for an IP address with one or more abuse category IDs"},"block.check":{riskLevel:"read",description:"Check a CIDR network block and list the reported addresses within it"},"address.clear":{riskLevel:"destructive",description:"Remove all reports for an IP address from your account and return the number deleted"}},Se="api_key",we={api_key:{account:[]}};function Et(t={}){let r={...t,authType:t.authType??Se};return{id:"abuseipdb",authConfig:we,schema:$,options:r,hooks:r.hooks,webhookHooks:void 0,endpoints:Ee,webhooks:Ce,endpointMeta:xe,endpointSchemas:De,pluginWebhookMatcher:void 0,errorHandlers:{...V,...r.errorHandlers},keyBuilder:async(n,s)=>{if(s==="endpoint"&&r.key)return r.key;if(s==="endpoint"){let o=await C(()=>n.keys?.get_api_key());if(!o)throw new Be("abuseipdb","api_key");return o}return""}}}export{v as CheckBlockInputSchema,k as CheckBlockResponseSchema,D as CheckIpInputSchema,I as CheckIpResponseSchema,O as ClearAddressInputSchema,A as ClearAddressResponseSchema,w as GetBlacklistInputSchema,y as GetBlacklistResponseSchema,S as GetReportsInputSchema,h as GetReportsResponseSchema,T as ReportIpInputSchema,f as ReportIpResponseSchema,we as abuseIPDBAuthConfig,De as abuseIPDBEndpointSchemas,Et as abuseipdb};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=integration.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration.test.d.ts","sourceRoot":"","sources":["../integration.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=operations.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.test.d.ts","sourceRoot":"","sources":["../operations.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ export declare const AbuseIPDBIpCheck: z.ZodObject<{
3
+ ipAddress: z.ZodString;
4
+ abuseConfidenceScore: z.ZodNumber;
5
+ isPublic: z.ZodBoolean;
6
+ ipVersion: z.ZodNumber;
7
+ countryCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
+ countryName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
9
+ usageType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
10
+ isp: z.ZodOptional<z.ZodNullable<z.ZodString>>;
11
+ domain: z.ZodOptional<z.ZodNullable<z.ZodString>>;
12
+ isTor: z.ZodBoolean;
13
+ totalReports: z.ZodNumber;
14
+ numDistinctUsers: z.ZodNumber;
15
+ checkedAt: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
16
+ }, z.core.$strip>;
17
+ export declare const AbuseIPDBReport: z.ZodObject<{
18
+ ipAddress: z.ZodString;
19
+ abuseConfidenceScore: z.ZodNumber;
20
+ reportedAt: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
21
+ }, z.core.$strip>;
22
+ export type AbuseIPDBIpCheck = z.infer<typeof AbuseIPDBIpCheck>;
23
+ export type AbuseIPDBReport = z.infer<typeof AbuseIPDBReport>;
24
+ //# sourceMappingURL=database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../schema/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;iBAc3B,CAAC;AAEH,eAAO,MAAM,eAAe;;;;iBAI1B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ export declare const AbuseIPDBSchema: {
2
+ readonly version: "1.0.0";
3
+ readonly entities: {
4
+ readonly ipChecks: import("zod").ZodObject<{
5
+ ipAddress: import("zod").ZodString;
6
+ abuseConfidenceScore: import("zod").ZodNumber;
7
+ isPublic: import("zod").ZodBoolean;
8
+ ipVersion: import("zod").ZodNumber;
9
+ countryCode: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
10
+ countryName: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
11
+ usageType: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
12
+ isp: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
13
+ domain: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
14
+ isTor: import("zod").ZodBoolean;
15
+ totalReports: import("zod").ZodNumber;
16
+ numDistinctUsers: import("zod").ZodNumber;
17
+ checkedAt: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodCoercedDate<unknown>>>;
18
+ }, import("zod/v4/core").$strip>;
19
+ readonly reports: import("zod").ZodObject<{
20
+ ipAddress: import("zod").ZodString;
21
+ abuseConfidenceScore: import("zod").ZodNumber;
22
+ reportedAt: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodCoercedDate<unknown>>>;
23
+ }, import("zod/v4/core").$strip>;
24
+ };
25
+ };
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../schema/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;CAMlB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=schema.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.test.d.ts","sourceRoot":"","sources":["../schema.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("tsup").Options | import("tsup").Options[] | ((overrideOptions: import("tsup").Options) => import("tsup").Options | import("tsup").Options[] | Promise<import("tsup").Options | import("tsup").Options[]>);
2
+ export default _default;
3
+ //# sourceMappingURL=tsup.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsup.config.d.ts","sourceRoot":"","sources":["../tsup.config.ts"],"names":[],"mappings":";AAEA,wBAYG"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@corsair-dev/abuseipdb",
3
+ "version": "0.1.0",
4
+ "description": "AbuseIPDB plugin for Corsair",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "dev-source": "./index.ts",
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "peerDependencies": {
17
+ "corsair": ">=0.1.0",
18
+ "zod": "^4.1.13"
19
+ },
20
+ "devDependencies": {
21
+ "@types/jest": "^29.5.14",
22
+ "jest": "^29.7.0",
23
+ "ts-jest": "^29.4.9",
24
+ "tsup": "^8.0.1",
25
+ "typescript": "^5.9.3",
26
+ "zod": "^4.1.13",
27
+ "corsair": "0.1.120"
28
+ },
29
+ "keywords": [
30
+ "corsair",
31
+ "abuseipdb",
32
+ "plugin"
33
+ ],
34
+ "author": "",
35
+ "license": "Apache-2.0",
36
+ "files": [
37
+ "dist"
38
+ ],
39
+ "scripts": {
40
+ "build": "rm -rf dist && tsc --build --force && tsup",
41
+ "typecheck": "tsc --noEmit",
42
+ "test": "jest"
43
+ }
44
+ }