Files
discord-decomp/modules/age_assurance/AgeVerificationURLActionCreators.tsx
T
2026-11-01 12:12:55 +02:00

143 lines
4.4 KiB
TypeScript

// Metro module 6754 (f6755).
import AuthenticationStore from "../../stores/AuthenticationStore";
import { VerificationVendorName } from "./AgeVerificationConstants";
import { Endpoints } from "../../Constants";
import { isCurrentUserSuspended } from "../safety_hub/SafetyHubUtils";
import { HTTP } from "../../_bundle/sendRequest";
import Dispatcher from "../../Dispatcher";
let initiateAgeVerification, initiateSuspendedUserAgeVerification, fetchAgeVerificationMethods, fetchAgeVerificationMethodsSuspendedUser;
const requestAgeVerification = async function requestAgeVerification(c25985_0) {
let r82;
let c25985_2;
let c29836_0, c29836_1, c29836_2;
L14: {
c25985_2 = void 0;
c29836_0 = void 0;
c29836_1 = void 0;
c29836_2 = void 0;
c29836_0 = c25985_0.method;
c29836_1 = c25985_0.classificationId;
c29836_2 = c25985_0.vendor;
await void 0;
if (isCurrentUserSuspended()) {
r82 = await (0, initiateSuspendedUserAgeVerification)({
classificationId: c29836_1,
method: c29836_0
});
break L14;
}
return await (0, initiateAgeVerification)(c29836_0, c29836_2);
}
return r82;
};
initiateAgeVerification = async function initiateAgeVerification(method2, vendor) {
return (await HTTP.post({
url: Endpoints.VERIFY_AGE,
body: {
method: method2,
vendor
},
rejectWithError: true
})).body;
};
initiateSuspendedUserAgeVerification = async function initiateSuspendedUserAgeVerification(c25988_0) {
let c25988_2;
c25988_2 = void 0;
let c29838_0 = c25988_0.classificationId;
let c29838_1 = c25988_0.method;
await void 0;
let c29838_2 = AuthenticationStore.getSuspendedUserToken();
return (await HTTP.post({
url: Endpoints.SAFETY_HUB_REQUEST_SUSPENDED_AGE_VERIFICATION,
body: {
token: c29838_2,
from_classification_id: c29838_0,
method: c29838_1
},
rejectWithError: true
})).body;
};
fetchAgeVerificationMethods = function fetchAgeVerificationMethods() {
return HTTP.get({
url: Endpoints.AGE_VERIFICATION_METHODS,
rejectWithError: true
});
};
fetchAgeVerificationMethodsSuspendedUser = function fetchAgeVerificationMethodsSuspendedUser() {
return HTTP.post({
url: Endpoints.SAFETY_HUB_GET_SUSPENDED_AGE_VERIFICATION_METHODS,
rejectWithError: true,
body: {
token: AuthenticationStore.getSuspendedUserToken()
}
});
};
export { requestAgeVerification };
export async function requestIncodeMethodSession(method) {
const incode_parameters2 = (await requestAgeVerification({
method,
vendor: VerificationVendorName.INCODE
})).incode_parameters;
let incode_parameters = incode_parameters2;
if (incode_parameters2 == null) {
incode_parameters = {};
}
let c29837_0 = incode_parameters;
let c29837_1 = c29837_0.api_url;
let c29837_2 = c29837_0.session_token;
let c29837_3 = c29837_0.consent_id;
let c29837_4 = c29837_0.interview_id;
return c29837_1 == null ? null : c29837_2 == null ? null : c29837_3 == null ? null : c29837_4 == null ? null : {
apiUrl: c29837_1,
sessionToken: c29837_2,
consentId: c29837_3,
interviewId: c29837_4
};
}
export { initiateAgeVerification };
export { initiateSuspendedUserAgeVerification };
export async function registerIncodeInterview(interview_id) {
await HTTP.post({
url: Endpoints.REGISTER_INCODE_INTERVIEW,
body: {
interview_id
},
rejectWithError: true
});
}
export async function requestIncodeSessionBootstrap(c25990_0) {
let c25990_2;
c25990_2 = void 0;
let r27 = c25990_0;
if (r27 === void 0) {
r27 = {};
}
let c29839_0 = r27;
await void 0;
return (await HTTP.post({
url: Endpoints.CREATE_INCODE_SESSION,
body: c29839_0.previousInterviewId != null ? {
previous_interview_id: c29839_0.previousInterviewId
} : void 0,
rejectWithError: true
})).body;
}
export async function getAgeVerificationMethods() {
Dispatcher.dispatch({
type: "AGE_VERIFICATION_METHODS_LOAD_START"
});
const r34 = isCurrentUserSuspended() ? fetchAgeVerificationMethodsSuspendedUser() : fetchAgeVerificationMethods();
return await (r34 == null ? void 0 : r34.then((result) => {
Dispatcher.dispatch({
type: "AGE_VERIFICATION_METHODS_LOAD_SUCCESS",
methods: result.body.methods
});
}).catch(() => {
Dispatcher.dispatch({
type: "AGE_VERIFICATION_METHODS_LOAD_FAILURE"
});
}));
}
export { fetchAgeVerificationMethods };
export { fetchAgeVerificationMethodsSuspendedUser };