chapybara 0.6.0 → 0.6.2

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/index.js CHANGED
@@ -6,7 +6,7 @@ const DEFAULT_BASE_URL = "https://api.chapyapi.com/api/v1";
6
6
  const DEFAULT_RETRIES = 2;
7
7
  const DEFAULT_TIMEOUT = 30000;
8
8
 
9
- const SDK_VERSION = "0.6.0";
9
+ const SDK_VERSION = "0.6.1";
10
10
 
11
11
  export class ChapybaraClient {
12
12
  constructor(options) {
@@ -15,7 +15,7 @@ export class ChapybaraClient {
15
15
  }
16
16
 
17
17
  this.apiKey = options.apiKey;
18
- this.baseUrl = options.baseUrl || DEFAULT_BASE_URL;
18
+ this.baseUrl = (options.baseUrl || DEFAULT_BASE_URL).replace(/\/?$/, "/");
19
19
  this.retries = options.retries ?? DEFAULT_RETRIES;
20
20
  this.timeout = options.timeout || DEFAULT_TIMEOUT;
21
21
 
@@ -34,22 +34,22 @@ export class ChapybaraClient {
34
34
  }
35
35
 
36
36
  this.domain = {
37
- getIntelligence: (domain) => this._request(`/domain/${domain}`),
37
+ getIntelligence: (domain) => this._request(`domain/${domain}`),
38
38
  };
39
39
 
40
40
  this.ip = {
41
- getIntelligence: (ip) => this._request(`/ip/${ip}`),
41
+ getIntelligence: (ip) => this._request(`ip/${ip}`),
42
42
  };
43
43
 
44
44
  this.webtech = {
45
- getScanner: (domain) => this._request(`/webtech/${domain}`),
45
+ getScanner: (domain) => this._request(`webtech/${domain}`),
46
46
  };
47
47
 
48
48
  this.account = {
49
- getInfo: () => this._request("/account"),
49
+ getInfo: () => this._request("account"),
50
50
  };
51
51
 
52
- this.getUserIP = () => this._request("/ip");
52
+ this.getUserIP = () => this._request("ip");
53
53
  }
54
54
 
55
55
  async _request(endpoint, attempt = 1) {
package/lib/errors.js CHANGED
@@ -7,11 +7,12 @@ export class ChapybaraError extends Error {
7
7
 
8
8
  export class APIError extends ChapybaraError {
9
9
  constructor(status, error) {
10
- super(error?.error || `Request failed with status code ${status}`);
10
+ const msg = typeof error?.error === "string" ? error.error : error?.error?.message || error?.message || `Request failed with status code ${status}`;
11
+ super(msg);
11
12
  this.name = "APIError";
12
13
  this.status = status;
13
- this.code = error?.code;
14
- this.requestId = error?.requestId;
14
+ this.code = error?.error?.code || error?.code;
15
+ this.requestId = error?.error?.requestId || error?.requestId;
15
16
  }
16
17
  }
17
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chapybara",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Official NodeJS SDK for the Chapybara Domain & IP Intelligence API.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,8 +20,8 @@
20
20
  "author": "Alpha System",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "lru-cache": "^11.2.6",
24
- "nlcurl": "^0.2.0"
23
+ "lru-cache": "^11.2.7",
24
+ "nlcurl": "^0.12.1"
25
25
  },
26
26
  "engines": {
27
27
  "node": ">=18.0.0"