recognize 1.0.0 → 3.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/package.json CHANGED
@@ -1,25 +1,58 @@
1
- {
2
- "name": "recognize",
3
- "version": "1.0.0",
4
- "description": "Client for solving services using node.js",
5
- "main": "index.js",
6
- "type": "module",
7
- "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/kdinisv/Recognize.git"
13
- },
14
- "keywords": [
15
- "captcha",
16
- "rucaptcha",
17
- "antigate"
18
- ],
19
- "author": "kdinisv",
20
- "license": "MIT",
21
- "bugs": {
22
- "url": "https://github.com/kdinisv/Recognize/issues"
23
- },
24
- "homepage": "https://github.com/kdinisv/Recognize#readme"
25
- }
1
+ {
2
+ "name": "recognize",
3
+ "version": "3.0.0",
4
+ "description": "Lightweight zero-dependency captcha solving client for RuCaptcha and Anti-Captcha (API v2)",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.mjs",
10
+ "require": "./dist/index.cjs"
11
+ }
12
+ },
13
+ "main": "./dist/index.cjs",
14
+ "module": "./dist/index.mjs",
15
+ "types": "./dist/index.d.ts",
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "engines": {
20
+ "node": ">=18.0.0"
21
+ },
22
+ "scripts": {
23
+ "build": "tsup",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest",
26
+ "prepublishOnly": "npm run build"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/kdinisv/Recognize.git"
31
+ },
32
+ "keywords": [
33
+ "captcha",
34
+ "rucaptcha",
35
+ "2captcha",
36
+ "anti-captcha",
37
+ "anticaptcha",
38
+ "recaptcha",
39
+ "hcaptcha",
40
+ "turnstile",
41
+ "funcaptcha",
42
+ "geetest",
43
+ "solver",
44
+ "typescript"
45
+ ],
46
+ "author": "kdinisv",
47
+ "license": "MIT",
48
+ "bugs": {
49
+ "url": "https://github.com/kdinisv/Recognize/issues"
50
+ },
51
+ "homepage": "https://github.com/kdinisv/Recognize#readme",
52
+ "devDependencies": {
53
+ "@types/node": "^25.5.0",
54
+ "tsup": "^8.0.0",
55
+ "typescript": "^5.4.0",
56
+ "vitest": "^4.1.0"
57
+ }
58
+ }
Binary file
package/example/test.js DELETED
@@ -1,35 +0,0 @@
1
- import { readFile } from "node:fs/promises";
2
- import Recognize, { SOURCE } from "../index.js";
3
-
4
- const recognize = new Recognize(SOURCE.RUCAPTCHA, {
5
- key: "api-key",
6
- });
7
-
8
- const price = await recognize.balanse();
9
- console.log("My balance:", price);
10
-
11
- // const buff = await readFile("./example/captcha.png");
12
-
13
- const { id, result } = await recognize
14
- .solvingRecaptcha3(
15
- "https://www.reestr-zalogov.ru/search/index",
16
- "6LdKJhMaAAAAAIfeHC6FZc-UVfzDQpiOjaJUWoxr",
17
- "search_notary",
18
- "0.3"
19
- )
20
- .catch(console.error);
21
-
22
- console.log(result);
23
-
24
- // const r = await recognize.reportGood(id).catch((err) => err.message);
25
- // console.log(r);
26
- // recognize.solving(data, function (err, id, code) {
27
- // if (err) throw err;
28
- // if (code) console.log("Captcha:", code);
29
- // else {
30
- // console.log("Captcha not valid");
31
- // recognize.report(id, function (err, answer) {
32
- // console.log(answer);
33
- // });
34
- // }
35
- // });
package/index.js DELETED
@@ -1,300 +0,0 @@
1
- import { setTimeout } from "node:timers/promises";
2
- import http from "node:http";
3
-
4
- export const SOURCE = {
5
- RUCAPTCHA: "RUCAPTCHA",
6
- ANTIGATE: "ANTIGATE",
7
- CAPTCHA24: "CAPTCHA24",
8
- };
9
-
10
- const _SOURCE = {
11
- [SOURCE.RUCAPTCHA]: {
12
- baseUrl: "rucaptcha.com",
13
- soft_id: 768,
14
- },
15
- [SOURCE.ANTIGATE]: {
16
- baseUrl: "anti-captcha.com",
17
- soft_id: 720,
18
- },
19
- [SOURCE.CAPTCHA24]: {
20
- baseUrl: "captcha24.com",
21
- soft_id: 921,
22
- },
23
- };
24
-
25
- export default class Recognize {
26
- constructor(sourceCode, options) {
27
- if (!options || !options.key) throw new Error("not key");
28
- const source = _SOURCE[sourceCode];
29
- if (!source) throw new Error("invalid type");
30
-
31
- this._options = {
32
- ...options,
33
- baseUrl: source.baseUrl,
34
- soft_id: source.soft_id,
35
- };
36
- }
37
-
38
- balanse() {
39
- return new Promise((resolve, reject) => {
40
- http
41
- .get(
42
- {
43
- hostname: this._options.baseUrl,
44
- port: 80,
45
- path: `/res.php?key=${this._options.key}&action=getbalance&json=1`,
46
- },
47
- function (res) {
48
- var body = [];
49
- res.on("data", function (chunk) {
50
- body.push(chunk);
51
- });
52
- res.on("end", function () {
53
- try {
54
- const { status, request } = JSON.parse(body.join(""));
55
- if (status === 1) {
56
- return resolve(request);
57
- }
58
- return reject(new Error(request));
59
- } catch (err) {
60
- reject(err);
61
- }
62
- });
63
- }
64
- )
65
- .on("error", reject);
66
- });
67
- }
68
-
69
- solvingImage(buff, options = {}) {
70
- return new Promise((resolve, reject) => {
71
- const postData = JSON.stringify({
72
- ...options,
73
- soft_id: this._options.soft_id,
74
- method: "base64",
75
- key: this._options.key,
76
- body: buff.toString("base64"),
77
- json: "1",
78
- });
79
-
80
- const req = http.request(
81
- {
82
- hostname: this._options.baseUrl,
83
- port: 80,
84
- path: "/in.php",
85
- method: "POST",
86
- headers: {
87
- "Content-Type": "application/json",
88
- "Content-Length": Buffer.byteLength(postData),
89
- },
90
- },
91
- (res) => {
92
- const body = [];
93
- res.setEncoding("utf8");
94
- res.on("data", (chunk) => {
95
- body.push(chunk);
96
- });
97
- res.on("end", () => {
98
- const { status, request } = JSON.parse(body.join(""));
99
- // console.log(request);
100
- if (status === 1) {
101
- waitResult(this._options.baseUrl, this._options.key, request)
102
- .then((result) => resolve({ id: request, result }))
103
- .catch((error) => reject(error));
104
- } else {
105
- reject(new Error(request));
106
- }
107
- });
108
- }
109
- );
110
-
111
- req.on("error", reject);
112
- req.write(postData);
113
- req.end();
114
- });
115
- }
116
-
117
- solvingRecaptcha2(url, googleKey, options = {}) {
118
- return new Promise((resolve, reject) => {
119
- const postData = JSON.stringify({
120
- ...options,
121
- soft_id: this._options.soft_id,
122
- method: "userrecaptcha",
123
- key: this._options.key,
124
- pageurl: url,
125
- googlekey: googleKey,
126
- json: "1",
127
- });
128
-
129
- const req = http.request(
130
- {
131
- hostname: this._options.baseUrl,
132
- port: 80,
133
- path: "/in.php",
134
- method: "POST",
135
- headers: {
136
- "Content-Type": "application/json",
137
- "Content-Length": Buffer.byteLength(postData),
138
- },
139
- },
140
- (res) => {
141
- const body = [];
142
- res.setEncoding("utf8");
143
- res.on("data", (chunk) => {
144
- body.push(chunk);
145
- });
146
- res.on("end", () => {
147
- const { status, request } = JSON.parse(body.join(""));
148
- // console.log(request);
149
- if (status === 1) {
150
- waitResult(this._options.baseUrl, this._options.key, request)
151
- .then((result) => resolve({ id: request, result }))
152
- .catch((error) => reject(error));
153
- } else {
154
- reject(new Error(request));
155
- }
156
- });
157
- }
158
- );
159
-
160
- req.on("error", reject);
161
- req.write(postData);
162
- req.end();
163
- });
164
- }
165
-
166
- solvingRecaptcha3(url, googleKey, action, score = "0.3", options = {}) {
167
- return new Promise((resolve, reject) => {
168
- const postData = JSON.stringify({
169
- ...options,
170
- soft_id: this._options.soft_id,
171
- method: "userrecaptcha",
172
- version: "v3",
173
- action,
174
- min_score: score,
175
- key: this._options.key,
176
- pageurl: url,
177
- googlekey: googleKey,
178
- json: "1",
179
- });
180
-
181
- const req = http.request(
182
- {
183
- hostname: this._options.baseUrl,
184
- port: 80,
185
- path: "/in.php",
186
- method: "POST",
187
- headers: {
188
- "Content-Type": "application/json",
189
- "Content-Length": Buffer.byteLength(postData),
190
- },
191
- },
192
- (res) => {
193
- const body = [];
194
- res.setEncoding("utf8");
195
- res.on("data", (chunk) => {
196
- body.push(chunk);
197
- });
198
- res.on("end", () => {
199
- const { status, request } = JSON.parse(body.join(""));
200
- // console.log(request);
201
- if (status === 1) {
202
- waitResult(this._options.baseUrl, this._options.key, request)
203
- .then((result) => resolve({ id: request, result }))
204
- .catch((error) => reject(error));
205
- } else {
206
- reject(new Error(request));
207
- }
208
- });
209
- }
210
- );
211
-
212
- req.on("error", reject);
213
- req.write(postData);
214
- req.end();
215
- });
216
- }
217
-
218
- reportBad(id) {
219
- return new Promise((resolve, reject) => {
220
- http
221
- .get(
222
- {
223
- hostname: this._options.baseUrl,
224
- port: 80,
225
- path: `/res.php?key=${this._options.key}&action=reportbad&id=${id}&json=1`,
226
- },
227
- function (res) {
228
- const body = [];
229
- res.setEncoding("utf8");
230
- res.on("data", function (chunk) {
231
- body.push(chunk);
232
- });
233
- res.on("end", function () {
234
- const { status, request } = JSON.parse(body.join(""));
235
- if (status === 0) return reject(new Error(request));
236
- resolve(request);
237
- });
238
- }
239
- )
240
- .on("error", reject);
241
- });
242
- }
243
-
244
- reportGood(id) {
245
- return new Promise((resolve, reject) => {
246
- http
247
- .get(
248
- {
249
- hostname: this._options.baseUrl,
250
- port: 80,
251
- path: `/res.php?key=${this._options.key}&action=reportgood&id=${id}&json=1`,
252
- },
253
- function (res) {
254
- const body = [];
255
- res.setEncoding("utf8");
256
- res.on("data", function (chunk) {
257
- body.push(chunk);
258
- });
259
- res.on("end", function () {
260
- const { status, request } = JSON.parse(body.join(""));
261
- if (status === 0) return reject(new Error(request));
262
- resolve(request);
263
- });
264
- }
265
- )
266
- .on("error", reject);
267
- });
268
- }
269
- }
270
-
271
- const httpGet = (request) => {
272
- return new Promise((resolve, reject) => {
273
- return http
274
- .get(request, (res) => {
275
- const body = [];
276
- res.setEncoding("utf8");
277
- res.on("data", function (chunk) {
278
- body.push(chunk);
279
- });
280
- res.on("end", () => {
281
- resolve(JSON.parse(body.join("")));
282
- });
283
- })
284
- .on("error", reject);
285
- });
286
- };
287
-
288
- const waitResult = async (baseUrl, key, id) => {
289
- await setTimeout(1000);
290
- const { status, request } = await httpGet({
291
- hostname: baseUrl,
292
- port: 80,
293
- path: `/res.php?key=${key}&action=get&id=${id}&json=1`,
294
- });
295
-
296
- if (request === "CAPCHA_NOT_READY") return waitResult(baseUrl, key, id);
297
- else if (status === 0) throw new Error(request);
298
-
299
- return request;
300
- };