ip-finder-client 1.0.3 → 1.0.5
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 +22 -26
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +92 -29
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -28,9 +28,10 @@ const client = new IPInsight({
|
|
|
28
28
|
// Look up an IP address
|
|
29
29
|
const result = await client.lookup('8.8.8.8');
|
|
30
30
|
|
|
31
|
-
console.log(result.
|
|
32
|
-
console.log(result.
|
|
33
|
-
console.log(result.
|
|
31
|
+
console.log(result.location?.country); // "US"
|
|
32
|
+
console.log(result.location?.city); // "Mountain View"
|
|
33
|
+
console.log(result.isp?.organization); // "GOOGLE"
|
|
34
|
+
console.log(result.isp?.asn); // "AS15169"
|
|
34
35
|
```
|
|
35
36
|
|
|
36
37
|
## Configuration
|
|
@@ -60,36 +61,31 @@ const result = await client.lookup('8.8.8.8');
|
|
|
60
61
|
// Result structure:
|
|
61
62
|
{
|
|
62
63
|
ip: '8.8.8.8',
|
|
63
|
-
|
|
64
|
+
ipDetails: { version: 4, decimal: '134744072', hex: '08080808' },
|
|
65
|
+
location: {
|
|
64
66
|
city: 'Mountain View',
|
|
65
67
|
region: 'California',
|
|
66
|
-
|
|
67
|
-
country: 'United States',
|
|
68
|
-
countryCode: 'US',
|
|
69
|
-
continent: 'North America',
|
|
70
|
-
continentCode: 'NA',
|
|
71
|
-
latitude: 37.4056,
|
|
72
|
-
longitude: -122.0775,
|
|
68
|
+
country: 'US',
|
|
73
69
|
timezone: 'America/Los_Angeles',
|
|
74
|
-
|
|
70
|
+
coordinates: { latitude: 37.422, longitude: -122.085 },
|
|
71
|
+
maps: { search: '...', place: '...', directions: '...' }
|
|
75
72
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
isp: {
|
|
74
|
+
organization: 'GOOGLE',
|
|
75
|
+
asn: 'AS15169',
|
|
76
|
+
domain: 'google.com',
|
|
77
|
+
connectionType: 'Cable/DSL'
|
|
80
78
|
},
|
|
81
79
|
network: {
|
|
82
80
|
cidr: '8.8.8.0/24',
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
type: 'assigned',
|
|
86
|
-
registry: 'arin'
|
|
81
|
+
rir: 'ARIN',
|
|
82
|
+
status: 'allocated'
|
|
87
83
|
},
|
|
88
|
-
|
|
84
|
+
cloud: { isCloud: false }
|
|
89
85
|
}
|
|
90
86
|
```
|
|
91
87
|
|
|
92
|
-
### `lookupBatch(ips: string[]): Promise<(IPLookupResult |
|
|
88
|
+
### `lookupBatch(ips: string[]): Promise<(IPLookupResult | IPInsightError)[]>`
|
|
93
89
|
|
|
94
90
|
Look up multiple IP addresses in parallel.
|
|
95
91
|
|
|
@@ -100,7 +96,7 @@ results.forEach(result => {
|
|
|
100
96
|
if (result instanceof IPInsightError) {
|
|
101
97
|
console.error(`Error: ${result.message}`);
|
|
102
98
|
} else {
|
|
103
|
-
console.log(`${result.ip}: ${result.
|
|
99
|
+
console.log(`${result.ip}: ${result.location?.country}`);
|
|
104
100
|
}
|
|
105
101
|
});
|
|
106
102
|
```
|
|
@@ -187,9 +183,9 @@ Full TypeScript support with exported types:
|
|
|
187
183
|
import type {
|
|
188
184
|
IPFinderConfig,
|
|
189
185
|
IPLookupResult,
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
186
|
+
Location,
|
|
187
|
+
ISP,
|
|
188
|
+
Network,
|
|
193
189
|
RateLimitInfo
|
|
194
190
|
} from 'ip-finder-client';
|
|
195
191
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IPFinderConfig, IPLookupResult, APIError, RateLimitInfo,
|
|
2
|
-
export type { IPFinderConfig, IPLookupResult, APIError, RateLimitInfo,
|
|
1
|
+
import type { IPFinderConfig, IPLookupResult, APIError, RateLimitInfo, Location, ISP, Network, IPDetails, Coordinates, CloudInfo, DataSources, Explanation } from './types';
|
|
2
|
+
export type { IPFinderConfig, IPLookupResult, APIError, RateLimitInfo, Location, ISP, Network, IPDetails, Coordinates, CloudInfo, DataSources, Explanation, };
|
|
3
3
|
/**
|
|
4
4
|
* Custom error class for IPInsight API errors
|
|
5
5
|
*/
|
|
@@ -17,7 +17,7 @@ export declare class IPInsightError extends Error {
|
|
|
17
17
|
*
|
|
18
18
|
* const client = new IPInsight({ apiKey: 'your-api-key' });
|
|
19
19
|
* const result = await client.lookup('8.8.8.8');
|
|
20
|
-
* console.log(result.
|
|
20
|
+
* console.log(result.location?.country); // "US"
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export declare class IPInsight {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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,QAAQ,EACR,GAAG,EACH,OAAO,EACP,SAAS,EACT,WAAW,EACX,SAAS,EACT,WAAW,EACX,WAAW,EACZ,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,cAAc,EACd,cAAc,EACd,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,GAAG,EACH,OAAO,EACP,SAAS,EACT,WAAW,EACX,SAAS,EACT,WAAW,EACX,WAAW,GACZ,CAAC;AAMF;;GAEG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,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,SAAS;IACpB,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;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/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export interface IPFinderConfig {
|
|
5
5
|
/** Your API key for authentication */
|
|
6
6
|
apiKey: string;
|
|
7
|
-
/** Base URL of the IP Finder API (optional, defaults to
|
|
7
|
+
/** Base URL of the IP Finder API (optional, defaults to https://api.ipwhere.site) */
|
|
8
8
|
baseUrl?: string;
|
|
9
9
|
/** Request timeout in milliseconds (default: 10000) */
|
|
10
10
|
timeout?: number;
|
|
@@ -12,52 +12,115 @@ export interface IPFinderConfig {
|
|
|
12
12
|
retries?: number;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* IP address details
|
|
16
16
|
*/
|
|
17
|
-
export interface
|
|
17
|
+
export interface IPDetails {
|
|
18
|
+
version: number;
|
|
19
|
+
decimal: string;
|
|
20
|
+
hex: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Map links for the location
|
|
24
|
+
*/
|
|
25
|
+
export interface MapLinks {
|
|
26
|
+
search: string;
|
|
27
|
+
place: string;
|
|
28
|
+
directions: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Coordinates information
|
|
32
|
+
*/
|
|
33
|
+
export interface Coordinates {
|
|
34
|
+
latitude: number;
|
|
35
|
+
longitude: number;
|
|
36
|
+
accuracyRadius?: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Location information
|
|
40
|
+
*/
|
|
41
|
+
export interface Location {
|
|
18
42
|
city?: string;
|
|
19
43
|
region?: string;
|
|
20
|
-
regionCode?: string;
|
|
21
44
|
country?: string;
|
|
22
|
-
|
|
23
|
-
continent?: string;
|
|
24
|
-
continentCode?: string;
|
|
25
|
-
latitude?: number;
|
|
26
|
-
longitude?: number;
|
|
45
|
+
postalCode?: string | null;
|
|
27
46
|
timezone?: string;
|
|
28
|
-
|
|
47
|
+
coordinates?: Coordinates;
|
|
48
|
+
maps?: MapLinks;
|
|
29
49
|
}
|
|
30
50
|
/**
|
|
31
|
-
*
|
|
51
|
+
* Allocation date information
|
|
32
52
|
*/
|
|
33
|
-
export interface
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
53
|
+
export interface AllocationDate {
|
|
54
|
+
raw: string;
|
|
55
|
+
formatted: string;
|
|
56
|
+
iso: string;
|
|
37
57
|
}
|
|
38
58
|
/**
|
|
39
|
-
* Network
|
|
59
|
+
* Network information
|
|
40
60
|
*/
|
|
41
|
-
export interface
|
|
61
|
+
export interface Network {
|
|
42
62
|
cidr?: string;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
range?: string;
|
|
64
|
+
rangeSize?: string;
|
|
65
|
+
rir?: string;
|
|
66
|
+
allocationDate?: AllocationDate;
|
|
67
|
+
status?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* ISP/ASN information
|
|
71
|
+
*/
|
|
72
|
+
export interface ISP {
|
|
73
|
+
organization?: string;
|
|
74
|
+
asn?: string;
|
|
75
|
+
domain?: string;
|
|
76
|
+
connectionType?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Cloud detection information
|
|
80
|
+
*/
|
|
81
|
+
export interface CloudInfo {
|
|
82
|
+
isCloud: boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Data sources used for the lookup
|
|
86
|
+
*/
|
|
87
|
+
export interface DataSources {
|
|
88
|
+
geolocation?: string;
|
|
89
|
+
asn?: string;
|
|
90
|
+
network?: string;
|
|
91
|
+
postalCode?: string | null;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Explanation of the lookup result
|
|
95
|
+
*/
|
|
96
|
+
export interface Explanation {
|
|
97
|
+
summary?: string;
|
|
98
|
+
primarySource?: string;
|
|
99
|
+
sourcesUsed?: {
|
|
100
|
+
geolocation?: boolean;
|
|
101
|
+
asn?: boolean;
|
|
102
|
+
rir?: boolean;
|
|
103
|
+
};
|
|
104
|
+
rangeSize?: string;
|
|
105
|
+
rir?: {
|
|
106
|
+
rir?: string;
|
|
107
|
+
allocationDate?: AllocationDate;
|
|
108
|
+
status?: string;
|
|
109
|
+
};
|
|
49
110
|
}
|
|
50
111
|
/**
|
|
51
112
|
* Complete IP lookup result
|
|
52
113
|
*/
|
|
53
114
|
export interface IPLookupResult {
|
|
54
115
|
ip: string;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
network?:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
116
|
+
ipDetails?: IPDetails;
|
|
117
|
+
location?: Location;
|
|
118
|
+
network?: Network;
|
|
119
|
+
isp?: ISP;
|
|
120
|
+
cloud?: CloudInfo;
|
|
121
|
+
ipVersion?: number;
|
|
122
|
+
dataSources?: DataSources;
|
|
123
|
+
explanation?: Explanation;
|
|
61
124
|
}
|
|
62
125
|
/**
|
|
63
126
|
* Error response from the API
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,qFAAqF;IACrF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd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AO,CAAC;QACtB,GAAG,CAAC,EAAE,OAAO,CAAC;QACd,GAAG,CAAC,EAAE,OAAO,CAAC;KACf,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE;QACJ,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,cAAc,CAAC,EAAE,cAAc,CAAC;QAChC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ip-finder-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Lightweight SDK for IP geolocation, ASN lookup, and network information",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"build:esm": "esbuild src/index.ts --bundle --platform=node --target=node18 --outfile=dist/index.mjs --format=esm",
|
|
22
22
|
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist",
|
|
23
23
|
"prepublishOnly": "npm run build",
|
|
24
|
+
"publish": "npm version patch && npm publish",
|
|
24
25
|
"test": "node test/test.js"
|
|
25
26
|
},
|
|
26
27
|
"keywords": [
|