Replace address with keyUid in accounts db
Account's address was used as a primary key in accounts db and as a deterministic id of an account in some API calls. Also it was used as a part of the name of the account specific database. This revealed some extra information about the account and wasn't necessary. At first the hash of the address was planned to be used as a deterministic id, but we already have a keyUid which is calculated as sha256 hash of account's public key and has similar properties: - it is deterministic - doesn't reveal accounts public key or address in plain
This commit is contained in:
parent
c0762e7594
commit
91b931c3b4
|
@ -154,13 +154,13 @@
|
|||
;; multiaccounts login module
|
||||
(handlers/register-handler-fx
|
||||
:multiaccounts.login.ui/multiaccount-selected
|
||||
(fn [{:keys [db] :as cofx} [_ address]]
|
||||
(fn [{:keys [db] :as cofx} [_ key-uid]]
|
||||
(let [{:keys [photo-path name public-key]}
|
||||
(get-in db [:multiaccounts/multiaccounts address])]
|
||||
(get-in db [:multiaccounts/multiaccounts key-uid])]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (dissoc db :intro-wizard)}
|
||||
(multiaccounts.login/open-login address photo-path name public-key)))))
|
||||
(multiaccounts.login/open-login key-uid photo-path name public-key)))))
|
||||
|
||||
;; multiaccounts logout module
|
||||
|
||||
|
|
|
@ -486,15 +486,6 @@
|
|||
(proceed-with-generating-key)))
|
||||
(load-pair-screen cofx)))))
|
||||
|
||||
(fx/defn show-existing-multiaccount-alert
|
||||
[{:keys [db] :as cofx}]
|
||||
(fx/merge cofx
|
||||
{:utils/show-confirmation {:title nil
|
||||
:content (i18n/label :t/keycard-existing-multiaccount)
|
||||
:cancel-button-text ""
|
||||
:confirm-button-text :t/okay}}
|
||||
(navigation/navigate-back)))
|
||||
|
||||
(fx/defn check-card-state
|
||||
{:events [:hardwallet/check-card-state]}
|
||||
[{:keys [db] :as cofx}]
|
||||
|
@ -523,12 +514,11 @@
|
|||
(load-pin-screen)))))
|
||||
(when (and (= card-state :multiaccount)
|
||||
(= flow :import))
|
||||
(let [{:keys [address]} (find-multiaccount-by-key-uid db key-uid)]
|
||||
(if address
|
||||
(recover/show-existing-multiaccount-alert address)
|
||||
(if pairing
|
||||
(load-recovery-pin-screen)
|
||||
(load-pair-screen)))))
|
||||
(if (find-multiaccount-by-key-uid db key-uid)
|
||||
(recover/show-existing-multiaccount-alert key-uid)
|
||||
(if pairing
|
||||
(load-recovery-pin-screen)
|
||||
(load-pair-screen))))
|
||||
(when (= card-state :blank)
|
||||
(if (= flow :import)
|
||||
(navigation/navigate-to-cofx :keycard-recovery-no-key nil)
|
||||
|
@ -631,13 +621,12 @@
|
|||
|
||||
(fx/defn get-keys-from-keycard
|
||||
[{:keys [db]}]
|
||||
(let [multiaccount-address (get-in db [:multiaccounts/login :address])
|
||||
pairing (get-in db [:multiaccounts/multiaccounts multiaccount-address :keycard-pairing])
|
||||
(let [key-uid (get-in db [:multiaccounts/login :key-uid])
|
||||
pairing (get-in db [:multiaccounts/multiaccounts key-uid :keycard-pairing])
|
||||
pin (string/join (get-in db [:hardwallet :pin :login]))]
|
||||
(when (and pairing
|
||||
(seq pin))
|
||||
{:db (-> db
|
||||
(assoc-in [:hardwallet :pin :status] :verifying))
|
||||
{:db (assoc-in db [:hardwallet :pin :status] :verifying)
|
||||
:hardwallet/get-keys {:pairing pairing
|
||||
:pin pin}})))
|
||||
|
||||
|
@ -646,7 +635,7 @@
|
|||
[{:keys [db] :as cofx}]
|
||||
(let [application-info (get-in db [:hardwallet :application-info])
|
||||
key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||
multiaccount (get-in db [:multiaccounts/multiaccounts (get-in db [:multiaccounts/login :address])])
|
||||
multiaccount (get-in db [:multiaccounts/multiaccounts (get-in db [:multiaccounts/login :key-uid])])
|
||||
multiaccount-key-uid (get multiaccount :key-uid)
|
||||
multiaccount-mismatch? (or (nil? multiaccount)
|
||||
(not= multiaccount-key-uid key-uid))
|
||||
|
@ -947,12 +936,12 @@
|
|||
|
||||
(fx/defn on-remove-key-success
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [multiaccount-address (get-in db [:multiaccount :address])
|
||||
(let [key-uid (get-in db [:multiaccount :key-uid])
|
||||
instance-uid (get-in db [:hardwallet :application-info :instance-uid])
|
||||
pairings (get-in db [:hardwallet :pairings])]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(update :multiaccounts/multiaccounts dissoc multiaccount-address)
|
||||
(update :multiaccounts/multiaccounts dissoc key-uid)
|
||||
(assoc-in [:hardwallet :secrets] nil)
|
||||
(update-in [:hardwallet :pairings] dissoc (keyword instance-uid))
|
||||
(assoc-in [:hardwallet :whisper-public-key] nil)
|
||||
|
@ -984,10 +973,10 @@
|
|||
|
||||
(fx/defn on-delete-success
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [multiaccount-address (get-in db [:multiaccount :address])]
|
||||
(let [key-uid (get-in db [:multiaccount :key-uid])]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(update :multiaccounts/multiaccounts dissoc multiaccount-address)
|
||||
(update :multiaccounts/multiaccounts dissoc key-uid)
|
||||
(assoc-in [:hardwallet :secrets] nil)
|
||||
(assoc-in [:hardwallet :application-info] nil)
|
||||
(assoc-in [:hardwallet :pin] {:status nil
|
||||
|
@ -1817,11 +1806,12 @@
|
|||
|
||||
(fx/defn on-get-keys-success
|
||||
[{:keys [db] :as cofx} data]
|
||||
(let [{:keys [address encryption-public-key whisper-private-key] :as account-data} (js->clj data :keywordize-keys true)
|
||||
address (ethereum/normalized-hex address)
|
||||
{:keys [photo-path name]} (get-in db [:multiaccounts/multiaccounts address])
|
||||
(let [{:keys [key-uid encryption-public-key whisper-private-key] :as account-data} (js->clj data :keywordize-keys true)
|
||||
{:keys [photo-path name]} (get-in db [:multiaccounts/multiaccounts key-uid])
|
||||
key-uid (get-in db [:hardwallet :application-info :key-uid])
|
||||
multiaccount-data (types/clj->json {:name name :address address :photo-path photo-path})
|
||||
multiaccount-data (types/clj->json {:name name
|
||||
:key-uid key-uid
|
||||
:photo-path photo-path})
|
||||
save-keys? (get-in db [:multiaccounts/login :save-password?])]
|
||||
(fx/merge
|
||||
cofx
|
||||
|
@ -1834,7 +1824,7 @@
|
|||
(assoc-in [:hardwallet :flow] nil)
|
||||
(update :multiaccounts/login assoc
|
||||
:password encryption-public-key
|
||||
:address address
|
||||
:key-uid key-uid
|
||||
:photo-path photo-path
|
||||
:name name))
|
||||
|
||||
|
@ -1843,22 +1833,22 @@
|
|||
:password encryption-public-key
|
||||
:chat-key whisper-private-key}}
|
||||
(when save-keys?
|
||||
(keychain/save-hardwallet-keys address encryption-public-key whisper-private-key))
|
||||
(keychain/save-hardwallet-keys key-uid encryption-public-key whisper-private-key))
|
||||
(clear-on-card-connected)
|
||||
(clear-on-card-read))))
|
||||
|
||||
(fx/defn on-hardwallet-keychain-keys
|
||||
{:events [:multiaccounts.login.callback/get-hardwallet-keys-success]}
|
||||
[{:keys [db] :as cofx} address [encryption-public-key whisper-private-key :as creds]]
|
||||
[{:keys [db] :as cofx} key-uid [encryption-public-key whisper-private-key :as creds]]
|
||||
(if (nil? creds)
|
||||
(navigation/navigate-to-cofx cofx :keycard-login-pin nil)
|
||||
(let [{:keys [photo-path name]} (get-in db [:multiaccounts/multiaccounts address])
|
||||
(let [{:keys [photo-path name]} (get-in db [:multiaccounts/multiaccounts key-uid])
|
||||
multiaccount-data (types/clj->json {:name name
|
||||
:address address
|
||||
:key-uid key-uid
|
||||
:photo-path photo-path})
|
||||
account-data {:address address
|
||||
account-data {:key-uid key-uid
|
||||
:encryption-public-key encryption-public-key
|
||||
:whisper-private-key whisper-private-key}]
|
||||
:whisper-private-key whisper-private-key}]
|
||||
{:db
|
||||
(-> db
|
||||
(assoc-in [:hardwallet :pin :status] nil)
|
||||
|
@ -1868,7 +1858,7 @@
|
|||
(assoc-in [:hardwallet :flow] nil)
|
||||
(update :multiaccounts/login assoc
|
||||
:password encryption-public-key
|
||||
:address address
|
||||
:key-uid key-uid
|
||||
:photo-path photo-path
|
||||
:name name
|
||||
:save-password? true))
|
||||
|
|
|
@ -35,18 +35,18 @@
|
|||
(let [{{:multiaccounts/keys [multiaccounts] :as db} :db} cofx]
|
||||
(if (empty? multiaccounts)
|
||||
(navigation/navigate-to-cofx cofx :intro nil)
|
||||
(let [{:keys [address public-key photo-path name]} (first (#(sort-by :last-sign-in > %) (vals multiaccounts)))]
|
||||
(multiaccounts.login/open-login cofx address photo-path name public-key)))))
|
||||
(let [{:keys [key-uid public-key photo-path name]} (first (#(sort-by :last-sign-in > %) (vals multiaccounts)))]
|
||||
(multiaccounts.login/open-login cofx key-uid photo-path name public-key)))))
|
||||
|
||||
(fx/defn initialize-multiaccounts
|
||||
{:events [::initialize-multiaccounts]}
|
||||
[{:keys [db] :as cofx} all-multiaccounts]
|
||||
(let [multiaccounts (reduce (fn [acc {:keys [address key-uid keycard-pairing] :as multiaccount}]
|
||||
(-> (assoc acc address multiaccount)
|
||||
(assoc-in [address :key-uid] (when-not (string/blank? key-uid)
|
||||
key-uid))
|
||||
(assoc-in [address :keycard-pairing] (when-not (string/blank? keycard-pairing)
|
||||
keycard-pairing))))
|
||||
(let [multiaccounts (reduce (fn [acc {:keys [key-uid keycard-pairing]
|
||||
:as multiaccount}]
|
||||
(-> (assoc acc key-uid multiaccount)
|
||||
(assoc-in [key-uid :keycard-pairing]
|
||||
(when-not (string/blank? keycard-pairing)
|
||||
keycard-pairing))))
|
||||
{}
|
||||
all-multiaccounts)]
|
||||
(fx/merge cofx
|
||||
|
|
|
@ -118,16 +118,16 @@
|
|||
(authenticate-fx #(cb %) options)))
|
||||
|
||||
(fx/defn update-biometric [{db :db :as cofx} biometric-auth?]
|
||||
(let [address (or (get-in db [:multiaccount :address])
|
||||
(get-in db [:multiaccounts/login :address]))]
|
||||
(let [key-uid (or (get-in db [:multiaccount :key-uid])
|
||||
(get-in db [:multiaccounts/login :key-uid]))]
|
||||
(fx/merge cofx
|
||||
(keychain/save-auth-method
|
||||
address
|
||||
key-uid
|
||||
(if biometric-auth?
|
||||
keychain/auth-method-biometric
|
||||
keychain/auth-method-none))
|
||||
#(when-not biometric-auth?
|
||||
{:keychain/clear-user-password address}))))
|
||||
{:keychain/clear-user-password key-uid}))))
|
||||
|
||||
(fx/defn biometric-auth-switched
|
||||
{:events [:multiaccounts.ui/biometric-auth-switched]}
|
||||
|
|
|
@ -50,9 +50,8 @@
|
|||
(some #(when (= selected-id (:id %)) %) multiaccounts)))
|
||||
|
||||
(fx/defn create-multiaccount
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [selected-id address key-code]} (:intro-wizard db)
|
||||
{:keys [address]} (get-selected-multiaccount cofx)
|
||||
[{:keys [db]}]
|
||||
(let [{:keys [selected-id key-code]} (:intro-wizard db)
|
||||
hashed-password (ethereum/sha3 (security/safe-unmask-data key-code))
|
||||
callback (fn [result]
|
||||
(let [derived-data (types/json->clj result)
|
||||
|
@ -66,7 +65,7 @@
|
|||
(merge derived-whisper {:name name :photo-path photo-path}))]
|
||||
(re-frame/dispatch [::store-multiaccount-success
|
||||
key-code derived-data-extended]))))))]
|
||||
{::store-multiaccount [selected-id address hashed-password callback]}))
|
||||
{::store-multiaccount [selected-id hashed-password callback]}))
|
||||
|
||||
(fx/defn prepare-intro-wizard
|
||||
[{:keys [db] :as cofx} first-time-setup?]
|
||||
|
@ -260,12 +259,12 @@
|
|||
:keycard-pairing keycard-pairing
|
||||
:keycard-paired-on keycard-paired-on))
|
||||
db (assoc db
|
||||
:multiaccounts/login {:address address
|
||||
:name name
|
||||
:photo-path photo-path
|
||||
:password password
|
||||
:creating? true
|
||||
:processing true}
|
||||
:multiaccounts/login {:key-uid keyUid
|
||||
:name name
|
||||
:photo-path photo-path
|
||||
:password password
|
||||
:creating? true
|
||||
:processing true}
|
||||
:multiaccount new-multiaccount
|
||||
:networks/current-network constants/default-network
|
||||
:networks/networks constants/default-networks)]
|
||||
|
@ -365,7 +364,7 @@
|
|||
|
||||
(re-frame/reg-fx
|
||||
::store-multiaccount
|
||||
(fn [[id address hashed-password callback]]
|
||||
(fn [[id hashed-password callback]]
|
||||
(status/multiaccount-store-derived
|
||||
id
|
||||
[constants/path-wallet-root
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
(spec/def :multiaccount/accounts (spec/nilable vector?))
|
||||
|
||||
(spec/def :multiaccount/address :global/address)
|
||||
(spec/def :multiaccount/key-uid string?)
|
||||
(spec/def :multiaccount/name :global/not-empty-string)
|
||||
(spec/def :multiaccount/public-key :global/public-key)
|
||||
(spec/def :multiaccount/signed-up? (spec/nilable boolean?))
|
||||
|
@ -67,6 +68,6 @@
|
|||
;;used during logging
|
||||
(spec/def :multiaccounts/login (spec/nilable map?))
|
||||
;;before login
|
||||
(spec/def :multiaccounts/multiaccount (spec/keys :req-un [:multiaccount/name :multiaccount/address]
|
||||
(spec/def :multiaccounts/multiaccount (spec/keys :req-un [:multiaccount/name :multiaccount/key-uid]
|
||||
:opt-un [:multiaccount/timestamp]))
|
||||
(spec/def :multiaccounts/multiaccounts (spec/nilable (spec/map-of :multiaccount/address :multiaccounts/multiaccount)))
|
||||
(spec/def :multiaccounts/multiaccounts (spec/nilable (spec/map-of :multiaccount/key-uid :multiaccounts/multiaccount)))
|
||||
|
|
|
@ -69,13 +69,15 @@
|
|||
|
||||
(fx/defn login
|
||||
{:events [:multiaccounts.login.ui/password-input-submitted]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [address password name photo-path]} (:multiaccounts/login db)]
|
||||
[{:keys [db]}]
|
||||
(let [{:keys [key-uid password name photo-path]} (:multiaccounts/login db)]
|
||||
{:db (-> db
|
||||
(assoc-in [:multiaccounts/login :processing] true)
|
||||
(dissoc :intro-wizard)
|
||||
(update :hardwallet dissoc :flow))
|
||||
::login [(types/clj->json {:name name :address address :photo-path photo-path})
|
||||
::login [(types/clj->json {:name name
|
||||
:key-uid key-uid
|
||||
:photo-path photo-path})
|
||||
(ethereum/sha3 (security/safe-unmask-data password))]}))
|
||||
|
||||
(fx/defn finish-keycard-setup
|
||||
|
@ -185,7 +187,7 @@
|
|||
keychain/auth-method-none)))
|
||||
|
||||
(fx/defn login-only-events
|
||||
[{:keys [db] :as cofx} address password save-password?]
|
||||
[{:keys [db] :as cofx} key-uid password save-password?]
|
||||
(let [auth-method (:auth-method db)
|
||||
new-auth-method (get-new-auth-method auth-method save-password?)]
|
||||
(log/debug "[login] login-only-events"
|
||||
|
@ -208,14 +210,14 @@
|
|||
:params [["multiaccount" "current-network" "networks"]]
|
||||
:on-success #(re-frame/dispatch [::get-config-callback %])}]}
|
||||
(when save-password?
|
||||
(keychain/save-user-password address password))
|
||||
(keychain/save-auth-method address (or new-auth-method auth-method))
|
||||
(keychain/save-user-password key-uid password))
|
||||
(keychain/save-auth-method key-uid (or new-auth-method auth-method))
|
||||
(navigation/navigate-to-cofx :home nil)
|
||||
(when platform/desktop?
|
||||
(chat-model/update-dock-badge-label)))))
|
||||
|
||||
(fx/defn create-only-events
|
||||
[{:keys [db] :as cofx} address password]
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [multiaccount :networks/networks :networks/current-network]} db]
|
||||
(fx/merge cofx
|
||||
{:db (assoc db
|
||||
|
@ -254,7 +256,7 @@
|
|||
|
||||
(fx/defn multiaccount-login-success
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [address password save-password? creating?]} (:multiaccounts/login db)
|
||||
(let [{:keys [key-uid password save-password? creating?]} (:multiaccounts/login db)
|
||||
recovering? (get-in db [:intro-wizard :recovering?])
|
||||
login-only? (not (or creating?
|
||||
recovering?
|
||||
|
@ -278,8 +280,8 @@
|
|||
(when nodes
|
||||
(fleet/set-nodes :eth.contract nodes))
|
||||
(if login-only?
|
||||
(login-only-events address password save-password?)
|
||||
(create-only-events address password))
|
||||
(login-only-events key-uid password save-password?)
|
||||
(create-only-events))
|
||||
(when recovering?
|
||||
(navigation/navigate-to-cofx :home nil)))))
|
||||
|
||||
|
@ -296,26 +298,26 @@
|
|||
(navigation/navigate-to-cofx :keycard-login-pin nil)))))
|
||||
|
||||
(fx/defn open-login
|
||||
[{:keys [db] :as cofx} address photo-path name public-key]
|
||||
[{:keys [db] :as cofx} key-uid photo-path name public-key]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
(update :multiaccounts/login assoc
|
||||
:public-key public-key
|
||||
:address address
|
||||
:key-uid key-uid
|
||||
:photo-path photo-path
|
||||
:name name)
|
||||
(assoc :profile/photo-added? (= (identicon/identicon public-key) photo-path))
|
||||
(update :multiaccounts/login dissoc
|
||||
:error
|
||||
:password))}
|
||||
(keychain/get-auth-method address)))
|
||||
(keychain/get-auth-method key-uid)))
|
||||
|
||||
(fx/defn open-login-callback
|
||||
{:events [:multiaccounts.login.callback/get-user-password-success]}
|
||||
[{:keys [db] :as cofx} password]
|
||||
(let [address (get-in db [:multiaccounts/login :address])
|
||||
(let [key-uid (get-in db [:multiaccounts/login :key-uid])
|
||||
keycard-account? (boolean (get-in db [:multiaccounts/multiaccounts
|
||||
address
|
||||
key-uid
|
||||
:keycard-pairing]))]
|
||||
(if password
|
||||
(fx/merge
|
||||
|
@ -334,20 +336,20 @@
|
|||
nil)))))
|
||||
|
||||
(fx/defn get-credentials
|
||||
[{:keys [db] :as cofx} address]
|
||||
(let [keycard-multiaccount? (boolean (get-in db [:multiaccounts/multiaccounts address :keycard-pairing]))]
|
||||
[{:keys [db] :as cofx} key-uid]
|
||||
(let [keycard-multiaccount? (boolean (get-in db [:multiaccounts/multiaccounts key-uid :keycard-pairing]))]
|
||||
(log/debug "[login] get-credentials"
|
||||
"keycard-multiacc?" keycard-multiaccount?)
|
||||
(if keycard-multiaccount?
|
||||
(keychain/get-hardwallet-keys cofx address)
|
||||
(keychain/get-user-password cofx address))))
|
||||
(keychain/get-hardwallet-keys cofx key-uid)
|
||||
(keychain/get-user-password cofx key-uid))))
|
||||
|
||||
(fx/defn get-auth-method-success
|
||||
"Auth method: nil - not supported, \"none\" - not selected, \"password\", \"biometric\", \"biometric-prepare\""
|
||||
{:events [:multiaccounts.login/get-auth-method-success]}
|
||||
[{:keys [db] :as cofx} auth-method]
|
||||
(let [address (get-in db [:multiaccounts/login :address])
|
||||
keycard-multiaccount? (boolean (get-in db [:multiaccounts/multiaccounts address :keycard-pairing]))]
|
||||
(let [key-uid (get-in db [:multiaccounts/login :key-uid])
|
||||
keycard-multiaccount? (boolean (get-in db [:multiaccounts/multiaccounts key-uid :keycard-pairing]))]
|
||||
(log/debug "[login] get-auth-method-success"
|
||||
"auth-method" auth-method
|
||||
"keycard-multiacc?" keycard-multiaccount?)
|
||||
|
@ -357,7 +359,7 @@
|
|||
keychain/auth-method-biometric
|
||||
(biometric/biometric-auth %)
|
||||
keychain/auth-method-password
|
||||
(get-credentials % address)
|
||||
(get-credentials % key-uid)
|
||||
|
||||
;;nil or "none" or "biometric-prepare"
|
||||
(if keycard-multiaccount?
|
||||
|
@ -367,17 +369,17 @@
|
|||
(fx/defn biometric-auth-done
|
||||
{:events [:biometric-auth-done]}
|
||||
[{:keys [db] :as cofx} {:keys [bioauth-success bioauth-message bioauth-code]}]
|
||||
(let [address (get-in db [:multiaccounts/login :address])]
|
||||
(let [key-uid (get-in db [:multiaccounts/login :key-uid])]
|
||||
(log/debug "[biometric] biometric-auth-done"
|
||||
"bioauth-success" bioauth-success
|
||||
"bioauth-message" bioauth-message
|
||||
"bioauth-code" bioauth-code)
|
||||
(if bioauth-success
|
||||
(get-credentials cofx address)
|
||||
(get-credentials cofx key-uid)
|
||||
(fx/merge cofx
|
||||
{:db (assoc-in db [:multiaccounts/login :save-password?] false)}
|
||||
(biometric/show-message bioauth-message bioauth-code)
|
||||
(keychain/save-auth-method address keychain/auth-method-none)
|
||||
(keychain/save-auth-method key-uid keychain/auth-method-none)
|
||||
(open-login-callback nil)))))
|
||||
|
||||
(fx/defn save-password
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
[status-im.utils.keychain.core :as keychain]))
|
||||
|
||||
(fx/defn logout-method [{:keys [db] :as cofx} auth-method]
|
||||
(let [address (get-in db [:multiaccount :address])]
|
||||
(let [key-uid (get-in db [:multiaccount :key-uid])]
|
||||
(fx/merge cofx
|
||||
{::logout nil
|
||||
:keychain/clear-user-password address
|
||||
:keychain/clear-user-password key-uid
|
||||
::init/open-multiaccounts #(re-frame/dispatch [::init/initialize-multiaccounts %])}
|
||||
(keychain/save-auth-method address auth-method)
|
||||
(keychain/save-auth-method key-uid auth-method)
|
||||
(transport/stop-whisper)
|
||||
(chaos-mode/stop-checking)
|
||||
(init/initialize-app-db))))
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
(get-in cofx [:db :multiaccount])))
|
||||
|
||||
(defn credentials [cofx]
|
||||
(select-keys (get-in cofx [:db :multiaccounts/login]) [:address :password :save-password?]))
|
||||
(select-keys (get-in cofx [:db :multiaccounts/login]) [:key-uid :password :save-password?]))
|
||||
|
||||
(defn current-public-key
|
||||
[cofx]
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
|
||||
(defn existing-account?
|
||||
[root-key multiaccounts]
|
||||
(contains? multiaccounts ((fnil clojure.string/lower-case "")
|
||||
(:address root-key))))
|
||||
(contains? multiaccounts (:key-uid root-key)))
|
||||
|
||||
(defn check-phrase-warnings [recovery-phrase]
|
||||
(cond (string/blank? recovery-phrase) :required-field
|
||||
|
@ -49,11 +48,8 @@
|
|||
:interceptors [(re-frame/inject-cofx :random-guid-generator)
|
||||
(re-frame/inject-cofx ::multiaccounts.create/get-signing-phrase)]}
|
||||
[{:keys [db] :as cofx} password]
|
||||
(let [multiaccount (get-in db [:intro-wizard :root-key])
|
||||
multiaccount-address (-> (:address multiaccount)
|
||||
(string/lower-case)
|
||||
(string/replace-first "0x" ""))
|
||||
keycard-multiaccount? (boolean (get-in db [:multiaccounts/multiaccounts multiaccount-address :keycard-pairing]))]
|
||||
(let [{:keys [key-uid] :as multiaccount} (get-in db [:intro-wizard :root-key])
|
||||
keycard-multiaccount? (boolean (get-in db [:multiaccounts/multiaccounts key-uid :keycard-pairing]))]
|
||||
(if keycard-multiaccount?
|
||||
;; trying to recover multiaccount created with keycard
|
||||
{:db (-> db
|
||||
|
@ -70,14 +66,14 @@
|
|||
|
||||
(fx/defn store-multiaccount
|
||||
{:events [::recover-multiaccount-confirmed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
[{:keys [db]}]
|
||||
(let [password (get-in db [:intro-wizard :key-code])
|
||||
{:keys [passphrase root-key]} (:intro-wizard db)
|
||||
{:keys [id address]} root-key
|
||||
{:keys [root-key]} (:intro-wizard db)
|
||||
{:keys [id]} root-key
|
||||
callback #(re-frame/dispatch [::store-multiaccount-success password])
|
||||
hashed-password (ethereum/sha3 (security/safe-unmask-data password))]
|
||||
{:db (assoc-in db [:intro-wizard :processing?] true)
|
||||
::multiaccounts.create/store-multiaccount [id address hashed-password callback]}))
|
||||
::multiaccounts.create/store-multiaccount [id hashed-password callback]}))
|
||||
|
||||
(fx/defn recover-multiaccount-with-checks
|
||||
{:events [::sign-in-button-pressed]}
|
||||
|
@ -118,19 +114,18 @@
|
|||
root-data derived-data-extended]))))))))))))
|
||||
|
||||
(fx/defn show-existing-multiaccount-alert
|
||||
[_ address]
|
||||
[_ key-uid]
|
||||
{:utils/show-confirmation
|
||||
{:title (i18n/label :t/multiaccount-exists-title)
|
||||
:content (i18n/label :t/multiaccount-exists-content)
|
||||
:confirm-button-text (i18n/label :t/unlock)
|
||||
:on-accept #(re-frame/dispatch
|
||||
[:multiaccounts.login.ui/multiaccount-selected
|
||||
(clojure.string/lower-case address)])
|
||||
[:multiaccounts.login.ui/multiaccount-selected key-uid])
|
||||
:on-cancel #(re-frame/dispatch [:navigate-to :multiaccounts])}})
|
||||
|
||||
(fx/defn on-import-multiaccount-success
|
||||
{:events [::import-multiaccount-success]}
|
||||
[{:keys [db] :as cofx} {:keys [address] :as root-data} derived-data]
|
||||
[{:keys [db] :as cofx} {:keys [key-uid] :as root-data} derived-data]
|
||||
(let [multiaccounts (:multiaccounts/multiaccounts db)]
|
||||
(fx/merge
|
||||
cofx
|
||||
|
@ -140,7 +135,7 @@
|
|||
:step :recovery-success
|
||||
:forward-action :multiaccounts.recover/re-encrypt-pressed)}
|
||||
(when (existing-account? root-data multiaccounts)
|
||||
(show-existing-multiaccount-alert address))
|
||||
(show-existing-multiaccount-alert key-uid))
|
||||
(navigation/navigate-to-cofx :recover-multiaccount-success nil))))
|
||||
|
||||
(fx/defn enter-phrase-pressed
|
||||
|
|
|
@ -46,7 +46,8 @@
|
|||
(defn save-account-and-login
|
||||
"NOTE: beware, the password has to be sha3 hashed"
|
||||
[multiaccount-data hashed-password config accounts-data]
|
||||
(log/debug "[native-module] save-account-and-login")
|
||||
(log/debug "[native-module] save-account-and-login"
|
||||
"multiaccount-data" multiaccount-data)
|
||||
(clear-web-data)
|
||||
(.saveAccountAndLogin (status) multiaccount-data hashed-password config accounts-data))
|
||||
|
||||
|
@ -125,12 +126,12 @@
|
|||
(defn multiaccount-store-derived
|
||||
"NOTE: beware, the password has to be sha3 hashed"
|
||||
[account-id paths hashed-password callback]
|
||||
(log/debug "[native-module] multiaccount-store-derived")
|
||||
(log/debug "[native-module] multiaccount-store-derived"
|
||||
"account-id" account-id)
|
||||
(.multiAccountStoreDerived (status)
|
||||
(types/clj->json {:accountID account-id
|
||||
:paths paths
|
||||
:password hashed-password})
|
||||
|
||||
callback))
|
||||
|
||||
(defn multiaccount-generate-and-derive-addresses
|
||||
|
|
|
@ -42,8 +42,6 @@
|
|||
(defview toolbar-content-view []
|
||||
(letsubs [{:keys [group-chat color online contacts chat-name contact
|
||||
public? chat-id] :as chat} [:chats/current-chat]
|
||||
show-actions? [:chats/current-chat-ui-prop :show-actions?]
|
||||
multiaccounts [:multiaccounts/multiaccounts]
|
||||
sync-state [:sync-state]]
|
||||
(let [has-subtitle? (or group-chat (not= :done sync-state))]
|
||||
[react/view {:style st/toolbar-container}
|
||||
|
|
|
@ -366,7 +366,7 @@
|
|||
status [:hardwallet/pin-status]
|
||||
error-label [:hardwallet/pin-error-label]
|
||||
multiple-multiaccounts? [:multiple-multiaccounts?]
|
||||
{:keys [address name] :as account} [:multiaccounts/login]
|
||||
{:keys [key-uid name] :as account} [:multiaccounts/login]
|
||||
small-screen? [:dimensions/small-screen?]
|
||||
retry-counter [:hardwallet/retry-counter]]
|
||||
[react/view styles/container
|
||||
|
@ -428,7 +428,7 @@
|
|||
:font-family "monospace"}
|
||||
:number-of-lines 1
|
||||
:ellipsize-mode :middle}
|
||||
(utils.core/truncate-str address 14 true)]]]
|
||||
(utils.core/truncate-str key-uid 14 true)]]]
|
||||
[pin.views/pin-view
|
||||
{:pin pin
|
||||
:retry-counter retry-counter
|
||||
|
@ -445,7 +445,7 @@
|
|||
|
||||
(defview login-connect-card []
|
||||
(letsubs [status [:hardwallet/pin-status]
|
||||
{:keys [address name] :as account} [:multiaccounts/login]]
|
||||
{:keys [key-uid name] :as account} [:multiaccounts/login]]
|
||||
(let [in-progress? (= status :verifying)]
|
||||
[react/view styles/container
|
||||
[toolbar/toolbar
|
||||
|
@ -506,7 +506,7 @@
|
|||
:font-family "monospace"}
|
||||
:number-of-lines 1
|
||||
:ellipsize-mode :middle}
|
||||
(utils.core/truncate-str address 14 true)]]]
|
||||
(utils.core/truncate-str key-uid 14 true)]]]
|
||||
[react/view {:margin-bottom 12
|
||||
:flex 1
|
||||
:align-items :center
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
[status-im.react-native.resources :as resources]))
|
||||
|
||||
(defn multiaccount-view
|
||||
[{:keys [address photo-path name public-key keycard-pairing]}]
|
||||
[react/touchable-highlight {:on-press #(re-frame/dispatch [:multiaccounts.login.ui/multiaccount-selected address])}
|
||||
[{:keys [key-uid photo-path name keycard-pairing]}]
|
||||
[react/touchable-highlight
|
||||
{:on-press #(re-frame/dispatch
|
||||
[:multiaccounts.login.ui/multiaccount-selected key-uid])}
|
||||
[react/view styles/multiaccount-view
|
||||
[photos/photo photo-path {:size styles/multiaccount-image-size}]
|
||||
[react/view styles/multiaccount-badge-text-view
|
||||
|
|
|
@ -116,11 +116,11 @@
|
|||
|
||||
(re-frame/reg-fx
|
||||
:keychain/get-auth-method
|
||||
(fn [[address callback]]
|
||||
(fn [[key-uid callback]]
|
||||
(can-save-user-password?
|
||||
(fn [can-save?]
|
||||
(if can-save?
|
||||
(get-credentials (str address "-auth")
|
||||
(get-credentials (str key-uid "-auth")
|
||||
#(callback (if %
|
||||
(.-password %)
|
||||
auth-method-none)))
|
||||
|
@ -128,18 +128,18 @@
|
|||
|
||||
(re-frame/reg-fx
|
||||
:keychain/get-user-password
|
||||
(fn [[address callback]]
|
||||
(get-credentials address #(if % (callback (security/mask-data (.-password %))) (callback nil)))))
|
||||
(fn [[key-uid callback]]
|
||||
(get-credentials key-uid #(if % (callback (security/mask-data (.-password %))) (callback nil)))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:keychain/get-hardwallet-keys
|
||||
(fn [[address callback]]
|
||||
(fn [[key-uid callback]]
|
||||
(get-credentials
|
||||
address
|
||||
key-uid
|
||||
(fn [encryption-key-data]
|
||||
(if encryption-key-data
|
||||
(get-credentials
|
||||
(whisper-key-name address)
|
||||
(whisper-key-name key-uid)
|
||||
(fn [whisper-key-data]
|
||||
(if whisper-key-data
|
||||
(callback [(.-password encryption-key-data)
|
||||
|
@ -149,10 +149,10 @@
|
|||
|
||||
(re-frame/reg-fx
|
||||
:keychain/save-user-password
|
||||
(fn [[address password]]
|
||||
(fn [[key-uid password]]
|
||||
(save-credentials
|
||||
address
|
||||
address
|
||||
key-uid
|
||||
key-uid
|
||||
(security/safe-unmask-data password)
|
||||
#(when-not %
|
||||
(log/error
|
||||
|
@ -163,12 +163,12 @@
|
|||
|
||||
(re-frame/reg-fx
|
||||
:keychain/save-auth-method
|
||||
(fn [[address method]]
|
||||
(fn [[key-uid method]]
|
||||
(log/debug "[keychain] :keychain/save-auth-method"
|
||||
"method" method)
|
||||
(save-credentials
|
||||
(str address "-auth")
|
||||
address
|
||||
(str key-uid "-auth")
|
||||
key-uid
|
||||
method
|
||||
#(when-not %
|
||||
(log/error
|
||||
|
@ -179,17 +179,17 @@
|
|||
|
||||
(re-frame/reg-fx
|
||||
:keychain/save-hardwallet-keys
|
||||
(fn [[address encryption-public-key whisper-private-key]]
|
||||
(fn [[key-uid encryption-public-key whisper-private-key]]
|
||||
(save-credentials
|
||||
address
|
||||
address
|
||||
key-uid
|
||||
key-uid
|
||||
encryption-public-key
|
||||
#(when-not %
|
||||
(log/error
|
||||
(str "Error while saving encryption-public-key"))))
|
||||
(save-credentials
|
||||
(whisper-key-name address)
|
||||
address
|
||||
(whisper-key-name key-uid)
|
||||
key-uid
|
||||
whisper-private-key
|
||||
#(when-not %
|
||||
(log/error
|
||||
|
@ -197,40 +197,40 @@
|
|||
|
||||
(re-frame/reg-fx
|
||||
:keychain/clear-user-password
|
||||
(fn [address]
|
||||
(fn [key-uid]
|
||||
(when platform/mobile?
|
||||
(-> (.resetInternetCredentials rn/keychain (string/lower-case address))
|
||||
(-> (.resetInternetCredentials rn/keychain (string/lower-case key-uid))
|
||||
(.then #(when-not % (log/error (str "Error while clearing saved password."))))))))
|
||||
|
||||
(fx/defn get-auth-method
|
||||
[_ address]
|
||||
[_ key-uid]
|
||||
{:keychain/get-auth-method
|
||||
[address #(re-frame/dispatch [:multiaccounts.login/get-auth-method-success % address])]})
|
||||
[key-uid #(re-frame/dispatch [:multiaccounts.login/get-auth-method-success % key-uid])]})
|
||||
|
||||
(fx/defn get-user-password
|
||||
[_ address]
|
||||
[_ key-uid]
|
||||
{:keychain/get-user-password
|
||||
[address
|
||||
[key-uid
|
||||
#(re-frame/dispatch
|
||||
[:multiaccounts.login.callback/get-user-password-success % address])]})
|
||||
[:multiaccounts.login.callback/get-user-password-success % key-uid])]})
|
||||
|
||||
(fx/defn get-hardwallet-keys
|
||||
[_ address]
|
||||
[_ key-uid]
|
||||
{:keychain/get-hardwallet-keys
|
||||
[address
|
||||
[key-uid
|
||||
#(re-frame/dispatch
|
||||
[:multiaccounts.login.callback/get-hardwallet-keys-success address %])]})
|
||||
[:multiaccounts.login.callback/get-hardwallet-keys-success key-uid %])]})
|
||||
|
||||
(fx/defn save-user-password
|
||||
[_ address password]
|
||||
{:keychain/save-user-password [address password]})
|
||||
[_ key-uid password]
|
||||
{:keychain/save-user-password [key-uid password]})
|
||||
|
||||
(fx/defn save-hardwallet-keys
|
||||
[_ address encryption-public-key whisper-private-key]
|
||||
{:keychain/save-hardwallet-keys [address
|
||||
[_ key-uid encryption-public-key whisper-private-key]
|
||||
{:keychain/save-hardwallet-keys [key-uid
|
||||
encryption-public-key
|
||||
whisper-private-key]})
|
||||
(fx/defn save-auth-method
|
||||
[{:keys [db]} address method]
|
||||
[{:keys [db]} key-uid method]
|
||||
{:db (assoc db :auth-method method)
|
||||
:keychain/save-auth-method [address method]})
|
||||
:keychain/save-auth-method [key-uid method]})
|
||||
|
|
|
@ -153,4 +153,4 @@
|
|||
:path ""
|
||||
:type :watch
|
||||
:color (rand-nth colors/account-colors)})}
|
||||
(navigation/navigate-to-cofx :account-added nil))))
|
||||
(navigation/navigate-to-cofx :account-added nil))))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
|
||||
"owner": "status-im",
|
||||
"repo": "status-go",
|
||||
"version": "v0.36.1",
|
||||
"commit-sha1": "fd49b0140ebafdcec35b4da84685bcd8559a7dd9",
|
||||
"src-sha256": "1pqnvmldg93vbmmsvpr24pj87d2vx3cfm7rr9rgwdk469pd1hhhy"
|
||||
"version": "v0.36.2",
|
||||
"commit-sha1": "4c0d8dedea10b02bbad476170cc0eef61a92ecbf",
|
||||
"src-sha256": "0a13rk9p13s3p1dz3n7wbb3s343dlqsidmphxz57xw6di2s40nzx"
|
||||
}
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
(deftest on-password-input-submitted
|
||||
(testing
|
||||
"handling :multiaccounts.login.ui/password-input-submitted event"
|
||||
(let [cofx {:db {:multiaccounts/login {:address "address"
|
||||
(let [cofx {:db {:multiaccounts/login {:key-uid "key-uid"
|
||||
:password "password"
|
||||
:name "user"
|
||||
:photo-path "photo"}}}
|
||||
efx (login.core/login cofx)]
|
||||
(testing "Change multiaccount."
|
||||
(is (= (::login.core/login efx)
|
||||
["{\"name\":\"user\",\"address\":\"address\",\"photo-path\":\"photo\"}" (ethereum/sha3 "password")])))
|
||||
["{\"name\":\"user\",\"key-uid\":\"key-uid\",\"photo-path\":\"photo\"}" (ethereum/sha3 "password")])))
|
||||
(testing "start activity indicator"
|
||||
(is (= (get-in efx [:db :multiaccounts/login :processing]) true))))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue