fix(@desktop/onboarding): cannot run any keycard flow after creating a Keycard replacement
Fixes: #11494
This commit is contained in:
parent
1a7532d92c
commit
51edc1b256
|
@ -1,4 +1,4 @@
|
||||||
import NimQml, sequtils, chronicles, os, uuids
|
import NimQml, sequtils, sugar, chronicles, os, uuids
|
||||||
|
|
||||||
import ../../app_service/service/general/service as general_service
|
import ../../app_service/service/general/service as general_service
|
||||||
import ../../app_service/service/keychain/service as keychain_service
|
import ../../app_service/service/keychain/service as keychain_service
|
||||||
|
@ -50,6 +50,7 @@ type
|
||||||
AppController* = ref object of RootObj
|
AppController* = ref object of RootObj
|
||||||
storeDefaultKeyPair: bool
|
storeDefaultKeyPair: bool
|
||||||
syncKeycardBasedOnAppWalletState: bool
|
syncKeycardBasedOnAppWalletState: bool
|
||||||
|
applyKeycardReplacement: bool
|
||||||
changedKeycardUids: seq[tuple[oldKcUid: string, newKcUid: string]] # used in case user unlocked keycard during onboarding using seed phrase
|
changedKeycardUids: seq[tuple[oldKcUid: string, newKcUid: string]] # used in case user unlocked keycard during onboarding using seed phrase
|
||||||
statusFoundation: StatusFoundation
|
statusFoundation: StatusFoundation
|
||||||
notificationsManager*: NotificationsManager
|
notificationsManager*: NotificationsManager
|
||||||
|
@ -108,7 +109,7 @@ type
|
||||||
proc load(self: AppController)
|
proc load(self: AppController)
|
||||||
proc buildAndRegisterLocalAccountSensitiveSettings(self: AppController)
|
proc buildAndRegisterLocalAccountSensitiveSettings(self: AppController)
|
||||||
proc buildAndRegisterUserProfile(self: AppController)
|
proc buildAndRegisterUserProfile(self: AppController)
|
||||||
proc tryKeycardSyncWithTheAppState(self: AppController)
|
proc applyNecessaryActionsAfterLoggingIn(self: AppController)
|
||||||
|
|
||||||
# Startup Module Delegate Interface
|
# Startup Module Delegate Interface
|
||||||
proc startupDidLoad*(self: AppController)
|
proc startupDidLoad*(self: AppController)
|
||||||
|
@ -117,6 +118,7 @@ proc logout*(self: AppController)
|
||||||
proc finishAppLoading*(self: AppController)
|
proc finishAppLoading*(self: AppController)
|
||||||
proc storeDefaultKeyPairForNewKeycardUser*(self: AppController)
|
proc storeDefaultKeyPairForNewKeycardUser*(self: AppController)
|
||||||
proc syncKeycardBasedOnAppWalletStateAfterLogin*(self: AppController)
|
proc syncKeycardBasedOnAppWalletStateAfterLogin*(self: AppController)
|
||||||
|
proc applyKeycardReplacementAfterLogin*(self: AppController)
|
||||||
proc addToKeycardUidPairsToCheckForAChangeAfterLogin*(self: AppController, oldKeycardUid: string, newKeycardUid: string)
|
proc addToKeycardUidPairsToCheckForAChangeAfterLogin*(self: AppController, oldKeycardUid: string, newKeycardUid: string)
|
||||||
proc removeAllKeycardUidPairsForCheckingForAChangeAfterLogin*(self: AppController)
|
proc removeAllKeycardUidPairsForCheckingForAChangeAfterLogin*(self: AppController)
|
||||||
|
|
||||||
|
@ -142,8 +144,9 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
|
||||||
result = AppController()
|
result = AppController()
|
||||||
result.storeDefaultKeyPair = false
|
result.storeDefaultKeyPair = false
|
||||||
result.syncKeycardBasedOnAppWalletState = false
|
result.syncKeycardBasedOnAppWalletState = false
|
||||||
|
result.applyKeycardReplacement = false
|
||||||
result.statusFoundation = statusFoundation
|
result.statusFoundation = statusFoundation
|
||||||
|
|
||||||
# Preparing settings service to be exposed later as global QObject
|
# Preparing settings service to be exposed later as global QObject
|
||||||
result.settingsService = settings_service.newService(statusFoundation.events)
|
result.settingsService = settings_service.newService(statusFoundation.events)
|
||||||
result.appSettingsVariant = newQVariant(result.settingsService)
|
result.appSettingsVariant = newQVariant(result.settingsService)
|
||||||
|
@ -154,7 +157,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
|
||||||
result.localAccountSettingsVariant = newQVariant(singletonInstance.localAccountSettings)
|
result.localAccountSettingsVariant = newQVariant(singletonInstance.localAccountSettings)
|
||||||
result.localAccountSensitiveSettingsVariant = newQVariant(singletonInstance.localAccountSensitiveSettings)
|
result.localAccountSensitiveSettingsVariant = newQVariant(singletonInstance.localAccountSensitiveSettings)
|
||||||
result.userProfileVariant = newQVariant(singletonInstance.userProfile)
|
result.userProfileVariant = newQVariant(singletonInstance.userProfile)
|
||||||
result.globalUtilsVariant = newQVariant(singletonInstance.utils)
|
result.globalUtilsVariant = newQVariant(singletonInstance.utils)
|
||||||
|
|
||||||
# Services
|
# Services
|
||||||
result.generalService = general_service.newService(statusFoundation.events, statusFoundation.threadpool)
|
result.generalService = general_service.newService(statusFoundation.events, statusFoundation.threadpool)
|
||||||
|
@ -163,11 +166,11 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
|
||||||
result.nodeConfigurationService = node_configuration_service.newService(statusFoundation.fleetConfiguration,
|
result.nodeConfigurationService = node_configuration_service.newService(statusFoundation.fleetConfiguration,
|
||||||
result.settingsService, statusFoundation.events)
|
result.settingsService, statusFoundation.events)
|
||||||
result.keychainService = keychain_service.newService(statusFoundation.events)
|
result.keychainService = keychain_service.newService(statusFoundation.events)
|
||||||
result.accountsService = accounts_service.newService(statusFoundation.events, statusFoundation.threadpool,
|
result.accountsService = accounts_service.newService(statusFoundation.events, statusFoundation.threadpool,
|
||||||
statusFoundation.fleetConfiguration)
|
statusFoundation.fleetConfiguration)
|
||||||
result.networkService = network_service.newService(statusFoundation.events, result.settingsService)
|
result.networkService = network_service.newService(statusFoundation.events, result.settingsService)
|
||||||
result.contactsService = contacts_service.newService(
|
result.contactsService = contacts_service.newService(
|
||||||
statusFoundation.events, statusFoundation.threadpool, result.networkService, result.settingsService,
|
statusFoundation.events, statusFoundation.threadpool, result.networkService, result.settingsService,
|
||||||
result.activityCenterService
|
result.activityCenterService
|
||||||
)
|
)
|
||||||
result.chatService = chat_service.newService(statusFoundation.events, statusFoundation.threadpool, result.contactsService)
|
result.chatService = chat_service.newService(statusFoundation.events, statusFoundation.threadpool, result.contactsService)
|
||||||
|
@ -386,7 +389,7 @@ proc startupDidLoad*(self: AppController) =
|
||||||
self.startupModule.startUpUIRaised()
|
self.startupModule.startUpUIRaised()
|
||||||
|
|
||||||
proc mainDidLoad*(self: AppController) =
|
proc mainDidLoad*(self: AppController) =
|
||||||
self.tryKeycardSyncWithTheAppState()
|
self.applyNecessaryActionsAfterLoggingIn()
|
||||||
self.startupModule.moveToAppState()
|
self.startupModule.moveToAppState()
|
||||||
self.checkForStoringPasswordToKeychain()
|
self.checkForStoringPasswordToKeychain()
|
||||||
|
|
||||||
|
@ -509,15 +512,49 @@ proc buildAndRegisterUserProfile(self: AppController) =
|
||||||
|
|
||||||
singletonInstance.engine.setRootContextProperty("userProfile", self.userProfileVariant)
|
singletonInstance.engine.setRootContextProperty("userProfile", self.userProfileVariant)
|
||||||
|
|
||||||
proc tryKeycardSyncWithTheAppState(self: AppController) =
|
proc doKeycardReplacement(self: AppController) =
|
||||||
|
let keyUid = singletonInstance.userProfile.getKeyUid()
|
||||||
|
let keypair = self.walletAccountService.getKeypairByKeyUid(keyUid)
|
||||||
|
if keypair.isNil:
|
||||||
|
error "cannot resolve appropriate keypair for logged in user"
|
||||||
|
return
|
||||||
|
let (_, flowEvent) = self.keycardService.getLastReceivedKeycardData()
|
||||||
|
let instanceUid = flowEvent.instanceUID
|
||||||
|
let pin = self.startupModule.getPin()
|
||||||
|
if instanceUid.len == 0 or
|
||||||
|
keyUid != flowEvent.keyUid or
|
||||||
|
pin.len != PINLengthForStatusApp:
|
||||||
|
info "keycard replacement process is not fully completed, try the same again"
|
||||||
|
return
|
||||||
|
# we have to delete all keycards with the same key uid to cover the case if user had more then a single keycard for the same keypair
|
||||||
|
discard self.walletAccountService.deleteAllKeycardsWithKeyUid(singletonInstance.userProfile.getKeyUid())
|
||||||
|
# store new keycard with accounts, in this context no need to check if accounts match the default Status derivation path,
|
||||||
|
# cause otherwise we wouldn't be here (cannot have keycard profile with any such path)
|
||||||
|
let accountsAddresses = keypair.accounts.filter(acc => not acc.isChat).map(acc => acc.address)
|
||||||
|
let keycard = KeycardDto(
|
||||||
|
keycardUid: instanceUid,
|
||||||
|
keycardName: keypair.name,
|
||||||
|
keyUid: keyUid,
|
||||||
|
accountsAddresses: accountsAddresses
|
||||||
|
)
|
||||||
|
discard self.walletAccountService.addKeycardOrAccounts(keycard, accountsComingFromKeycard = true)
|
||||||
|
# store metadata to a Keycard
|
||||||
|
let accountsPathsToStore = keypair.accounts.filter(acc => not acc.isChat).map(acc => acc.path)
|
||||||
|
self.keycardService.startStoreMetadataFlow(keypair.name, self.startupModule.getPin(), accountsPathsToStore)
|
||||||
|
info "keycard replacement fully done"
|
||||||
|
|
||||||
|
proc applyNecessaryActionsAfterLoggingIn(self: AppController) =
|
||||||
|
if self.applyKeycardReplacement:
|
||||||
|
self.doKeycardReplacement()
|
||||||
|
return
|
||||||
############################################################################## store def kc sync with app kc uid
|
############################################################################## store def kc sync with app kc uid
|
||||||
## Onboarding flows sync keycard state after login keypair | (inc. kp store) | update
|
## Onboarding flows sync keycard state after login keypair | (inc. kp store) | update
|
||||||
## `I’m new to Status` -> `Generate new keys` -> na | na | na
|
## `I’m new to Status` -> `Generate new keys` -> na | na | na
|
||||||
## `I’m new to Status` -> `Generate keys for a new Keycard` -> yes | no | no
|
## `I’m new to Status` -> `Generate keys for a new Keycard` -> yes | no | no
|
||||||
## `I’m new to Status` -> `Import a seed phrase` -> `Import a seed phrase` -> na | na | na
|
## `I’m new to Status` -> `Import a seed phrase` -> `Import a seed phrase` -> na | na | na
|
||||||
## `I’m new to Status` -> `Import a seed phrase` -> `Import a seed phrase into a new Keycard` -> yes | no | no
|
## `I’m new to Status` -> `Import a seed phrase` -> `Import a seed phrase into a new Keycard` -> yes | no | no
|
||||||
##
|
##
|
||||||
## `I already use Status` -> `Scan sync code` -> flow not developed yet
|
## `I already use Status` -> `Scan sync code` -> flow not developed yet
|
||||||
## `I already use Status` -> `I don’t have other device` -> `Login with Keycard` (fetched) -> no | yes | no
|
## `I already use Status` -> `I don’t have other device` -> `Login with Keycard` (fetched) -> no | yes | no
|
||||||
## `I already use Status` -> `I don’t have other device` -> `Login with Keycard` (unlock via puk, fetched) -> no | yes | no
|
## `I already use Status` -> `I don’t have other device` -> `Login with Keycard` (unlock via puk, fetched) -> no | yes | no
|
||||||
## `I already use Status` -> `I don’t have other device` -> `Login with Keycard` (unlock via seed phrase, fetched) -> no | yes | yes (kc details should be fetched and set to db while recovering, that's the reason why)
|
## `I already use Status` -> `I don’t have other device` -> `Login with Keycard` (unlock via seed phrase, fetched) -> no | yes | yes (kc details should be fetched and set to db while recovering, that's the reason why)
|
||||||
|
@ -525,16 +562,16 @@ proc tryKeycardSyncWithTheAppState(self: AppController) =
|
||||||
## `I already use Status` -> `I don’t have other device` -> `Login with Keycard` (unlock via puk, not fetched) -> no | yes | no
|
## `I already use Status` -> `I don’t have other device` -> `Login with Keycard` (unlock via puk, not fetched) -> no | yes | no
|
||||||
## `I already use Status` -> `I don’t have other device` -> `Login with Keycard` (unlock via seed phrase, not fetched) -> no | yes | no
|
## `I already use Status` -> `I don’t have other device` -> `Login with Keycard` (unlock via seed phrase, not fetched) -> no | yes | no
|
||||||
## `I already use Status` -> `I don’t have other device` -> `Enter a seed phrase` -> na | na | na
|
## `I already use Status` -> `I don’t have other device` -> `Enter a seed phrase` -> na | na | na
|
||||||
##
|
##
|
||||||
## `Login` -> na | na | na
|
## `Login` -> na | na | na
|
||||||
## `Login` -> if card was unlocked via puk -> na | na | na
|
## `Login` -> if card was unlocked via puk -> na | na | na
|
||||||
## `Login` -> if card was unlocked via seed phrase -> no | no | yes
|
## `Login` -> if card was unlocked via seed phrase -> no | no | yes
|
||||||
## `Login` -> `Create replacement Keycard with seed phrase` -> no | yes | no (we don't know which kc is replaced if user has more kc for the same kp)
|
## `Login` -> `Create replacement Keycard with seed phrase` -> no | yes | no (we don't know which kc is replaced if user has more kc for the same kp)
|
||||||
##############################################################################
|
##############################################################################
|
||||||
if singletonInstance.userProfile.getIsKeycardUser() or
|
if singletonInstance.userProfile.getIsKeycardUser() or
|
||||||
self.syncKeycardBasedOnAppWalletState:
|
self.syncKeycardBasedOnAppWalletState:
|
||||||
let data = SharedKeycarModuleArgs(
|
let data = SharedKeycarModuleArgs(
|
||||||
pin: self.startupModule.getPin(),
|
pin: self.startupModule.getPin(),
|
||||||
keyUid: singletonInstance.userProfile.getKeyUid()
|
keyUid: singletonInstance.userProfile.getKeyUid()
|
||||||
)
|
)
|
||||||
self.statusFoundation.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_TRY_KEYCARD_SYNC, data)
|
self.statusFoundation.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_TRY_KEYCARD_SYNC, data)
|
||||||
|
@ -545,14 +582,17 @@ proc tryKeycardSyncWithTheAppState(self: AppController) =
|
||||||
discard self.walletAccountService.updateKeycardUid(oldUid, newUid)
|
discard self.walletAccountService.updateKeycardUid(oldUid, newUid)
|
||||||
discard self.walletAccountService.setKeycardUnlocked(singletonInstance.userProfile.getKeyUid(), newUid)
|
discard self.walletAccountService.setKeycardUnlocked(singletonInstance.userProfile.getKeyUid(), newUid)
|
||||||
|
|
||||||
proc storeDefaultKeyPairForNewKeycardUser*(self: AppController) =
|
proc storeDefaultKeyPairForNewKeycardUser*(self: AppController) =
|
||||||
self.storeDefaultKeyPair = true
|
self.storeDefaultKeyPair = true
|
||||||
|
|
||||||
proc syncKeycardBasedOnAppWalletStateAfterLogin*(self: AppController) =
|
proc syncKeycardBasedOnAppWalletStateAfterLogin*(self: AppController) =
|
||||||
self.syncKeycardBasedOnAppWalletState = true
|
self.syncKeycardBasedOnAppWalletState = true
|
||||||
|
|
||||||
proc addToKeycardUidPairsToCheckForAChangeAfterLogin*(self: AppController, oldKeycardUid: string, newKeycardUid: string) =
|
proc applyKeycardReplacementAfterLogin*(self: AppController) =
|
||||||
|
self.applyKeycardReplacement = true
|
||||||
|
|
||||||
|
proc addToKeycardUidPairsToCheckForAChangeAfterLogin*(self: AppController, oldKeycardUid: string, newKeycardUid: string) =
|
||||||
self.changedKeycardUids.add((oldKcUid: oldKeycardUid, newKcUid: newKeycardUid))
|
self.changedKeycardUids.add((oldKcUid: oldKeycardUid, newKcUid: newKeycardUid))
|
||||||
|
|
||||||
proc removeAllKeycardUidPairsForCheckingForAChangeAfterLogin*(self: AppController) =
|
proc removeAllKeycardUidPairsForCheckingForAChangeAfterLogin*(self: AppController) =
|
||||||
self.changedKeycardUids = @[]
|
self.changedKeycardUids = @[]
|
||||||
|
|
|
@ -463,9 +463,9 @@ proc loginLocalPairingAccount*(self: Controller) =
|
||||||
kcEvent.encryptionKey.publicKey = self.localPairingStatus.password
|
kcEvent.encryptionKey.publicKey = self.localPairingStatus.password
|
||||||
discard self.accountsService.loginAccountKeycard(self.localPairingStatus.account, kcEvent)
|
discard self.accountsService.loginAccountKeycard(self.localPairingStatus.account, kcEvent)
|
||||||
|
|
||||||
proc loginAccountKeycard*(self: Controller, storeToKeychainValue: string, syncWalletAfterLogin = false) =
|
proc loginAccountKeycard*(self: Controller, storeToKeychainValue: string, keycardReplacement = false) =
|
||||||
if syncWalletAfterLogin:
|
if keycardReplacement:
|
||||||
self.syncKeycardBasedOnAppWalletStateAfterLogin()
|
self.delegate.applyKeycardReplacementAfterLogin()
|
||||||
singletonInstance.localAccountSettings.setStoreToKeychainValue(storeToKeychainValue)
|
singletonInstance.localAccountSettings.setStoreToKeychainValue(storeToKeychainValue)
|
||||||
self.delegate.moveToLoadingAppState()
|
self.delegate.moveToLoadingAppState()
|
||||||
let selAcc = self.getSelectedLoginAccount()
|
let selAcc = self.getSelectedLoginAccount()
|
||||||
|
|
|
@ -17,7 +17,7 @@ method executePrimaryCommand*(self: BiometricsState, controller: Controller) =
|
||||||
elif self.flowType == FlowType.FirstRunNewUserImportSeedPhrase:
|
elif self.flowType == FlowType.FirstRunNewUserImportSeedPhrase:
|
||||||
controller.storeImportedAccountAndLogin(storeToKeychain)
|
controller.storeImportedAccountAndLogin(storeToKeychain)
|
||||||
elif self.flowType == FlowType.FirstRunOldUserImportSeedPhrase:
|
elif self.flowType == FlowType.FirstRunOldUserImportSeedPhrase:
|
||||||
## This should not be the correct call for this flow, this is an issue,
|
## This should not be the correct call for this flow, this is an issue,
|
||||||
## but since current implementation is like that and this is not a bug fixing issue, left as it is.
|
## but since current implementation is like that and this is not a bug fixing issue, left as it is.
|
||||||
controller.storeImportedAccountAndLogin(storeToKeychain)
|
controller.storeImportedAccountAndLogin(storeToKeychain)
|
||||||
elif self.flowType == FlowType.FirstRunNewUserNewKeycardKeys:
|
elif self.flowType == FlowType.FirstRunNewUserNewKeycardKeys:
|
||||||
|
@ -39,7 +39,7 @@ method executeSecondaryCommand*(self: BiometricsState, controller: Controller) =
|
||||||
elif self.flowType == FlowType.FirstRunNewUserImportSeedPhrase:
|
elif self.flowType == FlowType.FirstRunNewUserImportSeedPhrase:
|
||||||
controller.storeImportedAccountAndLogin(storeToKeychain)
|
controller.storeImportedAccountAndLogin(storeToKeychain)
|
||||||
elif self.flowType == FlowType.FirstRunOldUserImportSeedPhrase:
|
elif self.flowType == FlowType.FirstRunOldUserImportSeedPhrase:
|
||||||
## This should not be the correct call for this flow, this is an issue,
|
## This should not be the correct call for this flow, this is an issue,
|
||||||
## but since current implementation is like that and this is not a bug fixing issue, left as it is.
|
## but since current implementation is like that and this is not a bug fixing issue, left as it is.
|
||||||
controller.storeImportedAccountAndLogin(storeToKeychain)
|
controller.storeImportedAccountAndLogin(storeToKeychain)
|
||||||
elif self.flowType == FlowType.FirstRunNewUserNewKeycardKeys:
|
elif self.flowType == FlowType.FirstRunNewUserNewKeycardKeys:
|
||||||
|
@ -54,13 +54,13 @@ method executeSecondaryCommand*(self: BiometricsState, controller: Controller) =
|
||||||
elif self.flowType == FlowType.LostKeycardConvertToRegularAccount:
|
elif self.flowType == FlowType.LostKeycardConvertToRegularAccount:
|
||||||
controller.loginAccountKeycardUsingSeedPhrase(storeToKeychain)
|
controller.loginAccountKeycardUsingSeedPhrase(storeToKeychain)
|
||||||
|
|
||||||
method resolveKeycardNextState*(self: BiometricsState, keycardFlowType: string, keycardEvent: KeycardEvent,
|
method resolveKeycardNextState*(self: BiometricsState, keycardFlowType: string, keycardEvent: KeycardEvent,
|
||||||
controller: Controller): State =
|
controller: Controller): State =
|
||||||
if self.flowType == FlowType.LostKeycardReplacement:
|
if self.flowType == FlowType.LostKeycardReplacement:
|
||||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
||||||
keycardEvent.error.len == 0:
|
keycardEvent.error.len == 0:
|
||||||
controller.setKeycardEvent(keycardEvent)
|
controller.setKeycardEvent(keycardEvent)
|
||||||
var storeToKeychainValue = LS_VALUE_NEVER
|
var storeToKeychainValue = LS_VALUE_NEVER
|
||||||
if self.storeToKeychain:
|
if self.storeToKeychain:
|
||||||
storeToKeychainValue = LS_VALUE_NOT_NOW
|
storeToKeychainValue = LS_VALUE_NOT_NOW
|
||||||
controller.loginAccountKeycard(storeToKeychainValue, syncWalletAfterLogin = true)
|
controller.loginAccountKeycard(storeToKeychainValue, keycardReplacement = true)
|
|
@ -51,16 +51,16 @@ method executePrimaryCommand*(self: KeycardPinSetState, controller: Controller)
|
||||||
return
|
return
|
||||||
controller.startLoginFlowAutomatically(controller.getPin())
|
controller.startLoginFlowAutomatically(controller.getPin())
|
||||||
|
|
||||||
method resolveKeycardNextState*(self: KeycardPinSetState, keycardFlowType: string, keycardEvent: KeycardEvent,
|
method resolveKeycardNextState*(self: KeycardPinSetState, keycardFlowType: string, keycardEvent: KeycardEvent,
|
||||||
controller: Controller): State =
|
controller: Controller): State =
|
||||||
if self.flowType == FlowType.LostKeycardReplacement:
|
if self.flowType == FlowType.LostKeycardReplacement:
|
||||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
||||||
keycardEvent.error.len == 0:
|
keycardEvent.error.len == 0:
|
||||||
controller.setKeycardEvent(keycardEvent)
|
controller.setKeycardEvent(keycardEvent)
|
||||||
controller.loginAccountKeycard(storeToKeychainValue = LS_VALUE_NOT_NOW, syncWalletAfterLogin = true)
|
controller.loginAccountKeycard(storeToKeychainValue = LS_VALUE_NOT_NOW, keycardReplacement = true)
|
||||||
if self.flowType == FlowType.AppLogin:
|
if self.flowType == FlowType.AppLogin:
|
||||||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
|
||||||
keycardEvent.error.len == 0:
|
keycardEvent.error.len == 0:
|
||||||
# we are here in case of recover account from the login flow using seed phrase
|
# we are here in case of recover account from the login flow using seed phrase
|
||||||
controller.setKeycardEvent(keycardEvent)
|
controller.setKeycardEvent(keycardEvent)
|
||||||
controller.loginAccountKeycard(storeToKeychainValue = LS_VALUE_NEVER, syncWalletAfterLogin = false)
|
controller.loginAccountKeycard(storeToKeychainValue = LS_VALUE_NEVER, keycardReplacement = false)
|
|
@ -42,7 +42,7 @@ method moveToStartupState*(self: AccessInterface) {.base.} =
|
||||||
|
|
||||||
method onBackActionClicked*(self: AccessInterface) {.base.} =
|
method onBackActionClicked*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method onPrimaryActionClicked*(self: AccessInterface) {.base.} =
|
method onPrimaryActionClicked*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
@ -151,14 +151,17 @@ method storeDefaultKeyPairForNewKeycardUser*(self: AccessInterface) {.base.} =
|
||||||
method syncKeycardBasedOnAppWalletStateAfterLogin*(self: AccessInterface) {.base.} =
|
method syncKeycardBasedOnAppWalletStateAfterLogin*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method addToKeycardUidPairsToCheckForAChangeAfterLogin*(self: AccessInterface, oldKeycardUid: string,
|
method applyKeycardReplacementAfterLogin*(self: AccessInterface) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method addToKeycardUidPairsToCheckForAChangeAfterLogin*(self: AccessInterface, oldKeycardUid: string,
|
||||||
newKeycardUid: string) {.base.} =
|
newKeycardUid: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method removeAllKeycardUidPairsForCheckingForAChangeAfterLogin*(self: AccessInterface) {.base.} =
|
method removeAllKeycardUidPairsForCheckingForAChangeAfterLogin*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method onFetchingFromWakuMessageReceived*(self: AccessInterface, backedUpMsgClock: uint64, section: string,
|
method onFetchingFromWakuMessageReceived*(self: AccessInterface, backedUpMsgClock: uint64, section: string,
|
||||||
totalMessages: int, loadedMessages: int) {.base.} =
|
totalMessages: int, loadedMessages: int) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
@ -197,5 +200,6 @@ type
|
||||||
c.finishAppLoading()
|
c.finishAppLoading()
|
||||||
c.storeDefaultKeyPairForNewKeycardUser()
|
c.storeDefaultKeyPairForNewKeycardUser()
|
||||||
c.syncKeycardBasedOnAppWalletStateAfterLogin()
|
c.syncKeycardBasedOnAppWalletStateAfterLogin()
|
||||||
|
c.applyKeycardReplacementAfterLogin()
|
||||||
c.addToKeycardUidPairsToCheckForAChangeAfterLogin(string, string)
|
c.addToKeycardUidPairsToCheckForAChangeAfterLogin(string, string)
|
||||||
c.removeAllKeycardUidPairsForCheckingForAChangeAfterLogin()
|
c.removeAllKeycardUidPairsForCheckingForAChangeAfterLogin()
|
||||||
|
|
|
@ -511,6 +511,9 @@ method storeDefaultKeyPairForNewKeycardUser*[T](self: Module[T]) =
|
||||||
method syncKeycardBasedOnAppWalletStateAfterLogin*[T](self: Module[T]) =
|
method syncKeycardBasedOnAppWalletStateAfterLogin*[T](self: Module[T]) =
|
||||||
self.delegate.syncKeycardBasedOnAppWalletStateAfterLogin()
|
self.delegate.syncKeycardBasedOnAppWalletStateAfterLogin()
|
||||||
|
|
||||||
|
method applyKeycardReplacementAfterLogin*[T](self: Module[T]) =
|
||||||
|
self.delegate.applyKeycardReplacementAfterLogin()
|
||||||
|
|
||||||
method addToKeycardUidPairsToCheckForAChangeAfterLogin*[T](self: Module[T], oldKeycardUid: string, newKeycardUid: string) =
|
method addToKeycardUidPairsToCheckForAChangeAfterLogin*[T](self: Module[T], oldKeycardUid: string, newKeycardUid: string) =
|
||||||
self.delegate.addToKeycardUidPairsToCheckForAChangeAfterLogin(oldKeycardUid, newKeycardUid)
|
self.delegate.addToKeycardUidPairsToCheckForAChangeAfterLogin(oldKeycardUid, newKeycardUid)
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ const SIGNAL_KEYPAIR_SYNCED* = "keypairSynced"
|
||||||
const SIGNAL_KEYPAIR_NAME_CHANGED* = "keypairNameChanged"
|
const SIGNAL_KEYPAIR_NAME_CHANGED* = "keypairNameChanged"
|
||||||
const SIGNAL_NEW_KEYCARD_SET* = "newKeycardSet"
|
const SIGNAL_NEW_KEYCARD_SET* = "newKeycardSet"
|
||||||
const SIGNAL_KEYCARD_DELETED* = "keycardDeleted"
|
const SIGNAL_KEYCARD_DELETED* = "keycardDeleted"
|
||||||
|
const SIGNAL_ALL_KEYCARDS_DELETED* = "allKeycardsDeleted"
|
||||||
const SIGNAL_KEYCARD_ACCOUNTS_REMOVED* = "keycardAccountsRemoved"
|
const SIGNAL_KEYCARD_ACCOUNTS_REMOVED* = "keycardAccountsRemoved"
|
||||||
const SIGNAL_KEYCARD_LOCKED* = "keycardLocked"
|
const SIGNAL_KEYCARD_LOCKED* = "keycardLocked"
|
||||||
const SIGNAL_KEYCARD_UNLOCKED* = "keycardUnlocked"
|
const SIGNAL_KEYCARD_UNLOCKED* = "keycardUnlocked"
|
||||||
|
@ -918,6 +919,19 @@ QtObject:
|
||||||
self.events.emit(SIGNAL_KEYCARD_DELETED, data)
|
self.events.emit(SIGNAL_KEYCARD_DELETED, data)
|
||||||
return data.success
|
return data.success
|
||||||
|
|
||||||
|
proc deleteAllKeycardsWithKeyUid*(self: Service, keyUid: string): bool =
|
||||||
|
var data = KeycardArgs(
|
||||||
|
success: false,
|
||||||
|
keycard: KeycardDto(keyUid: keyUid)
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
let response = backend.deleteAllKeycardsWithKeyUID(keyUid)
|
||||||
|
data.success = responseHasNoErrors("deleteAllKeycardsWithKeyUid", response)
|
||||||
|
except Exception as e:
|
||||||
|
error "error: ", procName="deleteAllKeycardsWithKeyUid", errName = e.name, errDesription = e.msg
|
||||||
|
self.events.emit(SIGNAL_ALL_KEYCARDS_DELETED, data)
|
||||||
|
return data.success
|
||||||
|
|
||||||
proc handleWalletAccount(self: Service, account: WalletAccountDto, notify: bool = true) =
|
proc handleWalletAccount(self: Service, account: WalletAccountDto, notify: bool = true) =
|
||||||
if account.removed:
|
if account.removed:
|
||||||
self.removeAccountFromLocalStoreAndNotify(account.address, notify)
|
self.removeAccountFromLocalStoreAndNotify(account.address, notify)
|
||||||
|
|
|
@ -255,6 +255,9 @@ rpc(updateKeycardUID, "accounts"):
|
||||||
rpc(deleteKeycard, "accounts"):
|
rpc(deleteKeycard, "accounts"):
|
||||||
keycardUid: string
|
keycardUid: string
|
||||||
|
|
||||||
|
rpc(deleteAllKeycardsWithKeyUID, "accounts"):
|
||||||
|
keyUid: string
|
||||||
|
|
||||||
rpc(updateAccountPosition, "accounts"):
|
rpc(updateAccountPosition, "accounts"):
|
||||||
address: string
|
address: string
|
||||||
position: int
|
position: int
|
||||||
|
|
Loading…
Reference in New Issue