chapybara 0.3.0 → 0.5.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 +15 -19
- package/index.d.ts +2 -6
- package/index.js +4 -13
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -28,6 +28,21 @@ const chapybara = new ChapybaraClient({
|
|
|
28
28
|
});
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
### Get Your IP Address
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
async function getUserIP() {
|
|
35
|
+
try {
|
|
36
|
+
const data = await chapybara.getUserIP();
|
|
37
|
+
console.log(data.ip);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error(`Error fetching user IP: ${error.message}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getUserIP();
|
|
44
|
+
```
|
|
45
|
+
|
|
31
46
|
### Get Domain Intelligence
|
|
32
47
|
|
|
33
48
|
```javascript
|
|
@@ -76,24 +91,6 @@ async function getWebTechInfo() {
|
|
|
76
91
|
getWebTechInfo();
|
|
77
92
|
```
|
|
78
93
|
|
|
79
|
-
### Get Website Screenshot
|
|
80
|
-
|
|
81
|
-
```javascript
|
|
82
|
-
import fs from "fs/promises";
|
|
83
|
-
|
|
84
|
-
async function getWebsiteScreenshot() {
|
|
85
|
-
try {
|
|
86
|
-
const imageBuffer = await chapybara.screenshot.get("apple.com");
|
|
87
|
-
await fs.writeFile("screenshot.png", imageBuffer);
|
|
88
|
-
console.log("Screenshot saved to screenshot.png");
|
|
89
|
-
} catch (error) {
|
|
90
|
-
console.error(`Error fetching screenshot: ${error.message}`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
getWebsiteScreenshot();
|
|
95
|
-
```
|
|
96
|
-
|
|
97
94
|
### Get Account Information
|
|
98
95
|
|
|
99
96
|
```javascript
|
|
@@ -101,7 +98,6 @@ async function getAccountDetails() {
|
|
|
101
98
|
try {
|
|
102
99
|
const data = await chapybara.account.getInfo();
|
|
103
100
|
console.log("Domain quota remaining:", data.quotas.domain.remaining);
|
|
104
|
-
console.log("Screenshot quota remaining:", data.quotas.screenshot.remaining);
|
|
105
101
|
} catch (error) {
|
|
106
102
|
console.error(`Error fetching account info: ${error.message}`);
|
|
107
103
|
}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { LRUCache } from "lru-cache";
|
|
2
|
-
import type { Buffer } from "node:buffer";
|
|
3
2
|
|
|
4
3
|
declare module "chapybara" {
|
|
5
4
|
interface ChapybaraClientOptions {
|
|
@@ -241,7 +240,6 @@ declare module "chapybara" {
|
|
|
241
240
|
domain: { limit: number; used: number; remaining: number };
|
|
242
241
|
ip: { limit: number; used: number; remaining: number };
|
|
243
242
|
webtech: { limit: number; used: number; remaining: number };
|
|
244
|
-
screenshot: { limit: number; used: number; remaining: number };
|
|
245
243
|
reset_date: string;
|
|
246
244
|
};
|
|
247
245
|
api_key: {
|
|
@@ -282,12 +280,10 @@ declare module "chapybara" {
|
|
|
282
280
|
getScanner: (domain: string) => Promise<WebTechResponse>;
|
|
283
281
|
};
|
|
284
282
|
|
|
285
|
-
screenshot: {
|
|
286
|
-
get: (domain: string) => Promise<Buffer>;
|
|
287
|
-
};
|
|
288
|
-
|
|
289
283
|
account: {
|
|
290
284
|
getInfo: () => Promise<AccountInfoResponse>;
|
|
291
285
|
};
|
|
286
|
+
|
|
287
|
+
getUserIP: () => Promise<{ ip: string }>;
|
|
292
288
|
}
|
|
293
289
|
}
|
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const DEFAULT_BASE_URL = "https://api.chapyapi.com/api/v1";
|
|
|
5
5
|
const DEFAULT_RETRIES = 2;
|
|
6
6
|
const DEFAULT_TIMEOUT = 30000;
|
|
7
7
|
|
|
8
|
-
const SDK_VERSION = "0.
|
|
8
|
+
const SDK_VERSION = "0.4.0";
|
|
9
9
|
|
|
10
10
|
export class ChapybaraClient {
|
|
11
11
|
constructor(options) {
|
|
@@ -34,19 +34,16 @@ export class ChapybaraClient {
|
|
|
34
34
|
getScanner: (domain) => this._request(`/webtech/${domain}`),
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
this.screenshot = {
|
|
38
|
-
get: (domain) => this._request(`/screenshot/${domain}`),
|
|
39
|
-
};
|
|
40
|
-
|
|
41
37
|
this.account = {
|
|
42
38
|
getInfo: () => this._request("/account"),
|
|
43
39
|
};
|
|
40
|
+
|
|
41
|
+
this.getUserIP = () => this._request("/ip");
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
async _request(endpoint, attempt = 1) {
|
|
47
45
|
const url = `${this.baseUrl}${endpoint}`;
|
|
48
46
|
const cacheKey = endpoint;
|
|
49
|
-
const isScreenshotRequest = endpoint.startsWith("/screenshot");
|
|
50
47
|
|
|
51
48
|
if (this.cache?.has(cacheKey)) {
|
|
52
49
|
return this.cache.get(cacheKey);
|
|
@@ -77,13 +74,7 @@ export class ChapybaraClient {
|
|
|
77
74
|
await this._handleError(response);
|
|
78
75
|
}
|
|
79
76
|
|
|
80
|
-
|
|
81
|
-
if (isScreenshotRequest) {
|
|
82
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
83
|
-
data = Buffer.from(arrayBuffer);
|
|
84
|
-
} else {
|
|
85
|
-
data = await response.json();
|
|
86
|
-
}
|
|
77
|
+
const data = await response.json();
|
|
87
78
|
|
|
88
79
|
if (this.cache) {
|
|
89
80
|
this.cache.set(cacheKey, data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chapybara",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Official NodeJS SDK for the Chapybara Domain & IP Intelligence API.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -15,13 +15,12 @@
|
|
|
15
15
|
"domain",
|
|
16
16
|
"ip",
|
|
17
17
|
"intelligence",
|
|
18
|
-
"security"
|
|
19
|
-
"screenshot"
|
|
18
|
+
"security"
|
|
20
19
|
],
|
|
21
20
|
"author": "Alpha System",
|
|
22
21
|
"license": "MIT",
|
|
23
22
|
"dependencies": {
|
|
24
|
-
"lru-cache": "^11.2.
|
|
23
|
+
"lru-cache": "^11.2.6"
|
|
25
24
|
},
|
|
26
25
|
"engines": {
|
|
27
26
|
"node": ">=18.0.0"
|