diff --git a/lib/challenge-commands/totp.js b/lib/challenge-commands/totp.js index d9a2a54ad..f86797569 100644 --- a/lib/challenge-commands/totp.js +++ b/lib/challenge-commands/totp.js @@ -78,6 +78,7 @@ var createJWT = function (Env, sessionId, publicKey, cb) { const TOTP_SETUP = Commands.TOTP_SETUP = function (Env, body, cb) { const { publicKey, secret, code, contact } = body; + // the client MUST provide an OTP code of the expected format // this doesn't check if it matches the secret and time, just that it's well-formed if (!isValidOTP(code)) { return void cb("E_INVALID"); } @@ -307,7 +308,7 @@ So, we should: createJWT(Env, sessionId, publicKey, w(function (err, _token) { if (err) { Env.Log.error("TOTP_VALIDATE_JWT_SIGN_ERROR", { - error: err, + error: Util.serializeError(err), publicKey: publicKey, }); return void cb("TOKEN_ERROR"); @@ -319,7 +320,7 @@ So, we should: Sessions.write(Env, publicKey, sessionId, token, w(function (err) { if (err) { Env.Log.error("TOTP_VALIDATE_SESSION_WRITE", { - error: err, + error: Util.serializeError(err), publicKey: publicKey, sessionId: sessionId, }); diff --git a/lib/http-commands.js b/lib/http-commands.js index c31ae2429..82508b2dd 100644 --- a/lib/http-commands.js +++ b/lib/http-commands.js @@ -94,7 +94,7 @@ var handleCommand = function (Env, req, res) { if (err) { Env.Log.error('CHALLENGE_COMMAND_EXECUTION_ERROR', { body: body, - error: err, + error: Util.serializeError(err), }); // errors returned from commands are passed back to the client // as a weak precaution, we try to only send an error's message @@ -119,7 +119,7 @@ var handleCommand = function (Env, req, res) { // this makes it so we can avoid holding state in memory Challenge.write(Env, txid, JSON.stringify(copy), function (err) { if (err) { - Env.Log.error('CHALLENGE_WRITE_ERROR', err); + Env.Log.error('CHALLENGE_WRITE_ERROR', Util.serializeError(err)); return void res.status(500).json({ // arbitrary error message, only intended for debugging error: 'Internal server error 6250', @@ -134,7 +134,7 @@ var handleCommand = function (Env, req, res) { }); } catch (err) { Env.Log.error("CHALLENGE_COMMAND_THROWN_ERROR", { - error: err, + error: Util.serializeError(err), }); return void res.status(500).json({ // arbitrary error message, only intended for debugging @@ -186,7 +186,7 @@ var handleResponse = function (Env, req, res) { if (err) { Env.Log.error("CHALLENGE_READ_ERROR", { txid: txid, - error: err, + error: Util.serializeError(err), }); return void res.status(500).json({ error: "Unexpected response", @@ -198,7 +198,7 @@ var handleResponse = function (Env, req, res) { if (err) { Env.Log.error("CHALLENGE_DELETION_ERROR", { txid: txid, - error: err, + error: Util.serializeError(err), }); } }); @@ -251,7 +251,7 @@ var handleResponse = function (Env, req, res) { text: text, sig: sig, publicKey: publicKey, - error: err3, + error: Util.serializeError(err3), }); return res.status(500).json({ error: "decoding error" @@ -273,7 +273,7 @@ var handleResponse = function (Env, req, res) { action(Env, json, function (err, content) { if (err) { Env.Log.error("CHALLENGE_RESPONSE_ACTION_ERROR", { - error: err, + error: Util.serializeError(err), }); return res.status(500).json({ error: 'Execution error',