decord/source/modules/age_assurance/AgeVerificationIncodeWebViewConstants.tsx

163 lines
5.8 KiB
TypeScript
Raw Normal View History

2026-08-07 06:50:47 +00:00
// Module ID: 7740
// Function ID: 7741
2026-07-29 08:29:29 +00:00
// Name: AGE_VERIFICATION_INCODE_PATH
2026-07-23 10:11:24 +00:00
// Dependencies: [2]
2026-07-20 16:05:17 +00:00
// Exports: buildIncodeFallbackSessionInjection, buildIncodeParamsInjection, parseIncodeWebViewMessage, postIncodeCaptureComplete, postIncodeFallbackRequest, postIncodeResult, readInjectedIncodeParams
2026-08-07 06:50:47 +00:00
// Module 7740 (AGE_VERIFICATION_INCODE_PATH)
2026-07-29 08:29:29 +00:00
let c0 = "__DISCORD_AGE_VERIFICATION_INCODE_PARAMS__";
let c1 = "Verification.Result";
let c2 = "Verification.CaptureComplete";
let c3 = "Verification.FallbackRequest";
let c4 = "__DISCORD_APPLY_INCODE_FALLBACK_SESSION__";
2026-07-23 10:11:24 +00:00
let obj = { COMPLETED: "completed", CANCELLED: "cancelled", ERROR: "error" };
const result = require("set").fileFinishedImporting("modules/age_assurance/AgeVerificationIncodeWebViewConstants.tsx");
2026-07-20 16:05:17 +00:00
export const AGE_VERIFICATION_INCODE_PATH = "/age-verification/incode";
export const AGE_VERIFICATION_INCODE_PARAMS_KEY = "__DISCORD_AGE_VERIFICATION_INCODE_PARAMS__";
export const AGE_VERIFICATION_INCODE_PARAMS_SCHEMA_VERSION = 2;
export const VERIFICATION_RESULT_EVENT_TYPE = "Verification.Result";
export const VERIFICATION_CAPTURE_COMPLETE_EVENT_TYPE = "Verification.CaptureComplete";
export const VERIFICATION_FALLBACK_REQUEST_EVENT_TYPE = "Verification.FallbackRequest";
export const INCODE_FALLBACK_SESSION_CALLBACK_KEY = "__DISCORD_APPLY_INCODE_FALLBACK_SESSION__";
export const AgeVerificationIncodeResultStatus = obj;
export const readInjectedIncodeParams = function readInjectedIncodeParams() {
let apiUrl;
let consentId;
let interviewId;
let method;
let schemaVersion;
let sessionToken;
let theme;
2026-07-29 08:29:29 +00:00
if (null != window[c0]) {
2026-08-04 21:03:28 +00:00
if (typeof tmp === "object") {
2026-07-29 08:29:29 +00:00
({ schemaVersion, apiUrl, sessionToken, consentId, interviewId, theme, method } = tmp);
2026-07-20 16:05:17 +00:00
if (null == schemaVersion) {
2026-07-29 08:29:29 +00:00
let tmp2 = null;
2026-08-04 21:03:28 +00:00
if (typeof apiUrl === "string") {
2026-07-29 08:29:29 +00:00
tmp2 = null;
2026-08-04 21:03:28 +00:00
if (typeof sessionToken === "string") {
2026-07-29 08:29:29 +00:00
tmp2 = null;
2026-08-04 21:03:28 +00:00
if (typeof consentId === "string") {
2026-07-29 08:29:29 +00:00
tmp2 = null;
2026-08-04 21:03:28 +00:00
if (typeof interviewId === "string") {
2026-07-20 16:05:17 +00:00
if (null == theme) {
2026-07-29 08:29:29 +00:00
const obj = { apiUrl: null, sessionToken: null, consentId: null, interviewId: null, theme: null, method: null };
obj[0] = apiUrl;
obj[1] = sessionToken;
obj[2] = consentId;
obj[3] = interviewId;
if (theme == null) {
theme = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[4] = theme;
if (method == null) {
method = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[5] = method;
tmp2 = obj;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
tmp2 = null;
2026-07-20 16:05:17 +00:00
}
}
}
}
}
} else {
2026-07-29 08:29:29 +00:00
tmp2 = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp2;
2026-07-20 16:05:17 +00:00
}
}
return null;
};
export const buildIncodeParamsInjection = function buildIncodeParamsInjection(arg0, arg1) {
const obj = {};
const merged = Object.assign(arg0);
2026-07-29 08:29:29 +00:00
obj.schemaVersion = 2;
2026-07-20 16:05:17 +00:00
const json = JSON.stringify(JSON.stringify(obj));
2026-07-29 08:29:29 +00:00
return "if (window.location.origin === " + JSON.stringify(arg1) + ") { window." + c0 + " = JSON.parse(" + json + "); } true;";
2026-07-20 16:05:17 +00:00
};
2026-08-04 21:03:28 +00:00
export const parseIncodeWebViewMessage = function parseIncodeWebViewMessage(str) {
if (null == str) {
2026-07-20 16:05:17 +00:00
return null;
} else {
2026-08-04 21:03:28 +00:00
let parsed = str;
if (typeof str === "string") {
2026-07-20 16:05:17 +00:00
const _JSON = JSON;
2026-08-04 21:03:28 +00:00
parsed = JSON.parse(str);
2026-07-20 16:05:17 +00:00
}
let eventType;
2026-07-29 08:29:29 +00:00
if (parsed != null) {
2026-07-20 16:05:17 +00:00
eventType = parsed.eventType;
}
2026-07-29 08:29:29 +00:00
if (eventType === c2) {
let tmp10 = null;
2026-08-04 21:03:28 +00:00
if (typeof parsed.interviewId === "string") {
2026-07-29 08:29:29 +00:00
tmp10 = null;
2026-07-20 16:05:17 +00:00
if (0 !== parsed.interviewId.length) {
2026-07-29 08:29:29 +00:00
let obj = { kind: "capture_complete", interviewId: null };
obj[1] = parsed.interviewId;
tmp10 = obj;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
return tmp10;
2026-07-20 16:05:17 +00:00
} else {
let eventType1;
2026-07-29 08:29:29 +00:00
if (parsed != null) {
2026-07-20 16:05:17 +00:00
eventType1 = parsed.eventType;
}
2026-07-29 08:29:29 +00:00
if (eventType1 === c3) {
let tmp9 = null;
2026-08-04 21:03:28 +00:00
if (typeof parsed.previousInterviewId === "string") {
2026-07-29 08:29:29 +00:00
tmp9 = null;
2026-07-20 16:05:17 +00:00
if (0 !== parsed.previousInterviewId.length) {
2026-07-29 08:29:29 +00:00
obj = { kind: "fallback_request", previousInterviewId: null };
obj[1] = parsed.previousInterviewId;
tmp9 = obj;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
return tmp9;
2026-07-20 16:05:17 +00:00
} else {
let eventType2;
2026-07-29 08:29:29 +00:00
if (parsed != null) {
2026-07-20 16:05:17 +00:00
eventType2 = parsed.eventType;
}
2026-07-29 08:29:29 +00:00
if (eventType2 !== c1) {
2026-07-20 16:05:17 +00:00
return null;
} else {
const status = parsed.status;
if (status !== obj.COMPLETED) {
2026-07-29 08:29:29 +00:00
if (status !== tmp7.CANCELLED) {
let tmp8 = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp8;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj = { kind: "result", status: null };
obj[1] = status;
tmp8 = obj;
2026-07-20 16:05:17 +00:00
}
}
}
}
};
2026-07-29 08:29:29 +00:00
export const postIncodeResult = function postIncodeResult(arg0) {
if (ReactNativeWebView != null) {
ReactNativeWebView.postMessage(tmp);
}
2026-07-20 16:05:17 +00:00
};
2026-07-29 08:29:29 +00:00
export const postIncodeCaptureComplete = function postIncodeCaptureComplete(arg0) {
if (ReactNativeWebView != null) {
ReactNativeWebView.postMessage(tmp);
}
2026-07-20 16:05:17 +00:00
};
2026-07-29 08:29:29 +00:00
export const postIncodeFallbackRequest = function postIncodeFallbackRequest(arg0) {
if (ReactNativeWebView != null) {
ReactNativeWebView.postMessage(tmp);
}
2026-07-20 16:05:17 +00:00
};
export const buildIncodeFallbackSessionInjection = function buildIncodeFallbackSessionInjection(arg0) {
const json = JSON.stringify(JSON.stringify(arg0));
2026-07-29 08:29:29 +00:00
return "(function(){var detail=JSON.parse(" + json + ");var key=" + JSON.stringify(c4) + ";var n=0;var apply=function(){var cb=window[key];if(typeof cb===\"function\"){cb(detail);return true;}return false;};if(apply()){return;}var id=setInterval(function(){n+=1;if(apply()||n>40){clearInterval(id);}},50);})();true;";
2026-07-20 16:05:17 +00:00
};