@capbypass/sdk 1.0.0 → 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 +30 -3
- package/dist/index.d.mts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +60 -7
- package/dist/index.mjs +60 -7
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://www.typescriptlang.org/)
|
|
6
6
|
|
|
7
|
-
Official TypeScript/JavaScript SDK for the CapBypass CAPTCHA solving service. Supports reCAPTCHA v2, reCAPTCHA v3, and AWS WAF challenges.
|
|
7
|
+
Official TypeScript/JavaScript SDK for the [CapBypass](https://capbypass.pro) CAPTCHA solving service. Supports reCAPTCHA v2, reCAPTCHA v3, and AWS WAF challenges.
|
|
8
8
|
|
|
9
9
|
Works in both Node.js and browser environments.
|
|
10
10
|
|
|
@@ -230,13 +230,37 @@ TaskType.RECAPTCHA_V3_ENTERPRISE // ReCaptchaV3EnterpriseTask
|
|
|
230
230
|
TaskType.RECAPTCHA_V3_ENTERPRISE_PROXYLESS // ReCaptchaV3EnterpriseTaskProxyLess
|
|
231
231
|
```
|
|
232
232
|
|
|
233
|
+
## Documentation
|
|
234
|
+
|
|
235
|
+
### 📚 Core Documentation
|
|
236
|
+
- [Quick Start Guide](https://github.com/CapBypass-Development/capbypass-sdks/blob/main/docs/quickstart/typescript.md)
|
|
237
|
+
- [Complete API Reference](https://github.com/CapBypass-Development/capbypass-sdks/blob/main/docs/api-reference/typescript-sdk.md)
|
|
238
|
+
- [Full SDK Documentation](https://capbypass.pro/docs/sdks/typescript)
|
|
239
|
+
|
|
240
|
+
### 🔧 Advanced Guides
|
|
241
|
+
- [Proxy Configuration](https://github.com/CapBypass-Development/capbypass-sdks/blob/main/docs/guides/proxy-configuration.md) — HTTP, HTTPS, SOCKS5 proxy support with rotation strategies
|
|
242
|
+
- [Error Handling](https://github.com/CapBypass-Development/capbypass-sdks/blob/main/docs/guides/error-handling.md) — Retry strategies, circuit breakers, production alerting
|
|
243
|
+
- [Performance Optimization](https://github.com/CapBypass-Development/capbypass-sdks/blob/main/docs/guides/performance-optimization.md) — Concurrent solving, connection pooling, token caching
|
|
244
|
+
- [Production Deployment](https://github.com/CapBypass-Development/capbypass-sdks/blob/main/docs/guides/production-deployment.md) — Kubernetes, AWS Lambda, monitoring, security
|
|
245
|
+
|
|
246
|
+
### 🔄 Migration
|
|
247
|
+
- [Migrating from Capsolver](https://github.com/CapBypass-Development/capbypass-sdks/blob/main/docs/migration/from-capsolver.md) — 100% API compatible, drop-in replacement
|
|
248
|
+
|
|
233
249
|
## Examples
|
|
234
250
|
|
|
235
|
-
|
|
251
|
+
### Basic Examples
|
|
252
|
+
See the [examples](examples/) directory for complete runnable examples:
|
|
236
253
|
- [recaptcha-v2.ts](examples/recaptcha-v2.ts) - reCAPTCHA v2 solving
|
|
237
254
|
- [recaptcha-v3.ts](examples/recaptcha-v3.ts) - reCAPTCHA v3 solving
|
|
238
255
|
- [aws-waf.ts](examples/aws-waf.ts) - AWS WAF challenge solving
|
|
239
256
|
|
|
257
|
+
### Advanced Examples
|
|
258
|
+
Full integration examples in the [documentation](https://github.com/CapBypass-Development/capbypass-sdks/tree/main/docs/examples):
|
|
259
|
+
- E-commerce checkout automation
|
|
260
|
+
- Social media automation
|
|
261
|
+
- Web scraping with CAPTCHA handling
|
|
262
|
+
- Microservice integration patterns
|
|
263
|
+
|
|
240
264
|
## Testing
|
|
241
265
|
|
|
242
266
|
```bash
|
|
@@ -268,7 +292,10 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
268
292
|
|
|
269
293
|
## Links
|
|
270
294
|
|
|
271
|
-
- [
|
|
295
|
+
- [Website](https://capbypass.pro)
|
|
296
|
+
- [Documentation](https://capbypass.pro/docs/sdks/typescript)
|
|
297
|
+
- [Dashboard / Sign up](https://capbypass.pro/signup)
|
|
298
|
+
- [Pricing](https://capbypass.pro/pricing)
|
|
272
299
|
- [npm Package](https://www.npmjs.com/package/@capbypass/sdk)
|
|
273
300
|
- [GitHub Repository](https://github.com/CapBypass-Development/capbypass-sdk-typescript)
|
|
274
301
|
- [Bug Reports](https://github.com/CapBypass-Development/capbypass-sdk-typescript/issues)
|
package/dist/index.d.mts
CHANGED
|
@@ -10,6 +10,10 @@ declare const TaskType: {
|
|
|
10
10
|
readonly RECAPTCHA_V3_PROXYLESS: "ReCaptchaV3TaskProxyLess";
|
|
11
11
|
readonly RECAPTCHA_V3_ENTERPRISE: "ReCaptchaV3EnterpriseTask";
|
|
12
12
|
readonly RECAPTCHA_V3_ENTERPRISE_PROXYLESS: "ReCaptchaV3EnterpriseTaskProxyLess";
|
|
13
|
+
readonly GEETEST: "GeetestTask";
|
|
14
|
+
readonly GEETEST_PROXYLESS: "GeetestTaskProxyLess";
|
|
15
|
+
readonly HCAPTCHA: "HCaptchaTask";
|
|
16
|
+
readonly HCAPTCHA_PROXYLESS: "HCaptchaTaskProxyless";
|
|
13
17
|
};
|
|
14
18
|
type TaskTypeValue = typeof TaskType[keyof typeof TaskType];
|
|
15
19
|
/**
|
|
@@ -39,12 +43,21 @@ interface TaskResult {
|
|
|
39
43
|
status?: 'processing' | 'ready' | 'failed';
|
|
40
44
|
solution?: Record<string, any>;
|
|
41
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Pricing item from GET /pricing
|
|
48
|
+
*/
|
|
49
|
+
interface PricingItem {
|
|
50
|
+
task_type: string;
|
|
51
|
+
user_cost: number;
|
|
52
|
+
status: 'active' | 'inactive' | 'soon';
|
|
53
|
+
}
|
|
42
54
|
/**
|
|
43
55
|
* Client configuration options
|
|
44
56
|
*/
|
|
45
57
|
interface ClientOptions {
|
|
46
58
|
apiKey?: string;
|
|
47
59
|
baseURL?: string;
|
|
60
|
+
developerKey?: string;
|
|
48
61
|
}
|
|
49
62
|
|
|
50
63
|
/**
|
|
@@ -52,6 +65,7 @@ interface ClientOptions {
|
|
|
52
65
|
*/
|
|
53
66
|
declare class CapBypassClient {
|
|
54
67
|
private apiKey;
|
|
68
|
+
private developerKey?;
|
|
55
69
|
private httpClient;
|
|
56
70
|
/**
|
|
57
71
|
* Create a new CapBypass client
|
|
@@ -78,6 +92,12 @@ declare class CapBypassClient {
|
|
|
78
92
|
* @returns Task result
|
|
79
93
|
*/
|
|
80
94
|
getTaskResult(taskId: string): Promise<TaskResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Get pricing for all task types.
|
|
97
|
+
* This is a public endpoint and does not require authentication.
|
|
98
|
+
* @returns Array of pricing items with task_type and user_cost
|
|
99
|
+
*/
|
|
100
|
+
getPricing(): Promise<PricingItem[]>;
|
|
81
101
|
/**
|
|
82
102
|
* Get account balance
|
|
83
103
|
* @returns Account balance
|
|
@@ -184,4 +204,4 @@ declare class ParseError extends Error {
|
|
|
184
204
|
constructor(message: string, cause?: Error | undefined);
|
|
185
205
|
}
|
|
186
206
|
|
|
187
|
-
export { AuthenticationError, type BaseTask, CapBypassClient, CapBypassError, type ClientOptions, GatewayError, InsufficientBalanceError, InternalError, NetworkError, ParseError, type ProxyConfig, RateLimitError, ServerError, SolverError, TaskNotFoundError, type TaskResult, TaskType, type TaskTypeValue, TimeoutError, ValidationError };
|
|
207
|
+
export { AuthenticationError, type BaseTask, CapBypassClient, CapBypassError, type ClientOptions, GatewayError, InsufficientBalanceError, InternalError, NetworkError, ParseError, type PricingItem, type ProxyConfig, RateLimitError, ServerError, SolverError, TaskNotFoundError, type TaskResult, TaskType, type TaskTypeValue, TimeoutError, ValidationError };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ declare const TaskType: {
|
|
|
10
10
|
readonly RECAPTCHA_V3_PROXYLESS: "ReCaptchaV3TaskProxyLess";
|
|
11
11
|
readonly RECAPTCHA_V3_ENTERPRISE: "ReCaptchaV3EnterpriseTask";
|
|
12
12
|
readonly RECAPTCHA_V3_ENTERPRISE_PROXYLESS: "ReCaptchaV3EnterpriseTaskProxyLess";
|
|
13
|
+
readonly GEETEST: "GeetestTask";
|
|
14
|
+
readonly GEETEST_PROXYLESS: "GeetestTaskProxyLess";
|
|
15
|
+
readonly HCAPTCHA: "HCaptchaTask";
|
|
16
|
+
readonly HCAPTCHA_PROXYLESS: "HCaptchaTaskProxyless";
|
|
13
17
|
};
|
|
14
18
|
type TaskTypeValue = typeof TaskType[keyof typeof TaskType];
|
|
15
19
|
/**
|
|
@@ -39,12 +43,21 @@ interface TaskResult {
|
|
|
39
43
|
status?: 'processing' | 'ready' | 'failed';
|
|
40
44
|
solution?: Record<string, any>;
|
|
41
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Pricing item from GET /pricing
|
|
48
|
+
*/
|
|
49
|
+
interface PricingItem {
|
|
50
|
+
task_type: string;
|
|
51
|
+
user_cost: number;
|
|
52
|
+
status: 'active' | 'inactive' | 'soon';
|
|
53
|
+
}
|
|
42
54
|
/**
|
|
43
55
|
* Client configuration options
|
|
44
56
|
*/
|
|
45
57
|
interface ClientOptions {
|
|
46
58
|
apiKey?: string;
|
|
47
59
|
baseURL?: string;
|
|
60
|
+
developerKey?: string;
|
|
48
61
|
}
|
|
49
62
|
|
|
50
63
|
/**
|
|
@@ -52,6 +65,7 @@ interface ClientOptions {
|
|
|
52
65
|
*/
|
|
53
66
|
declare class CapBypassClient {
|
|
54
67
|
private apiKey;
|
|
68
|
+
private developerKey?;
|
|
55
69
|
private httpClient;
|
|
56
70
|
/**
|
|
57
71
|
* Create a new CapBypass client
|
|
@@ -78,6 +92,12 @@ declare class CapBypassClient {
|
|
|
78
92
|
* @returns Task result
|
|
79
93
|
*/
|
|
80
94
|
getTaskResult(taskId: string): Promise<TaskResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Get pricing for all task types.
|
|
97
|
+
* This is a public endpoint and does not require authentication.
|
|
98
|
+
* @returns Array of pricing items with task_type and user_cost
|
|
99
|
+
*/
|
|
100
|
+
getPricing(): Promise<PricingItem[]>;
|
|
81
101
|
/**
|
|
82
102
|
* Get account balance
|
|
83
103
|
* @returns Account balance
|
|
@@ -184,4 +204,4 @@ declare class ParseError extends Error {
|
|
|
184
204
|
constructor(message: string, cause?: Error | undefined);
|
|
185
205
|
}
|
|
186
206
|
|
|
187
|
-
export { AuthenticationError, type BaseTask, CapBypassClient, CapBypassError, type ClientOptions, GatewayError, InsufficientBalanceError, InternalError, NetworkError, ParseError, type ProxyConfig, RateLimitError, ServerError, SolverError, TaskNotFoundError, type TaskResult, TaskType, type TaskTypeValue, TimeoutError, ValidationError };
|
|
207
|
+
export { AuthenticationError, type BaseTask, CapBypassClient, CapBypassError, type ClientOptions, GatewayError, InsufficientBalanceError, InternalError, NetworkError, ParseError, type PricingItem, type ProxyConfig, RateLimitError, ServerError, SolverError, TaskNotFoundError, type TaskResult, TaskType, type TaskTypeValue, TimeoutError, ValidationError };
|
package/dist/index.js
CHANGED
|
@@ -139,24 +139,31 @@ var ParseError = class _ParseError extends Error {
|
|
|
139
139
|
function parseError(errorCode, errorDescription) {
|
|
140
140
|
switch (errorCode) {
|
|
141
141
|
case "ERROR_KEY_DOES_NOT_EXIST":
|
|
142
|
-
case "ERROR_KEY_DENIED_ACCESS":
|
|
143
142
|
throw new AuthenticationError(errorCode, errorDescription);
|
|
144
143
|
case "ERROR_ZERO_BALANCE":
|
|
145
|
-
case "ERROR_NO_SLOT_AVAILABLE":
|
|
146
144
|
throw new InsufficientBalanceError(errorCode, errorDescription);
|
|
147
145
|
case "ERROR_INVALID_TASK_DATA":
|
|
148
|
-
case "
|
|
149
|
-
case "
|
|
146
|
+
case "ERROR_INVALID_DEVELOPER_KEY":
|
|
147
|
+
case "ERROR_PROXY_NOT_DEFINED":
|
|
148
|
+
case "ERROR_WRONG_TASK_TYPE":
|
|
149
|
+
case "ERROR_TASK_TYPE_COMING_SOON":
|
|
150
|
+
case "ERROR_TASK_TYPE_INACTIVE":
|
|
150
151
|
throw new ValidationError(errorCode, errorDescription);
|
|
151
152
|
case "ERROR_TASK_NOT_FOUND":
|
|
152
153
|
throw new TaskNotFoundError(errorCode, errorDescription);
|
|
154
|
+
case "ERROR_CAPTCHA_UNSOLVABLE":
|
|
155
|
+
throw new SolverError(errorDescription);
|
|
156
|
+
case "ERROR_TIMEOUT":
|
|
157
|
+
throw new TimeoutError();
|
|
158
|
+
// ERROR_TASK_QUEUE_FULL, ERROR_WORKER_CRASHED, ERROR_INTERNAL, and any
|
|
159
|
+
// unknown code -> retryable internal failure.
|
|
153
160
|
default:
|
|
154
161
|
throw new InternalError(errorCode, errorDescription);
|
|
155
162
|
}
|
|
156
163
|
}
|
|
157
164
|
|
|
158
165
|
// src/client.ts
|
|
159
|
-
var DEFAULT_BASE_URL = "https://
|
|
166
|
+
var DEFAULT_BASE_URL = "https://api.capbypass.pro";
|
|
160
167
|
var SDK_VERSION = "1.0.0";
|
|
161
168
|
var USER_AGENT = `capbypass-sdk-typescript/${SDK_VERSION}`;
|
|
162
169
|
var CapBypassClient = class {
|
|
@@ -166,6 +173,7 @@ var CapBypassClient = class {
|
|
|
166
173
|
*/
|
|
167
174
|
constructor(options = {}) {
|
|
168
175
|
this.apiKey = options.apiKey || process.env.CAPBYPASS_API_KEY || "";
|
|
176
|
+
this.developerKey = options.developerKey || process.env.CAPBYPASS_DEVELOPER_KEY || void 0;
|
|
169
177
|
if (!this.apiKey) {
|
|
170
178
|
throw new Error(
|
|
171
179
|
"API key is required. Provide via constructor or CAPBYPASS_API_KEY environment variable."
|
|
@@ -247,7 +255,8 @@ var CapBypassClient = class {
|
|
|
247
255
|
async createTask(task) {
|
|
248
256
|
const request = {
|
|
249
257
|
clientKey: this.apiKey,
|
|
250
|
-
task
|
|
258
|
+
task,
|
|
259
|
+
...this.developerKey && { developerKey: this.developerKey }
|
|
251
260
|
};
|
|
252
261
|
const response = await this.makeRequest(
|
|
253
262
|
"/createTask",
|
|
@@ -277,6 +286,44 @@ var CapBypassClient = class {
|
|
|
277
286
|
}
|
|
278
287
|
return response;
|
|
279
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Get pricing for all task types.
|
|
291
|
+
* This is a public endpoint and does not require authentication.
|
|
292
|
+
* @returns Array of pricing items with task_type and user_cost
|
|
293
|
+
*/
|
|
294
|
+
async getPricing() {
|
|
295
|
+
let lastError;
|
|
296
|
+
for (let attempt = 0; attempt <= 3; attempt++) {
|
|
297
|
+
try {
|
|
298
|
+
const response = await this.httpClient.get("/pricing");
|
|
299
|
+
return response.data.pricing;
|
|
300
|
+
} catch (error) {
|
|
301
|
+
const axiosError = error;
|
|
302
|
+
if (axiosError.response && [502, 503, 504].includes(axiosError.response.status)) {
|
|
303
|
+
if (attempt < 3) {
|
|
304
|
+
const backoff = Math.min(10, Math.pow(2, attempt)) + Math.random();
|
|
305
|
+
await this.sleep(backoff * 1e3);
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
throw new GatewayError(
|
|
309
|
+
axiosError.response.status,
|
|
310
|
+
axiosError.response.data
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
if (axiosError.code === "ECONNREFUSED" || axiosError.code === "ETIMEDOUT") {
|
|
314
|
+
if (attempt < 3) {
|
|
315
|
+
const backoff = Math.min(10, Math.pow(2, attempt)) + Math.random();
|
|
316
|
+
await this.sleep(backoff * 1e3);
|
|
317
|
+
lastError = new NetworkError("Connection failed", axiosError);
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
throw new NetworkError("Connection failed", axiosError);
|
|
321
|
+
}
|
|
322
|
+
throw new NetworkError(axiosError.message, axiosError);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
throw lastError;
|
|
326
|
+
}
|
|
280
327
|
/**
|
|
281
328
|
* Get account balance
|
|
282
329
|
* @returns Account balance
|
|
@@ -338,7 +385,13 @@ var TaskType = {
|
|
|
338
385
|
RECAPTCHA_V3_PROXYLESS: "ReCaptchaV3TaskProxyLess",
|
|
339
386
|
// reCAPTCHA v3 Enterprise
|
|
340
387
|
RECAPTCHA_V3_ENTERPRISE: "ReCaptchaV3EnterpriseTask",
|
|
341
|
-
RECAPTCHA_V3_ENTERPRISE_PROXYLESS: "ReCaptchaV3EnterpriseTaskProxyLess"
|
|
388
|
+
RECAPTCHA_V3_ENTERPRISE_PROXYLESS: "ReCaptchaV3EnterpriseTaskProxyLess",
|
|
389
|
+
// GeeTest v3 + v4
|
|
390
|
+
GEETEST: "GeetestTask",
|
|
391
|
+
GEETEST_PROXYLESS: "GeetestTaskProxyLess",
|
|
392
|
+
// hCaptcha
|
|
393
|
+
HCAPTCHA: "HCaptchaTask",
|
|
394
|
+
HCAPTCHA_PROXYLESS: "HCaptchaTaskProxyless"
|
|
342
395
|
};
|
|
343
396
|
// Annotate the CommonJS export names for ESM import in node:
|
|
344
397
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -89,24 +89,31 @@ var ParseError = class _ParseError extends Error {
|
|
|
89
89
|
function parseError(errorCode, errorDescription) {
|
|
90
90
|
switch (errorCode) {
|
|
91
91
|
case "ERROR_KEY_DOES_NOT_EXIST":
|
|
92
|
-
case "ERROR_KEY_DENIED_ACCESS":
|
|
93
92
|
throw new AuthenticationError(errorCode, errorDescription);
|
|
94
93
|
case "ERROR_ZERO_BALANCE":
|
|
95
|
-
case "ERROR_NO_SLOT_AVAILABLE":
|
|
96
94
|
throw new InsufficientBalanceError(errorCode, errorDescription);
|
|
97
95
|
case "ERROR_INVALID_TASK_DATA":
|
|
98
|
-
case "
|
|
99
|
-
case "
|
|
96
|
+
case "ERROR_INVALID_DEVELOPER_KEY":
|
|
97
|
+
case "ERROR_PROXY_NOT_DEFINED":
|
|
98
|
+
case "ERROR_WRONG_TASK_TYPE":
|
|
99
|
+
case "ERROR_TASK_TYPE_COMING_SOON":
|
|
100
|
+
case "ERROR_TASK_TYPE_INACTIVE":
|
|
100
101
|
throw new ValidationError(errorCode, errorDescription);
|
|
101
102
|
case "ERROR_TASK_NOT_FOUND":
|
|
102
103
|
throw new TaskNotFoundError(errorCode, errorDescription);
|
|
104
|
+
case "ERROR_CAPTCHA_UNSOLVABLE":
|
|
105
|
+
throw new SolverError(errorDescription);
|
|
106
|
+
case "ERROR_TIMEOUT":
|
|
107
|
+
throw new TimeoutError();
|
|
108
|
+
// ERROR_TASK_QUEUE_FULL, ERROR_WORKER_CRASHED, ERROR_INTERNAL, and any
|
|
109
|
+
// unknown code -> retryable internal failure.
|
|
103
110
|
default:
|
|
104
111
|
throw new InternalError(errorCode, errorDescription);
|
|
105
112
|
}
|
|
106
113
|
}
|
|
107
114
|
|
|
108
115
|
// src/client.ts
|
|
109
|
-
var DEFAULT_BASE_URL = "https://
|
|
116
|
+
var DEFAULT_BASE_URL = "https://api.capbypass.pro";
|
|
110
117
|
var SDK_VERSION = "1.0.0";
|
|
111
118
|
var USER_AGENT = `capbypass-sdk-typescript/${SDK_VERSION}`;
|
|
112
119
|
var CapBypassClient = class {
|
|
@@ -116,6 +123,7 @@ var CapBypassClient = class {
|
|
|
116
123
|
*/
|
|
117
124
|
constructor(options = {}) {
|
|
118
125
|
this.apiKey = options.apiKey || process.env.CAPBYPASS_API_KEY || "";
|
|
126
|
+
this.developerKey = options.developerKey || process.env.CAPBYPASS_DEVELOPER_KEY || void 0;
|
|
119
127
|
if (!this.apiKey) {
|
|
120
128
|
throw new Error(
|
|
121
129
|
"API key is required. Provide via constructor or CAPBYPASS_API_KEY environment variable."
|
|
@@ -197,7 +205,8 @@ var CapBypassClient = class {
|
|
|
197
205
|
async createTask(task) {
|
|
198
206
|
const request = {
|
|
199
207
|
clientKey: this.apiKey,
|
|
200
|
-
task
|
|
208
|
+
task,
|
|
209
|
+
...this.developerKey && { developerKey: this.developerKey }
|
|
201
210
|
};
|
|
202
211
|
const response = await this.makeRequest(
|
|
203
212
|
"/createTask",
|
|
@@ -227,6 +236,44 @@ var CapBypassClient = class {
|
|
|
227
236
|
}
|
|
228
237
|
return response;
|
|
229
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* Get pricing for all task types.
|
|
241
|
+
* This is a public endpoint and does not require authentication.
|
|
242
|
+
* @returns Array of pricing items with task_type and user_cost
|
|
243
|
+
*/
|
|
244
|
+
async getPricing() {
|
|
245
|
+
let lastError;
|
|
246
|
+
for (let attempt = 0; attempt <= 3; attempt++) {
|
|
247
|
+
try {
|
|
248
|
+
const response = await this.httpClient.get("/pricing");
|
|
249
|
+
return response.data.pricing;
|
|
250
|
+
} catch (error) {
|
|
251
|
+
const axiosError = error;
|
|
252
|
+
if (axiosError.response && [502, 503, 504].includes(axiosError.response.status)) {
|
|
253
|
+
if (attempt < 3) {
|
|
254
|
+
const backoff = Math.min(10, Math.pow(2, attempt)) + Math.random();
|
|
255
|
+
await this.sleep(backoff * 1e3);
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
throw new GatewayError(
|
|
259
|
+
axiosError.response.status,
|
|
260
|
+
axiosError.response.data
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
if (axiosError.code === "ECONNREFUSED" || axiosError.code === "ETIMEDOUT") {
|
|
264
|
+
if (attempt < 3) {
|
|
265
|
+
const backoff = Math.min(10, Math.pow(2, attempt)) + Math.random();
|
|
266
|
+
await this.sleep(backoff * 1e3);
|
|
267
|
+
lastError = new NetworkError("Connection failed", axiosError);
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
throw new NetworkError("Connection failed", axiosError);
|
|
271
|
+
}
|
|
272
|
+
throw new NetworkError(axiosError.message, axiosError);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
throw lastError;
|
|
276
|
+
}
|
|
230
277
|
/**
|
|
231
278
|
* Get account balance
|
|
232
279
|
* @returns Account balance
|
|
@@ -288,7 +335,13 @@ var TaskType = {
|
|
|
288
335
|
RECAPTCHA_V3_PROXYLESS: "ReCaptchaV3TaskProxyLess",
|
|
289
336
|
// reCAPTCHA v3 Enterprise
|
|
290
337
|
RECAPTCHA_V3_ENTERPRISE: "ReCaptchaV3EnterpriseTask",
|
|
291
|
-
RECAPTCHA_V3_ENTERPRISE_PROXYLESS: "ReCaptchaV3EnterpriseTaskProxyLess"
|
|
338
|
+
RECAPTCHA_V3_ENTERPRISE_PROXYLESS: "ReCaptchaV3EnterpriseTaskProxyLess",
|
|
339
|
+
// GeeTest v3 + v4
|
|
340
|
+
GEETEST: "GeetestTask",
|
|
341
|
+
GEETEST_PROXYLESS: "GeetestTaskProxyLess",
|
|
342
|
+
// hCaptcha
|
|
343
|
+
HCAPTCHA: "HCaptchaTask",
|
|
344
|
+
HCAPTCHA_PROXYLESS: "HCaptchaTaskProxyless"
|
|
292
345
|
};
|
|
293
346
|
export {
|
|
294
347
|
AuthenticationError,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capbypass/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Official TypeScript/JavaScript SDK for CapBypass CAPTCHA solving service",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://capbypass.dev/docs/sdks/typescript",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"axios": "^1.
|
|
50
|
+
"axios": "^1.13.5"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/jest": "^29.5.12",
|
|
@@ -63,6 +63,6 @@
|
|
|
63
63
|
"typescript": "^5.3.3"
|
|
64
64
|
},
|
|
65
65
|
"engines": {
|
|
66
|
-
"node": ">=
|
|
66
|
+
"node": ">=18.12.0"
|
|
67
67
|
}
|
|
68
68
|
}
|