From 087fdd27f3683a1deb9376b7a72aa608e6fd8e6a Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 12 Sep 2019 15:25:47 -0700 Subject: remove babel and eslint --- authy.js | 78 ++++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 44 insertions(+), 34 deletions(-) (limited to 'authy.js') diff --git a/authy.js b/authy.js index 336cc2c5..bfca8672 100644 --- a/authy.js +++ b/authy.js @@ -1,44 +1,54 @@ -import { Client } from 'authy-client' -import config from './config' +const { Client } = require("authy-client"); +const config = require("./config"); -const authy = new Client({ key: config.authy.key }) +const authy = new Client({ key: config.authy.key }); -export default async user => { - let { authyId } = user +module.exports = async user => { + let { authyId } = user; - const res = await authy.createApprovalRequest({ - authyId: user.authyId, - details: { - visible: { - User: user.name, - } + const res = await authy.createApprovalRequest( + { + authyId: user.authyId, + details: { + visible: { + User: user.name + } + }, + logos: [ + { + res: "default", + url: "https://coinos.io/static/img/coinos.png" + } + ], + message: "Login to CoinOS" }, - logos: [{ - res: 'default', - url: 'https://coinos.io/static/img/coinos.png' - }], - message: 'Login to CoinOS', - }, { - ttl: 120 - }); + { + ttl: 120 + } + ); - let counter = 0 + let counter = 0; return new Promise((resolve, reject) => { let poll = setInterval(async () => { - counter++ - const r = await authy.getApprovalRequest({ id: res.approval_request.uuid }); - if (r.approval_request.status === 'approved') { - clearInterval(poll) - resolve(true) - } + counter++; + const r = await authy.getApprovalRequest({ + id: res.approval_request.uuid + }); + if (r.approval_request.status === "approved") { + clearInterval(poll); + resolve(true); + } - if (r.approval_request.status === 'denied') { - clearInterval(poll) - resolve(false) - } + if (r.approval_request.status === "denied") { + clearInterval(poll); + resolve(false); + } - if (counter > 60) { clearInterval(poll); reject(false) } - }, 1000) - }) -} + if (counter > 60) { + clearInterval(poll); + reject(false); + } + }, 1000); + }); +}; -- cgit v1.2.3