157 lines
6 KiB
TypeScript
157 lines
6 KiB
TypeScript
// Module ID: 8088
|
|
// Function ID: 8089
|
|
// Name: AgeVerificationIncodeWebViewConstants
|
|
// Dependencies: [2]
|
|
// Exports: buildIncodeFallbackSessionInjection, buildIncodeParamsInjection, parseIncodeWebViewMessage, postIncodeCaptureComplete, postIncodeFallbackRequest, postIncodeResult, readInjectedIncodeParams
|
|
|
|
// Module 8088 (AgeVerificationIncodeWebViewConstants)
|
|
import size from "module_2" /* 2 */;
|
|
|
|
const __DISCORD_AGE_VERIFICATION_INCODE_PARAMS__ = "__DISCORD_AGE_VERIFICATION_INCODE_PARAMS__";
|
|
let c1 = "Verification.Result";
|
|
let c2 = "Verification.CaptureComplete";
|
|
let c3 = "Verification.FallbackRequest";
|
|
const __DISCORD_APPLY_INCODE_FALLBACK_SESSION__ = "__DISCORD_APPLY_INCODE_FALLBACK_SESSION__";
|
|
const AgeVerificationIncodeResultStatus = { COMPLETED: "completed", CANCELLED: "cancelled", ERROR: "error" };
|
|
const result = size.fileFinishedImporting("modules/age_assurance/AgeVerificationIncodeWebViewConstants.tsx");
|
|
|
|
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 { AgeVerificationIncodeResultStatus };
|
|
export const readInjectedIncodeParams = function readInjectedIncodeParams() {
|
|
let apiUrl;
|
|
let consentId;
|
|
let interviewId;
|
|
let method;
|
|
let schemaVersion;
|
|
let sessionToken;
|
|
let theme;
|
|
if (null != window[__DISCORD_AGE_VERIFICATION_INCODE_PARAMS__]) {
|
|
if (typeof window[__DISCORD_AGE_VERIFICATION_INCODE_PARAMS__] === "object") {
|
|
let tmp2;
|
|
({ schemaVersion, apiUrl, sessionToken, consentId, interviewId, theme, method } = window[__DISCORD_AGE_VERIFICATION_INCODE_PARAMS__]);
|
|
if (null == schemaVersion) {
|
|
tmp2 = null;
|
|
if (typeof apiUrl === "string") {
|
|
tmp2 = null;
|
|
if (typeof sessionToken === "string") {
|
|
tmp2 = null;
|
|
if (typeof consentId === "string") {
|
|
tmp2 = null;
|
|
if (typeof interviewId === "string") {
|
|
if (null == theme) {
|
|
const obj = { apiUrl, sessionToken, consentId, interviewId, theme, method };
|
|
if (theme == null) {
|
|
theme = null;
|
|
}
|
|
if (method == null) {
|
|
method = null;
|
|
}
|
|
tmp2 = obj;
|
|
} else {
|
|
tmp2 = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
tmp2 = null;
|
|
}
|
|
return tmp2;
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
export const buildIncodeParamsInjection = function buildIncodeParamsInjection(arg0, arg1) {
|
|
const obj = { schemaVersion: 2 };
|
|
const merged = Object.assign(arg0);
|
|
const json = JSON.stringify(JSON.stringify(obj));
|
|
return "if (window.location.origin === " + JSON.stringify(arg1) + ") { window." + __DISCORD_AGE_VERIFICATION_INCODE_PARAMS__ + " = JSON.parse(" + json + "); } true;";
|
|
};
|
|
export const parseIncodeWebViewMessage = function parseIncodeWebViewMessage(str) {
|
|
let obj;
|
|
if (null == str) {
|
|
return null;
|
|
} else {
|
|
let parsed = str;
|
|
if (typeof str === "string") {
|
|
const _JSON = JSON;
|
|
parsed = JSON.parse(str);
|
|
}
|
|
let eventType;
|
|
if (parsed != null) {
|
|
eventType = parsed.eventType;
|
|
}
|
|
if (eventType === c2) {
|
|
let tmp10 = null;
|
|
if (typeof parsed.interviewId === "string") {
|
|
tmp10 = null;
|
|
if (0 !== parsed.interviewId.length) {
|
|
tmp10 = { kind: "capture_complete", interviewId: parsed.interviewId };
|
|
const obj2 = { kind: "capture_complete", interviewId: parsed.interviewId };
|
|
}
|
|
}
|
|
return tmp10;
|
|
} else {
|
|
let eventType1;
|
|
if (parsed != null) {
|
|
eventType1 = parsed.eventType;
|
|
}
|
|
if (eventType1 === c3) {
|
|
let tmp9 = null;
|
|
if (typeof parsed.previousInterviewId === "string") {
|
|
tmp9 = null;
|
|
if (0 !== parsed.previousInterviewId.length) {
|
|
tmp9 = { kind: "fallback_request", previousInterviewId: parsed.previousInterviewId };
|
|
const obj3 = { kind: "fallback_request", previousInterviewId: parsed.previousInterviewId };
|
|
}
|
|
}
|
|
return tmp9;
|
|
} else {
|
|
let eventType2;
|
|
if (parsed != null) {
|
|
eventType2 = parsed.eventType;
|
|
}
|
|
if (eventType2 !== c1) {
|
|
return null;
|
|
} else {
|
|
const status = parsed.status;
|
|
if (status !== obj.COMPLETED) {
|
|
let tmp8;
|
|
if (status !== obj.CANCELLED) {
|
|
tmp8 = null;
|
|
}
|
|
return tmp8;
|
|
}
|
|
obj = { kind: "result", status };
|
|
tmp8 = obj;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
export const postIncodeResult = function postIncodeResult(arg0) {
|
|
if (ReactNativeWebView != null) {
|
|
ReactNativeWebView.postMessage(tmp);
|
|
}
|
|
};
|
|
export const postIncodeCaptureComplete = function postIncodeCaptureComplete(arg0) {
|
|
if (ReactNativeWebView != null) {
|
|
ReactNativeWebView.postMessage(tmp);
|
|
}
|
|
};
|
|
export const postIncodeFallbackRequest = function postIncodeFallbackRequest(arg0) {
|
|
if (ReactNativeWebView != null) {
|
|
ReactNativeWebView.postMessage(tmp);
|
|
}
|
|
};
|
|
export const buildIncodeFallbackSessionInjection = function buildIncodeFallbackSessionInjection(arg0) {
|
|
const json = JSON.stringify(JSON.stringify(arg0));
|
|
return "(function(){var detail=JSON.parse(" + json + ");var key=" + JSON.stringify(__DISCORD_APPLY_INCODE_FALLBACK_SESSION__) + ";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;";
|
|
};
|