@capbypass/sdk 1.0.0 → 1.0.4
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 +25 -1
- package/dist/index.d.mts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +45 -2
- package/dist/index.mjs +45 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -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.dev/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
|
package/dist/index.d.mts
CHANGED
|
@@ -39,12 +39,21 @@ interface TaskResult {
|
|
|
39
39
|
status?: 'processing' | 'ready' | 'failed';
|
|
40
40
|
solution?: Record<string, any>;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Pricing item from GET /pricing
|
|
44
|
+
*/
|
|
45
|
+
interface PricingItem {
|
|
46
|
+
task_type: string;
|
|
47
|
+
user_cost: number;
|
|
48
|
+
status: 'active' | 'inactive' | 'soon';
|
|
49
|
+
}
|
|
42
50
|
/**
|
|
43
51
|
* Client configuration options
|
|
44
52
|
*/
|
|
45
53
|
interface ClientOptions {
|
|
46
54
|
apiKey?: string;
|
|
47
55
|
baseURL?: string;
|
|
56
|
+
developerKey?: string;
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
/**
|
|
@@ -52,6 +61,7 @@ interface ClientOptions {
|
|
|
52
61
|
*/
|
|
53
62
|
declare class CapBypassClient {
|
|
54
63
|
private apiKey;
|
|
64
|
+
private developerKey?;
|
|
55
65
|
private httpClient;
|
|
56
66
|
/**
|
|
57
67
|
* Create a new CapBypass client
|
|
@@ -78,6 +88,12 @@ declare class CapBypassClient {
|
|
|
78
88
|
* @returns Task result
|
|
79
89
|
*/
|
|
80
90
|
getTaskResult(taskId: string): Promise<TaskResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Get pricing for all task types.
|
|
93
|
+
* This is a public endpoint and does not require authentication.
|
|
94
|
+
* @returns Array of pricing items with task_type and user_cost
|
|
95
|
+
*/
|
|
96
|
+
getPricing(): Promise<PricingItem[]>;
|
|
81
97
|
/**
|
|
82
98
|
* Get account balance
|
|
83
99
|
* @returns Account balance
|
|
@@ -184,4 +200,4 @@ declare class ParseError extends Error {
|
|
|
184
200
|
constructor(message: string, cause?: Error | undefined);
|
|
185
201
|
}
|
|
186
202
|
|
|
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 };
|
|
203
|
+
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
|
@@ -39,12 +39,21 @@ interface TaskResult {
|
|
|
39
39
|
status?: 'processing' | 'ready' | 'failed';
|
|
40
40
|
solution?: Record<string, any>;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Pricing item from GET /pricing
|
|
44
|
+
*/
|
|
45
|
+
interface PricingItem {
|
|
46
|
+
task_type: string;
|
|
47
|
+
user_cost: number;
|
|
48
|
+
status: 'active' | 'inactive' | 'soon';
|
|
49
|
+
}
|
|
42
50
|
/**
|
|
43
51
|
* Client configuration options
|
|
44
52
|
*/
|
|
45
53
|
interface ClientOptions {
|
|
46
54
|
apiKey?: string;
|
|
47
55
|
baseURL?: string;
|
|
56
|
+
developerKey?: string;
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
/**
|
|
@@ -52,6 +61,7 @@ interface ClientOptions {
|
|
|
52
61
|
*/
|
|
53
62
|
declare class CapBypassClient {
|
|
54
63
|
private apiKey;
|
|
64
|
+
private developerKey?;
|
|
55
65
|
private httpClient;
|
|
56
66
|
/**
|
|
57
67
|
* Create a new CapBypass client
|
|
@@ -78,6 +88,12 @@ declare class CapBypassClient {
|
|
|
78
88
|
* @returns Task result
|
|
79
89
|
*/
|
|
80
90
|
getTaskResult(taskId: string): Promise<TaskResult>;
|
|
91
|
+
/**
|
|
92
|
+
* Get pricing for all task types.
|
|
93
|
+
* This is a public endpoint and does not require authentication.
|
|
94
|
+
* @returns Array of pricing items with task_type and user_cost
|
|
95
|
+
*/
|
|
96
|
+
getPricing(): Promise<PricingItem[]>;
|
|
81
97
|
/**
|
|
82
98
|
* Get account balance
|
|
83
99
|
* @returns Account balance
|
|
@@ -184,4 +200,4 @@ declare class ParseError extends Error {
|
|
|
184
200
|
constructor(message: string, cause?: Error | undefined);
|
|
185
201
|
}
|
|
186
202
|
|
|
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 };
|
|
203
|
+
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
|
@@ -147,6 +147,9 @@ function parseError(errorCode, errorDescription) {
|
|
|
147
147
|
case "ERROR_INVALID_TASK_DATA":
|
|
148
148
|
case "ERROR_TASK_ABSENT":
|
|
149
149
|
case "ERROR_TASK_NOT_SUPPORTED":
|
|
150
|
+
case "TASK_TYPE_COMING_SOON":
|
|
151
|
+
case "TASK_TYPE_INACTIVE":
|
|
152
|
+
case "ERROR_INVALID_DEVELOPER_KEY":
|
|
150
153
|
throw new ValidationError(errorCode, errorDescription);
|
|
151
154
|
case "ERROR_TASK_NOT_FOUND":
|
|
152
155
|
throw new TaskNotFoundError(errorCode, errorDescription);
|
|
@@ -156,7 +159,7 @@ function parseError(errorCode, errorDescription) {
|
|
|
156
159
|
}
|
|
157
160
|
|
|
158
161
|
// src/client.ts
|
|
159
|
-
var DEFAULT_BASE_URL = "https://
|
|
162
|
+
var DEFAULT_BASE_URL = "https://api.capbypass.pro";
|
|
160
163
|
var SDK_VERSION = "1.0.0";
|
|
161
164
|
var USER_AGENT = `capbypass-sdk-typescript/${SDK_VERSION}`;
|
|
162
165
|
var CapBypassClient = class {
|
|
@@ -166,6 +169,7 @@ var CapBypassClient = class {
|
|
|
166
169
|
*/
|
|
167
170
|
constructor(options = {}) {
|
|
168
171
|
this.apiKey = options.apiKey || process.env.CAPBYPASS_API_KEY || "";
|
|
172
|
+
this.developerKey = options.developerKey || process.env.CAPBYPASS_DEVELOPER_KEY || void 0;
|
|
169
173
|
if (!this.apiKey) {
|
|
170
174
|
throw new Error(
|
|
171
175
|
"API key is required. Provide via constructor or CAPBYPASS_API_KEY environment variable."
|
|
@@ -247,7 +251,8 @@ var CapBypassClient = class {
|
|
|
247
251
|
async createTask(task) {
|
|
248
252
|
const request = {
|
|
249
253
|
clientKey: this.apiKey,
|
|
250
|
-
task
|
|
254
|
+
task,
|
|
255
|
+
...this.developerKey && { developerKey: this.developerKey }
|
|
251
256
|
};
|
|
252
257
|
const response = await this.makeRequest(
|
|
253
258
|
"/createTask",
|
|
@@ -277,6 +282,44 @@ var CapBypassClient = class {
|
|
|
277
282
|
}
|
|
278
283
|
return response;
|
|
279
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Get pricing for all task types.
|
|
287
|
+
* This is a public endpoint and does not require authentication.
|
|
288
|
+
* @returns Array of pricing items with task_type and user_cost
|
|
289
|
+
*/
|
|
290
|
+
async getPricing() {
|
|
291
|
+
let lastError;
|
|
292
|
+
for (let attempt = 0; attempt <= 3; attempt++) {
|
|
293
|
+
try {
|
|
294
|
+
const response = await this.httpClient.get("/pricing");
|
|
295
|
+
return response.data.pricing;
|
|
296
|
+
} catch (error) {
|
|
297
|
+
const axiosError = error;
|
|
298
|
+
if (axiosError.response && [502, 503, 504].includes(axiosError.response.status)) {
|
|
299
|
+
if (attempt < 3) {
|
|
300
|
+
const backoff = Math.min(10, Math.pow(2, attempt)) + Math.random();
|
|
301
|
+
await this.sleep(backoff * 1e3);
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
throw new GatewayError(
|
|
305
|
+
axiosError.response.status,
|
|
306
|
+
axiosError.response.data
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
if (axiosError.code === "ECONNREFUSED" || axiosError.code === "ETIMEDOUT") {
|
|
310
|
+
if (attempt < 3) {
|
|
311
|
+
const backoff = Math.min(10, Math.pow(2, attempt)) + Math.random();
|
|
312
|
+
await this.sleep(backoff * 1e3);
|
|
313
|
+
lastError = new NetworkError("Connection failed", axiosError);
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
throw new NetworkError("Connection failed", axiosError);
|
|
317
|
+
}
|
|
318
|
+
throw new NetworkError(axiosError.message, axiosError);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
throw lastError;
|
|
322
|
+
}
|
|
280
323
|
/**
|
|
281
324
|
* Get account balance
|
|
282
325
|
* @returns Account balance
|
package/dist/index.mjs
CHANGED
|
@@ -97,6 +97,9 @@ function parseError(errorCode, errorDescription) {
|
|
|
97
97
|
case "ERROR_INVALID_TASK_DATA":
|
|
98
98
|
case "ERROR_TASK_ABSENT":
|
|
99
99
|
case "ERROR_TASK_NOT_SUPPORTED":
|
|
100
|
+
case "TASK_TYPE_COMING_SOON":
|
|
101
|
+
case "TASK_TYPE_INACTIVE":
|
|
102
|
+
case "ERROR_INVALID_DEVELOPER_KEY":
|
|
100
103
|
throw new ValidationError(errorCode, errorDescription);
|
|
101
104
|
case "ERROR_TASK_NOT_FOUND":
|
|
102
105
|
throw new TaskNotFoundError(errorCode, errorDescription);
|
|
@@ -106,7 +109,7 @@ function parseError(errorCode, errorDescription) {
|
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
// src/client.ts
|
|
109
|
-
var DEFAULT_BASE_URL = "https://
|
|
112
|
+
var DEFAULT_BASE_URL = "https://api.capbypass.pro";
|
|
110
113
|
var SDK_VERSION = "1.0.0";
|
|
111
114
|
var USER_AGENT = `capbypass-sdk-typescript/${SDK_VERSION}`;
|
|
112
115
|
var CapBypassClient = class {
|
|
@@ -116,6 +119,7 @@ var CapBypassClient = class {
|
|
|
116
119
|
*/
|
|
117
120
|
constructor(options = {}) {
|
|
118
121
|
this.apiKey = options.apiKey || process.env.CAPBYPASS_API_KEY || "";
|
|
122
|
+
this.developerKey = options.developerKey || process.env.CAPBYPASS_DEVELOPER_KEY || void 0;
|
|
119
123
|
if (!this.apiKey) {
|
|
120
124
|
throw new Error(
|
|
121
125
|
"API key is required. Provide via constructor or CAPBYPASS_API_KEY environment variable."
|
|
@@ -197,7 +201,8 @@ var CapBypassClient = class {
|
|
|
197
201
|
async createTask(task) {
|
|
198
202
|
const request = {
|
|
199
203
|
clientKey: this.apiKey,
|
|
200
|
-
task
|
|
204
|
+
task,
|
|
205
|
+
...this.developerKey && { developerKey: this.developerKey }
|
|
201
206
|
};
|
|
202
207
|
const response = await this.makeRequest(
|
|
203
208
|
"/createTask",
|
|
@@ -227,6 +232,44 @@ var CapBypassClient = class {
|
|
|
227
232
|
}
|
|
228
233
|
return response;
|
|
229
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Get pricing for all task types.
|
|
237
|
+
* This is a public endpoint and does not require authentication.
|
|
238
|
+
* @returns Array of pricing items with task_type and user_cost
|
|
239
|
+
*/
|
|
240
|
+
async getPricing() {
|
|
241
|
+
let lastError;
|
|
242
|
+
for (let attempt = 0; attempt <= 3; attempt++) {
|
|
243
|
+
try {
|
|
244
|
+
const response = await this.httpClient.get("/pricing");
|
|
245
|
+
return response.data.pricing;
|
|
246
|
+
} catch (error) {
|
|
247
|
+
const axiosError = error;
|
|
248
|
+
if (axiosError.response && [502, 503, 504].includes(axiosError.response.status)) {
|
|
249
|
+
if (attempt < 3) {
|
|
250
|
+
const backoff = Math.min(10, Math.pow(2, attempt)) + Math.random();
|
|
251
|
+
await this.sleep(backoff * 1e3);
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
throw new GatewayError(
|
|
255
|
+
axiosError.response.status,
|
|
256
|
+
axiosError.response.data
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
if (axiosError.code === "ECONNREFUSED" || axiosError.code === "ETIMEDOUT") {
|
|
260
|
+
if (attempt < 3) {
|
|
261
|
+
const backoff = Math.min(10, Math.pow(2, attempt)) + Math.random();
|
|
262
|
+
await this.sleep(backoff * 1e3);
|
|
263
|
+
lastError = new NetworkError("Connection failed", axiosError);
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
throw new NetworkError("Connection failed", axiosError);
|
|
267
|
+
}
|
|
268
|
+
throw new NetworkError(axiosError.message, axiosError);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
throw lastError;
|
|
272
|
+
}
|
|
230
273
|
/**
|
|
231
274
|
* Get account balance
|
|
232
275
|
* @returns Account balance
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capbypass/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Official TypeScript/JavaScript SDK for CapBypass CAPTCHA solving service",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -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
|
}
|