-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
50 lines (44 loc) · 1.12 KB
/
index.js
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
var request = require("request");
const VERIFY_URL = "https://arcaptcha.co/2/siteverify";
const verify = (secret_key, site_key, challenge_id) => {
return new Promise(function verifyPromise(resolve, reject) {
let payload = {
secret: secret_key,
sitekey: site_key,
response: challenge_id,
};
request.post(
{
url: VERIFY_URL,
json: payload,
},
function (error, response, body) {
if (!error && response.statusCode == 200) {
if (!body.success) resolve(body);
else resolve(true);
}
if (error) {
reject(error);
}
}
);
});
};
const displayCaptcha = (
site_key,
size = "normal",
callback = null,
theme = "light",
color = null,
lang = "fa"
) => {
return `<div class=arcaptcha data-site-key=${site_key} data-color=${color} data-size=${size} data-theme=${theme} data-lang=${lang} data-callback=${callback}></div>`;
};
const display_tag = () => {
return "<script src='https://widget.arcaptcha.ir/1/api.js' async defer></script>";
};
module.exports = {
verify,
displayCaptcha,
display_tag,
};