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/package.json CHANGED
@@ -1,28 +1,58 @@
1
- {
2
- "name": "recognize",
3
- "version": "2.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
- "dependencies": {
26
- "got": "^12.0.0"
27
- }
28
- }
1
+ {
2
+ "name": "recognize",
3
+ "version": "3.1.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,37 +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(id, result);
23
-
24
- // console.log(await recognize.solvingImage(buff));
25
-
26
- // const r = await recognize.reportGood(1).catch((err) => err.message);
27
- // console.log(r);
28
- // recognize.solving(buff, function (err, id, code) {
29
- // if (err) throw err;
30
- // if (code) console.log("Captcha:", code);
31
- // else {
32
- // console.log("Captcha not valid");
33
- // recognize.report(id, function (err, answer) {
34
- // console.log(answer);
35
- // });
36
- // }
37
- // });
package/index.js DELETED
@@ -1,150 +0,0 @@
1
- import { setTimeout } from "node:timers/promises";
2
- import got from "got";
3
-
4
- export const SOURCE = {
5
- RUCAPTCHA: "RUCAPTCHA",
6
- ANTIGATE: "ANTIGATE",
7
- CAPTCHA24: "CAPTCHA24",
8
- };
9
-
10
- const _SOURCE = {
11
- [SOURCE.RUCAPTCHA]: {
12
- baseUrl: "http://rucaptcha.com",
13
- soft_id: 768,
14
- },
15
- [SOURCE.ANTIGATE]: {
16
- baseUrl: "http://anti-captcha.com",
17
- soft_id: 720,
18
- },
19
- [SOURCE.CAPTCHA24]: {
20
- baseUrl: "http://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
- this.rp = got.extend({
31
- prefixUrl: source.baseUrl,
32
- resolveBodyOnly: true,
33
- responseType: "json",
34
- });
35
- this._options = {
36
- ...options,
37
- soft_id: source.soft_id,
38
- };
39
- }
40
-
41
- async _waitResult(id) {
42
- await setTimeout(1000);
43
- const { status, request } = await this.rp.get("res.php", {
44
- searchParams: { key: this._options.key, action: "get", id, json: 1 },
45
- });
46
-
47
- if (request === "CAPCHA_NOT_READY") return this._waitResult(id);
48
- else if (status === 0) return Promise.reject(request);
49
-
50
- return request;
51
- }
52
-
53
- async balanse() {
54
- const { request } = await this.rp.get("res.php", {
55
- searchParams: { key: this._options.key, action: "getbalance", json: 1 },
56
- });
57
-
58
- return request;
59
- }
60
-
61
- async solvingImage(buff, options = {}) {
62
- const { status, request } = await this.rp.post("in.php", {
63
- json: {
64
- ...options,
65
- soft_id: this._options.soft_id,
66
- method: "base64",
67
- key: this._options.key,
68
- body: buff.toString("base64"),
69
- json: 1,
70
- },
71
- });
72
-
73
- if (status === 1) {
74
- return { result: await this._waitResult(request), id: request };
75
- }
76
-
77
- return Promise.reject(request);
78
- }
79
-
80
- async solvingRecaptcha2(url, googleKey, options = {}) {
81
- const { status, request } = await this.rp.post("in.php", {
82
- json: {
83
- ...options,
84
- soft_id: this._options.soft_id,
85
- method: "userrecaptcha",
86
- key: this._options.key,
87
- pageurl: url,
88
- googlekey: googleKey,
89
- json: 1,
90
- },
91
- });
92
-
93
- if (status === 1) {
94
- return { result: await this._waitResult(request), id: request };
95
- }
96
-
97
- return Promise.reject(request);
98
- }
99
-
100
- async solvingRecaptcha3(url, googleKey, action, score = "0.3", options = {}) {
101
- const { status, request } = await this.rp.post("in.php", {
102
- json: {
103
- ...options,
104
- soft_id: this._options.soft_id,
105
- method: "userrecaptcha",
106
- version: "v3",
107
- action,
108
- min_score: score,
109
- key: this._options.key,
110
- pageurl: url,
111
- googlekey: googleKey,
112
- json: 1,
113
- },
114
- });
115
-
116
- if (status === 1) {
117
- return { result: await this._waitResult(request), id: request };
118
- }
119
-
120
- return Promise.reject(request);
121
- }
122
-
123
- async reportBad(id) {
124
- const { status, request } = await this.rp.get("res.php", {
125
- searchParams: {
126
- key: this._options.key,
127
- action: "reportbad",
128
- id,
129
- json: 1,
130
- },
131
- });
132
-
133
- if (status === 0) return false;
134
- return true;
135
- }
136
-
137
- async reportGood(id) {
138
- const { status, request } = await this.rp.get("res.php", {
139
- searchParams: {
140
- key: this._options.key,
141
- action: "reportgood",
142
- id,
143
- json: 1,
144
- },
145
- });
146
-
147
- if (status === 0) return false;
148
- return true;
149
- }
150
- }