Files
discord-decomp/_bundle/_default_16109.jsx
T
2026-11-01 12:12:55 +02:00

139 lines
5.5 KiB
React

// Metro module 16109 (f16110).
import { useCallback, useMemo } from "react";
import { ActivityIndicator, Linking, View, StyleSheet } from "react-native";
import Module6759 from "./Module6759";
let styles;
const injectedJavaScript = `(${String(function() {
const postMessage = window.ReactNativeWebView.postMessage;
const patchedPostMessage = function patchedPostMessage(a0, a1, a2) {
postMessage(a0, a1, a2);
};
patchedPostMessage.toString = function() {
return String(Object.hasOwnProperty).replace("hasOwnProperty", "postMessage");
};
window.ReactNativeWebView.postMessage = patchedPostMessage;
})})();`;
styles = StyleSheet.create({
loadingOverlay: {
bottom: 0,
justifyContent: "center",
left: 0,
position: "absolute",
right: 0,
top: 0
}
});
export default (a0) => {
const { onMessage, siteKey, style, url, languageCode } = a0;
a0.cancelButtonText;
const { showLoading, loadingIndicatorColor, backgroundColor, theme: theme2 } = a0;
let theme = theme2;
let rqdata = a0.rqdata;
const r23 = "https://hcaptcha.com/1/api.js?render=explicit&onload=onloadCallback" + `&host=${siteKey ? siteKey : "missing-sitekey"}.react-native.hcaptcha.com`;
const r24 = languageCode ? r23 + ("&hl=" + languageCode) : r23;
let c22798_5 = typeof theme2 === "object" ? r24 + "&custom=true" : r24;
const r29 = theme2 ? typeof theme2 === "string" : theme2;
let r30 = theme2;
if (r29) {
theme = `"${theme2}"`;
r30 = theme;
}
if (rqdata && typeof rqdata === "string") {
rqdata = `"${rqdata}"`;
}
return <Module6759 originWhitelist={["*"]} onShouldStartLoadWithRequest={(event) => {
let r2 = event.url.slice(0, 24) !== "https://www.hcaptcha.com";
if (!r2) {
Linking.openURL(event.url);
r2 = false;
}
return r2;
}} mixedContentMode="always" onMessage={onMessage} javaScriptEnabled injectedJavaScript={injectedJavaScript} automaticallyAdjustContentInsets style={[{
backgroundColor: "transparent",
width: "100%"
}, style]} source={{
html: useMemo(() => {
let r10 = siteKey;
if (!siteKey) {
r10 = "";
}
return `<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="${c22798_5}" async defer></script>
<script type="text/javascript">
var onloadCallback = function() {
try {
console.log("challenge onload starting");
hcaptcha.render("submit", getRenderConfig("${r10}", ${theme}));
// have loaded by this point; render is sync.
console.log("challenge render complete");
} catch (e) {
console.log("challenge failed to render");
window.ReactNativeWebView.postMessage("error");
}
try {
console.log("showing challenge");
hcaptcha.execute(getExecuteOpts());
} catch (e) {
console.log("failed to show challenge");
window.ReactNativeWebView.postMessage("error");
}
};
var onDataCallback = function(response) {
window.ReactNativeWebView.postMessage(response);
};
var onCancel = function() {
window.ReactNativeWebView.postMessage("cancel");
};
var onOpen = function() {
// NOTE: disabled for simplicity.
// window.ReactNativeWebView.postMessage("open");
console.log("challenge opened");
};
var onDataExpiredCallback = function(error) { window.ReactNativeWebView.postMessage("expired"); };
var onChalExpiredCallback = function(error) { window.ReactNativeWebView.postMessage("cancel"); };
var onDataErrorCallback = function(error) {
console.log("challenge error callback fired");
window.ReactNativeWebView.postMessage("error");
};
const getRenderConfig = function(siteKey, theme) {
var config = {
sitekey: siteKey,
size: "invisible",
callback: onDataCallback,
"close-callback": onCancel,
"open-callback": onOpen,
"expired-callback": onDataExpiredCallback,
"chalexpired-callback": onChalExpiredCallback,
"error-callback": onDataErrorCallback
};
if (theme) {
config.theme = theme;
}
return config;
};
const getExecuteOpts = function() {
var opts;
const rqdata = ${rqdata};
if (rqdata) {
opts = {"rqdata": rqdata};
}
return opts;
};
</script>
</head>
<body style="background-color: ${backgroundColor};">
<div id="submit"></div>
</body>
</html>`;
}, [siteKey, backgroundColor, r30]),
baseUrl: `${url}`
}} renderLoading={useCallback(() => <View style={[styles.loadingOverlay]}>
<ActivityIndicator size="large" color={loadingIndicatorColor} />
</View>, [loadingIndicatorColor])} startInLoadingState={showLoading} />;
};