holz-provider
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -10,6 +10,6 @@ import { CaptchaInfo, CaptchaSolution, GetSolutionsResult, SolutionProvider } from "puppeteer-extra-plugin-recaptcha/dist/types"; | ||
constructor(requestSolver?: (cid: string, captcha: CaptchaInfo) => void); | ||
_getSolutions(captchas: CaptchaInfo[], token?: string): Promise<GetSolutionsResult>; | ||
_getSolution(captcha: CaptchaInfo): Promise<CaptchaSolution>; | ||
poll(cid: string): Promise<Captcha>; | ||
solve(url: string, sitekey: string, cidCallback?: (cid: string) => void): Promise<Captcha>; | ||
_getSolutions: (captchas: CaptchaInfo[], token?: string) => Promise<GetSolutionsResult>; | ||
_getSolution: (captcha: CaptchaInfo) => Promise<CaptchaSolution>; | ||
_poll: (cid: string) => Promise<Captcha>; | ||
_solve: (url: string, sitekey: string, cidCallback?: ((cid: string) => void) | undefined) => Promise<Captcha>; | ||
} |
@@ -20,7 +20,7 @@ "use strict"; | ||
} | ||
async _getSolutions(captchas, token) { | ||
_getSolutions = async (captchas, token) => { | ||
const solutions = await Promise.all(captchas.map((captcha) => this._getSolution(captcha))); | ||
return { solutions, error: solutions.find((solution) => !!solution.error) }; | ||
} | ||
async _getSolution(captcha) { | ||
}; | ||
_getSolution = async (captcha) => { | ||
const solution = { | ||
@@ -39,3 +39,3 @@ _vendor: captcha._vendor, | ||
solution.requestAt = new Date(); | ||
const result = await this.solve(captcha.url, captcha.sitekey, (cid) => this.requestSolver && this.requestSolver(cid, captcha)); | ||
const result = await this._solve(captcha.url, captcha.sitekey, (cid) => this.requestSolver && this.requestSolver(cid, captcha)); | ||
solution.providerCaptchaId = result.cid; | ||
@@ -51,4 +51,4 @@ solution.text = result.token; | ||
return solution; | ||
} | ||
async poll(cid) { | ||
}; | ||
_poll = async (cid) => { | ||
return new Promise(async (resolve, reject) => { | ||
@@ -111,4 +111,4 @@ const clearTime = () => { | ||
}); | ||
} | ||
async solve(url, sitekey, cidCallback) { | ||
}; | ||
_solve = async (url, sitekey, cidCallback) => { | ||
return new Promise((resolve, reject) => { | ||
@@ -139,3 +139,3 @@ const data = JSON.stringify({ | ||
cidCallback && cidCallback(cid); | ||
resolve(await this.poll(cid)); | ||
resolve(await this._poll(cid)); | ||
} | ||
@@ -154,5 +154,5 @@ catch (error) { | ||
}); | ||
} | ||
}; | ||
} | ||
exports.Holz = Holz; | ||
//# sourceMappingURL=provider.js.map |
{ | ||
"name": "holz-provider", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Holz Captcha Provider + Server", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -24,8 +24,8 @@ import https, { RequestOptions } from "https"; | ||
async _getSolutions(captchas: CaptchaInfo[], token?: string): Promise<GetSolutionsResult> { | ||
_getSolutions = async (captchas: CaptchaInfo[], token?: string): Promise<GetSolutionsResult> => { | ||
const solutions = await Promise.all(captchas.map((captcha) => this._getSolution(captcha))); | ||
return { solutions, error: solutions.find((solution) => !!solution.error) }; | ||
} | ||
}; | ||
async _getSolution(captcha: CaptchaInfo): Promise<CaptchaSolution> { | ||
_getSolution = async (captcha: CaptchaInfo): Promise<CaptchaSolution> => { | ||
const solution: CaptchaSolution = { | ||
@@ -45,3 +45,3 @@ _vendor: captcha._vendor, | ||
const result = await this.solve( | ||
const result = await this._solve( | ||
captcha.url, | ||
@@ -61,5 +61,5 @@ captcha.sitekey, | ||
return solution; | ||
} | ||
}; | ||
async poll(cid: string): Promise<Captcha> { | ||
_poll = async (cid: string): Promise<Captcha> => { | ||
return new Promise<Captcha>(async (resolve, reject) => { | ||
@@ -122,5 +122,5 @@ const clearTime = () => { | ||
}); | ||
} | ||
}; | ||
async solve(url: string, sitekey: string, cidCallback?: (cid: string) => void): Promise<Captcha> { | ||
_solve = async (url: string, sitekey: string, cidCallback?: (cid: string) => void): Promise<Captcha> => { | ||
return new Promise<Captcha>((resolve, reject) => { | ||
@@ -152,3 +152,3 @@ const data = JSON.stringify({ | ||
cidCallback && cidCallback(cid); | ||
resolve(await this.poll(cid)); | ||
resolve(await this._poll(cid)); | ||
} catch (error) { | ||
@@ -166,3 +166,3 @@ reject((error as Error).toString()); | ||
}); | ||
} | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
159490