@apiverve/spfvalidator 1.1.9 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2024 APIVerve, and Evlar LLC
3
+ Copyright (c) 2025 APIVerve, and EvlarSoft LLC
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,5 +1,4 @@
1
- SPF Validator API
2
- ============
1
+ # SPF Validator API
3
2
 
4
3
  SPF Validator checks the Sender Policy Framework (SPF) DNS record for a domain to verify if it’s valid and optionally whether a given IP address is authorized to send emails for that domain.
5
4
 
@@ -7,54 +6,62 @@ SPF Validator checks the Sender Policy Framework (SPF) DNS record for a domain t
7
6
  ![Code Climate](https://img.shields.io/badge/maintainability-B-purple)
8
7
  ![Prod Ready](https://img.shields.io/badge/production-ready-blue)
9
8
 
10
- This is a Javascript Wrapper for the [SPF Validator API](https://apiverve.com/marketplace/api/spfvalidator)
9
+ This is a Javascript Wrapper for the [SPF Validator API](https://apiverve.com/marketplace/spfvalidator)
11
10
 
12
11
  ---
13
12
 
14
13
  ## Installation
15
- npm install @apiverve/spfvalidator --save
14
+
15
+ Using npm:
16
+ ```shell
17
+ npm install @apiverve/spfvalidator
18
+ ```
19
+
20
+ Using yarn:
21
+ ```shell
22
+ yarn add @apiverve/spfvalidator
23
+ ```
16
24
 
17
25
  ---
18
26
 
19
27
  ## Configuration
20
28
 
21
- Before using the spfvalidator API client, you have to setup your account and obtain your API Key.
29
+ Before using the SPF Validator API client, you have to setup your account and obtain your API Key.
22
30
  You can get it by signing up at [https://apiverve.com](https://apiverve.com)
23
31
 
24
32
  ---
25
33
 
26
- ## Usage
34
+ ## Quick Start
27
35
 
28
- The SPF Validator API documentation is found here: [https://docs.apiverve.com/api/spfvalidator](https://docs.apiverve.com/api/spfvalidator).
36
+ [Get started with the Quick Start Guide](https://docs.apiverve.com/quickstart)
37
+
38
+ The SPF Validator API documentation is found here: [https://docs.apiverve.com/ref/spfvalidator](https://docs.apiverve.com/ref/spfvalidator).
29
39
  You can find parameters, example responses, and status codes documented here.
30
40
 
31
41
  ### Setup
32
42
 
33
- ```
34
- var spfvalidatorAPI = require('@apiverve/spfvalidator');
35
- var api = new spfvalidatorAPI({
36
- api_key: [YOUR_API_KEY],
37
- secure: true //(Optional, defaults to true)
43
+ ```javascript
44
+ const spfvalidatorAPI = require('@apiverve/spfvalidator');
45
+ const api = new spfvalidatorAPI({
46
+ api_key: '[YOUR_API_KEY]'
38
47
  });
39
48
  ```
40
49
 
41
50
  ---
42
51
 
52
+ ## Usage
53
+
54
+ ---
43
55
 
44
56
  ### Perform Request
45
- Using the API client, you can perform requests to the API.
46
57
 
47
- ###### Define Query
58
+ Using the API is simple. All you have to do is make a request. The API will return a response with the data you requested.
48
59
 
49
- ```
60
+ ```javascript
50
61
  var query = {
51
62
  domain: "myspace.com"
52
63
  };
53
- ```
54
-
55
- ###### Simple Request (using Callback)
56
64
 
57
- ```
58
65
  api.execute(query, function (error, data) {
59
66
  if (error) {
60
67
  return console.error(error);
@@ -64,299 +71,341 @@ api.execute(query, function (error, data) {
64
71
  });
65
72
  ```
66
73
 
67
- ###### Example Response
74
+ ---
75
+
76
+ ### Using Promises
77
+
78
+ You can also use promises to make requests. The API returns a promise that you can use to handle the response.
79
+
80
+ ```javascript
81
+ var query = {
82
+ domain: "myspace.com"
83
+ };
84
+
85
+ api.execute(query)
86
+ .then(data => {
87
+ console.log(data);
88
+ })
89
+ .catch(error => {
90
+ console.error(error);
91
+ });
92
+ ```
93
+
94
+ ---
95
+
96
+ ### Using Async/Await
68
97
 
98
+ You can also use async/await to make requests. The API returns a promise that you can use to handle the response.
99
+
100
+ ```javascript
101
+ async function makeRequest() {
102
+ var query = {
103
+ domain: "myspace.com"
104
+ };
105
+
106
+ try {
107
+ const data = await api.execute(query);
108
+ console.log(data);
109
+ } catch (error) {
110
+ console.error(error);
111
+ }
112
+ }
69
113
  ```
70
- {
71
- "status": "ok",
72
- "error": null,
73
- "data": {
74
- "authorized_ips": {
75
- "ipv4": [
76
- "63.208.226.34",
77
- "204.16.32.0/22",
78
- "67.134.143.0/24",
79
- "216.205.243.0/24",
80
- "34.85.156.5/32",
81
- "35.245.108.108/32",
82
- "34.86.129.193/32",
83
- "34.86.134.94/32",
84
- "34.85.222.234/32",
85
- "34.86.176.234/32",
86
- "34.86.125.212/32",
87
- "34.85.224.60/32",
88
- "34.86.160.49/32",
89
- "35.245.64.166/32",
90
- "35.188.226.11/32",
91
- "34.86.208.228/32",
92
- "34.85.216.144/32",
93
- "35.221.22.153/32",
94
- "34.86.137.108/32",
95
- "34.86.51.35/32",
96
- "34.150.221.40/32",
97
- "34.85.216.70/32",
98
- "34.86.37.191/32",
99
- "34.85.214.215/32",
100
- "35.236.234.82/32",
101
- "34.86.161.241/32",
102
- "216.32.181.16",
103
- "216.178.32.0/20",
104
- "168.235.224.0/24",
105
- "195.130.217.0/24",
106
- "91.220.42.0/24",
107
- "146.101.78.0/24",
108
- "207.82.80.0/24",
109
- "213.167.81.0/25",
110
- "193.7.207.0/25",
111
- "213.167.75.0/25",
112
- "185.58.85.0/24",
113
- "185.58.86.0/24",
114
- "193.7.206.0/25",
115
- "147.28.36.0/24",
116
- "207.211.31.0/25",
117
- "205.139.110.0/24",
118
- "216.205.24.0/24",
119
- "170.10.129.0/24",
120
- "63.128.21.0/24",
121
- "170.10.133.0/24",
122
- "185.58.84.93/32",
123
- "207.211.41.113/32",
124
- "207.211.30.64/26",
125
- "207.211.30.128/25",
126
- "216.145.221.0/24",
127
- "170.10.128.0/24",
128
- "170.10.132.56/29",
129
- "170.10.132.64/29",
130
- "41.74.192.0/22",
131
- "41.74.200.0/23",
132
- "41.74.196.0/22",
133
- "41.74.204.0/23",
134
- "41.74.206.0/24",
135
- "51.163.158.0/24",
136
- "194.104.109.0/24",
137
- "194.104.111.0/24",
138
- "194.104.110.21/32",
139
- "194.104.110.240/28",
140
- "62.140.10.21/32",
141
- "62.140.7.0/24",
142
- "194.104.108.240/29",
143
- "194.104.108.21/32",
144
- "103.13.69.0/24",
145
- "124.47.150.0/24",
146
- "124.47.189.0/24",
147
- "103.96.23.0/24",
148
- "103.96.21.0/24",
149
- "180.189.28.0/24",
150
- "216.145.217.0/24",
151
- "103.96.22.96/28",
152
- "103.96.22.22/32",
153
- "103.96.20.22/32",
154
- "103.96.20.96/28",
155
- "170.10.145.0/24",
156
- "170.10.147.0/24",
157
- "170.10.144.126/32",
158
- "170.10.146.126/32",
159
- "170.10.144.240/29",
160
- "170.10.146.240/29",
161
- "216.145.216.0/24"
162
- ]
163
- },
164
- "dns_lookups_num": 8,
165
- "domains_extracted": [
166
- "myspace.com",
167
- "_netblocks.mimecast.com",
168
- "eu._netblocks.mimecast.com",
169
- "us._netblocks.mimecast.com",
170
- "za._netblocks.mimecast.com",
171
- "de._netblocks.mimecast.com",
172
- "au._netblocks.mimecast.com",
173
- "ca._netblocks.mimecast.com"
174
- ],
175
- "elapsed_ms": 1118,
176
- "has_issues": false,
177
- "has_spf_record": true,
178
- "host": "myspace.com",
179
- "ip_pass": false,
180
- "macros_found": false,
181
- "spf_record": "v=spf1 mx ip4:63.208.226.34 ip4:204.16.32.0/22 ip4:67.134.143.0/24 ip4:216.205.243.0/24 ip4:34.85.156.5/32 ip4:35.245.108.108/32 ip4:34.86.129.193/32 ip4:34.86.134.94/32 ip4:34.85.222.234/32 ip4:34.86.176.234/32 ip4:34.86.125.212/32 ip4:34.85.224.60/32 ip4:34.86.160.49/32 ip4:35.245.64.166/32 ip4:35.188.226.11/32 ip4:34.86.208.228/32 ip4:34.85.216.144/32 ip4:35.221.22.153/32 ip4:34.86.137.108/32 ip4:34.86.51.35/32 ip4:34.150.221.40/32 ip4:34.85.216.70/32 ip4:34.86.37.191/32 ip4:34.85.214.215/32 ip4:35.236.234.82/32 ip4:34.86.161.241/32 ip4:216.32.181.16 ip4:216.178.32.0/20 ip4:168.235.224.0/24 include:_netblocks.mimecast.com -all",
182
- "spf_records_list": [
183
- {
184
- "authorized_ips": {
185
- "ipv4": [
186
- "63.208.226.34",
187
- "204.16.32.0/22",
188
- "67.134.143.0/24",
189
- "216.205.243.0/24",
190
- "34.85.156.5/32",
191
- "35.245.108.108/32",
192
- "34.86.129.193/32",
193
- "34.86.134.94/32",
194
- "34.85.222.234/32",
195
- "34.86.176.234/32",
196
- "34.86.125.212/32",
197
- "34.85.224.60/32",
198
- "34.86.160.49/32",
199
- "35.245.64.166/32",
200
- "35.188.226.11/32",
201
- "34.86.208.228/32",
202
- "34.85.216.144/32",
203
- "35.221.22.153/32",
204
- "34.86.137.108/32",
205
- "34.86.51.35/32",
206
- "34.150.221.40/32",
207
- "34.85.216.70/32",
208
- "34.86.37.191/32",
209
- "34.85.214.215/32",
210
- "35.236.234.82/32",
211
- "34.86.161.241/32",
212
- "216.32.181.16",
213
- "216.178.32.0/20",
214
- "168.235.224.0/24"
215
- ]
216
- },
217
- "chars_num": 637,
218
- "domains": [
219
- "_netblocks.mimecast.com"
220
- ],
221
- "origin": "myspace.com",
222
- "record": "v=spf1 mx ip4:63.208.226.34 ip4:204.16.32.0/22 ip4:67.134.143.0/24 ip4:216.205.243.0/24 ip4:34.85.156.5/32 ip4:35.245.108.108/32 ip4:34.86.129.193/32 ip4:34.86.134.94/32 ip4:34.85.222.234/32 ip4:34.86.176.234/32 ip4:34.86.125.212/32 ip4:34.85.224.60/32 ip4:34.86.160.49/32 ip4:35.245.64.166/32 ip4:35.188.226.11/32 ip4:34.86.208.228/32 ip4:34.85.216.144/32 ip4:35.221.22.153/32 ip4:34.86.137.108/32 ip4:34.86.51.35/32 ip4:34.150.221.40/32 ip4:34.85.216.70/32 ip4:34.86.37.191/32 ip4:34.85.214.215/32 ip4:35.236.234.82/32 ip4:34.86.161.241/32 ip4:216.32.181.16 ip4:216.178.32.0/20 ip4:168.235.224.0/24 include:_netblocks.mimecast.com -all",
223
- "use_macro": false
224
- },
225
- {
226
- "chars_num": 221,
227
- "domains": [
228
- "eu._netblocks.mimecast.com",
229
- "us._netblocks.mimecast.com",
230
- "za._netblocks.mimecast.com",
231
- "de._netblocks.mimecast.com",
232
- "au._netblocks.mimecast.com",
233
- "ca._netblocks.mimecast.com"
234
- ],
235
- "origin": "_netblocks.mimecast.com",
236
- "record": "v=spf1 include:eu._netblocks.mimecast.com include:us._netblocks.mimecast.com include:za._netblocks.mimecast.com include:de._netblocks.mimecast.com include:au._netblocks.mimecast.com include:ca._netblocks.mimecast.com ~all",
237
- "use_macro": false
238
- },
239
- {
240
- "authorized_ips": {
241
- "ipv4": [
242
- "195.130.217.0/24",
243
- "91.220.42.0/24",
244
- "146.101.78.0/24",
245
- "207.82.80.0/24",
246
- "213.167.81.0/25",
247
- "193.7.207.0/25",
248
- "213.167.75.0/25",
249
- "185.58.85.0/24",
250
- "185.58.86.0/24",
251
- "193.7.206.0/25",
252
- "147.28.36.0/24"
253
- ]
254
- },
255
- "chars_num": 225,
256
- "origin": "eu._netblocks.mimecast.com",
257
- "record": "v=spf1 ip4:195.130.217.0/24 ip4:91.220.42.0/24 ip4:146.101.78.0/24 ip4:207.82.80.0/24 ip4:213.167.81.0/25 ip4:193.7.207.0/25 ip4:213.167.75.0/25 ip4:185.58.85.0/24 ip4:185.58.86.0/24 ip4:193.7.206.0/25 ip4:147.28.36.0/24 ~all",
258
- "use_macro": false
259
- },
260
- {
261
- "authorized_ips": {
262
- "ipv4": [
263
- "207.211.31.0/25",
264
- "205.139.110.0/24",
265
- "216.205.24.0/24",
266
- "170.10.129.0/24",
267
- "63.128.21.0/24",
268
- "170.10.133.0/24",
269
- "185.58.84.93/32",
270
- "207.211.41.113/32",
271
- "207.211.30.64/26",
272
- "207.211.30.128/25",
273
- "216.145.221.0/24",
274
- "170.10.128.0/24",
275
- "170.10.132.56/29",
276
- "170.10.132.64/29"
277
- ]
278
- },
279
- "chars_num": 299,
280
- "origin": "us._netblocks.mimecast.com",
281
- "record": "v=spf1 ip4:207.211.31.0/25 ip4:205.139.110.0/24 ip4:216.205.24.0/24 ip4:170.10.129.0/24 ip4:63.128.21.0/24 ip4:170.10.133.0/24 ip4:185.58.84.93/32 ip4:207.211.41.113/32 ip4:207.211.30.64/26 ip4:207.211.30.128/25 ip4:216.145.221.0/24 ip4:170.10.128.0/24 ip4:170.10.132.56/29 ip4:170.10.132.64/29 ~all",
282
- "use_macro": false
283
- },
284
- {
285
- "authorized_ips": {
286
- "ipv4": [
287
- "41.74.192.0/22",
288
- "41.74.200.0/23",
289
- "41.74.196.0/22",
290
- "41.74.204.0/23",
291
- "41.74.206.0/24"
292
- ]
293
- },
294
- "chars_num": 106,
295
- "origin": "za._netblocks.mimecast.com",
296
- "record": "v=spf1 ip4:41.74.192.0/22 ip4:41.74.200.0/23 ip4:41.74.196.0/22 ip4:41.74.204.0/23 ip4:41.74.206.0/24 ~all",
297
- "use_macro": false
298
- },
299
- {
300
- "authorized_ips": {
301
- "ipv4": [
302
- "51.163.158.0/24",
303
- "194.104.109.0/24",
304
- "194.104.111.0/24",
305
- "194.104.110.21/32",
306
- "194.104.110.240/28",
307
- "62.140.10.21/32",
308
- "62.140.7.0/24",
309
- "194.104.108.240/29",
310
- "194.104.108.21/32"
311
- ]
312
- },
313
- "chars_num": 201,
314
- "origin": "de._netblocks.mimecast.com",
315
- "record": "v=spf1 ip4:51.163.158.0/24 ip4:194.104.109.0/24 ip4:194.104.111.0/24 ip4:194.104.110.21/32 ip4:194.104.110.240/28 ip4:62.140.10.21/32 ip4:62.140.7.0/24 ip4:194.104.108.240/29 ip4:194.104.108.21/32 ~all",
316
- "use_macro": false
317
- },
318
- {
319
- "authorized_ips": {
320
- "ipv4": [
321
- "103.13.69.0/24",
322
- "124.47.150.0/24",
323
- "124.47.189.0/24",
324
- "103.96.23.0/24",
325
- "103.96.21.0/24",
326
- "180.189.28.0/24",
327
- "216.145.217.0/24",
328
- "103.96.22.96/28",
329
- "103.96.22.22/32",
330
- "103.96.20.22/32",
331
- "103.96.20.96/28"
332
- ]
333
- },
334
- "chars_num": 229,
335
- "origin": "au._netblocks.mimecast.com",
336
- "record": "v=spf1 ip4:103.13.69.0/24 ip4:124.47.150.0/24 ip4:124.47.189.0/24 ip4:103.96.23.0/24 ip4:103.96.21.0/24 ip4:180.189.28.0/24 ip4:216.145.217.0/24 ip4:103.96.22.96/28 ip4:103.96.22.22/32 ip4:103.96.20.22/32 ip4:103.96.20.96/28 ~all",
337
- "use_macro": false
338
- },
339
- {
340
- "authorized_ips": {
341
- "ipv4": [
342
- "170.10.145.0/24",
343
- "170.10.147.0/24",
344
- "170.10.144.126/32",
345
- "170.10.146.126/32",
346
- "170.10.144.240/29",
347
- "170.10.146.240/29",
348
- "216.145.216.0/24"
349
- ]
350
- },
351
- "chars_num": 160,
352
- "origin": "ca._netblocks.mimecast.com",
353
- "record": "v=spf1 ip4:170.10.145.0/24 ip4:170.10.147.0/24 ip4:170.10.144.126/32 ip4:170.10.146.126/32 ip4:170.10.144.240/29 ip4:170.10.146.240/29 ip4:216.145.216.0/24 ~all",
354
- "use_macro": false
355
- }
356
- ],
357
- "spf_valid": true
358
- },
359
- "code": 200
114
+
115
+ ---
116
+
117
+ ## Example Response
118
+
119
+ ```json
120
+ {
121
+ "status": "ok",
122
+ "error": null,
123
+ "data": {
124
+ "authorized_ips": {
125
+ "ipv4": [
126
+ "63.208.226.34",
127
+ "204.16.32.0/22",
128
+ "67.134.143.0/24",
129
+ "216.205.243.0/24",
130
+ "34.85.156.5/32",
131
+ "35.245.108.108/32",
132
+ "34.86.129.193/32",
133
+ "34.86.134.94/32",
134
+ "34.85.222.234/32",
135
+ "34.86.176.234/32",
136
+ "34.86.125.212/32",
137
+ "34.85.224.60/32",
138
+ "34.86.160.49/32",
139
+ "35.245.64.166/32",
140
+ "35.188.226.11/32",
141
+ "34.86.208.228/32",
142
+ "34.85.216.144/32",
143
+ "35.221.22.153/32",
144
+ "34.86.137.108/32",
145
+ "34.86.51.35/32",
146
+ "34.150.221.40/32",
147
+ "34.85.216.70/32",
148
+ "34.86.37.191/32",
149
+ "34.85.214.215/32",
150
+ "35.236.234.82/32",
151
+ "34.86.161.241/32",
152
+ "216.32.181.16",
153
+ "216.178.32.0/20",
154
+ "168.235.224.0/24",
155
+ "195.130.217.0/24",
156
+ "91.220.42.0/24",
157
+ "146.101.78.0/24",
158
+ "207.82.80.0/24",
159
+ "213.167.81.0/25",
160
+ "193.7.207.0/25",
161
+ "213.167.75.0/25",
162
+ "185.58.85.0/24",
163
+ "185.58.86.0/24",
164
+ "193.7.206.0/25",
165
+ "147.28.36.0/24",
166
+ "207.211.31.0/25",
167
+ "205.139.110.0/24",
168
+ "216.205.24.0/24",
169
+ "170.10.129.0/24",
170
+ "63.128.21.0/24",
171
+ "170.10.133.0/24",
172
+ "185.58.84.93/32",
173
+ "207.211.41.113/32",
174
+ "207.211.30.64/26",
175
+ "207.211.30.128/25",
176
+ "216.145.221.0/24",
177
+ "170.10.128.0/24",
178
+ "170.10.132.56/29",
179
+ "170.10.132.64/29",
180
+ "41.74.192.0/22",
181
+ "41.74.200.0/23",
182
+ "41.74.196.0/22",
183
+ "41.74.204.0/23",
184
+ "41.74.206.0/24",
185
+ "51.163.158.0/24",
186
+ "194.104.109.0/24",
187
+ "194.104.111.0/24",
188
+ "194.104.110.21/32",
189
+ "194.104.110.240/28",
190
+ "62.140.10.21/32",
191
+ "62.140.7.0/24",
192
+ "194.104.108.240/29",
193
+ "194.104.108.21/32",
194
+ "103.13.69.0/24",
195
+ "124.47.150.0/24",
196
+ "124.47.189.0/24",
197
+ "103.96.23.0/24",
198
+ "103.96.21.0/24",
199
+ "180.189.28.0/24",
200
+ "216.145.217.0/24",
201
+ "103.96.22.96/28",
202
+ "103.96.22.22/32",
203
+ "103.96.20.22/32",
204
+ "103.96.20.96/28",
205
+ "170.10.145.0/24",
206
+ "170.10.147.0/24",
207
+ "170.10.144.126/32",
208
+ "170.10.146.126/32",
209
+ "170.10.144.240/29",
210
+ "170.10.146.240/29",
211
+ "216.145.216.0/24"
212
+ ]
213
+ },
214
+ "dns_lookups_num": 8,
215
+ "domains_extracted": [
216
+ "myspace.com",
217
+ "_netblocks.mimecast.com",
218
+ "eu._netblocks.mimecast.com",
219
+ "us._netblocks.mimecast.com",
220
+ "za._netblocks.mimecast.com",
221
+ "de._netblocks.mimecast.com",
222
+ "au._netblocks.mimecast.com",
223
+ "ca._netblocks.mimecast.com"
224
+ ],
225
+ "elapsed_ms": 1118,
226
+ "has_issues": false,
227
+ "has_spf_record": true,
228
+ "host": "myspace.com",
229
+ "ip_pass": false,
230
+ "macros_found": false,
231
+ "spf_record": "v=spf1 mx ip4:63.208.226.34 ip4:204.16.32.0/22 ip4:67.134.143.0/24 ip4:216.205.243.0/24 ip4:34.85.156.5/32 ip4:35.245.108.108/32 ip4:34.86.129.193/32 ip4:34.86.134.94/32 ip4:34.85.222.234/32 ip4:34.86.176.234/32 ip4:34.86.125.212/32 ip4:34.85.224.60/32 ip4:34.86.160.49/32 ip4:35.245.64.166/32 ip4:35.188.226.11/32 ip4:34.86.208.228/32 ip4:34.85.216.144/32 ip4:35.221.22.153/32 ip4:34.86.137.108/32 ip4:34.86.51.35/32 ip4:34.150.221.40/32 ip4:34.85.216.70/32 ip4:34.86.37.191/32 ip4:34.85.214.215/32 ip4:35.236.234.82/32 ip4:34.86.161.241/32 ip4:216.32.181.16 ip4:216.178.32.0/20 ip4:168.235.224.0/24 include:_netblocks.mimecast.com -all",
232
+ "spf_records_list": [
233
+ {
234
+ "authorized_ips": {
235
+ "ipv4": [
236
+ "63.208.226.34",
237
+ "204.16.32.0/22",
238
+ "67.134.143.0/24",
239
+ "216.205.243.0/24",
240
+ "34.85.156.5/32",
241
+ "35.245.108.108/32",
242
+ "34.86.129.193/32",
243
+ "34.86.134.94/32",
244
+ "34.85.222.234/32",
245
+ "34.86.176.234/32",
246
+ "34.86.125.212/32",
247
+ "34.85.224.60/32",
248
+ "34.86.160.49/32",
249
+ "35.245.64.166/32",
250
+ "35.188.226.11/32",
251
+ "34.86.208.228/32",
252
+ "34.85.216.144/32",
253
+ "35.221.22.153/32",
254
+ "34.86.137.108/32",
255
+ "34.86.51.35/32",
256
+ "34.150.221.40/32",
257
+ "34.85.216.70/32",
258
+ "34.86.37.191/32",
259
+ "34.85.214.215/32",
260
+ "35.236.234.82/32",
261
+ "34.86.161.241/32",
262
+ "216.32.181.16",
263
+ "216.178.32.0/20",
264
+ "168.235.224.0/24"
265
+ ]
266
+ },
267
+ "chars_num": 637,
268
+ "domains": [
269
+ "_netblocks.mimecast.com"
270
+ ],
271
+ "origin": "myspace.com",
272
+ "record": "v=spf1 mx ip4:63.208.226.34 ip4:204.16.32.0/22 ip4:67.134.143.0/24 ip4:216.205.243.0/24 ip4:34.85.156.5/32 ip4:35.245.108.108/32 ip4:34.86.129.193/32 ip4:34.86.134.94/32 ip4:34.85.222.234/32 ip4:34.86.176.234/32 ip4:34.86.125.212/32 ip4:34.85.224.60/32 ip4:34.86.160.49/32 ip4:35.245.64.166/32 ip4:35.188.226.11/32 ip4:34.86.208.228/32 ip4:34.85.216.144/32 ip4:35.221.22.153/32 ip4:34.86.137.108/32 ip4:34.86.51.35/32 ip4:34.150.221.40/32 ip4:34.85.216.70/32 ip4:34.86.37.191/32 ip4:34.85.214.215/32 ip4:35.236.234.82/32 ip4:34.86.161.241/32 ip4:216.32.181.16 ip4:216.178.32.0/20 ip4:168.235.224.0/24 include:_netblocks.mimecast.com -all",
273
+ "use_macro": false
274
+ },
275
+ {
276
+ "chars_num": 221,
277
+ "domains": [
278
+ "eu._netblocks.mimecast.com",
279
+ "us._netblocks.mimecast.com",
280
+ "za._netblocks.mimecast.com",
281
+ "de._netblocks.mimecast.com",
282
+ "au._netblocks.mimecast.com",
283
+ "ca._netblocks.mimecast.com"
284
+ ],
285
+ "origin": "_netblocks.mimecast.com",
286
+ "record": "v=spf1 include:eu._netblocks.mimecast.com include:us._netblocks.mimecast.com include:za._netblocks.mimecast.com include:de._netblocks.mimecast.com include:au._netblocks.mimecast.com include:ca._netblocks.mimecast.com ~all",
287
+ "use_macro": false
288
+ },
289
+ {
290
+ "authorized_ips": {
291
+ "ipv4": [
292
+ "195.130.217.0/24",
293
+ "91.220.42.0/24",
294
+ "146.101.78.0/24",
295
+ "207.82.80.0/24",
296
+ "213.167.81.0/25",
297
+ "193.7.207.0/25",
298
+ "213.167.75.0/25",
299
+ "185.58.85.0/24",
300
+ "185.58.86.0/24",
301
+ "193.7.206.0/25",
302
+ "147.28.36.0/24"
303
+ ]
304
+ },
305
+ "chars_num": 225,
306
+ "origin": "eu._netblocks.mimecast.com",
307
+ "record": "v=spf1 ip4:195.130.217.0/24 ip4:91.220.42.0/24 ip4:146.101.78.0/24 ip4:207.82.80.0/24 ip4:213.167.81.0/25 ip4:193.7.207.0/25 ip4:213.167.75.0/25 ip4:185.58.85.0/24 ip4:185.58.86.0/24 ip4:193.7.206.0/25 ip4:147.28.36.0/24 ~all",
308
+ "use_macro": false
309
+ },
310
+ {
311
+ "authorized_ips": {
312
+ "ipv4": [
313
+ "207.211.31.0/25",
314
+ "205.139.110.0/24",
315
+ "216.205.24.0/24",
316
+ "170.10.129.0/24",
317
+ "63.128.21.0/24",
318
+ "170.10.133.0/24",
319
+ "185.58.84.93/32",
320
+ "207.211.41.113/32",
321
+ "207.211.30.64/26",
322
+ "207.211.30.128/25",
323
+ "216.145.221.0/24",
324
+ "170.10.128.0/24",
325
+ "170.10.132.56/29",
326
+ "170.10.132.64/29"
327
+ ]
328
+ },
329
+ "chars_num": 299,
330
+ "origin": "us._netblocks.mimecast.com",
331
+ "record": "v=spf1 ip4:207.211.31.0/25 ip4:205.139.110.0/24 ip4:216.205.24.0/24 ip4:170.10.129.0/24 ip4:63.128.21.0/24 ip4:170.10.133.0/24 ip4:185.58.84.93/32 ip4:207.211.41.113/32 ip4:207.211.30.64/26 ip4:207.211.30.128/25 ip4:216.145.221.0/24 ip4:170.10.128.0/24 ip4:170.10.132.56/29 ip4:170.10.132.64/29 ~all",
332
+ "use_macro": false
333
+ },
334
+ {
335
+ "authorized_ips": {
336
+ "ipv4": [
337
+ "41.74.192.0/22",
338
+ "41.74.200.0/23",
339
+ "41.74.196.0/22",
340
+ "41.74.204.0/23",
341
+ "41.74.206.0/24"
342
+ ]
343
+ },
344
+ "chars_num": 106,
345
+ "origin": "za._netblocks.mimecast.com",
346
+ "record": "v=spf1 ip4:41.74.192.0/22 ip4:41.74.200.0/23 ip4:41.74.196.0/22 ip4:41.74.204.0/23 ip4:41.74.206.0/24 ~all",
347
+ "use_macro": false
348
+ },
349
+ {
350
+ "authorized_ips": {
351
+ "ipv4": [
352
+ "51.163.158.0/24",
353
+ "194.104.109.0/24",
354
+ "194.104.111.0/24",
355
+ "194.104.110.21/32",
356
+ "194.104.110.240/28",
357
+ "62.140.10.21/32",
358
+ "62.140.7.0/24",
359
+ "194.104.108.240/29",
360
+ "194.104.108.21/32"
361
+ ]
362
+ },
363
+ "chars_num": 201,
364
+ "origin": "de._netblocks.mimecast.com",
365
+ "record": "v=spf1 ip4:51.163.158.0/24 ip4:194.104.109.0/24 ip4:194.104.111.0/24 ip4:194.104.110.21/32 ip4:194.104.110.240/28 ip4:62.140.10.21/32 ip4:62.140.7.0/24 ip4:194.104.108.240/29 ip4:194.104.108.21/32 ~all",
366
+ "use_macro": false
367
+ },
368
+ {
369
+ "authorized_ips": {
370
+ "ipv4": [
371
+ "103.13.69.0/24",
372
+ "124.47.150.0/24",
373
+ "124.47.189.0/24",
374
+ "103.96.23.0/24",
375
+ "103.96.21.0/24",
376
+ "180.189.28.0/24",
377
+ "216.145.217.0/24",
378
+ "103.96.22.96/28",
379
+ "103.96.22.22/32",
380
+ "103.96.20.22/32",
381
+ "103.96.20.96/28"
382
+ ]
383
+ },
384
+ "chars_num": 229,
385
+ "origin": "au._netblocks.mimecast.com",
386
+ "record": "v=spf1 ip4:103.13.69.0/24 ip4:124.47.150.0/24 ip4:124.47.189.0/24 ip4:103.96.23.0/24 ip4:103.96.21.0/24 ip4:180.189.28.0/24 ip4:216.145.217.0/24 ip4:103.96.22.96/28 ip4:103.96.22.22/32 ip4:103.96.20.22/32 ip4:103.96.20.96/28 ~all",
387
+ "use_macro": false
388
+ },
389
+ {
390
+ "authorized_ips": {
391
+ "ipv4": [
392
+ "170.10.145.0/24",
393
+ "170.10.147.0/24",
394
+ "170.10.144.126/32",
395
+ "170.10.146.126/32",
396
+ "170.10.144.240/29",
397
+ "170.10.146.240/29",
398
+ "216.145.216.0/24"
399
+ ]
400
+ },
401
+ "chars_num": 160,
402
+ "origin": "ca._netblocks.mimecast.com",
403
+ "record": "v=spf1 ip4:170.10.145.0/24 ip4:170.10.147.0/24 ip4:170.10.144.126/32 ip4:170.10.146.126/32 ip4:170.10.144.240/29 ip4:170.10.146.240/29 ip4:216.145.216.0/24 ~all",
404
+ "use_macro": false
405
+ }
406
+ ],
407
+ "spf_valid": true
408
+ }
360
409
  }
361
410
  ```
362
411
 
@@ -369,6 +418,7 @@ Need any assistance? [Get in touch with Customer Support](https://apiverve.com/c
369
418
  ---
370
419
 
371
420
  ## Updates
421
+
372
422
  Stay up to date by following [@apiverveHQ](https://twitter.com/apiverveHQ) on Twitter.
373
423
 
374
424
  ---
@@ -388,4 +438,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
388
438
 
389
439
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
390
440
 
391
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
441
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Basic Example - SPF Validator API
3
+ *
4
+ * This example demonstrates how to use the SPF Validator API.
5
+ * Make sure to set your API key in the .env file or replace '[YOUR_API_KEY]' below.
6
+ */
7
+
8
+ require('dotenv').config();
9
+ const spfvalidatorAPI = require('../index.js');
10
+
11
+ // Initialize the API client
12
+ const api = new spfvalidatorAPI({
13
+ api_key: process.env.API_KEY || '[YOUR_API_KEY]'
14
+ });
15
+
16
+ // Example query
17
+ var query = {
18
+ domain: "myspace.com"
19
+ };
20
+
21
+ // Make the API request using callback
22
+ console.log('Making request to SPF Validator API...\n');
23
+
24
+ api.execute(query, function (error, data) {
25
+ if (error) {
26
+ console.error('Error occurred:');
27
+ if (error.error) {
28
+ console.error('Message:', error.error);
29
+ console.error('Status:', error.status);
30
+ } else {
31
+ console.error(JSON.stringify(error, null, 2));
32
+ }
33
+ return;
34
+ }
35
+
36
+ console.log('Response:');
37
+ console.log(JSON.stringify(data, null, 2));
38
+ });
package/index.d.ts ADDED
@@ -0,0 +1,50 @@
1
+ declare module '@apiverve/spfvalidator' {
2
+ export interface spfvalidatorOptions {
3
+ api_key: string;
4
+ secure?: boolean;
5
+ }
6
+
7
+ export interface spfvalidatorResponse {
8
+ status: string;
9
+ error: string | null;
10
+ data: SPFValidatorData;
11
+ code?: number;
12
+ }
13
+
14
+
15
+ interface SPFValidatorData {
16
+ authorizedIPS: AuthorizedIPS;
17
+ dnsLookupsNum: number;
18
+ domainsExtracted: string[];
19
+ elapsedMS: number;
20
+ hasIssues: boolean;
21
+ hasSPFRecord: boolean;
22
+ host: string;
23
+ ipPass: boolean;
24
+ macrosFound: boolean;
25
+ spfRecord: string;
26
+ spfRecordsList: SPFRecordsList[];
27
+ spfValid: boolean;
28
+ }
29
+
30
+ interface AuthorizedIPS {
31
+ ipv4: string[];
32
+ }
33
+
34
+ interface SPFRecordsList {
35
+ authorizedIPS?: AuthorizedIPS;
36
+ charsNum: number;
37
+ domains?: string[];
38
+ origin: string;
39
+ record: string;
40
+ useMacro: boolean;
41
+ }
42
+
43
+ export default class spfvalidatorWrapper {
44
+ constructor(options: spfvalidatorOptions);
45
+
46
+ execute(callback: (error: any, data: spfvalidatorResponse | null) => void): Promise<spfvalidatorResponse>;
47
+ execute(query: Record<string, any>, callback: (error: any, data: spfvalidatorResponse | null) => void): Promise<spfvalidatorResponse>;
48
+ execute(query?: Record<string, any>): Promise<spfvalidatorResponse>;
49
+ }
50
+ }
package/index.js CHANGED
@@ -4,14 +4,27 @@ class spfvalidatorWrapper {
4
4
 
5
5
  constructor(options) {
6
6
  if (!options || typeof options !== 'object') {
7
- throw new Error('Options object must be provided.');
7
+ throw new Error('Options object must be provided. See documentation: https://docs.apiverve.com/ref/spfvalidator');
8
8
  }
9
9
 
10
10
  const { api_key, secure = true } = options;
11
11
 
12
12
  if (!api_key || typeof api_key !== 'string') {
13
- throw new Error('API key must be provided as a non-empty string.');
13
+ throw new Error('API key must be provided as a non-empty string. Get your API key at: https://apiverve.com');
14
14
  }
15
+
16
+ // Validate API key format (GUID or alphanumeric with hyphens)
17
+ const apiKeyPattern = /^[a-zA-Z0-9-]+$/;
18
+ if (!apiKeyPattern.test(api_key)) {
19
+ throw new Error('Invalid API key format. API key must be alphanumeric and may contain hyphens. Get your API key at: https://apiverve.com');
20
+ }
21
+
22
+ // Check minimum length (GUIDs are typically 36 chars with hyphens, or 32 without)
23
+ const trimmedKey = api_key.replace(/-/g, '');
24
+ if (trimmedKey.length < 32) {
25
+ throw new Error('Invalid API key. API key appears to be too short. Get your API key at: https://apiverve.com');
26
+ }
27
+
15
28
  if (typeof secure !== 'boolean') {
16
29
  throw new Error('Secure parameter must be a boolean value.');
17
30
  }
@@ -24,20 +37,32 @@ class spfvalidatorWrapper {
24
37
  }
25
38
 
26
39
  async execute(query, callback) {
27
- if(arguments.length > 1) {
40
+ // Handle different argument patterns
41
+ if(arguments.length === 0) {
42
+ // execute() - no args
43
+ query = {};
44
+ callback = null;
45
+ } else if(arguments.length === 1) {
46
+ if (typeof query === 'function') {
47
+ // execute(callback)
48
+ callback = query;
49
+ query = {};
50
+ } else {
51
+ // execute(query)
52
+ callback = null;
53
+ }
54
+ } else {
55
+ // execute(query, callback)
28
56
  if (!query || typeof query !== 'object') {
29
57
  throw new Error('Query parameters must be provided as an object.');
30
58
  }
31
- } else {
32
- callback = query;
33
- query = {};
34
59
  }
35
60
 
36
61
  var requiredParams = ["domain"];
37
62
  if (requiredParams.length > 0) {
38
63
  for (var i = 0; i < requiredParams.length; i++) {
39
64
  if (!query[requiredParams[i]]) {
40
- throw new Error(`Required parameter [${requiredParams[i]}] is missing.`);
65
+ throw new Error(`Required parameter [${requiredParams[i]}] is missing. See documentation: https://docs.apiverve.com/ref/spfvalidator`);
41
66
  }
42
67
  }
43
68
  }
@@ -58,16 +83,25 @@ class spfvalidatorWrapper {
58
83
  });
59
84
 
60
85
  const data = response.data;
61
- callback(null, data);
86
+ if (callback) callback(null, data);
62
87
  return data;
63
88
  } catch (error) {
64
- if (error.response.data) {
65
- callback(error.response.data, null);
66
- throw error.response.data;
89
+ let apiError;
90
+
91
+ if (error.response && error.response.data) {
92
+ apiError = error.response.data;
93
+ } else if (error.message) {
94
+ apiError = { error: error.message, status: 'error' };
67
95
  } else {
68
- callback(error, null);
69
- throw error;
70
- }
96
+ apiError = { error: 'An unknown error occurred', status: 'error' };
97
+ }
98
+
99
+ if (callback) {
100
+ callback(apiError, null);
101
+ return; // Don't throw if callback is provided
102
+ }
103
+
104
+ throw apiError;
71
105
  }
72
106
  }
73
107
 
package/package.json CHANGED
@@ -1,24 +1,27 @@
1
1
  {
2
2
  "name": "@apiverve/spfvalidator",
3
- "version": "1.1.9",
3
+ "version": "1.1.12",
4
4
  "description": "SPF Validator checks the Sender Policy Framework (SPF) DNS record for a domain to verify if it’s valid and optionally whether a given IP address is authorized to send emails for that domain.",
5
5
  "main": "index.js",
6
+ "types": "index.d.ts",
6
7
  "scripts": {
7
- "test": "mocha"
8
+ "test": "mocha",
9
+ "example": "node examples/basic.js"
8
10
  },
9
11
  "repository": {
10
12
  "type": "git",
11
- "url": "git+https://github.com/apiverve/spfvalidator-API.git"
13
+ "url": "git+https://github.com/apiverve/spfvalidator-api.git",
14
+ "directory": "npm"
12
15
  },
13
16
  "keywords": [
14
- "spf","spf check","spf validator","spf test","email authentication"
17
+ "spf", "spf check", "spf validator", "spf test", "email authentication"
15
18
  ],
16
19
  "author": "APIVerve <hello@apiverve.com> (http://apiverve.com/)",
17
20
  "license": "MIT",
18
21
  "bugs": {
19
- "url": "https://github.com/apiverve/spfvalidator-API/issues"
22
+ "url": "https://github.com/apiverve/spfvalidator-api/issues"
20
23
  },
21
- "homepage": "https://apiverve.com/marketplace/api/spfvalidator?utm_source=npm",
24
+ "homepage": "https://apiverve.com/marketplace/spfvalidator?utm_source=npm",
22
25
  "devDependencies": {
23
26
  "mocha": "^11.0.1",
24
27
  "chai": "^5.1.2",
@@ -27,6 +30,6 @@
27
30
  "dependencies": {
28
31
  "node-fetch": "^3.3.2",
29
32
  "promise": "^8.3.0",
30
- "axios": "1.8.4"
33
+ "axios": "1.13.2"
31
34
  }
32
35
  }