From d7b0cc09d4c0cd2e2e7631eb6907ced84712a29c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Thu, 5 Jul 2018 15:32:10 +0200 Subject: [PATCH] Fix false positive in genuine check this happen when server close ws connection too early and/or has not sent a "success" event :o --- src/components/GenuineCheck.js | 4 ++++ static/i18n/en/errors.yml | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/components/GenuineCheck.js b/src/components/GenuineCheck.js index 82b6f0f1..dac98acc 100644 --- a/src/components/GenuineCheck.js +++ b/src/components/GenuineCheck.js @@ -27,6 +27,7 @@ import IconHome from 'icons/Home' import IconCheck from 'icons/Check' const DeviceNotGenuineError = createCustomErrorClass('DeviceNotGenuine') +const DeviceGenuineSocketEarlyClose = createCustomErrorClass('DeviceGenuineSocketEarlyClose') type Props = { t: T, @@ -93,6 +94,9 @@ class GenuineCheck extends PureComponent { logger.log(`genuine check resulted ${res} after ${(Date.now() - beforeDate) / 1000}s`, { deviceInfo, }) + if (!res) { + throw new DeviceGenuineSocketEarlyClose() + } const isGenuine = res === '0000' if (!isGenuine) { throw new DeviceNotGenuineError() diff --git a/static/i18n/en/errors.yml b/static/i18n/en/errors.yml index 221876df..95acaa42 100644 --- a/static/i18n/en/errors.yml +++ b/static/i18n/en/errors.yml @@ -5,6 +5,9 @@ BtcUnmatchedApp: DeviceNotGenuine: title: Possibly not genuine description: 'Request Ledger Support assistance.' +DeviceGenuineSocketEarlyClose: + title: Sorry, try again (genuine-close) + description: DeviceSocketFail: title: Oops, try again description: 'Some connection failed, so please try again.'