recognize 2.0.0 → 3.1.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 CHANGED
@@ -0,0 +1,443 @@
1
+ # Recognize
2
+
3
+ **[English](#english)** | **[Русский](#русский)**
4
+
5
+ ---
6
+
7
+ ## English
8
+
9
+ Lightweight zero-dependency captcha solving client for **RuCaptcha** and **Anti-Captcha** services (API v2).
10
+
11
+ - **0 runtime dependencies** — uses native `fetch` (Node.js 18+)
12
+ - **TypeScript** — full type safety, autocompletion, exported types
13
+ - **Dual ESM/CJS** — works with `import` and `require`
14
+ - **30+ captcha types** — reCAPTCHA, hCaptcha, Turnstile, FunCaptcha, GeeTest, and more
15
+ - **Auto-polling** — waits for result with configurable interval & timeout
16
+
17
+ ### Install
18
+
19
+ ```bash
20
+ npm install recognize
21
+ ```
22
+
23
+ ### Quick Start
24
+
25
+ ```ts
26
+ import { RuCaptcha } from "recognize";
27
+
28
+ const solver = new RuCaptcha({
29
+ apiKey: "YOUR_API_KEY",
30
+ pollingInterval: 5000, // optional, default 5000ms
31
+ timeout: 180000, // optional, default 180000ms
32
+ });
33
+
34
+ // Check balance
35
+ const balance = await solver.getBalance();
36
+ console.log("Balance:", balance);
37
+
38
+ // Solve reCAPTCHA v2
39
+ const { taskId, solution } = await solver.recaptchaV2(
40
+ "https://example.com",
41
+ "SITE_KEY",
42
+ );
43
+ console.log(solution.gRecaptchaResponse);
44
+
45
+ // Report result
46
+ await solver.reportCorrect(taskId);
47
+ ```
48
+
49
+ ### Anti-Captcha
50
+
51
+ ```ts
52
+ import { AntiCaptcha } from "recognize";
53
+
54
+ const solver = new AntiCaptcha({ apiKey: "YOUR_API_KEY" });
55
+ ```
56
+
57
+ ### Dynamic service selection
58
+
59
+ ```ts
60
+ import { createSolver } from "recognize";
61
+
62
+ const solver = createSolver("rucaptcha", { apiKey: "YOUR_API_KEY" });
63
+ // or
64
+ const solver2 = createSolver("anticaptcha", { apiKey: "YOUR_API_KEY" });
65
+ ```
66
+
67
+ ### Constructor Options
68
+
69
+ | Option | Type | Default | Description |
70
+ | ----------------- | -------- | -------- | ---------------------------- |
71
+ | `apiKey` | `string` | — | **Required.** API key |
72
+ | `pollingInterval` | `number` | `5000` | Polling interval in ms |
73
+ | `timeout` | `number` | `180000` | Max wait time per task in ms |
74
+
75
+ ### API
76
+
77
+ All solving methods return `Promise<TaskResult<T>>` where `TaskResult<T> = { taskId: number, solution: T }`.
78
+
79
+ ### Account
80
+
81
+ | Method | Description |
82
+ | ------------------------- | ------------------------- |
83
+ | `getBalance()` | Get account balance |
84
+ | `reportCorrect(taskId)` | Report correct solution |
85
+ | `reportIncorrect(taskId)` | Report incorrect solution |
86
+
87
+ ### Image & Text
88
+
89
+ | Method | Params | Task Type |
90
+ | ------------------------------ | ------------------------------------------------- | ----------------- |
91
+ | `imageCaptcha(body, options?)` | `body` — Buffer or base64 string | `ImageToTextTask` |
92
+ | `textCaptcha(text, options?)` | `text` — question string | `TextCaptchaTask` |
93
+ | `audioCaptcha(body, lang?)` | `body` — Buffer or base64, `lang` — language code | `AudioTask` |
94
+
95
+ ### reCAPTCHA
96
+
97
+ | Method | Params |
98
+ | -------------------------------------------------------- | ---------------------------------- |
99
+ | `recaptchaV2(url, siteKey, options?)` | Supports proxy via `options.proxy` |
100
+ | `recaptchaV3(url, siteKey, action, minScore?, options?)` | `minScore` default `0.3` |
101
+ | `recaptchaV2Enterprise(url, siteKey, options?)` | Enterprise version |
102
+
103
+ ### hCaptcha
104
+
105
+ ```ts
106
+ await solver.hcaptcha(url, siteKey, options?)
107
+ ```
108
+
109
+ ### Cloudflare Turnstile
110
+
111
+ ```ts
112
+ await solver.turnstile(url, siteKey, options?)
113
+ ```
114
+
115
+ ### FunCaptcha (Arkose Labs)
116
+
117
+ ```ts
118
+ await solver.funcaptcha(url, publicKey, options?)
119
+ ```
120
+
121
+ ### GeeTest
122
+
123
+ ```ts
124
+ await solver.geetest(url, gt, challenge, options?)
125
+ await solver.geetestV4(url, captchaId, options?)
126
+ ```
127
+
128
+ ### Amazon WAF
129
+
130
+ ```ts
131
+ await solver.amazonWaf(url, siteKey, options?)
132
+ ```
133
+
134
+ ### Other Captcha Types
135
+
136
+ | Method | Task Type |
137
+ | -------------------------------------------------------- | --------------------------------- |
138
+ | `keyCaptcha(url, options?)` | `KeyCaptchaTaskProxyless` |
139
+ | `lemin(url, captchaId, apiServer, options?)` | `LeminTaskProxyless` |
140
+ | `capyPuzzle(url, siteKey, options?)` | `CapyTaskProxyless` |
141
+ | `dataDome(url, captchaUrl, userAgent, proxyConfig)` | `DataDomeSliderTask` |
142
+ | `cyberSiara(url, slideMasterUrlId, userAgent, options?)` | `AntiCyberSiAraTaskProxyless` |
143
+ | `mtCaptcha(url, siteKey, options?)` | `MtCaptchaTaskProxyless` |
144
+ | `friendlyCaptcha(url, siteKey, options?)` | `FriendlyCaptchaTaskProxyless` |
145
+ | `cutcaptcha(url, miseryKey, apiKey, options?)` | `CutCaptchaTaskProxyless` |
146
+ | `tencent(url, appId, options?)` | `TencentTaskProxyless` |
147
+ | `atbCaptcha(url, appId, apiServer, options?)` | `AtbCaptchaTaskProxyless` |
148
+ | `yandexSmart(url, siteKey, options?)` | `YandexSmartCaptchaTaskProxyless` |
149
+ | `vkCaptcha(url, siteKey, options?)` | `VKCaptchaTaskProxyless` |
150
+ | `temuCaptcha(url, options?)` | `TemuCaptchaTaskProxyless` |
151
+
152
+ ### Image-Based Tasks
153
+
154
+ | Method | Task Type |
155
+ | ------------------------------------ | ----------------- |
156
+ | `rotateCaptcha(body, options?)` | `RotateTask` |
157
+ | `coordinatesCaptcha(body, options?)` | `CoordinatesTask` |
158
+ | `gridCaptcha(body, options?)` | `GridTask` |
159
+ | `boundingBoxCaptcha(body, options?)` | `BoundingBoxTask` |
160
+ | `drawAroundCaptcha(body, options?)` | `DrawAroundTask` |
161
+
162
+ ### Generic / Custom
163
+
164
+ ```ts
165
+ // Send any task type directly
166
+ await solver.solve<{ token: string }>({
167
+ type: "SomeNewTaskType",
168
+ websiteURL: "https://example.com",
169
+ });
170
+ ```
171
+
172
+ ### Proxy Support
173
+
174
+ Methods that support proxy accept it via options:
175
+
176
+ ```ts
177
+ await solver.recaptchaV2("https://example.com", "SITE_KEY", {
178
+ proxyType: "http",
179
+ proxyAddress: "1.2.3.4",
180
+ proxyPort: 8080,
181
+ proxyLogin: "user",
182
+ proxyPassword: "pass",
183
+ proxy: true,
184
+ });
185
+ ```
186
+
187
+ ### Exported Types
188
+
189
+ ```ts
190
+ import type {
191
+ SolverOptions,
192
+ TaskResult,
193
+ TokenSolution,
194
+ GRecaptchaSolution,
195
+ ImageSolution,
196
+ GeeTestSolution,
197
+ GeeTestV4Solution,
198
+ ProxyOptions,
199
+ RecaptchaV2Options,
200
+ HCaptchaOptions,
201
+ TurnstileOptions,
202
+ // ... and more
203
+ } from "recognize";
204
+ ```
205
+
206
+ ### Migration from v2
207
+
208
+ | v2 (old) | v3 (current) |
209
+ | --------------------------------------- | ------------------------------- |
210
+ | `new Recognize(SOURCE.RUCAPTCHA, {})` | `new RuCaptcha({ apiKey })` |
211
+ | `new Recognize(SOURCE.ANTICAPTCHA, {})` | `new AntiCaptcha({ apiKey })` |
212
+ | `{ key: "..." }` | `{ apiKey: "..." }` |
213
+ | `balanse()` | `getBalance()` |
214
+ | `solvingImage(buff)` | `imageCaptcha(buff)` |
215
+ | `solvingRecaptcha2()` | `recaptchaV2(url, key)` |
216
+ | `solvingRecaptcha3()` | `recaptchaV3(url, key, action)` |
217
+ | `reportGood(id)` | `reportCorrect(taskId)` |
218
+ | `reportBad(id)` | `reportIncorrect(taskId)` |
219
+ | return `{ id, result }` | return `{ taskId, solution }` |
220
+
221
+ ### License
222
+
223
+ MIT
224
+
225
+ ---
226
+
227
+ ## Русский
228
+
229
+ Лёгкий клиент для решения капч без сторонних зависимостей. Поддерживает сервисы **RuCaptcha** и **Anti-Captcha** (API v2).
230
+
231
+ - **0 зависимостей** — использует встроенный `fetch` (Node.js 18+)
232
+ - **TypeScript** — полная типизация, автодополнение, экспортируемые типы
233
+ - **Dual ESM/CJS** — работает с `import` и `require`
234
+ - **30+ типов капч** — reCAPTCHA, hCaptcha, Turnstile, FunCaptcha, GeeTest и другие
235
+ - **Автополлинг** — ожидает результат с настраиваемым интервалом и таймаутом
236
+
237
+ ### Установка
238
+
239
+ ```bash
240
+ npm install recognize
241
+ ```
242
+
243
+ ### Быстрый старт
244
+
245
+ ```ts
246
+ import { RuCaptcha } from "recognize";
247
+
248
+ const solver = new RuCaptcha({
249
+ apiKey: "ВАШ_API_КЛЮЧ",
250
+ pollingInterval: 5000, // опционально, по умолчанию 5000 мс
251
+ timeout: 180000, // опционально, по умолчанию 180000 мс
252
+ });
253
+
254
+ // Проверить баланс
255
+ const balance = await solver.getBalance();
256
+ console.log("Баланс:", balance);
257
+
258
+ // Решить reCAPTCHA v2
259
+ const { taskId, solution } = await solver.recaptchaV2(
260
+ "https://example.com",
261
+ "SITE_KEY",
262
+ );
263
+ console.log(solution.gRecaptchaResponse);
264
+
265
+ // Сообщить о результате
266
+ await solver.reportCorrect(taskId);
267
+ ```
268
+
269
+ #### Anti-Captcha
270
+
271
+ ```ts
272
+ import { AntiCaptcha } from "recognize";
273
+
274
+ const solver = new AntiCaptcha({ apiKey: "ВАШ_API_КЛЮЧ" });
275
+ ```
276
+
277
+ #### Динамический выбор сервиса
278
+
279
+ ```ts
280
+ import { createSolver } from "recognize";
281
+
282
+ const solver = createSolver("rucaptcha", { apiKey: "ВАШ_API_КЛЮЧ" });
283
+ // или
284
+ const solver2 = createSolver("anticaptcha", { apiKey: "ВАШ_API_КЛЮЧ" });
285
+ ```
286
+
287
+ ### Параметры конструктора
288
+
289
+ | Параметр | Тип | По умолчанию | Описание |
290
+ | ----------------- | -------- | ------------ | ------------------------------------- |
291
+ | `apiKey` | `string` | — | **Обязательный.** API ключ |
292
+ | `pollingInterval` | `number` | `5000` | Интервал опроса в мс |
293
+ | `timeout` | `number` | `180000` | Максимальное время ожидания задачи мс |
294
+
295
+ ### API
296
+
297
+ Все методы решения капч возвращают `Promise<TaskResult<T>>`, где `TaskResult<T> = { taskId: number, solution: T }`.
298
+
299
+ #### Аккаунт
300
+
301
+ | Метод | Описание |
302
+ | ------------------------- | --------------------------- |
303
+ | `getBalance()` | Получить баланс аккаунта |
304
+ | `reportCorrect(taskId)` | Сообщить о верном решении |
305
+ | `reportIncorrect(taskId)` | Сообщить о неверном решении |
306
+
307
+ #### Изображения и текст
308
+
309
+ | Метод | Параметры | Тип задачи |
310
+ | ------------------------------ | ----------------------------------------------------------- | ----------------- |
311
+ | `imageCaptcha(body, options?)` | `body` — Buffer или строка base64 | `ImageToTextTask` |
312
+ | `textCaptcha(text, options?)` | `text` — строка с вопросом | `TextCaptchaTask` |
313
+ | `audioCaptcha(body, lang?)` | `body` — Buffer или base64, `lang` — код языка (`ru`, `en`) | `AudioTask` |
314
+
315
+ #### reCAPTCHA
316
+
317
+ | Метод | Параметры |
318
+ | -------------------------------------------------------- | -------------------------------------- |
319
+ | `recaptchaV2(url, siteKey, options?)` | Поддержка прокси через `options.proxy` |
320
+ | `recaptchaV3(url, siteKey, action, minScore?, options?)` | `minScore` по умолчанию `0.3` |
321
+ | `recaptchaV2Enterprise(url, siteKey, options?)` | Enterprise версия |
322
+
323
+ #### hCaptcha
324
+
325
+ ```ts
326
+ await solver.hcaptcha(url, siteKey, options?)
327
+ ```
328
+
329
+ #### Cloudflare Turnstile
330
+
331
+ ```ts
332
+ await solver.turnstile(url, siteKey, options?)
333
+ ```
334
+
335
+ #### FunCaptcha (Arkose Labs)
336
+
337
+ ```ts
338
+ await solver.funcaptcha(url, publicKey, options?)
339
+ ```
340
+
341
+ #### GeeTest
342
+
343
+ ```ts
344
+ await solver.geetest(url, gt, challenge, options?)
345
+ await solver.geetestV4(url, captchaId, options?)
346
+ ```
347
+
348
+ #### Amazon WAF
349
+
350
+ ```ts
351
+ await solver.amazonWaf(url, siteKey, options?)
352
+ ```
353
+
354
+ #### Другие типы капч
355
+
356
+ | Метод | Тип задачи |
357
+ | -------------------------------------------------------- | --------------------------------- |
358
+ | `keyCaptcha(url, options?)` | `KeyCaptchaTaskProxyless` |
359
+ | `lemin(url, captchaId, apiServer, options?)` | `LeminTaskProxyless` |
360
+ | `capyPuzzle(url, siteKey, options?)` | `CapyTaskProxyless` |
361
+ | `dataDome(url, captchaUrl, userAgent, proxyConfig)` | `DataDomeSliderTask` |
362
+ | `cyberSiara(url, slideMasterUrlId, userAgent, options?)` | `AntiCyberSiAraTaskProxyless` |
363
+ | `mtCaptcha(url, siteKey, options?)` | `MtCaptchaTaskProxyless` |
364
+ | `friendlyCaptcha(url, siteKey, options?)` | `FriendlyCaptchaTaskProxyless` |
365
+ | `cutcaptcha(url, miseryKey, apiKey, options?)` | `CutCaptchaTaskProxyless` |
366
+ | `tencent(url, appId, options?)` | `TencentTaskProxyless` |
367
+ | `atbCaptcha(url, appId, apiServer, options?)` | `AtbCaptchaTaskProxyless` |
368
+ | `yandexSmart(url, siteKey, options?)` | `YandexSmartCaptchaTaskProxyless` |
369
+ | `vkCaptcha(url, siteKey, options?)` | `VKCaptchaTaskProxyless` |
370
+ | `temuCaptcha(url, options?)` | `TemuCaptchaTaskProxyless` |
371
+
372
+ #### Задачи на основе изображений
373
+
374
+ | Метод | Тип задачи |
375
+ | ------------------------------------ | ----------------- |
376
+ | `rotateCaptcha(body, options?)` | `RotateTask` |
377
+ | `coordinatesCaptcha(body, options?)` | `CoordinatesTask` |
378
+ | `gridCaptcha(body, options?)` | `GridTask` |
379
+ | `boundingBoxCaptcha(body, options?)` | `BoundingBoxTask` |
380
+ | `drawAroundCaptcha(body, options?)` | `DrawAroundTask` |
381
+
382
+ #### Произвольная задача
383
+
384
+ ```ts
385
+ // Отправить любой тип задачи напрямую
386
+ await solver.solve<{ token: string }>({
387
+ type: "SomeNewTaskType",
388
+ websiteURL: "https://example.com",
389
+ });
390
+ ```
391
+
392
+ ### Поддержка прокси
393
+
394
+ Методы с поддержкой прокси принимают его через параметры options:
395
+
396
+ ```ts
397
+ await solver.recaptchaV2("https://example.com", "SITE_KEY", {
398
+ proxyType: "http",
399
+ proxyAddress: "1.2.3.4",
400
+ proxyPort: 8080,
401
+ proxyLogin: "user",
402
+ proxyPassword: "pass",
403
+ proxy: true,
404
+ });
405
+ ```
406
+
407
+ ### Экспортируемые типы
408
+
409
+ ```ts
410
+ import type {
411
+ SolverOptions,
412
+ TaskResult,
413
+ TokenSolution,
414
+ GRecaptchaSolution,
415
+ ImageSolution,
416
+ GeeTestSolution,
417
+ GeeTestV4Solution,
418
+ ProxyOptions,
419
+ RecaptchaV2Options,
420
+ HCaptchaOptions,
421
+ TurnstileOptions,
422
+ // ... и другие
423
+ } from "recognize";
424
+ ```
425
+
426
+ ### Миграция с v2
427
+
428
+ | v2 (старый) | v3 (текущий) |
429
+ | --------------------------------------- | ------------------------------- |
430
+ | `new Recognize(SOURCE.RUCAPTCHA, {})` | `new RuCaptcha({ apiKey })` |
431
+ | `new Recognize(SOURCE.ANTICAPTCHA, {})` | `new AntiCaptcha({ apiKey })` |
432
+ | `{ key: "..." }` | `{ apiKey: "..." }` |
433
+ | `balanse()` | `getBalance()` |
434
+ | `solvingImage(buff)` | `imageCaptcha(buff)` |
435
+ | `solvingRecaptcha2()` | `recaptchaV2(url, key)` |
436
+ | `solvingRecaptcha3()` | `recaptchaV3(url, key, action)` |
437
+ | `reportGood(id)` | `reportCorrect(taskId)` |
438
+ | `reportBad(id)` | `reportIncorrect(taskId)` |
439
+ | return `{ id, result }` | return `{ taskId, solution }` |
440
+
441
+ ### Лицензия
442
+
443
+ MIT