ip-finder-client 1.0.0 → 1.0.1

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
@@ -1,6 +1,6 @@
1
1
  # ip-finder-client
2
2
 
3
- A lightweight, zero-dependency Node.js client for the IP Finder API. Get IP geolocation, ASN information, and network details with ease.
3
+ A lightweight, zero-dependency Node.js SDK for IP geolocation, ASN lookup, and network information.
4
4
 
5
5
  ## Installation
6
6
 
@@ -19,9 +19,9 @@ pnpm add ip-finder-client
19
19
  ## Quick Start
20
20
 
21
21
  ```typescript
22
- import { IPFinder } from 'ip-finder-client';
22
+ import { IPInsight } from 'ip-finder-client';
23
23
 
24
- const client = new IPFinder({
24
+ const client = new IPInsight({
25
25
  apiKey: 'your-api-key',
26
26
  baseUrl: 'https://api.your-domain.com' // Your API endpoint
27
27
  });
@@ -37,7 +37,7 @@ console.log(result.asn?.organization); // "Google LLC"
37
37
  ## Configuration
38
38
 
39
39
  ```typescript
40
- const client = new IPFinder({
40
+ const client = new IPInsight({
41
41
  // Required: Your API key
42
42
  apiKey: 'your-api-key',
43
43
 
@@ -101,7 +101,7 @@ Look up multiple IP addresses in parallel.
101
101
  const results = await client.lookupBatch(['8.8.8.8', '1.1.1.1', '9.9.9.9']);
102
102
 
103
103
  results.forEach(result => {
104
- if (result instanceof IPFinderError) {
104
+ if (result instanceof IPInsightError) {
105
105
  console.error(`Error: ${result.message}`);
106
106
  } else {
107
107
  console.log(`${result.ip}: ${result.geo?.country}`);
@@ -132,12 +132,12 @@ console.log(client.rateLimit);
132
132
  ## Error Handling
133
133
 
134
134
  ```typescript
135
- import { IPFinder, IPFinderError } from 'ip-finder-client';
135
+ import { IPInsight, IPInsightError } from 'ip-finder-client';
136
136
 
137
137
  try {
138
138
  const result = await client.lookup('invalid-ip');
139
139
  } catch (error) {
140
- if (error instanceof IPFinderError) {
140
+ if (error instanceof IPInsightError) {
141
141
  console.error(`API Error: ${error.message}`);
142
142
  console.error(`Status Code: ${error.statusCode}`);
143
143
  console.error(`Error Code: ${error.code}`);
@@ -166,9 +166,9 @@ try {
166
166
  ## CommonJS Usage
167
167
 
168
168
  ```javascript
169
- const { IPFinder } = require('ip-finder-client');
169
+ const { IPInsight } = require('ip-finder-client');
170
170
 
171
- const client = new IPFinder({ apiKey: 'your-api-key' });
171
+ const client = new IPInsight({ apiKey: 'your-api-key' });
172
172
  ```
173
173
 
174
174
  ## Factory Function
package/dist/index.d.ts CHANGED
@@ -1,26 +1,26 @@
1
1
  import type { IPFinderConfig, IPLookupResult, APIError, RateLimitInfo, GeoLocation, ASNInfo, NetworkInfo } from './types';
2
2
  export type { IPFinderConfig, IPLookupResult, APIError, RateLimitInfo, GeoLocation, ASNInfo, NetworkInfo, };
3
3
  /**
4
- * Custom error class for IP Finder API errors
4
+ * Custom error class for IPInsight API errors
5
5
  */
6
- export declare class IPFinderError extends Error {
6
+ export declare class IPInsightError extends Error {
7
7
  readonly statusCode: number;
8
8
  readonly code?: string;
9
9
  constructor(message: string, statusCode: number, code?: string);
10
10
  }
11
11
  /**
12
- * IP Finder client for looking up IP address information
12
+ * IPInsight client for looking up IP address information
13
13
  *
14
14
  * @example
15
15
  * ```ts
16
- * import { IPFinder } from 'ip-finder-client';
16
+ * import { IPInsight } from 'ip-finder-client';
17
17
  *
18
- * const client = new IPFinder({ apiKey: 'your-api-key' });
18
+ * const client = new IPInsight({ apiKey: 'your-api-key' });
19
19
  * const result = await client.lookup('8.8.8.8');
20
20
  * console.log(result.geo?.country); // "United States"
21
21
  * ```
22
22
  */
23
- export declare class IPFinder {
23
+ export declare class IPInsight {
24
24
  private readonly apiKey;
25
25
  private readonly baseUrl;
26
26
  private readonly timeout;
@@ -62,7 +62,7 @@ export declare class IPFinder {
62
62
  * results.forEach(r => console.log(r.ip, r.geo?.country));
63
63
  * ```
64
64
  */
65
- lookupBatch(ips: string[]): Promise<(IPLookupResult | IPFinderError)[]>;
65
+ lookupBatch(ips: string[]): Promise<(IPLookupResult | IPInsightError)[]>;
66
66
  /**
67
67
  * Check if the API is healthy and reachable
68
68
  *
@@ -74,10 +74,10 @@ export declare class IPFinder {
74
74
  private sleep;
75
75
  }
76
76
  /**
77
- * Create a new IP Finder client instance
77
+ * Create a new IPInsight client instance
78
78
  *
79
79
  * @param config - Client configuration
80
- * @returns New IPFinder instance
80
+ * @returns New IPInsight instance
81
81
  *
82
82
  * @example
83
83
  * ```ts
@@ -91,6 +91,6 @@ export declare class IPFinder {
91
91
  * const result = await client.lookup('8.8.8.8');
92
92
  * ```
93
93
  */
94
- export declare function createClient(config: IPFinderConfig): IPFinder;
95
- export default IPFinder;
94
+ export declare function createClient(config: IPFinderConfig): IPInsight;
95
+ export default IPInsight;
96
96
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,QAAQ,EACR,aAAa,EACb,WAAW,EACX,OAAO,EACP,WAAW,EACZ,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,cAAc,EACd,cAAc,EACd,QAAQ,EACR,aAAa,EACb,WAAW,EACX,OAAO,EACP,WAAW,GACZ,CAAC;AAMF;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAO/D;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC,4CAA4C;I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,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC,4CAA4C;IACrC,SAAS,CAAC,EAAE,aAAa,CAAC;gBAErB,MAAM,EAAE,cAAc;IAWlC;;;;;;;;;;;;;OAaG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA+BjD;;;;;OAKG;IACG,UAAU,IAAI,OAAO,CAAC,cAAc,CAAC;IAO3C;;;;;;;;;;;OAWG;IACG,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,cAAc,GAAG,cAAc,CAAC,EAAE,CAAC;IAqB9E;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;YAgBvB,KAAK;IAuDnB,OAAO,CAAC,qBAAqB;IAc7B,OAAO,CAAC,KAAK;CAGd;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,CAE9D;AAGD,eAAe,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -20,8 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
- IPFinder: () => IPFinder,
24
- IPFinderError: () => IPFinderError,
23
+ IPInsight: () => IPInsight,
24
+ IPInsightError: () => IPInsightError,
25
25
  createClient: () => createClient,
26
26
  default: () => src_default
27
27
  });
@@ -29,18 +29,18 @@ module.exports = __toCommonJS(src_exports);
29
29
  var DEFAULT_BASE_URL = "https://your-api-domain.com";
30
30
  var DEFAULT_TIMEOUT = 1e4;
31
31
  var DEFAULT_RETRIES = 2;
32
- var IPFinderError = class _IPFinderError extends Error {
32
+ var IPInsightError = class _IPInsightError extends Error {
33
33
  statusCode;
34
34
  code;
35
35
  constructor(message, statusCode, code) {
36
36
  super(message);
37
- this.name = "IPFinderError";
37
+ this.name = "IPInsightError";
38
38
  this.statusCode = statusCode;
39
39
  this.code = code;
40
- Object.setPrototypeOf(this, _IPFinderError.prototype);
40
+ Object.setPrototypeOf(this, _IPInsightError.prototype);
41
41
  }
42
42
  };
43
- var IPFinder = class {
43
+ var IPInsight = class {
44
44
  apiKey;
45
45
  baseUrl;
46
46
  timeout;
@@ -82,7 +82,7 @@ var IPFinder = class {
82
82
  return response;
83
83
  } catch (err) {
84
84
  lastError = err;
85
- if (err instanceof IPFinderError && err.statusCode >= 400 && err.statusCode < 500) {
85
+ if (err instanceof IPInsightError && err.statusCode >= 400 && err.statusCode < 500) {
86
86
  throw err;
87
87
  }
88
88
  if (attempt < this.retries) {
@@ -124,10 +124,10 @@ var IPFinder = class {
124
124
  return result.value;
125
125
  }
126
126
  const err = result.reason;
127
- if (err instanceof IPFinderError) {
127
+ if (err instanceof IPInsightError) {
128
128
  return err;
129
129
  }
130
- return new IPFinderError(
130
+ return new IPInsightError(
131
131
  err?.message || "Unknown error",
132
132
  0,
133
133
  "BATCH_ERROR"
@@ -173,7 +173,7 @@ var IPFinder = class {
173
173
  errorBody = await response.json();
174
174
  } catch {
175
175
  }
176
- throw new IPFinderError(
176
+ throw new IPInsightError(
177
177
  errorBody?.error || `HTTP ${response.status}`,
178
178
  response.status,
179
179
  errorBody?.code
@@ -183,16 +183,16 @@ var IPFinder = class {
183
183
  return data;
184
184
  } catch (err) {
185
185
  clearTimeout(timeoutId);
186
- if (err instanceof IPFinderError) {
186
+ if (err instanceof IPInsightError) {
187
187
  throw err;
188
188
  }
189
189
  if (err instanceof Error) {
190
190
  if (err.name === "AbortError") {
191
- throw new IPFinderError("Request timeout", 408, "TIMEOUT");
191
+ throw new IPInsightError("Request timeout", 408, "TIMEOUT");
192
192
  }
193
- throw new IPFinderError(err.message, 0, "NETWORK_ERROR");
193
+ throw new IPInsightError(err.message, 0, "NETWORK_ERROR");
194
194
  }
195
- throw new IPFinderError("Unknown error", 0, "UNKNOWN");
195
+ throw new IPInsightError("Unknown error", 0, "UNKNOWN");
196
196
  }
197
197
  }
198
198
  parseRateLimitHeaders(headers) {
@@ -212,12 +212,12 @@ var IPFinder = class {
212
212
  }
213
213
  };
214
214
  function createClient(config) {
215
- return new IPFinder(config);
215
+ return new IPInsight(config);
216
216
  }
217
- var src_default = IPFinder;
217
+ var src_default = IPInsight;
218
218
  // Annotate the CommonJS export names for ESM import in node:
219
219
  0 && (module.exports = {
220
- IPFinder,
221
- IPFinderError,
220
+ IPInsight,
221
+ IPInsightError,
222
222
  createClient
223
223
  });
package/dist/index.mjs CHANGED
@@ -2,18 +2,18 @@
2
2
  var DEFAULT_BASE_URL = "https://your-api-domain.com";
3
3
  var DEFAULT_TIMEOUT = 1e4;
4
4
  var DEFAULT_RETRIES = 2;
5
- var IPFinderError = class _IPFinderError extends Error {
5
+ var IPInsightError = class _IPInsightError extends Error {
6
6
  statusCode;
7
7
  code;
8
8
  constructor(message, statusCode, code) {
9
9
  super(message);
10
- this.name = "IPFinderError";
10
+ this.name = "IPInsightError";
11
11
  this.statusCode = statusCode;
12
12
  this.code = code;
13
- Object.setPrototypeOf(this, _IPFinderError.prototype);
13
+ Object.setPrototypeOf(this, _IPInsightError.prototype);
14
14
  }
15
15
  };
16
- var IPFinder = class {
16
+ var IPInsight = class {
17
17
  apiKey;
18
18
  baseUrl;
19
19
  timeout;
@@ -55,7 +55,7 @@ var IPFinder = class {
55
55
  return response;
56
56
  } catch (err) {
57
57
  lastError = err;
58
- if (err instanceof IPFinderError && err.statusCode >= 400 && err.statusCode < 500) {
58
+ if (err instanceof IPInsightError && err.statusCode >= 400 && err.statusCode < 500) {
59
59
  throw err;
60
60
  }
61
61
  if (attempt < this.retries) {
@@ -97,10 +97,10 @@ var IPFinder = class {
97
97
  return result.value;
98
98
  }
99
99
  const err = result.reason;
100
- if (err instanceof IPFinderError) {
100
+ if (err instanceof IPInsightError) {
101
101
  return err;
102
102
  }
103
- return new IPFinderError(
103
+ return new IPInsightError(
104
104
  err?.message || "Unknown error",
105
105
  0,
106
106
  "BATCH_ERROR"
@@ -146,7 +146,7 @@ var IPFinder = class {
146
146
  errorBody = await response.json();
147
147
  } catch {
148
148
  }
149
- throw new IPFinderError(
149
+ throw new IPInsightError(
150
150
  errorBody?.error || `HTTP ${response.status}`,
151
151
  response.status,
152
152
  errorBody?.code
@@ -156,16 +156,16 @@ var IPFinder = class {
156
156
  return data;
157
157
  } catch (err) {
158
158
  clearTimeout(timeoutId);
159
- if (err instanceof IPFinderError) {
159
+ if (err instanceof IPInsightError) {
160
160
  throw err;
161
161
  }
162
162
  if (err instanceof Error) {
163
163
  if (err.name === "AbortError") {
164
- throw new IPFinderError("Request timeout", 408, "TIMEOUT");
164
+ throw new IPInsightError("Request timeout", 408, "TIMEOUT");
165
165
  }
166
- throw new IPFinderError(err.message, 0, "NETWORK_ERROR");
166
+ throw new IPInsightError(err.message, 0, "NETWORK_ERROR");
167
167
  }
168
- throw new IPFinderError("Unknown error", 0, "UNKNOWN");
168
+ throw new IPInsightError("Unknown error", 0, "UNKNOWN");
169
169
  }
170
170
  }
171
171
  parseRateLimitHeaders(headers) {
@@ -185,12 +185,12 @@ var IPFinder = class {
185
185
  }
186
186
  };
187
187
  function createClient(config) {
188
- return new IPFinder(config);
188
+ return new IPInsight(config);
189
189
  }
190
- var src_default = IPFinder;
190
+ var src_default = IPInsight;
191
191
  export {
192
- IPFinder,
193
- IPFinderError,
192
+ IPInsight,
193
+ IPInsightError,
194
194
  createClient,
195
195
  src_default as default
196
196
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ip-finder-client",
3
- "version": "1.0.0",
4
- "description": "Lightweight client SDK for IP Finder API - Get IP geolocation, ASN, and network information",
3
+ "version": "1.0.1",
4
+ "description": "Lightweight SDK for IP geolocation, ASN lookup, and network information",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",