How to use the otpauth.Secret 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 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;

otpauth

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

MIT
Latest version published 1 month ago

Package Health Score

80 / 100
Full package analysis