do not store mnemonic on recovered accounts

Signed-off-by: yenda <eric@status.im>
This commit is contained in:
yenda 2019-12-17 10:26:25 +01:00
parent 5c7dc2edc7
commit a21454039b
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
13 changed files with 42 additions and 53 deletions

View File

@ -1775,7 +1775,6 @@
constants/path-default-wallet-keyword
{:publicKey wallet-public-key
:address (eip55/address->checksum wallet-address)}}
:mnemonic ""
:address address
:public-key public-key
:keycard-instance-uid instance-uid
@ -1784,8 +1783,7 @@
:keycard-paired-on paired-on
:chat-key whisper-private-key}
encryption-public-key
{:seed-backed-up? true
:login? true})
{})
(if (= flow :import)
(navigation/navigate-to-cofx :keycard-recovery-success nil)
(navigation/navigate-to-cofx :welcome nil))))))

View File

@ -227,7 +227,7 @@
keycard-pairing keycard-paired-on mnemonic public-key]
:as multiaccount}
password
{:keys [seed-backed-up? login?] :or {login? true}}]
{:keys [save-mnemonic? login?] :or {login? true save-mnemonic? false}}]
(let [[wallet-account {:keys [public-key photo-path name]} :as accounts-data] (prepare-accounts-data multiaccount)
multiaccount-data {:name name
:address address
@ -251,9 +251,9 @@
:latest-derived-path 0
:signing-phrase signing-phrase
:installation-id (random-guid-generator)
:mnemonic mnemonic
:settings constants/default-multiaccount-settings}
save-mnemonic?
(assoc :mnemonic mnemonic)
keycard-multiaccount?
(assoc :keycard-instance-uid keycard-instance-uid
:keycard-pairing keycard-pairing
@ -270,9 +270,7 @@
:networks/current-network constants/default-network
:networks/networks constants/default-networks)]
(fx/merge cofx
{:db (cond-> db
seed-backed-up?
(assoc-in [:multiaccount :seed-backed-up?] true))}
{:db db}
(if keycard-multiaccount?
(save-account-and-login-with-keycard new-multiaccount
password
@ -361,7 +359,7 @@
:derived
derived)
password
{:seed-backed-up? false}))
{:save-mnemonic? true}))
(re-frame/reg-fx
::store-multiaccount

View File

@ -49,7 +49,6 @@
(spec/def :multiaccount/sharing-usage-data? (spec/nilable boolean?))
(spec/def :multiaccount/desktop-notifications? (spec/nilable boolean?))
(spec/def :multiaccount/dev-mode? (spec/nilable boolean?))
(spec/def :multiaccount/seed-backed-up? (spec/nilable boolean?))
(spec/def :multiaccount/installation-id :global/not-empty-string)
(spec/def :multiaccount/wallet-set-up-passed? (spec/nilable boolean?))
(spec/def :multiaccount/hide-home-tooltip? (spec/nilable boolean?))
@ -66,7 +65,7 @@
:multiaccount/email :multiaccount/signed-up?
:multiaccount/settings :multiaccount/mailserver
:multiaccount/sharing-usage-data?
:multiaccount/seed-backed-up? :multiaccount/mnemonic :multiaccount/desktop-notifications?
:multiaccount/mnemonic :multiaccount/desktop-notifications?
:multiaccount/chaos-mode?
:multiaccount/wallet-set-up-passed? :multiaccount/last-request
:multiaccount/hide-home-tooltip?

View File

@ -63,7 +63,7 @@
(multiaccounts.create/on-multiaccount-created cofx
multiaccount
password
{:seed-backed-up? true})))))
{})))))
(fx/defn store-multiaccount
{:events [::recover-multiaccount-confirmed]}

View File

@ -67,8 +67,7 @@
"A helper function that removes seed phrase from storage."
[cofx]
(multiaccount-update cofx
{:seed-backed-up? true
:mnemonic nil}
{:mnemonic nil}
{}))
(fx/defn update-settings

View File

@ -1020,8 +1020,8 @@
(re-frame/reg-sub
:get-profile-unread-messages-number
:<- [:multiaccount]
(fn [{:keys [seed-backed-up? mnemonic]}]
(if (or seed-backed-up? (string/blank? mnemonic)) 0 1)))
(fn [{:keys [mnemonic]}]
(if mnemonic 1 0)))
;;WALLET ==============================================================================================================

View File

@ -279,7 +279,7 @@
(i18n/label :t/advanced-settings)]
[vector-icons/icon :main-icons/next {:style {:tint-color colors/gray}}]]])
(views/defview profile [{:keys [seed-backed-up? mnemonic] :as user}]
(views/defview profile [{:keys [mnemonic] :as user}]
(views/letsubs [current-view-id [:view-id]
editing? [:my-profile/editing?]] ;; TODO janherich: refactor my-profile, unnecessary complicated structure in db (could be just `:staged-name`/`:editing?` fields in multiaccount map) and horrible way to access it woth `:get`/`:set` subs/events
(let [adv-settings-open? (= current-view-id :advanced-settings)
@ -288,7 +288,7 @@
installations-open? (= current-view-id :installations)
backup-recovery-phrase-open? (= current-view-id :backup-recovery-phrase)
notifications? (get-in user [:desktop-notifications?])
show-backup-seed? (and (not seed-backed-up?) (not (string/blank? mnemonic)))]
show-backup-seed? (not mnemonic)]
[react/view
[react/view {:style styles/profile-edit}
[react/touchable-highlight {:on-press #(re-frame/dispatch (if editing?

View File

@ -11,22 +11,23 @@
[status-im.multiaccounts.biometric.core :as biometric])
(:require-macros [status-im.utils.views :as views]))
(defn- list-data [show-backup-seed? settings supported-biometric-auth biometric-auth? keycard?]
(defn- list-data [mnemonic settings supported-biometric-auth biometric-auth? keycard?]
[{:type :section-header
:title :t/security
:container-margin-top 6}
{:type :small
:title :t/back-up-seed-phrase
:accessibility-label :back-up-recovery-phrase-button
:disabled? (not show-backup-seed?)
:disabled? (not mnemonic)
;; TODO - remove container bottom margin
;; when items below are implemented
:container-margin-bottom 8
:on-press
#(re-frame/dispatch [:navigate-to :backup-seed])
:accessories
(when show-backup-seed? [[components.common/counter {:size 22} 1]
:chevron])}
(when mnemonic
[[components.common/counter {:size 22} 1]
:chevron])}
{:type :small
:title (str (i18n/label :t/lock-app-with) " " (biometric/get-label supported-biometric-auth))
:container-margin-bottom 8
@ -81,18 +82,16 @@
:theme :action-destructive})])
(views/defview privacy-and-security []
(views/letsubs [{:keys [seed-backed-up? mnemonic]} [:multiaccount]
(views/letsubs [{:keys [mnemonic]} [:multiaccount]
settings [:multiaccount-settings]
supported-biometric-auth [:supported-biometric-auth]
auth-method [:auth-method]
keycard-multiaccount? [:keycard-multiaccount?]]
(let [show-backup-seed? (and (not seed-backed-up?)
(not (string/blank? mnemonic)))]
[react/view {:flex 1 :background-color colors/white}
[toolbar/simple-toolbar
(i18n/label :t/privacy-and-security)]
[list/flat-list
{:data (list-data show-backup-seed? settings supported-biometric-auth
(= auth-method "biometric") keycard-multiaccount?)
:key-fn (fn [_ i] (str i))
:render-fn list/flat-list-generic-render-fn}]])))
[react/view {:flex 1 :background-color colors/white}
[toolbar/simple-toolbar
(i18n/label :t/privacy-and-security)]
[list/flat-list
{:data (list-data mnemonic settings supported-biometric-auth
(= auth-method "biometric") keycard-multiaccount?)
:key-fn (fn [_ i] (str i))
:render-fn list/flat-list-generic-render-fn}]]))

View File

@ -109,7 +109,7 @@
(defn- flat-list-content
[preferred-name registrar tribute-to-talk
active-contacts-count show-backup-seed?
active-contacts-count mnemonic
keycard-account? notifications-enabled?]
[(cond-> {:title (or (when registrar preferred-name)
:t/ens-usernames)
@ -147,7 +147,7 @@
:title :t/privacy-and-security
:accessibility-label :privacy-and-security-settings-button
:accessories
[(when show-backup-seed?
[(when mnemonic
[components.common/counter {:size 22} 1]) :chevron]
:on-press #(re-frame/dispatch [:navigate-to :privacy-and-security])}
(when (and platform/android?
@ -216,23 +216,20 @@
(defn content-with-header [list-ref scroll-y]
(let [{:keys [public-key
preferred-name
seed-backed-up?
mnemonic
keycard-pairing
address
notifications-enabled?]
:as multiaccount} @(re-frame/subscribe [:multiaccount])
active-contacts-count @(re-frame/subscribe [:contacts/active-count])
tribute-to-talk @(re-frame/subscribe [:tribute-to-talk/profile])
registrar @(re-frame/subscribe [:ens.stateofus/registrar])
photo-added? @(re-frame/subscribe [:profile/photo-added?])
show-backup-seed? (and (not seed-backed-up?)
(not (string/blank? mnemonic)))]
:as multiaccount} @(re-frame/subscribe [:multiaccount])
active-contacts-count @(re-frame/subscribe [:contacts/active-count])
tribute-to-talk @(re-frame/subscribe [:tribute-to-talk/profile])
registrar @(re-frame/subscribe [:ens.stateofus/registrar])
photo-added? @(re-frame/subscribe [:profile/photo-added?])]
[large-toolbar/flat-list-with-header-handler
(header multiaccount photo-added?)
(flat-list-content
preferred-name registrar tribute-to-talk
active-contacts-count show-backup-seed?
active-contacts-count mnemonic
keycard-pairing notifications-enabled?)
list-ref
scroll-y]))

View File

@ -7,7 +7,7 @@
(re-frame/dispatch [:bottom-sheet/hide-sheet])
(re-frame/dispatch event))
(defn accounts-options [seed-backed-up?]
(defn accounts-options [mnemonic]
(fn []
[react/view
[list-item/list-item
@ -27,7 +27,7 @@
:title :t/view-signing
:icon :main-icons/info
:on-press #(hide-sheet-and-dispatch [:show-popover {:view :signing-phrase}])}]
(when-not seed-backed-up?
(when mnemonic
[list-item/list-item
{:theme :action-destructive
:title :t/wallet-backup-recovery-title

View File

@ -113,11 +113,11 @@
50)}])))
(views/defview accounts-options []
(views/letsubs [{:keys [seed-backed-up?]} [:multiaccount]
(views/letsubs [{:keys [mnemonic]} [:multiaccount]
empty-balances? [:empty-balances?]]
[react/view {:flex-direction :row :align-items :center}
[react/view {:flex 1 :padding-left 16}
(when (and (not seed-backed-up?)
(when (and mnemonic
(not empty-balances?))
[react/touchable-highlight
{:on-press #(re-frame/dispatch [:navigate-to :backup-seed])}
@ -139,8 +139,8 @@
[icons/icon :main-icons/qr {:accessibility-label :accounts-qr-code}]]]
[react/touchable-highlight
{:on-press #(re-frame/dispatch [:bottom-sheet/show-sheet
{:content (sheets/accounts-options seed-backed-up?)
:content-height (if seed-backed-up? 190 250)}])}
{:content (sheets/accounts-options mnemonic)
:content-height (if mnemonic 250 190)}])}
[react/view {:height toolbar.styles/toolbar-height
:width toolbar.styles/toolbar-height :align-items :center
:justify-content :center}

View File

@ -17,4 +17,4 @@
(let [efx (multiaccounts.update/clean-seed-phrase {:db {:multiaccount {:mnemonic "lalalala"}}})
json-rpc (into #{} (map :method (::json-rpc/call efx)))]
(is (json-rpc "settings_saveConfig"))
(is (= (get-in efx [:db :multiaccount]) {:seed-backed-up? true, :mnemonic nil}))))
(is (= (get-in efx [:db :multiaccount]) {:mnemonic nil}))))

View File

@ -140,7 +140,6 @@
:URL "https://poa.infura.io"}}
:rpc-url nil}}
:photo-path "data:image/png;base64iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAADAFBMVEX////YsYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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