@2captcha/captcha-solver 1.2.0 → 1.3.1

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.
@@ -1,91 +1,91 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Server = void 0;
27
- const events_1 = require("events");
28
- // For creating the server
29
- const http = __importStar(require("http"));
30
- /**
31
- * ! WIP
32
- * This class will bind an http server to a specific port to allow for post requests from the 2captcha site, providing
33
- * an alternative to manually polling each captcha. A feature 2captcha allows for massive solve requirements.
34
- */
35
- class Server extends events_1.EventEmitter {
36
- constructor(apikey, serverAddr, serverPort, pingbackString, enableACAO = true) {
37
- super();
38
- this._terminated = false;
39
- this._apikey = apikey;
40
- this._headerACAO = enableACAO ? 1 : 0;
41
- this._serverAddr = serverAddr;
42
- this._serverPort = serverPort;
43
- this._pingbackString = pingbackString;
44
- this.server();
45
- }
46
- async server() {
47
- const server = http.createServer((req, res) => {
48
- if (req.method == "POST") {
49
- let body = '';
50
- req.on('data', chunk => {
51
- body += chunk.toString(); // convert Buffer to string
52
- });
53
- req.on('end', () => {
54
- console.log(body);
55
- res.end('ok');
56
- });
57
- }
58
- if (req.method == "GET" && req.url == "/2captcha.txt") {
59
- console.log("writing");
60
- res.write(this._pingbackString, "utf8");
61
- res.end();
62
- }
63
- });
64
- server.listen(this._serverPort);
65
- // let i = setInterval(() => {
66
- // if (this._terminated == true) {
67
- // clearInterval(i);
68
- // server.close();
69
- // }
70
- // }, 100)
71
- }
72
- get defaultPayload() {
73
- return {
74
- key: this._apikey, json: 1, header_acao: this._headerACAO, soft_id: 4587
75
- };
76
- }
77
- /**
78
- * Termintes the running HTTP server.
79
- */
80
- terminate() {
81
- this._terminated = true;
82
- }
83
- requestRecaptcha(params) {
84
- const payload = {
85
- ...params,
86
- method: "userrecaptcha",
87
- ...this.defaultPayload
88
- };
89
- }
90
- }
91
- exports.Server = Server;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.Server = void 0;
27
+ const events_1 = require("events");
28
+ // For creating the server
29
+ const http = __importStar(require("http"));
30
+ /**
31
+ * ! WIP
32
+ * This class will bind an http server to a specific port to allow for post requests from the 2captcha site, providing
33
+ * an alternative to manually polling each captcha. A feature 2captcha allows for massive solve requirements.
34
+ */
35
+ class Server extends events_1.EventEmitter {
36
+ constructor(apikey, serverAddr, serverPort, pingbackString, enableACAO = true) {
37
+ super();
38
+ this._terminated = false;
39
+ this._apikey = apikey;
40
+ this._headerACAO = enableACAO ? 1 : 0;
41
+ this._serverAddr = serverAddr;
42
+ this._serverPort = serverPort;
43
+ this._pingbackString = pingbackString;
44
+ this.server();
45
+ }
46
+ async server() {
47
+ const server = http.createServer((req, res) => {
48
+ if (req.method == "POST") {
49
+ let body = '';
50
+ req.on('data', chunk => {
51
+ body += chunk.toString(); // convert Buffer to string
52
+ });
53
+ req.on('end', () => {
54
+ console.log(body);
55
+ res.end('ok');
56
+ });
57
+ }
58
+ if (req.method == "GET" && req.url == "/2captcha.txt") {
59
+ console.log("writing");
60
+ res.write(this._pingbackString, "utf8");
61
+ res.end();
62
+ }
63
+ });
64
+ server.listen(this._serverPort);
65
+ // let i = setInterval(() => {
66
+ // if (this._terminated == true) {
67
+ // clearInterval(i);
68
+ // server.close();
69
+ // }
70
+ // }, 100)
71
+ }
72
+ get defaultPayload() {
73
+ return {
74
+ key: this._apikey, json: 1, header_acao: this._headerACAO, soft_id: 4587
75
+ };
76
+ }
77
+ /**
78
+ * Termintes the running HTTP server.
79
+ */
80
+ terminate() {
81
+ this._terminated = true;
82
+ }
83
+ requestRecaptcha(params) {
84
+ const payload = {
85
+ ...params,
86
+ method: "userrecaptcha",
87
+ ...this.defaultPayload
88
+ };
89
+ }
90
+ }
91
+ exports.Server = Server;
@@ -1,15 +1,15 @@
1
- declare const softId: number;
2
- declare const supportedProviders: {
3
- twoCaptcha: {
4
- name: string;
5
- in: string;
6
- res: string;
7
- };
8
- ruCaptcha: {
9
- name: string;
10
- in: string;
11
- res: string;
12
- };
13
- };
14
- export { supportedProviders, softId };
1
+ declare const softId: number;
2
+ declare const supportedProviders: {
3
+ twoCaptcha: {
4
+ name: string;
5
+ in: string;
6
+ res: string;
7
+ };
8
+ ruCaptcha: {
9
+ name: string;
10
+ in: string;
11
+ res: string;
12
+ };
13
+ };
14
+ export { supportedProviders, softId };
15
15
  //# sourceMappingURL=constants.d.ts.map
@@ -1,25 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.softId = exports.supportedProviders = void 0;
4
- const twoCaptchaName = '2captcha';
5
- const twoCaptchaIn = 'https://2captcha.com/in.php';
6
- const twoCaptchaRes = 'https://2captcha.com/res.php';
7
- const ruCaptchaName = 'ruCaptcha';
8
- const ruCaptchaIn = 'https://rucaptcha.com/in.php';
9
- const ruCaptchaRes = 'https://rucaptcha.com/res.php';
10
- // TODO: add the ability to specify softid in the constructor of the `Captcha` class
11
- const softId = 4587;
12
- exports.softId = softId;
13
- const supportedProviders = {
14
- twoCaptcha: {
15
- name: twoCaptchaName,
16
- in: twoCaptchaIn,
17
- res: twoCaptchaRes
18
- },
19
- ruCaptcha: {
20
- name: ruCaptchaName,
21
- in: ruCaptchaIn,
22
- res: ruCaptchaRes
23
- }
24
- };
25
- exports.supportedProviders = supportedProviders;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.softId = exports.supportedProviders = void 0;
4
+ const twoCaptchaName = '2captcha';
5
+ const twoCaptchaIn = 'https://2captcha.com/in.php';
6
+ const twoCaptchaRes = 'https://2captcha.com/res.php';
7
+ const ruCaptchaName = 'ruCaptcha';
8
+ const ruCaptchaIn = 'https://rucaptcha.com/in.php';
9
+ const ruCaptchaRes = 'https://rucaptcha.com/res.php';
10
+ // TODO: add the ability to specify softid in the constructor of the `Captcha` class
11
+ const softId = 4587;
12
+ exports.softId = softId;
13
+ const supportedProviders = {
14
+ twoCaptcha: {
15
+ name: twoCaptchaName,
16
+ in: twoCaptchaIn,
17
+ res: twoCaptchaRes
18
+ },
19
+ ruCaptcha: {
20
+ name: ruCaptchaName,
21
+ in: ruCaptchaIn,
22
+ res: ruCaptchaRes
23
+ }
24
+ };
25
+ exports.supportedProviders = supportedProviders;
@@ -1,6 +1,6 @@
1
- export default function getProviderData(provider?: string): {
2
- name: string;
3
- in: string;
4
- res: string;
5
- };
1
+ export default function getProviderData(provider?: string): {
2
+ name: string;
3
+ in: string;
4
+ res: string;
5
+ };
6
6
  //# sourceMappingURL=providers.d.ts.map
@@ -1,20 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const constants_1 = require("../constants/constants");
4
- const defautlProvider = constants_1.supportedProviders.twoCaptcha.name;
5
- function getProviderData(provider = defautlProvider) {
6
- const currentProvider = provider;
7
- let currentProviderData;
8
- switch (currentProvider) {
9
- case '2captcha':
10
- currentProviderData = constants_1.supportedProviders.twoCaptcha;
11
- break;
12
- case 'ruCaptcha':
13
- currentProviderData = constants_1.supportedProviders.ruCaptcha;
14
- break;
15
- default:
16
- currentProviderData = constants_1.supportedProviders.twoCaptcha;
17
- }
18
- return currentProviderData;
19
- }
20
- exports.default = getProviderData;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants_1 = require("../constants/constants");
4
+ const defautlProvider = constants_1.supportedProviders.twoCaptcha.name;
5
+ function getProviderData(provider = defautlProvider) {
6
+ const currentProvider = provider;
7
+ let currentProviderData;
8
+ switch (currentProvider) {
9
+ case '2captcha':
10
+ currentProviderData = constants_1.supportedProviders.twoCaptcha;
11
+ break;
12
+ case 'ruCaptcha':
13
+ currentProviderData = constants_1.supportedProviders.ruCaptcha;
14
+ break;
15
+ default:
16
+ currentProviderData = constants_1.supportedProviders.twoCaptcha;
17
+ }
18
+ return currentProviderData;
19
+ }
20
+ exports.default = getProviderData;
@@ -1,8 +1,16 @@
1
- /**
2
- * @param { Object } params Captcha parameters that need to be checked.
3
- * @returns true | false | Error
4
- * @example
5
- * checkCaptchaParams(params, 'userrecaptcha')
6
- */
7
- export default function checkCaptchaParams(params: Object, method: string): boolean | undefined;
1
+ /**
2
+ * ### Captcha Required Parameters Check.
3
+ *
4
+ * Checking required captcha parameters before sending.
5
+ * This function checks for required fields in the provided captcha parameters.
6
+ * Throws an error if the specified method is not supported or if required fields are missing.
7
+ *
8
+ * Note: The `checkCaptchaParams()` function should be called after `renameParams()`, if function `renameParams()` is used.
9
+ *
10
+ * @param { Object } params Captcha parameters that need to be checked.
11
+ * @returns true | false | Error
12
+ * @example
13
+ * checkCaptchaParams(params, 'userrecaptcha')
14
+ */
15
+ export default function checkCaptchaParams(params: Object, method: string): boolean | undefined;
8
16
  //# sourceMappingURL=checkCaptchaParams.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkCaptchaParams.d.ts","sourceRoot":"","sources":["../../src/utils/checkCaptchaParams.ts"],"names":[],"mappings":"AAyFA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAyCxE"}
1
+ {"version":3,"file":"checkCaptchaParams.d.ts","sourceRoot":"","sources":["../../src/utils/checkCaptchaParams.ts"],"names":[],"mappings":"AA8IA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAiCxE"}