Created
August 24, 2023 14:41
-
-
Save ad044/fb943c62d37487035b3f3c50161e5024 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let ct = { | |
host: null, | |
file: null, | |
sitekey: null, | |
a11y_tfe: null, | |
pingdom: | |
"safari" === tt.Browser.type && | |
"windows" !== tt.System.os && | |
"mac" !== tt.System.os && | |
"ios" !== tt.System.os && | |
"android" !== tt.System.os, | |
assetDomain: "https://newassets.hcaptcha.com", | |
assetUrl: "https://newassets.hcaptcha.com/captcha/v1/937a50f/static", | |
width: null, | |
height: null, | |
mobile: null, | |
orientation: "portrait", | |
challenge_type: null, | |
}; | |
// this is where we're at | |
function TheThing(manifest, false_bool) { | |
null !== e && (clearTimeout(e), (e = null)), | |
n.lockInterface(!0), | |
yo && (yo.p = Date.now() - yo.s), | |
po() | |
.then(function (t) { | |
return (function (t, e) { | |
return e || "on" !== ut.pat || !tt.supportsPAT() | |
? Promise.resolve({ proof: t, pass: !1 }) | |
: Vo.authenticate(t) | |
.then(function (t) { | |
return ( | |
uo(t.c), | |
po().then(function (e) { | |
return { | |
proof: e, | |
pass: t.pass, | |
authToken: t.auth_token, | |
}; | |
}) | |
); | |
}) | |
["catch"](function (t) { | |
vt(t), Vo.logAction(it.AUTHENTICATION_ERROR); | |
var e = t && t.response, | |
i = e && e.body; | |
return ( | |
uo(i.c), | |
po().then(function (t) { | |
return { proof: t, pass: i.pass || !1 }; | |
}) | |
); | |
}); | |
})(t, false_bool); | |
}) | |
.then(function (t) { | |
return Vo.hasPrivateStateToken().then(function (e) { | |
return (t.hasPst = e), t; | |
}); | |
}) | |
.then(function (t) { | |
return ( | |
yo && (yo.gcs = Date.now() - yo.s), | |
Vo.getTaskData(manifest, t, ((e = mo), (mo = null), e), yo) | |
); | |
var e; | |
}) | |
.then(function (t) { | |
return ( | |
yo && (yo.gce = Date.now() - yo.s), | |
t.pass || !1 === t.success | |
? l(t) | |
: ((e = { | |
c: t.c, | |
rq: t.rq, | |
key: t.key, | |
challengeType: t.request_type, | |
}), | |
e.challengeType | |
? (e.key && oi.send("challenge-key", { key: e.key }), | |
n.create({ rq: e.rq }), | |
uo(e.c), | |
(i = e.challengeType), | |
yo && ((yo.l = Date.now() - yo.s), (yo.t = i)), | |
Vo.loadBundle(e.challengeType) | |
.then(function (t) { | |
var i = Vo.getData(); | |
return ( | |
n.lockInterface(!1), | |
yo && (yo.o = Date.now() - yo.s), | |
n.show({ | |
width: ct.browserWidth, | |
height: ct.browserHeight, | |
bundle: t, | |
bundleData: i, | |
expiration: 1e3 * (i.expiration || 120), | |
challengeType: e.challengeType, | |
}) | |
); | |
}) | |
.then(function (t) { | |
return new Promise(function (e) { | |
Promise.all([ | |
po(), | |
oi.contact("check-api"), | |
]).then(function (i) { | |
e({ | |
answers: t, | |
proof: i[0], | |
motionData: i[1], | |
}); | |
}); | |
}); | |
}) | |
.then(function (t) { | |
Ke.stop(); | |
var e = t.answers, | |
i = t.proof, | |
n = Ke.getData(); | |
return ( | |
(n.topLevel = t.motionData), | |
(n.v = 1), | |
yo && (yo.c = Date.now() - yo.s), | |
Vo.checkAnswers(e, n, i) | |
); | |
}) | |
["catch"](function (t) { | |
if ( | |
n.isVisible() || | |
(t && -1 === o.indexOf(t.message)) | |
) | |
throw (n.lockInterface(!0), t); | |
})) | |
: Promise.resolve({ c: e.c, skip: !0 })).then(l) | |
); | |
var e, i; | |
}) | |
["catch"](function (e) { | |
var i = | |
e instanceof Error | |
? { event: it.CHALLENGE_ERROR, message: e.message || "" } | |
: e; | |
Vo.logAction(i.event); | |
var n = 429 === e.status, | |
o = e.response && e.response["error-codes"], | |
s = o && -1 !== o.indexOf("invalid-data"); | |
kt("challenge", "api", "debug", e), | |
n || | |
s || | |
(i.event !== it.NETWORK_ERROR && | |
i.event !== it.CHALLENGE_ERROR && | |
i.event !== it.BUNDLE_ERROR) || | |
!(t <= 2) | |
? (t > 2 && | |
0 !== e.status && | |
429 !== e.status && | |
403 !== e.status && | |
400 !== e.status && | |
wt("api:getcaptcha failed", "error", "challenge", { | |
error: e, | |
}), | |
(t = 0), | |
s && | |
(i = { | |
event: it.NETWORK_ERROR, | |
message: (o || [""]).join(", "), | |
}), | |
go(i.event), | |
oi.send(et.CHALLENGE_CLOSED, i)) | |
: ((t += 1), c()); | |
}); | |
} | |
function SetupChallenge(setup_chall_args) { | |
yo = { s: Date.now(), n: 0 }; | |
if (payload) { | |
setRqData(payload.rqdata); | |
} | |
let wdata; | |
let manifest = {}; | |
if (setup_chall_args) { | |
SetRqData(setup_chall_args.rqdata || GetRqData()) | |
if (payload.wdata) { | |
wdata = setup_chall_args.wdata; | |
window.__wdata = wdata; | |
} | |
// some weird shit with errors | |
// lo(setup_chall_args.errors), | |
if (setup_chall_args.width) { | |
ct.browserWidth = setup_chall_args.width; | |
ct.browserHeight = setup_chall_args.height; | |
} | |
if (setup_chall_args.manifest) { | |
manifest = setup_chall_args.manifest; | |
} | |
// some stuff checking whether or not the user is using keyboard i assuem | |
// "enter" === setup_chall_args.action | |
// ? i.addClass("using-kb") | |
// : i.hasClass("using-kb") && i.removeClass("using-kb"), | |
// this function sounds important but it only seems to | |
// set up the logo and initialize a11y challenge which we'll ignore for now | |
n.init(payload); | |
// some dom stuff perhaps | |
n.setFocus("info"); | |
// this is the important part | |
TheThing(manifest, !1); | |
} | |
} | |
function GetWindowData() { | |
try { | |
return Object.keys(window).sort().join(","); | |
} catch (Ts) { | |
return null; | |
} | |
} | |
function InitChallenge(payload) { | |
const manifest = getCaptchaManifest(); // null stub for now | |
const charity = payload.charity || null; | |
const a11yChallenge = payload.a11yChallenge || !1; | |
const link = payload.link || null; | |
const action = payload.action || ""; | |
const rqdata = payload.rqdata || null; | |
const errors = payload.errors || []; | |
// this is separate logic but idk if we care about this now | |
const width = tt.Browser.width(); | |
const height = tt.Browser.height(); | |
SetCheckBoxResponse(""); // null stub | |
SetupChallenge({ | |
a11yChallenge, | |
manifest, | |
width, | |
height, | |
charity, | |
link, | |
action, | |
rqdata, | |
wdata: GetWindowData(), | |
// this concatenates with some other weird thing but dont care for now | |
errors | |
}); | |
} | |
function execute(captchaId, payload) { | |
manifest["exec"] = true; | |
InitChallenge(payload); | |
} | |
execute("some_id", { rqdata: "some_rqdata" }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment