gatsbie 1.0.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 +61 -0
- package/dist/index.d.mts +265 -0
- package/dist/index.d.ts +265 -0
- package/dist/index.js +395 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +364 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Gatsbie Node.js SDK
|
|
2
|
+
|
|
3
|
+
Official Node.js/TypeScript SDK for the [Gatsbie Captcha API](https://gatsbie.io).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install gatsbie
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Client } from "gatsbie";
|
|
15
|
+
|
|
16
|
+
const client = new Client("gats_your_api_key");
|
|
17
|
+
|
|
18
|
+
// Solve a Turnstile challenge
|
|
19
|
+
const response = await client.solveTurnstile({
|
|
20
|
+
proxy: "http://user:pass@proxy:8080",
|
|
21
|
+
targetUrl: "https://example.com",
|
|
22
|
+
siteKey: "0x4AAAAAAABS7TtLxsNa7Z2e",
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
console.log(response.solution.token);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Supported Captcha Types
|
|
29
|
+
|
|
30
|
+
- **Datadome** - Device check and slider
|
|
31
|
+
- **reCAPTCHA v3** - Including enterprise
|
|
32
|
+
- **Akamai** - Bot management
|
|
33
|
+
- **Vercel** - Bot protection
|
|
34
|
+
- **Shape** - Antibot
|
|
35
|
+
- **Cloudflare Turnstile** - Turnstile challenges
|
|
36
|
+
- **Cloudflare WAF** - WAF challenges
|
|
37
|
+
- **PerimeterX** - Invisible challenges
|
|
38
|
+
|
|
39
|
+
## Error Handling
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { Client, APIError } from "gatsbie";
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const response = await client.solveTurnstile(request);
|
|
46
|
+
} catch (err) {
|
|
47
|
+
if (err instanceof APIError) {
|
|
48
|
+
if (err.isAuthError()) {
|
|
49
|
+
console.log("Check your API key");
|
|
50
|
+
} else if (err.isInsufficientCredits()) {
|
|
51
|
+
console.log("Add more credits");
|
|
52
|
+
} else if (err.isSolveFailed()) {
|
|
53
|
+
console.log("Solve failed, try again");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/** Response from the health check endpoint. */
|
|
2
|
+
interface HealthResponse {
|
|
3
|
+
status: string;
|
|
4
|
+
}
|
|
5
|
+
/** Generic response for successful captcha solves. */
|
|
6
|
+
interface SolveResponse<T> {
|
|
7
|
+
success: boolean;
|
|
8
|
+
taskId: string;
|
|
9
|
+
service: string;
|
|
10
|
+
solution: T;
|
|
11
|
+
cost: number;
|
|
12
|
+
solveTime: number;
|
|
13
|
+
}
|
|
14
|
+
/** Solution for Datadome challenges. */
|
|
15
|
+
interface DatadomeSolution {
|
|
16
|
+
datadome: string;
|
|
17
|
+
userAgent: string;
|
|
18
|
+
}
|
|
19
|
+
/** Solution for reCAPTCHA v3 challenges. */
|
|
20
|
+
interface RecaptchaV3Solution {
|
|
21
|
+
token: string;
|
|
22
|
+
userAgent: string;
|
|
23
|
+
}
|
|
24
|
+
/** Solution for Akamai challenges. */
|
|
25
|
+
interface AkamaiSolution {
|
|
26
|
+
abck: string;
|
|
27
|
+
bmSz: string;
|
|
28
|
+
userAgent: string;
|
|
29
|
+
country?: string;
|
|
30
|
+
usrLocale?: string;
|
|
31
|
+
}
|
|
32
|
+
/** Solution for Vercel challenges. */
|
|
33
|
+
interface VercelSolution {
|
|
34
|
+
vcrcs: string;
|
|
35
|
+
userAgent: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Solution for Shape challenges.
|
|
39
|
+
* Shape uses dynamic header names that vary by site.
|
|
40
|
+
*/
|
|
41
|
+
interface ShapeSolution {
|
|
42
|
+
headers: Record<string, string>;
|
|
43
|
+
userAgent: string;
|
|
44
|
+
}
|
|
45
|
+
/** Solution for Cloudflare Turnstile challenges. */
|
|
46
|
+
interface TurnstileSolution {
|
|
47
|
+
token: string;
|
|
48
|
+
userAgent: string;
|
|
49
|
+
}
|
|
50
|
+
/** PerimeterX cookies needed for requests. */
|
|
51
|
+
interface PerimeterXCookies {
|
|
52
|
+
px3: string;
|
|
53
|
+
pxde: string;
|
|
54
|
+
pxvid: string;
|
|
55
|
+
pxcts: string;
|
|
56
|
+
}
|
|
57
|
+
/** Solution for PerimeterX challenges. */
|
|
58
|
+
interface PerimeterXSolution {
|
|
59
|
+
cookies: PerimeterXCookies;
|
|
60
|
+
userAgent: string;
|
|
61
|
+
}
|
|
62
|
+
/** Solution for Cloudflare WAF challenges. */
|
|
63
|
+
interface CloudflareWAFSolution {
|
|
64
|
+
cfClearance: string;
|
|
65
|
+
userAgent: string;
|
|
66
|
+
}
|
|
67
|
+
/** Solution for Datadome Slider challenges. */
|
|
68
|
+
interface DatadomeSliderSolution {
|
|
69
|
+
datadome: string;
|
|
70
|
+
userAgent: string;
|
|
71
|
+
}
|
|
72
|
+
/** Request for solving Datadome device check challenges. */
|
|
73
|
+
interface DatadomeRequest {
|
|
74
|
+
proxy: string;
|
|
75
|
+
targetUrl: string;
|
|
76
|
+
targetMethod?: string;
|
|
77
|
+
}
|
|
78
|
+
/** Request for solving reCAPTCHA v3 challenges. */
|
|
79
|
+
interface RecaptchaV3Request {
|
|
80
|
+
proxy: string;
|
|
81
|
+
targetUrl: string;
|
|
82
|
+
siteKey: string;
|
|
83
|
+
action?: string;
|
|
84
|
+
title?: string;
|
|
85
|
+
enterprise?: boolean;
|
|
86
|
+
}
|
|
87
|
+
/** Request for solving Akamai challenges. */
|
|
88
|
+
interface AkamaiRequest {
|
|
89
|
+
proxy: string;
|
|
90
|
+
targetUrl: string;
|
|
91
|
+
akamaiJsUrl: string;
|
|
92
|
+
pageFp?: string;
|
|
93
|
+
}
|
|
94
|
+
/** Request for solving Vercel challenges. */
|
|
95
|
+
interface VercelRequest {
|
|
96
|
+
proxy: string;
|
|
97
|
+
targetUrl: string;
|
|
98
|
+
}
|
|
99
|
+
/** Request for solving Shape challenges. */
|
|
100
|
+
interface ShapeRequest {
|
|
101
|
+
proxy: string;
|
|
102
|
+
targetUrl: string;
|
|
103
|
+
targetApi: string;
|
|
104
|
+
shapeJsUrl: string;
|
|
105
|
+
title: string;
|
|
106
|
+
method: string;
|
|
107
|
+
}
|
|
108
|
+
/** Request for solving Cloudflare Turnstile challenges. */
|
|
109
|
+
interface TurnstileRequest {
|
|
110
|
+
proxy: string;
|
|
111
|
+
targetUrl: string;
|
|
112
|
+
siteKey: string;
|
|
113
|
+
}
|
|
114
|
+
/** Request for solving PerimeterX challenges. */
|
|
115
|
+
interface PerimeterXRequest {
|
|
116
|
+
proxy: string;
|
|
117
|
+
targetUrl: string;
|
|
118
|
+
perimeterxJsUrl: string;
|
|
119
|
+
pxAppId: string;
|
|
120
|
+
}
|
|
121
|
+
/** Request for solving Cloudflare WAF challenges. */
|
|
122
|
+
interface CloudflareWAFRequest {
|
|
123
|
+
proxy: string;
|
|
124
|
+
targetUrl: string;
|
|
125
|
+
targetMethod?: string;
|
|
126
|
+
}
|
|
127
|
+
/** Request for solving Datadome Slider challenges. */
|
|
128
|
+
interface DatadomeSliderRequest {
|
|
129
|
+
proxy: string;
|
|
130
|
+
targetUrl: string;
|
|
131
|
+
targetMethod?: string;
|
|
132
|
+
}
|
|
133
|
+
/** Options for configuring the Gatsbie client. */
|
|
134
|
+
interface ClientOptions {
|
|
135
|
+
/** Custom base URL for the API. */
|
|
136
|
+
baseUrl?: string;
|
|
137
|
+
/** Request timeout in milliseconds (default: 120000). */
|
|
138
|
+
timeout?: number;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Gatsbie API client.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const client = new Client("gats_your_api_key");
|
|
147
|
+
*
|
|
148
|
+
* const response = await client.solveTurnstile({
|
|
149
|
+
* proxy: "http://user:pass@proxy:8080",
|
|
150
|
+
* targetUrl: "https://example.com",
|
|
151
|
+
* siteKey: "0x4AAAAAAABS7TtLxsNa7Z2e",
|
|
152
|
+
* });
|
|
153
|
+
*
|
|
154
|
+
* console.log(response.solution.token);
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare class Client {
|
|
158
|
+
private readonly apiKey;
|
|
159
|
+
private readonly baseUrl;
|
|
160
|
+
private readonly timeout;
|
|
161
|
+
/**
|
|
162
|
+
* Create a new Gatsbie API client.
|
|
163
|
+
*
|
|
164
|
+
* @param apiKey - Your Gatsbie API key (should start with 'gats_').
|
|
165
|
+
* @param options - Optional client configuration.
|
|
166
|
+
*/
|
|
167
|
+
constructor(apiKey: string, options?: ClientOptions);
|
|
168
|
+
private request;
|
|
169
|
+
/**
|
|
170
|
+
* Check the API server health status.
|
|
171
|
+
*/
|
|
172
|
+
health(): Promise<HealthResponse>;
|
|
173
|
+
/**
|
|
174
|
+
* Solve a Datadome device check challenge.
|
|
175
|
+
*/
|
|
176
|
+
solveDatadome(request: DatadomeRequest): Promise<SolveResponse<DatadomeSolution>>;
|
|
177
|
+
/**
|
|
178
|
+
* Solve a reCAPTCHA v3 challenge.
|
|
179
|
+
*/
|
|
180
|
+
solveRecaptchaV3(request: RecaptchaV3Request): Promise<SolveResponse<RecaptchaV3Solution>>;
|
|
181
|
+
/**
|
|
182
|
+
* Solve an Akamai bot management challenge.
|
|
183
|
+
*/
|
|
184
|
+
solveAkamai(request: AkamaiRequest): Promise<SolveResponse<AkamaiSolution>>;
|
|
185
|
+
/**
|
|
186
|
+
* Solve a Vercel bot protection challenge.
|
|
187
|
+
*/
|
|
188
|
+
solveVercel(request: VercelRequest): Promise<SolveResponse<VercelSolution>>;
|
|
189
|
+
/**
|
|
190
|
+
* Solve a Shape antibot challenge.
|
|
191
|
+
*/
|
|
192
|
+
solveShape(request: ShapeRequest): Promise<SolveResponse<ShapeSolution>>;
|
|
193
|
+
/**
|
|
194
|
+
* Solve a Cloudflare Turnstile challenge.
|
|
195
|
+
*/
|
|
196
|
+
solveTurnstile(request: TurnstileRequest): Promise<SolveResponse<TurnstileSolution>>;
|
|
197
|
+
/**
|
|
198
|
+
* Solve a PerimeterX Invisible challenge.
|
|
199
|
+
*/
|
|
200
|
+
solvePerimeterX(request: PerimeterXRequest): Promise<SolveResponse<PerimeterXSolution>>;
|
|
201
|
+
/**
|
|
202
|
+
* Solve a Cloudflare WAF challenge.
|
|
203
|
+
*/
|
|
204
|
+
solveCloudflareWAF(request: CloudflareWAFRequest): Promise<SolveResponse<CloudflareWAFSolution>>;
|
|
205
|
+
/**
|
|
206
|
+
* Solve a Datadome Slider CAPTCHA challenge.
|
|
207
|
+
*/
|
|
208
|
+
solveDatadomeSlider(request: DatadomeSliderRequest): Promise<SolveResponse<DatadomeSliderSolution>>;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Error codes returned by the Gatsbie API.
|
|
213
|
+
*/
|
|
214
|
+
declare const ErrorCode: {
|
|
215
|
+
readonly AUTH_FAILED: "AUTH_FAILED";
|
|
216
|
+
readonly INSUFFICIENT_CREDITS: "INSUFFICIENT_CREDITS";
|
|
217
|
+
readonly INVALID_REQUEST: "INVALID_REQUEST";
|
|
218
|
+
readonly UPSTREAM_ERROR: "UPSTREAM_ERROR";
|
|
219
|
+
readonly SOLVE_FAILED: "SOLVE_FAILED";
|
|
220
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
221
|
+
};
|
|
222
|
+
type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
223
|
+
/**
|
|
224
|
+
* Base error class for Gatsbie SDK errors.
|
|
225
|
+
*/
|
|
226
|
+
declare class GatsbieError extends Error {
|
|
227
|
+
constructor(message: string);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Error thrown when the Gatsbie API returns an error response.
|
|
231
|
+
*/
|
|
232
|
+
declare class APIError extends GatsbieError {
|
|
233
|
+
readonly code: string;
|
|
234
|
+
readonly details?: string;
|
|
235
|
+
readonly timestamp?: number;
|
|
236
|
+
readonly httpStatus?: number;
|
|
237
|
+
constructor(options: {
|
|
238
|
+
code: string;
|
|
239
|
+
message: string;
|
|
240
|
+
details?: string;
|
|
241
|
+
timestamp?: number;
|
|
242
|
+
httpStatus?: number;
|
|
243
|
+
});
|
|
244
|
+
/** Check if this is an authentication error. */
|
|
245
|
+
isAuthError(): boolean;
|
|
246
|
+
/** Check if this error is due to insufficient credits. */
|
|
247
|
+
isInsufficientCredits(): boolean;
|
|
248
|
+
/** Check if this error is due to an invalid request. */
|
|
249
|
+
isInvalidRequest(): boolean;
|
|
250
|
+
/** Check if this error is from an upstream service. */
|
|
251
|
+
isUpstreamError(): boolean;
|
|
252
|
+
/** Check if the captcha solving failed. */
|
|
253
|
+
isSolveFailed(): boolean;
|
|
254
|
+
/** Check if this is an internal server error. */
|
|
255
|
+
isInternalError(): boolean;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Error thrown when a request fails (network error, timeout, etc.).
|
|
259
|
+
*/
|
|
260
|
+
declare class RequestError extends GatsbieError {
|
|
261
|
+
readonly cause?: Error | undefined;
|
|
262
|
+
constructor(message: string, cause?: Error | undefined);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export { APIError, type AkamaiRequest, type AkamaiSolution, Client, type ClientOptions, type CloudflareWAFRequest, type CloudflareWAFSolution, type DatadomeRequest, type DatadomeSliderRequest, type DatadomeSliderSolution, type DatadomeSolution, ErrorCode, GatsbieError, type HealthResponse, type PerimeterXCookies, type PerimeterXRequest, type PerimeterXSolution, type RecaptchaV3Request, type RecaptchaV3Solution, RequestError, type ShapeRequest, type ShapeSolution, type SolveResponse, type TurnstileRequest, type TurnstileSolution, type VercelRequest, type VercelSolution };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/** Response from the health check endpoint. */
|
|
2
|
+
interface HealthResponse {
|
|
3
|
+
status: string;
|
|
4
|
+
}
|
|
5
|
+
/** Generic response for successful captcha solves. */
|
|
6
|
+
interface SolveResponse<T> {
|
|
7
|
+
success: boolean;
|
|
8
|
+
taskId: string;
|
|
9
|
+
service: string;
|
|
10
|
+
solution: T;
|
|
11
|
+
cost: number;
|
|
12
|
+
solveTime: number;
|
|
13
|
+
}
|
|
14
|
+
/** Solution for Datadome challenges. */
|
|
15
|
+
interface DatadomeSolution {
|
|
16
|
+
datadome: string;
|
|
17
|
+
userAgent: string;
|
|
18
|
+
}
|
|
19
|
+
/** Solution for reCAPTCHA v3 challenges. */
|
|
20
|
+
interface RecaptchaV3Solution {
|
|
21
|
+
token: string;
|
|
22
|
+
userAgent: string;
|
|
23
|
+
}
|
|
24
|
+
/** Solution for Akamai challenges. */
|
|
25
|
+
interface AkamaiSolution {
|
|
26
|
+
abck: string;
|
|
27
|
+
bmSz: string;
|
|
28
|
+
userAgent: string;
|
|
29
|
+
country?: string;
|
|
30
|
+
usrLocale?: string;
|
|
31
|
+
}
|
|
32
|
+
/** Solution for Vercel challenges. */
|
|
33
|
+
interface VercelSolution {
|
|
34
|
+
vcrcs: string;
|
|
35
|
+
userAgent: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Solution for Shape challenges.
|
|
39
|
+
* Shape uses dynamic header names that vary by site.
|
|
40
|
+
*/
|
|
41
|
+
interface ShapeSolution {
|
|
42
|
+
headers: Record<string, string>;
|
|
43
|
+
userAgent: string;
|
|
44
|
+
}
|
|
45
|
+
/** Solution for Cloudflare Turnstile challenges. */
|
|
46
|
+
interface TurnstileSolution {
|
|
47
|
+
token: string;
|
|
48
|
+
userAgent: string;
|
|
49
|
+
}
|
|
50
|
+
/** PerimeterX cookies needed for requests. */
|
|
51
|
+
interface PerimeterXCookies {
|
|
52
|
+
px3: string;
|
|
53
|
+
pxde: string;
|
|
54
|
+
pxvid: string;
|
|
55
|
+
pxcts: string;
|
|
56
|
+
}
|
|
57
|
+
/** Solution for PerimeterX challenges. */
|
|
58
|
+
interface PerimeterXSolution {
|
|
59
|
+
cookies: PerimeterXCookies;
|
|
60
|
+
userAgent: string;
|
|
61
|
+
}
|
|
62
|
+
/** Solution for Cloudflare WAF challenges. */
|
|
63
|
+
interface CloudflareWAFSolution {
|
|
64
|
+
cfClearance: string;
|
|
65
|
+
userAgent: string;
|
|
66
|
+
}
|
|
67
|
+
/** Solution for Datadome Slider challenges. */
|
|
68
|
+
interface DatadomeSliderSolution {
|
|
69
|
+
datadome: string;
|
|
70
|
+
userAgent: string;
|
|
71
|
+
}
|
|
72
|
+
/** Request for solving Datadome device check challenges. */
|
|
73
|
+
interface DatadomeRequest {
|
|
74
|
+
proxy: string;
|
|
75
|
+
targetUrl: string;
|
|
76
|
+
targetMethod?: string;
|
|
77
|
+
}
|
|
78
|
+
/** Request for solving reCAPTCHA v3 challenges. */
|
|
79
|
+
interface RecaptchaV3Request {
|
|
80
|
+
proxy: string;
|
|
81
|
+
targetUrl: string;
|
|
82
|
+
siteKey: string;
|
|
83
|
+
action?: string;
|
|
84
|
+
title?: string;
|
|
85
|
+
enterprise?: boolean;
|
|
86
|
+
}
|
|
87
|
+
/** Request for solving Akamai challenges. */
|
|
88
|
+
interface AkamaiRequest {
|
|
89
|
+
proxy: string;
|
|
90
|
+
targetUrl: string;
|
|
91
|
+
akamaiJsUrl: string;
|
|
92
|
+
pageFp?: string;
|
|
93
|
+
}
|
|
94
|
+
/** Request for solving Vercel challenges. */
|
|
95
|
+
interface VercelRequest {
|
|
96
|
+
proxy: string;
|
|
97
|
+
targetUrl: string;
|
|
98
|
+
}
|
|
99
|
+
/** Request for solving Shape challenges. */
|
|
100
|
+
interface ShapeRequest {
|
|
101
|
+
proxy: string;
|
|
102
|
+
targetUrl: string;
|
|
103
|
+
targetApi: string;
|
|
104
|
+
shapeJsUrl: string;
|
|
105
|
+
title: string;
|
|
106
|
+
method: string;
|
|
107
|
+
}
|
|
108
|
+
/** Request for solving Cloudflare Turnstile challenges. */
|
|
109
|
+
interface TurnstileRequest {
|
|
110
|
+
proxy: string;
|
|
111
|
+
targetUrl: string;
|
|
112
|
+
siteKey: string;
|
|
113
|
+
}
|
|
114
|
+
/** Request for solving PerimeterX challenges. */
|
|
115
|
+
interface PerimeterXRequest {
|
|
116
|
+
proxy: string;
|
|
117
|
+
targetUrl: string;
|
|
118
|
+
perimeterxJsUrl: string;
|
|
119
|
+
pxAppId: string;
|
|
120
|
+
}
|
|
121
|
+
/** Request for solving Cloudflare WAF challenges. */
|
|
122
|
+
interface CloudflareWAFRequest {
|
|
123
|
+
proxy: string;
|
|
124
|
+
targetUrl: string;
|
|
125
|
+
targetMethod?: string;
|
|
126
|
+
}
|
|
127
|
+
/** Request for solving Datadome Slider challenges. */
|
|
128
|
+
interface DatadomeSliderRequest {
|
|
129
|
+
proxy: string;
|
|
130
|
+
targetUrl: string;
|
|
131
|
+
targetMethod?: string;
|
|
132
|
+
}
|
|
133
|
+
/** Options for configuring the Gatsbie client. */
|
|
134
|
+
interface ClientOptions {
|
|
135
|
+
/** Custom base URL for the API. */
|
|
136
|
+
baseUrl?: string;
|
|
137
|
+
/** Request timeout in milliseconds (default: 120000). */
|
|
138
|
+
timeout?: number;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Gatsbie API client.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const client = new Client("gats_your_api_key");
|
|
147
|
+
*
|
|
148
|
+
* const response = await client.solveTurnstile({
|
|
149
|
+
* proxy: "http://user:pass@proxy:8080",
|
|
150
|
+
* targetUrl: "https://example.com",
|
|
151
|
+
* siteKey: "0x4AAAAAAABS7TtLxsNa7Z2e",
|
|
152
|
+
* });
|
|
153
|
+
*
|
|
154
|
+
* console.log(response.solution.token);
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
declare class Client {
|
|
158
|
+
private readonly apiKey;
|
|
159
|
+
private readonly baseUrl;
|
|
160
|
+
private readonly timeout;
|
|
161
|
+
/**
|
|
162
|
+
* Create a new Gatsbie API client.
|
|
163
|
+
*
|
|
164
|
+
* @param apiKey - Your Gatsbie API key (should start with 'gats_').
|
|
165
|
+
* @param options - Optional client configuration.
|
|
166
|
+
*/
|
|
167
|
+
constructor(apiKey: string, options?: ClientOptions);
|
|
168
|
+
private request;
|
|
169
|
+
/**
|
|
170
|
+
* Check the API server health status.
|
|
171
|
+
*/
|
|
172
|
+
health(): Promise<HealthResponse>;
|
|
173
|
+
/**
|
|
174
|
+
* Solve a Datadome device check challenge.
|
|
175
|
+
*/
|
|
176
|
+
solveDatadome(request: DatadomeRequest): Promise<SolveResponse<DatadomeSolution>>;
|
|
177
|
+
/**
|
|
178
|
+
* Solve a reCAPTCHA v3 challenge.
|
|
179
|
+
*/
|
|
180
|
+
solveRecaptchaV3(request: RecaptchaV3Request): Promise<SolveResponse<RecaptchaV3Solution>>;
|
|
181
|
+
/**
|
|
182
|
+
* Solve an Akamai bot management challenge.
|
|
183
|
+
*/
|
|
184
|
+
solveAkamai(request: AkamaiRequest): Promise<SolveResponse<AkamaiSolution>>;
|
|
185
|
+
/**
|
|
186
|
+
* Solve a Vercel bot protection challenge.
|
|
187
|
+
*/
|
|
188
|
+
solveVercel(request: VercelRequest): Promise<SolveResponse<VercelSolution>>;
|
|
189
|
+
/**
|
|
190
|
+
* Solve a Shape antibot challenge.
|
|
191
|
+
*/
|
|
192
|
+
solveShape(request: ShapeRequest): Promise<SolveResponse<ShapeSolution>>;
|
|
193
|
+
/**
|
|
194
|
+
* Solve a Cloudflare Turnstile challenge.
|
|
195
|
+
*/
|
|
196
|
+
solveTurnstile(request: TurnstileRequest): Promise<SolveResponse<TurnstileSolution>>;
|
|
197
|
+
/**
|
|
198
|
+
* Solve a PerimeterX Invisible challenge.
|
|
199
|
+
*/
|
|
200
|
+
solvePerimeterX(request: PerimeterXRequest): Promise<SolveResponse<PerimeterXSolution>>;
|
|
201
|
+
/**
|
|
202
|
+
* Solve a Cloudflare WAF challenge.
|
|
203
|
+
*/
|
|
204
|
+
solveCloudflareWAF(request: CloudflareWAFRequest): Promise<SolveResponse<CloudflareWAFSolution>>;
|
|
205
|
+
/**
|
|
206
|
+
* Solve a Datadome Slider CAPTCHA challenge.
|
|
207
|
+
*/
|
|
208
|
+
solveDatadomeSlider(request: DatadomeSliderRequest): Promise<SolveResponse<DatadomeSliderSolution>>;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Error codes returned by the Gatsbie API.
|
|
213
|
+
*/
|
|
214
|
+
declare const ErrorCode: {
|
|
215
|
+
readonly AUTH_FAILED: "AUTH_FAILED";
|
|
216
|
+
readonly INSUFFICIENT_CREDITS: "INSUFFICIENT_CREDITS";
|
|
217
|
+
readonly INVALID_REQUEST: "INVALID_REQUEST";
|
|
218
|
+
readonly UPSTREAM_ERROR: "UPSTREAM_ERROR";
|
|
219
|
+
readonly SOLVE_FAILED: "SOLVE_FAILED";
|
|
220
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
221
|
+
};
|
|
222
|
+
type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
223
|
+
/**
|
|
224
|
+
* Base error class for Gatsbie SDK errors.
|
|
225
|
+
*/
|
|
226
|
+
declare class GatsbieError extends Error {
|
|
227
|
+
constructor(message: string);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Error thrown when the Gatsbie API returns an error response.
|
|
231
|
+
*/
|
|
232
|
+
declare class APIError extends GatsbieError {
|
|
233
|
+
readonly code: string;
|
|
234
|
+
readonly details?: string;
|
|
235
|
+
readonly timestamp?: number;
|
|
236
|
+
readonly httpStatus?: number;
|
|
237
|
+
constructor(options: {
|
|
238
|
+
code: string;
|
|
239
|
+
message: string;
|
|
240
|
+
details?: string;
|
|
241
|
+
timestamp?: number;
|
|
242
|
+
httpStatus?: number;
|
|
243
|
+
});
|
|
244
|
+
/** Check if this is an authentication error. */
|
|
245
|
+
isAuthError(): boolean;
|
|
246
|
+
/** Check if this error is due to insufficient credits. */
|
|
247
|
+
isInsufficientCredits(): boolean;
|
|
248
|
+
/** Check if this error is due to an invalid request. */
|
|
249
|
+
isInvalidRequest(): boolean;
|
|
250
|
+
/** Check if this error is from an upstream service. */
|
|
251
|
+
isUpstreamError(): boolean;
|
|
252
|
+
/** Check if the captcha solving failed. */
|
|
253
|
+
isSolveFailed(): boolean;
|
|
254
|
+
/** Check if this is an internal server error. */
|
|
255
|
+
isInternalError(): boolean;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Error thrown when a request fails (network error, timeout, etc.).
|
|
259
|
+
*/
|
|
260
|
+
declare class RequestError extends GatsbieError {
|
|
261
|
+
readonly cause?: Error | undefined;
|
|
262
|
+
constructor(message: string, cause?: Error | undefined);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export { APIError, type AkamaiRequest, type AkamaiSolution, Client, type ClientOptions, type CloudflareWAFRequest, type CloudflareWAFSolution, type DatadomeRequest, type DatadomeSliderRequest, type DatadomeSliderSolution, type DatadomeSolution, ErrorCode, GatsbieError, type HealthResponse, type PerimeterXCookies, type PerimeterXRequest, type PerimeterXSolution, type RecaptchaV3Request, type RecaptchaV3Solution, RequestError, type ShapeRequest, type ShapeSolution, type SolveResponse, type TurnstileRequest, type TurnstileSolution, type VercelRequest, type VercelSolution };
|