Compare commits

...
Author SHA1 Message Date
Alexander 916c0b995c Merge branch 'develop' into reg-event-fx-update 2024-04-22 23:23:07 +02:00
Alexander 4d018a32d4 Merge branch 'develop' into reg-event-fx-update 2024-04-22 17:33:30 +02:00
Alexander cce91abad0 Merge branch 'develop' into reg-event-fx-update 2024-04-19 12:46:02 +02:00
Alexander c54f291945 Merge branch 'develop' into reg-event-fx-update 2024-04-19 11:30:18 +02:00
alwx d379d80df4 Lint fix 2024-04-19 11:19:57 +02:00
alwx 702da7a318 Profile handlers 2024-04-19 11:08:38 +02:00
alwx 5a6ae261ed More bits of it 2024-04-18 16:46:59 +02:00
alwx 1bbfd2222e Events updates 2024-04-18 16:11:43 +02:00
alwx f04f138f93 reg-event-fx update 2024-04-18 12:33:02 +02:00
8 changed files with 265 additions and 271 deletions
@@ -35,7 +35,11 @@
:accessibility-label :enable-biometrics-button
:icon-left :i/face-id
:customization-color profile-color
:on-press #(rf/dispatch [:onboarding/enable-biometrics])}
:on-press (fn []
(rf/dispatch [:biometric/authenticate
{:on-success #(rf/dispatch [:onboarding/biometrics-done])
:on-fail #(rf/dispatch [:biometric/show-message
(ex-cause %)])}]))}
(i18n/label :t/biometric-enable-button {:bio-type-label bio-type-label})]
[quo/button
{:accessibility-label :maybe-later-button
+145 -142
View File
@@ -4,8 +4,7 @@
[re-frame.core :as re-frame]
status-im.common.biometric.events
[status-im.constants :as constants]
[status-im.contexts.profile.create.events :as profile.create]
[status-im.contexts.profile.recover.events :as profile.recover]
[status-im.contexts.profile.utils :as profile.utils]
[taoensso.timbre :as log]
[utils.i18n :as i18n]
[utils.re-frame :as rf]
@@ -23,157 +22,161 @@
(when on-error (on-error error))
(on-success mnemonic keyUID)))))))
(rf/defn profile-data-set
{:events [:onboarding/profile-data-set]}
[{:keys [db]} onboarding-data]
{:db (update db :onboarding/profile merge onboarding-data)
:dispatch [:navigate-to-within-stack
[:screen/onboarding.create-profile-password :screen/onboarding.new-to-status]]})
(rf/defn enable-biometrics
{:events [:onboarding/enable-biometrics]}
[_]
{:fx [[:dispatch
[:biometric/authenticate
{:on-success #(rf/dispatch [:onboarding/biometrics-done])
:on-fail #(rf/dispatch [:onboarding/biometrics-fail %])}]]]})
(rf/defn navigate-to-enable-notifications
{:events [:onboarding/navigate-to-enable-notifications]}
[{:keys [db]}]
(let [key-uid (get-in db [:profile/profile :key-uid])]
{:db (dissoc db :onboarding/profile)
:dispatch [:navigate-to-within-stack
[:screen/onboarding.enable-notifications :screen/onboarding.enable-biometrics]]}))
(rf/defn biometrics-done
{:events [:onboarding/biometrics-done]}
[{:keys [db]}]
(let [syncing? (get-in db [:onboarding/profile :syncing?])]
{:db (assoc-in db [:onboarding/profile :auth-method] constants/auth-method-biometric)
:dispatch (if syncing?
[:onboarding/finalize-setup]
[:onboarding/create-account-and-login])}))
(rf/reg-event-fx
:onboarding/profile-data-set
(fn [{:keys [db]} [onboarding-data]]
{:db (update db :onboarding/profile merge onboarding-data)
:fx [[:dispatch
[:navigate-to-within-stack
[:screen/onboarding.create-profile-password :screen/onboarding.new-to-status]]]]}))
(rf/reg-event-fx
:onboarding/biometrics-fail
(fn [_ [error]]
{:dispatch [:biometric/show-message (ex-cause error)]}))
:onboarding/navigate-to-enable-notifications
(fn [{:keys [db]}]
{:db (dissoc db :onboarding/profile)
:fx [[:dispatch
[:navigate-to-within-stack
[:screen/onboarding.enable-notifications :screen/onboarding.enable-biometrics]]]]}))
(rf/defn create-account-and-login
{:events [:onboarding/create-account-and-login]}
[{:keys [db] :as cofx}]
(let [{:keys [display-name seed-phrase password image-path color] :as profile}
(:onboarding/profile db)]
(rf/merge cofx
{:dispatch [:navigate-to-within-stack
[:screen/onboarding.generating-keys :screen/onboarding.new-to-status]]
:dispatch-later [{:ms constants/onboarding-generating-keys-animation-duration-ms
:dispatch [:onboarding/navigate-to-identifiers]}]
:db (-> db
(dissoc :profile/login)
(dissoc :auth-method)
(assoc :onboarding/new-account? true))}
(if seed-phrase
(profile.recover/recover-profile-and-login profile)
(profile.create/create-profile-and-login profile)))))
(rf/reg-event-fx
:onboarding/biometrics-done
(fn [{:keys [db]}]
(let [syncing? (get-in db [:onboarding/profile :syncing?])]
{:db (assoc-in db [:onboarding/profile :auth-method] constants/auth-method-biometric)
:fx [[:dispatch
(if syncing?
[:onboarding/finalize-setup]
[:onboarding/create-account-and-login])]]})))
(rf/defn on-delete-profile-success
{:events [:onboarding/on-delete-profile-success]}
[{:keys [db]} key-uid]
(let [multiaccounts (dissoc (:profile/profiles-overview db) key-uid)]
(merge
{:db (assoc db :profile/profiles-overview multiaccounts)}
(when-not (seq multiaccounts)
{:set-root :screen/onboarding.intro}))))
(rf/reg-event-fx
:onboarding/create-account-and-login
(fn [{:keys [db]}]
(let [{:keys [seed-phrase] :as profile} (:onboarding/profile db)
restore? (boolean seed-phrase)
{:keys [password] :as profile} (profile.utils/create-profile-config profile restore?)]
(cond-> {:fx [[:dispatch
[:navigate-to-within-stack
[:screen/onboarding.generating-keys :screen/onboarding.new-to-status]]]
[:dispatch-later
[{:ms constants/onboarding-generating-keys-animation-duration-ms
:dispatch [:onboarding/navigate-to-identifiers]}]]]
:db (-> db
(dissoc :profile/login)
(dissoc :auth-method)
(assoc :onboarding/new-account? true)
(assoc-in [:syncing :login-sha3-password] password))}
(rf/defn password-set
{:events [:onboarding/password-set]}
[{:keys [db]} password]
(let [supported-type (get-in db [:biometrics :supported-type])]
{:db (-> db
(assoc-in [:onboarding/profile :password] password)
(assoc-in [:onboarding/profile :auth-method] constants/auth-method-password))
:dispatch (if supported-type
[:navigate-to-within-stack
[:screen/onboarding.enable-biometrics :screen/onboarding.new-to-status]]
[:onboarding/create-account-and-login])}))
restore?
(assoc-in [:db :onboarding/recovered-account?] true)
(rf/defn navigate-to-enable-biometrics
{:events [:onboarding/navigate-to-enable-biometrics]}
[{:keys [db]}]
(let [supported-type (get-in db [:biometrics :supported-type])]
{:dispatch (if supported-type
[:open-modal :screen/onboarding.enable-biometrics]
[:open-modal :screen/onboarding.enable-notifications])}))
restore?
(assoc :effects.profile/restore-and-login profile)
(rf/defn seed-phrase-entered
{:events [:onboarding/seed-phrase-entered]}
[_ seed-phrase on-error]
{:multiaccount/validate-mnemonic [seed-phrase
(fn [mnemonic key-uid]
(re-frame/dispatch [:onboarding/seed-phrase-validated
mnemonic key-uid]))
on-error]})
(not restore?)
(assoc :effects.profile/create-and-login profile)))))
(rf/defn seed-phrase-validated
{:events [:onboarding/seed-phrase-validated]}
[{:keys [db]} seed-phrase key-uid]
(if (contains? (:profile/profiles-overview db) key-uid)
{:effects.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 (fn []
(re-frame/dispatch [:pop-to-root :screen/profile.profiles])
(re-frame/dispatch
[:profile/profile-selected key-uid]))
:on-cancel #(re-frame/dispatch [:pop-to-root :multiaccounts])}}
{:db (assoc-in db [:onboarding/profile :seed-phrase] seed-phrase)
:dispatch [:navigate-to-within-stack
[:screen/onboarding.create-profile :screen/onboarding.new-to-status]]}))
(rf/reg-event-fx
:onboarding/on-delete-profile-success
(fn [{:keys [db]} [key-uid]]
(let [multiaccounts (dissoc (:profile/profiles-overview db) key-uid)]
(merge
{:db (assoc db :profile/profiles-overview multiaccounts)}
(when-not (seq multiaccounts)
{:set-root :screen/onboarding.intro})))))
(rf/defn navigate-to-create-profile
{:events [:onboarding/navigate-to-create-profile]}
[{:keys [db]}]
;; Restart the flow
{:db (dissoc db :onboarding/profile)
:dispatch [:navigate-to-within-stack
[:screen/onboarding.create-profile :screen/onboarding.new-to-status]]})
(rf/reg-event-fx
:onboarding/password-set
(fn [{:keys [db]} [password]]
(let [supported-type (get-in db [:biometrics :supported-type])]
{:db (-> db
(assoc-in [:onboarding/profile :password] password)
(assoc-in [:onboarding/profile :auth-method] constants/auth-method-password))
:fx [[:dispatch
(if supported-type
[:navigate-to-within-stack
[:screen/onboarding.enable-biometrics :screen/onboarding.new-to-status]]
[:onboarding/create-account-and-login])]]})))
(rf/reg-event-fx :onboarding/set-auth-method
(rf/reg-event-fx
:onboarding/navigate-to-enable-biometrics
(fn [{:keys [db]}]
(let [supported-type (get-in db [:biometrics :supported-type])]
{:fx [[:dispatch
(if supported-type
[:open-modal :screen/onboarding.enable-biometrics]
[:open-modal :screen/onboarding.enable-notifications])]]})))
(rf/reg-event-fx
:onboarding/seed-phrase-entered
(fn [_ [seed-phrase on-error]]
{:multiaccount/validate-mnemonic [seed-phrase
(fn [mnemonic key-uid]
(rf/dispatch [:onboarding/seed-phrase-validated
mnemonic key-uid]))
on-error]}))
(rf/reg-event-fx
:onboarding/seed-phrase-validated
(fn [{:keys [db]} [seed-phrase key-uid]]
(if (contains? (:profile/profiles-overview db) key-uid)
{:effects.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 (fn []
(re-frame/dispatch [:pop-to-root :screen/profile.profiles])
(re-frame/dispatch
[:profile/profile-selected key-uid]))
:on-cancel #(re-frame/dispatch [:pop-to-root :multiaccounts])}}
{:db (assoc-in db [:onboarding/profile :seed-phrase] seed-phrase)
:fx [[:dispatch
[:navigate-to-within-stack
[:screen/onboarding.create-profile :screen/onboarding.new-to-status]]]]})))
(rf/reg-event-fx
:onboarding/navigate-to-create-profile
(fn [{:keys [db]}]
{:db (dissoc db :onboarding/profile)
:fx [[:dispatch
[:navigate-to-within-stack
[:screen/onboarding.create-profile :screen/onboarding.new-to-status]]]]}))
(rf/reg-event-fx
:onboarding/set-auth-method
(fn [{:keys [db]} [auth-method]]
{:db (assoc db :auth-method auth-method)}))
(rf/defn onboarding-new-account-finalize-setup
{:events [:onboarding/finalize-setup]}
[{:keys [db]}]
(let [masked-password (get-in db [:onboarding/profile :password])
key-uid (get-in db [:profile/profile :key-uid])
syncing? (get-in db [:onboarding/profile :syncing?])
auth-method (get-in db [:onboarding/profile :auth-method])
biometric-enabled? (= auth-method
constants/auth-method-biometric)]
(cond-> {:db (assoc db :onboarding/generated-keys? true)}
biometric-enabled?
(assoc :keychain/save-password-and-auth-method
{:key-uid key-uid
:masked-password (if syncing?
masked-password
(security/hash-masked-password masked-password))
:on-success (fn []
(rf/dispatch [:onboarding/set-auth-method auth-method])
(when syncing?
(rf/dispatch [:onboarding/navigate-to-enable-notifications])))
:on-error #(log/error "failed to save biometrics"
{:key-uid key-uid
:error %})}))))
(rf/reg-event-fx
:onboarding/finalize-setup
(fn [{:keys [db]}]
(let [masked-password (get-in db [:onboarding/profile :password])
key-uid (get-in db [:profile/profile :key-uid])
syncing? (get-in db [:onboarding/profile :syncing?])
auth-method (get-in db [:onboarding/profile :auth-method])
biometric-enabled? (= auth-method
constants/auth-method-biometric)]
(cond-> {:db (assoc db :onboarding/generated-keys? true)}
biometric-enabled?
(assoc :keychain/save-password-and-auth-method
{:key-uid key-uid
:masked-password (if syncing?
masked-password
(security/hash-masked-password masked-password))
:on-success (fn []
(rf/dispatch [:onboarding/set-auth-method auth-method])
(when syncing?
(rf/dispatch [:onboarding/navigate-to-enable-notifications])))
:on-error #(log/error "failed to save biometrics"
{:key-uid key-uid
:error %})})))))
(rf/defn navigate-to-identifiers
{:events [:onboarding/navigate-to-identifiers]}
[{:keys [db]}]
(if (:onboarding/generated-keys? db)
{:dispatch [:navigate-to-within-stack
[:screen/onboarding.identifiers :screen/onboarding.new-to-status]]}
{:dispatch-later [{:ms constants/onboarding-generating-keys-navigation-retry-ms
:dispatch [:onboarding/navigate-to-identifiers]}]}))
(rf/reg-event-fx
:onboarding/navigate-to-identifiers
(fn [{:keys [db]}]
{:fx [(if (:onboarding/generated-keys? db)
[:dispatch
[:navigate-to-within-stack
[:screen/onboarding.identifiers :screen/onboarding.new-to-status]]]
[:dispatch-later
[{:ms constants/onboarding-generating-keys-navigation-retry-ms
:dispatch [:onboarding/navigate-to-identifiers]}]])]}))
@@ -1,21 +1,11 @@
(ns status-im.contexts.profile.create.events
(:require
[native-module.core :as native-module]
[status-im.common.emoji-picker.utils :as emoji-picker.utils]
[status-im.contexts.profile.config :as profile.config]
status-im.contexts.profile.create.effects
[utils.re-frame :as rf]
[utils.security.core :as security]))
[status-im.contexts.profile.utils :as profile.utils]
[utils.re-frame :as rf]))
(rf/defn create-profile-and-login
{:events [:profile.create/create-and-login]}
[{:keys [db]} {:keys [display-name password image-path color]}]
(let [login-sha3-password (native-module/sha3 (security/safe-unmask-data password))]
{:db (assoc-in db [:syncing :login-sha3-password] login-sha3-password)
:effects.profile/create-and-login
(assoc (profile.config/create)
:displayName display-name
:password login-sha3-password
:imagePath (profile.config/strip-file-prefix image-path)
:customizationColor color
:emoji (emoji-picker.utils/random-emoji))}))
(rf/reg-event-fx :profile.create/create-and-login
(fn [{:keys [db]} [profile]]
(let [{:keys [password] :as profile} (profile.utils/create-profile-config profile false)]
{:db (assoc-in db [:syncing :login-sha3-password] password)
:effects.profile/create-and-login profile})))
@@ -35,27 +35,24 @@
(native-module.pn/add-listener "remoteNotificationReceived"
#(handle-notification-press (transforms/json->clj %)))))
(rf/defn handle-enable-notifications-event
{:events [:push-notifications/registered-for-push-notifications]}
[_ token]
{:json-rpc/call [{:method "wakuext_registerForPushNotifications"
:params [token (if platform/ios? config/apn-topic)
(if platform/ios? apn-token-type firebase-token-type)]
:on-success #(log/info "[push-notifications] register-success" %)
:on-error #(log/info "[push-notifications] register-error" %)}]})
(rf/reg-event-fx :push-notifications/registered-for-push-notifications
(fn [_ [token]]
{:json-rpc/call [{:method "wakuext_registerForPushNotifications"
:params [token (if platform/ios? config/apn-topic)
(if platform/ios? apn-token-type firebase-token-type)]
:on-success #(log/info "[push-notifications] register-success" %)
:on-error #(log/info "[push-notifications] register-error" %)}]}))
(rf/defn handle-disable-notifications-event
{:events [:push-notifications/unregistered-from-push-notifications]}
[_]
{:json-rpc/call [{:method "wakuext_unregisterFromPushNotifications"
:params []
:on-success #(log/info "[push-notifications] unregister-success" %)
:on-error #(log/info "[push-notifications] unregister-error" %)}]})
(rf/reg-event-fx :push-notifications/unregistered-from-push-notifications
(fn [_]
{:json-rpc/call [{:method "wakuext_unregisterFromPushNotifications"
:params []
:on-success #(log/info "[push-notifications] unregister-success" %)
:on-error #(log/info "[push-notifications] unregister-error" %)}]}))
(rf/defn handle-preferences-load
{:events [:push-notifications/preferences-loaded]}
[{:keys [db]} preferences]
{:db (assoc db :push-notifications/preferences preferences)})
(rf/reg-event-fx :push-notifications/preferences-loaded
(fn [{:keys [db]} [preferences]]
{:db (assoc db :push-notifications/preferences preferences)}))
(re-frame/reg-fx :push-notifications/load-preferences
(fn []
@@ -4,8 +4,7 @@
[react-native.platform :as platform]
[status-im.constants :as constants]
status-im.contexts.profile.push-notifications.local.effects
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
[utils.i18n :as i18n]))
(def ^:private push-notification-types
#{"transaction" "message"})
@@ -43,7 +42,7 @@
:body-type
bodyType))
(rf/defn process
(defn process
[cofx {:keys [bodyType] :as event}]
(if (push-notification-types bodyType)
(if platform/ios?
@@ -1,27 +1,13 @@
(ns status-im.contexts.profile.recover.events
(:require
[native-module.core :as native-module]
[status-im.common.emoji-picker.utils :as emoji-picker.utils]
[status-im.contexts.profile.config :as profile.config]
status-im.contexts.profile.recover.effects
[utils.re-frame :as rf]
[utils.security.core :as security]))
[status-im.contexts.profile.utils :as profile.utils]
[utils.re-frame :as rf]))
(rf/defn recover-profile-and-login
{:events [:profile.recover/recover-and-login]}
[{:keys [db]} {:keys [display-name password image-path color seed-phrase]}]
(let [login-sha3-password (native-module/sha3 (security/safe-unmask-data password))]
{:db
(-> db
(assoc :onboarding/recovered-account? true)
(assoc-in [:syncing :login-sha3-password] login-sha3-password))
:effects.profile/restore-and-login
(merge (profile.config/create)
{:displayName display-name
:mnemonic (security/safe-unmask-data seed-phrase)
:password login-sha3-password
:imagePath (profile.config/strip-file-prefix image-path)
:customizationColor color
:emoji (emoji-picker.utils/random-emoji)
:fetchBackup true})}))
(rf/reg-event-fx :profile.create/recover-and-login
(fn [{:keys [db]} [profile]]
(let [{:keys [password] :as profile} (profile.utils/create-profile-config profile true)]
{:db (-> db
(assoc :onboarding/recovered-account? true)
(assoc-in [:syncing :login-sha3-password] password))
:effects.profile/create-and-login profile})))
+21 -1
View File
@@ -1,5 +1,9 @@
(ns status-im.contexts.profile.utils
(:require [clojure.string :as string]))
(:require [clojure.string :as string]
[native-module.core :as native-module]
[status-im.common.emoji-picker.utils :as emoji-picker.utils]
[status-im.contexts.profile.config :as profile.config]
[utils.security.core :as security]))
(defn displayed-name
[{:keys [name display-name preferred-name alias ens-verified primary-name]}]
@@ -20,3 +24,19 @@
(or (:large images)
(:thumbnail images)
(first images)))
(defn create-profile-config
[{:keys [display-name seed-phrase password image-path color]} restore?]
(let [login-sha3-password (native-module/sha3 (security/safe-unmask-data password))]
(cond-> (profile.config/create)
true
(merge {:displayName display-name
:password login-sha3-password
:imagePath (profile.config/strip-file-prefix image-path)
:customizationColor color
:emoji (emoji-picker.utils/random-emoji)})
restore?
(merge {:mnemonic (security/safe-unmask-data seed-phrase)
:fetchBackup true}))))
+60 -65
View File
@@ -13,15 +13,13 @@
[utils.security.core :as security]
[utils.transforms :as transforms]))
(rf/defn local-pairing-update-role
{:events [:syncing/update-role]}
[{:keys [db]} role]
{:db (assoc-in db [:syncing :role] role)})
(rf/reg-event-fx :syncing/update-role
(fn [{:keys [db]} [role]]
{:db (assoc-in db [:syncing :role] role)}))
(rf/defn local-pairing-clear-states
{:events [:syncing/clear-states]}
[{:keys [db]} role]
{:db (dissoc db :syncing)})
(rf/reg-event-fx :syncing/clear-states
(fn [{:keys [db]}]
{:db (dissoc db :syncing)}))
(defn- get-default-node-config
[installation-id]
@@ -52,62 +50,59 @@
{:type :negative
:text error}]))))
(rf/defn preflight-outbound-check-for-local-pairing
{:events [:syncing/preflight-outbound-check]}
[_ set-checks-passed]
(let [callback
(fn [raw-response]
(log/info "Local pairing preflight check"
{:response raw-response
:event :syncing/preflight-outbound-check})
(let [^js response-js (transforms/json->js raw-response)
error (transforms/js->clj (.-error response-js))]
(set-checks-passed (empty? error))))]
(native-module/local-pairing-preflight-outbound-check callback)))
(rf/reg-event-fx :syncing/preflight-outbound-check
(fn [_ [set-checks-passed]]
(let [callback
(fn [raw-response]
(log/info "Local pairing preflight check"
{:response raw-response
:event :syncing/preflight-outbound-check})
(let [^js response-js (transforms/json->js raw-response)
error (transforms/js->clj (.-error response-js))]
(set-checks-passed (empty? error))))]
(native-module/local-pairing-preflight-outbound-check callback))))
(rf/defn initiate-local-pairing-with-connection-string
{:events [:syncing/input-connection-string-for-bootstrapping]
:interceptors [(re-frame/inject-cofx :random-guid-generator)]}
[{:keys [random-guid-generator db]} connection-string]
(let [installation-id (random-guid-generator)
default-node-config (get-default-node-config installation-id)
default-node-config-string (.stringify js/JSON (clj->js default-node-config))
callback
(fn [final-node-config]
(let [config-map (.stringify js/JSON
(clj->js
{:receiverConfig
{:kdfIterations config/default-kdf-iterations
:nodeConfig final-node-config
:settingCurrentNetwork config/default-network
:deviceType platform/os
:deviceName
(native-module/get-installation-name)}}))]
(rf/dispatch [:syncing/update-role constants/local-pairing-role-receiver])
(native-module/input-connection-string-for-bootstrapping
connection-string
config-map
input-connection-string-callback)))]
(native-module/prepare-dir-and-update-config "" default-node-config-string callback)))
(rf/reg-event-fx :syncing/input-connection-string-for-bootstrapping
[(re-frame/inject-cofx :random-guid-generator)]
(fn [{:keys [random-guid-generator]} [connection-string]]
(let [installation-id (random-guid-generator)
default-node-config (get-default-node-config installation-id)
default-node-config-string (.stringify js/JSON (clj->js default-node-config))
callback
(fn [final-node-config]
(let [config-map (.stringify js/JSON
(clj->js
{:receiverConfig
{:kdfIterations config/default-kdf-iterations
:nodeConfig final-node-config
:settingCurrentNetwork config/default-network
:deviceType platform/os
:deviceName
(native-module/get-installation-name)}}))]
(rf/dispatch [:syncing/update-role constants/local-pairing-role-receiver])
(native-module/input-connection-string-for-bootstrapping
connection-string
config-map
input-connection-string-callback)))]
(native-module/prepare-dir-and-update-config "" default-node-config-string callback))))
(rf/defn preparations-for-connection-string
{:events [:syncing/get-connection-string]}
[{:keys [db] :as cofx} sha3-pwd on-valid-connection-string]
(let [error (get-in db [:profile/login :error])
handle-connection (fn [response]
(when (sync-utils/valid-connection-string? response)
(on-valid-connection-string response)
(rf/dispatch [:syncing/update-role constants/local-pairing-role-sender])
(rf/dispatch [:hide-bottom-sheet])))]
(when-not (and error (string/blank? error))
(let [key-uid (get-in db [:profile/profile :key-uid])
config-map (.stringify js/JSON
(clj->js {:senderConfig {:keyUID key-uid
:keystorePath ""
:password (security/safe-unmask-data
sha3-pwd)
:deviceType platform/os}
:serverConfig {:timeout 0}}))]
(native-module/get-connection-string-for-bootstrapping-another-device
config-map
handle-connection)))))
(rf/reg-event-fx :syncing/get-connection-string
(fn [{:keys [db]} [sha3-pwd on-valid-connection-string]]
(let [error (get-in db [:profile/login :error])
handle-connection (fn [response]
(when (sync-utils/valid-connection-string? response)
(on-valid-connection-string response)
(rf/dispatch [:syncing/update-role constants/local-pairing-role-sender])
(rf/dispatch [:hide-bottom-sheet])))]
(when-not (and error (string/blank? error))
(let [key-uid (get-in db [:profile/profile :key-uid])
config-map (.stringify js/JSON
(clj->js {:senderConfig {:keyUID key-uid
:keystorePath ""
:password (security/safe-unmask-data
sha3-pwd)
:deviceType platform/os}
:serverConfig {:timeout 0}}))]
(native-module/get-connection-string-for-bootstrapping-another-device
config-map
handle-connection))))))