How to use otpauth - 6 common examples

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 bitshares / beet-js / src / lib / BeetConnection.js View on Github external
auth.then(res => {
                    console.groupCollapsed("authenticate"); // groupCollapsed
                    console.log(event);
                    this.authenticated = res.authenticate;
                    this.linked = res.link;
                    if (this.linked) {
                        this.otp = new OTPAuth.HOTP({
                            issuer: "Beet",
                            label: "BeetAuth",
                            algorithm: "SHA1",
                            digits: 32,
                            counter: 0,
                            secret: OTPAuth.Secret.fromHex(this.identity.secret)
                        });
                        console.debug("otp instantiated", this.identity.secret.toString());
                        this.identity = Object.assign(this.identity, res.requested);
                    } else {
                        this.beetkey = res.pub_key;
                    }
                    console.groupEnd();
                    resolve(res);
                }).catch(rej => {
                    console.error("socket.onopen authenticate rejected", rej);
github bitshares / beet-js / src / lib / BeetConnection.js View on Github external
console.log(res);
                this.chain = res.chain;
                if (res.existing) {
                    this.identityhash = res.identityhash;
                    try {
                        this.identity = await BeetClientDB.apps.where("identityhash").equals(this.identityhash).first();
                        console.debug("app fetched", this.identity);
                        this.authenticated = res.authenticate;
                        this.linked = res.link;
                        this.otp = new OTPAuth.HOTP({
                            issuer: "Beet",
                            label: "BeetAuth",
                            algorithm: "SHA1",
                            digits: 32,
                            counter: 0,
                            secret: OTPAuth.Secret.fromHex(this.identity.secret)
                        });
                        this.identity = Object.assign(this.identity, res.requested);
                        console.groupEnd();
                        resolve(this.identityhash);
                    } catch (e) {
                        console.warn("Beet has found an established identity, but the client does not know it, requesting relink ...");
                        console.groupEnd();
                        try {
                            let relink = await this.link(chain, requestDetails, res.identityhash);
                            resolve(relink);
                        }catch(e){
                            reject(e);
                        }
                    }
                } else {
                    this.identityhash = res.identityhash;
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);
            }
        }
    })()),
github bitshares / beet-js / src / lib / BeetConnection.js View on Github external
}
                } else {
                    this.identityhash = res.identityhash;
                    this.appstore = await BeetClientDB.apps.add({
                        apphash: this.apphash,
                        identityhash: this.identityhash,
                        chain: this.chain,
                        appName: this.appName,
                        secret: this.secret.toString('hex'),
                        next_id: next_id
                    });
                    this.authenticated = res.authenticate;
                    this.linked = res.link;
                    this.identity = await BeetClientDB.apps.where("identityhash").equals(this.identityhash).first();
                    console.debug("app fetched", this.identity);
                    this.otp = new OTPAuth.HOTP({
                        issuer: "Beet",
                        label: "BeetAuth",
                        algorithm: "SHA1",
                        digits: 32,
                        counter: 0,
                        secret: OTPAuth.Secret.fromHex(this.identity.secret)
                    });
                    this.identity = Object.assign(this.identity, res.requested);
                    console.groupEnd();
                    resolve(this.identityhash);
                }
            }).catch(rej => {
                console.debug("link rejected", rej);
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);
            }
github buttercup / buttercup-mobile / source / library / otp.js View on Github external
export function otpInstanceFromURL(url) {
    return OTPAuth.URI.parse(url);
}

otpauth

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

MIT
Latest version published 8 days ago

Package Health Score

80 / 100
Full package analysis