From b964af4da23868dfa7607784342c6950d60481e1 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 2 Sep 2021 14:20:00 +0200 Subject: [PATCH] Add try..catch in forms main.js --- www/form/main.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/www/form/main.js b/www/form/main.js index 8c794a19a..1a558678c 100644 --- a/www/form/main.js +++ b/www/form/main.js @@ -268,16 +268,20 @@ define([ var messages = obj.messages; if (!messages.length) { return void cb(); } if (obj.lastKnownHash !== answer.hash) { return void cb(); } - var res = Utils.Crypto.Mailbox.openOwnSecretLetter(messages[0].msg, { - validateKey: data.validateKey, - ephemeral_private: Nacl.util.decodeBase64(answer.curvePrivate), - my_private: Nacl.util.decodeBase64(myKeys.curvePrivate), - their_public: Nacl.util.decodeBase64(data.publicKey) - }); - var parsed = JSON.parse(res.content); - parsed._isAnon = answer.anonymous; - parsed._time = messages[0].time; - cb(parsed); + try { + var res = Utils.Crypto.Mailbox.openOwnSecretLetter(messages[0].msg, { + validateKey: data.validateKey, + ephemeral_private: Nacl.util.decodeBase64(answer.curvePrivate), + my_private: Nacl.util.decodeBase64(myKeys.curvePrivate), + their_public: Nacl.util.decodeBase64(data.publicKey) + }); + var parsed = JSON.parse(res.content); + parsed._isAnon = answer.anonymous; + parsed._time = messages[0].time; + cb(parsed); + } catch (e) { + cb({error: e}); + } }); });