diff --git a/export/index.html b/export/index.html index 005f41d..1846ca6 100644 --- a/export/index.html +++ b/export/index.html @@ -340,18 +340,30 @@

Message log

// TODO: find a way to filter messages and ensure they're coming from the parent window? // We do not want to arbitrarily receive messages from all origins. - window.addEventListener("message", event => { + window.addEventListener("message", async function(event) { if (event.data && event.data["type"] == "INJECT_KEY_EXPORT_BUNDLE") { TKHQ.logMessage(`⬇️ Received message ${event.data["type"]}: ${event.data["value"]}`); - onInjectKeyBundle(event.data["value"]) + try { + await onInjectKeyBundle(event.data["value"]) + } catch (e) { + TKHQ.sendMessageUp("ERROR", e.toString()); + } } if (event.data && event.data["type"] == "INJECT_WALLET_EXPORT_BUNDLE") { TKHQ.logMessage(`⬇️ Received message ${event.data["type"]}: ${event.data["value"]}`); - onInjectWalletBundle(event.data["value"]) + try { + await onInjectWalletBundle(event.data["value"]) + } catch (e) { + TKHQ.sendMessageUp("ERROR", e.toString()); + } } if (event.data && event.data["type"] == "RESET_EMBEDDED_KEY") { TKHQ.logMessage(`⬇️ Received message ${event.data["type"]}`); - TKHQ.onResetEmbeddedKey(); + try { + TKHQ.onResetEmbeddedKey(); + } catch (e) { + TKHQ.sendMessageUp("ERROR", e.toString()); + } } }, false); @@ -522,7 +534,7 @@

Message log

} /** - * Function triggered when INJECT_KEY_EXPORT_BUNDLE event is received. + * Function triggered when INJECT_WALLET_EXPORT_BUNDLE event is received. * @param {string} bundle */ const onInjectWalletBundle = async bundle => { diff --git a/recovery/index.html b/recovery/index.html index caf260b..46e82b9 100644 --- a/recovery/index.html +++ b/recovery/index.html @@ -795,18 +795,30 @@

Message log

// TODO: find a way to filter messages and ensure they're coming from the parent window? // We do not want to arbitrarily receive messages from all origins. - window.addEventListener("message", function(event) { + window.addEventListener("message", async function(event) { if (event.data && event.data["type"] == "INJECT_RECOVERY_BUNDLE") { TKHQ.logMessage(`⬇️ Received message ${event.data["type"]}: ${event.data["value"]}`); - onInjectBundle(event.data["value"]) + try { + await onInjectBundle(event.data["value"]) + } catch (e) { + TKHQ.sendMessageUp("ERROR", e.toString()); + } } if (event.data && event.data["type"] == "STAMP_REQUEST") { TKHQ.logMessage(`⬇️ Received message ${event.data["type"]}: ${event.data["value"]}`); - onStampRequest(event.data["value"]); + try { + await onStampRequest(event.data["value"]); + } catch (e) { + TKHQ.sendMessageUp("ERROR", e.toString()); + } } if (event.data && event.data["type"] == "RESET_EMBEDDED_KEY") { TKHQ.logMessage(`⬇️ Received message ${event.data["type"]}`); - TKHQ.onResetEmbeddedKey(); + try { + TKHQ.onResetEmbeddedKey(); + } catch (e) { + TKHQ.sendMessageUp("ERROR", e.toString()); + } } }, false);