decord/source/modules/age_assurance/native/AgeVerificationWebViewScreen.tsx

212 lines
8 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 7954
// Function ID: 7955
2026-07-20 16:05:17 +00:00
// Name: AgeVerificationWebViewScreen
2026-08-25 06:04:03 +00:00
// Dependencies: [32, 19, 17, 7943, 7945, 21, 3, 4380, 712, 4234, 4621, 7948, 4094, 7955, 500, 5929, 2]
2026-07-20 16:05:17 +00:00
// Exports: default
2026-08-25 06:04:03 +00:00
// Module 7954 (AgeVerificationWebViewScreen)
2026-08-24 06:08:38 +00:00
import timestampDefault from "timestamp" /* 3 */;
import ThemesDefault from "Themes" /* 712 */;
import closure_3 from "_slicedToArray" /* 32 */;
import closure_4 from "noop" /* 19 */;
import { View } from "get ActivityIndicator" /* 17 */;
2026-08-25 06:04:03 +00:00
import { AGE_VERIFICATION_MODAL_KEY as closure_6 } from "set" /* 7943 */;
import AGE_VERIFICATION_INCODE_PATH from "AGE_VERIFICATION_INCODE_PATH" /* 7945 */;
2026-08-24 06:08:38 +00:00
import jsxProd from "jsxProd" /* 21 */;
2026-08-25 06:04:03 +00:00
import createCacheKey from "createCacheKey" /* 4380 */;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-08-24 06:08:38 +00:00
({ AgeVerificationIncodeResultStatus: error, buildIncodeFallbackSessionInjection: closure_8, parseIncodeWebViewMessage: c9 } = AGE_VERIFICATION_INCODE_PATH);
2026-07-29 08:29:29 +00:00
({ jsx: c10, jsxs: unpackModuleId } = jsxProd);
2026-08-24 06:08:38 +00:00
let closure_12 = new timestampDefault("AgeVerificationWebViewScreen");
2026-07-29 08:29:29 +00:00
createCacheKey = { container: null, loadingOverlay: null, webView: null };
2026-08-24 06:08:38 +00:00
createCacheKey = { flex: 1, backgroundColor: ThemesDefault.colors.BACKGROUND_BASE_LOWEST };
2026-07-29 08:29:29 +00:00
createCacheKey[0] = createCacheKey;
2026-08-24 06:08:38 +00:00
const tmp4 = new timestampDefault("AgeVerificationWebViewScreen");
createCacheKey[1] = { position: "absolute", top: 0, left: 0, right: 0, bottom: 0, alignItems: "center", justifyContent: "center", backgroundColor: ThemesDefault.colors.BACKGROUND_BASE_LOWEST };
let obj1 = { position: "absolute", top: 0, left: 0, right: 0, bottom: 0, alignItems: "center", justifyContent: "center", backgroundColor: ThemesDefault.colors.BACKGROUND_BASE_LOWEST };
createCacheKey[2] = { flex: 1, backgroundColor: ThemesDefault.colors.BACKGROUND_BASE_LOWEST };
let closure_13 = createCacheKey.createStyles(createCacheKey);
const obj2 = { flex: 1, backgroundColor: ThemesDefault.colors.BACKGROUND_BASE_LOWEST };
let result = require("set").fileFinishedImporting("modules/age_assurance/native/AgeVerificationWebViewScreen.tsx");
2026-07-20 16:05:17 +00:00
2026-08-06 08:05:19 +00:00
export default function AgeVerificationWebViewScreen(webviewUrl) {
webviewUrl = webviewUrl.webviewUrl;
const onComplete = webviewUrl.onComplete;
const onClose = webviewUrl.onClose;
2026-07-29 08:29:29 +00:00
let ref;
let React;
2026-08-24 06:08:38 +00:00
closure_5 = undefined;
2026-07-29 08:29:29 +00:00
c6 = undefined;
let callback;
let callback1;
let callback3;
let memo;
ref = React.useRef(null);
2026-07-23 10:11:24 +00:00
React = React.useRef(false);
2026-07-29 08:29:29 +00:00
closure_5 = React.useRef(false);
[tmp3, c6] = ref(React.useState(true), 2);
callback = React.useCallback(() => {
2026-07-20 16:05:17 +00:00
if (!ref2.current) {
2026-07-29 08:29:29 +00:00
tmp.current = true;
_undefined(false);
2026-07-20 16:05:17 +00:00
}
}, []);
const items = [callback];
const effect = React.useEffect(() => {
const timeout = setTimeout(() => {
2026-07-29 08:29:29 +00:00
if (!ref.current) {
2026-08-24 06:08:38 +00:00
closure_1_12.warn("WebView initial load timed out", { timeoutMs: 15000 });
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
callback();
2026-07-20 16:05:17 +00:00
}, 15000);
return () => clearTimeout(closure_0);
}, items);
const items1 = [onComplete, onClose];
2026-07-29 08:29:29 +00:00
callback1 = React.useCallback(() => {
2026-07-20 16:05:17 +00:00
if (!ref.current) {
2026-07-29 08:29:29 +00:00
tmp.current = true;
2026-07-20 16:05:17 +00:00
onComplete();
onClose();
}
}, items1);
const items2 = [callback1];
const callback2 = React.useCallback(() => {
2026-07-29 08:29:29 +00:00
let isModalOpenResult = webviewUrl(onClose[9]).isModalOpen(c6);
2026-07-20 16:05:17 +00:00
if (isModalOpenResult) {
isModalOpenResult = webviewUrl(onClose[10]).isAgeVerified();
2026-07-29 08:29:29 +00:00
const tmpResult = webviewUrl(onClose[10]);
2026-07-20 16:05:17 +00:00
}
if (isModalOpenResult) {
callback1();
}
}, items2);
2026-07-23 10:11:24 +00:00
let obj = webviewUrl(onClose[10]);
2026-07-20 16:05:17 +00:00
const watchAgeVerificationStatusChange = obj.useWatchAgeVerificationStatusChange(callback2);
2026-07-29 08:29:29 +00:00
callback3 = React.useCallback((arg0) => {
2026-07-20 16:05:17 +00:00
const current = ref.current;
2026-07-29 08:29:29 +00:00
if (current != null) {
2026-07-20 16:05:17 +00:00
current.injectJavaScript(callback1(arg0));
}
}, []);
const items3 = [callback1, callback3, onClose];
const items4 = [webviewUrl];
const callback4 = React.useCallback((nativeEvent) => {
2026-07-29 08:29:29 +00:00
try {
const tmp3 = callback3(nativeEvent.nativeEvent.data);
if (null != tmp3) {
if ("capture_complete" === tmp4.kind) {
const result = webviewUrl(onClose[11]).registerIncodeInterview(tmp3.interviewId);
const obj3 = webviewUrl(onClose[11]);
result.then(() => {
const current = ref.current;
let isAgeVerifiedResult = !current;
if (!current) {
2026-08-24 06:08:38 +00:00
isAgeVerifiedResult = closure_1_0(closure_1_2[10]).isAgeVerified();
const obj = closure_1_0(closure_1_2[10]);
2026-07-29 08:29:29 +00:00
}
if (isAgeVerifiedResult) {
2026-08-06 08:05:19 +00:00
callback2();
2026-07-29 08:29:29 +00:00
}
}).catch((error) => {
2026-08-24 06:08:38 +00:00
closure_1_12.warn("Failed to register Incode interview from WebView", { error });
2026-08-06 08:05:19 +00:00
if (!ref.current) {
tmp2.current = true;
callback();
}
2026-07-29 08:29:29 +00:00
});
} else if ("fallback_request" === tmp4.kind) {
let obj = webviewUrl(onClose[11]);
obj = { previousInterviewId: null };
obj[0] = tmp4.previousInterviewId;
const incodeSessionBootstrap = obj.requestIncodeSessionBootstrap(obj);
incodeSessionBootstrap.then((incode_parameters) => {
incode_parameters = incode_parameters.incode_parameters;
let session_token;
if (incode_parameters != null) {
session_token = incode_parameters.session_token;
}
if (null != session_token) {
if (null != incode_parameters.interview_id) {
const obj = { sessionToken: null, interviewId: null };
({ session_token: obj[0], interview_id: obj[1] } = incode_parameters);
2026-08-06 08:05:19 +00:00
callback3(obj);
2026-07-29 08:29:29 +00:00
}
2026-07-20 16:05:17 +00:00
}
2026-08-06 08:05:19 +00:00
callback3({ error: true });
2026-07-29 08:29:29 +00:00
}).catch((error) => {
2026-08-24 06:08:38 +00:00
closure_1_12.warn("Failed to bootstrap Incode fallback session from WebView", { error });
2026-08-06 08:05:19 +00:00
callback3({ error: true });
2026-07-29 08:29:29 +00:00
});
} else if (tmp4.status === callback.COMPLETED) {
callback1();
} else if (!ref.current) {
tmp8.current = true;
onClose();
}
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
} catch (tmp20) {
obj = { error: null };
obj[0] = tmp20;
2026-08-24 06:08:38 +00:00
closure_1_12.warn("Failed to parse WebView message", obj);
2026-07-20 16:05:17 +00:00
}
}, items3);
2026-07-29 08:29:29 +00:00
memo = React.useMemo(() => {
2026-07-20 16:05:17 +00:00
const uRL = new URL(webviewUrl);
return uRL.origin;
}, items4);
const items5 = [memo];
const callback5 = React.useCallback((isTopFrame) => {
if (null != isTopFrame.isTopFrame) {
2026-07-29 08:29:29 +00:00
if (!isTopFrame.isTopFrame) {
2026-07-20 16:05:17 +00:00
return true;
}
}
2026-07-29 08:29:29 +00:00
try {
const _URL = URL;
const uRL = new URL(isTopFrame.url);
let flag2 = uRL.origin === memo;
if (!flag2) {
onComplete(onClose[12]).openURL(isTopFrame.url);
2026-07-20 16:05:17 +00:00
flag2 = false;
2026-07-29 08:29:29 +00:00
const obj = onComplete(onClose[12]);
2026-07-20 16:05:17 +00:00
}
return flag2;
2026-07-29 08:29:29 +00:00
} catch (err) {
2026-07-20 16:05:17 +00:00
}
}, items5);
2026-08-24 06:08:38 +00:00
const tmp15 = callback();
2026-07-29 08:29:29 +00:00
obj = { style: tmp15.container, children: null };
2026-08-06 08:05:19 +00:00
obj = { ref, allowsInlineMediaPlayback: true, mediaCapturePermissionGrantType: "grant", javaScriptEnabled: true, source: { uri: webviewUrl }, onShouldStartLoadWithRequest: null, onMessage: null, onError: null, onLoadEnd: null, injectedJavaScriptBeforeContentLoaded: null, style: null, containerStyle: null };
const tmp16 = closure_11;
const tmp2 = ref(React.useState(true), 2);
const tmp8 = webviewUrl;
const tmp9 = onClose;
const tmp19 = onComplete(onClose[13]);
let tmp20;
if (obj4.isIOS()) {
tmp20 = callback5;
}
obj[5] = tmp20;
obj[6] = callback4;
obj[7] = function onError(code) {
2026-08-24 06:08:38 +00:00
closure_1_12.warn("WebView load error", { code: code.nativeEvent.code });
2026-08-06 08:05:19 +00:00
callback();
};
obj[8] = function onLoadEnd() {
callback();
2026-07-20 16:05:17 +00:00
};
2026-08-06 08:05:19 +00:00
obj[9] = webviewUrl.injectedJavaScriptBeforeContentLoaded;
({ webView: obj3[10], webView: obj3[11] } = tmp15);
const items6 = [memo(tmp19, obj), ];
2026-07-29 08:29:29 +00:00
if (tmp18Result) {
2026-08-24 06:08:38 +00:00
obj1 = { style: null, children: null };
2026-07-29 08:29:29 +00:00
obj1[0] = tmp15.loadingOverlay;
2026-08-06 08:05:19 +00:00
obj1[1] = tmp18(tmp8(tmp9[15]).ActivityIndicator, {});
2026-07-29 08:29:29 +00:00
tmp18Result = tmp18(tmp17, obj1);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
items6[1] = tmp18Result;
obj[1] = items6;
2026-08-06 08:05:19 +00:00
return tmp16(closure_5, obj);
2026-07-20 16:05:17 +00:00
};