180 lines
6.3 KiB
TypeScript
180 lines
6.3 KiB
TypeScript
// Metro module 7616 (f7617).
|
|
import { useState, useCallback, useRef, useEffect } from "react";
|
|
import { ActivityIndicator } from "react-native";
|
|
import { jsxs } from "react/jsx-runtime";
|
|
import { useNavigation } from "../../../design/components/Navigator/native/useNavigation.native";
|
|
import { useWatchAgeVerificationStatusChange } from "../AgeVerificationUtils";
|
|
import { requestGoogleWalletVerification, getGoogleWalletCredential, verifyGoogleWalletCredential } from "../GoogleWalletActionCreators.native";
|
|
import MonitoringAgent from "../../monitoring/MonitoringAgent";
|
|
import { MetricEvents } from "../../../_bundle/Module5872";
|
|
import { intl } from "../../../intl/index.native";
|
|
import AgeAssurance_messages from "../AgeAssurance.messages";
|
|
import { ModalScreen } from "../../../design/components/Modal/native/ModalScreen.native";
|
|
import { ModalContent } from "../../../design/components/Modal/native/ModalContent.native";
|
|
import { Stack } from "../../../design/components/Stack/native/Stack.native";
|
|
import { Text } from "../../../design/components/Text/native/Text";
|
|
import { ButtonGroup } from "../../../design/components/ButtonGroup/native/ButtonGroup.native";
|
|
import { Button } from "../../../design/components/Button/native/Button.native";
|
|
import { trackAgeVerificationModalClicked, AgeVerificationModalVersion, AgeVerificationModalCta } from "../AgeVerificationAnalyticsUtils";
|
|
function $mk115044($env) {
|
|
return function getFailureReason(a0) {
|
|
const status = a0?.status;
|
|
let r3 = "rate_limited";
|
|
if (status !== 429) {
|
|
const r10 = a0?.code != null;
|
|
let r11 = "unknown";
|
|
if (r10) {
|
|
const code = a0.code;
|
|
r11 = code in c4778_9 ? c4778_9[a0.code] : "unknown";
|
|
}
|
|
r3 = r11;
|
|
}
|
|
return r3;
|
|
};
|
|
}
|
|
let env4778 = {};
|
|
const c4778_9 = {
|
|
NOT_AVAILABLE: "not_available",
|
|
FAILED: "credential_error"
|
|
};
|
|
export default function GoogleWalletVerificationScreen(props) {
|
|
let callback2, ref;
|
|
const { onClose, modalSessionId } = props;
|
|
callback2 = void 0;
|
|
ref = void 0;
|
|
const navigation = useNavigation();
|
|
const [state, setState] = useState({
|
|
type: "loading"
|
|
});
|
|
useWatchAgeVerificationStatusChange(onClose);
|
|
const callback = useCallback(() => {
|
|
navigation.goBack();
|
|
}, [navigation]);
|
|
callback2 = useCallback(async () => {
|
|
let c26006_0, c26006_1, c26006_2;
|
|
let c26006_3 = 0;
|
|
const r17 = void 0;
|
|
const r16 = env4778;
|
|
L14: {
|
|
try {
|
|
let env29842;
|
|
c26006_1 = r17;
|
|
const r39 = env29842 = {
|
|
$parent: r16
|
|
};
|
|
c26006_0 = r39;
|
|
env29842[0] = void 0;
|
|
env29842[1] = void 0;
|
|
env29842[2] = void 0;
|
|
env29842[3] = void 0;
|
|
c26006_3 = 1;
|
|
env29842[0] = (await requestGoogleWalletVerification()).request_json;
|
|
env29842[1] = await getGoogleWalletCredential(env29842[0]);
|
|
await verifyGoogleWalletCredential(env29842[1]);
|
|
c26006_3 = 0;
|
|
} catch ($e) {
|
|
const r37 = $e;
|
|
let r7 = r37;
|
|
c26006_2 = r37;
|
|
if (c26006_3 !== 0) {
|
|
while (true) {
|
|
L32: {
|
|
try {
|
|
const r138 = c26006_2;
|
|
c26006_3 = 0;
|
|
env29842[2] = r138;
|
|
if (env29842[2]?.code === "CANCELLED") {
|
|
MonitoringAgent.increment({
|
|
name: MetricEvents.GOOGLE_WALLET_VERIFICATION_FAILED,
|
|
tags: ["reason:user_cancelled"]
|
|
});
|
|
(0, callback)();
|
|
break L32;
|
|
}
|
|
const r160 = env29842[2];
|
|
if ((r160 == null ? void 0 : r160.body?.reason) !== "unsupported_issuing_country") {
|
|
const r198 = env29842[2];
|
|
env29842[3] = $mk115044(env4778)(r198);
|
|
MonitoringAgent.increment({
|
|
name: MetricEvents.GOOGLE_WALLET_VERIFICATION_FAILED,
|
|
tags: [`reason:${env29842[3]}`]
|
|
});
|
|
(0, setState)({
|
|
type: "error",
|
|
message: intl.string(AgeAssurance_messages["+pwfOA"])
|
|
});
|
|
break L14;
|
|
}
|
|
MonitoringAgent.increment({
|
|
name: MetricEvents.GOOGLE_WALLET_VERIFICATION_FAILED,
|
|
tags: ["reason:unsupported_issuing_country"]
|
|
});
|
|
(0, setState)({
|
|
type: "error",
|
|
message: intl.string(AgeAssurance_messages.Pf5xUq)
|
|
});
|
|
} catch (r135) {
|
|
r7 = r135;
|
|
c26006_2 = r135;
|
|
if (c26006_3 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return void 0;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
}, [callback]);
|
|
ref = useRef(false);
|
|
useEffect(() => {
|
|
let c26007_1;
|
|
let c26007_0 = navigation.addListener("transitionEnd", (a0) => {
|
|
if (!(ref.current || a0.data.closing === true)) {
|
|
ref.current = true;
|
|
callback2();
|
|
}
|
|
});
|
|
c26007_1 = setTimeout(() => {
|
|
if (!ref.current) {
|
|
ref.current = true;
|
|
callback2();
|
|
}
|
|
}, 1000);
|
|
return () => {
|
|
c26007_0();
|
|
clearTimeout(c26007_1);
|
|
};
|
|
}, [navigation, callback2]);
|
|
return state.type === "loading" ? <ModalScreen>
|
|
<ModalContent>
|
|
{(0, jsxs)(Stack, {
|
|
align: "center",
|
|
justify: "center",
|
|
spacing: 16,
|
|
children: [<ActivityIndicator size="large" />, <Text variant="text-md/medium" color="text-strong">
|
|
{intl.string(AgeAssurance_messages.MlFuBI)}
|
|
</Text>]
|
|
})}
|
|
</ModalContent>
|
|
</ModalScreen> : <ModalScreen>
|
|
<ModalContent>
|
|
{(0, jsxs)(Stack, {
|
|
align: "center",
|
|
justify: "center",
|
|
spacing: 16,
|
|
children: [<Text variant="text-md/medium" color="text-strong">{state.message}</Text>, <ButtonGroup>
|
|
<Button variant="primary" size="lg" text={intl.string(AgeAssurance_messages.fEUKEv)} onPress={() => {
|
|
trackAgeVerificationModalClicked(modalSessionId, AgeVerificationModalVersion.EXPRESSIVE_PRIMARY, AgeVerificationModalCta.METHOD_SELECT);
|
|
callback();
|
|
}} />
|
|
</ButtonGroup>]
|
|
})}
|
|
</ModalContent>
|
|
</ModalScreen>;
|
|
};
|