Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antiadmin/anticaptchaofficial

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antiadmin/anticaptchaofficial - npm Package Compare versions

Comparing version 1.0.34 to 1.0.35

770

index.js

@@ -45,13 +45,10 @@

},
getBalance() {
return new Promise((resolve, reject) => {
this.JSONRequest('getBalance', {
'clientKey' : this.settings.clientKey
})
.then(res => resolve(res.balance))
.catch(err => reject(err));
async getBalance() {
const response = await this.JSONRequest('getBalance', {
'clientKey' : this.settings.clientKey
});
return response.balance;
},
solveImage(body) {
return new Promise((resolve, reject) => {
async solveImage(body) {
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -72,54 +69,49 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => resolve(solution.text))
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
const solution = await this.waitForResult(taskCreateResult.taskId);
return solution.text;
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
reportIncorrectImageCaptcha() {
return new Promise((resolve, reject) => {
this.JSONRequest('reportIncorrectImageCaptcha', {
async reportIncorrectImageCaptcha() {
await this.JSONRequest('reportIncorrectImageCaptcha', {
'clientKey' : this.settings.clientKey,
'taskId': this.settings.taskId
})
.then(resolve)
.catch(err => reject(err));
});
return true;
},
solveRecaptchaV2Proxyless(websiteURL, websiteKey, isInvisible = false) {
return new Promise((resolve, reject) => {
let task = {
type: 'RecaptchaV2TaskProxyless',
websiteURL: websiteURL,
websiteKey: websiteKey,
websiteSToken: this.settings.websiteSToken,
recaptchaDataSValue: this.settings.recaptchaDataSValue
}
if (isInvisible === true) {
task['isInvisible'] = true
}
this.JSONRequest('createTask', {
async solveRecaptchaV2Proxyless(websiteURL, websiteKey, isInvisible = false) {
const task = {
type: 'RecaptchaV2TaskProxyless',
websiteURL: websiteURL,
websiteKey: websiteKey,
websiteSToken: this.settings.websiteSToken,
recaptchaDataSValue: this.settings.recaptchaDataSValue
}
if (isInvisible === true) {
task['isInvisible'] = true
}
const taskCreateResult =
await this.JSONRequest('createTask', {
'clientKey' : this.settings.clientKey,
'task' : task,
'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
if (solution.cookies) {
this.settings.cookies = solution.cookies;
}
resolve(solution.gRecaptchaResponse)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
const solution = await this.waitForResult(taskCreateResult.taskId);
if (solution.cookies) {
this.settings.cookies = solution.cookies;
}
return solution.gRecaptchaResponse;
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
solveRecaptchaV2ProxyOn(websiteURL,
async solveRecaptchaV2ProxyOn(websiteURL,
websiteKey,

@@ -134,20 +126,21 @@ proxyType,

isInvisible = false) {
return new Promise((resolve, reject) => {
let task = {
type: 'RecaptchaV2Task',
websiteURL: websiteURL,
websiteKey: websiteKey,
websiteSToken: this.settings.websiteSToken,
recaptchaDataSValue: this.settings.recaptchaDataSValue,
proxyType: proxyType,
proxyAddress: proxyAddress,
proxyPort: proxyPort,
proxyLogin: proxyLogin,
proxyPassword: proxyPassword,
userAgent: userAgent,
cookies: cookies
};
if (isInvisible === true) {
task['isInvisible'] = true;
}
const task = {
type: 'RecaptchaV2Task',
websiteURL: websiteURL,
websiteKey: websiteKey,
websiteSToken: this.settings.websiteSToken,
recaptchaDataSValue: this.settings.recaptchaDataSValue,
proxyType: proxyType,
proxyAddress: proxyAddress,
proxyPort: proxyPort,
proxyLogin: proxyLogin,
proxyPassword: proxyPassword,
userAgent: userAgent,
cookies: cookies
};
if (isInvisible === true) {
task['isInvisible'] = true;
}
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -157,20 +150,18 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
if (solution.cookies) {
this.settings.cookies = solution.cookies;
}
resolve(solution.gRecaptchaResponse)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
const solution = await this.waitForResult(taskCreateResult.taskId);
if (solution.cookies) {
this.settings.cookies = solution.cookies;
}
return solution.gRecaptchaResponse;
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
solveRecaptchaV3(websiteURL, websiteKey, minScore, pageAction) {
return new Promise((resolve, reject) => {
async solveRecaptchaV3(websiteURL, websiteKey, minScore, pageAction) {
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -186,26 +177,25 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
resolve(solution.gRecaptchaResponse)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
const solution = await this.waitForResult(taskCreateResult.taskId);
return solution.gRecaptchaResponse;
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
solveRecaptchaV2EnterpriseProxyless(websiteURL,
async solveRecaptchaV2EnterpriseProxyless(websiteURL,
websiteKey,
enterprisePayload = null) {
return new Promise((resolve, reject) => {
let taskObject = {
type: 'RecaptchaV2EnterpriseTaskProxyless',
websiteURL: websiteURL,
websiteKey: websiteKey
};
if (enterprisePayload) {
taskObject["enterprisePayload"] = enterprisePayload;
}
const taskObject = {
type: 'RecaptchaV2EnterpriseTaskProxyless',
websiteURL: websiteURL,
websiteKey: websiteKey
};
if (enterprisePayload) {
taskObject["enterprisePayload"] = enterprisePayload;
}
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -215,16 +205,14 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
resolve(solution.gRecaptchaResponse)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
const solution = await this.waitForResult(taskCreateResult.taskId);
return solution.gRecaptchaResponse;
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
solveRecaptchaV2EnterpriseProxyOn(websiteURL,
async solveRecaptchaV2EnterpriseProxyOn(websiteURL,
websiteKey,

@@ -239,18 +227,18 @@ enterprisePayload,

cookies) {
return new Promise((resolve, reject) => {
let taskObject = {
type: 'RecaptchaV2EnterpriseTask',
websiteURL: websiteURL,
websiteKey: websiteKey,
proxyType: proxyType,
proxyAddress: proxyAddress,
proxyPort: proxyPort,
proxyLogin: proxyLogin,
proxyPassword: proxyPassword,
userAgent: userAgent,
cookies: cookies
};
if (enterprisePayload) {
taskObject["enterprisePayload"] = enterprisePayload;
}
const taskObject = {
type: 'RecaptchaV2EnterpriseTask',
websiteURL: websiteURL,
websiteKey: websiteKey,
proxyType: proxyType,
proxyAddress: proxyAddress,
proxyPort: proxyPort,
proxyLogin: proxyLogin,
proxyPassword: proxyPassword,
userAgent: userAgent,
cookies: cookies
};
if (enterprisePayload) {
taskObject["enterprisePayload"] = enterprisePayload;
}
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -260,16 +248,14 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
resolve(solution.gRecaptchaResponse)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
const solution = await this.waitForResult(taskCreateResult.taskId);
return solution.gRecaptchaResponse;
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
solveRecaptchaV3Enterprise(websiteURL, websiteKey, minScore, pageAction) {
return new Promise((resolve, reject) => {
async solveRecaptchaV3Enterprise(websiteURL, websiteKey, minScore, pageAction) {
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -286,40 +272,35 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
resolve(solution.gRecaptchaResponse)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
const solution = await this.waitForResult(taskCreateResult.taskId);
if (solution.cookies) {
this.settings.cookies = solution.cookies;
}
return solution.gRecaptchaResponse;
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
reportIncorrectRecaptcha() {
return new Promise((resolve, reject) => {
this.JSONRequest('reportIncorrectRecaptcha', {
async reportIncorrectRecaptcha() {
await this.JSONRequest('reportIncorrectRecaptcha', {
'clientKey' : this.settings.clientKey,
'taskId': this.settings.taskId
})
.then(resolve)
.catch(err => reject(err));
});
return true;
},
reportCorrectRecaptcha() {
return new Promise((resolve, reject) => {
this.JSONRequest('reportCorrectRecaptcha', {
'clientKey' : this.settings.clientKey,
'taskId': this.settings.taskId
})
.then(resolve)
.catch(err => reject(err));
async reportCorrectRecaptcha() {
await this.JSONRequest('reportCorrectRecaptcha', {
'clientKey' : this.settings.clientKey,
'taskId': this.settings.taskId
});
return true;
},
solveHCaptchaProxyless(websiteURL, websiteKey, userAgent, enterprisePayload, isInvisible) {
async solveHCaptchaProxyless(websiteURL, websiteKey, userAgent, enterprisePayload, isInvisible) {
if (typeof userAgent === "undefined") userAgent = '';
let taskPayLoad = {
const taskPayLoad = {
type: 'HCaptchaTaskProxyless',

@@ -334,3 +315,3 @@ websiteURL: websiteURL,

}
return new Promise((resolve, reject) => {
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -340,19 +321,16 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
if (solution.userAgent) {
this.settings.hcaptchaUserAgent = solution.userAgent;
}
resolve(solution.gRecaptchaResponse)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
const solution = await this.waitForResult(taskCreateResult.taskId);
if (solution.userAgent) {
this.settings.hcaptchaUserAgent = solution.userAgent;
}
return solution.gRecaptchaResponse;
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
solveHCaptchaProxyOn(websiteURL,
async solveHCaptchaProxyOn(websiteURL,
websiteKey,

@@ -368,3 +346,3 @@ proxyType,

isInvisible) {
let taskPayLoad = {
const taskPayLoad = {
type: 'HCaptchaTask',

@@ -385,3 +363,3 @@ websiteURL: websiteURL,

}
return new Promise((resolve, reject) => {
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -391,36 +369,26 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
if (solution.cookies) {
this.settings.cookies = solution.cookies;
}
if (solution.userAgent) {
this.settings.hcaptchaUserAgent = solution.userAgent;
}
resolve(solution.gRecaptchaResponse)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
const solution = await this.waitForResult(taskCreateResult.taskId);
if (solution.userAgent) {
this.settings.hcaptchaUserAgent = solution.userAgent;
}
return solution.gRecaptchaResponse;
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
reportIncorrectHcaptcha() {
return new Promise((resolve, reject) => {
this.JSONRequest('reportIncorrectHcaptcha', {
async reportIncorrectHcaptcha() {
await this.JSONRequest('reportIncorrectHcaptcha', {
'clientKey' : this.settings.clientKey,
'taskId': this.settings.taskId
})
.then(resolve)
.catch(err => reject(err));
});
});
return true;
},
solveFunCaptchaProxyless(websiteURL, websiteKey) {
return new Promise((resolve, reject) => {
async solveFunCaptchaProxyless(websiteURL, websiteKey) {
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -438,17 +406,13 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
resolve(solution.token)
})
.catch(err => reject(err));
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
const solution = await this.waitForResult(taskCreateResult.taskId);
return solution.token;
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
solveFunCaptchaProxyOn(websiteURL,
async solveFunCaptchaProxyOn(websiteURL,
websiteKey,

@@ -462,3 +426,3 @@ proxyType,

cookies) {
return new Promise((resolve, reject) => {
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -483,15 +447,10 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
if (solution.cookies) {
this.settings.cookies = solution.cookies;
}
resolve(solution.token)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
const solution = await this.waitForResult(taskCreateResult.taskId);
return solution.token;
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},

@@ -501,3 +460,3 @@

solveGeeTestProxyless(websiteURL,
async solveGeeTestProxyless(websiteURL,
gt,

@@ -507,3 +466,3 @@ challenge,

getLib) {
return new Promise((resolve, reject) => {
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -520,20 +479,16 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
resolve(solution)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
return await this.waitForResult(taskCreateResult.taskId);
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
solveGeeTestV4Proxyless(websiteURL,
async solveGeeTestV4Proxyless(websiteURL,
captchaId,
apiSubdomain,
initParameters) {
return new Promise((resolve, reject) => {
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -550,15 +505,12 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
resolve(solution)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
return await this.waitForResult(taskCreateResult.taskId);
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
solveGeeTestProxyOn(websiteURL,
async solveGeeTestProxyOn(websiteURL,
gt,

@@ -575,3 +527,3 @@ challenge,

cookies) {
return new Promise((resolve, reject) => {
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -596,18 +548,12 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
if (solution.cookies) {
this.settings.cookies = solution.cookies;
}
resolve(solution)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
return await this.waitForResult(taskCreateResult.taskId);
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
solveGeeTestV4ProxyOn(websiteURL,
async solveGeeTestV4ProxyOn(websiteURL,
captchaId,

@@ -623,3 +569,3 @@ apiSubdomain,

cookies) {
return new Promise((resolve, reject) => {
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -643,20 +589,13 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
if (solution.cookies) {
this.settings.cookies = solution.cookies;
}
resolve(solution)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
return await this.waitForResult(taskCreateResult.taskId);
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
solveTurnstileProxyless(websiteURL, websiteKey, action = "") {
return new Promise((resolve, reject) => {
async solveTurnstileProxyless(websiteURL, websiteKey, action = "") {
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -671,16 +610,14 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
resolve(solution.token)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
const solution = await this.waitForResult(taskCreateResult.taskId);
return solution.token;
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
solveTurnstileProxyOn(websiteURL,
async solveTurnstileProxyOn(websiteURL,
websiteKey,

@@ -693,3 +630,3 @@ proxyType,

action = "") {
return new Promise((resolve, reject) => {
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -709,15 +646,10 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
if (solution.cookies) {
this.settings.cookies = solution.cookies;
}
resolve(solution.token)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
const solution = await this.waitForResult(taskCreateResult.taskId);
return solution.token;
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},

@@ -727,3 +659,3 @@

sendAntiGateTask(websiteURL,
async sendAntiGateTask(websiteURL,
templateName,

@@ -736,12 +668,13 @@ variables,

domainsOfInterest) {
return new Promise((resolve, reject) => {
if (typeof templateName != "string") {
reject('Parameter "templateName" must be a string');
}
if (typeof variables != "object") {
reject('Parameter "variables" must be an object');
}
if (typeof domainsOfInterest != "object") {
domainsOfInterest = [];
}
if (typeof templateName != "string") {
throw 'Parameter "templateName" must be a string';
}
if (typeof variables != "object") {
throw 'Parameter "variables" must be an object';
}
if (typeof domainsOfInterest != "object") {
domainsOfInterest = [];
}
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -761,12 +694,12 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
resolve(res.taskId);
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
return taskCreateResult.taskId;
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
solveAntiGateTask(websiteURL,
async solveAntiGateTask(websiteURL,
templateName,

@@ -779,3 +712,3 @@ variables,

domainsOfInterest) {
return new Promise((resolve, reject) => {
const taskId = await
this.sendAntiGateTask(websiteURL,

@@ -788,14 +721,8 @@ templateName,

proxyPassword,
domainsOfInterest)
.then(taskId => {
return this.waitForResult(taskId)
})
.then(solution => resolve(solution))
.catch(err => reject(err));
});
domainsOfInterest);
return await this.waitForResult(taskId);
},
pushAntiGateVariable(name, value) {
return new Promise((resolve, reject) => {
this.JSONRequest('pushAntiGateVariable', {
async pushAntiGateVariable(name, value) {
return await this.JSONRequest('pushAntiGateVariable', {
'clientKey' : this.settings.clientKey,

@@ -806,8 +733,5 @@ 'taskId': this.settings.taskId,

})
.then(resolve)
.catch(err => reject(err));
});
},
solveAntiBotCookieTask(websiteURL,
async solveAntiBotCookieTask(websiteURL,
proxyAddress,

@@ -817,3 +741,3 @@ proxyPort,

proxyPassword) {
return new Promise((resolve, reject) => {
const taskCreateResult = await
this.JSONRequest('createTask', {

@@ -830,65 +754,46 @@ 'clientKey' : this.settings.clientKey,

'softId' : this.settings.softId
})
.then(res => {
this.settings.taskId = res.taskId;
return this.waitForResult(res.taskId);
})
.then(solution => {
resolve(solution)
})
.catch(err => reject(err));
});
});
if (taskCreateResult.taskId) {
this.settings.taskId = taskCreateResult.taskId;
return await this.waitForResult(taskCreateResult.taskId);
} else {
throw "ERROR_NO_SLOT_AVAILABLE";
}
},
waitForResult(taskId) {
return new Promise((resolve, reject) => {
async waitForResult(taskId) {
(async () => {
if (this.settings.isVerbose) console.log('created task with ID '+taskId);
if (this.settings.isVerbose) console.log('waiting '+this.settings.firstAttemptWaitingInterval+' seconds');
await this.delay(this.settings.firstAttemptWaitingInterval * 1000);
if (this.settings.isVerbose) console.log('created task with ID '+taskId);
if (this.settings.isVerbose) console.log('waiting '+this.settings.firstAttemptWaitingInterval+' seconds');
await this.delay(this.settings.firstAttemptWaitingInterval * 1000);
while (taskId > 0) {
const checkResult = await this.JSONRequest('getTaskResult', {
'clientKey' : this.settings.clientKey,
'taskId' : taskId
});
if (checkResult.status === 'ready') {
return checkResult.solution;
}
if (checkResult.status === 'processing') {
if (this.settings.isVerbose) console.log('captcha result is not yet ready');
}
while (taskId > 0) {
await this.JSONRequest('getTaskResult', {
'clientKey' : this.settings.clientKey,
'taskId' : taskId
})
.then(response => {
if (response.status === 'ready') {
taskId = 0;
resolve(response.solution);
}
if (response.status === 'processing') {
if (this.settings.isVerbose) console.log('captcha result is not yet ready');
}
})
.catch(error => {
taskId = 0;
reject(error);
});
if (this.settings.isVerbose) console.log('waiting '+this.settings.normalWaitingInterval+' seconds');
await this.delay(this.settings.normalWaitingInterval * 1000);
}
},
if (this.settings.isVerbose) console.log('waiting '+this.settings.normalWaitingInterval+' seconds');
await this.delay(this.settings.normalWaitingInterval * 1000);
async JSONRequest(methodName, payLoad) {
}
if (typeof process !== 'object' || typeof require !== 'function') {
const message = 'Application should be run either in NodeJs or a WebBrowser environment';
if (this.settings.isVerbose) console.error(message);
throw message;
}
const axios = require('axios');
})();
});
},
JSONRequest(methodName, payLoad) {
return new Promise((resolve, reject) => {
if (typeof process !== 'object' || typeof require !== 'function') {
const message = 'Application should be run either in NodeJs or a WebBrowser environment';
console.error(message);
reject(message);
}
const axios = require('axios')
axios.post('https://api.anti-captcha.com/' + methodName,
const response =
await axios.post('https://api.anti-captcha.com/' + methodName,
payLoad,

@@ -901,38 +806,29 @@ {

}
})
.then(res => {
return this.checkForErrors(res.data);
})
.then(data => {
resolve(data)
})
.catch((error) => reject(error))
});
return this.checkForErrors(response.data);
},
});
},
checkForErrors(response) {
return new Promise((resolve, reject) => {
if (typeof response.errorId === "undefined") {
reject("Incorrect API response, something is wrong");
return;
}
if (typeof response.errorId !== "number") {
reject("Unknown API error code "+response.errorId);
return;
}
if (response.errorId > 0) {
console.error('Received API error '+response.errorCode+': '+response.errorDescription);
reject(response.errorCode);
return;
}
resolve(response);
});
if (typeof response.errorId === "undefined") {
throw "Incorrect API response, something is wrong";
}
if (typeof response.errorId !== "number") {
throw "Unknown API error code "+response.errorId
}
if (response.errorId > 0) {
if (this.settings.isVerbose) console.error('Received API error '+response.errorCode+': '+response.errorDescription);
throw response.errorCode;
}
return response;
},
getCookies() {
return this.settings.cookies;
},
getHcaptchaUserAgent() {
return this.settings.hcaptchaUserAgent;
},
delay(time) {

@@ -939,0 +835,0 @@ return new Promise(function(resolve) {

{
"name": "@antiadmin/anticaptchaofficial",
"version": "1.0.34",
"version": "1.0.35",
"description": "Official Anti-Captcha.com npm library",

@@ -39,4 +39,5 @@ "main": "index.js",

"dependencies": {
"@antiadmin/anticaptchaofficial": "^1.0.34",
"axios": "^0.21.1"
}
}

@@ -16,10 +16,46 @@ ## Official Anti-Captcha.com npm module ##

Import and check your balance:
Import and check your balance in sync mode:
```javascript
(async() => {
const ac = require("@antiadmin/anticaptchaofficial");
ac.setAPIKey('YOUR_API_KEY');
try {
const balance = await ac.getBalance();
console.log(`my balance is $${balance}`);
if (balance <= 0) {
throw "negative balance"
}
console.log("solving a captcha..")
// const token = await ac.solveRecaptchaV2Proxyless('http://DOMAIN.COM', 'WEBSITE_KEY');
// const fs = require('fs');
// const text = await ac.solveImage(fs.readFileSync('captcha.png', { encoding: 'base64' }), true)
} catch (e) {
console.log("got error: ", e.toString());
}
})();
```
Or do the same with promises:
```javascript
const ac = require("@antiadmin/anticaptchaofficial");
ac.setAPIKey('YOUR_API_KEY');
ac.getBalance()
.then(balance => console.log('my balance is $'+balance))
.then(balance => {
console.log('my balance is $' + balance)
if (balance <= 0) {
return false;
}
console.log("solving a captcha..")
// ac.solveRecaptchaV2Proxyless('http://DOMAIN.COM', 'WEBSITE_KEY')
// .then(token => {
// console.log('Got g-response:', token)
// // do something
// })
// .catch(error => {
// console.log('test received error ' + error)
// return false;
// });
})
.catch(error => console.log('received error '+error))
```

@@ -39,3 +75,16 @@

<h2>All following examples are for sync mode, compatible with promises</h2>
Run synchronous code like this:
```javascript
(async() => {
try {
// your code here:
// const balance = await ac.getBalance();
// const token = await ac.solveRecaptchaV2Proxyless('http://DOMAIN.COM', 'WEBSITE_KEY');
// etc.
} catch (e) {
console.error("Received error:", e.toString());
}
})();
```
---

@@ -46,9 +95,7 @@ Solve image captcha:

const captcha = fs.readFileSync('captcha.png', { encoding: 'base64' });
ac.solveImage(captcha, true)
.then(text => console.log('captcha text: '+text))
.catch(error => console.log('test received error '+error));
const text = await ac.solveImage(captcha, true);
```
Report last solved image captcha as incorrect (must read [this](https://anti-captcha.com/apidoc/methods/reportIncorrectImageCaptcha) before using):
```javascript
ac.reportIncorrectImageCaptcha();
await ac.reportIncorrectImageCaptcha();
```

@@ -62,9 +109,6 @@ ---

ac.settings.recaptchaDataSValue = 'set me for google.com domains';
ac.solveRecaptchaV2Proxyless('http://DOMAIN.COM', 'WEBSITE_KEY')
.then(gresponse => {
console.log('g-response: '+gresponse);
console.log('google cookies:');
console.log(ac.getCookies());
})
.catch(error => console.log('test received error '+error));
const gresponse = ac.solveRecaptchaV2Proxyless('http://DOMAIN.COM', 'WEBSITE_KEY');
console.log('g-response: '+gresponse);
console.log('google cookies:');
console.log(ac.getCookies());
```

@@ -76,3 +120,3 @@ Learn what to do with g-response in [this](https://anti-captcha.com/apidoc/articles/how-to-use-g-response) article.

```javascript
ac.reportIncorrectRecaptcha();
await ac.reportIncorrectRecaptcha();
```

@@ -82,3 +126,3 @@

```javascript
ac.reportCorrectRecaptcha();
await ac.reportCorrectRecaptcha();
```

@@ -91,3 +135,3 @@

```javascript
ac.solveRecaptchaV2ProxyOn('http://DOMAIN.COM',
const gresponse = await ac.solveRecaptchaV2ProxyOn('http://DOMAIN.COM',
'WEBSITE_KEY',

@@ -100,11 +144,7 @@ 'http', //http, socks4, socks5

'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116',
'some=cookies')
.then(gresponse => {
console.log('g-response: '+gresponse);
})
.catch(error => console.log('test received error '+error));
'some=cookies');
```
Solve Recaptcha V2-invisible (note the 3rd parameter "true"):
```javascript
ac.solveRecaptchaV2Proxyless('http://DOMAIN.COM', 'WEBSITE_KEY', true)
const gresponse = await ac.solveRecaptchaV2Proxyless('http://DOMAIN.COM', 'WEBSITE_KEY', true)
```

@@ -117,10 +157,6 @@ ---

```javascript
ac.solveRecaptchaV3('http://DOMAIN.COM',
const gresponse = await ac.solveRecaptchaV3('http://DOMAIN.COM',
'WEBSITE_KEY',
0.3, //minimum score required: 0.3, 0.7 or 0.9
'PAGE_ACTION_CAN_BE_EMPTY')
.then(gresponse => {
console.log('g-response: '+gresponse);
})
.catch(error => console.log('test received error '+error));
'PAGE_ACTION_CAN_BE_EMPTY');
```

@@ -130,13 +166,9 @@

```javascript
ac.solveRecaptchaV2EnterpriseProxyless(
const gresponse = await ac.solveRecaptchaV2EnterpriseProxyless(
'http://DOMAIN.COM',
'WEBSITE_KEY',
{
{ //enterprise payload:
"s" : "SOME_TOKEN",
"custom_parameter" : "string_number_boolean"
})
.then(gresponse => {
console.log('g-response: '+gresponse);
})
.catch(error => console.log('test received error '+error));
});
```

@@ -149,12 +181,9 @@ ---

```javascript
ac.solveHCaptchaProxyless('http://DOMAIN.COM', 'WEBSITE_KEY', 'FULL USER AGENT HERE')
.then(token => {
console.log('token: '+token);
console.log('user-agent: ', ac.getHcaptchaUserAgent())
})
.catch(error => console.log('test received error '+error));
const token = await ac.solveHCaptchaProxyless('http://DOMAIN.COM', 'WEBSITE_KEY', 'FULL USER AGENT HERE');
const userAgent = ac.getHcaptchaUserAgent();
// use this userAgent for posting the form with token!
```
Report last solved Hcaptcha as incorrect:
```javascript
ac.reportIncorrectHcaptcha();
await ac.reportIncorrectHcaptcha();
```

@@ -166,3 +195,3 @@ ---

```javascript
ac.solveHCaptchaProxyless('http://DOMAIN.COM',
const token = await ac.solveHCaptchaProxyless('http://DOMAIN.COM',
'WEBSITE_KEY',

@@ -175,8 +204,5 @@ 'FULL USER AGENT HERE',

// for more info go to https://anti-captcha.com/apidoc/task-types/HCaptchaTaskProxyless
})
.then(token => {
console.log('token: '+token);
console.log('user-agent: ', ac.getHcaptchaUserAgent())
})
.catch(error => console.log('test received error '+error));
});
const userAgent = ac.getHcaptchaUserAgent();
// use this userAgent for posting the form with token!
```

@@ -189,3 +215,3 @@

```javascript
ac.solveHCaptchaProxyless('http://DOMAIN.COM',
const token = await ac.solveHCaptchaProxyless('http://DOMAIN.COM',
'WEBSITE_KEY',

@@ -205,10 +231,5 @@ 'FULL USER AGENT HERE',

// for more info go to https://anti-captcha.com/apidoc/task-types/HCaptchaTaskProxyless
})
.then(token => {
//use token to submit at the target website
console.log('token: '+token);
//set this user-agent to your app library or browser
console.log('user-agent: ', ac.getHcaptchaUserAgent());
})
.catch(error => console.log('test received error '+error));
});
const userAgent = ac.getHcaptchaUserAgent();
// use this userAgent for posting the form with token!
```

@@ -222,7 +243,3 @@

```javascript
ac.solveTurnstileProxyless('http://DOMAIN.COM', 'WEBSITE_KEY', 'optional_action')
.then(token => {
console.log('token: '+token);
})
.catch(error => console.log('test received error '+error));
const token = await ac.solveTurnstileProxyless('http://DOMAIN.COM', 'WEBSITE_KEY', 'optional_action');
```

@@ -234,3 +251,3 @@ ---

```javascript
ac.solveTurnstileProxyOn('http://DOMAIN.COM',
const token = await ac.solveTurnstileProxyOn('http://DOMAIN.COM',
'WEBSITE_KEY',

@@ -242,7 +259,3 @@ 'http', //http, socks4, socks5

'PROXY_PASSWORD',
'optional_action')
.then(token => {
console.log('token: '+token);
})
.catch(error => console.log('test received error '+error));
'optional_action');
```

@@ -254,3 +267,3 @@ ---

```javascript
ac.solveAntiGateTask(
const solution = await ac.solveAntiGateTask(
'http://antigate.com/logintest.php',

@@ -264,13 +277,10 @@ 'Sign-in and wait for control text',

"control_text": "You have been logged successfully"
})
.then(solution => {
console.log('cookies: ', solution.cookies);
console.log('localStorage: ', solution.localStorage);
console.log('url: ', solution.url);
})
.catch(error => console.error('test received error: ', error));
});
console.log('cookies: ', solution.cookies);
console.log('localStorage: ', solution.localStorage);
console.log('url: ', solution.url);
```
same with a proxy:
```javascript
ac.solveAntiGateTask(
const solution = await ac.solveAntiGateTask(
'http://antigate.com/logintest.php',

@@ -288,34 +298,24 @@ 'Sign-in and wait for control text',

'PROXY_LOGIN',
'PROXY_PASSWORD')
.then(solution => {
console.log(solution);
})
.catch(error => console.error('test received error: ', error));
'PROXY_PASSWORD');
```
Send a task with a delayed variable and push it after a few seconds:
```javascript
(async() => {
try {
const taskId = await ac.sendAntiGateTask('http://antigate.com/logintest2fa.php',
'Sign-in with 2FA and wait for control text',
{
"login_input_css": "#login",
"login_input_value": "the login",
"password_input_css": "#password",
"password_input_value": "the password",
"2fa_input_css": "#2facode",
"2fa_input_value": "_WAIT_FOR_IT_",
"control_text": "You have been logged successfully"
});
await ac.delay(5000); //simulate a delay in 2FA retrieval
await ac.pushAntiGateVariable('2fa_input_value', '349001');
const solution = await ac.waitForResult(taskId);
const taskId = await ac.sendAntiGateTask('http://antigate.com/logintest2fa.php',
'Sign-in with 2FA and wait for control text',
{
"login_input_css": "#login",
"login_input_value": "the login",
"password_input_css": "#password",
"password_input_value": "the password",
"2fa_input_css": "#2facode",
"2fa_input_value": "_WAIT_FOR_IT_",
"control_text": "You have been logged successfully"
});
await ac.delay(5000); //simulate a delay in 2FA retrieval
await ac.pushAntiGateVariable('2fa_input_value', '349001');
const solution = await ac.waitForResult(taskId);
console.log('solution:');
console.log(solution);
console.log('solution:');
console.log(solution);
} catch (e) {
console.error('Something went wrong: '+e.toString());
}
})();
```

@@ -326,5 +326,5 @@

Bypass Cloudflare / Datadome / etc:
Bypass Cloudflare / Datadome / etc. [More info about this](https://anti-captcha.com/ru/apidoc/task-types/AntiBotCookieTask):
```javascript
ac.solveAntiBotCookieTask(
const solution = await ac.solveAntiBotCookieTask(
'https://www.thewebsite.com/',

@@ -334,9 +334,3 @@ 'PROXY_IP',

'PROXY_LOGIN',
'PROXY_PASSWORD')
.then(solution => {
console.log(solution);
//use solution.fingerprint['self.navigator.userAgent'] as user-agent for your requests
//use solution.cookies for your requests
})
.catch(error => console.error('test received error: ', error));
'PROXY_PASSWORD');
```

@@ -352,9 +346,5 @@

ac.settings.funcaptchaDataBlob = 'blob value here is any, or leave it empty';
ac.solveFunCaptchaProxyless(
const token = await ac.solveFunCaptchaProxyless(
'https://www.thewebsite.com/path',
'site-key')
.then(token => {
console.log(token);
})
.catch(error => console.error('test received error: ', error));
'site-key');
```

@@ -368,3 +358,3 @@ &nbsp;

ac.settings.funcaptchaDataBlob = 'blob value here is any, or leave it empty';
ac.solveFunCaptchaProxyOn(
const token = await ac.solveFunCaptchaProxyOn(
'https://www.thewebsite.com/path',

@@ -378,7 +368,3 @@ 'site-key',

'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116',
'')
.then(token => {
console.log(token);
})
.catch(error => console.error('test received error: ', error));
'');
```

@@ -393,11 +379,7 @@

```javascript
ac.solveGeeTestProxyless(
const token = await ac.solveGeeTestProxyless(
'https://www.thewebsite.com/path',
'gt key 32 bytes',
'challenge value 32 bytes',
'optional.api-domain.com')
.then(token => {
console.log(token);
})
.catch(error => console.error('test received error: ', error));
'optional.api-domain.com');
```

@@ -409,3 +391,3 @@

```javascript
ac.solveGeeTestV4Proxyless(
const token = await ac.solveGeeTestV4Proxyless(
'https://www.thewebsite.com/path',

@@ -416,7 +398,3 @@ 'captchaId key 32 bytes',

'riskType': 'slide' //example
})
.then(token => {
console.log(token);
})
.catch(error => console.error('test received error: ', error));
});
```

@@ -428,7 +406,7 @@

```javascript
ac.solveRecaptchaV2EnterpriseProxyOn( ... ); //Recaptcha V2 Enterprise with proxy
ac.solveRecaptchaV3Enterprise( ... ); //Recaptcha V3 Enterprise
ac.solveHCaptchaProxyOn( ... ); //hCaptcha with proxy
ac.solveGeeTestProxyOn( ... ); //Solve Geetest with proxy
ac.solveGeeTestV4ProxyOn( ... ); //Bypass Geetest V4 with proxy
await ac.solveRecaptchaV2EnterpriseProxyOn( ... ); //Recaptcha V2 Enterprise with proxy
await ac.solveRecaptchaV3Enterprise( ... ); //Recaptcha V3 Enterprise
await ac.solveHCaptchaProxyOn( ... ); //hCaptcha with proxy
await ac.solveGeeTestProxyOn( ... ); //Solve Geetest with proxy
await ac.solveGeeTestV4ProxyOn( ... ); //Bypass Geetest V4 with proxy
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc