32 lines
942 B
TypeScript
32 lines
942 B
TypeScript
export async function onRequestGet(context: RequestContext) {
|
|
return new Response(
|
|
`<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>WebView Captcha</title>
|
|
<script async defer src="https://challenges.cloudflare.com/turnstile/v0/api.js"></script>
|
|
</head>
|
|
<body>
|
|
<div class="cf-turnstile" data-callback="returnToken" data-error-callback="handleError" data-sitekey="${context.env.TURNSTILE_SITEKEY}" style="width: 90%; translate(5%);"></div>
|
|
<script>
|
|
function handleError(error) {
|
|
console.error(error);
|
|
window.flutter_inappwebview.callHandler("onToken", null);
|
|
|
|
return true;
|
|
}
|
|
|
|
function returnToken(token) {
|
|
window.flutter_inappwebview.callHandler("onToken", token);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>`,
|
|
{
|
|
headers: {
|
|
"content-type": "text/html",
|
|
},
|
|
},
|
|
);
|
|
}
|