node-ipdox 1.0.5 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,6 +4,25 @@
4
4
 
5
5
  IPDox is a simple and efficient IP geolocation library for Node.js. It fetches data from multiple geolocation APIs and provides a unified response. It also includes a caching mechanism to prevent unnecessary requests.
6
6
 
7
+ ## Providers
8
+
9
+ Current keyless providers used:
10
+
11
+ - ip-api.com
12
+ - ipwho.is
13
+ - freeipapi.com
14
+ - ipapi.co
15
+
16
+ Note: ip-api.com free tier uses HTTP only. Provide `ipApiKey` to enable HTTPS (pro).
17
+
18
+ Fallback providers (best-effort, used after primary providers fail):
19
+
20
+ - geoip.vuiz.net
21
+ - apip.cc
22
+ - ip-sonar.com
23
+
24
+ Fallback providers can return partial data; `city` may be an empty string when unknown.
25
+
7
26
  ## Installation
8
27
 
9
28
  ```bash
@@ -18,7 +37,9 @@ import { IPDox } from "node-ipdox";
18
37
  const ipdox = new IPDox({
19
38
  cacheMaxItems: 5000,
20
39
  cacheMaxAge: 43200000,
21
- maxRetries: 10
40
+ maxRetries: 10,
41
+ requestTimeoutMs: 5000,
42
+ ipApiKey: "YOUR_IP_API_KEY"
22
43
  });
23
44
 
24
45
  ipdox
@@ -29,13 +50,15 @@ ipdox
29
50
 
30
51
  ## API
31
52
 
32
- ### `new IPDox({ cacheMaxItems, cacheMaxAge, maxRetries })`
53
+ ### `new IPDox({ cacheMaxItems, cacheMaxAge, maxRetries, requestTimeoutMs, ipApiKey })`
33
54
 
34
55
  Creates a new instance of IPDox.
35
56
 
36
57
  - `cacheMaxItems` - The maximum number of items to store in the cache (default: 1000)
37
58
  - `cacheMaxAge` - The cache timeout in milliseconds (default: 43200000 (12 hours))
38
59
  - `maxRetries` - Maximum number of retries if an API request fails (default: 10)
60
+ - `requestTimeoutMs` - Request timeout in milliseconds (default: 5000)
61
+ - `ipApiKey` - Optional ip-api.com pro API key to enable HTTPS
39
62
 
40
63
  ### `ipdox.doxIP({ ip })`
41
64
 
@@ -45,7 +68,7 @@ Fetches geolocation data for the specified IP address.
45
68
 
46
69
  Returns a Promise that resolves to an `IPDOXResponse` object.
47
70
 
48
- If no response is found, undefined is returned.
71
+ If no response is found or the IP is invalid, undefined is returned.
49
72
 
50
73
  ## IPDOXResponse
51
74
 
@@ -59,8 +82,8 @@ export interface IPDOXResponse {
59
82
  continent: string; // Continent ISO code
60
83
  latitude: number; // Latitude
61
84
  longitude: number; // Longitude
62
- zip: string; // Zip code
63
- isp: string; // ISP name
85
+ zip?: string; // Zip code (might be undefined)
86
+ isp?: string; // ISP name (might be undefined)
64
87
  proxy?: boolean; // Boolean indicating if the IP address is a proxy (might be undefined)
65
88
  isHosting?: boolean; // Boolean indicating if the IP address is a hosting provider (might be undefined)
66
89
  proxyInfo?: {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import _IPDox from "./ipdox";
1
+ import _IPDox from "./ipdox.js";
2
2
  /**
3
3
  * Main Class
4
4
  */
@@ -6,12 +6,13 @@ export declare const IPDox: typeof _IPDox;
6
6
  /**
7
7
  * Constructor type
8
8
  */
9
- export { IPDOXConstructor } from "./types/IPDOXConstructor";
9
+ export type { IPDOXConstructor } from "./types/IPDOXConstructor.js";
10
10
  /**
11
11
  * Params type
12
12
  */
13
- export { IPDOXRequest } from "./types/IPDOXRequest";
13
+ export type { IPDOXRequest } from "./types/IPDOXRequest.js";
14
14
  /**
15
15
  * Response type
16
16
  */
17
- export { IPDOXResponse } from "./types/IPDOXResponse";
17
+ export type { IPDOXResponse } from "./types/IPDOXResponse.js";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,YAAY,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,KAAK,eAAS,CAAC;AAE5B;;GAEG;AACH,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEpE;;GAEG;AACH,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;GAEG;AACH,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC"}
package/dist/index.js CHANGED
@@ -4,8 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.IPDox = void 0;
7
- const ipdox_1 = __importDefault(require("./ipdox"));
7
+ const ipdox_js_1 = __importDefault(require("./ipdox.js"));
8
8
  /**
9
9
  * Main Class
10
10
  */
11
- exports.IPDox = ipdox_1.default;
11
+ exports.IPDox = ipdox_js_1.default;
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAgC;AAEhC;;GAEG;AACU,QAAA,KAAK,GAAG,kBAAM,CAAC"}
package/dist/ipdox.d.ts CHANGED
@@ -1,9 +1,14 @@
1
- import { IPDOXRequest } from "./types/IPDOXRequest";
2
- import { IPDOXResponse } from "./types/IPDOXResponse";
3
- import { IPDOXConstructor } from "./types/IPDOXConstructor";
1
+ import { IPDOXRequest } from "./types/IPDOXRequest.js";
2
+ import { IPDOXResponse } from "./types/IPDOXResponse.js";
3
+ import { IPDOXConstructor } from "./types/IPDOXConstructor.js";
4
4
  declare class IPDox {
5
5
  private cache;
6
6
  private maxRetries;
7
+ private requestTimeoutMs;
8
+ private inFlight;
9
+ private http;
10
+ private ipApiKey?;
11
+ private unavailableProviders;
7
12
  /**
8
13
  * @description Creates an instance of IPDox.
9
14
  * @param {IPDOXConstructor} params
@@ -11,7 +16,7 @@ declare class IPDox {
11
16
  * @param {number} params.cacheMaxAge - The cache timeout in milliseconds (default: 43200000 (12 hours))
12
17
  * @param {number} params.maxRetries - The maximum number of retries (default: 10)
13
18
  */
14
- constructor({ cacheMaxItems, cacheMaxAge, maxRetries }?: IPDOXConstructor);
19
+ constructor({ cacheMaxItems, cacheMaxAge, maxRetries, requestTimeoutMs, ipApiKey }?: IPDOXConstructor);
15
20
  /**
16
21
  * @description Get information about an IP address
17
22
  * @param {IPDOXRequest} params - Params of the request
@@ -20,11 +25,25 @@ declare class IPDox {
20
25
  * @memberof IPDox
21
26
  */
22
27
  doxIP({ ip }: IPDOXRequest): Promise<IPDOXResponse | undefined>;
23
- private selectRandomAPI;
28
+ private shuffleProviders;
29
+ private fetchWithRetries;
30
+ private fetchFromProvider;
31
+ private waitWithJitter;
32
+ private noteProviderFailure;
33
+ private isDnsError;
34
+ private parseNumber;
35
+ private parseString;
36
+ private pickString;
37
+ private pickStringOrEmpty;
38
+ private normalizeContinentCode;
24
39
  private cacheResponse;
25
40
  private fetchIPHyphenAPIDotCom;
26
41
  private fetchFreeIPAPIDotCom;
27
42
  private fetchIPWhoDotIs;
28
43
  private fetchIPAPIDotCo;
44
+ private fetchGeoIPVuizDotNet;
45
+ private fetchAPIPDotCC;
46
+ private fetchIPSonarDotCom;
29
47
  }
30
48
  export default IPDox;
49
+ //# sourceMappingURL=ipdox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ipdox.d.ts","sourceRoot":"","sources":["../src/ipdox.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAoB/D,cAAM,KAAK;IACV,OAAO,CAAC,KAAK,CAAkC;IAC/C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAkD;IAClE,OAAO,CAAC,IAAI,CAAgB;IAC5B,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,oBAAoB,CAAe;IAE3C;;;;;;OAMG;gBAEF,EACC,aAAoB,EACpB,WAAsB,EACtB,UAAe,EACf,gBAA6C,EAC7C,QAAQ,EACR,GAAE,gBAKF;IAqBF;;;;;;OAMG;IACG,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IA0BrE,OAAO,CAAC,gBAAgB;YAcV,gBAAgB;YAmEhB,iBAAiB;YAwBjB,cAAc;IAS5B,OAAO,CAAC,mBAAmB;IAM3B,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,WAAW;IAkBnB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,UAAU;IAWlB,OAAO,CAAC,iBAAiB;IAIzB,OAAO,CAAC,sBAAsB;IA0B9B,OAAO,CAAC,aAAa;YAIP,sBAAsB;YAuDtB,oBAAoB;YAkDpB,eAAe;YAoDf,eAAe;YAuCf,oBAAoB;YAwDpB,cAAc;YAyDd,kBAAkB;CA6ChC;AAED,eAAe,KAAK,CAAC"}
package/dist/ipdox.js CHANGED
@@ -1,21 +1,35 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
14
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_net_1 = require("node:net");
15
7
  const axios_1 = __importDefault(require("axios"));
16
- const apis_1 = require("./utils/apis");
8
+ const apis_js_1 = require("./utils/apis.js");
17
9
  const lru_cache_1 = require("lru-cache");
10
+ const DEFAULT_REQUEST_TIMEOUT_MS = 5000;
11
+ const DEFAULT_USER_AGENT = "node-ipdox";
12
+ const RETRY_BACKOFF_BASE_MS = 150;
13
+ const RETRY_BACKOFF_MAX_MS = 2000;
14
+ const PRIMARY_PROVIDERS = [
15
+ apis_js_1.GeoAPIs.IP_HYPHEN_API_DOT_COM,
16
+ apis_js_1.GeoAPIs.FREE_IP_API_DOT_COM,
17
+ apis_js_1.GeoAPIs.IPWHO_DOT_IS,
18
+ apis_js_1.GeoAPIs.IPAPI_DOT_CO
19
+ ];
20
+ const FALLBACK_PROVIDERS = [
21
+ apis_js_1.GeoAPIs.GEOIP_VUIZ_DOT_NET,
22
+ apis_js_1.GeoAPIs.APIP_DOT_CC,
23
+ apis_js_1.GeoAPIs.IP_SONAR_DOT_COM
24
+ ];
18
25
  class IPDox {
26
+ cache;
27
+ maxRetries;
28
+ requestTimeoutMs;
29
+ inFlight;
30
+ http;
31
+ ipApiKey;
32
+ unavailableProviders;
19
33
  /**
20
34
  * @description Creates an instance of IPDox.
21
35
  * @param {IPDOXConstructor} params
@@ -23,16 +37,29 @@ class IPDox {
23
37
  * @param {number} params.cacheMaxAge - The cache timeout in milliseconds (default: 43200000 (12 hours))
24
38
  * @param {number} params.maxRetries - The maximum number of retries (default: 10)
25
39
  */
26
- constructor({ cacheMaxItems = 1000, cacheMaxAge = 43200000, maxRetries = 10 } = {
40
+ constructor({ cacheMaxItems = 1000, cacheMaxAge = 43200000, maxRetries = 10, requestTimeoutMs = DEFAULT_REQUEST_TIMEOUT_MS, ipApiKey } = {
27
41
  cacheMaxItems: 1000,
28
42
  cacheMaxAge: 43200000,
29
- maxRetries: 10
43
+ maxRetries: 10,
44
+ requestTimeoutMs: DEFAULT_REQUEST_TIMEOUT_MS
30
45
  }) {
31
46
  this.cache = new lru_cache_1.LRUCache({
32
47
  max: cacheMaxItems,
33
- ttl: cacheMaxAge
48
+ ttl: cacheMaxAge,
49
+ ttlAutopurge: true
34
50
  });
35
51
  this.maxRetries = maxRetries;
52
+ this.requestTimeoutMs = requestTimeoutMs;
53
+ this.inFlight = new Map();
54
+ this.ipApiKey = typeof ipApiKey === "string" ? ipApiKey.trim() : undefined;
55
+ this.unavailableProviders = new Set();
56
+ this.http = axios_1.default.create({
57
+ timeout: this.requestTimeoutMs,
58
+ headers: {
59
+ "User-Agent": DEFAULT_USER_AGENT
60
+ },
61
+ validateStatus: status => status >= 200 && status < 500
62
+ });
36
63
  }
37
64
  /**
38
65
  * @description Get information about an IP address
@@ -41,169 +68,463 @@ class IPDox {
41
68
  * @returns {Promise<IPDOXResponse | undefined>} - Promise of the response or undefined
42
69
  * @memberof IPDox
43
70
  */
44
- doxIP(_a) {
45
- return __awaiter(this, arguments, void 0, function* ({ ip }) {
46
- // Check that the ip is valid
47
- if (!ip || ip === "") {
48
- return undefined;
49
- }
50
- // Check if the IP is already in the cache
51
- if (this.cache.has(ip)) {
52
- const cachedResponse = this.cache.get(ip);
53
- if (cachedResponse) {
54
- return cachedResponse;
71
+ async doxIP({ ip }) {
72
+ const normalizedIP = typeof ip === "string" ? ip.trim() : "";
73
+ // Check that the ip is valid
74
+ if (!normalizedIP || (0, node_net_1.isIP)(normalizedIP) === 0) {
75
+ return undefined;
76
+ }
77
+ // Check if the IP is already in the cache
78
+ const cachedResponse = this.cache.get(normalizedIP);
79
+ if (cachedResponse) {
80
+ return cachedResponse;
81
+ }
82
+ // Check if there's an ongoing request for the same IP
83
+ const inFlight = this.inFlight.get(normalizedIP);
84
+ if (inFlight) {
85
+ return inFlight;
86
+ }
87
+ const task = this.fetchWithRetries(normalizedIP);
88
+ this.inFlight.set(normalizedIP, task);
89
+ task.finally(() => this.inFlight.delete(normalizedIP));
90
+ return task;
91
+ }
92
+ shuffleProviders(providers, avoidFirst) {
93
+ const shuffled = [...providers];
94
+ for (let i = shuffled.length - 1; i > 0; i--) {
95
+ const j = Math.floor(Math.random() * (i + 1));
96
+ [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
97
+ }
98
+ if (avoidFirst && shuffled.length > 1 && shuffled[0] === avoidFirst) {
99
+ [shuffled[0], shuffled[1]] = [shuffled[1], shuffled[0]];
100
+ }
101
+ return shuffled;
102
+ }
103
+ async fetchWithRetries(ip) {
104
+ if (this.maxRetries <= 0) {
105
+ return undefined;
106
+ }
107
+ const primaryProviders = PRIMARY_PROVIDERS.filter(provider => !this.unavailableProviders.has(provider));
108
+ const fallbackProviders = FALLBACK_PROVIDERS.filter(provider => !this.unavailableProviders.has(provider));
109
+ const providers = primaryProviders.length > 0 || fallbackProviders.length > 0
110
+ ? { primary: primaryProviders, fallback: fallbackProviders }
111
+ : {
112
+ primary: Object.values(apis_js_1.GeoAPIs).filter(provider => !this.unavailableProviders.has(provider)),
113
+ fallback: []
114
+ };
115
+ let attempts = 0;
116
+ let order = [
117
+ ...this.shuffleProviders(providers.primary),
118
+ ...this.shuffleProviders(providers.fallback)
119
+ ];
120
+ let index = 0;
121
+ if (order.length === 0) {
122
+ return undefined;
123
+ }
124
+ while (attempts < this.maxRetries) {
125
+ if (index >= order.length) {
126
+ order = [
127
+ ...this.shuffleProviders(providers.primary),
128
+ ...this.shuffleProviders(providers.fallback)
129
+ ];
130
+ index = 0;
131
+ if (order.length === 0) {
132
+ return undefined;
55
133
  }
56
134
  }
57
- // Select a random API
58
- let randomAPI = this.selectRandomAPI();
59
- let response = null;
60
- let retries = 0;
61
- // Fetch data from the API
62
- while (!response && retries < this.maxRetries) {
63
- try {
64
- switch (randomAPI) {
65
- case apis_1.GeoAPIs.IP_HYPHEN_API_DOT_COM:
66
- response = yield this.fetchIPHyphenAPIDotCom(ip);
67
- break;
68
- case apis_1.GeoAPIs.FREE_IP_API_DOT_COM:
69
- response = yield this.fetchFreeIPAPIDotCom(ip);
70
- break;
71
- case apis_1.GeoAPIs.IPWHO_DOT_IS:
72
- response = yield this.fetchIPWhoDotIs(ip);
73
- break;
74
- case apis_1.GeoAPIs.IPAPI_DOT_CO:
75
- response = yield this.fetchIPAPIDotCo(ip);
76
- break;
77
- }
135
+ const provider = order[index];
136
+ index++;
137
+ if (this.unavailableProviders.has(provider)) {
138
+ attempts++;
139
+ continue;
140
+ }
141
+ try {
142
+ return await this.fetchFromProvider(provider, ip);
143
+ }
144
+ catch (error) {
145
+ this.noteProviderFailure(provider, error);
146
+ attempts++;
147
+ if (attempts < this.maxRetries) {
148
+ await this.waitWithJitter(attempts);
78
149
  }
79
- catch (error) {
80
- // If the promise is rejected, select another random API and try again
81
- randomAPI = this.selectRandomAPI();
82
- retries++;
150
+ }
151
+ }
152
+ return undefined;
153
+ }
154
+ async fetchFromProvider(provider, ip) {
155
+ switch (provider) {
156
+ case apis_js_1.GeoAPIs.IP_HYPHEN_API_DOT_COM:
157
+ return this.fetchIPHyphenAPIDotCom(ip);
158
+ case apis_js_1.GeoAPIs.FREE_IP_API_DOT_COM:
159
+ return this.fetchFreeIPAPIDotCom(ip);
160
+ case apis_js_1.GeoAPIs.IPWHO_DOT_IS:
161
+ return this.fetchIPWhoDotIs(ip);
162
+ case apis_js_1.GeoAPIs.IPAPI_DOT_CO:
163
+ return this.fetchIPAPIDotCo(ip);
164
+ case apis_js_1.GeoAPIs.GEOIP_VUIZ_DOT_NET:
165
+ return this.fetchGeoIPVuizDotNet(ip);
166
+ case apis_js_1.GeoAPIs.APIP_DOT_CC:
167
+ return this.fetchAPIPDotCC(ip);
168
+ case apis_js_1.GeoAPIs.IP_SONAR_DOT_COM:
169
+ return this.fetchIPSonarDotCom(ip);
170
+ default:
171
+ throw new Error("Unsupported provider");
172
+ }
173
+ }
174
+ async waitWithJitter(attempt) {
175
+ const baseDelay = Math.min(RETRY_BACKOFF_MAX_MS, RETRY_BACKOFF_BASE_MS * 2 ** Math.max(0, attempt - 1));
176
+ const jitter = Math.random() * baseDelay;
177
+ await new Promise(resolve => setTimeout(resolve, jitter));
178
+ }
179
+ noteProviderFailure(provider, error) {
180
+ if (provider === apis_js_1.GeoAPIs.IPAPI_DOT_CO && this.isDnsError(error)) {
181
+ this.unavailableProviders.add(provider);
182
+ }
183
+ }
184
+ isDnsError(error) {
185
+ if (!error || typeof error !== "object") {
186
+ return false;
187
+ }
188
+ const maybeError = error;
189
+ const code = maybeError.code ?? maybeError.cause?.code;
190
+ return code === "ENOTFOUND" || code === "EAI_AGAIN" || code === "ENODATA";
191
+ }
192
+ parseNumber(value) {
193
+ if (typeof value === "number" && Number.isFinite(value)) {
194
+ return value;
195
+ }
196
+ if (typeof value === "string") {
197
+ const trimmed = value.trim();
198
+ if (trimmed !== "") {
199
+ const parsed = Number.parseFloat(trimmed);
200
+ if (Number.isFinite(parsed)) {
201
+ return parsed;
83
202
  }
84
203
  }
85
- // If max retries reached and no response, return undefined
86
- if (retries === this.maxRetries && !response) {
87
- return undefined;
204
+ }
205
+ return undefined;
206
+ }
207
+ parseString(value) {
208
+ if (typeof value === "string") {
209
+ const trimmed = value.trim();
210
+ return trimmed === "" ? undefined : trimmed;
211
+ }
212
+ return undefined;
213
+ }
214
+ pickString(...values) {
215
+ for (const value of values) {
216
+ const parsed = this.parseString(value);
217
+ if (parsed) {
218
+ return parsed;
88
219
  }
89
- // Return the response
90
- return response ? response : undefined;
91
- });
220
+ }
221
+ return undefined;
92
222
  }
93
- selectRandomAPI() {
94
- // Get a random entry from the enum
95
- const randomEntry = Object.entries(apis_1.GeoAPIs)[Math.floor(Math.random() * Object.entries(apis_1.GeoAPIs).length)];
96
- // Return the random entry
97
- return randomEntry[1];
223
+ pickStringOrEmpty(...values) {
224
+ return this.pickString(...values) ?? "";
225
+ }
226
+ normalizeContinentCode(continentName) {
227
+ const name = this.parseString(continentName)?.toLowerCase();
228
+ if (!name) {
229
+ return undefined;
230
+ }
231
+ switch (name) {
232
+ case "north america":
233
+ return "NA";
234
+ case "south america":
235
+ return "SA";
236
+ case "europe":
237
+ return "EU";
238
+ case "africa":
239
+ return "AF";
240
+ case "asia":
241
+ return "AS";
242
+ case "oceania":
243
+ return "OC";
244
+ case "antarctica":
245
+ return "AN";
246
+ default:
247
+ return undefined;
248
+ }
98
249
  }
99
250
  cacheResponse(ip, response) {
100
251
  this.cache.set(ip, response);
101
252
  }
102
- fetchIPHyphenAPIDotCom(ip) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- const requestURL = apis_1.GeoAPIs.IP_HYPHEN_API_DOT_COM + ip + "?fields=24899583";
105
- const response = yield axios_1.default.get(requestURL);
106
- if (response.data.status === "success") {
107
- const formattedResponse = {
108
- ip: response.data.query,
109
- country: response.data.countryCode,
110
- city: response.data.city,
111
- continent: response.data.continentCode,
112
- latitude: response.data.lat,
113
- longitude: response.data.lon,
114
- zip: response.data.zip,
115
- isp: response.data.isp,
116
- proxy: response.data.proxy,
117
- isHosting: response.data.hosting,
118
- timeZone: response.data.timezone,
119
- source: "ip-api.com"
120
- };
121
- this.cacheResponse(ip, formattedResponse);
122
- return Promise.resolve(formattedResponse);
123
- }
124
- else {
125
- return Promise.reject();
126
- }
127
- });
253
+ async fetchIPHyphenAPIDotCom(ip) {
254
+ const baseURL = this.ipApiKey
255
+ ? "https://pro.ip-api.com/json/"
256
+ : apis_js_1.GeoAPIs.IP_HYPHEN_API_DOT_COM;
257
+ const requestURL = baseURL +
258
+ ip +
259
+ "?fields=24899583" +
260
+ (this.ipApiKey ? `&key=${encodeURIComponent(this.ipApiKey)}` : "");
261
+ const response = await this.http.get(requestURL);
262
+ if (response.data.status === "success") {
263
+ const zip = typeof response.data.zip === "string" && response.data.zip !== ""
264
+ ? response.data.zip
265
+ : undefined;
266
+ const isp = typeof response.data.isp === "string" && response.data.isp !== ""
267
+ ? response.data.isp
268
+ : undefined;
269
+ const proxy = typeof response.data.proxy === "boolean"
270
+ ? response.data.proxy
271
+ : undefined;
272
+ const isHosting = typeof response.data.hosting === "boolean"
273
+ ? response.data.hosting
274
+ : undefined;
275
+ const timeZone = typeof response.data.timezone === "string"
276
+ ? response.data.timezone
277
+ : undefined;
278
+ const formattedResponse = {
279
+ ip: response.data.query,
280
+ country: response.data.countryCode,
281
+ city: response.data.city,
282
+ continent: response.data.continentCode,
283
+ latitude: response.data.lat,
284
+ longitude: response.data.lon,
285
+ zip,
286
+ isp,
287
+ proxy,
288
+ isHosting,
289
+ timeZone,
290
+ source: "ip-api.com"
291
+ };
292
+ this.cacheResponse(ip, formattedResponse);
293
+ return Promise.resolve(formattedResponse);
294
+ }
295
+ else {
296
+ return Promise.reject();
297
+ }
128
298
  }
129
- fetchFreeIPAPIDotCom(ip) {
130
- return __awaiter(this, void 0, void 0, function* () {
131
- const requestURL = apis_1.GeoAPIs.FREE_IP_API_DOT_COM + ip;
132
- const response = yield axios_1.default.get(requestURL);
133
- if (response.data.ipVersion === 4) {
134
- const formattedResponse = {
135
- ip: response.data.ipAddress,
136
- country: response.data.countryCode,
137
- city: response.data.cityName,
138
- continent: response.data.continentCode,
139
- latitude: response.data.latitude,
140
- longitude: response.data.longitude,
141
- zip: response.data.zipCode,
142
- isp: response.data.isp,
143
- proxy: response.data.proxy,
144
- isHosting: response.data.hosting,
145
- timeZone: response.data.timeZones[0],
146
- source: "freeipapi.com"
147
- };
148
- this.cacheResponse(ip, formattedResponse);
149
- return Promise.resolve(formattedResponse);
150
- }
151
- else {
152
- return Promise.reject();
153
- }
154
- });
299
+ async fetchFreeIPAPIDotCom(ip) {
300
+ const requestURL = apis_js_1.GeoAPIs.FREE_IP_API_DOT_COM + ip;
301
+ const response = await this.http.get(requestURL);
302
+ if (response.data.ipVersion === 4 || response.data.ipVersion === 6) {
303
+ const zip = typeof response.data.zipCode === "string" &&
304
+ response.data.zipCode !== ""
305
+ ? response.data.zipCode
306
+ : undefined;
307
+ const isp = typeof response.data.isp === "string" && response.data.isp !== ""
308
+ ? response.data.isp
309
+ : undefined;
310
+ const proxy = typeof response.data.proxy === "boolean"
311
+ ? response.data.proxy
312
+ : undefined;
313
+ const isHosting = typeof response.data.hosting === "boolean"
314
+ ? response.data.hosting
315
+ : undefined;
316
+ const timeZone = Array.isArray(response.data.timeZones) &&
317
+ typeof response.data.timeZones[0] === "string"
318
+ ? response.data.timeZones[0]
319
+ : undefined;
320
+ const formattedResponse = {
321
+ ip: response.data.ipAddress,
322
+ country: response.data.countryCode,
323
+ city: response.data.cityName,
324
+ continent: response.data.continentCode,
325
+ latitude: response.data.latitude,
326
+ longitude: response.data.longitude,
327
+ zip,
328
+ isp,
329
+ proxy,
330
+ isHosting,
331
+ timeZone,
332
+ source: "freeipapi.com"
333
+ };
334
+ this.cacheResponse(ip, formattedResponse);
335
+ return Promise.resolve(formattedResponse);
336
+ }
337
+ else {
338
+ return Promise.reject();
339
+ }
155
340
  }
156
- fetchIPWhoDotIs(ip) {
157
- return __awaiter(this, void 0, void 0, function* () {
158
- const requestURL = apis_1.GeoAPIs.IPWHO_DOT_IS + ip;
159
- const response = yield axios_1.default.get(requestURL);
160
- if (response.data.success) {
161
- const formattedResponse = {
162
- ip: response.data.ip,
163
- country: response.data.country_code,
164
- city: response.data.city,
165
- continent: response.data.continent_code,
166
- latitude: response.data.latitude,
167
- longitude: response.data.longitude,
168
- zip: response.data.postal,
169
- isp: response.data.connection.isp,
170
- proxy: false,
171
- isHosting: false,
172
- timeZone: response.data.timezone.id,
173
- source: "ipwho.is"
174
- };
175
- this.cacheResponse(ip, formattedResponse);
176
- return Promise.resolve(formattedResponse);
177
- }
178
- else {
179
- return Promise.reject();
180
- }
181
- });
341
+ async fetchIPWhoDotIs(ip) {
342
+ const requestURL = apis_js_1.GeoAPIs.IPWHO_DOT_IS + ip;
343
+ const response = await this.http.get(requestURL);
344
+ if (response.data.success) {
345
+ const zip = typeof response.data.postal === "string" &&
346
+ response.data.postal !== ""
347
+ ? response.data.postal
348
+ : undefined;
349
+ const isp = typeof response.data.connection?.isp === "string" &&
350
+ response.data.connection.isp !== ""
351
+ ? response.data.connection.isp
352
+ : undefined;
353
+ const proxy = typeof response.data.proxy === "boolean"
354
+ ? response.data.proxy
355
+ : undefined;
356
+ const isHosting = typeof response.data.hosting === "boolean"
357
+ ? response.data.hosting
358
+ : undefined;
359
+ const timeZone = typeof response.data.timezone?.id === "string"
360
+ ? response.data.timezone.id
361
+ : typeof response.data.timezone === "string"
362
+ ? response.data.timezone
363
+ : undefined;
364
+ const formattedResponse = {
365
+ ip: response.data.ip,
366
+ country: response.data.country_code,
367
+ city: response.data.city,
368
+ continent: response.data.continent_code,
369
+ latitude: response.data.latitude,
370
+ longitude: response.data.longitude,
371
+ zip,
372
+ isp,
373
+ proxy,
374
+ isHosting,
375
+ timeZone,
376
+ source: "ipwho.is"
377
+ };
378
+ this.cacheResponse(ip, formattedResponse);
379
+ return Promise.resolve(formattedResponse);
380
+ }
381
+ else {
382
+ return Promise.reject();
383
+ }
182
384
  }
183
- fetchIPAPIDotCo(ip) {
184
- return __awaiter(this, void 0, void 0, function* () {
185
- const requestURL = apis_1.GeoAPIs.IPAPI_DOT_CO + ip + "/json";
186
- const response = yield axios_1.default.get(requestURL);
187
- if (response.data.ip) {
188
- const formattedResponse = {
189
- ip: response.data.ip,
190
- country: response.data.country_code,
191
- city: response.data.city,
192
- continent: response.data.continent_code,
193
- latitude: response.data.latitude,
194
- longitude: response.data.longitude,
195
- zip: response.data.postal,
196
- isp: response.data.org,
197
- timeZone: response.data.timezone,
198
- source: "ipapi.co"
199
- };
200
- this.cacheResponse(ip, formattedResponse);
201
- return Promise.resolve(formattedResponse);
202
- }
203
- else {
204
- return Promise.reject();
205
- }
206
- });
385
+ async fetchIPAPIDotCo(ip) {
386
+ const requestURL = apis_js_1.GeoAPIs.IPAPI_DOT_CO + ip + "/json";
387
+ const response = await this.http.get(requestURL);
388
+ if (response.data.ip) {
389
+ const zip = typeof response.data.postal === "string" &&
390
+ response.data.postal !== ""
391
+ ? response.data.postal
392
+ : undefined;
393
+ const isp = typeof response.data.org === "string" && response.data.org !== ""
394
+ ? response.data.org
395
+ : undefined;
396
+ const timeZone = typeof response.data.timezone === "string"
397
+ ? response.data.timezone
398
+ : undefined;
399
+ const formattedResponse = {
400
+ ip: response.data.ip,
401
+ country: response.data.country_code,
402
+ city: response.data.city,
403
+ continent: response.data.continent_code,
404
+ latitude: response.data.latitude,
405
+ longitude: response.data.longitude,
406
+ zip,
407
+ isp,
408
+ timeZone,
409
+ source: "ipapi.co"
410
+ };
411
+ this.cacheResponse(ip, formattedResponse);
412
+ return Promise.resolve(formattedResponse);
413
+ }
414
+ else {
415
+ return Promise.reject();
416
+ }
417
+ }
418
+ async fetchGeoIPVuizDotNet(ip) {
419
+ const requestURL = apis_js_1.GeoAPIs.GEOIP_VUIZ_DOT_NET + "?ip=" + encodeURIComponent(ip);
420
+ const response = await this.http.get(requestURL);
421
+ const data = response.data;
422
+ const responseIP = this.parseString(data?.ip) ?? ip;
423
+ const country = this.pickString(data?.country_code, data?.countryCode);
424
+ const city = this.pickStringOrEmpty(data?.city, data?.region, data?.country, data?.country_name);
425
+ const continent = this.pickString(data?.continent_code, data?.continentCode) ??
426
+ this.normalizeContinentCode(data?.continent);
427
+ const latitude = this.parseNumber(data?.latitude ?? data?.lat);
428
+ const longitude = this.parseNumber(data?.longitude ?? data?.lon);
429
+ if (responseIP &&
430
+ country &&
431
+ continent &&
432
+ latitude !== undefined &&
433
+ longitude !== undefined) {
434
+ const zip = this.pickString(data?.postal_code, data?.zip);
435
+ const isp = this.pickString(data?.isp, data?.organization, data?.asn_organization);
436
+ const timeZone = this.pickString(data?.timezone);
437
+ const formattedResponse = {
438
+ ip: responseIP,
439
+ country,
440
+ city,
441
+ continent,
442
+ latitude,
443
+ longitude,
444
+ zip,
445
+ isp,
446
+ timeZone,
447
+ source: "geoip.vuiz.net"
448
+ };
449
+ this.cacheResponse(ip, formattedResponse);
450
+ return Promise.resolve(formattedResponse);
451
+ }
452
+ return Promise.reject();
453
+ }
454
+ async fetchAPIPDotCC(ip) {
455
+ const requestURL = apis_js_1.GeoAPIs.APIP_DOT_CC + encodeURIComponent(ip);
456
+ const response = await this.http.get(requestURL);
457
+ const data = response.data;
458
+ if (data?.status && data.status !== "success") {
459
+ return Promise.reject();
460
+ }
461
+ const responseIP = this.parseString(data?.ip) ?? ip;
462
+ const country = this.parseString(data?.CountryCode);
463
+ const city = this.pickStringOrEmpty(data?.City, data?.RegionName, data?.CountryName);
464
+ const continent = this.parseString(data?.ContinentCode) ??
465
+ this.normalizeContinentCode(data?.ContinentName);
466
+ const latitude = this.parseNumber(data?.Latitude);
467
+ const longitude = this.parseNumber(data?.Longitude);
468
+ if (responseIP &&
469
+ country &&
470
+ continent &&
471
+ latitude !== undefined &&
472
+ longitude !== undefined) {
473
+ const zip = this.parseString(data?.Postal);
474
+ const isp = this.parseString(data?.org) ||
475
+ this.parseString(data?.Org) ||
476
+ this.parseString(data?.ISP);
477
+ const timeZone = this.parseString(data?.TimeZone);
478
+ const formattedResponse = {
479
+ ip: responseIP,
480
+ country,
481
+ city,
482
+ continent,
483
+ latitude,
484
+ longitude,
485
+ zip,
486
+ isp,
487
+ timeZone,
488
+ source: "apip.cc"
489
+ };
490
+ this.cacheResponse(ip, formattedResponse);
491
+ return Promise.resolve(formattedResponse);
492
+ }
493
+ return Promise.reject();
494
+ }
495
+ async fetchIPSonarDotCom(ip) {
496
+ const requestURL = apis_js_1.GeoAPIs.IP_SONAR_DOT_COM + encodeURIComponent(ip);
497
+ const response = await this.http.get(requestURL);
498
+ const data = response.data;
499
+ const responseIP = this.parseString(data?.ip) ?? ip;
500
+ const country = this.parseString(data?.country_code);
501
+ const city = this.pickStringOrEmpty(data?.city_name, data?.region_name, data?.country_name);
502
+ const continent = this.parseString(data?.continent_code);
503
+ const latitude = this.parseNumber(data?.latitude);
504
+ const longitude = this.parseNumber(data?.longitude);
505
+ if (responseIP &&
506
+ country &&
507
+ continent &&
508
+ latitude !== undefined &&
509
+ longitude !== undefined) {
510
+ const zip = this.parseString(data?.postal_code);
511
+ const timeZone = this.parseString(data?.timezone);
512
+ const formattedResponse = {
513
+ ip: responseIP,
514
+ country,
515
+ city,
516
+ continent,
517
+ latitude,
518
+ longitude,
519
+ zip,
520
+ timeZone,
521
+ source: "ip-sonar.com"
522
+ };
523
+ this.cacheResponse(ip, formattedResponse);
524
+ return Promise.resolve(formattedResponse);
525
+ }
526
+ return Promise.reject();
207
527
  }
208
528
  }
209
529
  exports.default = IPDox;
530
+ //# sourceMappingURL=ipdox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ipdox.js","sourceRoot":"","sources":["../src/ipdox.ts"],"names":[],"mappings":";;;;;AAAA,uCAAgC;AAChC,kDAAkD;AAIlD,6CAA0C;AAC1C,yCAAqC;AAErC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AACxC,MAAM,kBAAkB,GAAG,YAAY,CAAC;AACxC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,MAAM,iBAAiB,GAAc;IACpC,iBAAO,CAAC,qBAAqB;IAC7B,iBAAO,CAAC,mBAAmB;IAC3B,iBAAO,CAAC,YAAY;IACpB,iBAAO,CAAC,YAAY;CACpB,CAAC;AACF,MAAM,kBAAkB,GAAc;IACrC,iBAAO,CAAC,kBAAkB;IAC1B,iBAAO,CAAC,WAAW;IACnB,iBAAO,CAAC,gBAAgB;CACxB,CAAC;AAEF,MAAM,KAAK;IACF,KAAK,CAAkC;IACvC,UAAU,CAAS;IACnB,gBAAgB,CAAS;IACzB,QAAQ,CAAkD;IAC1D,IAAI,CAAgB;IACpB,QAAQ,CAAU;IAClB,oBAAoB,CAAe;IAE3C;;;;;;OAMG;IACH,YACC,EACC,aAAa,GAAG,IAAI,EACpB,WAAW,GAAG,QAAQ,EACtB,UAAU,GAAG,EAAE,EACf,gBAAgB,GAAG,0BAA0B,EAC7C,QAAQ,KACa;QACrB,aAAa,EAAE,IAAI;QACnB,WAAW,EAAE,QAAQ;QACrB,UAAU,EAAE,EAAE;QACd,gBAAgB,EAAE,0BAA0B;KAC5C;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,oBAAQ,CAAwB;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zD,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAClD,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAEpD,IACC,UAAU;YACV,OAAO;YACP,SAAS;YACT,QAAQ,KAAK,SAAS;YACtB,SAAS,KAAK,SAAS,EACtB,CAAC;YACF,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAElD,MAAM,iBAAiB,GAAkB;gBACxC,EAAE,EAAE,UAAU;gBACd,OAAO;gBACP,IAAI;gBACJ,SAAS;gBACT,QAAQ;gBACR,SAAS;gBACT,GAAG;gBACH,QAAQ;gBACR,MAAM,EAAE,cAAc;aACtB,CAAC;YAEF,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC;YAE1C,OAAO,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;CACD;AAED,kBAAe,KAAK,CAAC"}
@@ -5,9 +5,14 @@
5
5
  * @property {number} cacheMaxItems The maximum number of items in the cache (default: 1000)
6
6
  * @property {number} cacheMaxAge The cache timeout in milliseconds (default: 43200000 (12 hours))
7
7
  * @property {number} maxRetries The maximum number of retries (default: 10)
8
+ * @property {number} requestTimeoutMs Request timeout in milliseconds (default: 5000)
9
+ * @property {string} ipApiKey Optional ip-api.com pro API key for HTTPS
8
10
  */
9
11
  export interface IPDOXConstructor {
10
12
  cacheMaxItems?: number;
11
13
  cacheMaxAge?: number;
12
14
  maxRetries?: number;
15
+ requestTimeoutMs?: number;
16
+ ipApiKey?: string;
13
17
  }
18
+ //# sourceMappingURL=IPDOXConstructor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPDOXConstructor.d.ts","sourceRoot":"","sources":["../../src/types/IPDOXConstructor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB"}
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IPDOXConstructor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPDOXConstructor.js","sourceRoot":"","sources":["../../src/types/IPDOXConstructor.ts"],"names":[],"mappings":""}
@@ -7,3 +7,4 @@
7
7
  export interface IPDOXRequest {
8
8
  ip: string;
9
9
  }
10
+ //# sourceMappingURL=IPDOXRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPDOXRequest.d.ts","sourceRoot":"","sources":["../../src/types/IPDOXRequest.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC5B,EAAE,EAAE,MAAM,CAAC;CACX"}
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IPDOXRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPDOXRequest.js","sourceRoot":"","sources":["../../src/types/IPDOXRequest.ts"],"names":[],"mappings":""}
@@ -8,8 +8,8 @@
8
8
  * @property {string} continent The continent (ISO 3166)
9
9
  * @property {number} latitude The latitude
10
10
  * @property {number} longitude The longitude
11
- * @property {string} zip The ZIP code
12
- * @property {string} isp The ISP (Internet Service Provider)
11
+ * @property {string} zip The ZIP code (might be undefined)
12
+ * @property {string} isp The ISP (Internet Service Provider) (might be undefined)
13
13
  * @property {boolean} proxy Is the IP address a proxy?
14
14
  * @property {boolean} isHosting Is the IP address a hosting provider?
15
15
  * @property {object} proxyInfo Information about the proxy
@@ -26,8 +26,8 @@ export interface IPDOXResponse {
26
26
  continent: string;
27
27
  latitude: number;
28
28
  longitude: number;
29
- zip: string;
30
- isp: string;
29
+ zip?: string;
30
+ isp?: string;
31
31
  proxy?: boolean;
32
32
  isHosting?: boolean;
33
33
  proxyInfo?: {
@@ -38,3 +38,4 @@ export interface IPDOXResponse {
38
38
  timeZone?: string;
39
39
  source: string;
40
40
  }
41
+ //# sourceMappingURL=IPDOXResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPDOXResponse.d.ts","sourceRoot":"","sources":["../../src/types/IPDOXResponse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,aAAa;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE;QACX,KAAK,EAAE,OAAO,CAAC;QACf,KAAK,EAAE,OAAO,CAAC;QACf,OAAO,EAAE,OAAO,CAAC;KACjB,CAAC;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CACf"}
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=IPDOXResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPDOXResponse.js","sourceRoot":"","sources":["../../src/types/IPDOXResponse.ts"],"names":[],"mappings":""}
@@ -2,5 +2,9 @@ export declare enum GeoAPIs {
2
2
  IP_HYPHEN_API_DOT_COM = "http://ip-api.com/json/",
3
3
  FREE_IP_API_DOT_COM = "https://freeipapi.com/api/json/",
4
4
  IPWHO_DOT_IS = "https://ipwho.is/",
5
- IPAPI_DOT_CO = "https://ipapi.co/"
5
+ IPAPI_DOT_CO = "https://ipapi.co/",
6
+ GEOIP_VUIZ_DOT_NET = "https://geoip.vuiz.net/geoip",
7
+ APIP_DOT_CC = "https://apip.cc/api-json/",
8
+ IP_SONAR_DOT_COM = "https://api.ip-sonar.com/v1/"
6
9
  }
10
+ //# sourceMappingURL=apis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apis.d.ts","sourceRoot":"","sources":["../../src/utils/apis.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO;IAClB,qBAAqB,4BAA4B;IACjD,mBAAmB,oCAAoC;IACvD,YAAY,sBAAsB;IAClC,YAAY,sBAAsB;IAClC,kBAAkB,iCAAiC;IACnD,WAAW,8BAA8B;IACzC,gBAAgB,iCAAiC;CACjD"}
@@ -7,4 +7,8 @@ var GeoAPIs;
7
7
  GeoAPIs["FREE_IP_API_DOT_COM"] = "https://freeipapi.com/api/json/";
8
8
  GeoAPIs["IPWHO_DOT_IS"] = "https://ipwho.is/";
9
9
  GeoAPIs["IPAPI_DOT_CO"] = "https://ipapi.co/";
10
+ GeoAPIs["GEOIP_VUIZ_DOT_NET"] = "https://geoip.vuiz.net/geoip";
11
+ GeoAPIs["APIP_DOT_CC"] = "https://apip.cc/api-json/";
12
+ GeoAPIs["IP_SONAR_DOT_COM"] = "https://api.ip-sonar.com/v1/";
10
13
  })(GeoAPIs || (exports.GeoAPIs = GeoAPIs = {}));
14
+ //# sourceMappingURL=apis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apis.js","sourceRoot":"","sources":["../../src/utils/apis.ts"],"names":[],"mappings":";;;AAAA,IAAY,OAQX;AARD,WAAY,OAAO;IAClB,4DAAiD,CAAA;IACjD,kEAAuD,CAAA;IACvD,6CAAkC,CAAA;IAClC,6CAAkC,CAAA;IAClC,8DAAmD,CAAA;IACnD,oDAAyC,CAAA;IACzC,4DAAiD,CAAA;AAClD,CAAC,EARW,OAAO,uBAAP,OAAO,QAQlB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-ipdox",
3
- "version": "1.0.5",
3
+ "version": "1.1.0",
4
4
  "description": "node-ipdox is a Node.js library for GeoIP lookup, leveraging various free GeoIP APIs. It provides a unified response format and incorporates local caching to minimize duplicate requests.",
5
5
  "author": "Mikel Calvo <contact@mikecalvo.net> (www.mikelcalvo.net)",
6
6
  "keywords": [
@@ -14,11 +14,22 @@
14
14
  ],
15
15
  "license": "ISC",
16
16
  "readmeFilename": "README.md",
17
- "homepage": "https://github.com/mikelcalvo/ipdox#readme",
18
- "bugs": { "url": "https://github.com/mikelcalvo/ipdox/issues" },
17
+ "homepage": "https://github.com/MikelCalvo/ipdox#readme",
18
+ "bugs": {
19
+ "url": "https://github.com/MikelCalvo/ipdox/issues"
20
+ },
19
21
  "main": "./dist/index.js",
20
22
  "types": "./dist/index.d.ts",
21
- "files": ["dist"],
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "require": "./dist/index.js",
27
+ "import": "./dist/index.js"
28
+ }
29
+ },
30
+ "files": [
31
+ "dist"
32
+ ],
22
33
  "scripts": {
23
34
  "test": "vitest run",
24
35
  "test:watch": "vitest",
@@ -28,13 +39,20 @@
28
39
  },
29
40
  "repository": {
30
41
  "type": "git",
31
- "url": "git+https://github.com/mikelcalvo/node-ipdox.git"
42
+ "url": "git+https://github.com/MikelCalvo/node-ipdox.git"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public",
46
+ "provenance": true
47
+ },
48
+ "dependencies": {
49
+ "axios": "1.13.4",
50
+ "lru-cache": "^11.2.5"
32
51
  },
33
- "dependencies": { "axios": "1.11.0", "lru-cache": "^11.1.0" },
34
52
  "devDependencies": {
35
- "@types/node": "24.3.0",
36
- "prettier": "3.6.2",
37
- "typescript": "^5.9.2",
38
- "vitest": "3.2.4"
53
+ "@types/node": "25.2.1",
54
+ "prettier": "3.8.1",
55
+ "typescript": "^5.9.3",
56
+ "vitest": "4.0.18"
39
57
  }
40
58
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,50 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const vitest_1 = require("vitest");
13
- const index_1 = require("../index");
14
- const RUN = process.env.RUN_INTEGRATION === "1";
15
- const TEST_IP = process.env.TEST_IP || "8.8.8.8";
16
- // Run only when explicitly enabled
17
- (RUN ? vitest_1.describe : vitest_1.describe.skip)("Integration: real providers", () => {
18
- (0, vitest_1.it)("ipwho.is", () => __awaiter(void 0, void 0, void 0, function* () {
19
- const ipdox = new index_1.IPDox({ maxRetries: 1 });
20
- // @ts-expect-error call provider directly to avoid randomness
21
- const r = yield ipdox.fetchIPWhoDotIs(TEST_IP);
22
- (0, vitest_1.expect)(r).toBeTruthy();
23
- (0, vitest_1.expect)(r.source).toBe("ipwho.is");
24
- (0, vitest_1.expect)(r.ip).toBeTypeOf("string");
25
- }), 20000);
26
- (0, vitest_1.it)("ip-api.com", () => __awaiter(void 0, void 0, void 0, function* () {
27
- const ipdox = new index_1.IPDox({ maxRetries: 1 });
28
- // @ts-expect-error call provider directly to avoid randomness
29
- const r = yield ipdox.fetchIPHyphenAPIDotCom(TEST_IP);
30
- (0, vitest_1.expect)(r).toBeTruthy();
31
- (0, vitest_1.expect)(r.source).toBe("ip-api.com");
32
- (0, vitest_1.expect)(r.ip).toBeTypeOf("string");
33
- }), 20000);
34
- (0, vitest_1.it)("freeipapi.com", () => __awaiter(void 0, void 0, void 0, function* () {
35
- const ipdox = new index_1.IPDox({ maxRetries: 1 });
36
- // @ts-expect-error call provider directly to avoid randomness
37
- const r = yield ipdox.fetchFreeIPAPIDotCom(TEST_IP);
38
- (0, vitest_1.expect)(r).toBeTruthy();
39
- (0, vitest_1.expect)(r.source).toBe("freeipapi.com");
40
- (0, vitest_1.expect)(r.ip).toBeTypeOf("string");
41
- }), 20000);
42
- (0, vitest_1.it)("ipapi.co", () => __awaiter(void 0, void 0, void 0, function* () {
43
- const ipdox = new index_1.IPDox({ maxRetries: 1 });
44
- // @ts-expect-error call provider directly to avoid randomness
45
- const r = yield ipdox.fetchIPAPIDotCo(TEST_IP);
46
- (0, vitest_1.expect)(r).toBeTruthy();
47
- (0, vitest_1.expect)(r.source).toBe("ipapi.co");
48
- (0, vitest_1.expect)(r.ip).toBeTypeOf("string");
49
- }), 20000);
50
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,86 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const vitest_1 = require("vitest");
16
- const axios_1 = __importDefault(require("axios"));
17
- const index_1 = require("./index");
18
- vitest_1.vi.mock("axios");
19
- const mockedAxios = axios_1.default;
20
- (0, vitest_1.describe)("IPDox", () => {
21
- (0, vitest_1.beforeEach)(() => {
22
- vitest_1.vi.clearAllMocks();
23
- });
24
- (0, vitest_1.it)("returns undefined for empty ip", () => __awaiter(void 0, void 0, void 0, function* () {
25
- const ipdox = new index_1.IPDox();
26
- const res = yield ipdox.doxIP({ ip: "" });
27
- (0, vitest_1.expect)(res).toBeUndefined();
28
- }));
29
- (0, vitest_1.it)("formats response from ipwho.is provider", () => __awaiter(void 0, void 0, void 0, function* () {
30
- const ipdox = new index_1.IPDox({ maxRetries: 1 });
31
- mockedAxios.get = vitest_1.vi.fn().mockResolvedValue({
32
- data: {
33
- success: true,
34
- ip: "8.8.8.8",
35
- country_code: "US",
36
- city: "Mountain View",
37
- continent_code: "NA",
38
- latitude: 37.386,
39
- longitude: -122.0838,
40
- postal: "94039",
41
- connection: { isp: "Google LLC" },
42
- timezone: { id: "America/Los_Angeles" }
43
- }
44
- });
45
- // Call provider directly to avoid randomness
46
- // @ts-expect-error Accessing class method for test
47
- const r = yield ipdox.fetchIPWhoDotIs("8.8.8.8");
48
- (0, vitest_1.expect)(r).toMatchObject({
49
- ip: "8.8.8.8",
50
- country: "US",
51
- city: "Mountain View",
52
- continent: "NA",
53
- latitude: 37.386,
54
- longitude: -122.0838,
55
- zip: "94039",
56
- isp: "Google LLC",
57
- timeZone: "America/Los_Angeles",
58
- source: "ipwho.is"
59
- });
60
- }));
61
- (0, vitest_1.it)("caches responses by ip", () => __awaiter(void 0, void 0, void 0, function* () {
62
- const ipdox = new index_1.IPDox({ maxRetries: 1 });
63
- mockedAxios.get = vitest_1.vi.fn().mockResolvedValue({
64
- data: {
65
- success: true,
66
- ip: "1.1.1.1",
67
- country_code: "AU",
68
- city: "Sydney",
69
- continent_code: "OC",
70
- latitude: -33.86,
71
- longitude: 151.21,
72
- postal: "2000",
73
- connection: { isp: "Cloudflare" },
74
- timezone: { id: "Australia/Sydney" }
75
- }
76
- });
77
- // @ts-expect-error Accessing class method for test
78
- const r1 = yield ipdox.fetchIPWhoDotIs("1.1.1.1");
79
- (0, vitest_1.expect)(r1).toBeTruthy();
80
- // Second call should be served from cache; axios.get should not be called again if provider is called through cache path
81
- // @ts-expect-error Use cache via public doxIP path
82
- ipdox.cache.set("1.1.1.1", r1);
83
- const r2 = yield ipdox.doxIP({ ip: "1.1.1.1" });
84
- (0, vitest_1.expect)(r2).toEqual(r1);
85
- }));
86
- });