forked from dzmitry-duboyski/2captcha-ts
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathrenameParams.ts
More file actions
57 lines (49 loc) · 1.38 KB
/
renameParams.ts
File metadata and controls
57 lines (49 loc) · 1.38 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
/**
*
* ### Renaming captcha parameters
*
* Description: parameter names used in the API may differ from those used in the library, in such cases parameter names are renamed in accordance with those used in the API.
*
* @param params - captcha parameters as an object
* @returns returns new object with renamed params
*
*/
export default function renameParams(params: any) {
let newParams: any = new Object();
/**
* Captcha parameters that need to be renamed before sent to the API.
*/
const replaceParams: any = {
// Grid
"cols" : "recaptchacols",
"rows" : "recaptcharows",
"minClicks" : "min_clicks",
"maxClicks" : "max_clicks",
"canSkip" : "can_no_answer",
"previousId" : "previousID",
"imgType" : "img_type",
// KeyCaptcha
"userId" : "s_s_c_user_id",
"sessionId":"s_s_c_session_id",
"webServerSign":"s_s_c_web_server_sign",
"webServerSign2":"s_s_c_web_server_sign2",
// Cutcaptcha
"miseryKey":"misery_key",
"apiKey":"api_key",
// Tencent
"appId": "app_id",
// atbCAPTCHA
"apiServer": "api_server",
// Altcha
"challengeUrl": "challenge_url",
"challengeJson": "challenge_json",
}
for(let key in params) {
if(replaceParams.hasOwnProperty(key)) {
newParams[replaceParams[key]] = params[key]
} else {
newParams[key] = params[key]
}
}
return newParams
}