use a default pairing password for Keycard

Signed-off-by: Michele Balistreri <michele@bitgamma.com>
This commit is contained in:
Michele Balistreri 2021-11-11 18:05:24 +03:00
parent e125164273
commit 4349f2659e
No known key found for this signature in database
GPG Key ID: E9567DA33A4F791A
4 changed files with 21 additions and 11 deletions

View File

@ -58,7 +58,7 @@
"react-native-shake": "^3.3.1", "react-native-shake": "^3.3.1",
"react-native-share": "^7.0.1", "react-native-share": "^7.0.1",
"react-native-splash-screen": "^3.2.0", "react-native-splash-screen": "^3.2.0",
"react-native-status-keycard": "git+https://github.com/status-im/react-native-status-keycard.git#v2.5.35", "react-native-status-keycard": "git+https://github.com/status-im/react-native-status-keycard.git#v2.5.36",
"react-native-svg": "^9.8.4", "react-native-svg": "^9.8.4",
"react-native-touch-id": "^4.4.1", "react-native-touch-id": "^4.4.1",
"react-native-webview": "git+https://github.com/status-im/react-native-webview.git#v11.3.0-status", "react-native-webview": "git+https://github.com/status-im/react-native-webview.git#v11.3.0-status",

View File

@ -10,6 +10,7 @@
[status-im.utils.keychain.core :as keychain] [status-im.utils.keychain.core :as keychain]
[status-im.utils.types :as types] [status-im.utils.types :as types]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[status-im.utils.datetime :as utils.datetime]
[status-im.bottom-sheet.core :as bottom-sheet] [status-im.bottom-sheet.core :as bottom-sheet]
[status-im.utils.platform :as platform] [status-im.utils.platform :as platform]
[status-im.popover.core :as popover])) [status-im.popover.core :as popover]))
@ -416,6 +417,14 @@
;; Get application info ;; Get application info
(fx/defn update-pairings
[{:keys [db]} instance-uid pairing]
(let [paired-on (utils.datetime/timestamp)
pairings (-> (get-in db [:keycard :pairings])
(assoc instance-uid {:pairing pairing :paired-on paired-on}))]
{:keycard/persist-pairings pairings
:db (assoc-in db [:keycard :pairings] pairings)}))
(fx/defn get-application-info (fx/defn get-application-info
{:events [:keycard/get-application-info]} {:events [:keycard/get-application-info]}
[{:keys [db]} on-card-read] [{:keys [db]} on-card-read]
@ -425,9 +434,8 @@
(fx/defn on-get-application-info-success (fx/defn on-get-application-info-success
{:events [:keycard.callback/on-get-application-info-success]} {:events [:keycard.callback/on-get-application-info-success]}
[{:keys [db] :as cofx} info on-success] [{:keys [db] :as cofx} info on-success]
(let [{:keys [pin-retry-counter puk-retry-counter]} info (let [{:keys [pin-retry-counter puk-retry-counter instance-uid new-pairing]} info
view-id (:view-id db) view-id (:view-id db)
{:keys [on-card-read]} (:keycard db) {:keys [on-card-read]} (:keycard db)
on-success' (or on-success on-card-read) on-success' (or on-success on-card-read)
enter-step (get-in db [:keycard :pin :enter-step])] enter-step (get-in db [:keycard :pin :enter-step])]
@ -443,6 +451,8 @@
(assoc-in [:keycard :application-info :applet-installed?] true) (assoc-in [:keycard :application-info :applet-installed?] true)
(assoc-in [:keycard :application-info-error] nil))} (assoc-in [:keycard :application-info-error] nil))}
(stash-on-card-read) (stash-on-card-read)
(when new-pairing
(update-pairings instance-uid new-pairing))
(when (and (zero? pin-retry-counter) (when (and (zero? pin-retry-counter)
(pos? puk-retry-counter) (pos? puk-retry-counter)
(not= enter-step :puk)) (not= enter-step :puk))
@ -452,6 +462,7 @@
(blocked-keycard-popup cofx) (blocked-keycard-popup cofx)
(when on-success' (when on-success'
(dispatch-event cofx on-success'))))))) (dispatch-event cofx on-success')))))))
(fx/defn on-get-application-info-error (fx/defn on-get-application-info-error
{:events [:keycard.callback/on-get-application-info-error]} {:events [:keycard.callback/on-get-application-info-error]}
[{:keys [db] :as cofx} error] [{:keys [db] :as cofx} error]

View File

@ -232,8 +232,7 @@
[{:keys [db] :as cofx} secrets] [{:keys [db] :as cofx} secrets]
(let [secrets' (js->clj secrets :keywordize-keys true)] (let [secrets' (js->clj secrets :keywordize-keys true)]
(fx/merge cofx (fx/merge cofx
{:keycard/get-application-info nil {:db (-> db
:db (-> db
(assoc-in [:keycard :card-state] :init) (assoc-in [:keycard :card-state] :init)
(assoc-in [:keycard :setup-step] :secret-keys) (assoc-in [:keycard :setup-step] :secret-keys)
(update-in [:keycard :secrets] merge secrets'))} (update-in [:keycard :secrets] merge secrets'))}

View File

@ -6735,9 +6735,9 @@ react-native-splash-screen@^3.2.0:
resolved "https://registry.yarnpkg.com/react-native-splash-screen/-/react-native-splash-screen-3.2.0.tgz#d47ec8557b1ba988ee3ea98d01463081b60fff45" resolved "https://registry.yarnpkg.com/react-native-splash-screen/-/react-native-splash-screen-3.2.0.tgz#d47ec8557b1ba988ee3ea98d01463081b60fff45"
integrity sha512-Ls9qiNZzW/OLFoI25wfjjAcrf2DZ975hn2vr6U9gyuxi2nooVbzQeFoQS5vQcbCt9QX5NY8ASEEAtlLdIa6KVg== integrity sha512-Ls9qiNZzW/OLFoI25wfjjAcrf2DZ975hn2vr6U9gyuxi2nooVbzQeFoQS5vQcbCt9QX5NY8ASEEAtlLdIa6KVg==
"react-native-status-keycard@git+https://github.com/status-im/react-native-status-keycard.git#v2.5.35": "react-native-status-keycard@git+https://github.com/status-im/react-native-status-keycard.git#v2.5.36":
version "2.5.35" version "2.5.36"
resolved "git+https://github.com/status-im/react-native-status-keycard.git#8cf7cbff803b080b2069202ea6179703b8c69d2e" resolved "git+https://github.com/status-im/react-native-status-keycard.git#7548329c597a6e1370010b8aa2d16a1d93610f11"
react-native-svg@^9.8.4: react-native-svg@^9.8.4:
version "9.13.6" version "9.13.6"