How to use the otpauth.Secret.fromB32 function in otpauth

To help you get started, we’ve selected a few otpauth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vladimiry / ElectronMail / src / electron-preload / webview / index.ts View on Github external
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);
            }
        }
    })()),

otpauth

One Time Password (HOTP/TOTP) library for Node.js, Deno, Bun and browsers

MIT
Latest version published 7 days ago

Package Health Score

80 / 100
Full package analysis