forked from CapMonsterCloud/capmonster-nodejs-captcha-solver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecaptchaV2EnterpriseRequestBase.ts
More file actions
80 lines (72 loc) · 2.49 KB
/
Copy pathRecaptchaV2EnterpriseRequestBase.ts
File metadata and controls
80 lines (72 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { CaptchaRequestBase, CaptchaRequestBaseIn } from '../CaptchaRequestBase';
export type RecaptchaV2EnterpriseRequestBaseIn = {
websiteURL: string;
websiteKey: string;
enterprisePayload?: Record<string, unknown>;
recaptchaDataSValue?: string;
userAgent?: string;
pageAction?: string;
} & CaptchaRequestBaseIn;
/**
* Base Recaptcha V2 Enterprise recognition request
*/
export abstract class RecaptchaV2EnterpriseRequestBase extends CaptchaRequestBase {
/**
* Address of a webpage with Google ReCaptcha
*/
public websiteURL!: string;
/**
* Recaptcha website key.
* @example
* <![CDATA[<div class="g-recaptcha" data-sitekey="THAT_ONE"></div>]]>
*/
public websiteKey!: string;
/**
* Additional parameters which should be passed to "grecaptcha.enterprise.render" method along with sitekey.
* Example of what you should search for:
* @example
* <![CDATA[
* grecaptcha.enterprise.render("some-div-id", {
* sitekey: "6Lc_aCMTAAAAABx7u2N0D1XnVbI_v6ZdbM6rYf16",
* theme: "dark",
* s: "2JvUXHNTnZl1Jb6WEvbDyBMzrMTR7oQ78QRhBcG07rk9bpaAaE0LRq1ZeP5NYa0N...ugQA"
* });
* ]]>
* @description
* In this example, you will notice a parameter "s" which is not documented, but obviously required.
* Send it to the API, so that we render the Recaptcha widget with this parameter properly.
*/
public enterprisePayload?: Record<string, unknown>;
/**
* Some custom implementations may contain additional "data-s" parameter in ReCaptcha2 div, which is in fact a one-time token and must be grabbed every time you want to solve a ReCaptcha2.
* @example
* <![CDATA[<div class="g-recaptcha" data-sitekey="some sitekey" data-s="THIS_ONE"></div>]]>
*/
public recaptchaDataSValue?: string;
/**
* Browser's User-Agent which is used in emulation.
* It is required that you use a signature of a modern browser,
* otherwise Google will ask you to "update your browser".
*/
public userAgent?: string;
// The action name passed to grecaptcha.execute().
public pageAction?: string;
constructor({
type,
nocache,
websiteURL,
websiteKey,
enterprisePayload,
recaptchaDataSValue,
userAgent,
pageAction,
}: RecaptchaV2EnterpriseRequestBaseIn) {
super({ type, nocache });
this.websiteURL = websiteURL;
this.websiteKey = websiteKey;
this.enterprisePayload = enterprisePayload;
this.recaptchaDataSValue = recaptchaDataSValue;
this.userAgent = userAgent;
this.pageAction = pageAction;
}
}