I am trying to integrate AWS WAF CAPTCHA inside a React Native WebView. The AWS WAF response provides an HTML document that includes scripts (CDNs) for challenge and CAPTCHA rendering. However, the CAPTCHA does not render properly inside WebView. Even though the html document is rendering in web, it is only showing white screen in WebView.
const htmlContent = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Human Verification</title>
<script>
window.awsWafCookieDomainList = [];
window.gokuProps = {
"key": "AQIDAHjcYu/GjX+QlghicBgQ/...",
"iv": "A6wedAGoHAAAPbE0",
"context": "NFyHZVaB4qXxqYnXxoFtvbWK..."
};
window.addEventListener("load", function() {
const container = document.querySelector("#captcha-container");
if (window.CaptchaScript && window.ChallengeScript) {
CaptchaScript.renderCaptcha(container, async (voucher) => {
await ChallengeScript.submitCaptcha(voucher);
window.location.reload(true);
});
} else {
console.error("CaptchaScript or ChallengeScript is not defined");
}
});
</script>
</head>
<body>
<div id="captcha-container"></div>
<noscript>
<h1>JavaScript is disabled</h1>
<p>In order to continue, you need to verify that you're not a robot by solving a CAPTCHA puzzle.</p>
<p>The CAPTCHA puzzle requires JavaScript. Enable JavaScript and then reload the page.</p>
</noscript>
</body>
</html>
`;
return (
<View style={styles.container}>
<WebView
originWhitelist={['*']}
source={{ html: htmlContent }}
javaScriptEnabled={true}
domStorageEnabled={true}
/>
</View>
);
};```