From 32b87f2486df02d506d83e0a341810fd536558c6 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 28 Jun 2018 02:36:54 -0600 Subject: [PATCH] refactor otp assignment slightly --- bin/telebit.js | 26 +++++++++++++++----------- bin/telebitd.js | 2 +- lib/cli-common.js | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/bin/telebit.js b/bin/telebit.js index 02e01cb..730148f 100755 --- a/bin/telebit.js +++ b/bin/telebit.js @@ -534,6 +534,21 @@ function parseConfig(err, text) { throw err; } + // TODO make one request to set and then poll for readiness + if (!answers.token && answers._can_pair) { + console.log(""); + console.log("=============================================="); + console.log(" Hey, Listen! "); + console.log("=============================================="); + console.log(" "); + console.log(" GO CHECK YOUR EMAIL! "); + console.log(" "); + console.log(" DEVICE PAIR CODE: 0000 ".replace(/0000/g, answers._otp)); + console.log(" "); + console.log("=============================================="); + console.log(""); + } + // TODO use php-style object querification utils.putConfig('config', Object.keys(answers).map(function (key) { return key + ':' + answers[key]; @@ -618,17 +633,6 @@ var parsers = { if (!answers.token && answers._can_pair) { answers._otp = common.otp(); - console.log(""); - console.log("=============================================="); - console.log(" Hey, Listen! "); - console.log("=============================================="); - console.log(" "); - console.log(" GO CHECK YOUR EMAIL! "); - console.log(" "); - console.log(" DEVICE PAIR CODE: 0000 ".replace(/0000/g, answers._otp)); - console.log(" "); - console.log("=============================================="); - console.log(""); } cb(null, answers); diff --git a/bin/telebitd.js b/bin/telebitd.js index 88381e9..728420c 100755 --- a/bin/telebitd.js +++ b/bin/telebitd.js @@ -166,7 +166,7 @@ function serveControlsHelper() { if ('undefined' !== typeof conf.agree_tos) { state.config.agreeTos = conf.agree_tos; } - state.otp = conf._otp || common.otp(); + state.otp = conf._otp || '0000'; // this should only be done on the client side state.config.relay = conf.relay || state.config.relay || ''; state.config.token = conf.token || state.config.token || null; state.config.secret = conf.secret || state.config.secret || null; diff --git a/lib/cli-common.js b/lib/cli-common.js index 84f22b5..5420838 100644 --- a/lib/cli-common.js +++ b/lib/cli-common.js @@ -105,7 +105,7 @@ common.api.token = function (state, handlers) { // TODO sign token with own private key, including public key and thumbprint // (much like ACME JOSE account) - var otp = state.otp || state._otp || common.otp(); + var otp = state.otp || state._otp || '0000'; // common.otp(); var authReq = state.authRequest || state._auth || { subject: state.config.email , subject_scheme: 'mailto'