125 lines
3.6 KiB
TypeScript
125 lines
3.6 KiB
TypeScript
// Metro module 14775 (f14776).
|
|
import _slicedToArray from "../../../../_bundle/_slicedToArray";
|
|
import { useState, useCallback } from "react";
|
|
import { TOTP_CODE_LENGTH } from "../../../../_bundle/finishMFACheck";
|
|
import MfaOptionScreen from "./MfaOptionScreen";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import ClipboardCopyInput from "../components/ClipboardCopyInput";
|
|
import MFAButton from "../components/button";
|
|
let env10421 = {};
|
|
const isValidClipboardCode = function isValidClipboardCode(a0) {
|
|
return a0.length === TOTP_CODE_LENGTH && /^\d+$/.test(a0);
|
|
};
|
|
export default function TotpScreen(props) {
|
|
let env21332 = {
|
|
$parent: env10421
|
|
};
|
|
const { mfaChallenge, finish } = props;
|
|
env21332[0] = finish;
|
|
env21332[1] = void 0;
|
|
env21332[2] = void 0;
|
|
env21332[3] = void 0;
|
|
env21332[4] = void 0;
|
|
env21332[5] = void 0;
|
|
env21332[6] = void 0;
|
|
const r25 = _slicedToArray(useState(false), 2);
|
|
let disabled = r25[0];
|
|
env21332[1] = r25[1];
|
|
const r29 = _slicedToArray(useState(""), 2);
|
|
const r12 = r29[0];
|
|
env21332[2] = r12;
|
|
env21332[3] = r29[1];
|
|
const r33 = _slicedToArray(useState(void 0), 2);
|
|
const error = r33[0];
|
|
env21332[4] = r33[1];
|
|
const r37 = _slicedToArray(useState(false), 2);
|
|
const r14 = r37[0];
|
|
env21332[5] = r37[1];
|
|
let c21333_0 = async (data) => {
|
|
let message, c30767_4;
|
|
let c30767_5 = 0;
|
|
let c31731_0;
|
|
L14: {
|
|
try {
|
|
(0, env21332[3])(data);
|
|
if (isValidClipboardCode(data)) {
|
|
(0, env21332[4])(void 0);
|
|
(0, env21332[1])(true);
|
|
c30767_5 = 1;
|
|
await (0, env21332[0])({
|
|
mfaType: "totp",
|
|
data
|
|
});
|
|
(0, env21332[5])(true);
|
|
c30767_5 = 0;
|
|
(0, env21332[1])(false);
|
|
break L14;
|
|
}
|
|
} catch ($e) {
|
|
const r27 = $e;
|
|
let r7 = r27;
|
|
c30767_4 = r27;
|
|
if (c30767_5 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r77 = c30767_4;
|
|
c30767_5 = 0;
|
|
c31731_0 = r77;
|
|
const r80 = env21332[4];
|
|
const r81 = c31731_0;
|
|
message = r81 == null ? void 0 : r81.body?.message;
|
|
if (message == null) {
|
|
message = c31731_0.message;
|
|
}
|
|
r80(message);
|
|
(0, env21332[1])(false);
|
|
break L14;
|
|
} catch (r73) {
|
|
r7 = r73;
|
|
c30767_4 = r73;
|
|
if (c30767_5 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
return void 0;
|
|
}
|
|
};
|
|
const callback = useCallback(function() {
|
|
return c21333_0.apply(this, arguments);
|
|
}, [finish]);
|
|
env21332[6] = callback;
|
|
const props2 = {
|
|
headerText: intl.string(t.uc00u5),
|
|
input: <ClipboardCopyInput label={intl.string(t.HZPBOd)} placeholder={intl.string(t.tARzgo)} isValidClipboardCode={isValidClipboardCode} maxLength={TOTP_CODE_LENGTH} onChangeCode={callback} error={error} isDisabled={disabled ? disabled : r14} textContentType="oneTimeCode" autoComplete="one-time-code" keyboardType="number-pad" />,
|
|
submit: null,
|
|
screenProps: null,
|
|
mfaMethod: "totp"
|
|
};
|
|
const props3 = {
|
|
variant: "primary",
|
|
text: intl.string(t.geKm7t),
|
|
loading: disabled ? disabled : r14,
|
|
onPress: () => {
|
|
(0, env21332[6])(env21332[2]);
|
|
},
|
|
disabled: null
|
|
};
|
|
if (!disabled) {
|
|
disabled = r14;
|
|
}
|
|
if (!disabled) {
|
|
disabled = r12.length !== TOTP_CODE_LENGTH;
|
|
}
|
|
props3.disabled = disabled;
|
|
props2.submit = <MFAButton {...props3} />;
|
|
props2.screenProps = {
|
|
mfaChallenge,
|
|
finish
|
|
};
|
|
return <MfaOptionScreen {...props2} />;
|
|
};
|