Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function submit() {
const url = getUrl();
const elements = await waitElements({
twoFactorCode: () => document.getElementById("twoFactorCode") as HTMLInputElement,
submit: () => document.getElementById("login_btn_2fa") as HTMLElement,
});
const $ = (window as any).$;
const $formController: any = $(elements.twoFactorCode().form).data("$formController");
const totp = new TOTP({
digits: 6,
period: 30,
secret: Secret.fromB32(password),
});
const token = totp.generate();
$formController.twoFactorCode.$setViewValue(token);
$formController.twoFactorCode.$render();
elements.submit().click();
await new Promise((resolve) => setTimeout(resolve, submitTimeOutMs));
if (getUrl() === url) {
throw new Error(errorMessage);
}
}
})()),